From 3a0e4ef864055da28b767c473fa920ba430a6f8b Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 22:31:28 +0200 Subject: [PATCH 001/388] Add files via upload --- src/BankTransaction.php | 100 ++++---------- src/BankTransactionLine.php | 264 ++++++++++++++++++++++++++++++++++++ src/BaseTransaction.php | 12 +- 3 files changed, 294 insertions(+), 82 deletions(-) create mode 100644 src/BankTransactionLine.php diff --git a/src/BankTransaction.php b/src/BankTransaction.php index 068f7773..ff2085d3 100644 --- a/src/BankTransaction.php +++ b/src/BankTransaction.php @@ -6,111 +6,57 @@ use Money\Money; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\LineType; -use PhpTwinfield\Transactions\Transaction; -use PhpTwinfield\Transactions\TransactionFields\AutoBalanceVatField; -use PhpTwinfield\Transactions\TransactionFields\CodeNumberOfficeFields; -use PhpTwinfield\Transactions\TransactionFields\DestinyField; -use PhpTwinfield\Transactions\TransactionFields\FreeTextFields; -use PhpTwinfield\Transactions\TransactionFields\LinesField; -use PhpTwinfield\Transactions\TransactionFields\RaiseWarningField; use PhpTwinfield\Transactions\TransactionFields\StartAndCloseValueFields; use PhpTwinfield\Transactions\TransactionFields\StatementNumberField; -use PhpTwinfield\Transactions\TransactionLineFields\DateField; -use PhpTwinfield\Transactions\TransactionLineFields\PeriodField; -use Webmozart\Assert\Assert; +use PhpTwinfield\Transactions\TransactionLine; /** * @link https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankTransactions */ -class BankTransaction implements Transaction +class BankTransaction extends BaseTransaction { - use DestinyField; - use AutoBalanceVatField; - use PeriodField; - use CodeNumberOfficeFields; - use DateField; use StatementNumberField; - use RaiseWarningField; - - use StartAndCloseValueFields; - - use FreeTextFields; - - use LinesField { - addLine as protected traitAddLine; + use StartAndCloseValueFields { + setCurrency as protected traitSetCurrency; } - /** - * The date/time on which the transaction was created. - * Read-only attribute. - * - * @var \DateTimeImmutable - */ - private $inputDate; - - /** - * The bank transaction origin. - * Read-only attribute. - * - * @var mixed - */ - private $origin; - - /** - * The date/time on which the bank transaction was modified the last time. - * Read-only attribute. - * - * @var \DateTimeInterface - */ - private $modificationDate; - public function __construct() { - $this->currency = new Currency("EUR"); - $this->startvalue = new Money(0, $this->getCurrency()); + $this->startvalue = new Money(0, new Currency('EUR')); } + /** + * @return string + */ public function getLineClassName(): string { - return Transactions\BankTransactionLine\Base::class; + return BankTransactionLine::class; } /** - * The bank transaction origin. - * Read-only attribute. + * Set the currency. Can only be done when the start value is still 0. * - * @return mixed + * @param Currency $currency + * @return $this */ - public function getOrigin() - { - return $this->origin; - } - - public function getInputDate(): \DateTimeInterface + public function setCurrency(?Currency $currency): BaseTransaction { - return $this->inputDate; + $this->traitSetCurrency($currency); + return $this; } - public function addLine(Transactions\BankTransactionLine\Base $line): void + /** + * @param TransactionLine $line + * @return $this + */ + public function addLine(TransactionLine $line) { - Assert::notEmpty($this->startvalue); - - /* - * Max is 500 lines. - */ - Assert::lessThan($this->getLineCount(), 500); - - /* - * Calls the addLine() method on the LinesField trait. Uses an alias in the `use` statement at top of this - * class, because parent::addLine() doesn't work for traits. - */ - $this->traitAddLine($line); + parent::addLine($line); + /** @var BankTransactionLine $line */ if (!$line->getLineType()->equals(LineType::TOTAL())) { /* * Don't add total lines to the closevalue, they are summaries of the details and vat lines. - * - * @link https://github.com/php-twinfield/twinfield/issues/39 */ if ($line->getDebitCredit()->equals(DebitCredit::CREDIT())) { $this->closevalue = $this->getClosevalue()->add($line->getValue()); @@ -118,5 +64,7 @@ public function addLine(Transactions\BankTransactionLine\Base $line): void $this->closevalue = $this->getClosevalue()->subtract($line->getValue()); } } + + return $this; } } diff --git a/src/BankTransactionLine.php b/src/BankTransactionLine.php new file mode 100644 index 00000000..24aa0c91 --- /dev/null +++ b/src/BankTransactionLine.php @@ -0,0 +1,264 @@ +transaction, 'Attempting to set a transaction while the transaction is already set.'); + Assert::isInstanceOf($object, BankTransaction::class); + $this->transaction = $object; + } + + /** + * References the transaction this line belongs too. + * + * @return BankTransaction + */ + public function getTransaction(): BankTransaction + { + return $this->transaction; + } + + /** + * If line type = total the bank balance account. + * + * If line type = detail the customer or supplier balance account or profit and loss account. + * + * If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account + * will be taken as entered at the VAT code in Twinfield. + * + * @param string|null $dim1 + * @return $this + */ + public function setDim1(?string $dim1): BaseTransactionLine + { + return parent::setDim1($dim1); + } + + /** + * If line type = total empty. + * + * If line type = detail the customer or supplier or the cost center or empty. + * + * If line type = vat empty. + * + * @param string|null $dim2 + * @return $this + * @throws Exception + */ + public function setDim2(?string $dim2): BaseTransactionLine + { + if ($dim2 !== null && + ($this->getLineType()->equals(LineType::VAT()) || $this->getLineType()->equals(LineType::TOTAL()))) { + throw Exception::invalidDimensionForLineType(2, $this); + } + + return parent::setDim2($dim2); + } + + /** + * If line type = total empty. + * + * If line type = detail the project or asset or empty. + * + * If line type = vat empty. + * + * @param string|null $dim3 + * @return $this + * @throws Exception + */ + public function setDim3(?string $dim3): BaseTransactionLine + { + if ($dim3 !== null && + ($this->getLineType()->equals(LineType::VAT()) || $this->getLineType()->equals(LineType::TOTAL()))) { + throw Exception::invalidDimensionForLineType(3, $this); + } + + return parent::setDim3($dim3); + } + + /** + * If line type = total, based on the sum of the individual bank transaction lines. + * - In case of a bank addition debit. + * - In case of a bank withdrawal credit. + * + * If line type = detail + * - In case money is received credit. + * - In case money is paid debit. + * + * If line type = vat, based on the sum of the vat amounts of the individual bank transaction lines. + * - In case of a bank addition credit. + * - In case of a bank withdrawal debit. + * + * @param DebitCredit::DEBIT() $debitCredit + * @return $this + */ + public function setDebitCredit(DebitCredit $debitCredit): BaseTransactionLine + { + return parent::setDebitCredit($debitCredit); + } + + /** + * If line type = total amount including VAT. + * + * If line type = detail amount without VAT. + * + * If line type = vat VAT amount. + * + * @param Money $value + * @return $this + */ + public function setValue(Money $value): BaseTransactionLine + { + return parent::setValue($value); + } + + /** + * Payment status of the bank transaction. If line type total or vat always notmatchable. Read-only attribute. + * + * @param string|null $matchStatus + * @return $this + * @throws Exception + */ + public function setMatchStatus(?string $matchStatus): BaseTransactionLine + { + if ( + $matchStatus !== null && + in_array($this->getLineType(), [LineType::TOTAL(), LineType::VAT()]) && + $matchStatus != self::MATCHSTATUS_NOTMATCHABLE + ) { + throw Exception::invalidMatchStatusForLineType($matchStatus, $this); + } + + return parent::setMatchStatus($matchStatus); + } + + /** + * Only if line type is detail. The level of the matchable dimension. Read-only attribute. + * + * @param int|null $matchLevel + * @return $this + * @throws Exception + */ + public function setMatchLevel(?int $matchLevel): BaseTransactionLine + { + if ($matchLevel !== null && !$this->getLineType()->equals(LineType::DETAIL())) { + throw Exception::invalidFieldForLineType('matchLevel', $this); + } + + return parent::setMatchLevel($matchLevel); + } + + /** + * Only if line type is detail. The amount still owed in base currency. Read-only attribute. + * + * @param Money|null $baseValueOpen + * @return $this + * @throws Exception + */ + public function setBaseValueOpen(?Money $baseValueOpen): BaseTransactionLine + { + if ($baseValueOpen !== null && !$this->getLineType()->equals(LineType::DETAIL())) { + throw Exception::invalidFieldForLineType('baseValueOpen', $this); + } + + return parent::setBaseValueOpen($baseValueOpen); + } + + /** + * Only if line type is vat. Amount on which VAT was calculated in the currency of the sales transaction. + * + * @param Money|null $vatTurnover + * @return $this + * @throws Exception + */ + public function setVatTurnover(?Money $vatTurnover): BaseTransactionLine + { + if (!$this->getLineType()->equals(LineType::VAT())) { + throw Exception::invalidFieldForLineType('vatturnover', $this); + } + return parent::setVatTurnOver($vatTurnover); + } + + /** + * Only if line type is vat. Amount on which VAT was calculated in base currency. + * + * @param Money|null $vatBaseTurnover + * @return $this + * @throws Exception + */ + public function setVatBaseTurnover(?Money $vatBaseTurnover): BaseTransactionLine + { + if (!$this->getLineType()->equals(LineType::VAT())) { + throw Exception::invalidFieldForLineType('vatbaseturnover', $this); + } + return parent::setVatBaseTurnover($vatBaseTurnover); + } + + /** + * Only if line type is vat. Amount on which VAT was calculated in reporting currency. + * + * @param Money|null $vatRepTurnover + * @return $this + * @throws Exception + */ + public function setVatRepTurnover(?Money $vatRepTurnover): BaseTransactionLine + { + if (!$this->getLineType()->equals(LineType::VAT())) { + throw Exception::invalidFieldForLineType('vatrepturnover', $this); + } + return parent::setVatRepTurnover($vatRepTurnover); + } + + /** + * @param string|null $invoiceNumber + * @return $this + * @throws Exception + */ + public function setInvoiceNumber(?string $invoiceNumber) + { + if (!$this->getLineType()->equals(LineType::DETAIL())) { + throw Exception::invalidFieldForLineType('invoicenumber', $this); + } + + return $this->traitSetInvoiceNumber($invoiceNumber); + } + + /** + * Returns true if a positive amount in the TOTAL line means the amount is 'debit'. Examples of incoming transaction + * types are Sales Transactions, Electronic Bank Statements and Bank Transactions. + * + * Returns false if a positive amount in the TOTAL line means the amount is 'credit'. An example of an outgoing + * transaction type is a Purchase Transaction. + * + * @return bool + */ + protected function isIncomingTransactionType(): bool + { + return true; + } +} diff --git a/src/BaseTransaction.php b/src/BaseTransaction.php index bbdc4dc2..00db0a78 100644 --- a/src/BaseTransaction.php +++ b/src/BaseTransaction.php @@ -14,20 +14,20 @@ use PhpTwinfield\Transactions\TransactionLineFields\PeriodField; /** - * @todo $modificationDate The date/time on which the sales transaction was modified the last time. Read-only attribute. - * @todo $user The user who created the sales transaction. Read-only attribute. + * @todo $modificationDate The date/time on which the transaction was modified the last time. Read-only attribute. + * @todo $user The user who created the transaction. Read-only attribute. * @todo $inputDate The date/time on which the transaction was created. Read-only attribute. */ abstract class BaseTransaction extends BaseObject implements Transaction { - use DestinyField; use AutoBalanceVatField; use CodeNumberOfficeFields; - use PeriodField; + use DestinyField; use FreeTextFields; - use DateField; - use RaiseWarningField; use LinesField; + use RaiseWarningField; + use DateField; + use PeriodField; /** * @var Currency|null The currency. From 723dc8289f4fca0e4aa0d1bfa0159e5394d25f16 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 22:31:50 +0200 Subject: [PATCH 002/388] Add files via upload --- src/Transactions/TransactionLine.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Transactions/TransactionLine.php b/src/Transactions/TransactionLine.php index 4ebf3898..a72142ae 100644 --- a/src/Transactions/TransactionLine.php +++ b/src/Transactions/TransactionLine.php @@ -2,7 +2,6 @@ namespace PhpTwinfield\Transactions; -use PhpTwinfield\BankTransaction; use PhpTwinfield\Enums\LineType; use PhpTwinfield\MatchReferenceInterface; From ebbdc0ec64933cf23e391ed0040dbde74945460b Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 22:32:16 +0200 Subject: [PATCH 003/388] Add files via upload From 3033e40e6e00a66c0cee7add8181ec0d3ce32dd7 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 22:32:42 +0200 Subject: [PATCH 004/388] Add files via upload From c6f4d3d130b2b7875b8f9d043728aeffd89d2178 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 22:32:58 +0200 Subject: [PATCH 005/388] Delete Base.php --- src/Transactions/BankTransactionLine/Base.php | 165 ------------------ 1 file changed, 165 deletions(-) delete mode 100644 src/Transactions/BankTransactionLine/Base.php diff --git a/src/Transactions/BankTransactionLine/Base.php b/src/Transactions/BankTransactionLine/Base.php deleted file mode 100644 index 7d922205..00000000 --- a/src/Transactions/BankTransactionLine/Base.php +++ /dev/null @@ -1,165 +0,0 @@ -transaction; - } - - /** - * @param BankTransaction $object - */ - public function setTransaction($object): void - { - Assert::null($this->transaction, "Attempting to set a transaction while the transaction is already set."); - Assert::isInstanceOf($object, BankTransaction::class); - $this->transaction = $object; - } - - /** - * @return LineType - */ - final public function getLineType(): LineType - { - return $this->lineType; - } - - /** - * @param LineType $lineType - * @return $this - */ - final protected function setLineType(LineType $lineType) - { - $this->lineType = $lineType; - return $this; - } - - /** - * @return string - */ - public function getDescription(): ?string - { - return $this->description; - } - - /** - * @param string $description - * @return $this - */ - public function setDescription(string $description) - { - $this->description = $description; - return $this; - } - - /** - * @return null|Office - */ - public function getDestOffice(): ?Office - { - return $this->destOffice; - } - - /** - * Used for inter company transactions – here you define in which company the transaction line should be posted. - * - * @param Office $destOffice - * @return $this - */ - public function setDestOffice(Office $destOffice) - { - $this->destOffice = $destOffice; - return $this; - } - - public function getId(): ?int - { - return $this->id; - } - - /** - * @param int $id - * @return $this - */ - public function setId(int $id) - { - $this->id = $id; - return $this; - } - - public function getReference(): MatchReferenceInterface - { - $transaction = $this->getTransaction(); - - return new MatchReference( - $transaction->getOffice(), - $transaction->getCode(), - $transaction->getNumber(), - $this->getId() - ); - } - - protected function isIncomingTransactionType(): bool - { - return true; - } -} From 8a88ac0a8a47f2d5af72ce9355063ed98f955cc7 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 22:33:04 +0200 Subject: [PATCH 006/388] Delete Detail.php --- .../BankTransactionLine/Detail.php | 153 ------------------ 1 file changed, 153 deletions(-) delete mode 100644 src/Transactions/BankTransactionLine/Detail.php diff --git a/src/Transactions/BankTransactionLine/Detail.php b/src/Transactions/BankTransactionLine/Detail.php deleted file mode 100644 index 772784e8..00000000 --- a/src/Transactions/BankTransactionLine/Detail.php +++ /dev/null @@ -1,153 +0,0 @@ -vatValue = $vatValue; - - return $this; - } - - /** - * @param Money $vatBaseValue - * @return Detail - */ - public function setVatBaseValue(Money $vatBaseValue): Detail - { - $this->vatBaseValue = $vatBaseValue; - - return $this; - } - - /** - * @param Money $vatRepValue - * @return Detail - */ - public function setVatRepValue(Money $vatRepValue): Detail - { - $this->vatRepValue = $vatRepValue; - - return $this; - } - - /** - * VAT amount in base currency. - * - * @var Money|null - */ - private $vatBaseValue; - - /** - * VAT amount in reporting currency. - * - * @var Money|null - */ - private $vatRepValue; - - public function __construct() - { - $this->setLineType(LineType::DETAIL()); - } - - /** - * Set the customer or supplier balance account or profit and loss account. - * - * @param string $dim1 - * @return $this - */ - public function setAccount(string $dim1) - { - return $this->setDim1($dim1); - } - - /** - * Set the customer or supplier or the cost center or empty. - * - * @param string $dim2 - * @return $this - */ - public function setCustomerOrSupplierOrCostCenter(string $dim2) - { - return $this->setDim2($dim2); - } - - /** - * Set the project or asset or empty. - * - * @param string $dim3 - * @return $this - */ - public function setProjectOrAsset(string $dim3) - { - return $this->setDim3($dim3); - } - - /** - * Credit in case money is received and debit in case money is paid. - * - * @param DebitCredit $debitCredit - * @return Detail - */ - public function setDebitCredit(DebitCredit $debitCredit): self - { - return parent::setDebitCredit($debitCredit); - } - - /** - * Amount without VAT. - * - * @param Money $money - */ - public function setValue(Money $money): void - { - parent::setValue($money); - } - - - /** - * @return Money|null - */ - public function getVatValue(): ?Money - { - return $this->vatValue; - } - - /** - * @return Money|null - */ - public function getVatBaseValue(): ?Money - { - return $this->vatBaseValue; - } - - /** - * @return Money|null - */ - public function getVatRepValue(): ?Money - { - return $this->vatRepValue; - } -} \ No newline at end of file From d58d145191c728e0ca51271f13f34ec53ccc546f Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 22:33:10 +0200 Subject: [PATCH 007/388] Delete Total.php --- .../BankTransactionLine/Total.php | 115 ------------------ 1 file changed, 115 deletions(-) delete mode 100644 src/Transactions/BankTransactionLine/Total.php diff --git a/src/Transactions/BankTransactionLine/Total.php b/src/Transactions/BankTransactionLine/Total.php deleted file mode 100644 index 176312c0..00000000 --- a/src/Transactions/BankTransactionLine/Total.php +++ /dev/null @@ -1,115 +0,0 @@ -setLineType(LineType::TOTAL()); - } - - public function setBankBalanceAccount(string $dim1) - { - $this->setDim1($dim1); - } - - /** - * Based on the sum of the individual bank transaction lines. In case of a bank addition debit. In case of a bank - * withdrawal credit. - * - * @param DebitCredit $debitCredit - * @return $this - */ - public function setDebitCredit(DebitCredit $debitCredit) - { - return parent::setDebitCredit($debitCredit); - } - - /** - * Amount including VAT. - * - * @param Money $money - */ - public function setValue(Money $money): void - { - parent::setValue($money); - } - - /** - * @return Money|null - */ - public function getVatTotal(): ?Money - { - return $this->vatTotal; - } - - /** - * The total VAT amount in the currency of the bank transaction. - * - * @param Money $vatTotal - */ - public function setVatTotal(Money $vatTotal): void - { - $this->vatTotal = $vatTotal; - } - - /** - * @return Money|null - */ - public function getVatBaseTotal(): ?Money - { - return $this->vatBaseTotal; - } - - /** - * The total VAT amount in base currency. - * - * @param Money $vatBaseTotal - */ - public function setVatBaseTotal(Money $vatBaseTotal): void - { - $this->vatBaseTotal = $vatBaseTotal; - } - - /** - * @return Money|null - */ - public function getVatRepTotal(): ?Money - { - return $this->vatRepTotal; - } - - /** - * @param Money $vatRepTotal - */ - public function setVatRepTotal(Money $vatRepTotal): void - { - $this->vatRepTotal = $vatRepTotal; - } -} \ No newline at end of file From 13cd45df422de19f1d9e720262d4c80bfcd98640 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 22:33:15 +0200 Subject: [PATCH 008/388] Delete Vat.php --- src/Transactions/BankTransactionLine/Vat.php | 55 -------------------- 1 file changed, 55 deletions(-) delete mode 100644 src/Transactions/BankTransactionLine/Vat.php diff --git a/src/Transactions/BankTransactionLine/Vat.php b/src/Transactions/BankTransactionLine/Vat.php deleted file mode 100644 index 23315220..00000000 --- a/src/Transactions/BankTransactionLine/Vat.php +++ /dev/null @@ -1,55 +0,0 @@ -setLineType(LineType::VAT()); - } - - /** - * Set the VAT balance account. When an empty dim1 is entered, by default the general ledger account will be taken - * as entered at the VAT code in Twinfield. - * - * @param string $dim1 - */ - public function setVatBalanceAccount(string $dim1) - { - $this->setDim1($dim1); - } - - /** - * Based on the sum of the vat amounts of the individual bank transaction lins. In case of a bank addition credit. - * In case of a bank withdrawal debit. - * - * @param DebitCredit $debitCredit - * @return Vat - */ - public function setDebitCredit(DebitCredit $debitCredit): self - { - return parent::setDebitCredit($debitCredit); - } - - /** - * VAT amount. - * - * @param Money $money - */ - public function setValue(Money $money): void - { - parent::setValue($money); - } -} \ No newline at end of file From c6c37d80d177ae9d663d81b23cdbbc3caeaf9c51 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 22:33:27 +0200 Subject: [PATCH 009/388] Add files via upload From 08bda326a91a243692894d8dbac71463564bbef3 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 22:33:38 +0200 Subject: [PATCH 010/388] Add files via upload --- src/Mappers/TransactionMapper.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index cd928ae5..081d6338 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -4,6 +4,7 @@ use Money\Currency; use Money\Money; +use PhpTwinfield\BankTransaction; use PhpTwinfield\BaseTransaction; use PhpTwinfield\BaseTransactionLine; use PhpTwinfield\CashTransaction; @@ -134,7 +135,9 @@ public static function map(string $transactionClassName, Response $response): Ba // Parse the transaction lines $transactionLineClassName = $transaction->getLineClassName(); - foreach ($transactionElement->getElementsByTagName('line') as $lineElement) { + $linesElement = $transactionElement->getElementsByTagName('lines')->item(0); + + foreach ($linesElement->childNodes as $lineElement) { self::checkForMessage($transaction, $lineElement); /** @var BaseTransactionLine $transactionLine */ From 415c04bff9545e3b873f600254bb469d6b1307a6 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 22:33:50 +0200 Subject: [PATCH 011/388] Add files via upload --- src/DomDocuments/TransactionsDocument.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/DomDocuments/TransactionsDocument.php b/src/DomDocuments/TransactionsDocument.php index 2e0d9a9b..79bc7ef4 100644 --- a/src/DomDocuments/TransactionsDocument.php +++ b/src/DomDocuments/TransactionsDocument.php @@ -2,6 +2,7 @@ namespace PhpTwinfield\DomDocuments; +use PhpTwinfield\BankTransaction; use PhpTwinfield\BaseTransaction; use PhpTwinfield\BaseTransactionLine; use PhpTwinfield\CashTransaction; From d1d39dd195c857f10a9d1788e0521e64c3e79f64 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 22:34:02 +0200 Subject: [PATCH 012/388] Delete BankTransactionMapper.php --- src/Mappers/BankTransactionMapper.php | 206 -------------------------- 1 file changed, 206 deletions(-) delete mode 100644 src/Mappers/BankTransactionMapper.php diff --git a/src/Mappers/BankTransactionMapper.php b/src/Mappers/BankTransactionMapper.php deleted file mode 100644 index d4b5f027..00000000 --- a/src/Mappers/BankTransactionMapper.php +++ /dev/null @@ -1,206 +0,0 @@ -documentElement; - - if (!empty($element->getAttribute("autobalancevat"))) { - $bankTransaction->setAutoBalanceVat(Util::parseBoolean($element->getAttribute("autobalancevat"))); - } - - if (!empty($element->getAttribute("raisewarning"))) { - $bankTransaction->setRaiseWarning(Util::parseBoolean($element->getAttribute("raisewarning"))); - } - - self::setFromTagValue($document, "code", [$bankTransaction, "setCode"]); - self::setFromTagValue($document, "office", [$bankTransaction, "setOffice"]); - self::setFromTagValue($document, "date", [$bankTransaction, "setDate"]); - self::setFromTagValue($document, "period", [$bankTransaction, "setPeriod"]); - self::setFromTagValue($document, "startvalue", [$bankTransaction, "setStartValue"]); - - self::setFromTagValue($document, "statementnumber", [$bankTransaction, "setStatementNumber"]); - self::setFromTagValue($document, "number", [$bankTransaction, "setNumber"]); - - /** @var \DOMElement $lineElement */ - foreach ($element->getElementsByTagName("line") as $lineElement) { - switch ($lineElement->getAttribute("type")) { - case LineType::TOTAL(): - $bankTransaction->addLine(self::createTotalBankTransactionLine($bankTransaction, $lineElement)); - break; - case LineType::DETAIL(): - $bankTransaction->addLine(self::createDetailBankTransactionLine($bankTransaction, $lineElement)); - break; - case LineType::VAT(): - $bankTransaction->addLine(self::createVatBankTransactionLine($bankTransaction, $lineElement)); - break; - } - } - - return $bankTransaction; - } - - private static function createTotalBankTransactionLine(BankTransaction $bankTransaction, \DOMElement $lineElement): Total - { - $line = new Total(); - self::setBankTransactionLineBaseFields($bankTransaction, $lineElement, $line); - - $line->setBankBalanceAccount(self::getField($lineElement, "dim1")); - - $vatTotal = self::getField($lineElement, "vattotal"); - if ($vatTotal) { - $line->setVatTotal(Util::parseMoney($vatTotal, $bankTransaction->getCurrency())); - } - $vatBaseTotal = self::getField($lineElement, "vatbasetotal"); - if ($vatBaseTotal) { - $line->setVatBaseTotal(Util::parseMoney($vatBaseTotal, $bankTransaction->getCurrency())); - } - $vatRepTotal = self::getField($lineElement, "vatreptotal"); - if ($vatRepTotal) { - $line->setVatRepTotal(Util::parseMoney($vatRepTotal, $bankTransaction->getCurrency())); - } - - return $line; - } - - private static function createDetailBankTransactionLine(BankTransaction $bankTransaction, \DOMElement $lineElement): Detail - { - $line = new Detail(); - self::setBankTransactionLineBaseFields($bankTransaction, $lineElement, $line); - self::setBankTransactionLinePerformanceFields($lineElement, $line); - - $line->setAccount(self::getField($lineElement, "dim1")); - - $customerOrSupplierOrCostCenter = self::getField($lineElement, "dim2"); - if ($customerOrSupplierOrCostCenter !== null) { - $line->setCustomerOrSupplierOrCostCenter($customerOrSupplierOrCostCenter); - } - $vatCode = self::getField($lineElement, "vatcode"); - if ($vatCode !== null) { - $line->setVatCode($vatCode); - } - $vatValue = self::getField($lineElement, "vatvalue"); - if ($vatValue) { - $line->setVatValue(Util::parseMoney($vatValue, $bankTransaction->getCurrency())); - } - $vatBaseValue = self::getField($lineElement, "vatbasevalue"); - if ($vatBaseValue) { - $line->setVatBaseValue(Util::parseMoney($vatBaseValue, $bankTransaction->getCurrency())); - } - $vatRepValue = self::getField($lineElement, "vatrepvalue"); - if ($vatRepValue) { - $line->setVatRepValue(Util::parseMoney($vatRepValue, $bankTransaction->getCurrency())); - } - $projectOrAsset = self::getField($lineElement, "dim3"); - if ($projectOrAsset !== null) { - $line->setProjectOrAsset($projectOrAsset); - } - - return $line; - } - - private static function createVatBankTransactionLine(BankTransaction $bankTransaction, \DOMElement $lineElement): Vat - { - $line = new Vat(); - self::setBankTransactionLineBaseFields($bankTransaction, $lineElement, $line); - self::setBankTransactionLinePerformanceFields($lineElement, $line); - - $vatTurnover = self::getField($lineElement, "vatturnover"); - $line->setVatTurnover(Util::parseMoney($vatTurnover, $bankTransaction->getCurrency())); - $vatBaseTurnover = self::getField($lineElement, "vatbaseturnover"); - $line->setVatBaseTurnover(Util::parseMoney($vatBaseTurnover, $bankTransaction->getCurrency())); - - $vatRepTurnover = self::getField($lineElement, "vatrepturnover"); - if ($vatRepTurnover) { - $line->setVatRepTurnover(Util::parseMoney($vatRepTurnover, $bankTransaction->getCurrency())); - } - $vatCode = self::getField($lineElement, "vatcode"); - if ($vatCode !== null) { - $line->setVatCode($vatCode); - } - $vatBalanceAccount = self::getField($lineElement, "dim1"); - if ($vatBalanceAccount !== null) { - $line->setVatBalanceAccount($vatBalanceAccount); - } - - return $line; - } - - private static function setBankTransactionLineBaseFields( - BankTransaction $bankTransaction, - \DOMElement $lineElement, - Base $line - ): void { - /* - * When a bank transaction fails, it isn't created at Twinfield, so it is likely that they haven't generated - * any ids for the lines. - */ - $id = $lineElement->getAttribute("id"); - if (!empty($id)) { - $line->setId($id); - } - - $value = self::getField($lineElement, 'value'); - $line->setValue(Util::parseMoney($value, $bankTransaction->getCurrency())); - $line->setInvoiceNumber(self::getField($lineElement, "invoicenumber")); - - $description = self::getField($lineElement, "description"); - if ($description !== null) { - $line->setDescription($description); - } - $debitCredit = self::getField($lineElement, 'debitcredit'); - if ($debitCredit) { - $line->setDebitCredit(new DebitCredit($debitCredit)); - } - $destOffice = self::getField($lineElement, "destoffice"); - if ($destOffice) { - $line->setDestOffice(Office::fromCode($destOffice)); - } - $freeChar = self::getField($lineElement, "freechar"); - if ($freeChar) { - $line->setFreeChar($freeChar); - } - $comment = self::getField($lineElement, "comment"); - if ($comment !== null) { - $line->setComment($comment); - } - } - - private static function setBankTransactionLinePerformanceFields(\DOMElement $lineElement, Base $line): void - { - $performanceType = self::getField($lineElement, "performancetype"); - if ($performanceType) { - $line->setPerformanceType(new PerformanceType($performanceType)); - } - $performanceCountry = self::getField($lineElement, "performancecountry"); - if ($performanceCountry) { - $line->setPerformanceCountry($performanceCountry); - } - $performanceVatNumber = self::getField($lineElement, "performancevatnumber"); - if ($performanceVatNumber !== null) { - $line->setPerformanceVatNumber($performanceVatNumber); - } - $performanceDate = self::getField($lineElement, "performancedate"); - if ($performanceDate) { - $line->setPerformanceDate($performanceDate); - } - } -} \ No newline at end of file From 9b4b6de4a1a9987d8e3b2502d9507bab64fb804e Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 22:34:11 +0200 Subject: [PATCH 013/388] Delete BankTransactionDocument.php --- src/DomDocuments/BankTransactionDocument.php | 180 ------------------- 1 file changed, 180 deletions(-) delete mode 100644 src/DomDocuments/BankTransactionDocument.php diff --git a/src/DomDocuments/BankTransactionDocument.php b/src/DomDocuments/BankTransactionDocument.php deleted file mode 100644 index 0c13d577..00000000 --- a/src/DomDocuments/BankTransactionDocument.php +++ /dev/null @@ -1,180 +0,0 @@ -createElement("transaction"); - - $transaction->appendChild(new \DOMAttr("destiny", $bankTransaction->getDestiny())); - - if ($bankTransaction->isAutoBalanceVat() !== null) { - $transaction->appendChild( - $this->createBooleanAttribute("autobalancevat", $bankTransaction->isAutoBalanceVat()) - ); - } - - if ($bankTransaction->getRaiseWarning() !== null) { - $transaction->appendChild( - $this->createBooleanAttribute("raisewarning", $bankTransaction->getRaiseWarning()) - ); - } - - $header = $this->createElement("header"); - - if ($bankTransaction->getCode() !== null) { - $header->appendChild($this->createNodeWithTextContent("code", $bankTransaction->getCode())); - } - - $header->appendChild($this->createNodeWithTextContent("office", $bankTransaction->getOffice())); - - if ($bankTransaction->getNumber() !== null) { - $header->appendChild($this->createNodeWithTextContent("number", $bankTransaction->getNumber())); - } - - if ($bankTransaction->getPeriod() !== null) { - $header->appendChild($this->createNodeWithTextContent("period", $bankTransaction->getPeriod())); - } - - if ($bankTransaction->getDate() !== null) { - $this->appendDateElement($header, "date", $bankTransaction->getDate()); - } - - if ($bankTransaction->getStatementnumber() !== null) { - $header->appendChild($this->createNodeWithTextContent("statementnumber", $bankTransaction->getStatementnumber())); - } - - $this->appendStartCloseValues($header, $bankTransaction); - - $this->appendFreeTextFields($header, $bankTransaction); - $transaction->appendChild($header); - - $lines = $this->createElement("lines"); - $transaction->appendChild($lines); - - foreach ($bankTransaction->getLines() as $line) { - $lines->appendChild($this->createTransactionLineElement($line)); - } - - $this->rootElement->appendChild($transaction); - } - - protected function createTransactionLineElement(BankTransactionLine\Base $line): \DOMElement - { - $transaction = $this->createElement("line"); - $transaction->appendChild(new \DOMAttr("type", $line->getLineType())); - - if ($line->getId() !== null) { - $transaction->appendChild(new \DOMAttr("id", $line->getId())); - } - - if ($line->getDim1() !== null) { - $transaction->appendChild($this->createNodeWithTextContent("dim1", $line->getDim1())); - } - - if ($line->getDim2() !== null) { - $transaction->appendChild($this->createNodeWithTextContent("dim2", $line->getDim2())); - } - - if ($line->getDim3() !== null) { - $transaction->appendChild($this->createNodeWithTextContent("dim3", $line->getDim3())); - } - - $this->appendValueValues($transaction, $line); - - if ($line->getInvoiceNumber() !== null) { - $transaction->appendChild($this->createNodeWithTextContent("invoicenumber", $line->getInvoiceNumber())); - } - - if ($line->getDescription()) { - $transaction->appendChild($this->createNodeWithTextContent("description", $line->getDescription())); - } - - if ($line instanceof BankTransactionLine\Total) { - if ($line->getVatTotal() !== null) { - $transaction->appendChild($this->createNodeWithTextContent("vattotal", Util::formatMoney($line->getVatTotal()))); - } - - if ($line->getVatBaseTotal() !== null) { - $transaction->appendChild($this->createNodeWithTextContent("vatbasetotal", Util::formatMoney($line->getVatBaseTotal()))); - } - - if ($line->getVatRepTotal() !== null) { - $transaction->appendChild($this->createNodeWithTextContent("vatreptotal", Util::formatMoney($line->getVatRepTotal()))); - } - } - - if ($line instanceof BankTransactionLine\Vat || $line instanceof BankTransactionLine\Detail) { - if ($line->getVatCode() !== null) { - $transaction->appendChild($this->createNodeWithTextContent("vatcode", $line->getVatCode())); - } - } - - if ($line instanceof BankTransactionLine\Detail) { - if ($line->getVatValue() !== null) { - $transaction->appendChild($this->createNodeWithTextContent("vatvalue", Util::formatMoney($line->getVatValue()))); - } - - if ($line->getVatBaseValue() !== null) { - $transaction->appendChild($this->createNodeWithTextContent("vatbasevalue", Util::formatMoney($line->getVatBaseValue()))); - } - - if ($line->getVatRepValue() !== null) { - $transaction->appendChild($this->createNodeWithTextContent("vatrepvalue", Util::formatMoney($line->getVatRepValue()))); - } - } - - if ($line instanceof BankTransactionLine\Vat) { - - if ($line->getVatTurnover() !== null) { - $transaction->appendChild($this->createNodeWithTextContent("vatturnover", Util::formatMoney($line->getVatTurnover()))); - } - if ($line->getVatBaseTurnover() !== null) { - $transaction->appendChild($this->createNodeWithTextContent("vatbaseturnover", Util::formatMoney($line->getVatBaseTurnover()))); - } - if ($line->getVatRepTurnover() !== null) { - $transaction->appendChild($this->createNodeWithTextContent("vatrepturnover", Util::formatMoney($line->getVatRepTurnover()))); - } - } - - if ($line instanceof BankTransactionLine\Detail || $line instanceof BankTransactionLine\Vat) { - $this->appendPerformanceTypeFields($transaction, $line); - } - - if ($line->getDestOffice() !== null) { - $transaction->appendChild($this->createNodeWithTextContent("destoffice", $line->getDestOffice())); - } - - if ($line->getFreeChar()) { - $transaction->appendChild($this->createNodeWithTextContent("freechar", $line->getFreeChar())); - } - - if ($line->getComment()) { - $transaction->appendChild($this->createNodeWithTextContent("comment", $line->getComment())); - } - - return $transaction; - } -} \ No newline at end of file From f295ea554654247b72f2cd1b9548ad93248e7368 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 22:34:20 +0200 Subject: [PATCH 014/388] Add files via upload --- src/ApiConnectors/TransactionsDocument.php | 241 +++++++++++++++++++++ 1 file changed, 241 insertions(+) create mode 100644 src/ApiConnectors/TransactionsDocument.php diff --git a/src/ApiConnectors/TransactionsDocument.php b/src/ApiConnectors/TransactionsDocument.php new file mode 100644 index 00000000..79bc7ef4 --- /dev/null +++ b/src/ApiConnectors/TransactionsDocument.php @@ -0,0 +1,241 @@ + + */ +class TransactionsDocument extends BaseDocument +{ + final protected function getRootTagName(): string + { + return "transactions"; + } + + /** + * Turns a passed Transaction class into the required markup for interacting + * with Twinfield. + * + * This method doesn't return anything, instead just adds the transaction + * to this DOMDocument instance for submission usage. + * + * @param BaseTransaction $transaction + */ + public function addTransaction(BaseTransaction $transaction) + { + // Transaction + $transactionElement = $this->createElement('transaction'); + $transactionElement->setAttribute('destiny', $transaction->getDestiny()); + if ($transaction->getRaiseWarning() !== null) { + $transactionElement->appendChild($this->createBooleanAttribute('raisewarning', $transaction->getRaiseWarning())); + } + if ($transaction->isAutoBalanceVat() !== null) { + $transactionElement->appendChild($this->createBooleanAttribute('autobalancevat', $transaction->isAutoBalanceVat())); + } + + $this->rootElement->appendChild($transactionElement); + + // Header + $headerElement = $this->createElement('header'); + $transactionElement->appendChild($headerElement); + + $codeElement = $this->createNodeWithTextContent('code', $transaction->getCode()); + $headerElement->appendChild($codeElement); + + if ($transaction->getNumber() !== null) { + $numberElement = $this->createNodeWithTextContent('number', $transaction->getNumber()); + $headerElement->appendChild($numberElement); + } + + if ($transaction->getCurrency() !== null) { + $currencyElement = $this->createNodeWithTextContent('currency', $transaction->getCurrency()); + $headerElement->appendChild($currencyElement); + } + + $this->appendDateElement($headerElement, "date", $transaction->getDate()); + + if ($transaction->getPeriod() !== null) { + $periodElement = $this->createNodeWithTextContent('period', $transaction->getPeriod()); + $headerElement->appendChild($periodElement); + } + + if ( + in_array(InvoiceNumberField::class, class_uses($transaction)) && + $transaction->getInvoiceNumber() !== null + ) { + $invoiceNumberElement = $this->createNodeWithTextContent('invoicenumber', $transaction->getInvoiceNumber()); + $headerElement->appendChild($invoiceNumberElement); + } + + if ( + in_array(PaymentReferenceField::class, class_uses($transaction)) && + $transaction->getPaymentReference() !== null + ) { + $paymentReferenceElement = $this->createNodeWithTextContent('paymentreference', $transaction->getPaymentReference()); + $headerElement->appendChild($paymentReferenceElement); + } + + $officeElement = $this->createNodeWithTextContent('office', $transaction->getOffice()); + $headerElement->appendChild($officeElement); + + if (Util::objectUses(DueDateField::class, $transaction) && + $transaction->getDueDate() !== null + ) { + $this->appendDateElement($headerElement, "duedate", $transaction->getDueDate()); + } + + if (Util::objectUses(StatementNumberField::class, $transaction) && + $transaction->getStatementnumber() !== null) { + $headerElement->appendChild($this->createNodeWithTextContent('statementnumber', $transaction->getStatementnumber())); + } + + if ($transaction instanceof CashTransaction) { + $headerElement->appendChild($this->createNodeWithTextContent('startvalue', Util::formatMoney($transaction->getStartvalue()))); + $headerElement->appendChild($this->createNodeWithTextContent('closevalue', Util::formatMoney($transaction->getClosevalue()))); + } + + $this->appendFreeTextFields($headerElement, $transaction); + + $linesElement = $this->createElement('lines'); + $transactionElement->appendChild($linesElement); + + // Lines + /** @var BaseTransactionLine $transactionLine */ + foreach ($transaction->getLines() as $transactionLine) { + $lineElement = $this->createElement('line'); + $lineElement->setAttribute('type', $transactionLine->getLineType()); + $lineElement->setAttribute('id', $transactionLine->getId()); + $linesElement->appendChild($lineElement); + + $dim1Element = $this->createNodeWithTextContent('dim1', $transactionLine->getDim1()); + $lineElement->appendChild($dim1Element); + + $dim2 = $transactionLine->getDim2(); + if (!empty($dim2)) { + $dim2Element = $this->createNodeWithTextContent('dim2', $dim2); + $lineElement->appendChild($dim2Element); + } + + $this->appendValueValues($lineElement, $transactionLine); + + if (Util::objectUses(PerformanceFields::class, $transactionLine)) { + /** @var PerformanceFields $transactionLine */ + $performanceType = $transactionLine->getPerformanceType(); + if (!empty($performanceType)) { + $perfElement = $this->createNodeWithTextContent('performancetype', $performanceType); + $lineElement->appendChild($perfElement); + } + + $performanceCountry = $transactionLine->getPerformanceCountry(); + if (!empty($performanceCountry)) { + $perfCountryElement = $this->createNodeWithTextContent('performancecountry', $performanceCountry); + $lineElement->appendChild($perfCountryElement); + } + + $performanceVatNumber = $transactionLine->getPerformanceVatNumber(); + if (!empty($performanceVatNumber)) { + $perfVatNumberElement = $this->createNodeWithTextContent('performancevatnumber', $performanceVatNumber); + $lineElement->appendChild($perfVatNumberElement); + } + + $performanceDate = $transactionLine->getPerformanceDate(); + if (!empty($performanceDate)) { + $this->appendDateElement($lineElement, "performancedate", $transactionLine->getPerformanceDate()); + } + } + + if (Util::objectUses(FreeCharField::class, $transactionLine)) { + /** @var FreeCharField $transactionLine */ + $freeChar = $transactionLine->getFreeChar(); + if (!empty($freeChar)) { + $freeCharElement = $this->createNodeWithTextContent('freechar', $freeChar); + $lineElement->appendChild($freeCharElement); + } + } + + if (Util::objectUses(FreeTextFields::class, $transactionLine)) { + $freetext1 = $transactionLine->getFreetext1(); + if (!empty($freetext1)) { + $freetext1Element = $this->createNodeWithTextContent('freetext1', $freetext1); + $lineElement->appendChild($freetext1Element); + } + + $freetext2 = $transactionLine->getFreetext2(); + if (!empty($freetext2)) { + $freetext2Element = $this->createNodeWithTextContent('freetext2', $freetext2); + $lineElement->appendChild($freetext2Element); + } + + $freetext3 = $transactionLine->getFreetext3(); + if (!empty($freetext3)) { + $freetext3Element = $this->createNodeWithTextContent('freetext3', $freetext3); + $lineElement->appendChild($freetext3Element); + } + } + + if (Util::objectUses(VatTotalFields::class, $transactionLine)) { + /** @var VatTotalFields $transactionLine */ + $vatTotal = $transactionLine->getVatTotal(); + if (!empty($vatTotal)) { + $vatTotalElement = $this->createNodeWithTextContent('vattotal', Util::formatMoney($vatTotal)); + $lineElement->appendChild($vatTotalElement); + } + + $vatBaseTotal= $transactionLine->getVatBaseTotal(); + if (!empty($vatBaseTotal)) { + $vatBaseTotalElement = $this->createNodeWithTextContent('vatbasetotal', Util::formatMoney($vatBaseTotal)); + $lineElement->appendChild($vatBaseTotalElement); + } + } + + if (Util::objectUses(InvoiceNumberField::class, $transactionLine) && + $transactionLine->getInvoiceNumber() !== null + ) { + $invoiceNumberElement = $this->createNodeWithTextContent('invoicenumber', $transactionLine->getInvoiceNumber()); + $lineElement->appendChild($invoiceNumberElement); + } + + $vatValue = $transactionLine->getVatValue(); + if (!empty($vatValue)) { + $vatElement = $this->createNodeWithTextContent('vatvalue', Util::formatMoney($vatValue)); + $lineElement->appendChild($vatElement); + } + + $baseline = $transactionLine->getBaseline(); + if (!empty($baseline)) { + $baselineElement = $this->createNodeWithTextContent('baseline', $baseline); + $lineElement->appendChild($baselineElement); + } + + if ($transactionLine->getDescription() !== null) { + $descriptionNode = $this->createTextNode($transactionLine->getDescription()); + $descriptionElement = $this->createElement('description'); + $descriptionElement->appendChild($descriptionNode); + $lineElement->appendChild($descriptionElement); + } + + if (!LineType::TOTAL()->equals($transactionLine->getLineType()) && $transactionLine->getVatCode() !== null) { + $vatCodeElement = $this->createNodeWithTextContent('vatcode', $transactionLine->getVatCode()); + $lineElement->appendChild($vatCodeElement); + } + } + } +} From 27b57338e04cd9aae0830d62b470bfef4b2ff6b3 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 22:34:32 +0200 Subject: [PATCH 015/388] Delete BankTransactionApiConnector.php --- .../BankTransactionApiConnector.php | 66 ------------------- 1 file changed, 66 deletions(-) delete mode 100644 src/ApiConnectors/BankTransactionApiConnector.php diff --git a/src/ApiConnectors/BankTransactionApiConnector.php b/src/ApiConnectors/BankTransactionApiConnector.php deleted file mode 100644 index 3a704632..00000000 --- a/src/ApiConnectors/BankTransactionApiConnector.php +++ /dev/null @@ -1,66 +0,0 @@ -sendAll([$bankTransaction]); - - Assert::count($bankTransactionResponses, 1); - - foreach ($bankTransactionResponses as $bankTransactionResponse) { - return $bankTransactionResponse->unwrap(); - } - } - - /** - * @param BankTransaction[] $bankTransactions - * @return MappedResponseCollection|IndividualMappedResponse[] - * @throws Exception - */ - public function sendAll(array $bankTransactions): MappedResponseCollection - { - Assert::allIsInstanceOf($bankTransactions, BankTransaction::class); - - /* - * We can have multiple documents sent, so we need to collect all documents. - */ - /** @var Response[] $responses */ - $responses = []; - - foreach ($this->getProcessXmlService()->chunk($bankTransactions) as $chunk) { - - $bankTransactionDocument = new BankTransactionDocument(); - - foreach ($chunk as $bankTransaction) { - $bankTransactionDocument->addBankTransaction($bankTransaction); - } - - $responses[] = $this->sendXmlDocument($bankTransactionDocument); - } - - return $this->getProcessXmlService()->mapAll($responses, "transaction", function(Response $subresponse): BankTransaction { - return BankTransactionMapper::map($subresponse->getResponseDocument()); - }); - } -} From 26beab7ecc183086dacd3c1ef156208f9a4163ab Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 22:35:32 +0200 Subject: [PATCH 016/388] Delete TransactionsDocument.php --- src/ApiConnectors/TransactionsDocument.php | 241 --------------------- 1 file changed, 241 deletions(-) delete mode 100644 src/ApiConnectors/TransactionsDocument.php diff --git a/src/ApiConnectors/TransactionsDocument.php b/src/ApiConnectors/TransactionsDocument.php deleted file mode 100644 index 79bc7ef4..00000000 --- a/src/ApiConnectors/TransactionsDocument.php +++ /dev/null @@ -1,241 +0,0 @@ - - */ -class TransactionsDocument extends BaseDocument -{ - final protected function getRootTagName(): string - { - return "transactions"; - } - - /** - * Turns a passed Transaction class into the required markup for interacting - * with Twinfield. - * - * This method doesn't return anything, instead just adds the transaction - * to this DOMDocument instance for submission usage. - * - * @param BaseTransaction $transaction - */ - public function addTransaction(BaseTransaction $transaction) - { - // Transaction - $transactionElement = $this->createElement('transaction'); - $transactionElement->setAttribute('destiny', $transaction->getDestiny()); - if ($transaction->getRaiseWarning() !== null) { - $transactionElement->appendChild($this->createBooleanAttribute('raisewarning', $transaction->getRaiseWarning())); - } - if ($transaction->isAutoBalanceVat() !== null) { - $transactionElement->appendChild($this->createBooleanAttribute('autobalancevat', $transaction->isAutoBalanceVat())); - } - - $this->rootElement->appendChild($transactionElement); - - // Header - $headerElement = $this->createElement('header'); - $transactionElement->appendChild($headerElement); - - $codeElement = $this->createNodeWithTextContent('code', $transaction->getCode()); - $headerElement->appendChild($codeElement); - - if ($transaction->getNumber() !== null) { - $numberElement = $this->createNodeWithTextContent('number', $transaction->getNumber()); - $headerElement->appendChild($numberElement); - } - - if ($transaction->getCurrency() !== null) { - $currencyElement = $this->createNodeWithTextContent('currency', $transaction->getCurrency()); - $headerElement->appendChild($currencyElement); - } - - $this->appendDateElement($headerElement, "date", $transaction->getDate()); - - if ($transaction->getPeriod() !== null) { - $periodElement = $this->createNodeWithTextContent('period', $transaction->getPeriod()); - $headerElement->appendChild($periodElement); - } - - if ( - in_array(InvoiceNumberField::class, class_uses($transaction)) && - $transaction->getInvoiceNumber() !== null - ) { - $invoiceNumberElement = $this->createNodeWithTextContent('invoicenumber', $transaction->getInvoiceNumber()); - $headerElement->appendChild($invoiceNumberElement); - } - - if ( - in_array(PaymentReferenceField::class, class_uses($transaction)) && - $transaction->getPaymentReference() !== null - ) { - $paymentReferenceElement = $this->createNodeWithTextContent('paymentreference', $transaction->getPaymentReference()); - $headerElement->appendChild($paymentReferenceElement); - } - - $officeElement = $this->createNodeWithTextContent('office', $transaction->getOffice()); - $headerElement->appendChild($officeElement); - - if (Util::objectUses(DueDateField::class, $transaction) && - $transaction->getDueDate() !== null - ) { - $this->appendDateElement($headerElement, "duedate", $transaction->getDueDate()); - } - - if (Util::objectUses(StatementNumberField::class, $transaction) && - $transaction->getStatementnumber() !== null) { - $headerElement->appendChild($this->createNodeWithTextContent('statementnumber', $transaction->getStatementnumber())); - } - - if ($transaction instanceof CashTransaction) { - $headerElement->appendChild($this->createNodeWithTextContent('startvalue', Util::formatMoney($transaction->getStartvalue()))); - $headerElement->appendChild($this->createNodeWithTextContent('closevalue', Util::formatMoney($transaction->getClosevalue()))); - } - - $this->appendFreeTextFields($headerElement, $transaction); - - $linesElement = $this->createElement('lines'); - $transactionElement->appendChild($linesElement); - - // Lines - /** @var BaseTransactionLine $transactionLine */ - foreach ($transaction->getLines() as $transactionLine) { - $lineElement = $this->createElement('line'); - $lineElement->setAttribute('type', $transactionLine->getLineType()); - $lineElement->setAttribute('id', $transactionLine->getId()); - $linesElement->appendChild($lineElement); - - $dim1Element = $this->createNodeWithTextContent('dim1', $transactionLine->getDim1()); - $lineElement->appendChild($dim1Element); - - $dim2 = $transactionLine->getDim2(); - if (!empty($dim2)) { - $dim2Element = $this->createNodeWithTextContent('dim2', $dim2); - $lineElement->appendChild($dim2Element); - } - - $this->appendValueValues($lineElement, $transactionLine); - - if (Util::objectUses(PerformanceFields::class, $transactionLine)) { - /** @var PerformanceFields $transactionLine */ - $performanceType = $transactionLine->getPerformanceType(); - if (!empty($performanceType)) { - $perfElement = $this->createNodeWithTextContent('performancetype', $performanceType); - $lineElement->appendChild($perfElement); - } - - $performanceCountry = $transactionLine->getPerformanceCountry(); - if (!empty($performanceCountry)) { - $perfCountryElement = $this->createNodeWithTextContent('performancecountry', $performanceCountry); - $lineElement->appendChild($perfCountryElement); - } - - $performanceVatNumber = $transactionLine->getPerformanceVatNumber(); - if (!empty($performanceVatNumber)) { - $perfVatNumberElement = $this->createNodeWithTextContent('performancevatnumber', $performanceVatNumber); - $lineElement->appendChild($perfVatNumberElement); - } - - $performanceDate = $transactionLine->getPerformanceDate(); - if (!empty($performanceDate)) { - $this->appendDateElement($lineElement, "performancedate", $transactionLine->getPerformanceDate()); - } - } - - if (Util::objectUses(FreeCharField::class, $transactionLine)) { - /** @var FreeCharField $transactionLine */ - $freeChar = $transactionLine->getFreeChar(); - if (!empty($freeChar)) { - $freeCharElement = $this->createNodeWithTextContent('freechar', $freeChar); - $lineElement->appendChild($freeCharElement); - } - } - - if (Util::objectUses(FreeTextFields::class, $transactionLine)) { - $freetext1 = $transactionLine->getFreetext1(); - if (!empty($freetext1)) { - $freetext1Element = $this->createNodeWithTextContent('freetext1', $freetext1); - $lineElement->appendChild($freetext1Element); - } - - $freetext2 = $transactionLine->getFreetext2(); - if (!empty($freetext2)) { - $freetext2Element = $this->createNodeWithTextContent('freetext2', $freetext2); - $lineElement->appendChild($freetext2Element); - } - - $freetext3 = $transactionLine->getFreetext3(); - if (!empty($freetext3)) { - $freetext3Element = $this->createNodeWithTextContent('freetext3', $freetext3); - $lineElement->appendChild($freetext3Element); - } - } - - if (Util::objectUses(VatTotalFields::class, $transactionLine)) { - /** @var VatTotalFields $transactionLine */ - $vatTotal = $transactionLine->getVatTotal(); - if (!empty($vatTotal)) { - $vatTotalElement = $this->createNodeWithTextContent('vattotal', Util::formatMoney($vatTotal)); - $lineElement->appendChild($vatTotalElement); - } - - $vatBaseTotal= $transactionLine->getVatBaseTotal(); - if (!empty($vatBaseTotal)) { - $vatBaseTotalElement = $this->createNodeWithTextContent('vatbasetotal', Util::formatMoney($vatBaseTotal)); - $lineElement->appendChild($vatBaseTotalElement); - } - } - - if (Util::objectUses(InvoiceNumberField::class, $transactionLine) && - $transactionLine->getInvoiceNumber() !== null - ) { - $invoiceNumberElement = $this->createNodeWithTextContent('invoicenumber', $transactionLine->getInvoiceNumber()); - $lineElement->appendChild($invoiceNumberElement); - } - - $vatValue = $transactionLine->getVatValue(); - if (!empty($vatValue)) { - $vatElement = $this->createNodeWithTextContent('vatvalue', Util::formatMoney($vatValue)); - $lineElement->appendChild($vatElement); - } - - $baseline = $transactionLine->getBaseline(); - if (!empty($baseline)) { - $baselineElement = $this->createNodeWithTextContent('baseline', $baseline); - $lineElement->appendChild($baselineElement); - } - - if ($transactionLine->getDescription() !== null) { - $descriptionNode = $this->createTextNode($transactionLine->getDescription()); - $descriptionElement = $this->createElement('description'); - $descriptionElement->appendChild($descriptionNode); - $lineElement->appendChild($descriptionElement); - } - - if (!LineType::TOTAL()->equals($transactionLine->getLineType()) && $transactionLine->getVatCode() !== null) { - $vatCodeElement = $this->createNodeWithTextContent('vatcode', $transactionLine->getVatCode()); - $lineElement->appendChild($vatCodeElement); - } - } - } -} From b4abb11590418950d496c4e1d86698d2e7cbcdb1 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 22:35:43 +0200 Subject: [PATCH 017/388] Add files via upload From 4fef34e4d32823d69ed3d37765ed96a3db75a647 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 23:12:35 +0200 Subject: [PATCH 018/388] Delete BankTransactionDocumentUnitTest.php --- .../BankTransactionDocumentUnitTest.php | 113 ------------------ 1 file changed, 113 deletions(-) delete mode 100644 tests/UnitTests/DomDocuments/BankTransactionDocumentUnitTest.php diff --git a/tests/UnitTests/DomDocuments/BankTransactionDocumentUnitTest.php b/tests/UnitTests/DomDocuments/BankTransactionDocumentUnitTest.php deleted file mode 100644 index e732c29f..00000000 --- a/tests/UnitTests/DomDocuments/BankTransactionDocumentUnitTest.php +++ /dev/null @@ -1,113 +0,0 @@ -document = new BankTransactionDocument(); - } - - public function testXmlIsCreatedPerSpec() - { - $transaction = new BankTransaction(); - $transaction->setDestiny(Destiny::TEMPORARY()); - $transaction->setAutoBalanceVat(true); - $transaction->setOffice(Office::fromCode("DEV-10000")); - $transaction->setStartvalue(Money::EUR(0)); - - $line1 = new Total(); - $line1->setValue(Money::EUR(121)); - $line1->setId(38861); - $line1->setVatTotal(Money::EUR(21)); - $line1->setVatBaseTotal(Money::EUR(21)); - $line1->setVatRepTotal(Money::EUR(21)); - $line1->setComment("Round House Kicks & Beard Fists"); - - $line2 = new Detail(); - $line2->setValue(Money::EUR(100)); - $line2->setId(38862); - $line2->setVatValue(Money::EUR(100)); // Not sure? - $line2->setVatBaseValue(Money::EUR(100)); - $line2->setVatRepValue(Money::EUR(100)); - - $line3 = new Detail(); - $line3->setValue(Money::EUR(-100)); - $line3->setId(38863); - $line3->setDestOffice(Office::fromCode("DEV-11000")); - - $line4 = new Vat(); - $line4->setValue(Money::EUR(21)); - $line4->setId(38864); - - $transaction->setLines([$line1, $line2, $line3, $line4]); - - $line3->setComment( - "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse facilisis lobortis arcu in tincidunt. Mauris urna enim, commodo nec feugiat quis, pharetra vel sem. Etiam ullamcorper eleifend tellus non viverra. Nulla facilisi. Donec sed orci aliquam." - ); - - $this->document->addBankTransaction($transaction); - - $this->assertXmlStringEqualsXmlString( - << - - -
- DEV-10000 - EUR - 0.00 - 0.21 -
- - - debit - 1.21 - 0.21 - 0.21 - 0.21 - Round House Kicks & Beard Fists - - - credit - 1.00 - 1.00 - 1.00 - 1.00 - - - debit - 1.00 - DEV-11000 - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse facilisis lobortis arcu in tincidunt. Mauris urna enim, commodo nec feugiat quis, pharetra vel sem. Etiam ullamcorper eleifend tellus non viverra. Nulla facilisi. Donec sed orci aliquam. - - - credit - 0.21 - - -
-
-XML - , - $this->document->saveXML() - ); - } -} \ No newline at end of file From 8fb7a313501f05193a02f41d21e56a4e7883ba17 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 23:13:19 +0200 Subject: [PATCH 019/388] Delete BankTransactionApiConnectorTest.php --- .../BankTransactionApiConnectorTest.php | 260 ------------------ 1 file changed, 260 deletions(-) delete mode 100644 tests/UnitTests/ApiConnectors/BankTransactionApiConnectorTest.php diff --git a/tests/UnitTests/ApiConnectors/BankTransactionApiConnectorTest.php b/tests/UnitTests/ApiConnectors/BankTransactionApiConnectorTest.php deleted file mode 100644 index dd4f455c..00000000 --- a/tests/UnitTests/ApiConnectors/BankTransactionApiConnectorTest.php +++ /dev/null @@ -1,260 +0,0 @@ -processXmlService = $this->getMockBuilder(ProcessXmlService::class) - ->setMethods(["sendDocument"]) - ->disableOriginalConstructor() - ->getMock(); - - /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ - $connection = $this->createMock(AuthenticatedConnection::class); - $connection - ->expects($this->any()) - ->method("getAuthenticatedClient") - ->willReturn($this->processXmlService); - - $this->apiConnector = new BankTransactionApiConnector($connection); - $this->office = Office::fromCode("XXX101"); - } - - private function createBankTransaction(): BankTransaction - { - $banktransaction = new BankTransaction(); - $banktransaction->setDestiny(Destiny::TEMPORARY()); - $banktransaction->setOffice($this->office); - - return $banktransaction; - } - - public function testFailureResponseWithoutLineIdsThrowsResponseExceptionAndObjectCanStillBeExtracted() - { - $response = Response::fromString(file_get_contents( - __DIR__. "/resources/failed-response-without-line-ids.xml" - )); - - $this->processXmlService->expects($this->once()) - ->method("sendDocument") - ->willReturn($response); - - $mapped_responses = $this->apiConnector->sendAll([ - $this->createBankTransaction() - ]); - - self::assertCount(1, $mapped_responses); - - try { - $mapped_responses[0]->unwrap(); - - self::fail('Expected a ResponseException for a failed response'); - } catch (ResponseException $e) { - /** @var BankTransaction $bank_transaction */ - $bank_transaction = $e->getReturnedObject(); - - self::assertCount(2, $bank_transaction->getLines()); - - self::assertNull($bank_transaction->getLines()[0]->getId()); - self::assertNull($bank_transaction->getLines()[1]->getId()); - } - } - - public function testSendAllReturnsMappedObjects() - { - $response = Response::fromString(file_get_contents( - __DIR__."/resources/2-failed-and-1-successful-banktransactions.xml" - )); - - $this->processXmlService->expects($this->once()) - ->method("sendDocument") - ->willReturn($response); - - $responses = $this->apiConnector->sendAll([ - $this->createBankTransaction(), - $this->createBankTransaction(), - $this->createBankTransaction(), - ]); - - $this->assertCount(3, $responses); - - [$response1, $response2, $response3] = $responses; - - try { - $response1->unwrap(); - } catch (Exception $e) { - $this->assertEquals("De boeking is niet in balans. Er ontbreekt 0.01 debet.//De boeking balanceert niet in de basisvaluta. Er ontbreekt 0.01 debet.//De boeking balanceert niet in de rapportagevaluta. Er ontbreekt 0.01 debet.", $e->getMessage()); - } - - try { - $response2->unwrap(); - } catch (Exception $e) { - $this->assertEquals("De boeking is niet in balans. Er ontbreekt 0.01 debet.//De boeking balanceert niet in de basisvaluta. Er ontbreekt 0.01 debet.//De boeking balanceert niet in de rapportagevaluta. Er ontbreekt 0.01 debet.", $e->getMessage()); - } - - /** @var BankTransaction $banktransaction3 */ - $banktransaction3 = $response3->unwrap(); - - $this->assertEquals("BNK", $banktransaction3->getCode()); - $this->assertEquals("OFFICE001", $banktransaction3->getOffice()->getCode()); - $this->assertEquals("2017/08", $banktransaction3->getPeriod()); - $this->assertEquals(new Currency("EUR"), $banktransaction3->getCurrency()); - $this->assertEquals(Money::EUR(0), $banktransaction3->getStartvalue()); - $this->assertEquals(Money::EUR(0), $banktransaction3->getClosevalue()); - $this->assertEquals(0, $banktransaction3->getStatementnumber()); - $this->assertEquals("201700334", $banktransaction3->getNumber()); - - $lines = $banktransaction3->getLines(); - $this->assertCount(3, $lines); - - /** @var Total $line */ - $line = $lines[0]; - $this->assertEquals("1", $line->getId()); - $this->assertEquals(LineType::TOTAL(), $line->getLineType()); - $this->assertEquals("1100", $line->getDim1()); - $this->assertEquals("debit", $line->getDebitCredit()); - $this->assertEquals(Money::EUR(0), $line->getValue()); - $this->assertEquals("2017.123456", $line->getInvoiceNumber()); - $this->assertEquals("2017.123456", $line->getDescription()); - $this->assertEquals("2017.123456", $line->getComment()); - - /** @var Detail $line */ - $line = $lines[1]; - $this->assertEquals("2", $line->getId()); - $this->assertEquals(LineType::DETAIL(), $line->getLineType()); - $this->assertEquals("1800", $line->getDim1()); - $this->assertEquals("debit", $line->getDebitCredit()); - $this->assertEquals(Money::EUR(87), $line->getValue()); - $this->assertEquals("2017.123456", $line->getInvoiceNumber()); - $this->assertEquals("2017.123456", $line->getDescription()); - $this->assertEquals("2017.123456", $line->getComment()); - } - - public function testSendAllReturnsMappedObjectsAllLineTypes() - { - $response = Response::fromString(file_get_contents( - __DIR__."/resources/banktransaction-with-all-line-types.xml" - )); - - $this->processXmlService->expects($this->once()) - ->method("sendDocument") - ->willReturn($response); - - $responses = $this->apiConnector->sendAll([$this->createBankTransaction()]); - $this->assertCount(1, $responses); - $response = $responses[0]; - - /** @var BankTransaction $banktransaction */ - $banktransaction = $response->unwrap(); - - $this->assertEquals("BNK", $banktransaction->getCode()); - $this->assertEquals("OFFICE001", $banktransaction->getOffice()->getCode()); - $this->assertEquals("2017/09", $banktransaction->getPeriod()); - $this->assertEquals(new Currency("EUR"), $banktransaction->getCurrency()); - $this->assertEquals(Money::EUR(0), $banktransaction->getStartvalue()); - $this->assertEquals(Money::EUR(12100), $banktransaction->getClosevalue()); - $this->assertEquals(0, $banktransaction->getStatementnumber()); - $this->assertEquals("201700001", $banktransaction->getNumber()); - - $lines = $banktransaction->getLines(); - $this->assertCount(3, $lines); - - /** @var Total $line */ - $line = $lines[0]; - $this->assertEquals("1", $line->getId()); - $this->assertEquals(LineType::TOTAL(), $line->getLineType()); - $this->assertEquals("1100", $line->getDim1()); - $this->assertEquals("debit", $line->getDebitCredit()); - $this->assertEquals(Money::EUR(12100), $line->getValue()); - - /** @var Detail $line */ - $line = $lines[1]; - $this->assertEquals("2", $line->getId()); - $this->assertEquals(LineType::DETAIL(), $line->getLineType()); - $this->assertEquals("2200", $line->getDim1()); - $this->assertEquals("credit", $line->getDebitCredit()); - $this->assertEquals(Money::EUR(10000), $line->getValue()); - $this->assertEquals("My transaction", $line->getDescription()); - $this->assertEquals("VH", $line->getVatCode()); - $this->assertEquals(Money::EUR(2100), $line->getVatValue()); - $this->assertEquals(null, $line->getInvoiceNumber()); - $this->assertEquals(Money::EUR(2100), $line->getVatBaseValue()); - - /** @var Vat $line */ - $line = $lines[2]; - $this->assertEquals("3", $line->getId()); - $this->assertEquals(LineType::VAT(), $line->getLineType()); - $this->assertEquals("1502", $line->getDim1()); - $this->assertEquals("credit", $line->getDebitCredit()); - $this->assertEquals(Money::EUR(2100), $line->getValue()); - $this->assertEquals("VH", $line->getVatCode()); - $this->assertEquals(Money::EUR(10000), $line->getVatTurnover()); - $this->assertEquals(Money::EUR(10000), $line->getVatBaseTurnover()); - } - - /** - * @expectedException Exception - * @expectedExceptionMessage De status van de boeking moet Concept zijn - */ - public function testDeleteThrowsWhenResponseContainsErrorMessages() - { - $bookingReference = new BookingReference(Office::fromCode("OFFICE001"), "BNK", 201700006); - - $this->processXmlService->expects($this->once()) - ->method("sendDocument") - ->willReturnCallback(function(\DOMDocument $document) { - - $this->assertXmlStringEqualsXmlString(' - OFFICE001 - BNK - 201700006 -', $document->saveXML()); - - return Response::fromString(' - - OFFICE001 - BNK - 201700006 -'); - }); - - $this->apiConnector->delete($bookingReference, "It was merely a test transaction & I no longer need it."); - } -} \ No newline at end of file From 2010f3b95fbb05f1e599aa0cd91f88a643ee0b3a Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 23:15:17 +0200 Subject: [PATCH 020/388] Create BankTransactionLineUnitTest.php --- .../UnitTests/BankTransactionLineUnitTest.php | 193 ++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 tests/UnitTests/BankTransactionLineUnitTest.php diff --git a/tests/UnitTests/BankTransactionLineUnitTest.php b/tests/UnitTests/BankTransactionLineUnitTest.php new file mode 100644 index 00000000..80f05e00 --- /dev/null +++ b/tests/UnitTests/BankTransactionLineUnitTest.php @@ -0,0 +1,193 @@ +line = new BankTransactionLine(); + } + + public function testSetTransaction() + { + $bankTransaction = new BankTransaction(); + $this->line->setTransaction($bankTransaction); + + $this->assertEquals($bankTransaction, $this->line->getTransaction()); + } + + public function testCanNotSetDifferentTransaction() + { + $this->expectException(InvalidArgumentException::class); + + $transaction = new SalesTransaction(); + $this->line->setTransaction($transaction); + } + + public function testCanNotSetTransactionIfTransactionIsAlreadySet() + { + $this->expectException(InvalidArgumentException::class); + + $bankTransaction1 = new BankTransaction(); + $bankTransaction2 = new BankTransaction(); + $this->line->setTransaction($bankTransaction1); + $this->line->setTransaction($bankTransaction2); + } + + public function testSetDim2() + { + $this->line->setLineType(LineType::DETAIL()); + + $this->assertEquals($this->line, $this->line->setDim2('test'), 'Fluid interface is expected'); + $this->assertSame('test', $this->line->getDim2()); + } + + public function testCanNotSetDim2IfLineTypeIsNotDetail() + { + $this->expectExceptionMessage('Dimension 2 is invalid for line class PhpTwinfield\BankTransactionLine and type \'vat\'.'); + + $this->line->setLineType(LineType::VAT()); + $this->line->setDim2('test'); + } + + public function testSetDim3() + { + $this->line->setLineType(LineType::DETAIL()); + + $this->assertEquals($this->line, $this->line->setDim3('test'), 'Fluid interface is expected'); + $this->assertSame('test', $this->line->getDim3()); + } + + public function testCanNotSetDim3IfLineTypeIsNotDetail() + { + $this->expectExceptionMessage('Dimension 3 is invalid for line class PhpTwinfield\BankTransactionLine and type \'vat\'.'); + + $this->line->setLineType(LineType::VAT()); + $this->line->setDim3('test'); + } + + public function testSetMatchStatus() + { + $this->line->setLineType(LineType::DETAIL()); + + $this->assertEquals($this->line, $this->line->setMatchStatus(BankTransactionLine::MATCHSTATUS_MATCHED), 'Fluid interface is expected'); + $this->assertSame(BankTransactionLine::MATCHSTATUS_MATCHED, $this->line->getMatchStatus()); + } + + public function testCanNotSetMatchStatusOtherThanNotMatchableIfLineTypeIsNotDetail() + { + $this->expectExceptionMessage('Invalid match status \'matched\' for line class PhpTwinfield\BankTransactionLine and type \'vat\'.'); + + $this->line->setLineType(LineType::VAT()); + $this->line->setMatchStatus(BankTransactionLine::MATCHSTATUS_MATCHED); + } + + public function testSetMatchLevel() + { + $this->line->setLineType(LineType::DETAIL()); + + $this->assertEquals($this->line, $this->line->setMatchLevel(1), 'Fluid interface is expected'); + $this->assertSame(1, $this->line->getMatchLevel()); + } + + public function testCanNotSetMatchLevelIfLineTypeIsNotDetail() + { + $this->expectExceptionMessage('Invalid field \'matchLevel\' for line class PhpTwinfield\BankTransactionLine and type \'vat\'.'); + + $this->line->setLineType(LineType::VAT()); + $this->line->setMatchLevel(1); + } + + public function testSetBaseValueOpen() + { + $this->line->setLineType(LineType::DETAIL()); + + $this->assertEquals($this->line, $this->line->setBaseValueOpen(Money::EUR(100)), 'Fluid interface is expected'); + $this->assertEquals(Money::EUR(100), $this->line->getBaseValueOpen()); + } + + public function testCanNotSetBaseValueOpenIfLineTypeIsNotDetail() + { + $this->expectExceptionMessage('Invalid field \'baseValueOpen\' for line class PhpTwinfield\BankTransactionLine and type \'vat\'.'); + + $this->line->setLineType(LineType::VAT()); + $this->line->setBaseValueOpen(Money::EUR(100)); + } + + public function testSetVatTurnover() + { + $this->line->setLineType(LineType::VAT()); + + $this->assertEquals($this->line, $this->line->setVatTurnover(Money::EUR(100)), 'Fluid interface is expected'); + $this->assertEquals(Money::EUR(100), $this->line->getVatTurnover()); + } + + public function testCanNotSetVatTurnoverIfLineTypeIsNotVat() + { + $this->expectExceptionMessage('Invalid field \'vatturnover\' for line class PhpTwinfield\BankTransactionLine and type \'detail\'.'); + + $this->line->setLineType(LineType::DETAIL()); + $this->line->setVatTurnover(Money::EUR(100)); + } + + public function testSetVatBaseTurnover() + { + $this->line->setLineType(LineType::VAT()); + + $this->assertEquals($this->line, $this->line->setVatBaseTurnover(Money::EUR(100)), 'Fluid interface is expected'); + $this->assertEquals(Money::EUR(100), $this->line->getVatBaseTurnover()); + } + + public function testCanNotSetVatBaseTurnoverIfLineTypeIsNotVat() + { + $this->expectExceptionMessage('Invalid field \'vatbaseturnover\' for line class PhpTwinfield\BankTransactionLine and type \'detail\'.'); + + $this->line->setLineType(LineType::DETAIL()); + $this->line->setVatBaseTurnover(Money::EUR(100)); + } + + public function testSetVatRepTurnover() + { + $this->line->setLineType(LineType::VAT()); + + $this->assertEquals($this->line, $this->line->setVatRepTurnover(Money::EUR(100)), 'Fluid interface is expected'); + $this->assertEquals(Money::EUR(100), $this->line->getVatRepTurnover()); + } + + public function testCanNotSetVatRepTurnoverIfLineTypeIsNotVat() + { + $this->expectExceptionMessage('Invalid field \'vatrepturnover\' for line class PhpTwinfield\BankTransactionLine and type \'detail\'.'); + + $this->line->setLineType(LineType::DETAIL()); + $this->line->setVatRepTurnover(Money::EUR(100)); + } + + public function testSetInvoiceNumber() + { + $this->line->setLineType(LineType::DETAIL()); + + $this->assertEquals($this->line, $this->line->setInvoiceNumber('11001770'), 'Fluid interface is expected'); + $this->assertSame('11001770', $this->line->getInvoiceNumber()); + } + + public function testCanNotSetInvoiceNumberIfLineTypeIsNotDetail() + { + $this->expectExceptionMessage('Invalid field \'invoicenumber\' for line class PhpTwinfield\BankTransactionLine and type \'total\'.'); + + $this->line->setLineType(LineType::TOTAL()); + $this->line->setInvoiceNumber('11001770'); + } +} From cd4cfa235ba60d40693b1e5f680e5f507b8bbef7 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 23:15:54 +0200 Subject: [PATCH 021/388] Update BankTransactionUnitTest.php --- tests/UnitTests/BankTransactionUnitTest.php | 187 +++++--------------- 1 file changed, 48 insertions(+), 139 deletions(-) diff --git a/tests/UnitTests/BankTransactionUnitTest.php b/tests/UnitTests/BankTransactionUnitTest.php index 54b66017..99aece47 100644 --- a/tests/UnitTests/BankTransactionUnitTest.php +++ b/tests/UnitTests/BankTransactionUnitTest.php @@ -1,179 +1,88 @@ setOffice(Office::fromCode("XXX99999")); - $bank->setNumber("201300003"); - $bank->getNumber(); - $bank->setCode("MEMO"); - - $line = new Detail(); - $line->setId(1); - $line->setValue(Money::EUR(1)); - - $bank->addLine($line); - - $reference = $line->getReference(); - - $this->assertEquals(Office::fromCode("XXX99999"), $reference->getOffice()); - $this->assertEquals("201300003", $reference->getNumber()); - $this->assertEquals("1", $reference->getLineId()); - $this->assertEquals("MEMO", $reference->getCode()); - } - - public function testGetLineReturnsLinesInSameOrderButAlwaysWithTotalAtTheTop() - { - $total_line_count = 287; - - $bank_transaction = new BankTransaction(); - - for ($i = 1; $i < $total_line_count; $i++) { - $this->addDetailLineWithDescription($bank_transaction, (string)$i); - } - - $this->addTotalLineWithDescription($bank_transaction, '0'); - - self::assertLinesInOrderBasedOnDescription($bank_transaction, $total_line_count); - } - - private static function assertLinesInOrderBasedOnDescription( - BankTransaction $bank_transaction, - int $expected_line_count - ) { - $i = 0; - /** @var Base $line */ - foreach ($bank_transaction->getLines() as $line) { - self::assertSame( - $i, - (int)$line->getDescription(), - 'Expected line #' . $i . ', but got line #' . $line->getDescription() . - ' of type ' . $line->getLineType()->getValue() . '. Wrong order!' - ); - $i++; - } - - self::assertSame($expected_line_count, $i, 'Number of returned lines does not match number of added lines'); - } - - private function addTotalLineWithDescription(BankTransaction $bankTransaction, string $description): Total - { - $line = new Total(); - $line->setDescription($description); - $line->setValue(Money::EUR(0)); + /** + * @var BankTransaction + */ + private $bankTransaction; - $bankTransaction->addLine($line); - - return $line; - } - - private function addDetailLineWithDescription(BankTransaction $bankTransaction, string $description): Detail + protected function setUp() { - $line = new Detail(); - $line->setDescription($description); - $line->setValue(Money::EUR(0)); - - $bankTransaction->addLine($line); - - return $line; + $this->bankTransaction = new BankTransaction(); } - public function testGetLinesReturnsLinesInTheSameOrderAsTheyWereAdded() + public function testSetStartValue() { - $total_line_count = 300; + $this->bankTransaction->setStartvalue(Money::EUR(100)); - $bank_transaction = new BankTransaction(); - - $this->addTotalLineWithDescription($bank_transaction, '0'); - - for ($i = 1; $i < $total_line_count; $i++) { - $this->addDetailLineWithDescription($bank_transaction, (string)$i); - } - - self::assertLinesInOrderBasedOnDescription($bank_transaction, $total_line_count); + $this->assertEquals(new Currency('EUR'), $this->bankTransaction->getCurrency()); + $this->assertEquals(Money::EUR(100), $this->bankTransaction->getStartvalue()); + $this->assertEquals(Money::EUR(100), $this->bankTransaction->getClosevalue()); } - public function testGetLinesReturnsEmptyArrayWhenNoLinesSet() + public function testSetCurrencyWithoutStartValue() { - $bank_transaction = new BankTransaction(); - - self::assertCount(0, $bank_transaction->getLines()); + $this->bankTransaction->setCurrency(new Currency('EUR')); + $this->assertEquals(new Currency('EUR'), $this->bankTransaction->getCurrency()); } - public function testGetLinesReturnsLinesInSameOrderWhenOnlyDetailsAdded() + public function testSetCurrencyWithZeroStartValue() { - $bank_transaction = new BankTransaction(); + $this->bankTransaction->setStartvalue(Money::EUR(0)); + $this->bankTransaction->setCurrency(new Currency('EUR')); - $this->addDetailLineWithDescription($bank_transaction, '0'); - $this->addDetailLineWithDescription($bank_transaction, '1'); - $this->addDetailLineWithDescription($bank_transaction, '2'); - - self::assertLinesInOrderBasedOnDescription($bank_transaction, 3); + $this->assertEquals(new Currency('EUR'), $this->bankTransaction->getCurrency()); } - public function testGetLinesReturnsOnlyTotalLineWhenOnlyTotalLineIsAdded() + public function testSetCurrencyWithStartValue() { - $bank_transaction = new BankTransaction(); - - $this->addTotalLineWithDescription($bank_transaction, '0'); + $this->expectException(InvalidArgumentException::class); - self::assertCount(1, $bank_transaction->getLines()); - self::assertTrue($bank_transaction->getLines()[0]->getLineType()->equals(LineType::TOTAL())); + $this->bankTransaction->setStartvalue(Money::EUR(100)); + $this->bankTransaction->setCurrency(new Currency('EUR')); } - public function testAdding1TotalLineAnd499DetailLinesToABankTransactionWorks() + public function testAddLineWithWrongTransactionLine() { - $total_line_count = 500; - - $bank_transaction = new BankTransaction(); + $this->expectException(InvalidArgumentException::class); - $this->addTotalLineWithDescription($bank_transaction, '0'); - for ($i = 1; $i < $total_line_count; $i++) { - $this->addDetailLineWithDescription($bank_transaction, (string)$i); - } - - self::assertCount($total_line_count, $bank_transaction->getLines()); + $this->bankTransaction->setStartvalue(Money::EUR(100)); + $this->bankTransaction->addLine(new SalesTransactionLine()); } - public function testAdding1TotalLineWith500DetailLinesToABankTransactionThrows() + public function testAddLineUpdatesCloseValue() { - $total_line_count = 501; - - $bank_transaction = new BankTransaction(); + $this->bankTransaction->setStartvalue(Money::EUR(100)); - $this->addTotalLineWithDescription($bank_transaction, '0'); + $totalLine = new BankTransactionLine(); + $totalLine + ->setLineType(LineType::TOTAL()) + ->setValue(Money::EUR(0)); - $this->expectException(\InvalidArgumentException::class); - - for ($i = 1; $i < $total_line_count; $i++) { - $this->addDetailLineWithDescription($bank_transaction, (string)$i); - } - } - - public function testAddLineThrowsAndIgnoresWhenAddingASecondTotalLine() - { - $bank_transaction = new BankTransaction(); + $detailLine1 = new BankTransactionLine(); + $detailLine1 + ->setLineType(LineType::DETAIL()) + ->setValue(Money::EUR(43555)); - $this->addTotalLineWithDescription($bank_transaction, '0'); + $detailLine2 = new BankTransactionLine(); + $detailLine2 + ->setLineType(LineType::DETAIL()) + ->setValue(Money::EUR(-43455)); - try { - $this->addTotalLineWithDescription($bank_transaction, '0'); + $this->bankTransaction->addLine($totalLine); + $this->bankTransaction->addLine($detailLine1); + $this->bankTransaction->addLine($detailLine2); - self::fail('An exception should have been thrown when adding a second total line'); - } catch (\InvalidArgumentException $e) { - self::assertCount(1, $bank_transaction->getLines()); - } + $this->assertEquals(Money::EUR(200), $this->bankTransaction->getClosevalue()); } } From 2dd0e11086d5f902fff7621971f4a1180a0ee723 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 23:18:59 +0200 Subject: [PATCH 022/388] Create bankTransactionGetResponse.xml --- .../resources/bankTransactionGetResponse.xml | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests/IntegrationTests/resources/bankTransactionGetResponse.xml diff --git a/tests/IntegrationTests/resources/bankTransactionGetResponse.xml b/tests/IntegrationTests/resources/bankTransactionGetResponse.xml new file mode 100644 index 00000000..4bfdb0c8 --- /dev/null +++ b/tests/IntegrationTests/resources/bankTransactionGetResponse.xml @@ -0,0 +1,47 @@ + +
+ 001 + BNK + EUR + 20131104 + 4 + 974.01 + 1409.56 + import + MARCEL + 2013/11 + 201300008 +
+ + + 1001 + debit + 435.55 + 1 + 435.55 + 1.500000000 + 653.33 + notmatchable + + + 1300 + 1000 + credit + 435.55 + 11001770 + Invoice paid + 20131108 + 1 + 435.55 + 1.500000000 + 653.33 + + 2 + 2 + 435.55 + 435.55 + 653.33 + available + + +
From 71eec80d3ce884225b69c7e8cf24f79a201892b4 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 23:19:38 +0200 Subject: [PATCH 023/388] Create bankTransactionSendRequest.xml --- .../resources/bankTransactionSendRequest.xml | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/IntegrationTests/resources/bankTransactionSendRequest.xml diff --git a/tests/IntegrationTests/resources/bankTransactionSendRequest.xml b/tests/IntegrationTests/resources/bankTransactionSendRequest.xml new file mode 100644 index 00000000..0c1ab476 --- /dev/null +++ b/tests/IntegrationTests/resources/bankTransactionSendRequest.xml @@ -0,0 +1,28 @@ + + +
+ BNK + EUR + 20131104 + 001 + 4 + 974.01 + 1409.56 +
+ + + 1001 + debit + 435.55 + + + 1300 + 1000 + credit + 435.55 + 11001770 + Invoice paid + + +
+
From 63580cf11b9e5d039113f34b7b7fedf2240fe7e1 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 23:20:58 +0200 Subject: [PATCH 024/388] Create BankTransactionIntegrationTest.php --- .../BankTransactionIntegrationTest.php | 196 ++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 tests/IntegrationTests/BankTransactionIntegrationTest.php diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php new file mode 100644 index 00000000..993df09d --- /dev/null +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -0,0 +1,196 @@ +transactionApiConnector = new TransactionApiConnector($this->connection); + } + + public function testGetBankTransactionWorks() + { + $response = Response::fromString(file_get_contents(__DIR__ . '/resources/bankTransactionGetResponse.xml')); + + $this->processXmlService + ->expects($this->once()) + ->method("sendDocument") + ->with($this->isInstanceOf(\PhpTwinfield\Request\Read\Transaction::class)) + ->willReturn($response); + + /** @var BankTransaction $bankTransaction */ + $bankTransaction = $this->transactionApiConnector->get(BankTransaction::class, 'BNK', '201300008', $this->office); + + $this->assertInstanceOf(BankTransaction::class, $bankTransaction); + $this->assertEquals(Destiny::TEMPORARY(), $bankTransaction->getDestiny()); + $this->assertNull($bankTransaction->isAutoBalanceVat()); + $this->assertSame(false, $bankTransaction->getRaiseWarning()); + $this->assertEquals(Office::fromCode('001'), $bankTransaction->getOffice()); + $this->assertSame('BNK', $bankTransaction->getCode()); + $this->assertSame(201300008, $bankTransaction->getNumber()); + $this->assertSame('2013/11', $bankTransaction->getPeriod()); + $this->assertEquals(new Currency('EUR'), $bankTransaction->getCurrency()); + $this->assertEquals(new DateTimeImmutable('2013-11-04'), $bankTransaction->getDate()); + $this->assertSame('import', $bankTransaction->getOrigin()); + $this->assertNull($bankTransaction->getFreetext1()); + $this->assertNull($bankTransaction->getFreetext2()); + $this->assertNull($bankTransaction->getFreetext3()); + $this->assertSame(4, $bankTransaction->getStatementnumber()); + $this->assertTrue(Money::EUR(97401)->equals($bankTransaction->getStartvalue())); + $this->assertTrue(Money::EUR(140956)->equals($bankTransaction->getClosevalue())); + + /** @var BankTransactionLine[] $bankTransactionLines */ + $bankTransactionLines = $bankTransaction->getLines(); + $this->assertCount(2, $bankTransactionLines); + [$totalLine, $detailLine] = $bankTransactionLines; + + $this->assertEquals(LineType::TOTAL(), $totalLine->getLineType()); + $this->assertSame(1, $totalLine->getId()); + $this->assertSame('1001', $totalLine->getDim1()); + $this->assertEquals(DebitCredit::DEBIT(), $totalLine->getDebitCredit()); + $this->assertEquals(Money::EUR(43555), $totalLine->getValue()); + $this->assertEquals(Money::EUR(43555), $totalLine->getBaseValue()); + $this->assertSame(1.0, $totalLine->getRate()); + $this->assertEquals(Money::EUR(65333), $totalLine->getRepValue()); + $this->assertSame(1.500000000, $totalLine->getRepRate()); + $this->assertSame(BankTransactionLine::MATCHSTATUS_NOTMATCHABLE, $totalLine->getMatchStatus()); + $this->assertNull($totalLine->getMatchLevel()); + $this->assertNull($totalLine->getBaseValueOpen()); + $this->assertNull($totalLine->getVatCode()); + $this->assertNull($totalLine->getVatValue()); + $this->assertNull($totalLine->getVatTotal()); + $this->assertNull($totalLine->getVatBaseTotal()); + $this->assertNull($totalLine->getPerformanceType()); + $this->assertNull($totalLine->getPerformanceCountry()); + $this->assertNull($totalLine->getPerformanceVatNumber()); + $this->assertNull($totalLine->getPerformanceDate()); + + $this->assertEquals(LineType::DETAIL(), $detailLine->getLineType()); + $this->assertSame(2, $detailLine->getId()); + $this->assertSame('1300', $detailLine->getDim1()); + $this->assertSame('1000', $detailLine->getDim2()); + $this->assertEquals(DebitCredit::CREDIT(), $detailLine->getDebitCredit()); + $this->assertSame('11001770', $detailLine->getInvoiceNumber()); + $this->assertEquals(Money::EUR(43555), $detailLine->getValue()); + $this->assertEquals(Money::EUR(43555), $totalLine->getBaseValue()); + $this->assertSame(1.0, $totalLine->getRate()); + $this->assertEquals(Money::EUR(65333), $totalLine->getRepValue()); + $this->assertSame(1.500000000, $totalLine->getRepRate()); + $this->assertSame('Invoice paid', $detailLine->getDescription()); + $this->assertSame(SalesTransactionLine::MATCHSTATUS_AVAILABLE, $detailLine->getMatchStatus()); + $this->assertSame(2, $detailLine->getMatchLevel()); + $this->assertEquals(Money::EUR(43555), $detailLine->getBaseValueOpen()); + $this->assertEquals(Money::EUR(65333), $detailLine->getRepValue()); + $this->assertNull($detailLine->getVatCode()); + $this->assertNull($detailLine->getVatValue()); + $this->assertNull($detailLine->getVatTotal()); + $this->assertNull($detailLine->getVatBaseTotal()); + $this->assertNull($detailLine->getPerformanceType()); + $this->assertNull($detailLine->getPerformanceCountry()); + $this->assertNull($detailLine->getPerformanceVatNumber()); + $this->assertNull($detailLine->getPerformanceDate()); + } + + public function testSendBankTransactionWorks() + { + $bankTransaction = new BankTransaction(); + $bankTransaction + ->setOffice(Office::fromCode('001')) + ->setDestiny(Destiny::TEMPORARY()) + ->setRaiseWarning(false) + ->setCode('BNK') + ->setCurrency(new Currency('EUR')) + ->setDate(new DateTimeImmutable('2013-11-04')) + ->setStatementnumber(4) + ->setStartvalue(Money::EUR(97401)); + + $totalLine = new BankTransactionLine(); + $totalLine + ->setLineType(LineType::TOTAL()) + ->setId('1') + ->setDim1('1001') + ->setValue(Money::EUR(43555)); + + $detailLine = new BankTransactionLine(); + $detailLine + ->setLineType(LineType::DETAIL()) + ->setId('2') + ->setDim1('1300') + ->setDim2('1000') + ->setValue(Money::EUR(43555)) + ->setInvoiceNumber('11001770') + ->setDescription('Invoice paid'); + + $bankTransaction + ->addLine($totalLine) + ->addLine($detailLine); + + $this->processXmlService + ->expects($this->once()) + ->method("sendDocument") + ->with($this->isInstanceOf(TransactionsDocument::class)) + ->willReturnCallback(function (TransactionsDocument $transactionsDocument) { + $this->assertXmlStringEqualsXmlString( + file_get_contents(realpath(__DIR__ . '/resources/bankTransactionSendRequest.xml')), + $transactionsDocument->saveXML() + ); + + return $this->getSuccessfulResponse(); + }); + + $this->transactionApiConnector->send($bankTransaction); + } + + protected function getSuccessfulResponse(): Response + { + return Response::fromString( + ' +
+ 001 + BNK + EUR + 20131104 + 4 + 974.01 + 1409.56 + import + MARCEL + 2013/11 + 201300008 +
+
+
' + ); + } +} From 9d6b6e4246d4c19a4139d276fcdf4aad027c63e3 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 23:51:33 +0200 Subject: [PATCH 025/388] Add files via upload --- src/Mappers/TransactionMapper.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 081d6338..c46ac82f 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -138,6 +138,10 @@ public static function map(string $transactionClassName, Response $response): Ba $linesElement = $transactionElement->getElementsByTagName('lines')->item(0); foreach ($linesElement->childNodes as $lineElement) { + if ($lineElement->nodeType !== 1) { + continue; + } + self::checkForMessage($transaction, $lineElement); /** @var BaseTransactionLine $transactionLine */ From b758c827bfa4b1065f5285d2ea8e43c246e3c2e7 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 23:58:55 +0200 Subject: [PATCH 026/388] Update MappedResponseCollectionUnitTest.php --- .../UnitTests/Request/MappedResponseCollectionUnitTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/UnitTests/Request/MappedResponseCollectionUnitTest.php b/tests/UnitTests/Request/MappedResponseCollectionUnitTest.php index 89bc98c8..7803c53a 100644 --- a/tests/UnitTests/Request/MappedResponseCollectionUnitTest.php +++ b/tests/UnitTests/Request/MappedResponseCollectionUnitTest.php @@ -2,7 +2,7 @@ namespace PhpTwinfield\UnitTests; -use PhpTwinfield\ApiConnectors\BankTransactionApiConnector; +use PhpTwinfield\ApiConnectors\TransactionApiConnector; use PhpTwinfield\Response\Response; use PhpTwinfield\Services\ProcessXmlService; use PHPUnit\Framework\TestCase; @@ -10,7 +10,7 @@ class MappedResponseCollectionUnitTest extends TestCase { /** - * @var BankTransactionApiConnector + * @var TransactionApiConnector */ protected $apiConnector; @@ -54,4 +54,4 @@ public function createFakeResponse() "); } -} \ No newline at end of file +} From 60a1fe167b6b4eaae131721a97ce738cbe913679 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 28 Apr 2019 23:59:56 +0200 Subject: [PATCH 027/388] Update TransactionLine.php --- src/Transactions/TransactionLine.php | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/src/Transactions/TransactionLine.php b/src/Transactions/TransactionLine.php index a72142ae..314c0bb6 100644 --- a/src/Transactions/TransactionLine.php +++ b/src/Transactions/TransactionLine.php @@ -21,26 +21,6 @@ public function getLineType(): LineType; */ public function getId(): ?int; - /** - * Set the bank transaction on the line. This is needed later on. - * - * @param BankTransaction $object - * @throws \InvalidArgumentException If a transaction is invalid or if a transaction is already set. - * @internal - */ - public function setTransaction($object): void; - - /** - * Gets the bank transaction from the line. - * - * Note that you should add the return type when implementing. - * - * @see MatchReferenceInterface - * @return BankTransaction - * @internal - */ - public function getTransaction(); - /** * Get an object containing everything you need to uniquely reference this line. * @@ -49,4 +29,4 @@ public function getTransaction(); * @return MatchReferenceInterface */ public function getReference(): MatchReferenceInterface; -} \ No newline at end of file +} From 213edccd5428a7f2e1da3efe54d0cc48123e072e Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 29 Apr 2019 00:03:13 +0200 Subject: [PATCH 028/388] Update TransactionLine.php --- src/Transactions/TransactionLine.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Transactions/TransactionLine.php b/src/Transactions/TransactionLine.php index 314c0bb6..4298d24a 100644 --- a/src/Transactions/TransactionLine.php +++ b/src/Transactions/TransactionLine.php @@ -21,6 +21,26 @@ public function getLineType(): LineType; */ public function getId(): ?int; + /** + * Set the bank transaction on the line. This is needed later on. + * + * @param BankTransaction $object + * @throws \InvalidArgumentException If a transaction is invalid or if a transaction is already set. + * @internal + */ + public function setTransaction($object): void; + + /** + * Gets the bank transaction from the line. + * + * Note that you should add the return type when implementing. + * + * @see MatchReferenceInterface + * @return BankTransaction + * @internal + */ + public function getTransaction(); + /** * Get an object containing everything you need to uniquely reference this line. * From a46ba4a31ef11975a906cfeec11b37832d8cd66b Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 29 Apr 2019 00:04:11 +0200 Subject: [PATCH 029/388] Update TransactionLine.php --- src/Transactions/TransactionLine.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Transactions/TransactionLine.php b/src/Transactions/TransactionLine.php index 4298d24a..5ea88790 100644 --- a/src/Transactions/TransactionLine.php +++ b/src/Transactions/TransactionLine.php @@ -2,6 +2,7 @@ namespace PhpTwinfield\Transactions; +use PhpTwinfield\Transaction; use PhpTwinfield\Enums\LineType; use PhpTwinfield\MatchReferenceInterface; @@ -22,21 +23,21 @@ public function getLineType(): LineType; public function getId(): ?int; /** - * Set the bank transaction on the line. This is needed later on. + * Set the transaction on the line. This is needed later on. * - * @param BankTransaction $object + * @param Transaction $object * @throws \InvalidArgumentException If a transaction is invalid or if a transaction is already set. * @internal */ public function setTransaction($object): void; /** - * Gets the bank transaction from the line. + * Gets the transaction from the line. * * Note that you should add the return type when implementing. * * @see MatchReferenceInterface - * @return BankTransaction + * @return Transaction * @internal */ public function getTransaction(); From 53117abb64af9cf57be84b1dea449f27a4247c92 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 29 Apr 2019 00:07:27 +0200 Subject: [PATCH 030/388] Update TransactionLine.php --- src/Transactions/TransactionLine.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Transactions/TransactionLine.php b/src/Transactions/TransactionLine.php index 5ea88790..9448082d 100644 --- a/src/Transactions/TransactionLine.php +++ b/src/Transactions/TransactionLine.php @@ -2,7 +2,7 @@ namespace PhpTwinfield\Transactions; -use PhpTwinfield\Transaction; +use PhpTwinfield\BaseTransaction; use PhpTwinfield\Enums\LineType; use PhpTwinfield\MatchReferenceInterface; @@ -25,7 +25,7 @@ public function getId(): ?int; /** * Set the transaction on the line. This is needed later on. * - * @param Transaction $object + * @param BaseTransaction $object * @throws \InvalidArgumentException If a transaction is invalid or if a transaction is already set. * @internal */ @@ -37,7 +37,7 @@ public function setTransaction($object): void; * Note that you should add the return type when implementing. * * @see MatchReferenceInterface - * @return Transaction + * @return BaseTransaction * @internal */ public function getTransaction(); From eebaad95e670cc642e451d0ef319aafe2ca80f47 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 29 Apr 2019 00:19:50 +0200 Subject: [PATCH 031/388] Update TransactionMapper.php --- src/Mappers/TransactionMapper.php | 174 +++++++++++++++--------------- 1 file changed, 89 insertions(+), 85 deletions(-) diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index c46ac82f..9f754d14 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -135,109 +135,113 @@ public static function map(string $transactionClassName, Response $response): Ba // Parse the transaction lines $transactionLineClassName = $transaction->getLineClassName(); - $linesElement = $transactionElement->getElementsByTagName('lines')->item(0); + $linesDOMTag = $transactionElement->getElementsByTagName('lines'); - foreach ($linesElement->childNodes as $lineElement) { - if ($lineElement->nodeType !== 1) { - continue; - } + if (isset($linesDOMTag) && $linesDOMTag->length > 0) { + $linesDOM = $linesDOMTag->item(0); - self::checkForMessage($transaction, $lineElement); - - /** @var BaseTransactionLine $transactionLine */ - $transactionLine = new $transactionLineClassName(); - $lineType = $lineElement->getAttribute('type'); - - $transactionLine - ->setLineType(new LineType($lineType)) - ->setId($lineElement->getAttribute('id')) - ->setDim1(self::getField($transaction, $lineElement, 'dim1')) - ->setDim2(self::getField($transaction, $lineElement, 'dim2')) - ->setValue(Money::EUR(100 * self::getField($transaction, $lineElement, 'value'))) - ->setDebitCredit(new DebitCredit(self::getField($transaction, $lineElement, 'debitcredit'))) - ->setBaseValue(Money::EUR(100 * self::getField($transaction, $lineElement, 'basevalue'))) - ->setRate(self::getField($transaction, $lineElement, 'rate')) - ->setRepValue(Money::EUR(100 * self::getField($transaction, $lineElement, 'repvalue'))) - ->setRepRate(self::getField($transaction, $lineElement, 'reprate')) - ->setDescription(self::getField($transaction, $lineElement, 'description')) - ->setMatchStatus(self::getField($transaction, $lineElement, 'matchstatus')) - ->setMatchLevel(self::getField($transaction, $lineElement, 'matchlevel')) - ->setVatCode(self::getField($transaction, $lineElement, 'vatcode')); - - // TODO - according to the docs, the field is called , but the examples use . - $baseValueOpen = self::getField($transaction, $lineElement, 'basevalueopen') ?: self::getField($transaction, $lineElement, 'openbasevalue'); - if ($baseValueOpen) { - $transactionLine->setBaseValueOpen(Money::EUR(100 * $baseValueOpen)); - } + foreach ($linesDOM->childNodes as $lineElement) { + if ($lineElement->nodeType !== 1) { + continue; + } - $vatValue = self::getField($transaction, $lineElement, 'vatvalue'); - if ($lineType == LineType::DETAIL() && $vatValue) { - $transactionLine->setVatValue(Money::EUR(100 * $vatValue)); - } + self::checkForMessage($transaction, $lineElement); - $baseline = self::getField($transaction, $lineElement, 'baseline'); - if ($baseline) { - $transactionLine->setBaseline($baseline); - } + /** @var BaseTransactionLine $transactionLine */ + $transactionLine = new $transactionLineClassName(); + $lineType = $lineElement->getAttribute('type'); - if (Util::objectUses(FreeTextFields::class, $transactionLine)) { - $freetext1 = self::getField($transaction, $lineElement, 'freetext1'); - if ($freetext1) { - $transactionLine->setFreetext1($freetext1); + $transactionLine + ->setLineType(new LineType($lineType)) + ->setId($lineElement->getAttribute('id')) + ->setDim1(self::getField($transaction, $lineElement, 'dim1')) + ->setDim2(self::getField($transaction, $lineElement, 'dim2')) + ->setValue(Money::EUR(100 * self::getField($transaction, $lineElement, 'value'))) + ->setDebitCredit(new DebitCredit(self::getField($transaction, $lineElement, 'debitcredit'))) + ->setBaseValue(Money::EUR(100 * self::getField($transaction, $lineElement, 'basevalue'))) + ->setRate(self::getField($transaction, $lineElement, 'rate')) + ->setRepValue(Money::EUR(100 * self::getField($transaction, $lineElement, 'repvalue'))) + ->setRepRate(self::getField($transaction, $lineElement, 'reprate')) + ->setDescription(self::getField($transaction, $lineElement, 'description')) + ->setMatchStatus(self::getField($transaction, $lineElement, 'matchstatus')) + ->setMatchLevel(self::getField($transaction, $lineElement, 'matchlevel')) + ->setVatCode(self::getField($transaction, $lineElement, 'vatcode')); + + // TODO - according to the docs, the field is called , but the examples use . + $baseValueOpen = self::getField($transaction, $lineElement, 'basevalueopen') ?: self::getField($transaction, $lineElement, 'openbasevalue'); + if ($baseValueOpen) { + $transactionLine->setBaseValueOpen(Money::EUR(100 * $baseValueOpen)); } - $freetext2 = self::getField($transaction, $lineElement, 'freetext2'); - if ($freetext2) { - $transactionLine->setFreetext2($freetext2); + $vatValue = self::getField($transaction, $lineElement, 'vatvalue'); + if ($lineType == LineType::DETAIL() && $vatValue) { + $transactionLine->setVatValue(Money::EUR(100 * $vatValue)); } - $freetext3 = self::getField($transaction, $lineElement, 'freetext3'); - if ($freetext3) { - $transactionLine->setFreetext3($freetext3); + $baseline = self::getField($transaction, $lineElement, 'baseline'); + if ($baseline) { + $transactionLine->setBaseline($baseline); } - } - if (Util::objectUses(PerformanceFields::class, $transactionLine)) { - /** @var BaseTransactionLine|PerformanceFields $transactionLine */ - $performanceType = self::getField($transaction, $lineElement, 'performancetype'); - $transactionLine - ->setPerformanceType($performanceType ? new PerformanceType($performanceType) : null) - ->setPerformanceCountry(self::getField($transaction, $lineElement, 'performancecountry')) - ->setPerformanceVatNumber(self::getField($transaction, $lineElement, 'performancevatnumber')); + if (Util::objectUses(FreeTextFields::class, $transactionLine)) { + $freetext1 = self::getField($transaction, $lineElement, 'freetext1'); + if ($freetext1) { + $transactionLine->setFreetext1($freetext1); + } + + $freetext2 = self::getField($transaction, $lineElement, 'freetext2'); + if ($freetext2) { + $transactionLine->setFreetext2($freetext2); + } + + $freetext3 = self::getField($transaction, $lineElement, 'freetext3'); + if ($freetext3) { + $transactionLine->setFreetext3($freetext3); + } + } - $performanceDate = self::getField($transaction, $lineElement, 'performancedate'); + if (Util::objectUses(PerformanceFields::class, $transactionLine)) { + /** @var BaseTransactionLine|PerformanceFields $transactionLine */ + $performanceType = self::getField($transaction, $lineElement, 'performancetype'); + $transactionLine + ->setPerformanceType($performanceType ? new PerformanceType($performanceType) : null) + ->setPerformanceCountry(self::getField($transaction, $lineElement, 'performancecountry')) + ->setPerformanceVatNumber(self::getField($transaction, $lineElement, 'performancevatnumber')); - if ($performanceDate) { - $transactionLine->setPerformanceDate(Util::parseDate($performanceDate)); - } - } - if (in_array(ValueOpenField::class, class_uses($transactionLine))) { - // TODO - according to the docs, the field is called , but the examples use . - $valueOpen = self::getField($transaction, $lineElement, 'valueopen') ?: self::getField($transaction, $lineElement, 'openvalue'); - if ($valueOpen) { - $transactionLine->setValueOpen(Money::EUR(100 * $valueOpen)); + $performanceDate = self::getField($transaction, $lineElement, 'performancedate'); + + if ($performanceDate) { + $transactionLine->setPerformanceDate(Util::parseDate($performanceDate)); + } } - } - if (in_array(VatTotalFields::class, class_uses($transactionLine))) { - $vatTotal = self::getField($transaction, $lineElement, 'vattotal'); - if ($vatTotal) { - $transactionLine->setVatTotal(Money::EUR(100 * $vatTotal)); + if (in_array(ValueOpenField::class, class_uses($transactionLine))) { + // TODO - according to the docs, the field is called , but the examples use . + $valueOpen = self::getField($transaction, $lineElement, 'valueopen') ?: self::getField($transaction, $lineElement, 'openvalue'); + if ($valueOpen) { + $transactionLine->setValueOpen(Money::EUR(100 * $valueOpen)); + } } - - $vatBaseTotal = self::getField($transaction, $lineElement, 'vatbasetotal'); - if ($vatBaseTotal) { - $transactionLine->setVatBaseTotal(Money::EUR(100 * $vatBaseTotal)); + if (in_array(VatTotalFields::class, class_uses($transactionLine))) { + $vatTotal = self::getField($transaction, $lineElement, 'vattotal'); + if ($vatTotal) { + $transactionLine->setVatTotal(Money::EUR(100 * $vatTotal)); + } + + $vatBaseTotal = self::getField($transaction, $lineElement, 'vatbasetotal'); + if ($vatBaseTotal) { + $transactionLine->setVatBaseTotal(Money::EUR(100 * $vatBaseTotal)); + } } - } - if (Util::objectUses(InvoiceNumberField::class, $transactionLine)) { - /** @var InvoiceNumberField $transactionLine */ - $invoiceNumber = self::getField($transaction, $lineElement, 'invoicenumber'); - if ($invoiceNumber) { - $transactionLine->setInvoiceNumber(self::getField($transaction, $lineElement, 'invoicenumber')); + if (Util::objectUses(InvoiceNumberField::class, $transactionLine)) { + /** @var InvoiceNumberField $transactionLine */ + $invoiceNumber = self::getField($transaction, $lineElement, 'invoicenumber'); + if ($invoiceNumber) { + $transactionLine->setInvoiceNumber(self::getField($transaction, $lineElement, 'invoicenumber')); + } } - } - $transaction->addLine($transactionLine); + $transaction->addLine($transactionLine); + } } return $transaction; From 57f8ddf2e3262b97cdf1fe7ab735757499b7f659 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 29 Apr 2019 08:46:25 +0200 Subject: [PATCH 032/388] Update TransactionsDocument.php --- src/DomDocuments/TransactionsDocument.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DomDocuments/TransactionsDocument.php b/src/DomDocuments/TransactionsDocument.php index 79bc7ef4..e7f019ea 100644 --- a/src/DomDocuments/TransactionsDocument.php +++ b/src/DomDocuments/TransactionsDocument.php @@ -107,7 +107,7 @@ public function addTransaction(BaseTransaction $transaction) $headerElement->appendChild($this->createNodeWithTextContent('statementnumber', $transaction->getStatementnumber())); } - if ($transaction instanceof CashTransaction) { + if ($transaction instanceof BankTransaction || $transaction instanceof CashTransaction) { $headerElement->appendChild($this->createNodeWithTextContent('startvalue', Util::formatMoney($transaction->getStartvalue()))); $headerElement->appendChild($this->createNodeWithTextContent('closevalue', Util::formatMoney($transaction->getClosevalue()))); } From 9ef387750620bb76c053bb1ea36e501da9a85611 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 29 Apr 2019 08:47:19 +0200 Subject: [PATCH 033/388] Update BankTransactionIntegrationTest.php --- tests/IntegrationTests/BankTransactionIntegrationTest.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index 993df09d..d4add1d2 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -15,12 +15,10 @@ use PhpTwinfield\Mappers\TransactionMapper; use PhpTwinfield\Office; use PhpTwinfield\Response\Response; -use PhpTwinfield\SalesTransaction; -use PhpTwinfield\SalesTransactionLine; /** - * @covers SalesTransaction - * @covers SalesTransactionLine + * @covers BankTransaction + * @covers BankTransactionLine * @covers TransactionsDocument * @covers TransactionMapper * @covers TransactionApiConnector @@ -108,7 +106,7 @@ public function testGetBankTransactionWorks() $this->assertEquals(Money::EUR(65333), $totalLine->getRepValue()); $this->assertSame(1.500000000, $totalLine->getRepRate()); $this->assertSame('Invoice paid', $detailLine->getDescription()); - $this->assertSame(SalesTransactionLine::MATCHSTATUS_AVAILABLE, $detailLine->getMatchStatus()); + $this->assertSame(BankTransactionLine::MATCHSTATUS_AVAILABLE, $detailLine->getMatchStatus()); $this->assertSame(2, $detailLine->getMatchLevel()); $this->assertEquals(Money::EUR(43555), $detailLine->getBaseValueOpen()); $this->assertEquals(Money::EUR(65333), $detailLine->getRepValue()); From 5ec14bbb2bff756ba00c55ea2409b18c707e3606 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 29 Apr 2019 08:50:33 +0200 Subject: [PATCH 034/388] Update TransactionMapper.php --- src/Mappers/TransactionMapper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 9f754d14..214688ef 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -123,7 +123,7 @@ public static function map(string $transactionClassName, Response $response): Ba if ($transaction instanceof JournalTransaction) { $transaction->setRegime(self::getField($transaction, $transactionElement, 'regime')); } - if ($transaction instanceof CashTransaction) { + if ($transaction instanceof BankTransaction || $transaction instanceof CashTransaction) { $transaction->setStartvalue( Util::parseMoney( self::getField($transaction, $transactionElement, 'startvalue'), From 57d699b80e85780c5047617afdb463335ac6543a Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:14:29 +0200 Subject: [PATCH 035/388] Add files via upload --- src/Activity.php | 54 ++++ src/ActivityProjects.php | 79 ++++++ src/ActivityQuantity.php | 22 ++ src/Article.php | 208 +++----------- src/ArticleLine.php | 147 ++-------- src/AssetMethod.php | 93 ++++++ src/AssetMethodBalanceAccounts.php | 26 ++ src/AssetMethodFreeText.php | 23 ++ src/AssetMethodProfitLossAccounts.php | 18 ++ src/CashBankBook.php | 19 ++ src/CostCenter.php | 38 +++ src/Country.php | 19 ++ src/Currency.php | 45 +++ src/CurrencyRate.php | 18 ++ src/Customer.php | 389 +++++--------------------- src/CustomerAddress.php | 248 +++------------- src/CustomerBank.php | 210 +++----------- src/CustomerChildValidation.php | 18 ++ src/CustomerCollectMandate.php | 118 +------- src/CustomerCreditManagement.php | 120 ++------ src/CustomerFinancials.php | 93 ++++++ src/CustomerLine.php | 32 +++ src/CustomerPostingRule.php | 50 ++++ src/DimensionGroup.php | 45 +++ src/DimensionGroupDimension.php | 16 ++ src/DimensionType.php | 55 ++++ src/DimensionTypeAddress.php | 24 ++ src/DimensionTypeLevels.php | 16 ++ src/Dummy.php | 20 ++ src/Exception.php | 2 +- src/FixedAsset.php | 67 +++++ src/FixedAssetFinancials.php | 35 +++ src/FixedAssetFixedAssets.php | 99 +++++++ src/FixedAssetTransactionLine.php | 56 ++++ src/GeneralLedger.php | 66 +++++ src/GeneralLedgerChildValidation.php | 18 ++ src/GeneralLedgerFinancials.php | 53 ++++ src/Invoice.php | 259 +++++------------ src/InvoiceLine.php | 229 +++------------ src/InvoiceTotals.php | 29 +- src/InvoiceType.php | 19 ++ src/InvoiceVatLine.php | 19 ++ src/Office.php | 61 ++-- src/PayCode.php | 19 ++ src/Project.php | 54 ++++ src/ProjectProjects.php | 79 ++++++ src/ProjectQuantity.php | 22 ++ src/Rate.php | 54 ++++ src/RateRateChange.php | 29 ++ src/Supplier.php | 348 +++++------------------ src/SupplierAddress.php | 239 +++------------- src/SupplierBank.php | 203 +++----------- src/SupplierChildValidation.php | 18 ++ src/SupplierFinancials.php | 74 +++++ src/SupplierLine.php | 32 +++ src/SupplierPostingRule.php | 50 ++++ src/User.php | 65 ++--- src/UserRole.php | 19 ++ src/Util.php | 13 +- src/VatCode.php | 61 ++-- src/VatCodeAccount.php | 29 ++ src/VatCodePercentage.php | 47 ++++ src/VatGroup.php | 19 ++ 63 files changed, 2383 insertions(+), 2366 deletions(-) create mode 100644 src/Activity.php create mode 100644 src/ActivityProjects.php create mode 100644 src/ActivityQuantity.php create mode 100644 src/AssetMethod.php create mode 100644 src/AssetMethodBalanceAccounts.php create mode 100644 src/AssetMethodFreeText.php create mode 100644 src/AssetMethodProfitLossAccounts.php create mode 100644 src/CashBankBook.php create mode 100644 src/CostCenter.php create mode 100644 src/Country.php create mode 100644 src/Currency.php create mode 100644 src/CurrencyRate.php create mode 100644 src/CustomerChildValidation.php create mode 100644 src/CustomerFinancials.php create mode 100644 src/CustomerLine.php create mode 100644 src/CustomerPostingRule.php create mode 100644 src/DimensionGroup.php create mode 100644 src/DimensionGroupDimension.php create mode 100644 src/DimensionType.php create mode 100644 src/DimensionTypeAddress.php create mode 100644 src/DimensionTypeLevels.php create mode 100644 src/Dummy.php create mode 100644 src/FixedAsset.php create mode 100644 src/FixedAssetFinancials.php create mode 100644 src/FixedAssetFixedAssets.php create mode 100644 src/FixedAssetTransactionLine.php create mode 100644 src/GeneralLedger.php create mode 100644 src/GeneralLedgerChildValidation.php create mode 100644 src/GeneralLedgerFinancials.php create mode 100644 src/InvoiceType.php create mode 100644 src/InvoiceVatLine.php create mode 100644 src/PayCode.php create mode 100644 src/Project.php create mode 100644 src/ProjectProjects.php create mode 100644 src/ProjectQuantity.php create mode 100644 src/Rate.php create mode 100644 src/RateRateChange.php create mode 100644 src/SupplierChildValidation.php create mode 100644 src/SupplierFinancials.php create mode 100644 src/SupplierLine.php create mode 100644 src/SupplierPostingRule.php create mode 100644 src/UserRole.php create mode 100644 src/VatCodeAccount.php create mode 100644 src/VatCodePercentage.php create mode 100644 src/VatGroup.php diff --git a/src/Activity.php b/src/Activity.php new file mode 100644 index 00000000..594aaf99 --- /dev/null +++ b/src/Activity.php @@ -0,0 +1,54 @@ + + */ +class Activity extends BaseObject +{ + use BehaviourField; + use CodeField; + use DimensionTypeField; + use InUseField; + use NameField; + use OfficeField; + use ShortNameField; + use StatusField; + use TouchedField; + use UIDField; + use VatCodeField; + + private $projects; + + public function __construct() + { + $this->setTypeFromCode('ACT'); + $this->setProjects(new ActivityProjects); + } + + public function getProjects(): ActivityProjects + { + return $this->projects; + } + + public function setProjects(ActivityProjects $projects) + { + $this->projects = $projects; + return $this; + } +} \ No newline at end of file diff --git a/src/ActivityProjects.php b/src/ActivityProjects.php new file mode 100644 index 00000000..92720054 --- /dev/null +++ b/src/ActivityProjects.php @@ -0,0 +1,79 @@ +setAuthoriserInherit(true); + $this->setAuthoriserLocked(true); + $this->setBillableInherit(true); + $this->setBillableLocked(true); + $this->setCustomerInherit(true); + $this->setCustomerLocked(true); + $this->setRateInherit(true); + $this->setRateLocked(true); + } + + public function getQuantities() + { + return $this->quantities; + } + + public function addQuantity(ActivityQuantity $quantity) + { + $this->quantities[] = $quantity; + return $this; + } + + public function removeQuantity($index) + { + if (array_key_exists($index, $this->quantities)) { + unset($this->quantities[$index]); + return true; + } else { + return false; + } + } +} diff --git a/src/ActivityQuantity.php b/src/ActivityQuantity.php new file mode 100644 index 00000000..eb84b5c1 --- /dev/null +++ b/src/ActivityQuantity.php @@ -0,0 +1,22 @@ +code; - } - - public function setCode($code) - { - $this->code = $code; - return $this; - } - - public function getStatus() - { - return $this->status; - } - - public function setStatus($status) - { - $this->status = $status; - return $this; - } - - public function getType() - { - return $this->type; - } - - public function setType($type) - { - $this->type = $type; - return $this; - } - - public function getName() - { - return $this->name; - } - - public function setName($name) - { - $this->name = $name; - return $this; - } - - public function getShortName() - { - return $this->shortName; - } - - public function setShortName($shortName) - { - $this->shortName = $shortName; - return $this; - } - - public function getUnitNameSingular() - { - return $this->unitNameSingular; - } - - public function setUnitNameSingular($unitNameSingular) - { - $this->unitNameSingular = $unitNameSingular; - return $this; - } - - public function getUnitNamePlural() - { - return $this->unitNamePlural; - } - - public function setUnitNamePlural($unitNamePlural) - { - $this->unitNamePlural = $unitNamePlural; - return $this; - } - - public function getAllowChangeVatCode(): bool - { - return $this->allowChangeVatCode; - } - - public function setAllowChangeVatCode(bool $allowChangeVatCode): self - { - $this->allowChangeVatCode = $allowChangeVatCode; - return $this; - } - - public function getPerformanceType() - { - return $this->performanceType; - } - - public function setPerformanceType($performanceType) - { - $this->performanceType = $performanceType; - return $this; - } - - public function getAllowChangePerformanceType() - { - return $this->allowChangePerformanceType; - } - - public function setAllowChangePerformanceType($allowChangePerformanceType) - { - $this->allowChangePerformanceType - = $allowChangePerformanceType; - return $this; - } - - public function getPercentage() - { - return $this->percentage; - } - - public function setPercentage($percentage) - { - $this->percentage = $percentage; - return $this; - } - - public function getAllowDiscountorPremium(): bool - { - return $this->allowDiscountorPremium; - } - - public function setAllowDiscountorPremium(bool $allowDiscountorPremium): self - { - $this->allowDiscountorPremium = $allowDiscountorPremium; - return $this; - } - - public function getAllowChangeUnitsPrice(): bool - { - return $this->allowChangeUnitsPrice; - } - - public function setAllowChangeUnitsPrice(bool $allowChangeUnitsPrice): self - { - $this->allowChangeUnitsPrice = $allowChangeUnitsPrice; - return $this; - } - - public function getAllowDecimalQuantity(): bool - { - return $this->allowDecimalQuantity; - } - - public function setAllowDecimalQuantity(bool $allowDecimalQuantity): self - { - $this->allowDecimalQuantity = $allowDecimalQuantity; - return $this; + $this->setAllowChangeUnitsPrice(false); + $this->setAllowChangeVatCode(false); + $this->setAllowDecimalQuantity(false); + $this->setAllowDiscountorPremium(true); + $this->setTypeFromString('normal'); } public function getLines() diff --git a/src/ArticleLine.php b/src/ArticleLine.php index b8ec6d2f..6286332b 100644 --- a/src/ArticleLine.php +++ b/src/ArticleLine.php @@ -2,135 +2,40 @@ namespace PhpTwinfield; +use PhpTwinfield\Fields\FreeText3Field; +use PhpTwinfield\Fields\IDField; +use PhpTwinfield\Fields\InUseField; +use PhpTwinfield\Fields\Invoice\Article\ArticleLineFreeText1Field; +use PhpTwinfield\Fields\Invoice\Article\ArticleLineFreeText2Field; +use PhpTwinfield\Fields\Invoice\Article\SubCodeField; +use PhpTwinfield\Fields\Invoice\UnitsField; +use PhpTwinfield\Fields\Invoice\UnitsPriceExclField; +use PhpTwinfield\Fields\Invoice\UnitsPriceIncField; +use PhpTwinfield\Fields\NameField; +use PhpTwinfield\Fields\ShortNameField; +use PhpTwinfield\Fields\StatusField; + /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Articles * @todo Add documentation and typehints to all properties. */ -class ArticleLine +class ArticleLine extends BaseObject { - private $ID; - private $status; - private $inUse; - private $unitsPriceExcl; - private $unitsPriceInc; - private $units; - private $name; - private $shortName; - private $subCode; - private $freeText1; + use ArticleLineFreeText1Field; + use ArticleLineFreeText2Field; + use FreeText3Field; + use IDField; + use InUseField; + use NameField; + use ShortNameField; + use StatusField; + use SubCodeField; + use UnitsField; + use UnitsPriceExclField; + use UnitsPriceIncField; public function __construct() { $this->ID = uniqid(); } - - public function getID() - { - return $this->ID; - } - - public function setID($ID) - { - $this->ID = $ID; - return $this; - } - - public function getStatus() - { - return $this->status; - } - - public function setStatus($status) - { - $this->status = $status; - return $this; - } - - public function getInUse() - { - return $this->inUse; - } - - public function setInUse($inUse) - { - $this->inUse = $inUse; - return $this; - } - - public function getUnitsPriceInc() - { - return $this->unitsPriceInc; - } - - public function setUnitsPriceInc($unitsPriceInc) - { - $this->unitsPriceInc = $unitsPriceInc; - return $this; - } - - public function getUnitsPriceExcl () - { - return $this->unitsPriceExcl; - } - - public function setUnitsPriceExcl($unitsPriceExcl) - { - $this->unitsPriceExcl = $unitsPriceExcl; - return $this; - } - - public function getUnits() - { - return $this->units; - } - - public function setUnits($units) - { - $this->units = $units; - return $this; - } - - public function getName() - { - return $this->name; - } - - public function setName($name) - { - $this->name = $name; - return $this; - } - - public function getShortName() - { - return $this->shortName; - } - - public function setShortName($shortName) - { - $this->shortName = $shortName; - return $this; - } - - public function getSubCode() - { - return $this->subCode; - } - - public function setSubCode($subCode) - { - $this->subCode = $subCode; - return $this; - } - - public function getFreeText1() - { - return $this->freeText1; - } - - public function setFreeText1($freeText1) - { - $this->freeText1 = $freeText1; - return $this; - } } diff --git a/src/AssetMethod.php b/src/AssetMethod.php new file mode 100644 index 00000000..b69c2ef1 --- /dev/null +++ b/src/AssetMethod.php @@ -0,0 +1,93 @@ +setBalanceAccounts(new AssetMethodBalanceAccounts); + $this->setProfitLossAccounts(new AssetMethodProfitLossAccounts); + } + + public function getBalanceAccounts(): AssetMethodBalanceAccounts + { + return $this->balanceAccounts; + } + + public function setBalanceAccounts(AssetMethodBalanceAccounts $balanceAccounts) + { + $this->balanceAccounts = $balanceAccounts; + return $this; + } + + public function getProfitLossAccounts(): AssetMethodProfitLossAccounts + { + return $this->profitLossAccounts; + } + + public function setProfitLossAccounts(AssetMethodProfitLossAccounts $profitLossAccounts) + { + $this->profitLossAccounts = $profitLossAccounts; + return $this; + } + + public function getFreeTexts() + { + return $this->freeTexts; + } + + public function addFreeText(AssetMethodFreeText $freeText) + { + $this->freeTexts[$freeText->getID()] = $freeText; + return $this; + } + + public function removeFreeText($index) + { + if (array_key_exists($index, $this->freeTexts)) { + unset($this->freeTexts[$index]); + return true; + } else { + return false; + } + } +} diff --git a/src/AssetMethodBalanceAccounts.php b/src/AssetMethodBalanceAccounts.php new file mode 100644 index 00000000..4ab5dd50 --- /dev/null +++ b/src/AssetMethodBalanceAccounts.php @@ -0,0 +1,26 @@ +ID = uniqid(); + } +} diff --git a/src/AssetMethodProfitLossAccounts.php b/src/AssetMethodProfitLossAccounts.php new file mode 100644 index 00000000..6a8f2b17 --- /dev/null +++ b/src/AssetMethodProfitLossAccounts.php @@ -0,0 +1,18 @@ + + */ +class CashBankBook extends BaseObject +{ + use CodeField; + use NameField; + use ShortNameField; +} \ No newline at end of file diff --git a/src/CostCenter.php b/src/CostCenter.php new file mode 100644 index 00000000..d649ec58 --- /dev/null +++ b/src/CostCenter.php @@ -0,0 +1,38 @@ + + */ +class CostCenter extends BaseObject +{ + use BehaviourField; + use CodeField; + use DimensionTypeField; + use InUseField; + use NameField; + use OfficeField; + use ShortNameField; + use StatusField; + use TouchedField; + use UIDField; + + public function __construct() + { + $this->setTypeFromCode('KPL'); + } +} diff --git a/src/Country.php b/src/Country.php new file mode 100644 index 00000000..e0137081 --- /dev/null +++ b/src/Country.php @@ -0,0 +1,19 @@ + + */ +class Country extends BaseObject +{ + use CodeField; + use NameField; + use ShortNameField; +} \ No newline at end of file diff --git a/src/Currency.php b/src/Currency.php new file mode 100644 index 00000000..ba76d763 --- /dev/null +++ b/src/Currency.php @@ -0,0 +1,45 @@ +rates; + } + + public function addRate(CurrencyRate $rate) + { + $this->rates[] = $rate; + return $this; + } + + public function removeRate($index) + { + if (array_key_exists($index, $this->rates)) { + unset($this->rates[$index]); + return true; + } else { + return false; + } + } +} diff --git a/src/CurrencyRate.php b/src/CurrencyRate.php new file mode 100644 index 00000000..01a40a11 --- /dev/null +++ b/src/CurrencyRate.php @@ -0,0 +1,18 @@ +code; - } + private $financials; + private $addresses = []; + private $banks = []; + private $postingRules = []; - public function setCode($code) + public function __construct() { - $this->code = $code; - return $this; - } - - public function getID() - { - trigger_error('getID is a deprecated method: Use getCode', E_USER_NOTICE); - return $this->getCode(); - } - - public function setID($ID) - { - trigger_error('setID is a deprecated method: Use setCode', E_USER_NOTICE); - return $this->setCode($ID); - } - - public function getUID() - { - return $this->UID; - } - - public function setUID($UID) - { - $this->UID = $UID; - return $this; - } - - public function getStatus() - { - return $this->status; - } - - public function setStatus($status) - { - $this->status = $status; - return $this; - } - - public function getName() - { - return $this->name; - } - - public function setName($name) - { - $this->name = $name; - return $this; - } - - public function getType() - { - return $this->type; - } - - public function getInUse() - { - return $this->inUse; - } + $this->setBeginPeriod(0); + $this->setBeginYear(0); + $this->setEndPeriod(0); + $this->setEndYear(0); + $this->setTypeFromCode('DEB'); - public function setInUse($inUse) - { - $this->inUse = $inUse; - return $this; - } - - public function getBehaviour() - { - return $this->behaviour; - } - - public function setBehaviour($behaviour) - { - $this->behaviour = $behaviour; - return $this; - } - - public function getTouched() - { - return $this->touched; - } - - public function setTouched($touched) - { - $this->touched = $touched; - return $this; - } - - public function getBeginPeriod() - { - return $this->beginPeriod; - } - - public function setBeginPeriod($beginPeriod) - { - $this->beginPeriod = $beginPeriod; - return $this; - } - - public function getBeginYear() - { - return $this->beginYear; - } - - public function setBeginYear($beginYear) - { - $this->beginYear = $beginYear; - return $this; - } - - public function getEndPeriod() - { - return $this->endPeriod; - } - - public function setEndPeriod($endPeriod) - { - $this->endPeriod = $endPeriod; - return $this; - } - - public function getEndYear() - { - return $this->endYear; + $this->setCreditManagement(new CustomerCreditManagement); + $this->setFinancials(new CustomerFinancials); } - public function setEndYear($endYear) + public function getCreditManagement(): CustomerCreditManagement { - $this->endYear = $endYear; - return $this; - } - - public function getWebsite() - { - return $this->website; - } - - public function setWebsite($website) - { - $this->website = $website; - return $this; - } - - public function getCocNumber() - { - trigger_error('setCocNumber is a deprecated method: get from CustomerAddress::field05', E_USER_NOTICE); - return $this->cocNumber; - } - - public function setCocNumber($cocNumber) - { - trigger_error('setCocNumber is a deprecated method: add to CustomerAddress::field05', E_USER_NOTICE); - $this->cocNumber = $cocNumber; - return $this; - } - - public function getVatNumber() - { - trigger_error('setVatNumber is a deprecated method: add to CustomerAddress::field04', E_USER_NOTICE); - return $this->vatNumber; - } - - public function setVatNumber($vatNumber) - { - trigger_error('setVatNumber is a deprecated method: get CustomerAddress::field04', E_USER_NOTICE); - $this->vatNumber = $vatNumber; - return $this; - } - - public function getEditDimensionName() - { - return $this->editDimensionName; - } - - public function setEditDimensionName($editDimensionName) - { - $this->editDimensionName = $editDimensionName; - return $this; - } - - public function getDueDays() - { - return $this->dueDays; - } - - public function setDueDays($dueDays) - { - $this->dueDays = $dueDays; - return $this; - } - - public function getPayAvailable(): bool - { - return $this->payAvailable; - } - - public function setPayAvailable(bool $payAvailable): self - { - $this->payAvailable = $payAvailable; - return $this; - } - - public function getPayCode() - { - return $this->payCode; - } - - public function setPayCode($payCode) - { - $this->payCode = $payCode; - return $this; - } - - public function getEBilling(): bool - { - return $this->eBilling; - } - - public function setEBilling(bool $eBilling): self - { - $this->eBilling = $eBilling; - return $this; - } - - public function getEBillMail() - { - return $this->eBillMail; - } - - public function setEBillMail($eBillMail) - { - $this->eBillMail = $eBillMail; - return $this; - } - - /** - * - * @return CustomerCollectMandate - */ - public function getCollectMandate(): ?CustomerCollectMandate - { - return $this->collectMandate; + return $this->creditManagement; } - public function setCollectMandate(CustomerCollectMandate $collectMandate): self + public function setCreditManagement(CustomerCreditManagement $creditManagement) { - $this->collectMandate = $collectMandate; + $this->creditManagement = $creditManagement; return $this; } - /** - * - * @return CustomerCreditManagement - */ - public function getCreditManagement(): ?CustomerCreditManagement + public function getFinancials(): CustomerFinancials { - return $this->creditManagement; + return $this->financials; } - public function setCreditManagement(CustomerCreditManagement $creditManagement) + public function setFinancials(CustomerFinancials $financials) { - $this->creditManagement = $creditManagement; + $this->financials = $financials; return $this; } @@ -369,30 +136,24 @@ public function removeBank($index) } } - public function getGroups() + public function getPostingRules() { - return $this->groups; + return $this->postingRules; } - public function setGroups($groups) + public function addPostingRule(CustomerPostingRule $postingRule) { - $this->groups = $groups; + $this->postingRules[$postingRule->getID()] = $postingRule; return $this; } - /** - * @return string - */ - public function getCountry(): string - { - return $this->country; - } - - /** - * @param string $country - */ - public function setCountry(string $country): void + public function removePostingRule($index) { - $this->country = $country; + if (array_key_exists($index, $this->postingRules)) { + unset($this->postingRules[$index]); + return true; + } else { + return false; + } } } diff --git a/src/CustomerAddress.php b/src/CustomerAddress.php index e7226c1d..87f15be1 100644 --- a/src/CustomerAddress.php +++ b/src/CustomerAddress.php @@ -2,226 +2,48 @@ namespace PhpTwinfield; +use PhpTwinfield\Fields\IDField; +use PhpTwinfield\Fields\Level1234\Level2\AddressTypeField; +use PhpTwinfield\Fields\Level1234\Level2\CityField; +use PhpTwinfield\Fields\Level1234\Level2\CountryField; +use PhpTwinfield\Fields\Level1234\Level2\DefaultField; +use PhpTwinfield\Fields\Level1234\Level2\EmailField; +use PhpTwinfield\Fields\Level1234\Level2\Field1Field; +use PhpTwinfield\Fields\Level1234\Level2\Field2Field; +use PhpTwinfield\Fields\Level1234\Level2\Field3Field; +use PhpTwinfield\Fields\Level1234\Level2\Field4Field; +use PhpTwinfield\Fields\Level1234\Level2\Field5Field; +use PhpTwinfield\Fields\Level1234\Level2\Field6Field; +use PhpTwinfield\Fields\Level1234\Level2\PostcodeField; +use PhpTwinfield\Fields\Level1234\Level2\TelefaxField; +use PhpTwinfield\Fields\Level1234\Level2\TelephoneField; +use PhpTwinfield\Fields\NameField; + /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers * @todo Add documentation and typehints to all properties. */ -class CustomerAddress +class CustomerAddress extends BaseObject { - private $ID; - private $type; - private $default; - private $name; - private $contact; - private $country; - private $city; - private $postcode; - private $telephone; - private $fax; - private $email; - private $field1; - private $field2; - private $field3; - private $field4; - private $field5; - private $field6; + use AddressTypeField; + use CityField; + use CountryField; + use DefaultField; + use EmailField; + use Field1Field; + use Field2Field; + use Field3Field; + use Field4Field; + use Field5Field; + use Field6Field; + use IDField; + use NameField; + use PostcodeField; + use TelefaxField; + use TelephoneField; public function __construct() { $this->ID = uniqid(); } - - public function getID() - { - return $this->ID; - } - - public function setID($ID) - { - $this->ID = $ID; - return $this; - } - - public function getType() - { - return $this->type; - } - - public function setType($type) - { - $this->type = $type; - return $this; - } - - /** - * @return bool - */ - public function getDefault() : bool - { - return $this->default; - } - - /** - * @param bool $default - * @return $this - */ - public function setDefault(bool $default) - { - $this->default = $default; - return $this; - } - - public function getName() - { - return $this->name; - } - - public function setName($name) - { - $this->name = $name; - return $this; - } - - public function getContact() - { - return $this->contact; - } - - public function setContact($contact) - { - $this->contact = $contact; - return $this; - } - - public function getCountry() - { - return $this->country; - } - - public function setCountry($country) - { - $this->country = $country; - return $this; - } - - public function getCity() - { - return $this->city; - } - - public function setCity($city) - { - $this->city = $city; - return $this; - } - - public function getPostcode() - { - return $this->postcode; - } - - public function setPostcode($postcode) - { - $this->postcode = $postcode; - return $this; - } - - public function getTelephone() - { - return $this->telephone; - } - - public function setTelephone($telephone) - { - $this->telephone = $telephone; - return $this; - } - - public function getFax() - { - return $this->fax; - } - - public function setFax($fax) - { - $this->fax = $fax; - return $this; - } - - public function getEmail() - { - return $this->email; - } - - public function setEmail($email) - { - $this->email = $email; - return $this; - } - - public function getField1() - { - return $this->field1; - } - - public function setField1($field1) - { - $this->field1 = $field1; - return $this; - } - - public function getField2() - { - return $this->field2; - } - - public function setField2($field2) - { - $this->field2 = $field2; - return $this; - } - - public function getField3() - { - return $this->field3; - } - - public function setField3($field3) - { - $this->field3 = $field3; - return $this; - } - - public function getField4() - { - return $this->field4; - } - - public function setField4($field4) - { - $this->field4 = $field4; - return $this; - } - - public function getField5() - { - return $this->field5; - } - - public function setField5($field5) - { - $this->field5 = $field5; - return $this; - } - - public function getField6() - { - return $this->field6; - } - - public function setField6($field6) - { - $this->field6 = $field6; - return $this; - } -} +} \ No newline at end of file diff --git a/src/CustomerBank.php b/src/CustomerBank.php index a59fa791..a440607a 100644 --- a/src/CustomerBank.php +++ b/src/CustomerBank.php @@ -2,190 +2,46 @@ namespace PhpTwinfield; +use PhpTwinfield\Fields\IDField; +use PhpTwinfield\Fields\Level1234\Level2\AccountNumberField; +use PhpTwinfield\Fields\Level1234\Level2\AddressField2Field; +use PhpTwinfield\Fields\Level1234\Level2\AddressField3Field; +use PhpTwinfield\Fields\Level1234\Level2\AscriptionField; +use PhpTwinfield\Fields\Level1234\Level2\BankBlockedField; +use PhpTwinfield\Fields\Level1234\Level2\BankNameField; +use PhpTwinfield\Fields\Level1234\Level2\BicCodeField; +use PhpTwinfield\Fields\Level1234\Level2\CityField; +use PhpTwinfield\Fields\Level1234\Level2\CountryField; +use PhpTwinfield\Fields\Level1234\Level2\DefaultField; +use PhpTwinfield\Fields\Level1234\Level2\IbanField; +use PhpTwinfield\Fields\Level1234\Level2\NatBicCodeField; +use PhpTwinfield\Fields\Level1234\Level2\PostcodeField; +use PhpTwinfield\Fields\Level1234\Level2\StateField; + /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers * @todo Add documentation and typehints to all properties. */ -class CustomerBank +class CustomerBank extends BaseObject { - private $ID; # integer Sequence number of the bank account line. - private $default; # true/false Is this the default bank account, only one default bank account is possible. - private $ascription; # string(40) Account holder. - private $accountnumber; # string(40) Account number. - private $addressField2; # string(128) Bank address. - private $addressField3; # string(128) Bank address number. - private $bankname; # string(40) Bank name. - private $biccode; # string(16) BIC code. - private $city; # string(40) City. - private $country; # string(2) Bank country code. The ISO country codes are used. - private $iban; # string(40) IBAN account number. - private $natbiccode; # string(20) National bank code. - private $postcode; # string(16) Postcode. - private $state; # string(40) State. + use AccountNumberField; + use AddressField2Field; + use AddressField3Field; + use AscriptionField; + use BankNameField; + use BankBlockedField; + use BicCodeField; + use CityField; + use CountryField; + use DefaultField; + use IbanField; + use IDField; + use NatBicCodeField; + use PostcodeField; + use StateField; public function __construct() { $this->ID = uniqid(); } - - public function getID() - { - return $this->ID; - } - - public function setID($ID) - { - $this->ID = $ID; - return $this; - } - - /** - * @return bool - */ - public function getDefault() : bool - { - return $this->default; - } - - /** - * @param bool $default - * @return $this - */ - public function setDefault(bool $default) - { - $this->default = $default; - return $this; - } - - public function getAscription() - { - return $this->ascription; - } - - public function setAscription($ascription) - { - $this->ascription = $ascription; - return $this; - } - - public function getAccountnumber() - { - return $this->accountnumber; - } - - public function setAccountnumber($accountnumber) - { - $this->accountnumber = $accountnumber; - return $this; - } - - public function getAddressField2() - { - return $this->addressField2; - } - - public function setAddressField2($addressField2) - { - $this->addressField2 = $addressField2; - return $this; - } - - public function getAddressField3() - { - return $this->addressField3; - } - - public function setAddressField3($addressField3) - { - $this->addressField3 = $addressField3; - return $this; - } - - public function getBankname() - { - return $this->bankname; - } - - public function setBankname($bankname) - { - $this->bankname = $bankname; - return $this; - } - - public function getBiccode() - { - return $this->biccode; - } - - public function setBiccode($biccode) - { - $this->biccode = $biccode; - return $this; - } - - public function getCity() - { - return $this->city; - } - - public function setCity($city) - { - $this->city = $city; - return $this; - } - - public function getCountry() - { - return $this->country; - } - - public function setCountry($country) - { - $this->country = $country; - return $this; - } - - public function getIban() - { - return $this->iban; - } - - public function setIban($iban) - { - $this->iban = $iban; - return $this; - } - - public function getNatbiccode() - { - return $this->natbiccode; - } - - public function setNatbiccode($natbiccode) - { - $this->natbiccode = $natbiccode; - return $this; - } - - public function getPostcode() - { - return $this->postcode; - } - - public function setPostcode($postcode) - { - $this->postcode = $postcode; - return $this; - } - - public function getState() - { - return $this->state; - } - - public function setState($state) - { - $this->state = $state; - return $this; - } -} +} \ No newline at end of file diff --git a/src/CustomerChildValidation.php b/src/CustomerChildValidation.php new file mode 100644 index 00000000..b06bff43 --- /dev/null +++ b/src/CustomerChildValidation.php @@ -0,0 +1,18 @@ +ID; - } - - /** - * @param string $ID - * @return $this - */ - public function setID(string $ID): self + use FirstRunDateField; + use IDField; + use SignatureDateField; + + public function __construct() { - Assert::maxLength($ID, 35); - $this->ID = $ID; - - return $this; - } - - /** - * @return \DateTimeInterface|null - */ - public function getSignatureDate(): ?\DateTimeInterface - { - return $this->signatureDate; - } - - /** - * @param \DateTimeInterface|null $date - * @return $this - */ - public function setSignatureDate(?\DateTimeInterface $date): self - { - $this->signatureDate = $date; - - return $this; - } - - /** - * @param string|null $dateString - * @return $this - * @throws Exception - */ - public function setSignatureDateFromString(?string $dateString): self - { - if (!empty($dateString)) { - $dateString = Util::parseDate($dateString); - } - - return $this->setSignatureDate($dateString); - } - - /** - * @return \DateTimeInterface|null - */ - public function getFirstRunDate(): ?\DateTimeInterface - { - return $this->firstRunDate; - } - - /** - * @param \DateTimeInterface|null $date - * @return $this - */ - public function setFirstRunDate(?\DateTimeInterface $date): self - { - $this->firstRunDate = $date; - - return $this; - } - - /** - * @param string|null $dateString - * @return $this - * @throws Exception - */ - public function setFirstRunDateFromString(?string $dateString): self - { - if (!empty($dateString)) { - $dateString = Util::parseDate($dateString); - } - - return $this->setFirstRunDate($dateString); + $this->ID = uniqid(); } } diff --git a/src/CustomerCreditManagement.php b/src/CustomerCreditManagement.php index 95f6e4c5..9a3aefb2 100644 --- a/src/CustomerCreditManagement.php +++ b/src/CustomerCreditManagement.php @@ -2,110 +2,38 @@ namespace PhpTwinfield; -use PhpTwinfield\Transactions\TransactionLineFields\CommentField; +use PhpTwinfield\Fields\FreeText2Field; +use PhpTwinfield\Fields\FreeText3Field; +use PhpTwinfield\Fields\Level1234\Level2\Customer\BaseCreditLimitField; +use PhpTwinfield\Fields\Level1234\Level2\Customer\BlockedField; +use PhpTwinfield\Fields\Level1234\Level2\Customer\BlockedLockedField; +use PhpTwinfield\Fields\Level1234\Level2\Customer\BlockedModifiedField; +use PhpTwinfield\Fields\Level1234\Level2\Customer\CommentField; +use PhpTwinfield\Fields\Level1234\Level2\Customer\CustomerFreeText1Field; +use PhpTwinfield\Fields\Level1234\Level2\Customer\ReminderEmailField; +use PhpTwinfield\Fields\Level1234\Level2\Customer\ResponsibleUserField; +use PhpTwinfield\Fields\Level1234\Level2\Customer\SendReminderField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers * @todo Add documentation and typehints to all properties. */ -class CustomerCreditManagement +class CustomerCreditManagement extends BaseObject { + use BaseCreditLimitField; + use BlockedField; + use BlockedLockedField; + use BlockedModifiedField; use CommentField; + use CustomerFreeText1Field; + use FreeText2Field; + use FreeText3Field; + use ReminderEmailField; + use ResponsibleUserField; + use SendReminderField; - private $responsibleUser; #string(16) The credit manager. - private $baseCreditLimit = 0; #amount The credit limit amount. - private $sendReminder = true; #true/email/false Determines if and how a customer will be reminded. - private $reminderEmail; #string(200) Mandatory if sendreminder is email. - private $blocked = false; #true/false Are related projects for this cust. blocked in time & expenses. - private $freeText1; #true/false Right of use. - private $freeText2; #string(40) Segment code. - private $freeText3; # Not in use - - public function getResponsibleUser() - { - return $this->responsibleUser; - } - - public function getBaseCreditLimit() - { - return $this->baseCreditLimit; - } - - public function getSendReminder() - { - return $this->sendReminder; - } - - public function getReminderEmail() - { - return $this->reminderEmail; - } - - public function getBlocked() - { - return $this->blocked; - } - - public function getFreeText1() - { - return $this->freeText1; - } - - public function getFreeText2() - { - return $this->freeText2; - } - - public function getFreeText3() - { - return $this->freeText3; - } - - public function setResponsibleUser($responsibleUser) - { - $this->responsibleUser = $responsibleUser; - return $this; - } - - public function setBaseCreditLimit($baseCreditLimit) - { - $this->baseCreditLimit = $baseCreditLimit; - return $this; - } - - public function setSendReminder($sendReminder) - { - $this->sendReminder = $sendReminder; - return $this; - } - - public function setReminderEmail($reminderEmail) - { - $this->reminderEmail = $reminderEmail; - return $this; - } - - public function setBlocked($blocked) - { - $this->blocked = $blocked; - return $this; - } - - public function setFreeText1($freeText1) - { - $this->freeText1 = $freeText1; - return $this; - } - - public function setFreeText2($freeText2) - { - $this->freeText2 = $freeText2; - return $this; - } - - public function setFreeText3($freeText3) + public function __construct() { - $this->freeText3 = $freeText3; - return $this; + $this->setSendReminderFromString('true'); } } diff --git a/src/CustomerFinancials.php b/src/CustomerFinancials.php new file mode 100644 index 00000000..81fb5c4f --- /dev/null +++ b/src/CustomerFinancials.php @@ -0,0 +1,93 @@ +setAccountTypeFromString('inherit'); + $this->setCollectionSchemaFromString('core'); + $this->setDueDays(30); + $this->setMatchTypeFromString('customersupplier'); + $this->setSubAnalyseFromString('false'); + $this->setSubstitutionLevel(1); + + $this->setCollectMandate(new CustomerCollectMandate); + } + + public function getCollectMandate(): CustomerCollectMandate + { + return $this->collectmandate; + } + + public function setCollectMandate(CustomerCollectMandate $collectmandate) + { + $this->collectmandate = $collectmandate; + return $this; + } + + public function getChildValidations() + { + return $this->childValidations; + } + + public function addChildValidation(CustomerChildValidation $childValidation) + { + $this->childValidations[] = $childValidation; + return $this; + } + + public function removeChildValidation($index) + { + if (array_key_exists($index, $this->childValidations)) { + unset($this->childValidations[$index]); + return true; + } else { + return false; + } + } +} diff --git a/src/CustomerLine.php b/src/CustomerLine.php new file mode 100644 index 00000000..8e97a127 --- /dev/null +++ b/src/CustomerLine.php @@ -0,0 +1,32 @@ +ID = uniqid(); + } + + public function getLines() + { + return $this->lines; + } + + public function addLine(CustomerLine $line) + { + $this->lines[] = $line; + return $this; + } + + public function removeLine($index) + { + if (array_key_exists($index, $this->lines)) { + unset($this->lines[$index]); + return true; + } else { + return false; + } + } +} diff --git a/src/DimensionGroup.php b/src/DimensionGroup.php new file mode 100644 index 00000000..4d48ff7a --- /dev/null +++ b/src/DimensionGroup.php @@ -0,0 +1,45 @@ +dimensions; + } + + public function addDimension(DimensionGroupDimension $dimension) + { + $this->dimensions[] = $dimension; + return $this; + } + + public function removeDimension($index) + { + if (array_key_exists($index, $this->dimensions)) { + unset($this->dimensions[$index]); + return true; + } else { + return false; + } + } +} diff --git a/src/DimensionGroupDimension.php b/src/DimensionGroupDimension.php new file mode 100644 index 00000000..3825b7f4 --- /dev/null +++ b/src/DimensionGroupDimension.php @@ -0,0 +1,16 @@ +setAddress(new DimensionTypeAddress); + $this->setLevels(new DimensionTypeLevels); + } + + public function getAddress(): DimensionTypeAddress + { + return $this->address; + } + + public function setAddress(DimensionTypeAddress $address) + { + $this->address = $address; + return $this; + } + + public function getLevels(): DimensionTypeLevels + { + return $this->levels; + } + + public function setLevels(DimensionTypeLevels $levels) + { + $this->levels = $levels; + return $this; + } +} \ No newline at end of file diff --git a/src/DimensionTypeAddress.php b/src/DimensionTypeAddress.php new file mode 100644 index 00000000..bae379f5 --- /dev/null +++ b/src/DimensionTypeAddress.php @@ -0,0 +1,24 @@ + + */ +class Dummy extends BaseObject +{ + use CodeField; + use NameField; + use ShortNameField; +} \ No newline at end of file diff --git a/src/Exception.php b/src/Exception.php index 4eafbd4f..eb9c4ded 100644 --- a/src/Exception.php +++ b/src/Exception.php @@ -60,4 +60,4 @@ public static function invalidMatchStatusForLineType( $transactionLine->getLineType() )); } -} +} \ No newline at end of file diff --git a/src/FixedAsset.php b/src/FixedAsset.php new file mode 100644 index 00000000..122b21c8 --- /dev/null +++ b/src/FixedAsset.php @@ -0,0 +1,67 @@ + + */ +class FixedAsset extends BaseObject +{ + use BehaviourField; + use CodeField; + use DimensionGroupField; + use DimensionTypeField; + use InUseField; + use NameField; + use OfficeField; + use ShortNameField; + use StatusField; + use TouchedField; + use UIDField; + + private $financials; + private $fixedAssets; + + public function __construct() + { + $this->setTypeFromCode('AST'); + $this->setFinancials(new FixedAssetFinancials); + $this->setFixedAssets(new FixedAssetFixedAssets); + } + + public function getFinancials(): FixedAssetFinancials + { + return $this->financials; + } + + public function setFinancials(FixedAssetFinancials $financials) + { + $this->financials = $financials; + return $this; + } + + public function getFixedAssets(): FixedAssetFixedAssets + { + return $this->fixedAssets; + } + + public function setFixedAssets(FixedAssetFixedAssets $fixedAssets) + { + $this->fixedAssets = $fixedAssets; + return $this; + } +} \ No newline at end of file diff --git a/src/FixedAssetFinancials.php b/src/FixedAssetFinancials.php new file mode 100644 index 00000000..c2bd644c --- /dev/null +++ b/src/FixedAssetFinancials.php @@ -0,0 +1,35 @@ +setSubstitutionLevel(2); + } +} diff --git a/src/FixedAssetFixedAssets.php b/src/FixedAssetFixedAssets.php new file mode 100644 index 00000000..2f8351f7 --- /dev/null +++ b/src/FixedAssetFixedAssets.php @@ -0,0 +1,99 @@ +transactionLines; + } + + public function addTransactionLine(FixedAssetTransactionLine $transactionLine) + { + $this->transactionLines[] = $transactionLine; + return $this; + } + + public function removeTransactionLine($index) + { + if (array_key_exists($index, $this->transactionLines)) { + unset($this->transactionLines[$index]); + return true; + } else { + return false; + } + } +} diff --git a/src/FixedAssetTransactionLine.php b/src/FixedAssetTransactionLine.php new file mode 100644 index 00000000..1a91c152 --- /dev/null +++ b/src/FixedAssetTransactionLine.php @@ -0,0 +1,56 @@ + + */ +class GeneralLedger extends BaseObject +{ + use BeginYearField; + use BehaviourField; + use CodeField; + use DimensionGroupField; + use DimensionTypeField; + use EndYearField; + use GeneralLedgerBeginPeriodField; + use GeneralLedgerEndPeriodField; + use InUseField; + use NameField; + use OfficeField; + use ShortNameField; + use StatusField; + use TouchedField; + use UIDField; + + private $financials; + + public function __construct() + { + $this->setBeginPeriod(0); + $this->setBeginYear(0); + $this->setEndPeriod(0); + $this->setEndYear(0); + + $this->setFinancials(new GeneralLedgerFinancials); + } + + public function getFinancials(): GeneralLedgerFinancials + { + return $this->financials; + } + + public function setFinancials(GeneralLedgerFinancials $financials) + { + $this->financials = $financials; + return $this; + } +} diff --git a/src/GeneralLedgerChildValidation.php b/src/GeneralLedgerChildValidation.php new file mode 100644 index 00000000..876800af --- /dev/null +++ b/src/GeneralLedgerChildValidation.php @@ -0,0 +1,18 @@ +setMatchTypeFromString('notmatchable'); + $this->setSubAnalyseFromString('maybe'); + } + + public function getChildValidations() + { + return $this->childValidations; + } + + public function addChildValidation(GeneralLedgerChildValidation $childValidation) + { + $this->childValidations[] = $childValidation; + return $this; + } + + public function removeChildValidation($index) + { + if (array_key_exists($index, $this->childValidations)) { + unset($this->childValidations[$index]); + return true; + } else { + return false; + } + } +} diff --git a/src/Invoice.php b/src/Invoice.php index 658ed7b4..e4851d0a 100644 --- a/src/Invoice.php +++ b/src/Invoice.php @@ -1,9 +1,29 @@ + * @author Leon Rowland , extended by Yannick Aerssens * @copyright (c) 2013, Leon Rowland * @version 0.0.1 * * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices * @todo Add documentation and typehints to all properties. - * @todo Add support for VatLines. */ -class Invoice +class Invoice extends BaseObject { - use PeriodField; + use BankField; + use CalculateOnlyField; + use CurrencyField; + use CustomerField; + use CustomerNameField; + use DeliverAddressNumberField; use DueDateField; + use FinancialCodeField; + use FinancialNumberField; + use FooterTextField; + use HeaderTextField; + use InvoiceAddressNumberField; + use InvoiceAmountField; + use InvoiceDateField; + use InvoiceDebitCreditField; + use InvoiceNumberField; + use InvoiceTypeField; + use InvoiceStatusField; use OfficeField; + use PaymentMethodField; + use PerformanceDateField; + use PeriodField; + use RaiseWarningField; - private $customer; - private $invoiceType; - private $invoiceNumber; - private $status; - private $currency; - private $invoiceDate; - private $performanceDate; - private $paymentMethod; - private $bank; - private $invoiceAddressNumber; - private $deliverAddressNumber; - private $headerText; - private $footerText; private $totals; - - private $financialCode; - private $financialNumber; - - /** - * @var InvoiceLine[] - */ private $lines = []; - - public function addLine(InvoiceLine $line) - { - $this->lines[$line->getID()] = $line; - return $this; - } - - /** - * @return InvoiceLine[] - */ - public function getLines(): array - { - return $this->lines; - } - - public function getCustomer(): Customer - { - return $this->customer; - } - - public function setCustomer(Customer $customer) - { - $this->customer = $customer; - return $this; - } + private $vatlines = []; public function setTotals(InvoiceTotals $totals) { @@ -91,162 +86,46 @@ public function getTotals(): InvoiceTotals return $this->totals; } - public function getInvoiceType() - { - return $this->invoiceType; - } - - public function setInvoiceType($invoiceType) - { - $this->invoiceType = $invoiceType; - return $this; - } - - public function getInvoiceNumber() - { - return $this->invoiceNumber; - } - - public function setInvoiceNumber($invoiceNumber) - { - $this->invoiceNumber = $invoiceNumber; - return $this; - } - - public function getStatus() - { - return $this->status; - } - - public function setStatus($status) - { - $this->status = $status; - return $this; - } - - public function getCurrency() - { - return $this->currency; - } - - public function setCurrency($currency) - { - $this->currency = $currency; - return $this; - } - - public function getInvoiceDate() - { - return $this->invoiceDate; - } - - public function setInvoiceDate($invoiceDate) - { - $this->invoiceDate = $invoiceDate; - return $this; - } - - public function getPerformanceDate() - { - return $this->performanceDate; - } - - public function setPerformanceDate($performanceDate) - { - $this->performanceDate = $performanceDate; - return $this; - } - - public function getPaymentMethod() - { - return $this->paymentMethod; - } - - public function setPaymentMethod($paymentMethod) - { - $this->paymentMethod = $paymentMethod; - return $this; - } - - public function getBank() - { - return $this->bank; - } - - public function setBank($bank) - { - $this->bank = $bank; - return $this; - } - - public function getInvoiceAddressNumber() - { - return $this->invoiceAddressNumber; - } - - public function setInvoiceAddressNumber($invoiceAddressNumber) - { - $this->invoiceAddressNumber = $invoiceAddressNumber; - return $this; - } - - public function getDeliverAddressNumber() + /** + * @return InvoiceLine[] + */ + public function getLines(): array { - return $this->deliverAddressNumber; + return $this->lines; } - public function setDeliverAddressNumber($delivererAddressNumber) + public function addLine(InvoiceLine $line) { - $this->deliverAddressNumber = $delivererAddressNumber; + $this->lines[$line->getID()] = $line; return $this; } - public function getHeaderText() + public function removeLine($index) { - return $this->headerText; - } - - public function setHeaderText($headerText) - { - $this->headerText = $headerText; - return $this; + if (array_key_exists($index, $this->lines)) { + unset($this->lines[$index]); + return true; + } else { + return false; + } } - public function getFooterText() + /** + * @return InvoiceVatLine[] + */ + public function getVatLines(): array { - return $this->footerText; + return $this->vatlines; } - public function setFooterText($footerText) + public function addVatLine(InvoiceVatLine $vatline) { - $this->footerText = $footerText; + $this->vatlines[] = $vatline; return $this; } - public function getFinancialCode() - { - return $this->financialCode; - } - - public function setFinancialCode($financialCode) - { - $this->financialCode = $financialCode; - return $this; - } - - public function getFinancialNumber() - { - return $this->financialNumber; - } - - public function setFinancialNumber($financialNumber) - { - $this->financialNumber = $financialNumber; - return $this; - } - public function getMatchReference(): MatchReferenceInterface { return new MatchReference($this->getOffice(), $this->getFinancialCode(), $this->getFinancialNumber(), 1); } -} +} \ No newline at end of file diff --git a/src/InvoiceLine.php b/src/InvoiceLine.php index a8a14c8d..ed400e72 100644 --- a/src/InvoiceLine.php +++ b/src/InvoiceLine.php @@ -1,211 +1,58 @@ ID = uniqid(); - $this->quantity = $quantity; $this->article = $article; $this->setFreeText1($freeText1); $this->setFreeText2($freeText2); } - - public function getID() - { - return $this->ID; - } - - public function setID($ID) - { - $this->ID = $ID; - return $this; - } - - public function getQuantity() - { - return $this->quantity; - } - - public function setQuantity($quantity) - { - $this->quantity = $quantity; - return $this; - } - - public function getArticle() - { - return $this->article; - } - - public function setArticle($article) - { - $this->article = $article; - return $this; - } - - public function getSubArticle() - { - return $this->subArticle; - } - - public function setSubArticle($subArticle) - { - $this->subArticle = $subArticle; - return $this; - } - - public function getDescription() - { - return $this->description; - } - - public function setDescription($description) - { - $this->description = $description; - return $this; - } - - public function getUnitsPriceExcl() - { - return $this->unitsPriceExcl; - } - - public function setUnitsPriceExcl($unitsPriceExcl) - { - $this->unitsPriceExcl = $unitsPriceExcl; - return $this; - } - - public function getUnits() - { - return $this->units; - } - - public function setUnits($units) - { - $this->units = $units; - return $this; - } - - public function getAllowDiscountOrPremium() - { - return $this->allowDiscountOrPremium; - } - - public function setAllowDiscountOrPremium($allowDiscountOrPremium) - { - $this->allowDiscountOrPremium = $allowDiscountOrPremium; - return $this; - } - - public function getValueExcl() - { - return $this->valueExcl; - } - - public function setValueExcl($valueExcl) - { - $this->valueExcl = $valueExcl; - return $this; - } - - public function getVatValue() - { - return $this->vatValue; - } - - public function setVatValue($vatValue) - { - $this->vatValue = $vatValue; - return $this; - } - - public function getValueInc() - { - return $this->valueInc; - } - - public function setValueInc($valueInc) - { - $this->valueInc = $valueInc; - return $this; - } - - public function getUnitsPriceInc() - { - return $this->unitsPriceInc; - } - - public function setUnitsPriceInc($unitsPriceInc) - { - $this->unitsPriceInc = $unitsPriceInc; - return $this; - } - - public function getPerformanceDate() - { - return $this->performanceDate; - } - - public function setPerformanceDate($performanceDate) - { - $this->performanceDate = $performanceDate; - return $this; - } - - public function getPerformanceType(): ?PerformanceType - { - return $this->performanceType; - } - - public function setPerformanceType(?PerformanceType $performanceType): self - { - $this->performanceType = $performanceType; - return $this; - } - - public function getDim1() - { - return $this->dim1; - } - - public function setDim1($dim1) - { - $this->dim1 = $dim1; - return $this; - } } diff --git a/src/InvoiceTotals.php b/src/InvoiceTotals.php index dbe12595..a0aae10f 100644 --- a/src/InvoiceTotals.php +++ b/src/InvoiceTotals.php @@ -1,32 +1,15 @@ valueExcl; - } - - public function setValueExcl($valueExcl) - { - $this->valueExcl = $valueExcl; - } - - public function getValueInc() - { - return $this->valueInc; - } - - public function setValueInc($valueInc) - { - $this->valueInc = $valueInc; - } + use ValueExclField; + use ValueIncField; } diff --git a/src/InvoiceType.php b/src/InvoiceType.php new file mode 100644 index 00000000..c32ccfb6 --- /dev/null +++ b/src/InvoiceType.php @@ -0,0 +1,19 @@ + + */ +class InvoiceType extends BaseObject +{ + use CodeField; + use NameField; + use ShortNameField; +} \ No newline at end of file diff --git a/src/InvoiceVatLine.php b/src/InvoiceVatLine.php new file mode 100644 index 00000000..38ec0e4c --- /dev/null +++ b/src/InvoiceVatLine.php @@ -0,0 +1,19 @@ +code; - } - - public function setCode(string $code): void - { - $this->code = $code; - } - - public function getCountryCode(): string - { - return $this->countryCode; - } - - public function setCountryCode(string $countryCode): void - { - $this->countryCode = $countryCode; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): void - { - $this->name = $name; - } - public function __toString() { return $this->getCode(); diff --git a/src/PayCode.php b/src/PayCode.php new file mode 100644 index 00000000..a32edafd --- /dev/null +++ b/src/PayCode.php @@ -0,0 +1,19 @@ + + */ +class PayCode extends BaseObject +{ + use CodeField; + use NameField; + use ShortNameField; +} \ No newline at end of file diff --git a/src/Project.php b/src/Project.php new file mode 100644 index 00000000..947189c7 --- /dev/null +++ b/src/Project.php @@ -0,0 +1,54 @@ + + */ +class Project extends BaseObject +{ + use BehaviourField; + use CodeField; + use DimensionTypeField; + use InUseField; + use NameField; + use OfficeField; + use ShortNameField; + use StatusField; + use TouchedField; + use UIDField; + use VatCodeField; + + private $projects; + + public function __construct() + { + $this->setTypeFromCode('PRJ'); + $this->setProjects(new ProjectProjects); + } + + public function getProjects(): ProjectProjects + { + return $this->projects; + } + + public function setProjects(ProjectProjects $projects) + { + $this->projects = $projects; + return $this; + } +} \ No newline at end of file diff --git a/src/ProjectProjects.php b/src/ProjectProjects.php new file mode 100644 index 00000000..82caf045 --- /dev/null +++ b/src/ProjectProjects.php @@ -0,0 +1,79 @@ +setAuthoriserInherit(true); + $this->setAuthoriserLocked(true); + $this->setBillableInherit(true); + $this->setBillableLocked(true); + $this->setCustomerInherit(true); + $this->setCustomerLocked(true); + $this->setRateInherit(true); + $this->setRateLocked(true); + } + + public function getQuantities() + { + return $this->quantities; + } + + public function addQuantity(ProjectQuantity $quantity) + { + $this->quantities[] = $quantity; + return $this; + } + + public function removeQuantity($index) + { + if (array_key_exists($index, $this->quantities)) { + unset($this->quantities[$index]); + return true; + } else { + return false; + } + } +} diff --git a/src/ProjectQuantity.php b/src/ProjectQuantity.php new file mode 100644 index 00000000..ee7172ea --- /dev/null +++ b/src/ProjectQuantity.php @@ -0,0 +1,22 @@ + + */ +class Rate extends BaseObject +{ + use CodeField; + use CurrencyField; + use NameField; + use OfficeField; + use ShortNameField; + use StatusField; + use RateTypeField; + use UnitField; + use UserField; + + private $ratechanges = []; + + public function getRateChanges() + { + return $this->ratechanges; + } + + public function addRateChange(RateRateChange $ratechange) + { + $this->ratechanges[$ratechange->getID()] = $ratechange; + return $this; + } + + public function removeRateChange($index) + { + if (array_key_exists($index, $this->ratechanges)) { + unset($this->ratechanges[$index]); + return true; + } else { + return false; + } + } +} diff --git a/src/RateRateChange.php b/src/RateRateChange.php new file mode 100644 index 00000000..e207aff5 --- /dev/null +++ b/src/RateRateChange.php @@ -0,0 +1,29 @@ +ID = uniqid(); + } +} diff --git a/src/Supplier.php b/src/Supplier.php index 3ae9a054..254901fb 100644 --- a/src/Supplier.php +++ b/src/Supplier.php @@ -2,294 +2,82 @@ namespace PhpTwinfield; -use PhpTwinfield\Transactions\TransactionFields\OfficeField; -use PhpTwinfield\Transactions\TransactionLineFields\VatCodeField; +use PhpTwinfield\Fields\BehaviourField; +use PhpTwinfield\Fields\CodeField; +use PhpTwinfield\Fields\InUseField; +use PhpTwinfield\Fields\Level1234\BeginYearField; +use PhpTwinfield\Fields\Level1234\DimensionGroupField; +use PhpTwinfield\Fields\Level1234\DimensionTypeField; +use PhpTwinfield\Fields\Level1234\EndYearField; +use PhpTwinfield\Fields\Level1234\GeneralLedgerBeginPeriodField; +use PhpTwinfield\Fields\Level1234\GeneralLedgerEndPeriodField; +use PhpTwinfield\Fields\Level1234\Level2\PaymentConditionDiscountDaysField; +use PhpTwinfield\Fields\Level1234\Level2\PaymentConditionDiscountPercentageField; +use PhpTwinfield\Fields\Level1234\Level2\RemittanceAdviceSendMailField; +use PhpTwinfield\Fields\Level1234\Level2\RemittanceAdviceSendTypeField; +use PhpTwinfield\Fields\Level1234\Level2\Supplier\BlockedAccountPaymentConditionsIncludeVatField; +use PhpTwinfield\Fields\Level1234\Level2\Supplier\BlockedAccountPaymentConditionsPercentageField; +use PhpTwinfield\Fields\Level1234\Level2\WebsiteField; +use PhpTwinfield\Fields\NameField; +use PhpTwinfield\Fields\OfficeField; +use PhpTwinfield\Fields\ShortNameField; +use PhpTwinfield\Fields\StatusField; +use PhpTwinfield\Fields\TouchedField; +use PhpTwinfield\Fields\UIDField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers * @todo Add documentation and typehints to all properties. */ -class Supplier +class Supplier extends BaseObject { + use BeginYearField; + use BehaviourField; + use BlockedAccountPaymentConditionsIncludeVatField; + use BlockedAccountPaymentConditionsPercentageField; + use CodeField; + use DimensionGroupField; + use DimensionTypeField; + use EndYearField; + use GeneralLedgerBeginPeriodField; + use GeneralLedgerEndPeriodField; + use InUseField; + use NameField; use OfficeField; - use VatCodeField; + use PaymentConditionDiscountDaysField; + use PaymentConditionDiscountPercentageField; + use RemittanceAdviceSendMailField; + use RemittanceAdviceSendTypeField; + use ShortNameField; + use StatusField; + use TouchedField; + use UIDField; + use WebsiteField; - private $code; - private $UID; - private $status; - private $name; + private $financials; + private $addresses = []; + private $banks = []; + private $postingRules = []; - /** - * Dimension type of suppliers is CRD. - * - * @var string - */ - private $type = "CRD"; - - private $inUse; - private $behaviour; - private $touched; - private $beginPeriod; - private $beginYear; - private $endPeriod; - private $endYear; - private $website; - private $cocNumber; - private $vatNumber; - private $editDimensionName; - private $dueDays = 0; - private $payAvailable = false; - private $payCode; - private $eBilling = false; - private $eBillMail; - private $addresses = array(); - private $banks = array(); - private $groups; - - public function getCode() - { - return $this->code; - } - - public function setCode($code) - { - $this->code = $code; - return $this; - } - - public function getID() - { - trigger_error('getID is a deprecated method: Use getCode', E_USER_NOTICE); - return $this->getCode(); - } - - public function setID($ID) - { - trigger_error('setID is a deprecated method: Use setCode', E_USER_NOTICE); - return $this->setCode($ID); - } - - public function getUID() - { - return $this->UID; - } - - public function setUID($UID) - { - $this->UID = $UID; - return $this; - } - - public function getStatus() - { - return $this->status; - } - - public function setStatus($status) - { - $this->status = $status; - return $this; - } - - public function getName() - { - return $this->name; - } - - public function setName($name) - { - $this->name = $name; - return $this; - } - - public function getType() - { - return $this->type; - } - - public function setType($type) - { - $this->type = $type; - return $this; - } - - public function getInUse() - { - return $this->inUse; - } - - public function setInUse($inUse) - { - $this->inUse = $inUse; - return $this; - } - - public function getBehaviour() - { - return $this->behaviour; - } - - public function setBehaviour($behaviour) - { - $this->behaviour = $behaviour; - return $this; - } - - public function getTouched() + public function __construct() { - return $this->touched; - } - - public function setTouched($touched) - { - $this->touched = $touched; - return $this; - } + $this->setBeginPeriod(0); + $this->setBeginYear(0); + $this->setEndPeriod(0); + $this->setEndYear(0); + $this->setTypeFromCode('CRD'); - public function getBeginPeriod() - { - return $this->beginPeriod; - } - - public function setBeginPeriod($beginPeriod) - { - $this->beginPeriod = $beginPeriod; - return $this; + $this->setFinancials(new SupplierFinancials); } - public function getBeginYear() + public function getFinancials(): SupplierFinancials { - return $this->beginYear; + return $this->financials; } - public function setBeginYear($beginYear) + public function setFinancials(SupplierFinancials $financials) { - $this->beginYear = $beginYear; - return $this; - } - - public function getEndPeriod() - { - return $this->endPeriod; - } - - public function setEndPeriod($endPeriod) - { - $this->endPeriod = $endPeriod; - return $this; - } - - public function getEndYear() - { - return $this->endYear; - } - - public function setEndYear($endYear) - { - $this->endYear = $endYear; - return $this; - } - - public function getWebsite() - { - return $this->website; - } - - public function setWebsite($website) - { - $this->website = $website; - return $this; - } - - public function getCocNumber() - { - trigger_error('setCocNumber is a deprecated method: get from SupplierAddress::field05', E_USER_NOTICE); - return $this->cocNumber; - } - - public function setCocNumber($cocNumber) - { - trigger_error('setCocNumber is a deprecated method: add to SupplierAddress::field05', E_USER_NOTICE); - $this->cocNumber = $cocNumber; - return $this; - } - - public function getVatNumber() - { - trigger_error('setVatNumber is a deprecated method: add to SupplierAddress::field04', E_USER_NOTICE); - return $this->vatNumber; - } - - public function setVatNumber($vatNumber) - { - trigger_error('setVatNumber is a deprecated method: get SupplierAddress::field04', E_USER_NOTICE); - $this->vatNumber = $vatNumber; - return $this; - } - - public function getEditDimensionName() - { - return $this->editDimensionName; - } - - public function setEditDimensionName($editDimensionName) - { - $this->editDimensionName = $editDimensionName; - return $this; - } - - public function getDueDays() - { - return $this->dueDays; - } - - public function setDueDays($dueDays) - { - $this->dueDays = $dueDays; - return $this; - } - - public function getPayAvailable(): bool - { - return $this->payAvailable; - } - - public function setPayAvailable(bool $payAvailable): self - { - $this->payAvailable = $payAvailable; - return $this; - } - - public function getPayCode() - { - return $this->payCode; - } - - public function setPayCode($payCode) - { - $this->payCode = $payCode; - return $this; - } - - public function getEBilling(): bool - { - return $this->eBilling; - } - - public function setEBilling(bool $eBilling): self - { - $this->eBilling = $eBilling; - return $this; - } - - public function getEBillMail() - { - return $this->eBillMail; - } - - public function setEBillMail($eBillMail) - { - $this->eBillMail = $eBillMail; + $this->financials = $financials; return $this; } @@ -335,14 +123,24 @@ public function removeBank($index) } } - public function getGroups() + public function getPostingRules() { - return $this->groups; + return $this->postingRules; } - public function setGroups($groups) + public function addPostingRule(SupplierPostingRule $postingRule) { - $this->groups = $groups; + $this->postingRules[$postingRule->getID()] = $postingRule; return $this; } + + public function removePostingRule($index) + { + if (array_key_exists($index, $this->postingRules)) { + unset($this->postingRules[$index]); + return true; + } else { + return false; + } + } } diff --git a/src/SupplierAddress.php b/src/SupplierAddress.php index 84d2301d..caf6575d 100644 --- a/src/SupplierAddress.php +++ b/src/SupplierAddress.php @@ -2,219 +2,48 @@ namespace PhpTwinfield; +use PhpTwinfield\Fields\IDField; +use PhpTwinfield\Fields\Level1234\Level2\AddressTypeField; +use PhpTwinfield\Fields\Level1234\Level2\CityField; +use PhpTwinfield\Fields\Level1234\Level2\CountryField; +use PhpTwinfield\Fields\Level1234\Level2\DefaultField; +use PhpTwinfield\Fields\Level1234\Level2\EmailField; +use PhpTwinfield\Fields\Level1234\Level2\Field1Field; +use PhpTwinfield\Fields\Level1234\Level2\Field2Field; +use PhpTwinfield\Fields\Level1234\Level2\Field3Field; +use PhpTwinfield\Fields\Level1234\Level2\Field4Field; +use PhpTwinfield\Fields\Level1234\Level2\Field5Field; +use PhpTwinfield\Fields\Level1234\Level2\Field6Field; +use PhpTwinfield\Fields\Level1234\Level2\PostcodeField; +use PhpTwinfield\Fields\Level1234\Level2\TelefaxField; +use PhpTwinfield\Fields\Level1234\Level2\TelephoneField; +use PhpTwinfield\Fields\NameField; + /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers * @todo Add documentation and typehints to all properties. */ -class SupplierAddress +class SupplierAddress extends BaseObject { - private $ID; - private $type; - private $default; - private $name; - private $contact; - private $country; - private $city; - private $postcode; - private $telephone; - private $fax; - private $email; - private $field1; - private $field2; - private $field3; - private $field4; - private $field5; - private $field6; + use AddressTypeField; + use CityField; + use CountryField; + use DefaultField; + use EmailField; + use Field1Field; + use Field2Field; + use Field3Field; + use Field4Field; + use Field5Field; + use Field6Field; + use IDField; + use NameField; + use PostcodeField; + use TelefaxField; + use TelephoneField; public function __construct() { $this->ID = uniqid(); } - - public function getID() - { - return $this->ID; - } - - public function setID($ID) - { - $this->ID = $ID; - return $this; - } - - public function getType() - { - return $this->type; - } - - public function setType($type) - { - $this->type = $type; - return $this; - } - - public function getDefault() - { - return $this->default; - } - - public function setDefault($default) - { - $this->default = $default; - return $this; - } - - public function getName() - { - return $this->name; - } - - public function setName($name) - { - $this->name = $name; - return $this; - } - - public function getContact() - { - return $this->contact; - } - - public function setContact($contact) - { - $this->contact = $contact; - return $this; - } - - public function getCountry() - { - return $this->country; - } - - public function setCountry($country) - { - $this->country = $country; - return $this; - } - - public function getCity() - { - return $this->city; - } - - public function setCity($city) - { - $this->city = $city; - return $this; - } - - public function getPostcode() - { - return $this->postcode; - } - - public function setPostcode($postcode) - { - $this->postcode = $postcode; - return $this; - } - - public function getTelephone() - { - return $this->telephone; - } - - public function setTelephone($telephone) - { - $this->telephone = $telephone; - return $this; - } - - public function getFax() - { - return $this->fax; - } - - public function setFax($fax) - { - $this->fax = $fax; - return $this; - } - - public function getEmail() - { - return $this->email; - } - - public function setEmail($email) - { - $this->email = $email; - return $this; - } - - public function getField1() - { - return $this->field1; - } - - public function setField1($field1) - { - $this->field1 = $field1; - return $this; - } - - public function getField2() - { - return $this->field2; - } - - public function setField2($field2) - { - $this->field2 = $field2; - return $this; - } - - public function getField3() - { - return $this->field3; - } - - public function setField3($field3) - { - $this->field3 = $field3; - return $this; - } - - public function getField4() - { - return $this->field4; - } - - public function setField4($field4) - { - $this->field4 = $field4; - return $this; - } - - public function getField5() - { - return $this->field5; - } - - public function setField5($field5) - { - $this->field5 = $field5; - return $this; - } - - public function getField6() - { - return $this->field6; - } - - public function setField6($field6) - { - $this->field6 = $field6; - return $this; - } } diff --git a/src/SupplierBank.php b/src/SupplierBank.php index 02c1d145..9621e4c0 100644 --- a/src/SupplierBank.php +++ b/src/SupplierBank.php @@ -2,183 +2,46 @@ namespace PhpTwinfield; +use PhpTwinfield\Fields\IDField; +use PhpTwinfield\Fields\Level1234\Level2\AccountNumberField; +use PhpTwinfield\Fields\Level1234\Level2\AddressField2Field; +use PhpTwinfield\Fields\Level1234\Level2\AddressField3Field; +use PhpTwinfield\Fields\Level1234\Level2\AscriptionField; +use PhpTwinfield\Fields\Level1234\Level2\BankBlockedField; +use PhpTwinfield\Fields\Level1234\Level2\BankNameField; +use PhpTwinfield\Fields\Level1234\Level2\BicCodeField; +use PhpTwinfield\Fields\Level1234\Level2\CityField; +use PhpTwinfield\Fields\Level1234\Level2\CountryField; +use PhpTwinfield\Fields\Level1234\Level2\DefaultField; +use PhpTwinfield\Fields\Level1234\Level2\IbanField; +use PhpTwinfield\Fields\Level1234\Level2\NatBicCodeField; +use PhpTwinfield\Fields\Level1234\Level2\PostcodeField; +use PhpTwinfield\Fields\Level1234\Level2\StateField; + /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers * @todo Add documentation and typehints to all properties. */ -class SupplierBank +class SupplierBank extends BaseObject { - private $ID; # integer Sequence number of the bank account line. - private $default; # true/false Is this the default bank account, only one default bank account is possible. - private $ascription; # string(40) Account holder. - private $accountnumber; # string(40) Account number. - private $addressField2; # string(128) Bank address. - private $addressField3; # string(128) Bank address number. - private $bankname; # string(40) Bank name. - private $biccode; # string(16) BIC code. - private $city; # string(40) City. - private $country; # string(2) Bank country code. The ISO country codes are used. - private $iban; # string(40) IBAN account number. - private $natbiccode; # string(20) National bank code. - private $postcode; # string(16) Postcode. - private $state; # string(40) State. + use AccountNumberField; + use AddressField2Field; + use AddressField3Field; + use AscriptionField; + use BankNameField; + use BankBlockedField; + use BicCodeField; + use CityField; + use CountryField; + use DefaultField; + use IbanField; + use IDField; + use NatBicCodeField; + use PostcodeField; + use StateField; public function __construct() { $this->ID = uniqid(); } - - public function getID() - { - return $this->ID; - } - - public function setID($ID) - { - $this->ID = $ID; - return $this; - } - - public function getDefault() - { - return $this->default; - } - - public function setDefault($default) - { - $this->default = $default; - return $this; - } - - public function getAscription() - { - return $this->ascription; - } - - public function setAscription($ascription) - { - $this->ascription = $ascription; - return $this; - } - - public function getAccountnumber() - { - return $this->accountnumber; - } - - public function setAccountnumber($accountnumber) - { - $this->accountnumber = $accountnumber; - return $this; - } - - public function getAddressField2() - { - return $this->addressField2; - } - - public function setAddressField2($addressField2) - { - $this->addressField2 = $addressField2; - return $this; - } - - public function getAddressField3() - { - return $this->addressField3; - } - - public function setAddressField3($addressField3) - { - $this->addressField3 = $addressField3; - return $this; - } - - public function getBankname() - { - return $this->bankname; - } - - public function setBankname($bankname) - { - $this->bankname = $bankname; - return $this; - } - - public function getBiccode() - { - return $this->biccode; - } - - public function setBiccode($biccode) - { - $this->biccode = $biccode; - return $this; - } - - public function getCity() - { - return $this->city; - } - - public function setCity($city) - { - $this->city = $city; - return $this; - } - - public function getCountry() - { - return $this->country; - } - - public function setCountry($country) - { - $this->country = $country; - return $this; - } - - public function getIban() - { - return $this->iban; - } - - public function setIban($iban) - { - $this->iban = $iban; - return $this; - } - - public function getNatbiccode() - { - return $this->natbiccode; - } - - public function setNatbiccode($natbiccode) - { - $this->natbiccode = $natbiccode; - return $this; - } - - public function getPostcode() - { - return $this->postcode; - } - - public function setPostcode($postcode) - { - $this->postcode = $postcode; - return $this; - } - - public function getState() - { - return $this->state; - } - - public function setState($state) - { - $this->state = $state; - return $this; - } -} +} \ No newline at end of file diff --git a/src/SupplierChildValidation.php b/src/SupplierChildValidation.php new file mode 100644 index 00000000..63891886 --- /dev/null +++ b/src/SupplierChildValidation.php @@ -0,0 +1,18 @@ +setAccountTypeFromString('inherit'); + $this->setDueDays(30); + $this->setMatchTypeFromString('customersupplier'); + $this->setSubAnalyseFromString('false'); + $this->setSubstitutionLevel(1); + } + + public function getChildValidations() + { + return $this->childValidations; + } + + public function addChildValidation(SupplierChildValidation $childValidation) + { + $this->childValidations[] = $childValidation; + return $this; + } + + public function removeChildValidation($index) + { + if (array_key_exists($index, $this->childValidations)) { + unset($this->childValidations[$index]); + return true; + } else { + return false; + } + } +} diff --git a/src/SupplierLine.php b/src/SupplierLine.php new file mode 100644 index 00000000..8c2d6ac0 --- /dev/null +++ b/src/SupplierLine.php @@ -0,0 +1,32 @@ +ID = uniqid(); + } + + public function getLines() + { + return $this->lines; + } + + public function addLine(SupplierLine $line) + { + $this->lines[] = $line; + return $this; + } + + public function removeLine($index) + { + if (array_key_exists($index, $this->lines)) { + unset($this->lines[$index]); + return true; + } else { + return false; + } + } +} diff --git a/src/User.php b/src/User.php index 55fd3f6c..ac96d698 100644 --- a/src/User.php +++ b/src/User.php @@ -2,50 +2,25 @@ namespace PhpTwinfield; -class User +use PhpTwinfield\Fields\CodeField; +use PhpTwinfield\Fields\CreatedField; +use PhpTwinfield\Fields\ModifiedField; +use PhpTwinfield\Fields\NameField; +use PhpTwinfield\Fields\ShortNameField; +use PhpTwinfield\Fields\StatusField; +use PhpTwinfield\Fields\TouchedField; +use PhpTwinfield\Fields\User\IsCurrentUserField; +use PhpTwinfield\Fields\User\UserLevelField; + +class User extends BaseObject { - /** - * @var string The code of the user. - */ - private $code; - - /** - * @var string The name of the user. - */ - private $name; - - /** - * @var string The short name of the user. - */ - private $shortName; - - public function getCode(): string - { - return $this->code; - } - - public function setCode(string $code): void - { - $this->code = $code; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): void - { - $this->name = $name; - } - - public function getShortName(): string - { - return $this->shortName; - } - - public function setShortName(string $value): void - { - $this->shortName = $value; - } + use CodeField; + use CreatedField; + use IsCurrentUserField; + use ModifiedField; + use NameField; + use ShortNameField; + use StatusField; + use TouchedField; + use UserLevelField; } diff --git a/src/UserRole.php b/src/UserRole.php new file mode 100644 index 00000000..170ab88b --- /dev/null +++ b/src/UserRole.php @@ -0,0 +1,19 @@ + + */ +class UserRole extends BaseObject +{ + use CodeField; + use NameField; + use ShortNameField; +} \ No newline at end of file diff --git a/src/Util.php b/src/Util.php index de8e09c5..636f9ee8 100644 --- a/src/Util.php +++ b/src/Util.php @@ -53,6 +53,17 @@ public static function parseDate(string $dateString): \DateTimeImmutable return $date; } + /** + * Format a date time according to Twinfield specifications. + * + * @param \DateTimeInterface $datetime + * @return string + */ + public static function formatDateTime(\DateTimeInterface $datetime): string + { + return $datetime->format("YmdHis"); + } + /** * Parse a date time string from a Twinfield XML. * @@ -60,7 +71,7 @@ public static function parseDate(string $dateString): \DateTimeImmutable * @return \DateTimeImmutable * @throws Exception */ - public static function parseDateTime(string $dateString) + public static function parseDateTime(string $dateString): \DateTimeImmutable { $date = \DateTimeImmutable::createFromFormat("YmdHis", $dateString); diff --git a/src/VatCode.php b/src/VatCode.php index 61051d2c..0e4815e3 100644 --- a/src/VatCode.php +++ b/src/VatCode.php @@ -2,40 +2,57 @@ namespace PhpTwinfield; +use PhpTwinfield\Fields\CodeField; +use PhpTwinfield\Fields\CreatedField; +use PhpTwinfield\Fields\ModifiedField; +use PhpTwinfield\Fields\NameField; +use PhpTwinfield\Fields\OfficeField; +use PhpTwinfield\Fields\ShortNameField; +use PhpTwinfield\Fields\StatusField; +use PhpTwinfield\Fields\TouchedField; +use PhpTwinfield\Fields\UIDField; +use PhpTwinfield\Fields\UserField; +use PhpTwinfield\Fields\VatCode\VatCodeTypeField; + /** * Class VatCode * - * @author Emile Bons + * @author Emile Bons , extended by Yannick Aerssens */ -class VatCode +class VatCode extends BaseObject { - /** - * @var string The code of the VAT code. - */ - private $code; - - /** - * @var string The name of the VAT code. - */ - private $name; + use CodeField; + use CreatedField; + use ModifiedField; + use NameField; + use OfficeField; + use ShortNameField; + use StatusField; + use TouchedField; + use UIDField; + use UserField; + use VatCodeTypeField; - public function getCode(): string - { - return $this->code; - } + private $percentages = []; - public function setCode(string $code): void + public function getPercentages() { - $this->code = $code; + return $this->percentages; } - public function getName(): string + public function addPercentage(VatCodePercentage $percentage) { - return $this->name; + $this->percentages[] = $percentage; + return $this; } - public function setName(string $name): void + public function removePercentage($index) { - $this->name = $name; + if (array_key_exists($index, $this->percentages)) { + unset($this->percentages[$index]); + return true; + } else { + return false; + } } -} +} \ No newline at end of file diff --git a/src/VatCodeAccount.php b/src/VatCodeAccount.php new file mode 100644 index 00000000..97d55556 --- /dev/null +++ b/src/VatCodeAccount.php @@ -0,0 +1,29 @@ +ID = uniqid(); + } +} diff --git a/src/VatCodePercentage.php b/src/VatCodePercentage.php new file mode 100644 index 00000000..dbf78012 --- /dev/null +++ b/src/VatCodePercentage.php @@ -0,0 +1,47 @@ +accounts; + } + + public function addAccount(VatCodeAccount $account) + { + $this->accounts[$account->getID()] = $account; + return $this; + } + + public function removeAccount($index) + { + if (array_key_exists($index, $this->accounts)) { + unset($this->accounts[$index]); + return true; + } else { + return false; + } + } +} diff --git a/src/VatGroup.php b/src/VatGroup.php new file mode 100644 index 00000000..d6374333 --- /dev/null +++ b/src/VatGroup.php @@ -0,0 +1,19 @@ + + */ +class VatGroup extends BaseObject +{ + use CodeField; + use NameField; + use ShortNameField; +} \ No newline at end of file From 32da28aeb3b91f9d66d292d7b41b7bab7e6f5f1d Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:16:36 +0200 Subject: [PATCH 036/388] Add files via upload --- src/Transactions/TransactionLine.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Transactions/TransactionLine.php b/src/Transactions/TransactionLine.php index 9448082d..c2e8ff1a 100644 --- a/src/Transactions/TransactionLine.php +++ b/src/Transactions/TransactionLine.php @@ -50,4 +50,4 @@ public function getTransaction(); * @return MatchReferenceInterface */ public function getReference(): MatchReferenceInterface; -} +} \ No newline at end of file From abdd2dde05248091b0217020bb3e48e35905250e Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:17:03 +0200 Subject: [PATCH 037/388] Add files via upload From 8d6b3e56e3249c95d1a608a9c5c0de264b74da19 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:17:57 +0200 Subject: [PATCH 038/388] Add files via upload From 1a55d0e4a4e1d63a76f8d0e50b9ff30710a7ba98 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:18:28 +0200 Subject: [PATCH 039/388] Add files via upload --- src/Services/ProcessXmlService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Services/ProcessXmlService.php b/src/Services/ProcessXmlService.php index f6204e5f..2c230c94 100644 --- a/src/Services/ProcessXmlService.php +++ b/src/Services/ProcessXmlService.php @@ -37,7 +37,7 @@ public function chunk(array $items): array * * If there is an error in the response, an Exception is thrown, but it can also throw SoapFaults. * - * Note that you will probably have to chunk the objects into several documents if you want to send many objects. + * Note that you will probably have to chunk the objects into several documents if you want to send many objects. * * @param \DOMDocument $document * @return Response The response from the request From ddb09746d5e4c9076eedb065fb770c5e64f1ef1b Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:18:46 +0200 Subject: [PATCH 040/388] Add files via upload --- src/Secure/OpenIdConnectAuthentication.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Secure/OpenIdConnectAuthentication.php b/src/Secure/OpenIdConnectAuthentication.php index 36ee7a3f..61c5b1db 100644 --- a/src/Secure/OpenIdConnectAuthentication.php +++ b/src/Secure/OpenIdConnectAuthentication.php @@ -48,11 +48,13 @@ class OpenIdConnectAuthentication extends AuthenticatedConnection * Please note that for most calls an office is mandatory. If you do not supply it * you have to pass it with every request, or call setOffice. */ - public function __construct(OAuthProvider $provider, string $refreshToken, ?Office $office) + public function __construct(OAuthProvider $provider, string $refreshToken, ?Office $office, string $accessToken = null, string $cluster = null) { $this->provider = $provider; + $this->accessToken = $accessToken; $this->refreshToken = $refreshToken; $this->office = $office; + $this->cluster = $cluster; } public function setOffice(?Office $office) @@ -95,8 +97,10 @@ protected function login(): void $this->refreshToken(); } - $validationResult = $this->validateToken(); - $this->cluster = $validationResult["twf.clusterUrl"]; + if ($this->cluster === null) { + $validationResult = $this->validateToken(); + $this->cluster = $validationResult["twf.clusterUrl"]; + } } /** From a392f607447671a827ba58f9f6455d4809ec2d4a Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:19:05 +0200 Subject: [PATCH 041/388] Add files via upload --- src/Secure/Provider/OAuthProvider.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Secure/Provider/OAuthProvider.php b/src/Secure/Provider/OAuthProvider.php index f4fc0478..611d90fb 100644 --- a/src/Secure/Provider/OAuthProvider.php +++ b/src/Secure/Provider/OAuthProvider.php @@ -88,18 +88,12 @@ public function getResourceOwnerDetailsUrl(AccessToken $token): string /** * Returns the default scopes used by this provider. * - * Besides the ORGANISATION_USER and OPEN_ID scopes, the OFFLINE_ACCESS and ORGANISATION scopes have to - * be used in order to receive a refresh token and cluster URL. These are necessary to refresh the access - * token and make requests to the correct endpoint. + * This should only be the scopes that are required to request the details of the resource owner, rather than all + * the available scopes. */ protected function getDefaultScopes(): array { - return [ - self::SCOPE_ORGANISATION_USER, - self::SCOPE_OPEN_ID, - self::SCOPE_OFFLINE_ACCESS, - self::SCOPE_ORGANISATION - ]; + return [self::SCOPE_ORGANISATION_USER, self::SCOPE_OPEN_ID]; } /** From 76385e003035fc1aff1362cf70ad0a8963768d0b Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:19:38 +0200 Subject: [PATCH 042/388] Add files via upload --- src/Response/MappedResponseCollection.php | 2 +- src/Response/Response.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Response/MappedResponseCollection.php b/src/Response/MappedResponseCollection.php index 0c953615..779e17e7 100644 --- a/src/Response/MappedResponseCollection.php +++ b/src/Response/MappedResponseCollection.php @@ -95,4 +95,4 @@ private function countResponses(bool $successful): int return $count; } -} +} \ No newline at end of file diff --git a/src/Response/Response.php b/src/Response/Response.php index 43ea9c6e..9e842a82 100644 --- a/src/Response/Response.php +++ b/src/Response/Response.php @@ -45,7 +45,7 @@ public static function fromString(string $xml) return new self($document); } - + public function __construct(\DOMDocument $responseDocument) { $this->responseDocument = $responseDocument; @@ -145,4 +145,4 @@ public function getWarningMessages(): array { return $this->getMessages('warning'); } -} +} \ No newline at end of file From 223ae74bcd7f8dbd42ce80a049cb9ecbbc1d8080 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:20:05 +0200 Subject: [PATCH 043/388] Add files via upload --- src/Request/AssetMethod.php | 90 ++++++++++++++++++++++++++++++++++ src/Request/DimensionGroup.php | 90 ++++++++++++++++++++++++++++++++++ src/Request/DimensionType.php | 90 ++++++++++++++++++++++++++++++++++ 3 files changed, 270 insertions(+) create mode 100644 src/Request/AssetMethod.php create mode 100644 src/Request/DimensionGroup.php create mode 100644 src/Request/DimensionType.php diff --git a/src/Request/AssetMethod.php b/src/Request/AssetMethod.php new file mode 100644 index 00000000..6e81d070 --- /dev/null +++ b/src/Request/AssetMethod.php @@ -0,0 +1,90 @@ + + * @version 0.0.1 + */ +class AssetMethod extends DOMDocument +{ + /** + * Holds the element that all + * additional elements should be a child of. + * + * @access private + * @var DOMElement + */ + private $assetMethodElement; + + /** + * Creates the element and adds it to the property + * assetMethodElement and sets office and code if they are present. + * + * @access public + */ + public function __construct($office = null, $code = null) + { + parent::__construct(); + + $this->assetMethodElement = $this->createElement('assetmethod'); + $this->appendChild($this->assetMethodElement); + + if (null !== $office) { + $this->setOffice($office); + } + + if (null !== $code) { + $this->setCode($code); + } + } + + /** + * Adds additional elements to the dom element. + * + * See the documentation over what requires to know + * and what additional elements you need. + * + * @access protected + * @param string $element + * @param mixed $value + * @return void + */ + protected function add($element, $value) + { + $_element = $this->createElement($element, $value); + $this->assetMethodElement->appendChild($_element); + } + + /** + * Sets the office code for this request. + * + * @access public + * @param int $office + * @return \PhpTwinfield\Request + */ + public function setOffice($office) + { + $this->add('office', $office); + return $this; + } + + /** + * Sets the code for this request. + * + * @access public + * @param string $code + * @return \PhpTwinfield\Request + */ + public function setCode($code) + { + $this->add('code', $code); + return $this; + } +} diff --git a/src/Request/DimensionGroup.php b/src/Request/DimensionGroup.php new file mode 100644 index 00000000..4b6bf415 --- /dev/null +++ b/src/Request/DimensionGroup.php @@ -0,0 +1,90 @@ + + * @version 0.0.1 + */ +class DimensionGroup extends DOMDocument +{ + /** + * Holds the element that all + * additional elements should be a child of. + * + * @access private + * @var DOMElement + */ + private $dimensionGroupElement; + + /** + * Creates the element and adds it to the property + * dimensionGroupElement and sets office and code if they are present. + * + * @access public + */ + public function __construct($office = null, $code = null) + { + parent::__construct(); + + $this->dimensionGroupElement = $this->createElement('dimensiongroup'); + $this->appendChild($this->dimensionGroupElement); + + if (null !== $office) { + $this->setOffice($office); + } + + if (null !== $code) { + $this->setCode($code); + } + } + + /** + * Adds additional elements to the dom element. + * + * See the documentation over what requires to know + * and what additional elements you need. + * + * @access protected + * @param string $element + * @param mixed $value + * @return void + */ + protected function add($element, $value) + { + $_element = $this->createElement($element, $value); + $this->dimensionGroupElement->appendChild($_element); + } + + /** + * Sets the office code for this request. + * + * @access public + * @param int $office + * @return \PhpTwinfield\Request + */ + public function setOffice($office) + { + $this->add('office', $office); + return $this; + } + + /** + * Sets the code for this request. + * + * @access public + * @param string $code + * @return \PhpTwinfield\Request + */ + public function setCode($code) + { + $this->add('code', $code); + return $this; + } +} diff --git a/src/Request/DimensionType.php b/src/Request/DimensionType.php new file mode 100644 index 00000000..d7e78322 --- /dev/null +++ b/src/Request/DimensionType.php @@ -0,0 +1,90 @@ + + * @version 0.0.1 + */ +class DimensionType extends DOMDocument +{ + /** + * Holds the element that all + * additional elements should be a child of. + * + * @access private + * @var DOMElement + */ + private $dimensionTypeElement; + + /** + * Creates the element and adds it to the property + * dimensionTypeElement and sets office and code if they are present. + * + * @access public + */ + public function __construct($office = null, $code = null) + { + parent::__construct(); + + $this->dimensionTypeElement = $this->createElement('dimensiontype'); + $this->appendChild($this->dimensionTypeElement); + + if (null !== $office) { + $this->setOffice($office); + } + + if (null !== $code) { + $this->setCode($code); + } + } + + /** + * Adds additional elements to the dom element. + * + * See the documentation over what requires to know + * and what additional elements you need. + * + * @access protected + * @param string $element + * @param mixed $value + * @return void + */ + protected function add($element, $value) + { + $_element = $this->createElement($element, $value); + $this->dimensionTypeElement->appendChild($_element); + } + + /** + * Sets the office code for this request. + * + * @access public + * @param int $office + * @return \PhpTwinfield\Request + */ + public function setOffice($office) + { + $this->add('office', $office); + return $this; + } + + /** + * Sets the code for this request. + * + * @access public + * @param string $code + * @return \PhpTwinfield\Request + */ + public function setCode($code) + { + $this->add('code', $code); + return $this; + } +} From 5346418e8f1ef2b84cf15a02517ef9fe014af7ce Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:20:23 +0200 Subject: [PATCH 044/388] Add files via upload --- src/Request/Catalog/Catalog.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Request/Catalog/Catalog.php b/src/Request/Catalog/Catalog.php index cfb21cf8..a56e9b75 100644 --- a/src/Request/Catalog/Catalog.php +++ b/src/Request/Catalog/Catalog.php @@ -5,13 +5,13 @@ * Abstract parent class Catalog. Catalog is the name of the request * for LIST. List is a protected term in PHP so all instances of the word * catalog are just a replacement. - * + * * All aspects of LIST request require a parent element called 'list' - * + * * The constructor makes this element, appends to the itself. All requirements * to add new elements to this dom element are done through * the add() method. - * + * * @package PhpTwinfield * @subpackage Request\Catalog * @author Leon Rowland @@ -23,7 +23,7 @@ abstract class Catalog extends \DOMDocument /** * Holds the element that all * additional elements should be a child of. - * + * * @access private * @var \DOMElement */ @@ -32,7 +32,7 @@ abstract class Catalog extends \DOMDocument /** * Creates the element and adds it to the property * listElement - * + * * @access public */ public function __construct() @@ -45,10 +45,10 @@ public function __construct() /** * Adds additional elements to the dom element. - * + * * See the documentation over what requires to know * what additional elements you need. - * + * * @access protected * @param string $element * @param mixed $value From 552b4da7c49cf19bb28fc772c871ef9930776644 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:20:39 +0200 Subject: [PATCH 045/388] Delete Dimension.php --- src/Request/Catalog/Dimension.php | 62 ------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 src/Request/Catalog/Dimension.php diff --git a/src/Request/Catalog/Dimension.php b/src/Request/Catalog/Dimension.php deleted file mode 100644 index f64620c3..00000000 --- a/src/Request/Catalog/Dimension.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright (c) 2013, Pronamic - * @version 0.0.1 - */ -class Dimension extends Catalog -{ - /** - * Sets the to dimensions for the request - * and sets the office and dimtype if they are passed - * in. - * - * @access public - * @param Office|null $office - * @param string|null $dimType - */ - public function __construct(Office $office = null, $dimType = null) - { - parent::__construct(); - - $this->add('type', 'dimensions'); - - if (null !== $office) { - $this->setOffice($office); - } - - if (null !== $dimType) { - $this->setDimType($dimType); - } - } - - /** - * Sets the officecode for the dimension request. - * - * @param Office $office - */ - public function setOffice(Office $office) - { - $this->add('office', $office->getCode()); - } - - /** - * Sets the dimtype for the request. - * - * @access public - * @param string $dimType - */ - public function setDimType($dimType) - { - $this->add('dimtype', $dimType); - } -} From cb251baaabcebd290680d947a310b5c27d27af83 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:20:49 +0200 Subject: [PATCH 046/388] Delete Office.php --- src/Request/Catalog/Office.php | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 src/Request/Catalog/Office.php diff --git a/src/Request/Catalog/Office.php b/src/Request/Catalog/Office.php deleted file mode 100644 index ac20adec..00000000 --- a/src/Request/Catalog/Office.php +++ /dev/null @@ -1,27 +0,0 @@ - - * @copyright (c) 2013, Pronamic - * @version 0.0.1 - */ -class Office extends Catalog -{ - /** - * Adds the only required element for this request. - * - * No other methods exist or are required, - * - * @access public - */ - public function __construct() - { - parent::__construct(); - $this->add('type', 'offices'); - } -} From 6f8d62991297e504329ceabe3aae2af032ddbca7 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:21:23 +0200 Subject: [PATCH 047/388] Add files via upload --- src/Request/Read/Activity.php | 35 ++++++++++++++ src/Request/Read/Article.php | 35 ++------------ src/Request/Read/BrowseDefinition.php | 26 ---------- src/Request/Read/CostCenter.php | 34 ++++++++++++++ src/Request/Read/Currency.php | 33 +++++++++++++ src/Request/Read/Customer.php | 54 +++------------------ src/Request/Read/FixedAsset.php | 34 ++++++++++++++ src/Request/Read/GeneralLedger.php | 37 +++++++++++++++ src/Request/Read/Invoice.php | 63 +++++++------------------ src/Request/Read/Office.php | 29 ++++++++++++ src/Request/Read/Project.php | 34 ++++++++++++++ src/Request/Read/Rate.php | 33 +++++++++++++ src/Request/Read/Read.php | 68 +++++++++++++++++++++++---- src/Request/Read/Supplier.php | 54 +++------------------ src/Request/Read/Transaction.php | 51 +++----------------- src/Request/Read/User.php | 33 +++++++++++++ src/Request/Read/VatCode.php | 33 +++++++++++++ 17 files changed, 437 insertions(+), 249 deletions(-) create mode 100644 src/Request/Read/Activity.php create mode 100644 src/Request/Read/CostCenter.php create mode 100644 src/Request/Read/Currency.php create mode 100644 src/Request/Read/FixedAsset.php create mode 100644 src/Request/Read/GeneralLedger.php create mode 100644 src/Request/Read/Office.php create mode 100644 src/Request/Read/Project.php create mode 100644 src/Request/Read/Rate.php create mode 100644 src/Request/Read/User.php create mode 100644 src/Request/Read/VatCode.php diff --git a/src/Request/Read/Activity.php b/src/Request/Read/Activity.php new file mode 100644 index 00000000..cfde02c9 --- /dev/null +++ b/src/Request/Read/Activity.php @@ -0,0 +1,35 @@ + + * @version 0.0.1 + */ +class Activity extends Read +{ + /** + * Sets office and code if they are present. + * + * @access public + */ + + public function __construct($office = null, $code = null) + { + parent::__construct(); + + $this->add('type', 'dimensions'); + $this->add('dimtype', 'ACT'); + + if (null !== $office) { + $this->setOffice($office); + } + + if (null !== $code) { + $this->setCode($code); + } + } +} diff --git a/src/Request/Read/Article.php b/src/Request/Read/Article.php index 84561c22..1d2de5a7 100644 --- a/src/Request/Read/Article.php +++ b/src/Request/Read/Article.php @@ -2,9 +2,8 @@ namespace PhpTwinfield\Request\Read; /** - * Used to request a specific custom from a certain - * office and code. - * + * Used to request a specific Article from a certain office and code. + * * @package PhpTwinfield * @subpackage Request\Read * @author Willem van de Sande @@ -14,7 +13,7 @@ class Article extends Read { /** * Sets office and code if they are present. - * + * * @access public */ public function __construct($office = null, $code = null) @@ -22,7 +21,7 @@ public function __construct($office = null, $code = null) parent::__construct(); $this->add('type', 'article'); - + if (null !== $office) { $this->setOffice($office); } @@ -31,30 +30,4 @@ public function __construct($office = null, $code = null) $this->setCode($code); } } - - /** - * Sets the office code for this Article request. - * - * @access public - * @param int $office - * @return \PhpTwinfield\Request\Read\Article - */ - public function setOffice($office) - { - $this->add('office', $office); - return $this; - } - - /** - * Sets the code for this Article request. - * - * @access public - * @param string $code - * @return \PhpTwinfield\Request\Read\Article - */ - public function setCode($code) - { - $this->add('code', $code); - return $this; - } } diff --git a/src/Request/Read/BrowseDefinition.php b/src/Request/Read/BrowseDefinition.php index 99e3a7de..895a2ff2 100644 --- a/src/Request/Read/BrowseDefinition.php +++ b/src/Request/Read/BrowseDefinition.php @@ -26,30 +26,4 @@ public function __construct(string $code, Office $office = null) $this->setCode($code); } } - - /** - * Sets the office code for this BrowseData request. - * - * @access public - * @param Office $office - * @return BrowseDefinition - */ - public function setOffice(Office $office) - { - $this->add('office', $office->getCode()); - return $this; - } - - /** - * Sets the code for this BrowseData request. - * - * @access public - * @param string $code - * @return BrowseDefinition - */ - public function setCode($code) - { - $this->add('code', $code); - return $this; - } } diff --git a/src/Request/Read/CostCenter.php b/src/Request/Read/CostCenter.php new file mode 100644 index 00000000..9d66d8bb --- /dev/null +++ b/src/Request/Read/CostCenter.php @@ -0,0 +1,34 @@ + + * @version 0.0.1 + */ +class CostCenter extends Read +{ + /** + * Sets office and code if they are present. + * + * @access public + */ + public function __construct($office = null, $code = null) + { + parent::__construct(); + + $this->add('type', 'dimensions'); + $this->add('dimtype', 'KPL'); + + if (null !== $office) { + $this->setOffice($office); + } + + if (null !== $code) { + $this->setCode($code); + } + } +} \ No newline at end of file diff --git a/src/Request/Read/Currency.php b/src/Request/Read/Currency.php new file mode 100644 index 00000000..b0558ecb --- /dev/null +++ b/src/Request/Read/Currency.php @@ -0,0 +1,33 @@ + + * @version 0.0.1 + */ +class Currency extends Read +{ + /** + * Sets office and code if they are present. + * + * @access public + */ + public function __construct($office = null, $code = null) + { + parent::__construct(); + + $this->add('type', 'currency'); + + if (null !== $office) { + $this->setOffice($office); + } + + if (null !== $code) { + $this->setCode($code); + } + } +} diff --git a/src/Request/Read/Customer.php b/src/Request/Read/Customer.php index a7d827b2..b3e66958 100644 --- a/src/Request/Read/Customer.php +++ b/src/Request/Read/Customer.php @@ -2,9 +2,9 @@ namespace PhpTwinfield\Request\Read; /** - * Used to request a specific custom from a certain + * Used to request a specific Customer from a certain * office and code. - * + * * @package PhpTwinfield * @subpackage Request\Read * @author Leon Rowland @@ -16,62 +16,22 @@ class Customer extends Read /** * Sets the to dimensions for the request and * sets the dimtype, office and code if they are present. - * + * * @access public */ - public function __construct($office = null, $code = null, $dimType = 'DEB') + public function __construct($office = null, $code = null) { parent::__construct(); $this->add('type', 'dimensions'); - + $this->add('dimtype', 'DEB'); + if (null !== $office) { $this->setOffice($office); } - + if (null !== $code) { $this->setCode($code); } - - $this->setDimType($dimType); - } - - /** - * Sets the office code for this customer request. - * - * @access public - * @param int $office - * @return \PhpTwinfield\Request\Read\Customer - */ - public function setOffice($office) - { - $this->add('office', $office); - return $this; - } - - /** - * Sets the code for this customer request. - * - * @access public - * @param string $code - * @return \PhpTwinfield\Request\Read\Customer - */ - public function setCode($code) - { - $this->add('code', $code); - return $this; - } - - /** - * Sets the dimtype for the request. - * - * @access public - * @param string $dimType - * @return \PhpTwinfield\Request\Read\Customer - */ - public function setDimType($dimType) - { - $this->add('dimtype', $dimType); - return $this; } } diff --git a/src/Request/Read/FixedAsset.php b/src/Request/Read/FixedAsset.php new file mode 100644 index 00000000..fc6994c4 --- /dev/null +++ b/src/Request/Read/FixedAsset.php @@ -0,0 +1,34 @@ + + * @version 0.0.1 + */ +class FixedAsset extends Read +{ + /** + * Sets office and code if they are present. + * + * @access public + */ + public function __construct($office = null, $code = null) + { + parent::__construct(); + + $this->add('type', 'dimensions'); + $this->add('dimtype', 'AST'); + + if (null !== $office) { + $this->setOffice($office); + } + + if (null !== $code) { + $this->setCode($code); + } + } +} \ No newline at end of file diff --git a/src/Request/Read/GeneralLedger.php b/src/Request/Read/GeneralLedger.php new file mode 100644 index 00000000..4884a173 --- /dev/null +++ b/src/Request/Read/GeneralLedger.php @@ -0,0 +1,37 @@ + + * @version 0.0.1 + */ +class GeneralLedger extends Read +{ + /** + * Sets office and code if they are present. + * + * @access public + */ + public function __construct($office = null, $code = null, $dimType = null) + { + parent::__construct(); + + $this->add('type', 'dimensions'); + + if (null !== $office) { + $this->setOffice($office); + } + + if (null !== $code) { + $this->setCode($code); + } + + if (null !== $dimType) { + $this->setDimType($dimType); + } + } +} \ No newline at end of file diff --git a/src/Request/Read/Invoice.php b/src/Request/Read/Invoice.php index 27aec93a..2fe2a310 100644 --- a/src/Request/Read/Invoice.php +++ b/src/Request/Read/Invoice.php @@ -2,83 +2,56 @@ namespace PhpTwinfield\Request\Read; /** - * Used to request a specific invoice from a certain - * code, number and office. - * + * Used to request a specific Invoice from a certain + * code, invoice number and office. + * * @package PhpTwinfield * @subpackage Request\Read * @author Leon Rowland - * @copyright (c) 2013, Pronamic + * @copyright (c) 2013, Pronamic * @version 0.0.1 */ class Invoice extends Read { /** * Sets the to salesinvoice for the request - * and sets the office, code and number if they + * and sets the office, code and invoice number if they * are present. - * + * * @access public * @param int $office * @param string $code - * @param int $number + * @param int $invoiceNumber */ - public function __construct($office = null, $code = null, $number = null) + public function __construct($office = null, $code = null, $invoiceNumber = null) { parent::__construct(); $this->add('type', 'salesinvoice'); - + if (null !== $office) { $this->setOffice($office); } - + if (null !== $code) { $this->setCode($code); } - - if (null !== $number) { - $this->setNumber($number); - } - } - /** - * Sets the office code for this salesinvoice - * request. It is an optional field. - * - * @access public - * @param int $office - * @return \PhpTwinfield\Request\Read\Invoice - */ - public function setOffice($office) - { - $this->add('office', $office); - return $this; + if (null !== $invoiceNumber) { + $this->setInvoiceNumber($invoiceNumber); + } } - /** - * Sets the code for this salesinvoice request. + /** + * Sets the invoice number for this request. * * @access public - * @param string $code - * @return \PhpTwinfield\Request\Read\Invoice - */ - public function setCode($code) - { - $this->add('code', $code); - return $this; - } - - /** - * Sets the invoicenumber for this request. - * - * @access public - * @param int $number + * @param string $invoiceNumber * @return \PhpTwinfield\Request\Read\Invoice */ - public function setNumber($number) + public function setInvoiceNumber($invoiceNumber) { - $this->add('invoicenumber', $number); + $this->add('invoicenumber', $invoiceNumber); return $this; } } diff --git a/src/Request/Read/Office.php b/src/Request/Read/Office.php new file mode 100644 index 00000000..f9c228fe --- /dev/null +++ b/src/Request/Read/Office.php @@ -0,0 +1,29 @@ + + * @version 0.0.1 + */ +class Office extends Read +{ + /** + * Sets office and code if they are present. + * + * @access public + */ + public function __construct($code = null) + { + parent::__construct(); + + $this->add('type', 'office'); + + if (null !== $code) { + $this->setCode($code); + } + } +} diff --git a/src/Request/Read/Project.php b/src/Request/Read/Project.php new file mode 100644 index 00000000..ed2f0d66 --- /dev/null +++ b/src/Request/Read/Project.php @@ -0,0 +1,34 @@ + + * @version 0.0.1 + */ +class Project extends Read +{ + /** + * Sets office and code if they are present. + * + * @access public + */ + public function __construct($office = null, $code = null) + { + parent::__construct(); + + $this->add('type', 'dimensions'); + $this->add('dimtype', 'PRJ'); + + if (null !== $office) { + $this->setOffice($office); + } + + if (null !== $code) { + $this->setCode($code); + } + } +} \ No newline at end of file diff --git a/src/Request/Read/Rate.php b/src/Request/Read/Rate.php new file mode 100644 index 00000000..ddda02af --- /dev/null +++ b/src/Request/Read/Rate.php @@ -0,0 +1,33 @@ + + * @version 0.0.1 + */ +class Rate extends Read +{ + /** + * Sets office and code if they are present. + * + * @access public + */ + public function __construct($office = null, $code = null) + { + parent::__construct(); + + $this->add('type', 'projectrate'); + + if (null !== $office) { + $this->setOffice($office); + } + + if (null !== $code) { + $this->setCode($code); + } + } +} \ No newline at end of file diff --git a/src/Request/Read/Read.php b/src/Request/Read/Read.php index 31b8899c..49a28961 100644 --- a/src/Request/Read/Read.php +++ b/src/Request/Read/Read.php @@ -4,13 +4,13 @@ /** * Abstract parent class Read. Read is the name for the request component * READ. - * + * * All aspects of READ request require a parent element called 'read' - * + * * The construct makes this element, appends to itself. All requirements to * add new elements to this dom element are done through the add() * method. - * + * * @package PhpTwinfield * @subpackage Request\Read * @author Leon Rowland @@ -21,8 +21,8 @@ abstract class Read extends \DOMDocument { /** * Holds the element that all - * additional elements shoudl be a child of. - * + * additional elements should be a child of. + * * @access private * @var \DOMElement */ @@ -31,7 +31,7 @@ abstract class Read extends \DOMDocument /** * Creates the element and adds it to the property * readElement - * + * * @access public */ public function __construct() @@ -44,10 +44,10 @@ public function __construct() /** * Adds additional elements to the dom element. - * + * * See the documentation over what requires to know * and what additional elements you need. - * + * * @access protected * @param string $element * @param mixed $value @@ -58,4 +58,56 @@ protected function add($element, $value) $_element = $this->createElement($element, $value); $this->readElement->appendChild($_element); } + + /** + * Sets the office code for this request. + * + * @access public + * @param int $office + * @return \PhpTwinfield\Request\Read + */ + public function setOffice($office) + { + $this->add('office', $office); + return $this; + } + + /** + * Sets the code for this request. + * + * @access public + * @param string $code + * @return \PhpTwinfield\Request\Read + */ + public function setCode($code) + { + $this->add('code', $code); + return $this; + } + + /** + * Sets the dimtype for this request. + * + * @access public + * @param string $dimType + * @return \PhpTwinfield\Request\Read + */ + public function setDimType($dimType) + { + $this->add('dimtype', $dimType); + return $this; + } + + /** + * Sets the number for this request. + * + * @access public + * @param string $number + * @return \PhpTwinfield\Request\Read + */ + public function setNumber($number) + { + $this->add('number', $number); + return $this; + } } diff --git a/src/Request/Read/Supplier.php b/src/Request/Read/Supplier.php index 2abfc86a..0fd9e75e 100644 --- a/src/Request/Read/Supplier.php +++ b/src/Request/Read/Supplier.php @@ -4,7 +4,7 @@ /** * Used to request a specific custom from a certain * office and code. - * + * * @package PhpTwinfield * @subpackage Request\Read * @author Leon Rowland @@ -15,63 +15,23 @@ class Supplier extends Read { /** * Sets the to dimensions for the request and - * sets the dimtype, office and code if they are present. - * + * sets the office and code if they are present. + * * @access public */ - public function __construct($office = null, $code = null, $dimType = 'CRD') + public function __construct($office = null, $code = null) { parent::__construct(); $this->add('type', 'dimensions'); - + $this->add('dimtype', 'CRD'); + if (null !== $office) { $this->setOffice($office); } - + if (null !== $code) { $this->setCode($code); } - - $this->setDimType($dimType); - } - - /** - * Sets the office code for this customer request. - * - * @access public - * @param int $office - * @return $this - */ - public function setOffice($office) - { - $this->add('office', $office); - return $this; - } - - /** - * Sets the code for this customer request. - * - * @access public - * @param string $code - * @return $this - */ - public function setCode($code) - { - $this->add('code', $code); - return $this; - } - - /** - * Sets the dimtype for the request. - * - * @access public - * @param string $dimType - * @return $this - */ - public function setDimType($dimType) - { - $this->add('dimtype', $dimType); - return $this; } } diff --git a/src/Request/Read/Transaction.php b/src/Request/Read/Transaction.php index 00bdbad7..31443d0d 100644 --- a/src/Request/Read/Transaction.php +++ b/src/Request/Read/Transaction.php @@ -6,7 +6,7 @@ /** * Used to request a specific transaction from a certain * office, code and number. - * + * * @package PhpTwinfield * @subpackage Request\Read * @author Leon Rowland @@ -18,7 +18,7 @@ class Transaction extends Read /** * Sets the to transaction for the request and * sets the office, code and number if they are present. - * + * * @access public * @param int $office * @param string $code @@ -27,58 +27,19 @@ class Transaction extends Read public function __construct($office = null, $code = null, $number = null) { parent::__construct(); - + $this->add('type', 'transaction'); - + if (null !== $office) { $this->setOffice($office); } - + if (null !== $code) { $this->setCode($code); } - + if (null !== $number) { $this->setNumber($number); } } - - /** - * Sets the office code for this transaction request. - * - * @access public - * @param Office $office - * @return \PhpTwinfield\Request\Read\Transaction - */ - public function setOffice(Office $office) - { - $this->add('office', $office->getCode()); - return $this; - } - - /** - * Sets the code for this transaction request. - * - * @access public - * @param string $code - * @return \PhpTwinfield\Request\Read\Transaction - */ - public function setCode($code) - { - $this->add('code', $code); - return $this; - } - - /** - * Sets the number for this transaction request - * - * @access public - * @param int $number - * @return \PhpTwinfield\Request\Read\Transaction - */ - public function setNumber($number) - { - $this->add('number', $number); - return $this; - } } diff --git a/src/Request/Read/User.php b/src/Request/Read/User.php new file mode 100644 index 00000000..54ee431d --- /dev/null +++ b/src/Request/Read/User.php @@ -0,0 +1,33 @@ + + * @version 0.0.1 + */ +class User extends Read +{ + /** + * Sets office and code if they are present. + * + * @access public + */ + public function __construct($office = null, $code = null) + { + parent::__construct(); + + $this->add('type', 'user'); + + if (null !== $office) { + $this->setOffice($office); + } + + if (null !== $code) { + $this->setCode($code); + } + } +} diff --git a/src/Request/Read/VatCode.php b/src/Request/Read/VatCode.php new file mode 100644 index 00000000..42efcf47 --- /dev/null +++ b/src/Request/Read/VatCode.php @@ -0,0 +1,33 @@ + + * @version 0.0.1 + */ +class VatCode extends Read +{ + /** + * Sets office and code if they are present. + * + * @access public + */ + public function __construct($office = null, $code = null) + { + parent::__construct(); + + $this->add('type', 'vat'); + + if (null !== $office) { + $this->setOffice($office); + } + + if (null !== $code) { + $this->setCode($code); + } + } +} From 4e1da8e112c6692db8ed2fa128af75929e9d23e6 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:21:39 +0200 Subject: [PATCH 048/388] Add files via upload From 9742b01d1f81dd9a799dadbed188d9b5bf1da3e1 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:22:28 +0200 Subject: [PATCH 049/388] Add files via upload --- src/Mappers/ActivityMapper.php | 119 +++++++ src/Mappers/ArticleMapper.php | 125 ++++---- src/Mappers/AssetMethodMapper.php | 126 ++++++++ src/Mappers/BaseMapper.php | 130 +++++++- src/Mappers/CashBankBookMapper.php | 45 +++ src/Mappers/CostCenterMapper.php | 54 ++++ src/Mappers/CurrencyMapper.php | 80 +++++ src/Mappers/CustomerMapper.php | 447 ++++++++++++++++----------- src/Mappers/DimensionGroupMapper.php | 77 +++++ src/Mappers/DimensionTypeMapper.php | 87 ++++++ src/Mappers/FixedAssetMapper.php | 174 +++++++++++ src/Mappers/GeneralLedgerMapper.php | 109 +++++++ src/Mappers/InvoiceMapper.php | 224 ++++++++------ src/Mappers/InvoiceTypeMapper.php | 45 +++ src/Mappers/OfficeMapper.php | 35 ++- src/Mappers/PayCodeMapper.php | 45 +++ src/Mappers/ProjectMapper.php | 119 +++++++ src/Mappers/RateMapper.php | 85 +++++ src/Mappers/SupplierMapper.php | 381 ++++++++++++++--------- src/Mappers/UserMapper.php | 56 ++++ src/Mappers/UserRoleMapper.php | 45 +++ src/Mappers/VatCodeMapper.php | 117 +++++++ src/Mappers/VatGroupMapper.php | 45 +++ 23 files changed, 2276 insertions(+), 494 deletions(-) create mode 100644 src/Mappers/ActivityMapper.php create mode 100644 src/Mappers/AssetMethodMapper.php create mode 100644 src/Mappers/CashBankBookMapper.php create mode 100644 src/Mappers/CostCenterMapper.php create mode 100644 src/Mappers/CurrencyMapper.php create mode 100644 src/Mappers/DimensionGroupMapper.php create mode 100644 src/Mappers/DimensionTypeMapper.php create mode 100644 src/Mappers/FixedAssetMapper.php create mode 100644 src/Mappers/GeneralLedgerMapper.php create mode 100644 src/Mappers/InvoiceTypeMapper.php create mode 100644 src/Mappers/PayCodeMapper.php create mode 100644 src/Mappers/ProjectMapper.php create mode 100644 src/Mappers/RateMapper.php create mode 100644 src/Mappers/UserMapper.php create mode 100644 src/Mappers/UserRoleMapper.php create mode 100644 src/Mappers/VatCodeMapper.php create mode 100644 src/Mappers/VatGroupMapper.php diff --git a/src/Mappers/ActivityMapper.php b/src/Mappers/ActivityMapper.php new file mode 100644 index 00000000..9ff007b7 --- /dev/null +++ b/src/Mappers/ActivityMapper.php @@ -0,0 +1,119 @@ + + */ +class ActivityMapper extends BaseMapper +{ + /** + * Maps a Response object to a clean Activity entity. + * + * @access public + * + * @param \PhpTwinfield\Response\Response $response + * + * @return Activity + * @throws \PhpTwinfield\Exception + */ + public static function map(Response $response) + { + // Generate new Activity object + $activity = new Activity(); + + // Gets the raw DOMDocument response. + $responseDOM = $response->getResponseDocument(); + + // Get the root/activity element + $activityElement = $responseDOM->documentElement; + + // Set the result and status attribute + $activity->setResult($activityElement->getAttribute('result')) + ->setStatus(self::parseEnumAttribute('Status', $activityElement->getAttribute('status'))); + + // Set the activity elements from the activity element + $activity->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($activity, $activityElement, 'behaviour'))) + ->setCode(self::getField($activity, $activityElement, 'code')) + ->setInUse(self::parseBooleanAttribute(self::getField($activity, $activityElement, 'name'))) + ->setName(self::getField($activity, $activityElement, 'name')) + ->setOffice(self::parseObjectAttribute('Office', $activity, $activityElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setShortName(self::getField($activity, $activityElement, 'shortname')) + ->setTouched(self::getField($activity, $activityElement, 'touched')) + ->setType(self::parseObjectAttribute('DimensionType', $activity, $activityElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setUID(self::getField($activity, $activityElement, 'uid')) + ->setVatCode(self::parseObjectAttribute('VatCode', $activity, $activityElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); + + // Get the projects element + $projectsElement = $responseDOM->getElementsByTagName('projects')->item(0); + + if ($projectsElement !== null) { + // Make a new temporary ActivityProjects class + $activityProjects = new ActivityProjects(); + + // Set the projects elements from the projects element + $activityProjects->setAuthoriser(self::parseObjectAttribute('User', $activityProjects, $projectsElement, 'authoriser')) + ->setBillable(self::parseBooleanAttribute(self::getField($activityProjects, $projectsElement, 'billable'))) + ->setCustomer(self::parseObjectAttribute('Customer', $activityProjects, $projectsElement, 'customer')) + ->setInvoiceDescription(self::getField($activityProjects, $projectsElement, 'invoicedescription')) + ->setRate(self::parseObjectAttribute('Rate', $activityProjects, $projectsElement, 'rate')) + ->setValidFrom(self::parseDateAttribute(self::getField($activityProjects, $projectsElement, 'validfrom'))) + ->setValidTill(self::parseDateAttribute(self::getField($activityProjects, $projectsElement, 'validtill'))); + + // Set the projects elements from the projects element attributes + $activityProjects->setAuthoriserInherit(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'authoriser', 'inherit'))) + ->setAuthoriserLocked(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'authoriser', 'locked'))) + ->setBillableForRatio(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'billable', 'forratio'))) + ->setBillableInherit(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'billable', 'inherit'))) + ->setBillableLocked(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'billable', 'locked'))) + ->setCustomerInherit(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'customer', 'inherit'))) + ->setCustomerLocked(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'customer', 'locked'))) + ->setRateInherit(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'rate', 'inherit'))) + ->setRateLocked(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'rate', 'locked'))); + + // Get the quantities element + $quantitiesDOMTag = $projectsElement->getElementsByTagName('quantities'); + + if (isset($quantitiesDOMTag) && $quantitiesDOMTag->length > 0) { + // Loop through each returned quantity for the project + foreach ($quantitiesDOMTag->item(0)->childNodes as $quantityElement) { + if ($quantityElement->nodeType !== 1) { + continue; + } + + // Make a new temporary ActivityQuantity class + $activityQuantity = new ActivityQuantity(); + + // Set the quantity elements from the quantity element + $activityQuantity->setBillable(self::parseBooleanAttribute(self::getField($activityQuantity, $quantityElement, 'billable'))) + ->setLabel(self::getField($activityQuantity, $quantityElement, 'label')) + ->setMandatory(self::parseBooleanAttribute(self::getField($activityQuantity, $quantityElement, 'mandatory'))) + ->setRate(self::parseObjectAttribute('Rate', $activityQuantity, $quantityElement, 'rate')); + + // Set the quantity elements from the quantity element attributes + $activityQuantity->setBillableLocked(self::parseBooleanAttribute(self::getAttribute($quantityElement, 'billable', 'locked'))); + + // Add the quantity to the project + $activityProjects->addQuantity($activityQuantity); + + // Clean that memory! + unset ($activityQuantity); + } + } + + // Set the custom class to the project + $activity->setProjects($activityProjects); + } + + // Return the complete object + return $activity; + } +} \ No newline at end of file diff --git a/src/Mappers/ArticleMapper.php b/src/Mappers/ArticleMapper.php index b9b10268..7370fbcc 100644 --- a/src/Mappers/ArticleMapper.php +++ b/src/Mappers/ArticleMapper.php @@ -7,14 +7,13 @@ /** * Maps a response DOMDocument to the corresponding entity. - * + * * @package PhpTwinfield * @subpackage Mapper - * @author Willem van de Sande + * @author Willem van de Sande , extended by Yannick Aerssens */ class ArticleMapper extends BaseMapper { - /** * Maps a Response object to a clean Article entity. * @@ -33,80 +32,84 @@ public static function map(Response $response) // Gets the raw DOMDocument response. $responseDOM = $response->getResponseDocument(); - // Set the status attribute - $dimensionElement = $responseDOM->getElementsByTagName('header')->item(0); - $article->setStatus($dimensionElement->getAttribute('status')); - - // Article elements and their methods - $articleTags = [ - 'code' => 'setCode', - 'office' => 'setOffice', - 'type' => 'setType', - 'name' => 'setName', - 'shortname' => 'setShortName', - 'unitnamesingular' => 'setUnitNameSingular', - 'unitnameplural' => 'setUnitNamePlural', - 'vatcode' => 'setVatCode', - 'allowchangevatcode' => 'setAllowChangeVatCode', - 'performancetype' => 'setPerformanceType', - 'allowchangeperformancetype' => 'setAllowChangePerformanceType', - 'percentage' => 'setPercentage', - 'allowdiscountorpremium' => 'setAllowDiscountorPremium', - 'allowchangeunitsprice' => 'setAllowChangeUnitsPrice', - 'allowdecimalquantity' => 'setAllowDecimalQuantity', - ]; - - // Loop through all the tags - foreach ($articleTags as $tag => $method) { - self::setFromTagValue($responseDOM, $tag, [$article, $method]); - } + // Get the root/article element + $articleElement = $responseDOM->documentElement; + + // Set the result attribute + $article->setResult($articleElement->getAttribute('result')); + // Get the header element + $headerElement = $articleElement->getElementsByTagName('header')->item(0); + + // Set the status attribute + $article->setStatus(self::parseEnumAttribute('Status', $headerElement->getAttribute('status'))); + + // Set the article elements from the header + $article->setAllowChangePerformanceType(self::parseBooleanAttribute(self::getField($article, $headerElement, 'allowchangeperformancetype'))) + ->setAllowChangeUnitsPrice(self::parseBooleanAttribute(self::getField($article, $headerElement, 'allowchangeunitsprice'))) + ->setAllowChangeVatCode(self::parseBooleanAttribute(self::getField($article, $headerElement, 'allowchangevatcode'))) + ->setAllowDecimalQuantity(self::parseBooleanAttribute(self::getField($article, $headerElement, 'allowdecimalquantity'))) + ->setAllowDiscountOrPremium(self::parseBooleanAttribute(self::getField($article, $headerElement, 'allowdiscountorpremium'))) + ->setCode(self::getField($article, $headerElement, 'code')) + ->setName(self::getField($article, $headerElement, 'name')) + ->setOffice(self::parseObjectAttribute('Office', $article, $headerElement, 'office')) + ->setPercentage(self::parseBooleanAttribute(self::getField($article, $headerElement, 'percentage'))) + ->setPerformanceType(self::parseEnumAttribute('PerformanceType', self::getField($article, $headerElement, 'performancetype'))) + ->setShortName(self::getField($article, $headerElement, 'shortname')) + ->setType(self::parseEnumAttribute('ArticleType', self::getField($article, $headerElement, 'type'))) + ->setUnitNameSingular(self::getField($article, $headerElement, 'unitnamesingular')) + ->setUnitNamePlural(self::getField($article, $headerElement, 'unitnameplural')) + ->setVatCode(self::parseObjectAttribute('VatCode', $article, $headerElement, 'vatcode')); + + // Get the lines element $linesDOMTag = $responseDOM->getElementsByTagName('lines'); if (isset($linesDOMTag) && $linesDOMTag->length > 0) { - // Element tags and their methods for lines - $lineTags = [ - 'unitspriceexcl' => 'setUnitsPriceExcl', - 'unitspriceinc' => 'setUnitsPriceInc', - 'units' => 'setUnits', - 'name' => 'setName', - 'shortname' => 'setShortName', - 'subcode' => 'setSubCode', - 'freetext1' => 'setFreeText1', - ]; - - $linesDOM = $linesDOMTag->item(0); + $lineNumber = 0; // Loop through each returned line for the article - foreach ($linesDOM->getElementsByTagName('line') as $lineDOM) { - - // Make a new tempory ArticleLine class - $articleLine = new ArticleLine(); - - // Set the attributes ( id,status,inuse) - $articleLine->setID($lineDOM->getAttribute('id')) - ->setStatus($lineDOM->getAttribute('status')) - ->setInUse($lineDOM->getAttribute('inuse')); + foreach ($linesDOMTag->item(0)->childNodes as $lineElement) { + // Skip child nodes that are not of the DOMElement type + if ($lineElement->nodeType !== 1) { + continue; + } - // Loop through the element tags. Determine if it exists and set it if it does - foreach ($lineTags as $tag => $method) { + $lineNumber++; - // Get the dom element - $_tag = $lineDOM->getElementsByTagName($tag)->item(0); + // Make a new temporary ArticleLine class + $articleLine = new ArticleLine(); - // Check if the tag is set, and its content is set, to prevent DOMNode errors - if (isset($_tag) && isset($_tag->textContent)) { - $articleLine->$method($_tag->textContent); - } + // Set the ID attributes if it is not null, else set the current line number + if ($lineElement->getAttribute('id') != null) { + $articleLine->setID($lineElement->getAttribute('id')); + } else { + $articleLine->setID($lineNumber); } - // Add the bank to the customer + // Set the inuse and status attributes + $articleLine->setInUse($lineElement->getAttribute('inuse')); + $articleLine->setStatusFromString($lineElement->getAttribute('status')); + + // Set the article line elements + $articleLine->setFreeText1(self::parseObjectAttribute('GeneralLedger', $articleLine, $lineElement, 'freetext1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setFreeText2(self::parseObjectAttribute('CostCenter', $articleLine, $lineElement, 'freetext2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setFreeText3(self::getField($articleLine, $lineElement, 'freetext3')) + ->setUnits(self::getField($articleLine, $lineElement, 'units')) + ->setName(self::getField($articleLine, $lineElement, 'name')) + ->setShortName(self::getField($articleLine, $lineElement, 'shortname')) + ->setSubCode(self::getField($articleLine, $lineElement, 'subcode')) + ->setUnitsPriceExcl(self::parseMoneyAttribute(self::getField($articleLine, $lineElement, 'unitspriceexcl'))) + ->setUnitsPriceInc(self::parseMoneyAttribute(self::getField($articleLine, $lineElement, 'unitspriceinc'))); + + // Add the line to the article $article->addLine($articleLine); // Clean that memory! unset ($articleLine); } } + + // Return the complete object return $article; } -} +} \ No newline at end of file diff --git a/src/Mappers/AssetMethodMapper.php b/src/Mappers/AssetMethodMapper.php new file mode 100644 index 00000000..cc6df732 --- /dev/null +++ b/src/Mappers/AssetMethodMapper.php @@ -0,0 +1,126 @@ + + */ +class AssetMethodMapper extends BaseMapper +{ + /** + * Maps a Response object to a clean AssetMethod entity. + * + * @access public + * + * @param \PhpTwinfield\Response\Response $response + * + * @return AssetMethod + * @throws \PhpTwinfield\Exception + */ + public static function map(Response $response) + { + // Generate new AssetMethod object + $assetmethod = new AssetMethod(); + + // Gets the raw DOMDocument response. + $responseDOM = $response->getResponseDocument(); + + // Get the root/assetmethod element + $assetmethodElement = $responseDOM->documentElement; + + // Set the inuse, result and status attribute + $assetmethod->setInUse(self::parseBooleanAttribute($assetmethodElement->getAttribute('inuse'))) + ->setResult($assetmethodElement->getAttribute('result')) + ->setStatus(self::parseEnumAttribute('Status', $assetmethodElement->getAttribute('status'))); + + // Set the asset method elements from the asset method element + $assetmethod->setCalcMethod(self::parseEnumAttribute('CalcMethod', self::getField($assetmethod, $assetmethodElement, 'calcmethod'))) + ->setCode(self::getField($assetmethod, $assetmethodElement, 'code')) + ->setCreated(self::parseDateTimeAttribute(self::getField($assetmethod, $assetmethodElement, 'created'))) + ->setDepreciateReconciliation(self::parseEnumAttribute('DepreciateReconciliation', self::getField($assetmethod, $assetmethodElement, 'depreciatereconciliation'))) + ->setModified(self::parseDateTimeAttribute(self::getField($assetmethod, $assetmethodElement, 'modified'))) + ->setName(self::getField($assetmethod, $assetmethodElement, 'name')) + ->setNrOfPeriods(self::getField($assetmethod, $assetmethodElement, 'nrofperiods')) + ->setOffice(self::parseObjectAttribute('Office', $assetmethod, $assetmethodElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setPercentage(self::getField($assetmethod, $assetmethodElement, 'percentage')) + ->setShortName(self::getField($assetmethod, $assetmethodElement, 'shortname')) + ->setTouched(self::getField($assetmethod, $assetmethodElement, 'touched')) + ->setUser(self::parseObjectAttribute('User', $assetmethod, $assetmethodElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); + + // Get the balanceaccounts element + $balanceAccountsElement = $responseDOM->getElementsByTagName('balanceaccounts')->item(0); + + if ($balanceAccountsElement !== null) { + // Make a new temporary AssetMethodBalanceAccounts class + $assetMethodBalanceAccounts = new AssetMethodBalanceAccounts(); + + // Set the asset method balance account elements from the balance accounts element + $assetMethodBalanceAccounts + ->setAssetsToActivate(self::parseObjectAttribute('GeneralLedger', $assetMethodBalanceAccounts, $balanceAccountsElement, 'assetstoactivate', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setDepreciation(self::parseObjectAttribute('GeneralLedger', $assetMethodBalanceAccounts, $balanceAccountsElement, 'depreciation', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setDepreciationGroup(self::parseObjectAttribute('DimensionGroup', $assetMethodBalanceAccounts, $balanceAccountsElement, 'depreciationgroup', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setPurchaseValue(self::parseObjectAttribute('GeneralLedger', $assetMethodBalanceAccounts, $balanceAccountsElement, 'purchasevalue', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setPurchaseValueGroup(self::parseObjectAttribute('DimensionGroup', $assetMethodBalanceAccounts, $balanceAccountsElement, 'purchasevaluegroup', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setReconciliation(self::parseObjectAttribute('GeneralLedger', $assetMethodBalanceAccounts, $balanceAccountsElement, 'reconciliation', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setToBeInvoiced(self::parseObjectAttribute('GeneralLedger', $assetMethodBalanceAccounts, $balanceAccountsElement, 'tobeinvoiced', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))); + + // Set the custom class to the assetmethod + $assetmethod->setBalanceAccounts($assetMethodBalanceAccounts); + } + + // Get the profitlossaccounts element + $profitLossAccountsElement = $responseDOM->getElementsByTagName('profitlossaccounts')->item(0); + + if ($profitLossAccountsElement !== null) { + // Make a new temporary AssetMethodProfitLossAccounts class + $assetMethodProfitLossAccounts = new AssetMethodProfitLossAccounts(); + + // Set the asset method profit loss account elements from the profit loss accounts element + $assetMethodProfitLossAccounts + ->setDepreciation(self::parseObjectAttribute('GeneralLedger', $assetMethodProfitLossAccounts, $profitLossAccountsElement, 'depreciation', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setReconciliation(self::parseObjectAttribute('GeneralLedger', $assetMethodProfitLossAccounts, $profitLossAccountsElement, 'reconciliation', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setSales(self::parseObjectAttribute('GeneralLedger', $assetMethodProfitLossAccounts, $profitLossAccountsElement, 'sales', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))); + + // Set the custom class to the assetmethod + $assetmethod->setProfitLossAccounts($assetMethodProfitLossAccounts); + } + + // Get the freetexts element + $freetextsDOMTag = $responseDOM->getElementsByTagName('freetexts'); + + if (isset($freetextsDOMTag) && $freetextsDOMTag->length > 0) { + // Loop through each returned freetext for the assetmethod + foreach ($freetextsDOMTag->item(0)->childNodes as $freetextElement) { + if ($freetextElement->nodeType !== 1) { + continue; + } + + // Make a new temporary AssetMethodFreeText class + $assetmethodFreeText = new AssetMethodFreeText(); + + // Set the attributes (id, type, value) + $assetmethodFreeText->setID($freetextElement->getAttribute('id')) + ->setType(self::parseEnumAttribute('FreeTextType', $freetextElement->getAttribute('type'))) + ->setElementValue($freetextElement->nodeValue); + + // Add the freetext to the assetmethod + $assetmethod->addFreeText($assetmethodFreeText); + + // Clean that memory! + unset ($assetmethodFreeText); + } + } + + // Return the complete object + return $assetmethod; + } +} \ No newline at end of file diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index d98027bb..f8395d57 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -3,6 +3,8 @@ namespace PhpTwinfield\Mappers; use Money\Currency; +use Money\Money; +use PhpTwinfield\Message\Message; use PhpTwinfield\Office; use PhpTwinfield\Util; use Webmozart\Assert\Assert; @@ -62,17 +64,143 @@ protected static function getValueFromTag(\DOMDocument $document, string $tag): return $element->textContent; } - protected static function getField(\DOMElement $element, string $fieldTagName): ?string + protected static function getAttribute(\DOMElement $element, string $fieldTagName, string $attributeName): ?string { $fieldElement = $element->getElementsByTagName($fieldTagName)->item(0); + + if (!isset($fieldElement)) { + return null; + } + + if ($fieldElement->getAttribute($attributeName) === "") { + return null; + } + + return $fieldElement->getAttribute($attributeName); + } + + protected static function getField($object, \DOMElement $element, string $fieldTagName): ?string + { + $fieldElement = $element->getElementsByTagName($fieldTagName)->item(0); + if (!isset($fieldElement)) { return null; } + self::checkForMessage($object, $fieldElement); + if ($fieldElement->textContent === "") { return null; } return $fieldElement->textContent; } + + private static function checkForMessage($object, \DOMElement $element): void + { + if ($element->hasAttribute('msg')) { + $message = new Message(); + $message->setType($element->getAttribute('msgtype')); + $message->setMessage($element->getAttribute('msg')); + $message->setField($element->nodeName); + + $object->addMessage($message); + } + } + + protected static function parseBooleanAttribute(?string $value): ?bool + { + return filter_var($value, FILTER_VALIDATE_BOOLEAN); + } + + protected static function parseDateAttribute(?string $value): ?\DateTimeImmutable + { + if ((bool)strtotime($value)) { + return Util::parseDate($value); + } else { + return null; + } + } + + protected static function parseDateTimeAttribute(?string $value): ?\DateTimeImmutable + { + if ((bool)strtotime($value)) { + return Util::parseDateTime($value); + } else { + return null; + } + } + + protected static function parseEnumAttribute(string $enumName, ?string $value) + { + if ($value === null) { + return null; + } + + $enum = "\\PhpTwinfield\\Enums\\" . $enumName; + + return new $enum($value); + } + + protected static function parseMoneyAttribute(?float $value): ?Money + { + if ($value === null) { + return null; + } + + return Util::parseMoney($value, new Currency('EUR')); + } + + protected static function parseObjectAttribute(string $className, $object, \DOMElement $element, string $fieldTagName, array $attributes = null) + { + if ($className == "DimensionGroupDimension" || $className == "UnknownDimension") { + if ($className == "DimensionGroupDimension") { + $type = self::getField($object, $element, "type"); + } elseif ($className == "UnknownDimension") { + $type = self::getAttribute($element, $fieldTagName, "dimensiontype"); + } + + switch ($type) { + case "ACT": + $className = "Activity"; + break; + case "AST": + $className = "FixedAsset"; + break; + case "BAS": + $className = "GeneralLedger"; + break; + case "CRD": + $className = "Supplier"; + break; + case "DEB": + $className = "Customer"; + break; + case "KPL": + $className = "CostCenter"; + break; + case "PNL": + $className = "GeneralLedger"; + break; + case "PRJ": + $className = "Project"; + break; + default: + return null; + } + } + + $class = "\\PhpTwinfield\\" . $className; + + $object2 = new $class(); + $object2->setCode(self::getField($object, $element, $fieldTagName)); + + if (isset($attributes)) { + foreach ($attributes as $attributeName => $method) { + $object2->$method(self::getAttribute($element, $fieldTagName, $attributeName)); + } + } + + return $object2; + } } \ No newline at end of file diff --git a/src/Mappers/CashBankBookMapper.php b/src/Mappers/CashBankBookMapper.php new file mode 100644 index 00000000..8e66b28d --- /dev/null +++ b/src/Mappers/CashBankBookMapper.php @@ -0,0 +1,45 @@ + + */ +class CashBankBookMapper extends BaseMapper +{ + /** + * Maps a Response object to a clean CashBankBook entity. + * + * @access public + * + * @param \PhpTwinfield\Response\Response $response + * + * @return CashBankBook + * @throws \PhpTwinfield\Exception + */ + public static function map(Response $response) + { + // Generate new CashBankBook object + $vatGroup = new CashBankBook(); + + // Gets the raw DOMDocument response. + $responseDOM = $response->getResponseDocument(); + + // Get the root/vat group element + $vatGroupElement = $responseDOM->documentElement; + + // Set the vat group elements from the vat group element + $vatGroup->setCode(self::getField($vatGroup, $vatGroupElement, 'code')) + ->setName(self::getField($vatGroup, $vatGroupElement, 'name')) + ->setShortName(self::getField($vatGroup, $vatGroupElement, 'shortname')); + + // Return the complete object + return $vatGroup; + } +} \ No newline at end of file diff --git a/src/Mappers/CostCenterMapper.php b/src/Mappers/CostCenterMapper.php new file mode 100644 index 00000000..8120e9b7 --- /dev/null +++ b/src/Mappers/CostCenterMapper.php @@ -0,0 +1,54 @@ + + */ +class CostCenterMapper extends BaseMapper +{ + /** + * Maps a Response object to a clean CostCenter entity. + * + * @access public + * + * @param \PhpTwinfield\Response\Response $response + * + * @return CostCenter + * @throws \PhpTwinfield\Exception + */ + public static function map(Response $response) + { + // Generate new CostCenter object + $costCenter = new CostCenter(); + + // Gets the raw DOMDocument response. + $responseDOM = $response->getResponseDocument(); + + // Get the root/costcenter element + $costCenterElement = $responseDOM->documentElement; + + // Set the result and status attribute + $costCenter->setResult($costCenterElement->getAttribute('result')) + ->setStatus(self::parseEnumAttribute('Status', $costCenterElement->getAttribute('status'))); + + // Set the cost center elements from the cost center element + $costCenter->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($costCenter, $costCenterElement, 'behaviour'))) + ->setCode(self::getField($costCenter, $costCenterElement, 'code')) + ->setInUse(self::parseBooleanAttribute(self::getField($costCenter, $costCenterElement, 'name'))) + ->setName(self::getField($costCenter, $costCenterElement, 'name')) + ->setOffice(self::parseObjectAttribute('Office', $costCenter, $costCenterElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setTouched(self::getField($costCenter, $costCenterElement, 'touched')) + ->setType(self::parseObjectAttribute('DimensionType', $costCenter, $costCenterElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setUID(self::getField($costCenter, $costCenterElement, 'uid')); + + // Return the complete object + return $costCenter; + } +} \ No newline at end of file diff --git a/src/Mappers/CurrencyMapper.php b/src/Mappers/CurrencyMapper.php new file mode 100644 index 00000000..6bb88a39 --- /dev/null +++ b/src/Mappers/CurrencyMapper.php @@ -0,0 +1,80 @@ + + */ +class CurrencyMapper extends BaseMapper +{ + /** + * Maps a Response object to a clean Currency entity. + * + * @access public + * + * @param \PhpTwinfield\Response\Response $response + * + * @return Currency + * @throws \PhpTwinfield\Exception + */ + public static function map(Response $response) + { + // Generate new Currency object + $currency = new Currency(); + + // Gets the raw DOMDocument response. + $responseDOM = $response->getResponseDocument(); + + // Get the root/currency element + $currencyElement = $responseDOM->documentElement; + + // Set the result and status attribute + $currency->setResult($currencyElement->getAttribute('result')) + ->setStatus(self::parseEnumAttribute('Status', $currencyElement->getAttribute('status'))); + + // Set the currency elements from the currency element + $currency->setCode(self::getField($currency, $currencyElement, 'code')) + ->setName(self::getField($currency, $currencyElement, 'name')) + ->setOffice(self::parseObjectAttribute('Office', $currency, $currencyElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setShortName(self::getField($currency, $currencyElement, 'shortname')); + + // Get the rates element + $ratesDOMTag = $responseDOM->getElementsByTagName('rates'); + + if (isset($ratesDOMTag) && $ratesDOMTag->length > 0) { + // Loop through each returned rate for the currency + foreach ($ratesDOMTag->item(0)->childNodes as $rateElement) { + if ($rateElement->nodeType !== 1) { + continue; + } + + // Make a new temporary CurrencyRate class + $currencyRate = new CurrencyRate(); + + // Set the status + // NOTE: Contrary to what is written in the API documentation status is not implemented for currency rates, DO NOT SET! + //$currencyRate->setStatus($rateElement->getAttribute('status')); + + // Set the currency rate elements from the rate element + $currencyRate->setRate(self::getField($currencyRate, $rateElement, 'rate')) + ->setStartDate(self::parseDateAttribute(self::getField($currencyRate, $rateElement, 'startdate'))); + + // Add the rate to the currency + $currency->addRate($currencyRate); + + // Clean that memory! + unset ($currencyRate); + } + } + + // Return the complete object + return $currency; + } +} diff --git a/src/Mappers/CustomerMapper.php b/src/Mappers/CustomerMapper.php index 50805326..86599edc 100644 --- a/src/Mappers/CustomerMapper.php +++ b/src/Mappers/CustomerMapper.php @@ -4,16 +4,20 @@ use PhpTwinfield\Customer; use PhpTwinfield\CustomerAddress; use PhpTwinfield\CustomerBank; -use PhpTwinfield\Exception; +use PhpTwinfield\CustomerChildValidation; +use PhpTwinfield\CustomerCollectMandate; +use PhpTwinfield\CustomerCreditManagement; +use PhpTwinfield\CustomerFinancials; +use PhpTwinfield\CustomerLine; +use PhpTwinfield\CustomerPostingRule; use PhpTwinfield\Response\Response; -use PhpTwinfield\Util; /** * Maps a response DOMDocument to the corresponding entity. * * @package PhpTwinfield * @subpackage Mapper - * @author Leon Rowland + * @author Leon Rowland , extended by Yannick Aerssens * @copyright (c) 2013, Pronamic */ class CustomerMapper extends BaseMapper @@ -24,240 +28,311 @@ class CustomerMapper extends BaseMapper * @access public * @param \PhpTwinfield\Response\Response $response * @return Customer - * @throws Exception + * @throws \PhpTwinfield\Exception */ public static function map(Response $response) { - // Generate new customer object + // Generate new Customer object $customer = new Customer(); // Gets the raw DOMDocument response. $responseDOM = $response->getResponseDocument(); - // Set the status attribute - $dimensionElement = $responseDOM->documentElement; - $customer->setStatus($dimensionElement->getAttribute('status')); - - // Customer elements and their methods - $customerTags = array( - 'code' => 'setCode', - 'uid' => 'setUID', - 'name' => 'setName', - 'inuse' => 'setInUse', - 'behaviour' => 'setBehaviour', - 'touched' => 'setTouched', - 'beginperiod' => 'setBeginPeriod', - 'beginyear' => 'setBeginYear', - 'endperiod' => 'setEndPeriod', - 'endyear' => 'setEndYear', - 'website' => 'setWebsite', - 'editdimensionname' => 'setEditDimensionName', - 'office' => 'setOffice', - 'country' => 'setCountry', - ); - - // Loop through all the tags - foreach ($customerTags as $tag => $method) { - self::setFromTagValue($responseDOM, $tag, [$customer, $method]); - } + // Get the root/customer element + $customerElement = $responseDOM->documentElement; + + // Set the result and status attribute + $customer->setResult($customerElement->getAttribute('result')) + ->setStatus(self::parseEnumAttribute('Status', $customerElement->getAttribute('status'))); + + // Set the customer elements from the customer element + $customer->setBeginPeriod(self::getField($customer, $customerElement, 'beginperiod')) + ->setBeginYear(self::getField($customer, $customerElement, 'beginyear')) + ->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($customer, $customerElement, 'behaviour'))) + ->setDiscountArticle(self::parseObjectAttribute('Article', $customer, $customerElement, 'discountarticle', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setCode(self::getField($customer, $customerElement, 'code')) + ->setEndPeriod(self::getField($customer, $customerElement, 'endperiod')) + ->setEndYear(self::getField($customer, $customerElement, 'endyear')) + ->setGroup(self::parseObjectAttribute('DimensionGroup', $customer, $customerElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setInUse(self::parseBooleanAttribute(self::getField($customer, $customerElement, 'name'))) + ->setName(self::getField($customer, $customerElement, 'name')) + ->setOffice(self::parseObjectAttribute('Office', $customer, $customerElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setTouched(self::getField($customer, $customerElement, 'touched')) + ->setType(self::parseObjectAttribute('DimensionType', $customer, $customerElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setUID(self::getField($customer, $customerElement, 'uid')) + ->setWebsite(self::getField($customer, $customerElement, 'website')); + + // Set the customer elements from the customer element attributes + $customer->setDiscountArticleID(self::getAttribute($customerElement, 'discountarticle', 'id')); + + // Get the financials element + $financialsElement = $responseDOM->getElementsByTagName('financials')->item(0); + + if ($financialsElement !== null) { + // Make a new temporary CustomerFinancials class + $customerFinancials = new CustomerFinancials(); + + // Set the financials elements from the financials element + $customerFinancials->setAccountType(self::parseEnumAttribute('AccountType', self::getField($customerFinancials, $financialsElement, 'accounttype'))) + ->setCollectionSchema(self::parseEnumAttribute('CollectionSchema', self::getField($customerFinancials, $financialsElement, 'collectionschema'))) + ->setDueDays(self::getField($customerFinancials, $financialsElement, 'duedays')) + ->setEBilling(self::parseBooleanAttribute(self::getField($customerFinancials, $financialsElement, 'ebilling'))) + ->setEBillMail(self::getField($customerFinancials, $financialsElement, 'ebillmail')) + ->setLevel(self::getField($customerFinancials, $financialsElement, 'level')) + ->setMatchType(self::parseEnumAttribute('MatchType', self::getField($customerFinancials, $financialsElement, 'matchtype'))) + ->setMeansOfPayment(self::parseEnumAttribute('MeansOfPayment', self::getField($customerFinancials, $financialsElement, 'meansofpayment'))) + ->setPayAvailable(self::parseBooleanAttribute(self::getField($customerFinancials, $financialsElement, 'payavailable'))) + ->setPayCode(self::parseObjectAttribute('PayCode', $customerFinancials, $financialsElement, 'paycode', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setSubAnalyse(self::parseEnumAttribute('SubAnalyse', self::getField($customerFinancials, $financialsElement, 'subanalyse'))) + ->setSubstitutionLevel(self::getField($customerFinancials, $financialsElement, 'substitutionlevel')) + ->setSubstituteWith(self::parseObjectAttribute('UnknownDimension', $customerFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setVatCode(self::parseObjectAttribute('VatCode', $customerFinancials, $financialsElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); + + // Set the financials elements from the financials element attributes + $customerFinancials->setPayCodeID(self::getAttribute($financialsElement, 'paycode', 'id')) + ->setSubstituteWithID(self::getAttribute($financialsElement, 'substitutewith', 'id')) + ->setVatCodeFixed(self::parseBooleanAttribute(self::getAttribute($financialsElement, 'vatcode', 'fixed'))); + + // Get the collectmandate element + $collectMandateElement = $financialsElement->getElementsByTagName('collectmandate')->item(0); - // Financial elements and their methods - $financialsTags = array( - 'duedays' => 'setDueDays', - 'payavailable' => 'setPayAvailable', - 'paycode' => 'setPayCode', - 'ebilling' => 'setEBilling', - 'ebillmail' => 'setEBillMail', - 'vatcode' => 'setVatCode', - ); - - // Financial elements - $financialElement = $responseDOM->getElementsByTagName('financials')->item(0); - - if ($financialElement) { - // Go through each financial element and add to the assigned method - foreach ($financialsTags as $tag => $method) { - - // Get the dom element - $_tag = $financialElement->getElementsByTagName($tag)->item(0); - - // If it has a value, set it to the associated method - if (isset($_tag) && isset($_tag->textContent)) { - $value = $_tag->textContent; - if ($value == 'true' || $value == 'false') { - $value = $value == 'true'; - } + if ($collectMandateElement !== null) { + // Make a new temporary CustomerCollectMandate class + $customerCollectMandate = new CustomerCollectMandate(); - $customer->$method($value); - } + // Set the collect mandate elements from the collect mandate element + $customerCollectMandate->setFirstRunDate(self::parseDateAttribute(self::getField($customerCollectMandate, $collectMandateElement, 'firstrundate'))) + ->setID(self::getField($customerCollectMandate, $collectMandateElement, 'id')) + ->setSignatureDate(self::parseDateAttribute(self::getField($customerCollectMandate, $collectMandateElement, 'signaturedate'))); + + // Add the collect mandate element to the customer financials class + $customerFinancials->setCollectMandate($customerCollectMandate); + + // Clean that memory! + unset ($customerCollectMandate); } - $collectMandateElement = $responseDOM->getElementsByTagName('collectmandate')->item(0); + // Get the childvalidations element + $childValidationsDOMTag = $financialsElement->getElementsByTagName('childvalidations'); - if ($collectMandateElement !== null) { + if (isset($childValidationsDOMTag) && $childValidationsDOMTag->length > 0) { + // Loop through each returned child validation for the customer + foreach ($childValidationsDOMTag->item(0)->childNodes as $childValidationElement) { + if ($childValidationElement->nodeType !== 1) { + continue; + } + + // Make a new temporary CustomerChildValidation class + $customerChildValidation = new CustomerChildValidation(); - // Collect mandate elements and their methods - $collectMandateTags = array( - 'id' => 'setID', - 'signaturedate' => 'setSignatureDateFromString', - 'firstrundate' => 'setFirstRunDateFromString', - ); + // Set the child validation elements from the child validation element en element attributes + $customerChildValidation->setLevel($childValidationElement->getAttribute('level')) + ->setType(self::parseEnumAttribute('GeneralLedgerType', $childValidationElement->getAttribute('type'))) + ->setElementValue($childValidationElement->textContent); - $customer->setCollectMandate(new \PhpTwinfield\CustomerCollectMandate()); + // Add the child validation to the customer financials class + $customerFinancials->addChildValidation($customerChildValidation); - // Go through each collect mandate element and add to the assigned method - foreach ($collectMandateTags as $tag => $method) { - $customer->getCollectMandate()->$method(self::getField($collectMandateElement, $tag)); + // Clean that memory! + unset ($customerChildValidation); } } + + // Set the custom class to the customer + $customer->setFinancials($customerFinancials); } - // Credit management elements + // Get the creditmanagement element $creditManagementElement = $responseDOM->getElementsByTagName('creditmanagement')->item(0); - if ($creditManagementElement) { - - // Credit management elements and their methods - $creditManagementTags = array( - 'responsibleuser' => 'setResponsibleUser', - 'basecreditlimit' => 'setBaseCreditLimit', - 'sendreminder' => 'setSendReminder', - 'reminderemail' => 'setReminderEmail', - 'blocked' => 'setBlocked', - 'freetext1' => 'setFreeText1', - 'freetext2' => 'setFreeText2', - 'freetext3' => 'setFreeText3', - 'comment' => 'setComment', - ); - - $customer->setCreditManagement(new \PhpTwinfield\CustomerCreditManagement()); - - // Go through each financial element and add to the assigned method - foreach ($creditManagementTags as $tag => $method) { - - // Get the dom element - $_tag = $creditManagementElement->getElementsByTagName($tag)->item(0); - - // If it has a value, set it to the associated method - if (isset($_tag) && isset($_tag->textContent)) { - $value = $_tag->textContent; - if ($value == 'true' || $value == 'false') { - $value = $value == 'true'; - } + if ($creditManagementElement !== null) { + // Make a new temporary CustomerCreditManagement class + $customerCreditManagement = new CustomerCreditManagement(); + + // Set the customer credit management elements from the creditmanagement element + $customerCreditManagement->setBaseCreditLimit(self::parseMoneyAttribute(self::getField($customerCreditManagement, $creditManagementElement, 'basecreditlimit'))) + ->setBlocked(self::parseBooleanAttribute(self::getField($customerCreditManagement, $creditManagementElement, 'blocked'))) + ->setComment(self::getField($customerCreditManagement, $creditManagementElement, 'comment')) + ->setFreeText1(self::parseBooleanAttribute(self::getField($customerCreditManagement, $creditManagementElement, 'freetext1'))) + ->setFreeText2(self::getField($customerCreditManagement, $creditManagementElement, 'freetext2')) + ->setFreeText3(self::getField($customerCreditManagement, $creditManagementElement, 'freetext3')) + ->setReminderEmail(self::getField($customerCreditManagement, $creditManagementElement, 'reminderemail')) + ->setResponsibleUser(self::parseObjectAttribute('User', $customerCreditManagement, $creditManagementElement, 'responsibleuser', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setSendReminder(self::parseEnumAttribute('SendReminder', self::getField($customerCreditManagement, $creditManagementElement, 'sendreminder'))); + + // Set the customer credit management elements from the creditmanagement element attributes + $customerCreditManagement->setBlockedLocked(self::parseBooleanAttribute(self::getAttribute($creditManagementElement, 'blocked', 'locked'))) + ->setBlockedModified(self::parseDateTimeAttribute(self::getAttribute($creditManagementElement, 'blocked', 'modified'))); + + // Set the custom class to the customer + $customer->setCreditManagement($customerCreditManagement); + } - $customer->getCreditManagement()->$method($value); - } - } + // Get the remittanceadvice element + $remittanceAdviceElement = $responseDOM->getElementsByTagName('remittanceadvice')->item(0); + + if ($remittanceAdviceElement !== null) { + // Set the customer elements from the remittanceadvice element + $customer->setRemittanceAdviceSendType(self::parseEnumAttribute('RemittanceAdviceSendType', self::getField($customer, $remittanceAdviceElement, 'sendtype'))) + ->setRemittanceAdviceSendMail(self::getField($customer, $remittanceAdviceElement, 'sendmail')); } + // Get the addresses element $addressesDOMTag = $responseDOM->getElementsByTagName('addresses'); - if (isset($addressesDOMTag) && $addressesDOMTag->length > 0) { - - // Element tags and their methods for address - $addressTags = array( - 'name' => 'setName', - 'contact' => 'setContact', - 'country' => 'setCountry', - 'city' => 'setCity', - 'postcode' => 'setPostcode', - 'telephone' => 'setTelephone', - 'telefax' => 'setFax', - 'email' => 'setEmail', - 'field1' => 'setField1', - 'field2' => 'setField2', - 'field3' => 'setField3', - 'field4' => 'setField4', - 'field5' => 'setField5', - 'field6' => 'setField6', - ); - - $addressesDOM = $addressesDOMTag->item(0); + if (isset($addressesDOMTag) && $addressesDOMTag->length > 0) { // Loop through each returned address for the customer - foreach ($addressesDOM->getElementsByTagName('address') as $addressDOM) { - - // Make a new tempory CustomerAddress class - $temp_address = new CustomerAddress(); - - // Set the attributes ( id, type, default ) - $temp_address - ->setID($addressDOM->getAttribute('id')) - ->setType($addressDOM->getAttribute('type')) - ->setDefault(Util::parseBoolean($addressDOM->getAttribute('default'))); - - // Loop through the element tags. Determine if it exists and set it if it does - foreach ($addressTags as $tag => $method) { - - // Get the dom element - $_tag = $addressDOM->getElementsByTagName($tag)->item(0); - - // Check if the tag is set, and its content is set, to prevent DOMNode errors - if (isset($_tag) && isset($_tag->textContent)) { - $temp_address->$method($_tag->textContent); - } + foreach ($addressesDOMTag->item(0)->childNodes as $addressElement) { + if ($addressElement->nodeType !== 1) { + continue; } + // Make a new temporary CustomerAddress class + $customerAddress = new CustomerAddress(); + + // Set the default, id and type attribute + $customerAddress->setDefault(self::parseBooleanAttribute($addressElement->getAttribute('default'))) + ->setID($addressElement->getAttribute('id')) + ->setType(self::parseEnumAttribute('AddressType', $addressElement->getAttribute('type'))); + + // Set the address elements from the address element + $customerAddress->setCity(self::getField($customerAddress, $addressElement, 'city')) + ->setCountry(self::parseObjectAttribute('Country', $customerAddress, $addressElement, 'country', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setEmail(self::getField($customerAddress, $addressElement, 'email')) + ->setField1(self::getField($customerAddress, $addressElement, 'field1')) + ->setField2(self::getField($customerAddress, $addressElement, 'field2')) + ->setField3(self::getField($customerAddress, $addressElement, 'field3')) + ->setField4(self::getField($customerAddress, $addressElement, 'field4')) + ->setField5(self::getField($customerAddress, $addressElement, 'field5')) + ->setField6(self::getField($customerAddress, $addressElement, 'field6')) + ->setName(self::getField($customerAddress, $addressElement, 'name')) + ->setPostcode(self::getField($customerAddress, $addressElement, 'postcode')) + ->setTelephone(self::getField($customerAddress, $addressElement, 'telephone')) + ->setTelefax(self::getField($customerAddress, $addressElement, 'telefax')); + // Add the address to the customer - $customer->addAddress($temp_address); + $customer->addAddress($customerAddress); // Clean that memory! - unset($temp_address); + unset ($customerAddress); } } + // Get the banks element $banksDOMTag = $responseDOM->getElementsByTagName('banks'); - if (isset($banksDOMTag) && $banksDOMTag->length > 0) { - - // Element tags and their methods for bank - $bankTags = array( - 'ascription' => 'setAscription', - 'accountnumber' => 'setAccountnumber', - 'field2' => 'setAddressField2', - 'field3' => 'setAddressField3', - 'bankname' => 'setBankname', - 'biccode' => 'setBiccode', - 'city' => 'setCity', - 'country' => 'setCountry', - 'iban' => 'setIban', - 'natbiccode' => 'setNatbiccode', - 'postcode' => 'setPostcode', - 'state' => 'setState', - ); - - $banksDOM = $banksDOMTag->item(0); + if (isset($banksDOMTag) && $banksDOMTag->length > 0) { // Loop through each returned bank for the customer - /** @var \DOMElement $bankDOM */ - foreach ($banksDOM->getElementsByTagName('bank') as $bankDOM) { + foreach ($banksDOMTag->item(0)->childNodes as $bankElement) { + if ($bankElement->nodeType !== 1) { + continue; + } - // Make a new tempory CustomerBank class - $temp_bank = new CustomerBank(); + // Make a new temporary CustomerBank class + $customerBank = new CustomerBank(); + + // Set the default and id attribute + $customerBank->setBlocked(self::parseBooleanAttribute($bankElement->getAttribute('blocked'))) + ->setDefault(self::parseBooleanAttribute($bankElement->getAttribute('default'))) + ->setID($bankElement->getAttribute('id')); + + // Set the bank elements from the bank element + $customerBank->setAscription(self::getField($customerBank, $bankElement, 'ascription')) + ->setAccountNumber(self::getField($customerBank, $bankElement, 'accountnumber')) + ->setBankName(self::getField($customerBank, $bankElement, 'bankname')) + ->setBicCode(self::getField($customerBank, $bankElement, 'biccode')) + ->setCity(self::getField($customerBank, $bankElement, 'city')) + ->setCountry(self::parseObjectAttribute('Country', $customerBank, $bankElement, 'country', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setField2(self::getField($customerBank, $bankElement, 'field2')) + ->setField3(self::getField($customerBank, $bankElement, 'field3')) + ->setIban(self::getField($customerBank, $bankElement, 'iban')) + ->setNatBicCode(self::getField($customerBank, $bankElement, 'natbiccode')) + ->setPostcode(self::getField($customerBank, $bankElement, 'postcode')) + ->setState(self::getField($customerBank, $bankElement, 'state')); - // Set the attributes ( id, default ) - $temp_bank - ->setID($bankDOM->getAttribute('id')) - ->setDefault(Util::parseBoolean($bankDOM->getAttribute('default'))); + // Add the bank to the customer + $customer->addBank($customerBank); + + // Clean that memory! + unset ($customerBank); + } + } - // Loop through the element tags. Determine if it exists and set it if it does - foreach ($bankTags as $tag => $method) { + // Get the postingrules element + $postingrulesDOMTag = $responseDOM->getElementsByTagName('postingrules'); - // Get the dom element - $_tag = $bankDOM->getElementsByTagName($tag)->item(0); + if (isset($postingrulesDOMTag) && $postingrulesDOMTag->length > 0) { + // Loop through each returned postingrule for the customer + foreach ($postingrulesDOMTag->item(0)->childNodes as $postingruleElement) { + if ($postingruleElement->nodeType !== 1) { + continue; + } - // Check if the tag is set, and its content is set, to prevent DOMNode errors - if (isset($_tag) && isset($_tag->textContent)) { - $temp_bank->$method($_tag->textContent); + // Make a new temporary CustomerPostingRule class + $customerPostingRule = new CustomerPostingRule(); + + // Set the id and status attribute + $customerPostingRule->setID($postingruleElement->getAttribute('id')) + ->setStatus(self::parseEnumAttribute('Status', $postingruleElement->getAttribute('status'))); + + // Set the postingrule elements from the postingrule element + $customerPostingRule->setAmount(self::parseMoneyAttribute(self::getField($customerPostingRule, $postingruleElement, 'amount'))) + ->setCurrency(self::parseObjectAttribute('Currency', $customerPostingRule, $postingruleElement, 'currency', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setDescription(self::getField($customerPostingRule, $postingruleElement, 'description')); + + // Get the lines element + $linesDOMTag = $postingruleElement->getElementsByTagName('lines'); + + if (isset($linesDOMTag) && $linesDOMTag->length > 0) { + // Loop through each returned line for the posting rule + foreach ($linesDOMTag->item(0)->childNodes as $lineElement) { + if ($lineElement->nodeType !== 1) { + continue; + } + + // Make a new temporary CustomerLine class + $customerLine = new CustomerLine(); + + // Set the line elements from the line element + $customerLine->setDescription(self::getField($customerLine, $lineElement, 'description')) + ->setDimension1(self::parseObjectAttribute('GeneralLedger', $customerLine, $lineElement, 'dimension1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setDimension2(self::parseObjectAttribute('CostCenter', $customerLine, $lineElement, 'dimension2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setDimension3(self::parseObjectAttribute('UnknownDimension', $customerLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setOffice(self::parseObjectAttribute('Office', $customerLine, $lineElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setRatio(self::getField($customerLine, $lineElement, 'ratio')) + ->setVatCode(self::parseObjectAttribute('VatCode', $customerLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); + + // Set the line elements from the line element attributes + $customerLine->setDimension1ID(self::getAttribute($lineElement, 'dimension1', 'id')) + ->setDimension2ID(self::getAttribute($lineElement, 'dimension2', 'id')) + ->setDimension3ID(self::getAttribute($lineElement, 'dimension2', 'id')); + + // Add the line to the customer posting rule + $customerPostingRule->addLine($customerLine); + + // Clean that memory! + unset ($customerLine); } } - // Add the bank to the customer - $customer->addBank($temp_bank); + // Add the postingrule to the customer + $customer->addPostingRule($customerPostingRule); // Clean that memory! - unset($temp_bank); + unset ($customerPostingRule); } } + // Get the paymentconditions element + $paymentConditionsElement = $responseDOM->getElementsByTagName('paymentconditions')->item(0); + + if ($paymentConditionsElement !== null) { + // Set the customer elements from the paymentconditions element + $customer->setPaymentConditionDiscountDays(self::getField($customer, $paymentConditionsElement, 'discountdays')) + ->setPaymentConditionDiscountPercentage(self::getField($customer, $paymentConditionsElement, 'discountpercentage')); + } + + // Return the complete object return $customer; } -} +} \ No newline at end of file diff --git a/src/Mappers/DimensionGroupMapper.php b/src/Mappers/DimensionGroupMapper.php new file mode 100644 index 00000000..c10b503f --- /dev/null +++ b/src/Mappers/DimensionGroupMapper.php @@ -0,0 +1,77 @@ + + */ +class DimensionGroupMapper extends BaseMapper +{ + + /** + * Maps a Response object to a clean DimensionGroup entity. + * + * @access public + * + * @param \PhpTwinfield\Response\Response $response + * + * @return DimensionGroup + * @throws \PhpTwinfield\Exception + */ + public static function map(Response $response) + { + // Generate new DimensionGroup object + $dimensiongroup = new DimensionGroup(); + + // Gets the raw DOMDocument response. + $responseDOM = $response->getResponseDocument(); + + // Get the root/dimensiongroup element + $dimensiongroupElement = $responseDOM->documentElement; + + // Set the result and status attribute + $dimensiongroup->setResult($dimensiongroupElement->getAttribute('result')) + ->setStatus(self::parseEnumAttribute('Status', $dimensiongroupElement->getAttribute('status'))); + + // Set the dimension group elements from the dimension group element + $dimensiongroup->setCode(self::getField($dimensiongroup, $dimensiongroupElement, 'code')) + ->setName(self::getField($dimensiongroup, $dimensiongroupElement, 'name')) + ->setOffice(self::parseObjectAttribute('Office', $dimensiongroup, $dimensiongroupElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setShortName(self::getField($dimensiongroup, $dimensiongroupElement, 'shortname')); + + // Get the dimensions element + $dimensionsDOMTag = $responseDOM->getElementsByTagName('dimensions'); + + if (isset($dimensionsDOMTag) && $dimensionsDOMTag->length > 0) { + // Loop through each returned dimension for the dimensiongroup + foreach ($dimensionsDOMTag->item(0)->childNodes as $dimensionElement) { + if ($dimensionElement->nodeType !== 1) { + continue; + } + + // Make a new temporary DimensionGroupDimension class + $dimensionGroupDimension = new DimensionGroupDimension(); + + // Set the dimension group dimension elements from the dimension element + $dimensionGroupDimension->setType(self::parseObjectAttribute('DimensionType', $dimensionGroupDimension, $dimensionElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))); + $dimensionGroupDimension->setCode(self::parseObjectAttribute('DimensionGroupDimension', $dimensionGroupDimension, $dimensionElement, 'code', array('name' => 'setName', 'shortname' => 'setShortName'))); + + // Add the dimension to the dimension group + $dimensiongroup->addDimension($dimensionGroupDimension); + + // Clean that memory! + unset ($dimensionGroupDimension); + } + } + + // Return the complete object + return $dimensiongroup; + } +} diff --git a/src/Mappers/DimensionTypeMapper.php b/src/Mappers/DimensionTypeMapper.php new file mode 100644 index 00000000..1d776cb3 --- /dev/null +++ b/src/Mappers/DimensionTypeMapper.php @@ -0,0 +1,87 @@ + + */ +class DimensionTypeMapper extends BaseMapper +{ + /** + * Maps a Response object to a clean DimensionType entity. + * + * @access public + * + * @param \PhpTwinfield\Response\Response $response + * + * @return DimensionType + * @throws \PhpTwinfield\Exception + */ + public static function map(Response $response) + { + // Generate new DimensionType object + $dimensiontype = new DimensionType(); + + // Gets the raw DOMDocument response. + $responseDOM = $response->getResponseDocument(); + + // Get the root/dimensiontype element + $dimensiontypeElement = $responseDOM->documentElement; + + // Set the result and status attribute + $dimensiontype->setResult($dimensiontypeElement->getAttribute('result')) + ->setStatus(self::parseEnumAttribute('Status', $dimensiontypeElement->getAttribute('status'))); + + // Set the dimension type elements from the dimension type element + $dimensiontype->setCode(self::getField($dimensiontype, $dimensiontypeElement, 'code')) + ->setMask(self::getField($dimensiontype, $dimensiontypeElement, 'mask')) + ->setName(self::getField($dimensiontype, $dimensiontypeElement, 'name')) + ->setOffice(self::parseObjectAttribute('Office', $dimensiontype, $dimensiontypeElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setShortName(self::getField($dimensiontype, $dimensiontypeElement, 'shortname')); + + // Get the levels element + $levelsElement = $responseDOM->getElementsByTagName('levels')->item(0); + + if ($levelsElement !== null) { + // Make a new temporary DimensionTypeLevels class + $dimensionTypeLevels = new DimensionTypeLevels(); + + // Set the dimension type levels elements from the levels element + $dimensionTypeLevels->setFinancials(self::getField($dimensionTypeLevels, $levelsElement, 'financials')) + ->setTime(self::getField($dimensionTypeLevels, $levelsElement, 'time')); + + // Set the custom class to the dimension type + $dimensiontype->setLevels($dimensionTypeLevels); + } + + // Get the address element + $addressElement = $responseDOM->getElementsByTagName('address')->item(0); + + if ($addressElement !== null) { + // Make a new temporary DimensionTypeAddress class + $dimensionTypeAddress = new DimensionTypeAddress(); + + // Set the dimension type address elements from the address element + $dimensionTypeAddress->setLabel1(self::getField($dimensionTypeAddress, $addressElement, 'label1')) + ->setLabel2(self::getField($dimensionTypeAddress, $addressElement, 'label2')) + ->setLabel3(self::getField($dimensionTypeAddress, $addressElement, 'label3')) + ->setLabel4(self::getField($dimensionTypeAddress, $addressElement, 'label4')) + ->setLabel5(self::getField($dimensionTypeAddress, $addressElement, 'label5')) + ->setLabel6(self::getField($dimensionTypeAddress, $addressElement, 'label6')); + + // Set the custom class to the dimensiontype + $dimensiontype->setAddress($dimensionTypeAddress); + } + + // Return the complete object + return $dimensiontype; + } +} \ No newline at end of file diff --git a/src/Mappers/FixedAssetMapper.php b/src/Mappers/FixedAssetMapper.php new file mode 100644 index 00000000..35b57fd8 --- /dev/null +++ b/src/Mappers/FixedAssetMapper.php @@ -0,0 +1,174 @@ + + */ +class FixedAssetMapper extends BaseMapper +{ + /** + * Maps a Response object to a clean FixedAsset entity. + * + * @access public + * + * @param \PhpTwinfield\Response\Response $response + * + * @return FixedAsset + * @throws \PhpTwinfield\Exception + */ + public static function map(Response $response) + { + // Generate new FixedAsset object + $fixedAsset = new FixedAsset(); + + // Gets the raw DOMDocument response. + $responseDOM = $response->getResponseDocument(); + // Get the root/fixed asset element + $fixedAssetElement = $responseDOM->documentElement; + + // Set the result and status attribute + $fixedAsset->setResult($fixedAssetElement->getAttribute('result')) + ->setStatus(self::parseEnumAttribute('Status', $fixedAssetElement->getAttribute('status'))); + + // Set the fixed asset elements from the fixed asset element + $fixedAsset->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($fixedAsset, $fixedAssetElement, 'behaviour'))) + ->setCode(self::getField($fixedAsset, $fixedAssetElement, 'code')) + ->setGroup(self::parseObjectAttribute('DimensionGroup', $fixedAsset, $fixedAssetElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setInUse(self::parseBooleanAttribute(self::getField($fixedAsset, $fixedAssetElement, 'name'))) + ->setName(self::getField($fixedAsset, $fixedAssetElement, 'name')) + ->setOffice(self::parseObjectAttribute('Office', $fixedAsset, $fixedAssetElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setTouched(self::getField($fixedAsset, $fixedAssetElement, 'touched')) + ->setType(self::parseObjectAttribute('DimensionType', $fixedAsset, $fixedAssetElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setUID(self::getField($fixedAsset, $fixedAssetElement, 'uid')); + + // Get the financials element + $financialsElement = $responseDOM->getElementsByTagName('financials')->item(0); + + if ($financialsElement !== null) { + // Make a new temporary FixedAssetFinancials class + $fixedAssetFinancials = new FixedAssetFinancials(); + + // Set the financials elements from the financials element + $fixedAssetFinancials->setAccountType(self::parseEnumAttribute('AccountType', self::getField($fixedAssetFinancials, $financialsElement, 'accounttype'))) + ->setLevel(self::getField($fixedAssetFinancials, $financialsElement, 'level')) + ->setMatchType(self::parseEnumAttribute('MatchType', self::getField($fixedAssetFinancials, $financialsElement, 'matchtype'))) + ->setSubAnalyse(self::parseEnumAttribute('SubAnalyse', self::getField($fixedAssetFinancials, $financialsElement, 'subanalyse'))) + ->setSubstitutionLevel(self::getField($fixedAssetFinancials, $financialsElement, 'substitutionlevel')) + ->setSubstituteWith(self::parseObjectAttribute('CostCenter', $fixedAssetFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setVatCode(self::parseObjectAttribute('VatCode', $fixedAssetFinancials, $financialsElement, 'vatcode')); + + // Set the financials elements from the financials element attributes + $fixedAssetFinancials->setSubstituteWithID(self::getAttribute($financialsElement, 'substitutewith', 'id')); + $fixedAssetFinancials->setVatCodeFixed(self::parseBooleanAttribute(self::getAttribute($financialsElement, 'vatcode', 'fixed'))); + + // Set the custom class to the fixedAsset + $fixedAsset->setFinancials($fixedAssetFinancials); + } + + // Get the fixedassets element + $fixedAssetsElement = $responseDOM->getElementsByTagName('fixedassets')->item(0); + + if ($fixedAssetsElement !== null) { + // Make a new temporary FixedAssetFixedAssets class + $fixedAssetFixedAssets = new FixedAssetFixedAssets(); + + // Set the fixed assets elements from the fixed assets element + $fixedAssetFixedAssets->setBeginPeriod(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'beginperiod')) + ->setFreeText1(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'freetext1')) + ->setFreeText2(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'freetext2')) + ->setFreeText3(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'freetext3')) + ->setFreeText4(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'freetext4')) + ->setFreeText5(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'freetext5')) + ->setLastDepreciation(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'lastdepreciation')) + ->setMethod(self::parseObjectAttribute('AssetMethod', $fixedAssetFixedAssets, $fixedAssetsElement, 'method', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setNrOfPeriods(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'nrofperiods')) + ->setPercentage(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'percentage')) + ->setPurchaseDate(self::parseDateAttribute(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'purchasedate'))) + ->setResidualValue(self::parseMoneyAttribute(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'residualvalue'))) + ->setSellDate(self::parseDateAttribute(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'selldate'))) + ->setStatus(self::parseEnumAttribute('FixedAssetsStatus', self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'status'))) + ->setStopValue(self::parseMoneyAttribute(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'stopvalue'))); + + // Set the fixed assets elements from the fixed assets element attributes + $fixedAssetFixedAssets->setBeginPeriodLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'beginperiod', 'locked'))) + ->setMethodLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'method', 'locked'))) + ->setStatusLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'status', 'locked'))) + ->setFreeText1Locked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'freetext1', 'locked'))) + ->setFreeText2Locked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'freetext2', 'locked'))) + ->setFreeText3Locked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'freetext3', 'locked'))) + ->setFreeText4Locked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'freetext4', 'locked'))) + ->setFreeText5Locked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'freetext5', 'locked'))) + ->setLastDepreciationLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'lastdepreciation', 'locked'))) + ->setNrOfPeriodsInherited(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'nrofperiods', 'inherited'))) + ->setNrOfPeriodsLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'nrofperiods', 'locked'))) + ->setPercentageLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'percentage', 'locked'))) + ->setPurchaseDateLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'purchasedate', 'locked'))) + ->setResidualValueLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'residualvalue', 'locked'))) + ->setSellDateLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'selldate', 'locked'))) + ->setStopValueLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'stopvalue', 'locked'))); + + // Get the translines element + $transactionLinesDOMTag = $fixedAssetsElement->getElementsByTagName('translines'); + + if (isset($transactionLinesDOMTag) && $transactionLinesDOMTag->length > 0) { + // Loop through each returned transactionLine for the fixedAsset + foreach ($transactionLinesDOMTag->item(0)->childNodes as $transactionLineElement) { + if ($transactionLineElement->nodeType !== 1) { + continue; + } + + // Make a new temporary FixedAssetTransactionLine class + $fixedAssetTransactionLine = new FixedAssetTransactionLine(); + + // Set the fixed assets transaction line elements from the fixed assets transline element + $fixedAssetTransactionLine->setAmount(self::parseMoneyAttribute(self::getField($fixedAssetTransactionLine, $transactionLineElement, 'amount'))) + ->setCode(self::getField($fixedAssetTransactionLine, $transactionLineElement, 'code')) + ->setDim1(self::parseObjectAttribute('GeneralLedger', $fixedAssetTransactionLine, $transactionLineElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim2(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim3(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim4(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim4', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim5(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim5', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim6(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim6', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setLine(self::getField($fixedAssetTransactionLine, $transactionLineElement, 'line')) + ->setNumber(self::getField($fixedAssetTransactionLine, $transactionLineElement, 'number')) + ->setPeriod(self::getField($fixedAssetTransactionLine, $transactionLineElement, 'period')); + + // Set the fixed assets transaction line elements from the fixed assets transline attributes + $fixedAssetTransactionLine->setAmountLocked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'amount', 'locked'))) + ->setCodeLocked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'code', 'locked'))) + ->setDim1Locked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'dim1', 'locked'))) + ->setDim2Locked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'dim2', 'locked'))) + ->setDim3Locked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'dim3', 'locked'))) + ->setDim4Locked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'dim4', 'locked'))) + ->setDim5Locked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'dim5', 'locked'))) + ->setDim6Locked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'dim6', 'locked'))) + ->setLineLocked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'line', 'locked'))) + ->setNumberLocked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'number', 'locked'))) + ->setPeriodLocked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'period', 'locked'))); + + // Add the transactionLine to the fixedAsset + $fixedAssetFixedAssets->addTransactionLine($fixedAssetTransactionLine); + + // Clean that memory! + unset ($fixedAssetTransactionLine); + } + } + + // Set the custom class to the fixedAsset + $fixedAsset->setFixedAssets($fixedAssetFixedAssets); + } + + // Return the complete object + return $fixedAsset; + } +} diff --git a/src/Mappers/GeneralLedgerMapper.php b/src/Mappers/GeneralLedgerMapper.php new file mode 100644 index 00000000..5631505a --- /dev/null +++ b/src/Mappers/GeneralLedgerMapper.php @@ -0,0 +1,109 @@ + + */ +class GeneralLedgerMapper extends BaseMapper +{ + /** + * Maps a Response object to a clean GeneralLedger entity. + * + * @access public + * + * @param \PhpTwinfield\Response\Response $response + * + * @return GeneralLedger + * @throws \PhpTwinfield\Exception + */ + public static function map(Response $response) + { + // Generate new GeneralLedger object + $generalLedger = new GeneralLedger(); + + // Gets the raw DOMDocument response. + $responseDOM = $response->getResponseDocument(); + + // Get the root/dimension element + $generalLedgerElement = $responseDOM->documentElement; + + // Set the result and status attribute + $generalLedger->setResult($generalLedgerElement->getAttribute('result')) + ->setStatus(self::parseEnumAttribute('Status', $generalLedgerElement->getAttribute('status'))); + + // Set the general ledger elements from the general ledger element + $generalLedger->setBeginPeriod(self::getField($generalLedger, $generalLedgerElement, 'beginperiod')) + ->setBeginYear(self::getField($generalLedger, $generalLedgerElement, 'beginyear')) + ->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($generalLedger, $generalLedgerElement, 'behaviour'))) + ->setCode(self::getField($generalLedger, $generalLedgerElement, 'code')) + ->setEndPeriod(self::getField($generalLedger, $generalLedgerElement, 'endperiod')) + ->setEndYear(self::getField($generalLedger, $generalLedgerElement, 'endyear')) + ->setGroup(self::parseObjectAttribute('DimensionGroup', $generalLedger, $generalLedgerElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setInUse(self::parseBooleanAttribute(self::getField($generalLedger, $generalLedgerElement, 'inuse'))) + ->setName(self::getField($generalLedger, $generalLedgerElement, 'name')) + ->setOffice(self::parseObjectAttribute('Office', $generalLedger, $generalLedgerElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setShortName(self::getField($generalLedger, $generalLedgerElement, 'shortname')) + ->setTouched(self::getField($generalLedger, $generalLedgerElement, 'touched')) + ->setType(self::parseObjectAttribute('DimensionType', $generalLedger, $generalLedgerElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setUID(self::getField($generalLedger, $generalLedgerElement, 'uid')); + + // Get the financials element + $financialsElement = $responseDOM->getElementsByTagName('financials')->item(0); + + if ($financialsElement !== null) { + // Make a new temporary GeneralLedgerFinancials class + $generalLedgerFinancials = new GeneralLedgerFinancials(); + + // Set the financials elements from the financials element + $generalLedgerFinancials->setAccountType(self::parseEnumAttribute('AccountType', self::getField($generalLedgerFinancials, $financialsElement, 'accounttype'))) + ->setLevel(self::getField($generalLedgerFinancials, $financialsElement, 'level')) + ->setMatchType(self::parseEnumAttribute('MatchType', self::getField($generalLedgerFinancials, $financialsElement, 'matchtype'))) + ->setSubAnalyse(self::parseEnumAttribute('SubAnalyse', self::getField($generalLedgerFinancials, $financialsElement, 'subanalyse'))) + ->setVatCode(self::parseObjectAttribute('VatCode', $generalLedgerFinancials, $financialsElement, 'vatcode')); + + // Set the financials elements from the financials element attributes + $generalLedgerFinancials->setVatCodeFixed(self::parseBooleanAttribute(self::getAttribute($financialsElement, 'vatcode', 'fixed'))); + + // Get the childvalidations element + $childValidationsDOMTag = $financialsElement->getElementsByTagName('childvalidations'); + + if (isset($childValidationsDOMTag) && $childValidationsDOMTag->length > 0) { + // Loop through each returned childValidation for the generalLedger + foreach ($childValidationsDOMTag->item(0)->childNodes as $childValidationElement) { + if ($childValidationElement->nodeType !== 1) { + continue; + } + + // Make a new temporary GeneralLedgerChildValidation class + $generalLedgerChildValidation = new GeneralLedgerChildValidation(); + + // Set the child validation elements from the child validation element en element attributes + $generalLedgerChildValidation->setLevel($childValidationElement->getAttribute('level')); + $generalLedgerChildValidation->setType(self::parseEnumAttribute('GeneralLedgerType', $childValidationElement->getAttribute('type'))); + $generalLedgerChildValidation->setElementValue($childValidationElement->textContent); + + // Add the child validation to the general ledger financials class + $generalLedgerFinancials->addChildValidation($generalLedgerChildValidation); + + // Clean that memory! + unset ($generalLedgerChildValidation); + } + } + + // Set the custom class to the general ledger + $generalLedger->setFinancials($generalLedgerFinancials); + } + + // Return the complete object + return $generalLedger; + } +} diff --git a/src/Mappers/InvoiceMapper.php b/src/Mappers/InvoiceMapper.php index 5fccf1f9..07b9a0b1 100644 --- a/src/Mappers/InvoiceMapper.php +++ b/src/Mappers/InvoiceMapper.php @@ -1,133 +1,153 @@ + */ class InvoiceMapper extends BaseMapper { - public static function map(Response $response) + /** + * Maps a Response object to a clean Invoice entity. + * + * @access public + * + * @param \PhpTwinfield\Response\Response $response + * + * @return Invoice + * @throws \PhpTwinfield\Exception + */ + public static function map(Response $response) { - $responseDOM = $response->getResponseDocument(); - - $invoiceTags = array( - 'office' => 'setOffice', - 'invoicetype' => 'setInvoiceType', - 'invoicenumber' => 'setInvoiceNumber', - 'status' => 'setStatus', - 'currency' => 'setCurrency', - 'period' => 'setPeriod', - 'invoicedate' => 'setInvoiceDate', - 'duedate' => 'setDueDateFromString', - 'performancedate' => 'setPerformanceDate', - 'paymentmethod' => 'setPaymentMethod', - 'bank' => 'setBank', - 'invoiceaddressnumber' => 'setInvoiceAddressNumber', - 'deliveraddressnumber' => 'setDeliverAddressNumber', - 'headertext' => 'setHeaderText', - 'footertext' => 'setFooterText', - ); - - $customerTags = array( - 'customer' => 'setCode', - ); - - $totalsTags = array( - 'valueexcl' => 'setValueExcl', - 'valueinc' => 'setValueInc', - ); - - // Generate new Invoice + // Generate new Invoice object $invoice = new Invoice(); - // Loop through all invoice tags - foreach ($invoiceTags as $tag => $method) { + // Gets the raw DOMDocument response. + $responseDOM = $response->getResponseDocument(); - self::setFromTagValue($responseDOM, $tag, [$invoice, $method]); + // Get the root/salesinvoice element + $invoiceElement = $responseDOM->documentElement; + + // Set the result attribute + $invoice->setResult($invoiceElement->getAttribute('result')); + + // Set the invoice elements from the invoice element + $invoice->setBank(self::parseObjectAttribute('CashBankBook', $invoice, $invoiceElement, 'bank')) + ->setCurrency(self::parseObjectAttribute('Currency', $invoice, $invoiceElement, 'currency')) + ->setCustomer(self::parseObjectAttribute('Customer', $invoice, $invoiceElement, 'customer')) + ->setDeliverAddressNumber(self::getField($invoice, $invoiceElement, 'deliveraddressnumber')) + ->setDueDate(self::parseDateAttribute(self::getField($invoice, $invoiceElement, 'duedate'))) + ->setFooterText(self::getField($invoice, $invoiceElement, 'footertext')) + ->setHeaderText(self::getField($invoice, $invoiceElement, 'headertext')) + ->setInvoiceAddressNumber(self::getField($invoice, $invoiceElement, 'invoiceaddressnumber')) + ->setInvoiceDate(self::parseDateAttribute(self::getField($invoice, $invoiceElement, 'invoicedate'))) + ->setInvoiceNumber(self::getField($invoice, $invoiceElement, 'invoicenumber')) + ->setInvoiceType(self::parseObjectAttribute('InvoiceType', $invoice, $invoiceElement, 'invoicetype')) + ->setOffice(self::parseObjectAttribute('Office', $invoice, $invoiceElement, 'office')) + ->setPaymentMethod(self::parseEnumAttribute('PaymentMethod', self::getField($invoice, $invoiceElement, 'paymentmethod'))) + ->setPeriod(self::getField($invoice, $invoiceElement, 'period')) + ->setPerformanceDate(self::parseDateAttribute(self::getField($invoice, $invoiceElement, 'performancedate'))) + ->setStatus(self::parseEnumAttribute('InvoiceStatus', self::getField($invoice, $invoiceElement, 'status'))); + + // Get the totals element + $totalsElement = $responseDOM->getElementsByTagName('totals')->item(0); + + if ($totalsElement !== null) { + // Make a new temporary InvoiceTotals class + $invoiceTotals = new InvoiceTotals(); + + // Set the invoice totals elements from the totals element + $invoiceTotals->setValueExcl(self::parseMoneyAttribute(self::getField($invoiceTotals, $totalsElement, 'valueexcl'))) + ->setValueInc(self::parseMoneyAttribute(self::getField($invoiceTotals, $totalsElement, 'valueinc'))); + + // Set the custom class to the invoice + $invoice->setTotals($invoiceTotals); } - // Make a custom, and loop through custom tags - $customer = new Customer(); - foreach ($customerTags as $tag => $method) { - $_tag = $responseDOM->getElementsByTagName($tag)->item(0); + // Get the lines element + $linesDOMTag = $responseDOM->getElementsByTagName('lines'); - if (isset($_tag) && isset($_tag->textContent)) { - $customer->$method($_tag->textContent); - } - } - - // Make an InvoiceTotals and loop through custom tags - $invoiceTotals = new InvoiceTotals(); - foreach ($totalsTags as $tag => $method) { - $_tag = $responseDOM->getElementsByTagName($tag)->item(0); + if (isset($linesDOMTag) && $linesDOMTag->length > 0) { + // Loop through each returned lines for the invoice + foreach ($linesDOMTag->item(0)->childNodes as $lineElement) { + if ($lineElement->nodeType !== 1) { + continue; + } - if (isset($_tag) && isset($_tag->textContent)) { - $invoiceTotals->$method($_tag->textContent); + // Make a new temporary InvoiceLine class + $invoiceLine = new InvoiceLine(); + + // Set the ID attribute + $invoiceLine->setID($lineElement->getAttribute('id')); + + // Set the invoice line elements from the line element + $invoiceLine->setAllowDiscountOrPremium(self::parseBooleanAttribute(self::getField($invoiceLine, $lineElement, 'allowdiscountorpremium'))) + ->setArticle(self::parseObjectAttribute('Article', $invoiceLine, $lineElement, 'article')) + ->setDescription(self::getField($invoiceLine, $lineElement, 'description')) + ->setDim1(self::parseObjectAttribute('GeneralLedger', $invoiceLine, $lineElement, 'dim1')) + ->setFreeText1(self::getField($invoiceLine, $lineElement, 'freetext1')) + ->setFreeText2(self::getField($invoiceLine, $lineElement, 'freetext2')) + ->setFreeText3(self::getField($invoiceLine, $lineElement, 'freetext3')) + ->setPerformanceDate(self::parseDateAttribute(self::getField($invoiceLine, $lineElement, 'performancedate'))) + ->setPerformanceType(self::parseEnumAttribute('PerformanceType', self::getField($invoiceLine, $lineElement, 'performancetype'))) + ->setQuantity(self::getField($invoiceLine, $lineElement, 'quantity')) + ->setSubArticleFromSubCode(self::getField($invoiceLine, $lineElement, 'subarticle')) + ->setUnits(self::getField($invoiceLine, $lineElement, 'units')) + ->setUnitsPriceExcl(self::parseMoneyAttribute(self::getField($invoiceLine, $lineElement, 'unitspriceexcl'))) + ->setUnitsPriceInc(self::parseMoneyAttribute(self::getField($invoiceLine, $lineElement, 'unitspriceinc'))) + ->setValueExcl(self::parseMoneyAttribute(self::getField($invoiceLine, $lineElement, 'valueexcl'))) + ->setValueInc(self::parseMoneyAttribute(self::getField($invoiceLine, $lineElement, 'valueinc'))) + ->setVatCode(self::parseObjectAttribute('VatCode', $invoiceLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) + ->setVatValue(self::parseMoneyAttribute(self::getField($invoiceLine, $lineElement, 'vatvalue'))); + + // Set the custom class to the invoice + $invoice->addLine($invoiceLine); } } - // Set the custom classes to the invoice - $invoice->setCustomer($customer); - $invoice->setTotals($invoiceTotals); - - $lineTags = array( - 'article' => 'setArticle', - 'subarticle' => 'setSubArticle', - 'quantity' => 'setQuantity', - 'units' => 'setUnits', - 'allowdiscountorpremium' => 'setAllowDiscountOrPremium', - 'description' => 'setDescription', - 'valueexcl' => 'setValueExcl', - 'vatvalue' => 'setVatValue', - 'valueinc' => 'setValueInc', - 'unitspriceexcl' => 'setUnitsPriceExcl', - 'unitspriceinc' => 'setUnitsPriceInc', - 'freetext1' => 'setFreeText1', - 'freetext2' => 'setFreeText2', - 'freetext3' => 'setFreeText3', - 'performancedate' => 'setPerformanceDate', - 'performancetype' => 'setPerformanceType', - 'dim1' => 'setDim1', - ); - - /** @var \DOMElement $lineDOM */ - foreach ($responseDOM->getElementsByTagName('line') as $lineDOM) { - - $invoiceLine = new InvoiceLine(); - $invoiceLine->setID($lineDOM->getAttribute('id')); - - foreach ($lineTags as $tag => $method) { - - $content = self::getField($lineDOM, $tag); - - if (null !== $content) { - $invoiceLine->$method($content); + // Get the vatlines element + $vatlinesDOMTag = $responseDOM->getElementsByTagName('vatlines'); + + if (isset($vatlinesDOMTag) && $vatlinesDOMTag->length > 0) { + // Loop through each returned lines for the invoice + foreach ($vatlinesDOMTag->item(0)->childNodes as $vatlineElement) { + if ($vatlineElement->nodeType !== 1) { + continue; } - } - $invoice->addLine($invoiceLine); - } + // Make a new temporary InvoiceVatLine class + $invoiceVatLine = new InvoiceVatLine(); - // Financial elements and their methods - $financialsTags = array( - 'code' => 'setFinancialCode', - 'number' => 'setFinancialNumber' - ); + // Set the invoice vat line elements from the vat line element + $invoiceVatLine->setPerformanceDate(self::parseDateAttribute(self::getField($invoiceVatLine, $vatlineElement, 'performancedate'))) + ->setPerformanceType(self::parseEnumAttribute('PerformanceType', self::getField($invoiceVatLine, $vatlineElement, 'performancetype'))) + ->setVatCode(self::parseObjectAttribute('VatCode', $invoiceVatLine, $vatlineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) + ->setVatValue(self::parseMoneyAttribute(self::getField($invoiceVatLine, $vatlineElement, 'vatvalue'))); - // Financial elements - $financialElement = $responseDOM->getElementsByTagName('financials')->item(0); + // Set the custom class to the invoice + $invoice->addVatLine($invoiceVatLine); + } + } - if ($financialElement !== null) { + // Get the financials element + $financialsElement = $responseDOM->getElementsByTagName('financials')->item(0); - // Go through each financial element and add to the assigned method - foreach ($financialsTags as $tag => $method) { - $invoice->$method(self::getField($financialElement, $tag)); - } + if ($financialsElement !== null) { + // Set the invoice elements from the financials element + $invoice->setFinancialCode(self::getField($invoice, $financialsElement, 'code')) + ->setFinancialNumber(self::getField($invoice, $financialsElement, 'number')); } + //Return the complete object return $invoice; } -} +} \ No newline at end of file diff --git a/src/Mappers/InvoiceTypeMapper.php b/src/Mappers/InvoiceTypeMapper.php new file mode 100644 index 00000000..51706339 --- /dev/null +++ b/src/Mappers/InvoiceTypeMapper.php @@ -0,0 +1,45 @@ + + */ +class InvoiceTypeMapper extends BaseMapper +{ + /** + * Maps a Response object to a clean InvoiceType entity. + * + * @access public + * + * @param \PhpTwinfield\Response\Response $response + * + * @return InvoiceType + * @throws \PhpTwinfield\Exception + */ + public static function map(Response $response) + { + // Generate new InvoiceType object + $invoiceType = new InvoiceType(); + + // Gets the raw DOMDocument response. + $responseDOM = $response->getResponseDocument(); + + // Get the root/invoice type element + $invoiceTypeElement = $responseDOM->documentElement; + + // Set the vat group elements from the vat group element + $invoiceType->setCode(self::getField($invoiceType, $invoiceTypeElement, 'code')) + ->setName(self::getField($invoiceType, $invoiceTypeElement, 'name')) + ->setShortName(self::getField($invoiceType, $invoiceTypeElement, 'shortname')); + + // Return the complete object + return $invoiceType; + } +} \ No newline at end of file diff --git a/src/Mappers/OfficeMapper.php b/src/Mappers/OfficeMapper.php index 5e043fb5..c9d40c01 100644 --- a/src/Mappers/OfficeMapper.php +++ b/src/Mappers/OfficeMapper.php @@ -2,8 +2,8 @@ namespace PhpTwinfield\Mappers; -use PhpTwinfield\Response\Response; use PhpTwinfield\Office; +use PhpTwinfield\Response\Response; /** * Maps a response DOMDocument to the corresponding entity. @@ -13,6 +13,39 @@ */ class OfficeMapper extends BaseMapper { + /** + * Maps a Response object to a clean Office entity. + * + * @access public + * + * @param \PhpTwinfield\Response\Response $response + * + * @return Office + * @throws \PhpTwinfield\Exception + */ + public static function map(Response $response) + { + // Generate new Office object + $office = new Office(); + + // Gets the raw DOMDocument response. + $responseDOM = $response->getResponseDocument(); + + // Get the root/office element + $officeElement = $responseDOM->documentElement; + + // Set the result and status attribute + $office->setResult($officeElement->getAttribute('result')) + ->setStatus(self::parseEnumAttribute('Status', $officeElement->getAttribute('status'))); + + // Set the office elements from the office element + $office->setCode(self::getField($office, $officeElement, 'code')) + ->setName(self::getField($office, $officeElement, 'name')); + + // Return the complete object + return $office; + } + /** * Maps multiple offices to an office array. * diff --git a/src/Mappers/PayCodeMapper.php b/src/Mappers/PayCodeMapper.php new file mode 100644 index 00000000..041e2e13 --- /dev/null +++ b/src/Mappers/PayCodeMapper.php @@ -0,0 +1,45 @@ + + */ +class PayCodeMapper extends BaseMapper +{ + /** + * Maps a Response object to a clean PayCode entity. + * + * @access public + * + * @param \PhpTwinfield\Response\Response $response + * + * @return PayCode + * @throws \PhpTwinfield\Exception + */ + public static function map(Response $response) + { + // Generate new PayCode object + $payCode = new PayCode(); + + // Gets the raw DOMDocument response. + $responseDOM = $response->getResponseDocument(); + + // Get the root/vat group element + $payCodeElement = $responseDOM->documentElement; + + // Set the vat group elements from the vat group element + $payCode->setCode(self::getField($payCode, $payCodeElement, 'code')) + ->setName(self::getField($payCode, $payCodeElement, 'name')) + ->setShortName(self::getField($payCode, $payCodeElement, 'shortname')); + + // Return the complete object + return $payCode; + } +} diff --git a/src/Mappers/ProjectMapper.php b/src/Mappers/ProjectMapper.php new file mode 100644 index 00000000..4190152e --- /dev/null +++ b/src/Mappers/ProjectMapper.php @@ -0,0 +1,119 @@ + + */ +class ProjectMapper extends BaseMapper +{ + /** + * Maps a Response object to a clean Project entity. + * + * @access public + * + * @param \PhpTwinfield\Response\Response $response + * + * @return Project + * @throws \PhpTwinfield\Exception + */ + public static function map(Response $response) + { + // Generate new Project object + $project = new Project(); + + // Gets the raw DOMDocument response. + $responseDOM = $response->getResponseDocument(); + + // Get the root/project element + $projectElement = $responseDOM->documentElement; + + // Set the result and status attribute + $project->setResult($projectElement->getAttribute('result')) + ->setStatus(self::parseEnumAttribute('Status', $projectElement->getAttribute('status'))); + + // Set the project elements from the project element + $project->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($project, $projectElement, 'behaviour'))) + ->setCode(self::getField($project, $projectElement, 'code')) + ->setInUse(self::parseBooleanAttribute(self::getField($project, $projectElement, 'name'))) + ->setName(self::getField($project, $projectElement, 'name')) + ->setOffice(self::parseObjectAttribute('Office', $project, $projectElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setShortName(self::getField($project, $projectElement, 'shortname')) + ->setTouched(self::getField($project, $projectElement, 'touched')) + ->setType(self::parseObjectAttribute('DimensionType', $project, $projectElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setUID(self::getField($project, $projectElement, 'uid')) + ->setVatCode(self::parseObjectAttribute('VatCode', $project, $projectElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); + + // Get the projects element + $projectsElement = $responseDOM->getElementsByTagName('projects')->item(0); + + if ($projectsElement !== null) { + // Make a new temporary ProjectProjects class + $projectProjects = new ProjectProjects(); + + // Set the projects elements from the projects element + $projectProjects->setAuthoriser(self::parseObjectAttribute('User', $projectProjects, $projectsElement, 'authoriser')) + ->setBillable(self::parseBooleanAttribute(self::getField($projectProjects, $projectsElement, 'billable'))) + ->setCustomer(self::parseObjectAttribute('Customer', $projectProjects, $projectsElement, 'customer')) + ->setInvoiceDescription(self::getField($projectProjects, $projectsElement, 'invoicedescription')) + ->setRate(self::parseObjectAttribute('Rate', $projectProjects, $projectsElement, 'rate')) + ->setValidFrom(self::parseDateAttribute(self::getField($projectProjects, $projectsElement, 'validfrom'))) + ->setValidTill(self::parseDateAttribute(self::getField($projectProjects, $projectsElement, 'validtill'))); + + // Set the projects elements from the projects element attributes + $projectProjects->setAuthoriserInherit(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'authoriser', 'inherit'))) + ->setAuthoriserLocked(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'authoriser', 'locked'))) + ->setBillableForRatio(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'billable', 'forratio'))) + ->setBillableInherit(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'billable', 'inherit'))) + ->setBillableLocked(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'billable', 'locked'))) + ->setCustomerInherit(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'customer', 'inherit'))) + ->setCustomerLocked(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'customer', 'locked'))) + ->setRateInherit(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'rate', 'inherit'))) + ->setRateLocked(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'rate', 'locked'))); + + // Get the quantities element + $quantitiesDOMTag = $projectsElement->getElementsByTagName('quantities'); + + if (isset($quantitiesDOMTag) && $quantitiesDOMTag->length > 0) { + // Loop through each returned quantity for the project + foreach ($quantitiesDOMTag->item(0)->childNodes as $quantityElement) { + if ($quantityElement->nodeType !== 1) { + continue; + } + + // Make a new temporary ProjectQuantity class + $projectQuantity = new ProjectQuantity(); + + // Set the quantity elements from the quantity element + $projectQuantity->setBillable(self::parseBooleanAttribute(self::getField($projectQuantity, $quantityElement, 'billable'))) + ->setLabel(self::getField($projectQuantity, $quantityElement, 'label')) + ->setMandatory(self::parseBooleanAttribute(self::getField($projectQuantity, $quantityElement, 'mandatory'))) + ->setRate(self::parseObjectAttribute('Rate', $projectQuantity, $quantityElement, 'rate')); + + // Set the quantity elements from the quantity element attributes + $projectQuantity->setBillableLocked(self::parseBooleanAttribute(self::getAttribute($quantityElement, 'billable', 'locked'))); + + // Add the quantity to the project + $projectProjects->addQuantity($projectQuantity); + + // Clean that memory! + unset ($projectQuantity); + } + } + + // Set the custom class to the project + $project->setProjects($projectProjects); + } + + // Return the complete object + return $project; + } +} diff --git a/src/Mappers/RateMapper.php b/src/Mappers/RateMapper.php new file mode 100644 index 00000000..8fe3fe1d --- /dev/null +++ b/src/Mappers/RateMapper.php @@ -0,0 +1,85 @@ + + */ +class RateMapper extends BaseMapper +{ + /** + * Maps a Response object to a clean Rate entity. + * + * @access public + * + * @param \PhpTwinfield\Response\Response $response + * + * @return Rate + * @throws \PhpTwinfield\Exception + */ + public static function map(Response $response) + { + // Generate new Rate object + $rate = new Rate(); + + // Gets the raw DOMDocument response. + $responseDOM = $response->getResponseDocument(); + + // Get the root/rate element + $rateElement = $responseDOM->documentElement; + + // Set the result and status attribute + $rate->setResult($rateElement->getAttribute('result')) + ->setStatus(self::parseEnumAttribute('Status', $rateElement->getAttribute('status'))); + + // Set the rate elements from the rate element + $rate->setCode(self::getField($rate, $rateElement, 'code')) + ->setCurrency(self::parseObjectAttribute('Currency', $rate, $rateElement, 'currency', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setName(self::getField($rate, $rateElement, 'name')) + ->setOffice(self::parseObjectAttribute('Office', $rate, $rateElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setShortName(self::getField($rate, $rateElement, 'shortname')) + ->setType(self::parseEnumAttribute('RateType', self::getField($rate, $rateElement, 'type'))) + ->setUnit(self::getField($rate, $rateElement, 'unit')) + ->setUser(self::parseObjectAttribute('User', $rate, $rateElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); + + // Get the ratechanges element + $ratechangesDOMTag = $responseDOM->getElementsByTagName('ratechanges'); + + if (isset($ratechangesDOMTag) && $ratechangesDOMTag->length > 0) { + // Loop through each returned ratechange for the rate + foreach ($ratechangesDOMTag->item(0)->childNodes as $ratechangeElement) { + if ($ratechangeElement->nodeType !== 1) { + continue; + } + + // Make a new temporary RateRateChange class + $rateRateChange = new RateRateChange(); + + $rateRateChange->setID($ratechangeElement->getAttribute('id')) + ->setStatus(self::parseEnumAttribute('Status', $rateElement->getAttribute('status'))); + + // Set the project rate rate change elements from the ratechange element + $rateRateChange->setBeginDate(self::parseDateAttribute(self::getField($rateRateChange, $ratechangeElement, 'begindate'))) + ->setEndDate(self::parseDateAttribute(self::getField($rateRateChange, $ratechangeElement, 'enddate'))) + ->setExternalRate(self::getField($rateRateChange, $ratechangeElement, 'externalrate')) + ->setInternalRate(self::getField($rateRateChange, $ratechangeElement, 'internalrate')); + + // Add the rate change to the project rate + $rate->addRateChange($rateRateChange); + + // Clean that memory! + unset ($rateRateChange); + } + } + + // Return the complete object + return $rate; + } +} diff --git a/src/Mappers/SupplierMapper.php b/src/Mappers/SupplierMapper.php index 0078321b..8d67eb46 100644 --- a/src/Mappers/SupplierMapper.php +++ b/src/Mappers/SupplierMapper.php @@ -5,195 +5,290 @@ use PhpTwinfield\Supplier; use PhpTwinfield\SupplierAddress; use PhpTwinfield\SupplierBank; +use PhpTwinfield\SupplierChildValidation; +use PhpTwinfield\SupplierFinancials; +use PhpTwinfield\SupplierLine; +use PhpTwinfield\SupplierPostingRule; /** * Maps a response DOMDocument to the corresponding entity. - * + * * @package PhpTwinfield * @subpackage Mapper - * @author Leon Rowland + * @author Leon Rowland , extended by Yannick Aerssens * @copyright (c) 2013, Pronamic */ class SupplierMapper extends BaseMapper { /** * Maps a Response object to a clean Supplier entity. - * + * * @access public * @param \PhpTwinfield\Response\Response $response * @return Supplier + * @throws \PhpTwinfield\Exception */ public static function map(Response $response) { - // Generate new customer object + // Generate new Supplier object $supplier = new Supplier(); - + // Gets the raw DOMDocument response. $responseDOM = $response->getResponseDocument(); - // Set the status attribute - $dimensionElement = $responseDOM->getElementsByTagName('dimension')->item(0); - $supplier->setStatus($dimensionElement->getAttribute('status')); - - // Supplier elements and their methods - $supplierTags = array( - 'code' => 'setCode', - 'uid' => 'setUID', - 'name' => 'setName', - 'inuse' => 'setInUse', - 'behaviour' => 'setBehaviour', - 'touched' => 'setTouched', - 'beginperiod' => 'setBeginPeriod', - 'endperiod' => 'setEndPeriod', - 'endyear' => 'setEndYear', - 'website' => 'setWebsite', - 'editdimensionname' => 'setEditDimensionName', - 'office' => 'setOffice', - ); - - // Loop through all the tags - foreach ($supplierTags as $tag => $method) { - self::setFromTagValue($responseDOM, $tag, [$supplier, $method]); - } - - // Financial elements and their methods - $financialsTags = array( - 'duedays' => 'setDueDays', - 'payavailable' => 'setPayAvailable', - 'paycode' => 'setPayCode', - 'ebilling' => 'setEBilling', - 'ebillmail' => 'setEBillMail' - ); - - // Financial elements - $financialElement = $responseDOM->getElementsByTagName('financials')->item(0); - - if ($financialElement) { - // Go through each financial element and add to the assigned method - foreach ($financialsTags as $tag => $method) { - - // Get the dom element - $_tag = $financialElement->getElementsByTagName($tag)->item(0); - - // If it has a value, set it to the associated method - if (isset($_tag) && isset($_tag->textContent)) { - $value = $_tag->textContent; - if ($value == 'true' || $value == 'false') { - $value = $value == 'true'; + // Get the root/supplier element + $supplierElement = $responseDOM->documentElement; + + // Set the result and status attribute + $supplier->setResult($supplierElement->getAttribute('result')) + ->setStatus(self::parseEnumAttribute('Status', $supplierElement->getAttribute('status'))); + + // Set the supplier elements from the supplier element + $supplier->setBeginPeriod(self::getField($supplier, $supplierElement, 'beginperiod')) + ->setBeginYear(self::getField($supplier, $supplierElement, 'beginyear')) + ->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($supplier, $supplierElement, 'behaviour'))) + ->setCode(self::getField($supplier, $supplierElement, 'code')) + ->setEndPeriod(self::getField($supplier, $supplierElement, 'endperiod')) + ->setEndYear(self::getField($supplier, $supplierElement, 'endyear')) + ->setGroup(self::parseObjectAttribute('DimensionGroup', $supplier, $supplierElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setInUse(self::parseBooleanAttribute(self::getField($supplier, $supplierElement, 'name'))) + ->setName(self::getField($supplier, $supplierElement, 'name')) + ->setOffice(self::parseObjectAttribute('Office', $supplier, $supplierElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setTouched(self::getField($supplier, $supplierElement, 'touched')) + ->setType(self::parseObjectAttribute('DimensionType', $supplier, $supplierElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setUID(self::getField($supplier, $supplierElement, 'uid')) + ->setWebsite(self::getField($supplier, $supplierElement, 'website')); + + // Get the financials element + $financialsElement = $responseDOM->getElementsByTagName('financials')->item(0); + + if ($financialsElement !== null) { + // Make a new temporary SupplierFinancials class + $supplierFinancials = new SupplierFinancials(); + + // Set the financials elements from the financials element + $supplierFinancials->setAccountType(self::parseEnumAttribute('AccountType', self::getField($supplierFinancials, $financialsElement, 'accounttype'))) + ->setDueDays(self::getField($supplierFinancials, $financialsElement, 'duedays')) + ->setLevel(self::getField($supplierFinancials, $financialsElement, 'level')) + ->setMatchType(self::parseEnumAttribute('MatchType', self::getField($supplierFinancials, $financialsElement, 'matchtype'))) + ->setMeansOfPayment(self::parseEnumAttribute('MeansOfPayment', self::getField($supplierFinancials, $financialsElement, 'meansofpayment'))) + ->setPayAvailable(self::parseBooleanAttribute(self::getField($supplierFinancials, $financialsElement, 'payavailable'))) + ->setPayCode(self::parseObjectAttribute('PayCode', $supplierFinancials, $financialsElement, 'paycode', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setRelationsReference(self::getField($supplierFinancials, $financialsElement, 'relationsreference')) + ->setSubAnalyse(self::parseEnumAttribute('SubAnalyse', self::getField($supplierFinancials, $financialsElement, 'subanalyse'))) + ->setSubstitutionLevel(self::getField($supplierFinancials, $financialsElement, 'substitutionlevel')) + ->setSubstituteWith(self::parseObjectAttribute('UnknownDimension', $supplierFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setVatCode(self::parseObjectAttribute('VatCode', $supplierFinancials, $financialsElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); + + // Set the financials elements from the financials element attributes + $supplierFinancials->setPayCodeID(self::getAttribute($financialsElement, 'paycode', 'id')) + ->setSubstituteWithID(self::getAttribute($financialsElement, 'substitutewith', 'id')) + ->setVatCodeFixed(self::parseBooleanAttribute(self::getAttribute($financialsElement, 'vatcode', 'fixed'))); + + // Get the childvalidations element + $childValidationsDOMTag = $financialsElement->getElementsByTagName('childvalidations'); + + if (isset($childValidationsDOMTag) && $childValidationsDOMTag->length > 0) { + // Loop through each returned childValidation for the supplier + foreach ($childValidationsDOMTag->item(0)->childNodes as $childValidationElement) { + if ($childValidationElement->nodeType !== 1) { + continue; } - $supplier->$method($value); + // Make a new temporary SupplierChildValidation class + $supplierChildValidation = new SupplierChildValidation(); + + // Set the child validation elements from the child validation element en element attributes + $supplierChildValidation->setLevel($childValidationElement->getAttribute('level')) + ->setType(self::parseEnumAttribute('GeneralLedgerType', $childValidationElement->getAttribute('type'))) + ->setElementValue($childValidationElement->textContent); + + // Add the child validation to the supplier financials class + $supplierFinancials->addChildValidation($supplierChildValidation); + + // Clean that memory! + unset ($supplierChildValidation); } } + + // Set the custom class to the supplier + $supplier->setFinancials($supplierFinancials); } + // Get the remittanceadvice element + $remittanceAdviceElement = $responseDOM->getElementsByTagName('remittanceadvice')->item(0); + + if ($remittanceAdviceElement !== null) { + // Set the supplier elements from the remittanceadvice element + $supplier->setRemittanceAdviceSendType(self::parseEnumAttribute('RemittanceAdviceSendType', self::getField($supplier, $remittanceAdviceElement, 'sendtype'))) + ->setRemittanceAdviceSendMail(self::getField($supplier, $remittanceAdviceElement, 'sendmail')); + } + + // Get the addresses element $addressesDOMTag = $responseDOM->getElementsByTagName('addresses'); - if (isset($addressesDOMTag) && $addressesDOMTag->length > 0) { - // Element tags and their methods for address - $addressTags = array( - 'name' => 'setName', - 'contact' => 'setContact', - 'country' => 'setCountry', - 'city' => 'setCity', - 'postcode' => 'setPostcode', - 'telephone' => 'setTelephone', - 'telefax' => 'setFax', - 'email' => 'setEmail', - 'field1' => 'setField1', - 'field2' => 'setField2', - 'field3' => 'setField3', - 'field4' => 'setField4', - 'field5' => 'setField5', - 'field6' => 'setField6', - ); - - $addressesDOM = $addressesDOMTag->item(0); - - // Loop through each returned address for the customer - foreach ($addressesDOM->getElementsByTagName('address') as $addressDOM) { - - // Make a new tempory SupplierAddress class - $temp_address = new SupplierAddress(); - - // Set the attributes ( id, type, default ) - $temp_address - ->setID($addressDOM->getAttribute('id')) - ->setType($addressDOM->getAttribute('type')) - ->setDefault($addressDOM->getAttribute('default')); - - // Loop through the element tags. Determine if it exists and set it if it does - foreach ($addressTags as $tag => $method) { - - // Get the dom element - $_tag = $addressDOM->getElementsByTagName($tag)->item(0); - - // Check if the tag is set, and its content is set, to prevent DOMNode errors - if (isset($_tag) && isset($_tag->textContent)) { - $temp_address->$method($_tag->textContent); - } + if (isset($addressesDOMTag) && $addressesDOMTag->length > 0) { + // Loop through each returned address for the supplier + foreach ($addressesDOMTag->item(0)->childNodes as $addressElement) { + if ($addressElement->nodeType !== 1) { + continue; } - // Add the address to the customer - $supplier->addAddress($temp_address); + // Make a new temporary SupplierAddress class + $supplierAddress = new SupplierAddress(); + + // Set the default, id and type attribute + $supplierAddress->setDefault(self::parseBooleanAttribute($addressElement->getAttribute('default'))) + ->setID($addressElement->getAttribute('id')) + ->setType(self::parseEnumAttribute('AddressType', $addressElement->getAttribute('type'))); + + // Set the address elements from the address element + $supplierAddress->setCity(self::getField($supplierAddress, $addressElement, 'city')) + ->setCountry(self::parseObjectAttribute('Country', $supplierAddress, $addressElement, 'country', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setEmail(self::getField($supplierAddress, $addressElement, 'email')) + ->setField1(self::getField($supplierAddress, $addressElement, 'field1')) + ->setField2(self::getField($supplierAddress, $addressElement, 'field2')) + ->setField3(self::getField($supplierAddress, $addressElement, 'field3')) + ->setField4(self::getField($supplierAddress, $addressElement, 'field4')) + ->setField5(self::getField($supplierAddress, $addressElement, 'field5')) + ->setField6(self::getField($supplierAddress, $addressElement, 'field6')) + ->setName(self::getField($supplierAddress, $addressElement, 'name')) + ->setPostcode(self::getField($supplierAddress, $addressElement, 'postcode')) + ->setTelephone(self::getField($supplierAddress, $addressElement, 'telephone')) + ->setTelefax(self::getField($supplierAddress, $addressElement, 'telefax')); + + // Add the address to the supplier + $supplier->addAddress($supplierAddress); // Clean that memory! - unset($temp_address); + unset ($supplierAddress); } } + // Get the banks element $banksDOMTag = $responseDOM->getElementsByTagName('banks'); + if (isset($banksDOMTag) && $banksDOMTag->length > 0) { + // Loop through each returned bank for the supplier + foreach ($banksDOMTag->item(0)->childNodes as $bankElement) { + if ($bankElement->nodeType !== 1) { + continue; + } - // Element tags and their methods for bank - $bankTags = array( - 'ascription' => 'setAscription', - 'accountnumber' => 'setAccountnumber', - 'field2' => 'setAddressField2', - 'field3' => 'setAddressField3', - 'bankname' => 'setBankname', - 'biccode' => 'setBiccode', - 'city' => 'setCity', - 'country' => 'setCountry', - 'iban' => 'setIban', - 'natbiccode' => 'setNatbiccode', - 'postcode' => 'setPostcode', - 'state' => 'setState' - ); - - $banksDOM = $banksDOMTag->item(0); - - // Loop through each returned bank for the customer - foreach ($banksDOM->getElementsByTagName('bank') as $bankDOM) { - - // Make a new tempory SupplierBank class - $temp_bank = new SupplierBank(); - - // Set the attributes ( id, default ) - $temp_bank - ->setID($bankDOM->getAttribute('id')) - ->setDefault($bankDOM->getAttribute('default')); - - // Loop through the element tags. Determine if it exists and set it if it does - foreach ($bankTags as $tag => $method) { - - // Get the dom element - $_tag = $bankDOM->getElementsByTagName($tag)->item(0); - - // Check if the tag is set, and its content is set, to prevent DOMNode errors - if (isset($_tag) && isset($_tag->textContent)) { - $temp_bank->$method($_tag->textContent); + // Make a new temporary SupplierBank class + $supplierBank = new SupplierBank(); + + // Set the default and id attribute + $supplierBank->setBlocked(self::parseBooleanAttribute($bankElement->getAttribute('blocked'))) + ->setDefault(self::parseBooleanAttribute($bankElement->getAttribute('default'))) + ->setID($bankElement->getAttribute('id')); + + // Set the bank elements from the bank element + $supplierBank->setAscription(self::getField($supplierBank, $bankElement, 'ascription')) + ->setAccountNumber(self::getField($supplierBank, $bankElement, 'accountnumber')) + ->setBankName(self::getField($supplierBank, $bankElement, 'bankname')) + ->setBicCode(self::getField($supplierBank, $bankElement, 'biccode')) + ->setCity(self::getField($supplierBank, $bankElement, 'city')) + ->setCountry(self::parseObjectAttribute('Country', $supplierBank, $bankElement, 'country', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setField2(self::getField($supplierBank, $bankElement, 'field2')) + ->setField3(self::getField($supplierBank, $bankElement, 'field3')) + ->setIban(self::getField($supplierBank, $bankElement, 'iban')) + ->setNatBicCode(self::getField($supplierBank, $bankElement, 'natbiccode')) + ->setPostcode(self::getField($supplierBank, $bankElement, 'postcode')) + ->setState(self::getField($supplierBank, $bankElement, 'state')); + + // Add the bank to the supplier + $supplier->addBank($supplierBank); + + // Clean that memory! + unset ($supplierBank); + } + } + + // Get the postingrules element + $postingrulesDOMTag = $responseDOM->getElementsByTagName('postingrules'); + + if (isset($postingrulesDOMTag) && $postingrulesDOMTag->length > 0) { + // Loop through each returned postingrule for the supplier + foreach ($postingrulesDOMTag->item(0)->childNodes as $postingruleElement) { + if ($postingruleElement->nodeType !== 1) { + continue; + } + + // Make a new temporary SupplierPostingRule class + $supplierPostingRule = new SupplierPostingRule(); + + // Set the id and status attribute + $supplierPostingRule->setID($postingruleElement->getAttribute('id')) + ->setStatus(self::parseEnumAttribute('Status', $postingruleElement->getAttribute('status'))); + + // Set the postingrule elements from the postingrule element + $supplierPostingRule->setAmount(self::parseMoneyAttribute(self::getField($supplierPostingRule, $postingruleElement, 'amount'))) + ->setCurrency(self::parseObjectAttribute('Currency', $supplierPostingRule, $postingruleElement, 'currency', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setDescription(self::getField($supplierPostingRule, $postingruleElement, 'description')); + + // Get the lines element + $linesDOMTag = $postingruleElement->getElementsByTagName('lines'); + + if (isset($linesDOMTag) && $linesDOMTag->length > 0) { + // Loop through each returned line for the posting rule + foreach ($linesDOMTag->item(0)->childNodes as $lineElement) { + if ($lineElement->nodeType !== 1) { + continue; + } + + // Make a new temporary SupplierLine class + $supplierLine = new SupplierLine(); + + // Set the line elements from the line element + $supplierLine->setDescription(self::getField($supplierLine, $lineElement, 'description')) + ->setDimension1(self::parseObjectAttribute('GeneralLedger', $supplierLine, $lineElement, 'dimension1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setDimension2(self::parseObjectAttribute('CostCenter', $supplierLine, $lineElement, 'dimension2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setDimension3(self::parseObjectAttribute('UnknownDimension', $supplierLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setOffice(self::parseObjectAttribute('Office', $supplierLine, $lineElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setRatio(self::getField($supplierLine, $lineElement, 'ratio')) + ->setVatCode(self::parseObjectAttribute('VatCode', $supplierLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); + + // Set the line elements from the line element attributes + $supplierLine->setDimension1ID(self::getAttribute($lineElement, 'dimension1', 'id')) + ->setDimension2ID(self::getAttribute($lineElement, 'dimension2', 'id')) + ->setDimension3ID(self::getAttribute($lineElement, 'dimension2', 'id')); + + // Add the line to the supplier posting rule + $supplierPostingRule->addLine($supplierLine); + + // Clean that memory! + unset ($supplierLine); } } - // Add the bank to the customer - $supplier->addBank($temp_bank); + // Add the postingrule to the supplier + $supplier->addPostingRule($supplierPostingRule); // Clean that memory! - unset($temp_bank); + unset ($supplierPostingRule); } } + // Get the paymentconditions element + $paymentConditionsElement = $responseDOM->getElementsByTagName('paymentconditions')->item(0); + + if ($paymentConditionsElement !== null) { + // Set the supplier elements from the paymentconditions element + $supplier->setPaymentConditionDiscountDays(self::getField($supplier, $paymentConditionsElement, 'discountdays')) + ->setPaymentConditionDiscountPercentage(self::getField($supplier, $paymentConditionsElement, 'discountpercentage')); + } + + // Get the blockedaccountpaymentconditions element + $blockedAccountPaymentConditionsElement = $responseDOM->getElementsByTagName('blockedaccountpaymentconditions')->item(0); + + if ($blockedAccountPaymentConditionsElement !== null) { + // Set the supplier elements from the blockedaccountpaymentconditions element + $supplier->setBlockedAccountPaymentConditionsIncludeVat(self::parseEnumAttribute('BlockedAccountPaymentConditionsIncludeVat', self::getField($supplier, $blockedAccountPaymentConditionsElement, 'includevat'))) + ->setBlockedAccountPaymentConditionsPercentage(self::getField($supplier, $blockedAccountPaymentConditionsElement, 'percentage')); + } + + // Return the complete object return $supplier; } -} +} \ No newline at end of file diff --git a/src/Mappers/UserMapper.php b/src/Mappers/UserMapper.php new file mode 100644 index 00000000..ee9f316e --- /dev/null +++ b/src/Mappers/UserMapper.php @@ -0,0 +1,56 @@ + + */ +class UserMapper extends BaseMapper +{ + /** + * Maps a Response object to a clean User entity. + * + * @access public + * + * @param \PhpTwinfield\Response\Response $response + * + * @return User + * @throws \PhpTwinfield\Exception + */ + public static function map(Response $response) + { + // Generate new User object + $user = new User(); + + // Gets the raw DOMDocument response. + $responseDOM = $response->getResponseDocument(); + + // Get the root/user element + $userElement = $responseDOM->documentElement; + + // Set the iscurrentuser, level, result and status attribute + $user->setIsCurrentUser(self::parseBooleanAttribute($userElement->getAttribute('iscurrentuser'))); + $user->setLevel($userElement->getAttribute('level')); + $user->setResult($userElement->getAttribute('result')); + $user->setStatus(self::parseEnumAttribute('Status', $userElement->getAttribute('status'))); + + // Set the user elements from the user element + $user->setCode(self::getField($user, $userElement, 'code')) + ->setCreated(self::parseDateTimeAttribute(self::getField($user, $userElement, 'created'))) + ->setModified(self::parseDateTimeAttribute(self::getField($user, $userElement, 'modified'))) + ->setName(self::getField($user, $userElement, 'name')) + ->setShortName(self::getField($user, $userElement, 'shortname')) + ->setTouched(self::getField($user, $userElement, 'touched')); + + // Return the complete object + return $user; + } +} diff --git a/src/Mappers/UserRoleMapper.php b/src/Mappers/UserRoleMapper.php new file mode 100644 index 00000000..89e548fb --- /dev/null +++ b/src/Mappers/UserRoleMapper.php @@ -0,0 +1,45 @@ + + */ +class UserRoleMapper extends BaseMapper +{ + /** + * Maps a Response object to a clean UserRole entity. + * + * @access public + * + * @param \PhpTwinfield\Response\Response $response + * + * @return UserRole + * @throws \PhpTwinfield\Exception + */ + public static function map(Response $response) + { + // Generate new UserRole object + $userRole = new UserRole(); + + // Gets the raw DOMDocument response. + $responseDOM = $response->getResponseDocument(); + + // Get the root/user role element + $userRoleElement = $responseDOM->documentElement; + + // Set the user role elements from the user role element + $userRole->setCode(self::getField($userRole, $userRoleElement, 'code')) + ->setName(self::getField($userRole, $userRoleElement, 'name')) + ->setShortName(self::getField($userRole, $userRoleElement, 'shortname')); + + // Return the complete object + return $userRole; + } +} diff --git a/src/Mappers/VatCodeMapper.php b/src/Mappers/VatCodeMapper.php new file mode 100644 index 00000000..d852a64d --- /dev/null +++ b/src/Mappers/VatCodeMapper.php @@ -0,0 +1,117 @@ + + */ +class VatCodeMapper extends BaseMapper +{ + /** + * Maps a Response object to a clean VatCode entity. + * + * @access public + * + * @param \PhpTwinfield\Response\Response $response + * + * @return VatCode + * @throws \PhpTwinfield\Exception + */ + public static function map(Response $response) + { + // Generate new VatCode object + $vatCode = new VatCode(); + + // Gets the raw DOMDocument response. + $responseDOM = $response->getResponseDocument(); + + // Get the root/vat element + $vatCodeElement = $responseDOM->documentElement; + + // Set the result and status attribute + $vatCode->setResult($vatCodeElement->getAttribute('result')) + ->setStatus(self::parseEnumAttribute('Status', $vatCodeElement->getAttribute('status'))); + + // Set the vat code elements from the vat element + $vatCode->setCode(self::getField($vatCode, $vatCodeElement, 'code')) + ->setCreated(self::parseDateTimeAttribute(self::getField($vatCode, $vatCodeElement, 'created'))) + ->setModified(self::parseDateTimeAttribute(self::getField($vatCode, $vatCodeElement, 'modified'))) + ->setName(self::getField($vatCode, $vatCodeElement, 'name')) + ->setShortName(self::getField($vatCode, $vatCodeElement, 'shortname')) + ->setTouched(self::getField($vatCode, $vatCodeElement, 'touched')) + ->setType(self::parseEnumAttribute('VatType', self::getField($vatCode, $vatCodeElement, 'type'))) + ->setUID(self::getField($vatCode, $vatCodeElement, 'uid')) + ->setUser(self::parseObjectAttribute('User', $vatCode, $vatCodeElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); + + // Get the percentages element + $percentagesDOMTag = $responseDOM->getElementsByTagName('percentages'); + + if (isset($percentagesDOMTag) && $percentagesDOMTag->length > 0) { + // Loop through each returned percentage for the vatcode + foreach ($percentagesDOMTag->item(0)->childNodes as $percentageElement) { + if ($percentageElement->nodeType !== 1) { + continue; + } + + // Make a new temporary VatCodePercentage class + $vatCodePercentage = new VatCodePercentage(); + + // Set the vat code percentage elements from the percentage element + $vatCodePercentage->setCreated(self::parseDateTimeAttribute(self::getField($vatCodePercentage, $percentageElement, 'created'))) + ->setDate(self::parseDateAttribute(self::getField($vatCodePercentage, $percentageElement, 'date'))) + ->setName(self::getField($vatCodePercentage, $percentageElement, 'name')) + ->setPercentage(self::getField($vatCodePercentage, $percentageElement, 'percentage')) + ->setShortName(self::getField($vatCodePercentage, $percentageElement, 'shortname')) + ->setUser(self::parseObjectAttribute('User', $vatCodePercentage, $percentageElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); + + // Get the accounts element + $accountsDOMTag = $percentageElement->getElementsByTagName('accounts'); + + if (isset($accountsDOMTag) && $accountsDOMTag->length > 0) { + // Loop through each returned account for the percentage + foreach ($accountsDOMTag->item(0)->childNodes as $accountElement) { + if ($accountElement->nodeType !== 1) { + continue; + } + + // Make a new temporary VatCodeAccount class + $vatCodeAccount = new VatCodeAccount(); + + // Set the ID attribute + $vatCodeAccount->setID($accountElement->getAttribute('id')); + + // Set the vat code percentage account elements from the account element + $vatCodeAccount->setDim1(self::parseObjectAttribute('GeneralLedger', $vatCodeAccount, $accountElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setGroup(self::parseObjectAttribute('VatGroup', $vatCodeAccount, $accountElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setGroupCountry(self::parseObjectAttribute('Country', $vatCodeAccount, $accountElement, 'groupcountry', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setLineType(self::parseEnumAttribute('LineType', self::getField($vatCodeAccount, $accountElement, 'linetype'))) + ->setPercentage(self::getField($vatCodeAccount, $accountElement, 'percentage')); + + // Add the account to the percentage + $vatCodePercentage->addAccount($vatCodeAccount); + + // Clean that memory! + unset ($vatCodeAccount); + } + } + + // Add the percentage to the vat code + $vatCode->addPercentage($vatCodePercentage); + + // Clean that memory! + unset ($vatCodePercentage); + } + } + + // Return the complete object + return $vatCode; + } +} \ No newline at end of file diff --git a/src/Mappers/VatGroupMapper.php b/src/Mappers/VatGroupMapper.php new file mode 100644 index 00000000..aaf17c87 --- /dev/null +++ b/src/Mappers/VatGroupMapper.php @@ -0,0 +1,45 @@ + + */ +class VatGroupMapper extends BaseMapper +{ + /** + * Maps a Response object to a clean VatGroup entity. + * + * @access public + * + * @param \PhpTwinfield\Response\Response $response + * + * @return VatGroup + * @throws \PhpTwinfield\Exception + */ + public static function map(Response $response) + { + // Generate new VatGroup object + $vatGroup = new VatGroup(); + + // Gets the raw DOMDocument response. + $responseDOM = $response->getResponseDocument(); + + // Get the root/vat group element + $vatGroupElement = $responseDOM->documentElement; + + // Set the vat group elements from the vat group element + $vatGroup->setCode(self::getField($vatGroup, $vatGroupElement, 'code')) + ->setName(self::getField($vatGroup, $vatGroupElement, 'name')) + ->setShortName(self::getField($vatGroup, $vatGroupElement, 'shortname')); + + // Return the complete object + return $vatGroup; + } +} \ No newline at end of file From 5e9567b4658027f64258a31e1c4ef0c274d70fb0 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:23:22 +0200 Subject: [PATCH 050/388] Add files via upload --- src/Enums/AccountType.php | 17 +++++++++++++++ src/Enums/AddressType.php | 17 +++++++++++++++ src/Enums/ArticleType.php | 17 +++++++++++++++ src/Enums/Behaviour.php | 17 +++++++++++++++ ...ckedAccountPaymentConditionsIncludeVat.php | 17 +++++++++++++++ src/Enums/BrowseColumnOperator.php | 8 +++---- src/Enums/CalcMethod.php | 19 +++++++++++++++++ src/Enums/CollectionSchema.php | 15 +++++++++++++ src/Enums/DebitCredit.php | 6 +++--- src/Enums/DepreciateReconciliation.php | 15 +++++++++++++ src/Enums/Destiny.php | 4 ++-- src/Enums/FixedAssetsStatus.php | 19 +++++++++++++++++ src/Enums/FreeTextType.php | 15 +++++++++++++ src/Enums/GeneralLedgerType.php | 17 +++++++++++++++ src/Enums/InvoiceDebitCredit.php | 15 +++++++++++++ src/Enums/InvoiceStatus.php | 17 +++++++++++++++ src/Enums/LineType.php | 8 +++---- src/Enums/MatchCode.php | 12 +++++------ src/Enums/MatchType.php | 17 +++++++++++++++ src/Enums/MeansOfPayment.php | 17 +++++++++++++++ src/Enums/Order.php | 4 ++-- src/Enums/PaymentMethod.php | 21 +++++++++++++++++++ src/Enums/PerformanceType.php | 8 ++++--- src/Enums/RateType.php | 15 +++++++++++++ src/Enums/RemittanceAdviceSendType.php | 15 +++++++++++++ src/Enums/SendReminder.php | 17 +++++++++++++++ src/Enums/Status.php | 17 +++++++++++++++ src/Enums/SubAnalyse.php | 17 +++++++++++++++ src/Enums/VatType.php | 17 +++++++++++++++ src/Enums/WriteOffType.php | 8 +++---- 30 files changed, 400 insertions(+), 28 deletions(-) create mode 100644 src/Enums/AccountType.php create mode 100644 src/Enums/AddressType.php create mode 100644 src/Enums/ArticleType.php create mode 100644 src/Enums/Behaviour.php create mode 100644 src/Enums/BlockedAccountPaymentConditionsIncludeVat.php create mode 100644 src/Enums/CalcMethod.php create mode 100644 src/Enums/CollectionSchema.php create mode 100644 src/Enums/DepreciateReconciliation.php create mode 100644 src/Enums/FixedAssetsStatus.php create mode 100644 src/Enums/FreeTextType.php create mode 100644 src/Enums/GeneralLedgerType.php create mode 100644 src/Enums/InvoiceDebitCredit.php create mode 100644 src/Enums/InvoiceStatus.php create mode 100644 src/Enums/MatchType.php create mode 100644 src/Enums/MeansOfPayment.php create mode 100644 src/Enums/PaymentMethod.php create mode 100644 src/Enums/RateType.php create mode 100644 src/Enums/RemittanceAdviceSendType.php create mode 100644 src/Enums/SendReminder.php create mode 100644 src/Enums/Status.php create mode 100644 src/Enums/SubAnalyse.php create mode 100644 src/Enums/VatType.php diff --git a/src/Enums/AccountType.php b/src/Enums/AccountType.php new file mode 100644 index 00000000..3b0dd081 --- /dev/null +++ b/src/Enums/AccountType.php @@ -0,0 +1,17 @@ + Date: Thu, 9 May 2019 17:24:02 +0200 Subject: [PATCH 051/388] Add files via upload --- src/DomDocuments/ActivitiesDocument.php | 107 +++++ src/DomDocuments/ArticlesDocument.php | 138 ++---- src/DomDocuments/AssetMethodsDocument.php | 84 ++++ src/DomDocuments/BaseDocument.php | 17 +- src/DomDocuments/CostCentersDocument.php | 50 +++ src/DomDocuments/CurrenciesDocument.php | 74 ++++ src/DomDocuments/CustomersDocument.php | 434 +++++++++---------- src/DomDocuments/DimensionGroupsDocument.php | 68 +++ src/DomDocuments/DimensionTypesDocument.php | 65 +++ src/DomDocuments/FixedAssetsDocument.php | 114 +++++ src/DomDocuments/GeneralLedgersDocument.php | 87 ++++ src/DomDocuments/InvoicesDocument.php | 188 ++++---- src/DomDocuments/ProjectsDocument.php | 107 +++++ src/DomDocuments/RatesDocument.php | 85 ++++ src/DomDocuments/SuppliersDocument.php | 350 ++++++++------- src/DomDocuments/VatCodesDocument.php | 96 ++++ 16 files changed, 1480 insertions(+), 584 deletions(-) create mode 100644 src/DomDocuments/ActivitiesDocument.php create mode 100644 src/DomDocuments/AssetMethodsDocument.php create mode 100644 src/DomDocuments/CostCentersDocument.php create mode 100644 src/DomDocuments/CurrenciesDocument.php create mode 100644 src/DomDocuments/DimensionGroupsDocument.php create mode 100644 src/DomDocuments/DimensionTypesDocument.php create mode 100644 src/DomDocuments/FixedAssetsDocument.php create mode 100644 src/DomDocuments/GeneralLedgersDocument.php create mode 100644 src/DomDocuments/ProjectsDocument.php create mode 100644 src/DomDocuments/RatesDocument.php create mode 100644 src/DomDocuments/VatCodesDocument.php diff --git a/src/DomDocuments/ActivitiesDocument.php b/src/DomDocuments/ActivitiesDocument.php new file mode 100644 index 00000000..65723afb --- /dev/null +++ b/src/DomDocuments/ActivitiesDocument.php @@ -0,0 +1,107 @@ + + */ +class ActivitiesDocument extends BaseDocument +{ + final protected function getRootTagName(): string + { + return "dimensions"; + } + + /** + * Turns a passed Activity class into the required markup for interacting + * with Twinfield. + * + * This method doesn't return anything, instead just adds the Activity to + * this DOMDOcument instance for submission usage. + * + * @access public + * @param Activity $activity + * @return void | [Adds to this instance] + */ + public function addActivity(Activity $activity) + { + $activityElement = $this->createElement('dimension'); + $this->rootElement->appendChild($activityElement); + + $status = $activity->getStatus(); + + if (!empty($status)) { + $activityElement->setAttribute('status', $status); + } + + $activityElement->appendChild($this->createNodeWithTextContent('code', $activity->getCode())); + $activityElement->appendChild($this->createNodeWithTextContent('name', $activity->getName())); + $activityElement->appendChild($this->createNodeWithTextContent('office', $activity->getOfficeToCode())); + $activityElement->appendChild($this->createNodeWithTextContent('shortname', $activity->getShortName())); + $activityElement->appendChild($this->createNodeWithTextContent('type', $activity->getTypeToCode())); + + $financialsElement = $this->createElement('financials'); + $activityElement->appendChild($financialsElement); + + $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $activity->getVatCodeToCode())); + + $projects = $activity->getProjects(); + + $projectsElement = $this->createElement('projects'); + $activityElement->appendChild($projectsElement); + + $inheritArray = array('authoriser' => 'getAuthoriserToCode', 'billable' => 'getBillableToString', 'customer' => 'getCustomerToCode', 'rate' => 'getRateToCode'); + + foreach ($inheritArray as $inheritVar => $method) { + $methodLocked = "get" . ucfirst($inheritVar) . "Locked"; + $methodInherit = "get" . ucfirst($inheritVar) . "Inherit"; + $elementVar = ""; + + if ($projects->$methodLocked() !== true || $projects->$methodInherit() !== true) { + $elementVar = $projects->$method(); + } elseif ($inheritVar == 'billable') { + $projects->setBillableForRatio(false); + } + + $attributesArray = array('locked' => $methodLocked, 'inherit' => $methodInherit); + + if ($inheritVar == 'billable') { + $attributesArray['forratio'] = 'getBillableForRatioToString'; + } + + $projectsElement->appendChild($this->createNodeWithTextContent($inheritVar, $elementVar, $projects, $attributesArray)); + } + + $projectsElement->appendChild($this->createNodeWithTextContent('invoicedescription', $projects->getInvoiceDescription())); + $projectsElement->appendChild($this->createNodeWithTextContent('validfrom', $projects->getValidFromToString())); + $projectsElement->appendChild($this->createNodeWithTextContent('validtill', $projects->getValidTillToString())); + + $quantities = $projects->getQuantities(); + + if (!empty($quantities)) { + // Make quantities element + $quantitiesElement = $this->createElement('quantities'); + $projectsElement->appendChild($quantitiesElement); + + // Go through each quantity assigned to the activity project + foreach ($quantities as $quantity) { + // Makes quantity element + $quantityElement = $this->createElement('quantity'); + $quantitiesElement->appendChild($quantityElement); + + $quantityElement->appendChild($this->createNodeWithTextContent('label', $quantity->getLabel())); + $quantityElement->appendChild($this->createNodeWithTextContent('rate', $quantity->getRateToCode())); + $quantityElement->appendChild($this->createNodeWithTextContent('billable', $quantity->getBillableToString(), $quantity, array('locked' => 'getBillableLockedToString'))); + $quantityElement->appendChild($this->createNodeWithTextContent('mandatory', $quantity->getMandatoryToString())); + } + } + } +} \ No newline at end of file diff --git a/src/DomDocuments/ArticlesDocument.php b/src/DomDocuments/ArticlesDocument.php index bb184e03..c1a7cd73 100644 --- a/src/DomDocuments/ArticlesDocument.php +++ b/src/DomDocuments/ArticlesDocument.php @@ -8,69 +8,37 @@ * The Document Holder for making new XML Article. Is a child class * of DOMDocument and makes the required DOM tree for the interaction in * creating a new Article. - * + * * @package PhpTwinfield * @subpackage Article\DOM - * @author Willem van de Sande + * @author Willem van de Sande , extended by Yannick Aerssens */ -class ArticlesDocument extends \DOMDocument +class ArticlesDocument extends BaseDocument { - /** - * Holds the
element - * that all additional elements should be a child of - * @var \DOMElement - */ - private $articleElement; - - /** - * Creates the
element and adds it to the property - * articleElement - * - * @access public - */ - public function __construct() + final protected function getRootTagName(): string { - parent::__construct(); - - $this->articleElement = $this->createElement('article'); - $this->appendChild($this->articleElement); + return "articles"; } /** * Turns a passed Article class into the required markup for interacting * with Twinfield. - * - * This method doesn't return anything, instead just adds the Article to + * + * This method doesn't return anything, instead just adds the Article to * this DOMDOcument instance for submission usage. - * + * * @access public * @param Article $article * @return void | [Adds to this instance] */ public function addArticle(Article $article) { - // Article->header elements and their methods - $articleTags = array( - 'office' => 'getOffice', - 'code' => 'getCode', - 'type' => 'getType', - 'name' => 'getName', - 'shortname' => 'getShortName', - 'unitnamesingular' => 'getUnitNameSingular', - 'unitnameplural' => 'getUnitNamePlural', - 'vatcode' => 'getVatCode', - 'allowchangevatcode' => 'getAllowChangeVatCode', - 'allowdiscountorpremium' => 'getAllowDiscountorPremium', - 'allowchangeunitsprice' => 'getAllowChangeUnitsPrice', - 'allowdecimalquantity' => 'getAllowDecimalQuantity', - 'performancetype' => 'getPerformanceType', - //'allowchangeperformancetype' => 'getAllowChangePerformanceType', - 'percentage' => 'getPercentage', - ); + $articleElement = $this->createElement('article'); + $this->rootElement->appendChild($articleElement); // Make header element $headerElement = $this->createElement('header'); - $this->articleElement->appendChild($headerElement); + $articleElement->appendChild($headerElement); $status = $article->getStatus(); @@ -78,75 +46,61 @@ public function addArticle(Article $article) $headerElement->setAttribute('status', $status); } - // Go through each Article element and use the assigned method - foreach ($articleTags as $tag => $method) { - // Make text node for method value - $nodeValue = $article->$method(); - if (is_bool($nodeValue)) { - $nodeValue = ($nodeValue) ? 'true' : 'false'; - } - $node = $this->createTextNode($nodeValue); - - // Make the actual element and assign the node - $element = $this->createElement($tag); - $element->appendChild($node); - - // Add the full element - $headerElement->appendChild($element); + $headerElement->appendChild($this->createNodeWithTextContent('allowchangeperformancetype', $article->getAllowChangePerformanceTypeToString())); + $headerElement->appendChild($this->createNodeWithTextContent('allowchangeunitsprice', $article->getAllowChangeUnitsPriceToString())); + $headerElement->appendChild($this->createNodeWithTextContent('allowchangevatcode', $article->getAllowChangeVatCodeToString())); + $headerElement->appendChild($this->createNodeWithTextContent('allowdecimalquantity', $article->getAllowDecimalQuantityToString())); + $headerElement->appendChild($this->createNodeWithTextContent('allowdiscountorpremium', $article->getAllowDiscountOrPremiumToString())); + $headerElement->appendChild($this->createNodeWithTextContent('code', $article->getCode())); + $headerElement->appendChild($this->createNodeWithTextContent('office', $article->getOfficeToCode())); + $headerElement->appendChild($this->createNodeWithTextContent('name', $article->getName())); + $headerElement->appendChild($this->createNodeWithTextContent('percentage', $article->getPercentageToString())); + $headerElement->appendChild($this->createNodeWithTextContent('performancetype', $article->getPerformanceType())); + $headerElement->appendChild($this->createNodeWithTextContent('shortname', $article->getShortName())); + $headerElement->appendChild($this->createNodeWithTextContent('type', $article->getType())); + $headerElement->appendChild($this->createNodeWithTextContent('unitnameplural', $article->getUnitNamePlural())); + $headerElement->appendChild($this->createNodeWithTextContent('unitnamesingular', $article->getUnitNameSingular())); + $headerElement->appendChild($this->createNodeWithTextContent('vatcode', $article->getVatCodeToCode())); + + //Clear VAT code in case of a discount/premium article with percentage set to true to prevent errors + if ($article->getType() != "normal" && $article->getPercentage() == true) { + $headerElement->getElementsByTagName('vatcode')->item(0)->nodeValue = ""; } $lines = $article->getLines(); if (!empty($lines)) { - // Element tags and their methods for lines - $lineTags = [ - 'unitspriceexcl' => 'getUnitsPriceExcl', - 'unitspriceinc' => 'getUnitsPriceInc', - 'units' => 'getUnits', - 'name' => 'getName', - 'shortname' => 'getShortName', - 'subcode' => 'getSubCode', - 'freetext1' => 'getFreeText1', - ]; - - // Make addresses element + // Make lines element $linesElement = $this->createElement('lines'); - $this->articleElement->appendChild($linesElement); + $articleElement->appendChild($linesElement); // Go through each line assigned to the article foreach ($lines as $line) { - // Makes new articleLine element + // Makes new line element $lineElement = $this->createElement('line'); $linesElement->appendChild($lineElement); - $status = $line->getStatus(); $id = $line->getID(); - $inUse = $line->getInUse(); - - if (!empty($status)) { - $lineElement->setAttribute('status', $status); - } if (!empty($id)) { $lineElement->setAttribute('id', $id); } - if (!empty($inUse)) { - $lineElement->setAttribute('inuse', $inUse); - } - - // Go through each line element and use the assigned method - foreach ($lineTags as $tag => $method) { - // Make the text node for the method value - $node = $this->createTextNode($line->$method()); - - // Make the actual element and assign the text node - $element = $this->createElement($tag); - $element->appendChild($node); + $status = $line->getStatus(); - // Add the completed element - $lineElement->appendChild($element); + if (!empty($status)) { + $lineElement->setAttribute('status', $status); } + + $lineElement->appendChild($this->createNodeWithTextContent('freetext1', $line->getFreeText1ToCode())); + $lineElement->appendChild($this->createNodeWithTextContent('freetext2', $line->getFreeText2ToCode())); + $lineElement->appendChild($this->createNodeWithTextContent('freetext3', $line->getFreeText3())); + $lineElement->appendChild($this->createNodeWithTextContent('name', $line->getName())); + $lineElement->appendChild($this->createNodeWithTextContent('shortname', $line->getShortName())); + $lineElement->appendChild($this->createNodeWithTextContent('subcode', $line->getSubCode())); + $lineElement->appendChild($this->createNodeWithTextContent('units', $line->getUnits())); + $lineElement->appendChild($this->createNodeWithTextContent('unitspriceexcl', $line->getUnitsPriceExclToFloat())); + $lineElement->appendChild($this->createNodeWithTextContent('unitspriceinc', $line->getUnitsPriceIncToFloat())); } } } diff --git a/src/DomDocuments/AssetMethodsDocument.php b/src/DomDocuments/AssetMethodsDocument.php new file mode 100644 index 00000000..6d25378f --- /dev/null +++ b/src/DomDocuments/AssetMethodsDocument.php @@ -0,0 +1,84 @@ + + */ +class AssetMethodsDocument extends BaseDocument +{ + final protected function getRootTagName(): string + { + return "assetmethods"; + } + + /** + * Turns a passed AssetMethod class into the required markup for interacting + * with Twinfield. + * + * This method doesn't return anything, instead just adds the AssetMethod to + * this DOMDOcument instance for submission usage. + * + * @access public + * @param AssetMethod $assetMethod + * @return void | [Adds to this instance] + */ + public function addAssetMethod(AssetMethod $assetMethod) + { + $assetMethodElement = $this->createElement('assetmethod'); + $this->rootElement->appendChild($assetMethodElement); + + $assetMethodElement->appendChild($this->createNodeWithTextContent('calcmethod', $assetMethod->getCalcMethod())); + $assetMethodElement->appendChild($this->createNodeWithTextContent('code', $assetMethod->getCode())); + $assetMethodElement->appendChild($this->createNodeWithTextContent('depreciatereconciliation', $assetMethod->getDepreciateReconciliation())); + $assetMethodElement->appendChild($this->createNodeWithTextContent('name', $assetMethod->getName())); + $assetMethodElement->appendChild($this->createNodeWithTextContent('nrofperiods', $assetMethod->getNrOfPeriods())); + $assetMethodElement->appendChild($this->createNodeWithTextContent('office', $assetMethod->getOfficeToCode())); + $assetMethodElement->appendChild($this->createNodeWithTextContent('percentage', $assetMethod->getPercentage())); + $assetMethodElement->appendChild($this->createNodeWithTextContent('shortname', $assetMethod->getShortName())); + + $balanceAccounts = $assetMethod->getBalanceAccounts(); + + $balanceAccountsElement = $this->createElement('balanceaccounts'); + $assetMethodElement->appendChild($balanceAccountsElement); + + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('assetstoactivate', $balanceAccounts->getAssetsToActivateToCode())); + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('depreciation', $balanceAccounts->getDepreciationToCode())); + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('depreciationgroup', $balanceAccounts->getDepreciationGroupToCode())); + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('purchasevalue', $balanceAccounts->getPurchaseValueToCode())); + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('purchasevaluegroup', $balanceAccounts->getPurchaseValueGroupToCode())); + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('reconciliation', $balanceAccounts->getReconciliationToCode())); + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('tobeinvoiced', $balanceAccounts->getToBeInvoicedToCode())); + + $profitLossAccounts = $assetMethod->getProfitLossAccounts(); + + $profitLossAccountsElement = $this->createElement('profitlossaccounts'); + $assetMethodElement->appendChild($profitLossAccountsElement); + + $profitLossAccountsElement->appendChild($this->createNodeWithTextContent('depreciation', $profitLossAccounts->getDepreciationToCode())); + $profitLossAccountsElement->appendChild($this->createNodeWithTextContent('reconciliation', $profitLossAccounts->getReconciliationToCode())); + $profitLossAccountsElement->appendChild($this->createNodeWithTextContent('sales', $profitLossAccounts->getSalesToCode())); + + $freeTexts = $assetMethod->getFreeTexts(); + + if (!empty($freeTexts)) { + // Make freetexts element + $freeTextsElement = $this->createElement('freetexts'); + $assetMethodElement->appendChild($freeTextsElement); + + // Go through each freetext assigned to the asset method + foreach ($freeTexts as $freeText) { + // Make freetext element + $freeTextsElement->appendChild($this->createNodeWithTextContent('freetext', $freeText->getElementValue(), $freeText, array('id' => 'getID', 'type' => 'getType'))); + } + } + } +} diff --git a/src/DomDocuments/BaseDocument.php b/src/DomDocuments/BaseDocument.php index ed9cb33b..161436c3 100644 --- a/src/DomDocuments/BaseDocument.php +++ b/src/DomDocuments/BaseDocument.php @@ -156,13 +156,24 @@ protected function appendPerformanceTypeFields(\DOMElement $element, $object): v * Use this instead of createElement(). * * @param string $tag - * @param string $textContent + * @param string|null $textContent + * @param object|null $object + * @param array|null $attributes * @return \DOMElement */ - final protected function createNodeWithTextContent(string $tag, string $textContent): \DOMElement + final protected function createNodeWithTextContent(string $tag, ?string $textContent, object $object = null, array $attributes = null): \DOMElement { $element = $this->createElement($tag); - $element->textContent = $textContent; + + if ($textContent != null) { + $element->textContent = $textContent; + } + + if (isset($object) && isset($attributes)) { + foreach ($attributes as $attributeName => $method) { + $element->setAttribute($attributeName, $object->$method()); + } + } return $element; } diff --git a/src/DomDocuments/CostCentersDocument.php b/src/DomDocuments/CostCentersDocument.php new file mode 100644 index 00000000..ac22394b --- /dev/null +++ b/src/DomDocuments/CostCentersDocument.php @@ -0,0 +1,50 @@ +, based on ArticlesDocument by Willem van de Sande + */ +class CostCentersDocument extends BaseDocument +{ + final protected function getRootTagName(): string + { + return "dimensions"; + } + + /** + * Turns a passed CostCenter class into the required markup for interacting + * with Twinfield. + * + * This method doesn't return anything, instead just adds the CostCenter to + * this DOMDOcument instance for submission usage. + * + * @access public + * @param CostCenter $costCenter + * @return void | [Adds to this instance] + */ + public function addCostCenter(CostCenter $costCenter) + { + $costCenterElement = $this->createElement('dimension'); + $this->rootElement->appendChild($costCenterElement); + + $status = $costCenter->getStatus(); + + if (!empty($status)) { + $costCenterElement->setAttribute('status', $status); + } + + $costCenterElement->appendChild($this->createNodeWithTextContent('code', $costCenter->getCode())); + $costCenterElement->appendChild($this->createNodeWithTextContent('name', $costCenter->getName())); + $costCenterElement->appendChild($this->createNodeWithTextContent('office', $costCenter->getOfficeToCode())); + $costCenterElement->appendChild($this->createNodeWithTextContent('type', $costCenter->getTypeToCode())); + } +} diff --git a/src/DomDocuments/CurrenciesDocument.php b/src/DomDocuments/CurrenciesDocument.php new file mode 100644 index 00000000..260c372f --- /dev/null +++ b/src/DomDocuments/CurrenciesDocument.php @@ -0,0 +1,74 @@ +, based on ArticlesDocument by Willem van de Sande + */ +class CurrenciesDocument extends BaseDocument +{ + final protected function getRootTagName(): string + { + return "currencies"; + } + + /** + * Turns a passed Currency class into the required markup for interacting + * with Twinfield. + * + * This method doesn't return anything, instead just adds the Currency to + * this DOMDOcument instance for submission usage. + * + * @access public + * @param Currency $currency + * @return void | [Adds to this instance] + */ + public function addCurrency(Currency $currency) + { + $currencyElement = $this->createElement('currency'); + $this->rootElement->appendChild($currencyElement); + + $status = $currency->getStatus(); + + if (!empty($status)) { + $currencyElement->setAttribute('status', $status); + } + + $currencyElement->appendChild($this->createNodeWithTextContent('code', $currency->getCode())); + $currencyElement->appendChild($this->createNodeWithTextContent('name', $currency->getName())); + $currencyElement->appendChild($this->createNodeWithTextContent('office', $currency->getOfficeToCode())); + $currencyElement->appendChild($this->createNodeWithTextContent('shortname', $currency->getShortName())); + + $rates = $currency->getRates(); + + if (!empty($rates)) { + // Make rates element + $ratesElement = $this->createElement('rates'); + $currencyElement->appendChild($ratesElement); + + // Go through each rate assigned to the currency + foreach ($rates as $rate) { + // Makes rate element + $rateElement = $this->createElement('rate'); + $ratesElement->appendChild($rateElement); + + $status = $rate->getStatus(); + + if (!empty($status)) { + $rateElement->setAttribute('status', $status); + } + + $rateElement->appendChild($this->createNodeWithTextContent('rate', $rate->getRate())); + $rateElement->appendChild($this->createNodeWithTextContent('startdate', $rate->getStartDateToString())); + } + } + } +} diff --git a/src/DomDocuments/CustomersDocument.php b/src/DomDocuments/CustomersDocument.php index 21a2cd23..8ca18d2a 100644 --- a/src/DomDocuments/CustomersDocument.php +++ b/src/DomDocuments/CustomersDocument.php @@ -2,299 +2,283 @@ namespace PhpTwinfield\DomDocuments; use PhpTwinfield\Customer; -use PhpTwinfield\CustomerAddress; -use PhpTwinfield\CustomerBank; -use PhpTwinfield\Util; /** - * The Document Holder for making new XML customers. Is a child class + * The Document Holder for making new XML Customer. Is a child class * of DOMDocument and makes the required DOM tree for the interaction in - * creating a new customer. + * creating a new Customer. * * @package PhpTwinfield * @subpackage Invoice\DOM - * @author Leon Rowland + * @author Leon Rowland , extended by Yannick Aerssens * @copyright (c) 2013, Pronamic */ class CustomersDocument extends BaseDocument { - /** - * Multiple customers can be created at once by enclosing them by the dimensions element. - * - * @return string - */ - protected function getRootTagName(): string + final protected function getRootTagName(): string { - return 'dimensions'; + return "dimensions"; } /** * Turns a passed Customer class into the required markup for interacting * with Twinfield. * + * This method doesn't return anything, instead just adds the Customer to + * this DOMDOcument instance for submission usage. + * + * @access public * @param Customer $customer + * @return void | [Adds to this instance] */ - public function addCustomer(Customer $customer): void + public function addCustomer(Customer $customer) { - $customerEl = $this->createElement("dimension"); - - // Elements and their associated methods for customer - $customerTags = array( - 'code' => 'getCode', - 'name' => 'getName', - 'type' => 'getType', - 'website' => 'getWebsite', - 'office' => 'getOffice', - ); - - if ($customer->getOffice()) { - $customerTags['office'] = 'getOffice'; - } - - if (!empty($customer->getStatus())) { - $customerEl->setAttribute('status', $customer->getStatus()); - } - - // Go through each customer element and use the assigned method - foreach ($customerTags as $tag => $method) { + $customerElement = $this->createElement('dimension'); + $this->rootElement->appendChild($customerElement); - if($value = $customer->$method()) { - // Make text node for method value - $node = $this->createTextNode($value); + $status = $customer->getStatus(); - // Make the actual element and assign the node - $element = $this->createElement($tag); - $element->appendChild($node); - - // Add the full element - $customerEl->appendChild($element); - } + if (!empty($status)) { + $customerElement->setAttribute('status', $status); } - // Check if the financial information should be supplied - if ($customer->getDueDays() > 0) { - - // Financial elements and their methods - $financialsTags = array( - 'duedays' => 'getDueDays', - 'payavailable' => 'getPayAvailable', - 'paycode' => 'getPayCode', - 'vatcode' => 'getVatCode', - 'ebilling' => 'getEBilling', - 'ebillmail' => 'getEBillMail', - ); - - // Make the financial element - $financialElement = $this->createElement('financials'); - $customerEl->appendChild($financialElement); - - // Go through each financial element and use the assigned method - foreach ($financialsTags as $tag => $method) { - - // Make the text node for the method value - $nodeValue = $customer->$method(); - if (is_bool($nodeValue)) { - $nodeValue = ($nodeValue) ? 'true' : 'false'; - } - $node = $this->createTextNode($nodeValue); - - // Make the actual element and assign the node - $element = $this->createElement($tag); - $element->appendChild($node); - - // Add the full element - $financialElement->appendChild($element); + $customerElement->appendChild($this->createNodeWithTextContent('beginperiod', $customer->getBeginPeriod())); + $customerElement->appendChild($this->createNodeWithTextContent('beginyear', $customer->getBeginYear())); + $customerElement->appendChild($this->createNodeWithTextContent('code', $customer->getCode())); + $customerElement->appendChild($this->createNodeWithTextContent('endperiod', $customer->getEndPeriod())); + $customerElement->appendChild($this->createNodeWithTextContent('endyear', $customer->getEndYear())); + $customerElement->appendChild($this->createNodeWithTextContent('name', $customer->getName())); + $customerElement->appendChild($this->createNodeWithTextContent('office', $customer->getOfficeToCode())); + $customerElement->appendChild($this->createNodeWithTextContent('shortname', $customer->getShortName())); + $customerElement->appendChild($this->createNodeWithTextContent('type', $customer->getTypeToCode())); + $customerElement->appendChild($this->createNodeWithTextContent('website', $customer->getWebsite())); + + $financials = $customer->getFinancials(); + + $financialsElement = $this->createElement('financials'); + $customerElement->appendChild($financialsElement); + + $financialsElement->appendChild($this->createNodeWithTextContent('collectionschema', $financials->getCollectionSchema())); + $financialsElement->appendChild($this->createNodeWithTextContent('duedays', $financials->getDueDays())); + $financialsElement->appendChild($this->createNodeWithTextContent('ebilling', $financials->getEBillingToString())); + $financialsElement->appendChild($this->createNodeWithTextContent('ebillmail', $financials->getEBillMail())); + $financialsElement->appendChild($this->createNodeWithTextContent('meansofpayment', $financials->getMeansOfPayment())); + $financialsElement->appendChild($this->createNodeWithTextContent('payavailable', $financials->getPayAvailableToString())); + $financialsElement->appendChild($this->createNodeWithTextContent('paycode', $financials->getPayCodeToCode())); + $financialsElement->appendChild($this->createNodeWithTextContent('substitutewith', $financials->getSubstituteWithToCode())); + $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $financials->getVatCodeToCode())); + + $collectMandate = $financials->getCollectMandate(); + + // Make collectmandate element + $collectMandateElement = $this->createElement('collectmandate'); + $financialsElement->appendChild($collectMandateElement); + + $collectMandateElement->appendChild($this->createNodeWithTextContent('firstrundate', $collectMandate->getFirstRunDateToString())); + $collectMandateElement->appendChild($this->createNodeWithTextContent('id', $collectMandate->getID())); + $collectMandateElement->appendChild($this->createNodeWithTextContent('signaturedate', $collectMandate->getSignatureDateToString())); + + $childValidations = $financials->getChildValidations(); + + if (!empty($childValidations)) { + // Make childvalidations element + $childValidationsElement = $this->createElement('childvalidations'); + $financialsElement->appendChild($childValidationsElement); + + // Go through each childvalidation assigned to the customer financials + foreach ($childValidations as $childValidation) { + // Make childvalidation element + $childValidationsElement->appendChild($this->createNodeWithTextContent('childvalidation', $childValidation->getElementValue(), $childValidation, array('level' => 'getLevel', 'type' => 'getType'))); } + } - //check if collectmandate should be set - $collectMandate = $customer->getCollectMandate(); - - if ($collectMandate !== null) { - - // Collect mandate elements and their methods - $collectMandateTags = array( - 'id' => 'getID', - 'signaturedate' => 'getSignatureDate', - 'firstrundate' => 'getFirstRunDate', - ); - - // Make the collectmandate element - $collectMandateElement = $this->createElement('collectmandate'); - $financialElement->appendChild($collectMandateElement); - - // Go through each collectmandate element and use the assigned method - foreach ($collectMandateTags as $tag => $method) { - - // Make the text node for the method value - $node = $this->createTextNode($this->getValueFromCallback([$collectMandate, $method])); - - // Make the actual element and assign the node - $element = $this->createElement($tag); - $element->appendChild($node); + $creditManagement = $customer->getCreditManagement(); - // Add the full element - $collectMandateElement->appendChild($element); - } - } - } + // Make creditmanagement element + $creditManagementElement = $this->createElement('creditmanagement'); + $customerElement->appendChild($creditManagementElement); - //check if creditmanagement should be set - if ($customer->getCreditManagement() !== null) { - - // Credit management elements and their methods - $creditManagementTags = array( - 'responsibleuser' => 'getResponsibleUser', - 'basecreditlimit' => 'getBaseCreditLimit', - 'sendreminder' => 'getSendReminder', - 'reminderemail' => 'getReminderEmail', - 'blocked' => 'getBlocked', - 'freetext1' => 'getFreeText1', - 'freetext2' => 'getFreeText2', - 'comment' => 'getComment', - ); - - // Make the creditmanagement element - $creditManagementElement = $this->createElement('creditmanagement'); - $customerEl->appendChild($creditManagementElement); - - // Go through each credit management element and use the assigned method - foreach ($creditManagementTags as $tag => $method) { - - // Make the text node for the method value - $nodeValue = $customer->getCreditManagement()->$method(); - if (is_bool($nodeValue)) { - $nodeValue = ($nodeValue) ? 'true' : 'false'; - } - $node = $this->createTextNode($nodeValue); + $creditManagementElement->appendChild($this->createNodeWithTextContent('basecreditlimit', $creditManagement->getBaseCreditLimitToFloat())); + $creditManagementElement->appendChild($this->createNodeWithTextContent('blocked', $creditManagement->getBlockedToString())); + $creditManagementElement->appendChild($this->createNodeWithTextContent('comment', $creditManagement->getComment())); + $creditManagementElement->appendChild($this->createNodeWithTextContent('freetext1', $creditManagement->getFreeText1ToString())); + $creditManagementElement->appendChild($this->createNodeWithTextContent('freetext2', $creditManagement->getFreeText2())); + $creditManagementElement->appendChild($this->createNodeWithTextContent('freetext3', $creditManagement->getFreeText3())); + $creditManagementElement->appendChild($this->createNodeWithTextContent('reminderemail', $creditManagement->getReminderEmail())); + $creditManagementElement->appendChild($this->createNodeWithTextContent('responsibleuser', $creditManagement->getResponsibleUserToCode())); + $creditManagementElement->appendChild($this->createNodeWithTextContent('sendreminder', $creditManagement->getSendReminder())); - // Make the actual element and assign the node - $element = $this->createElement($tag); - $element->appendChild($node); + // Make invoicing element + $invoicingElement = $this->createElement('invoicing'); + $customerElement->appendChild($invoicingElement); - // Add the full element - $creditManagementElement->appendChild($element); - } - } + $invoicingElement->appendChild($this->createNodeWithTextContent('discountarticle', $customer->getDiscountArticleToCode())); $addresses = $customer->getAddresses(); - if (!empty($addresses)) { - - // Address elements and their methods - $addressTags = array( - 'name' => 'getName', - 'contact' => 'getContact', - 'country' => 'getCountry', - 'city' => 'getCity', - 'postcode' => 'getPostcode', - 'telephone' => 'getTelephone', - 'telefax' => 'getFax', - 'email' => 'getEmail', - 'field1' => 'getField1', - 'field2' => 'getField2', - 'field3' => 'getField3', - 'field4' => 'getField4', - 'field5' => 'getField5', - 'field6' => 'getField6', - ); + if (!empty($addresses)) { // Make addresses element $addressesElement = $this->createElement('addresses'); - $customerEl->appendChild($addressesElement); + $customerElement->appendChild($addressesElement); // Go through each address assigned to the customer - /** @var CustomerAddress $address */ foreach ($addresses as $address) { - - // Makes new address element + // Make address element $addressElement = $this->createElement('address'); $addressesElement->appendChild($addressElement); - // Set attributes - $addressElement->setAttribute('default', Util::formatBoolean($address->getDefault())); - $addressElement->setAttribute('type', $address->getType()); + $default = $address->getDefaultToString(); + + if (!empty($default)) { + $addressElement->setAttribute('default', $default); + } - // Go through each address element and use the assigned method - foreach ($addressTags as $tag => $method) { + $id = $address->getID(); - // Make the text node for the method value - $node = $this->createTextNode($address->$method()); + if (!empty($id)) { + $addressElement->setAttribute('id', $id); + } - // Make the actual element and assign the text node - $element = $this->createElement($tag); - $element->appendChild($node); + $type = $address->getType(); - // Add the completed element - $addressElement->appendChild($element); + if (!empty($type)) { + $addressElement->setAttribute('type', $type); } + + $addressElement->appendChild($this->createNodeWithTextContent('city', $address->getCity())); + $addressElement->appendChild($this->createNodeWithTextContent('country', $address->getCountryToCode())); + $addressElement->appendChild($this->createNodeWithTextContent('email', $address->getEmail())); + $addressElement->appendChild($this->createNodeWithTextContent('field1', $address->getField1())); + $addressElement->appendChild($this->createNodeWithTextContent('field2', $address->getField2())); + $addressElement->appendChild($this->createNodeWithTextContent('field3', $address->getField3())); + $addressElement->appendChild($this->createNodeWithTextContent('field4', $address->getField4())); + $addressElement->appendChild($this->createNodeWithTextContent('field5', $address->getField5())); + $addressElement->appendChild($this->createNodeWithTextContent('field6', $address->getField6())); + $addressElement->appendChild($this->createNodeWithTextContent('name', $address->getName())); + $addressElement->appendChild($this->createNodeWithTextContent('postcode', $address->getPostcode())); + $addressElement->appendChild($this->createNodeWithTextContent('telefax', $address->getTelefax())); + $addressElement->appendChild($this->createNodeWithTextContent('telephone', $address->getTelephone())); } } $banks = $customer->getBanks(); - if (!empty($banks)) { - - // Bank elements and their methods - $bankTags = array( - 'ascription' => 'getAscription', - 'accountnumber' => 'getAccountnumber', - 'bankname' => 'getBankname', - 'biccode' => 'getBiccode', - 'city' => 'getCity', - 'country' => 'getCountry', - 'iban' => 'getIban', - 'natbiccode' => 'getNatbiccode', - 'postcode' => 'getPostcode', - 'state' => 'getState', - ); + if (!empty($banks)) { // Make banks element $banksElement = $this->createElement('banks'); - $customerEl->appendChild($banksElement); + $customerElement->appendChild($banksElement); // Go through each bank assigned to the customer - /** @var CustomerBank $bank */ foreach ($banks as $bank) { - - // Makes new bank element + // Make bank element $bankElement = $this->createElement('bank'); $banksElement->appendChild($bankElement); - // Set attributes - $bankElement->setAttribute('default', Util::formatBoolean($bank->getDefault())); - - // Go through each bank element and use the assigned method - foreach ($bankTags as $tag => $method) { + $default = $bank->getDefaultToString(); - // Make the text node for the method value - $node = $this->createTextNode($bank->$method()); + if (!empty($default)) { + $bankElement->setAttribute('default', $default); + } - // Make the actual element and assign the text node - $element = $this->createElement($tag); - $element->appendChild($node); + $id = $bank->getID(); - // Add the completed element - $bankElement->appendChild($element); + if (!empty($id)) { + $bankElement->setAttribute('id', $id); } - // Bank address fields + $bankAddressElement = $this->createElement('address'); + $bankAddressElement->appendChild($this->createNodeWithTextContent('field2', $bank->getField2())); + $bankAddressElement->appendChild($this->createNodeWithTextContent('field3', $bank->getField3())); + $bankElement->appendChild($bankAddressElement); + + $bankElement->appendChild($this->createNodeWithTextContent('ascription', $bank->getAscription())); + $bankElement->appendChild($this->createNodeWithTextContent('accountnumber', $bank->getAccountNumber())); + $bankElement->appendChild($this->createNodeWithTextContent('bankname', $bank->getBankName())); + $bankElement->appendChild($this->createNodeWithTextContent('biccode', $bank->getBicCode())); + $bankElement->appendChild($this->createNodeWithTextContent('city', $bank->getCity())); + $bankElement->appendChild($this->createNodeWithTextContent('country', $bank->getCountryToCode())); + $bankElement->appendChild($this->createNodeWithTextContent('iban', $bank->getIban())); + $bankElement->appendChild($this->createNodeWithTextContent('natbiccode', $bank->getNatBicCode())); + $bankElement->appendChild($this->createNodeWithTextContent('postcode', $bank->getPostcode())); + $bankElement->appendChild($this->createNodeWithTextContent('state', $bank->getState())); + } + } - // Make the text nodes for the bank address fields - $field2Node = $this->createTextNode($bank->getAddressField2()); - $field3Node = $this->createTextNode($bank->getAddressField3()); + $remittanceAdviceElement = $this->createElement('remittanceadvice'); + $customerElement->appendChild($remittanceAdviceElement); - // Make the actual elements and assign the text nodes - $field2Element = $this->createElement('field2'); - $field3Element = $this->createElement('field3'); - $field2Element->appendChild($field2Node); - $field3Element->appendChild($field3Node); + $remittanceAdviceElement->appendChild($this->createNodeWithTextContent('sendmail', $customer->getRemittanceAdviceSendMail())); + $remittanceAdviceElement->appendChild($this->createNodeWithTextContent('sendtype', $customer->getRemittanceAdviceSendType())); - // Combine the fields in an address element and add that to the bank element - $addressElement = $this->createElement('address'); - $addressElement->appendChild($field2Element); - $addressElement->appendChild($field3Element); - $bankElement->appendChild($addressElement); + $group = $customer->getGroupToCode(); + + if (!empty($group)) { + $groupsElement = $this->createElement('groups'); + $groupsElement->appendChild($this->createNodeWithTextContent('group', $group)); + $customerElement->appendChild($groupsElement); + } + + $postingRules = $customer->getPostingRules(); + + if (!empty($postingRules)) { + // Make postingrules element + $postingRulesElement = $this->createElement('postingrules'); + $customerElement->appendChild($postingRulesElement); + + // Go through each posting rule assigned to the customer + foreach ($postingRules as $postingRule) { + // Make postingrule element + $postingRuleElement = $this->createElement('postingrule'); + $postingRulesElement->appendChild($postingRuleElement); + + $id = $postingRule->getID(); + + if (!empty($id)) { + $postingRuleElement->setAttribute('id', $id); + } + + $status = $postingRule->getStatus(); + + if (!empty($status)) { + $postingRuleElement->setAttribute('status', $status); + } + + $postingRuleElement->appendChild($this->createNodeWithTextContent('amount', $postingRule->getAmountToFloat())); + $postingRuleElement->appendChild($this->createNodeWithTextContent('currency', $postingRule->getCurrencyToCode())); + $postingRuleElement->appendChild($this->createNodeWithTextContent('description', $postingRule->getDescription())); + + $postingRuleLines = $postingRule->getLines(); + + if (!empty($postingRuleLines)) { + // Make lines element + $postingRuleLinesElement = $this->createElement('lines'); + $postingRuleElement->appendChild($postingRuleLinesElement); + + // Go through each line assigned to the customer posting rule + foreach ($postingRuleLines as $postingRuleLine) { + // Make line element + $postingRuleLineElement = $this->createElement('line'); + $postingRuleLinesElement->appendChild($postingRuleLineElement); + + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension1', $postingRuleLine->getDimension1ToCode())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension2', $postingRuleLine->getDimension2ToCode())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension3', $postingRuleLine->getDimension3ToCode())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('description', $postingRuleLine->getDescription())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('office', $postingRuleLine->getOfficeToCode())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('ratio', $postingRuleLine->getRatio())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('vatcode', $postingRuleLine->getVatCodeToCode())); + } + } } } - $this->rootElement->appendChild($customerEl); + $paymentconditionsElement = $this->createElement('paymentconditions'); + $customerElement->appendChild($paymentconditionsElement); + + $paymentconditionElement = $this->createElement('paymentcondition'); + $paymentconditionsElement->appendChild($paymentconditionElement); + + $paymentconditionElement->appendChild($this->createNodeWithTextContent('discountdays', $customer->getPaymentConditionDiscountDays())); + $paymentconditionElement->appendChild($this->createNodeWithTextContent('discountpercentage', $customer->getPaymentConditionDiscountPercentage())); } -} +} \ No newline at end of file diff --git a/src/DomDocuments/DimensionGroupsDocument.php b/src/DomDocuments/DimensionGroupsDocument.php new file mode 100644 index 00000000..cd178d35 --- /dev/null +++ b/src/DomDocuments/DimensionGroupsDocument.php @@ -0,0 +1,68 @@ + + */ +class DimensionGroupsDocument extends BaseDocument +{ + final protected function getRootTagName(): string + { + return "dimensiongroups"; + } + + /** + * Turns a passed DimensionGroup class into the required markup for interacting + * with Twinfield. + * + * This method doesn't return anything, instead just adds the DimensionGroup to + * this DOMDOcument instance for submission usage. + * + * @access public + * @param DimensionGroup $dimensionGroup + * @return void | [Adds to this instance] + */ + public function addDimensionGroup(DimensionGroup $dimensionGroup) + { + $dimensionGroupElement = $this->createElement('dimensiongroup'); + $this->rootElement->appendChild($dimensionGroupElement); + + $status = $dimensionGroup->getStatus(); + + if (!empty($status)) { + $dimensionGroupElement->setAttribute('status', $status); + } + + $dimensionGroupElement->appendChild($this->createNodeWithTextContent('code', $dimensionGroup->getCode())); + $dimensionGroupElement->appendChild($this->createNodeWithTextContent('name', $dimensionGroup->getName())); + $dimensionGroupElement->appendChild($this->createNodeWithTextContent('office', $dimensionGroup->getOfficeToCode())); + $dimensionGroupElement->appendChild($this->createNodeWithTextContent('shortname', $dimensionGroup->getShortName())); + + $dimensions = $dimensionGroup->getDimensions(); + + if (!empty($dimensions)) { + // Make dimensions element + $dimensionsElement = $this->createElement('dimensions'); + $dimensionGroupElement->appendChild($dimensionsElement); + + // Go through each dimension assigned to the dimension group + foreach ($dimensions as $dimension) { + // Makes dimension element + $dimensionElement = $this->createElement('dimension'); + $dimensionsElement->appendChild($dimensionElement); + + $dimensionElement->appendChild($this->createNodeWithTextContent('code', $dimension->getCodeToCode())); + $dimensionElement->appendChild($this->createNodeWithTextContent('type', $dimension->getTypeToCode())); + } + } + } +} diff --git a/src/DomDocuments/DimensionTypesDocument.php b/src/DomDocuments/DimensionTypesDocument.php new file mode 100644 index 00000000..b89c35c2 --- /dev/null +++ b/src/DomDocuments/DimensionTypesDocument.php @@ -0,0 +1,65 @@ + + */ +class DimensionTypesDocument extends BaseDocument +{ + final protected function getRootTagName(): string + { + return "dimensiontypes"; + } + + /** + * Turns a passed DimensionType class into the required markup for interacting + * with Twinfield. + * + * This method doesn't return anything, instead just adds the DimensionType to + * this DOMDOcument instance for submission usage. + * + * @access public + * @param DimensionType $dimensionType + * @return void | [Adds to this instance] + */ + public function addDimensionType(DimensionType $dimensionType) + { + $dimensionTypeElement = $this->createElement('dimensiontype'); + $this->rootElement->appendChild($dimensionTypeElement); + + $dimensionTypeElement->appendChild($this->createNodeWithTextContent('code', $dimensionType->getCode())); + $dimensionTypeElement->appendChild($this->createNodeWithTextContent('mask', $dimensionType->getMask())); + $dimensionTypeElement->appendChild($this->createNodeWithTextContent('name', $dimensionType->getName())); + $dimensionTypeElement->appendChild($this->createNodeWithTextContent('office', $dimensionType->getOfficeToCode())); + $dimensionTypeElement->appendChild($this->createNodeWithTextContent('shortname', $dimensionType->getShortName())); + + $address = $dimensionType->getAddress(); + + $addressElement = $this->createElement('address'); + $dimensionTypeElement->appendChild($addressElement); + + $addressElement->appendChild($this->createNodeWithTextContent('label1', $address->getLabel1())); + $addressElement->appendChild($this->createNodeWithTextContent('label2', $address->getLabel2())); + $addressElement->appendChild($this->createNodeWithTextContent('label3', $address->getLabel3())); + $addressElement->appendChild($this->createNodeWithTextContent('label4', $address->getLabel4())); + $addressElement->appendChild($this->createNodeWithTextContent('label5', $address->getLabel5())); + $addressElement->appendChild($this->createNodeWithTextContent('label6', $address->getLabel6())); + + $levels = $dimensionType->getLevels(); + + $levelsElement = $this->createElement('levels'); + $dimensionTypeElement->appendChild($levelsElement); + + $levelsElement->appendChild($this->createNodeWithTextContent('financials', $levels->getFinancials())); + $levelsElement->appendChild($this->createNodeWithTextContent('time', $levels->getTime())); + } +} diff --git a/src/DomDocuments/FixedAssetsDocument.php b/src/DomDocuments/FixedAssetsDocument.php new file mode 100644 index 00000000..8349f318 --- /dev/null +++ b/src/DomDocuments/FixedAssetsDocument.php @@ -0,0 +1,114 @@ + + */ +class FixedAssetsDocument extends BaseDocument +{ + final protected function getRootTagName(): string + { + return "dimensions"; + } + + /** + * Turns a passed FixedAsset class into the required markup for interacting + * with Twinfield. + * + * This method doesn't return anything, instead just adds the FixedAsset to + * this DOMDOcument instance for submission usage. + * + * @access public + * @param FixedAsset $fixedAsset + * @return void | [Adds to this instance] + */ + public function addFixedAsset(FixedAsset $fixedAsset) + { + $fixedAssetElement = $this->createElement('dimension'); + $this->rootElement->appendChild($fixedAssetElement); + + $status = $fixedAsset->getStatus(); + + if (!empty($status)) { + $fixedAssetElement->setAttribute('status', $status); + } + + $fixedAssetElement->appendChild($this->createNodeWithTextContent('code', $fixedAsset->getCode())); + $fixedAssetElement->appendChild($this->createNodeWithTextContent('name', $fixedAsset->getName())); + $fixedAssetElement->appendChild($this->createNodeWithTextContent('office', $fixedAsset->getOfficeToCode())); + $fixedAssetElement->appendChild($this->createNodeWithTextContent('type', $fixedAsset->getTypeToCode())); + + $financials = $fixedAsset->getFinancials(); + + $financialsElement = $this->createElement('financials'); + $fixedAssetElement->appendChild($financialsElement); + + $financialsElement->appendChild($this->createNodeWithTextContent('substitutionlevel', $financials->getSubstitutionLevel())); + $financialsElement->appendChild($this->createNodeWithTextContent('substitutewith', $financials->getSubstituteWithToCode())); + $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $financials->getVatCodeToCode())); + + $fixedAssets = $fixedAsset->getFixedAssets(); + + $fixedAssetsElement = $this->createElement('fixedassets'); + $fixedAssetElement->appendChild($fixedAssetsElement); + + $fixedAssetsElement->appendChild($this->createNodeWithTextContent('beginperiod', $fixedAssets->getBeginPeriod())); + $fixedAssetsElement->appendChild($this->createNodeWithTextContent('freetext1', $fixedAssets->getFreeText1())); + $fixedAssetsElement->appendChild($this->createNodeWithTextContent('freetext2', $fixedAssets->getFreeText2())); + $fixedAssetsElement->appendChild($this->createNodeWithTextContent('freetext3', $fixedAssets->getFreeText3())); + $fixedAssetsElement->appendChild($this->createNodeWithTextContent('freetext4', $fixedAssets->getFreeText4())); + $fixedAssetsElement->appendChild($this->createNodeWithTextContent('freetext5', $fixedAssets->getFreeText5())); + $fixedAssetsElement->appendChild($this->createNodeWithTextContent('lastdepreciation', $fixedAssets->getLastDepreciation())); + $fixedAssetsElement->appendChild($this->createNodeWithTextContent('method', $fixedAssets->getMethodToCode())); + $fixedAssetsElement->appendChild($this->createNodeWithTextContent('nrofperiods', $fixedAssets->getNrOfPeriods())); + $fixedAssetsElement->appendChild($this->createNodeWithTextContent('percentage', $fixedAssets->getPercentage())); + $fixedAssetsElement->appendChild($this->createNodeWithTextContent('purchasedate', $fixedAssets->getPurchaseDateToString())); + $fixedAssetsElement->appendChild($this->createNodeWithTextContent('residualvalue', $fixedAssets->getResidualValueToFloat())); + $fixedAssetsElement->appendChild($this->createNodeWithTextContent('selldate', $fixedAssets->getSellDateToString())); + $fixedAssetsElement->appendChild($this->createNodeWithTextContent('stopvalue', $fixedAssets->getStopValueToFloat())); + + $transactionLines = $fixedAssets->getTransactionLines(); + + if (!empty($transactionLines)) { + // Make translines element + $transactionLinesElement = $this->createElement('translines'); + $fixedAssetsElement->appendChild($transactionLinesElement); + + // Go through each transaction line assigned to the fixed asset fixed assets + foreach ($transactionLines as $transactionLine) { + // Make transline element + $transactionLineElement = $this->createElement('transline'); + $transactionLinesElement->appendChild($transactionLineElement); + + $transactionLineElement->appendChild($this->createNodeWithTextContent('amount', $transactionLine->getAmountToFloat())); + $transactionLineElement->appendChild($this->createNodeWithTextContent('code', $transactionLine->getCodeToCode())); + $transactionLineElement->appendChild($this->createNodeWithTextContent('dim1', $transactionLine->getDim1ToCode())); + $transactionLineElement->appendChild($this->createNodeWithTextContent('dim2', $transactionLine->getDim2ToCode())); + $transactionLineElement->appendChild($this->createNodeWithTextContent('dim3', $transactionLine->getDim3ToCode())); + $transactionLineElement->appendChild($this->createNodeWithTextContent('dim4', $transactionLine->getDim4ToCode())); + $transactionLineElement->appendChild($this->createNodeWithTextContent('dim5', $transactionLine->getDim5ToCode())); + $transactionLineElement->appendChild($this->createNodeWithTextContent('dim6', $transactionLine->getDim6ToCode())); + $transactionLineElement->appendChild($this->createNodeWithTextContent('line', $transactionLine->getLine())); + $transactionLineElement->appendChild($this->createNodeWithTextContent('number', $transactionLine->getNumber())); + $transactionLineElement->appendChild($this->createNodeWithTextContent('period', $transactionLine->getPeriod())); + } + } + + $group = $fixedAsset->getGroupToCode(); + + if (!empty($group)) { + $groupsElement = $this->createElement('groups'); + $groupsElement->appendChild($this->createNodeWithTextContent('group', $group)); + $fixedAssetElement->appendChild($groupsElement); + } + } +} diff --git a/src/DomDocuments/GeneralLedgersDocument.php b/src/DomDocuments/GeneralLedgersDocument.php new file mode 100644 index 00000000..823ba6e5 --- /dev/null +++ b/src/DomDocuments/GeneralLedgersDocument.php @@ -0,0 +1,87 @@ + + */ +class GeneralLedgersDocument extends BaseDocument +{ + final protected function getRootTagName(): string + { + return "dimensions"; + } + + /** + * Turns a passed GeneralLedger class into the required markup for interacting + * with Twinfield. + * + * This method doesn't return anything, instead just adds the GeneralLedger to + * this DOMDOcument instance for submission usage. + * + * @access public + * @param GeneralLedger $generalLedger + * @return void | [Adds to this instance] + */ + public function addGeneralLedger(GeneralLedger $generalLedger) + { + $generalLedgerElement = $this->createElement('dimension'); + $this->rootElement->appendChild($generalLedgerElement); + + $status = $generalLedger->getStatus(); + + if (!empty($status)) { + $generalLedgerElement->setAttribute('status', $status); + } + + $generalLedgerElement->appendChild($this->createNodeWithTextContent('beginperiod', $generalLedger->getBeginPeriod())); + $generalLedgerElement->appendChild($this->createNodeWithTextContent('beginyear', $generalLedger->getBeginYear())); + $generalLedgerElement->appendChild($this->createNodeWithTextContent('code', $generalLedger->getCode())); + $generalLedgerElement->appendChild($this->createNodeWithTextContent('endperiod', $generalLedger->getEndPeriod())); + $generalLedgerElement->appendChild($this->createNodeWithTextContent('endyear', $generalLedger->getEndYear())); + $generalLedgerElement->appendChild($this->createNodeWithTextContent('name', $generalLedger->getName())); + $generalLedgerElement->appendChild($this->createNodeWithTextContent('office', $generalLedger->getOfficeToCode())); + $generalLedgerElement->appendChild($this->createNodeWithTextContent('shortname', $generalLedger->getShortName())); + $generalLedgerElement->appendChild($this->createNodeWithTextContent('type', $generalLedger->getTypeToCode())); + + $financials = $generalLedger->getFinancials(); + + $financialsElement = $this->createElement('financials'); + $generalLedgerElement->appendChild($financialsElement); + + $financialsElement->appendChild($this->createNodeWithTextContent('accounttype', $financials->getAccountType())); + $financialsElement->appendChild($this->createNodeWithTextContent('matchtype', $financials->getMatchType())); + $financialsElement->appendChild($this->createNodeWithTextContent('subanalyse', $financials->getSubAnalyse())); + $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $financials->getVatCodeToCode())); + + $childValidations = $financials->getChildValidations(); + + if (!empty($childValidations)) { + // Make childvalidations element + $childValidationsElement = $this->createElement('childvalidations'); + $financialsElement->appendChild($childValidationsElement); + + // Go through each childvalidation assigned to the general ledger financials + foreach ($childValidations as $childValidation) { + // Make childvalidation element + $childValidationsElement->appendChild($this->createNodeWithTextContent('childvalidation', $childValidation->getElementValue(), $childValidation, array('level' => 'getLevel', 'type' => 'getType'))); + } + } + + $group = $generalLedger->getGroupToCode(); + + if (!empty($group)) { + $groupsElement = $this->createElement('groups'); + $groupsElement->appendChild($this->createNodeWithTextContent('group', $group)); + $generalLedgerElement->appendChild($groupsElement); + } + } +} diff --git a/src/DomDocuments/InvoicesDocument.php b/src/DomDocuments/InvoicesDocument.php index ad6a9274..a59b53b5 100644 --- a/src/DomDocuments/InvoicesDocument.php +++ b/src/DomDocuments/InvoicesDocument.php @@ -1,18 +1,18 @@ - * @copyright (c) 2013, Pronamic - * @version 0.0.1 + * @author Willem van de Sande , extended by Yannick Aerssens */ class InvoicesDocument extends BaseDocument { @@ -24,115 +24,101 @@ final protected function getRootTagName(): string /** * Turns a passed Invoice class into the required markup for interacting * with Twinfield. - * - * This method doesn't return anything, instead just adds the invoice - * to this DOMDocument instance for submission usage. - * + * + * This method doesn't return anything, instead just adds the Invoice to + * this DOMDOcument instance for submission usage. + * * @access public * @param Invoice $invoice + * @param AuthenticatedConnection $connection * @return void | [Adds to this instance] */ - public function addInvoice(Invoice $invoice) + public function addInvoice(Invoice $invoice, $connection) { - // Make a new element $invoiceElement = $this->createElement('salesinvoice'); + $this->rootElement->appendChild($invoiceElement); - // Makes a child header element + // Make header element $headerElement = $this->createElement('header'); $invoiceElement->appendChild($headerElement); - - // Set customer element - $customer = $invoice->getCustomer(); - - // - $customerNode = $this->createTextNode($customer->getCode()); - $customerElement = $this->createElement('customer'); - $customerElement->appendChild($customerNode); - $headerElement->appendChild($customerElement); - - // Elements and their associated methods for invoice - $headerTags = array( - 'office' => 'getOffice', - 'invoicetype' => 'getInvoiceType', - 'invoicenumber' => 'getInvoiceNumber', - 'status' => 'getStatus', - 'currency' => 'getCurrency', - 'period' => 'getPeriod', - 'invoicedate' => 'getInvoiceDate', - 'duedate' => 'getDueDate', - 'bank' => 'getBank', - 'invoiceaddressnumber' => 'getInvoiceAddressNumber', - 'deliveraddressnumber' => 'getDeliverAddressNumber', - 'headertext' => 'getHeaderText', - 'footertext' => 'getFooterText' - ); - - // Go through each element and use the assigned method - foreach ($headerTags as $tag => $method) { - - $value = $this->getValueFromCallback([$invoice, $method]); - - if(null !== $value) { - // Make text node for method value - $node = $this->createTextNode($value); - - // Make the actual element and assign the node - $element = $this->createElement($tag); - $element->appendChild($node); - - // Add the full element - $headerElement->appendChild($element); - } + + $calculateOnly = $invoice->getCalculateOnly(); + + if (!empty($calculateOnly)) { + $headerElement->setAttribute('calculateonly', $calculateOnly); } - // Add orders - $linesElement = $this->createElement('lines'); - $invoiceElement->appendChild($linesElement); - - // Elements and their associated methods for lines - $lineTags = array( - 'quantity' => 'getQuantity', - 'article' => 'getArticle', - 'subarticle' => 'getSubArticle', - 'description' => 'getDescription', - 'unitspriceexcl' => 'getUnitsPriceExcl', - 'units' => 'getUnits', - 'vatcode' => 'getVatCode', - 'freetext1' => 'getFreeText1', - 'freetext2' => 'getFreeText2', - 'freetext3' => 'getFreeText3', - 'performancedate' => 'getPerformanceDate', - 'performancetype' => 'getPerformanceType', - 'dim1' => 'getDim1', - ); - - // Loop through all orders, and add those elements - foreach ($invoice->getLines() as $line) { - - // Make a new line element, and add to - $lineElement = $this->createElement('line'); - $lineElement->setAttribute('id', $line->getID()); - $linesElement->appendChild($lineElement); - - // Go through each element and use the assigned method - foreach ($lineTags as $tag => $method) { - - // Make text node for method value - $node = $this->createTextNode($this->getValueFromCallback([$line, $method])); - - if ($node->textContent === "") { - continue; + $raiseWarning = $invoice->getRaiseWarning(); + + if (!empty($raiseWarning)) { + $headerElement->setAttribute('raisewarning', $raiseWarning); + } + + $headerElement->appendChild($this->createNodeWithTextContent('bank', $invoice->getBankToCode())); + $headerElement->appendChild($this->createNodeWithTextContent('currency', $invoice->getCurrencyToCode())); + $headerElement->appendChild($this->createNodeWithTextContent('customer', $invoice->getCustomerToCode())); + $headerElement->appendChild($this->createNodeWithTextContent('deliveraddressnumber', $invoice->getDeliverAddressNumber())); + $headerElement->appendChild($this->createNodeWithTextContent('duedate', $invoice->getDueDateToString())); + $headerElement->appendChild($this->createNodeWithTextContent('footertext', $invoice->getFooterText())); + $headerElement->appendChild($this->createNodeWithTextContent('headertext', $invoice->getHeaderText())); + $headerElement->appendChild($this->createNodeWithTextContent('invoiceaddressnumber', $invoice->getInvoiceAddressNumber())); + $headerElement->appendChild($this->createNodeWithTextContent('invoicedate', $invoice->getInvoiceDateToString())); + $headerElement->appendChild($this->createNodeWithTextContent('invoicenumber', $invoice->getInvoiceNumber())); + $headerElement->appendChild($this->createNodeWithTextContent('invoicetype', $invoice->getInvoiceTypeToCode())); + $headerElement->appendChild($this->createNodeWithTextContent('office', $invoice->getOfficeToCode())); + $headerElement->appendChild($this->createNodeWithTextContent('paymentmethod', $invoice->getPaymentMethod())); + $headerElement->appendChild($this->createNodeWithTextContent('period', $invoice->getPeriod())); + $headerElement->appendChild($this->createNodeWithTextContent('status', $invoice->getStatus())); + + $invoiceTypeApiConnector = new \PhpTwinfield\ApiConnectors\InvoiceTypeApiConnector($connection); + $invoiceVatType = $invoiceTypeApiConnector->getInvoiceTypeVatType('FACTUUR'); + + $articleApiConnector = new \PhpTwinfield\ApiConnectors\ArticleApiConnector($connection); + + $lines = $invoice->getLines(); + + if (!empty($lines)) { + // Make lines element + $linesElement = $this->createElement('lines'); + $invoiceElement->appendChild($linesElement); + + // Go through each line assigned to the invoice + foreach ($lines as $line) { + // Makes new line element + $lineElement = $this->createElement('line'); + $linesElement->appendChild($lineElement); + + $id = $line->getID(); + + if (!empty($id)) { + $lineElement->setAttribute('id', $id); + } + + $lineElement->appendChild($this->createNodeWithTextContent('allowdiscountorpremium', $line->getAllowDiscountOrPremiumToString())); + $lineElement->appendChild($this->createNodeWithTextContent('article', $line->getArticleToCode())); + $lineElement->appendChild($this->createNodeWithTextContent('description', $line->getDescription())); + $lineElement->appendChild($this->createNodeWithTextContent('dim1', $line->getDim1ToCode())); + $lineElement->appendChild($this->createNodeWithTextContent('freetext1', $line->getFreeText1())); + $lineElement->appendChild($this->createNodeWithTextContent('freetext2', $line->getFreeText2())); + $lineElement->appendChild($this->createNodeWithTextContent('freetext3', $line->getFreeText3())); + $lineElement->appendChild($this->createNodeWithTextContent('performancedate', $line->getPerformanceDateToString())); + $lineElement->appendChild($this->createNodeWithTextContent('performancetype', $line->getPerformanceType())); + $lineElement->appendChild($this->createNodeWithTextContent('quantity', $line->getQuantity())); + $lineElement->appendChild($this->createNodeWithTextContent('subarticle', $line->getSubArticleToSubCode())); + $lineElement->appendChild($this->createNodeWithTextContent('units', $line->getUnits())); + + if ($invoiceVatType == 'inclusive') { + $lineElement->appendChild($this->createNodeWithTextContent('unitspriceinc', $line->getUnitsPriceIncToFloat())); + } else { + $lineElement->appendChild($this->createNodeWithTextContent('unitspriceexcl', $line->getUnitsPriceExclToFloat())); } - // Make the actual element with tag - $element = $this->createElement($tag); - $element->appendChild($node); + $article = $articleApiConnector->get($line->getArticleToCode(), $invoice->getOffice()); - // Add the full element - $lineElement->appendChild($element); + if ($article->getAllowChangeVatCode == true) { + $lineElement->appendChild($this->createNodeWithTextContent('vatcode', $line->getVatCodeToCode())); + } } } - - $this->rootElement->appendChild($invoiceElement); } -} +} \ No newline at end of file diff --git a/src/DomDocuments/ProjectsDocument.php b/src/DomDocuments/ProjectsDocument.php new file mode 100644 index 00000000..eae6beed --- /dev/null +++ b/src/DomDocuments/ProjectsDocument.php @@ -0,0 +1,107 @@ + + */ +class ProjectsDocument extends BaseDocument +{ + final protected function getRootTagName(): string + { + return "dimensions"; + } + + /** + * Turns a passed Project class into the required markup for interacting + * with Twinfield. + * + * This method doesn't return anything, instead just adds the Project to + * this DOMDOcument instance for submission usage. + * + * @access public + * @param Project $project + * @return void | [Adds to this instance] + */ + public function addProject(Project $project) + { + $projectElement = $this->createElement('dimension'); + $this->rootElement->appendChild($projectElement); + + $status = $project->getStatus(); + + if (!empty($status)) { + $projectElement->setAttribute('status', $status); + } + + $projectElement->appendChild($this->createNodeWithTextContent('code', $project->getCode())); + $projectElement->appendChild($this->createNodeWithTextContent('name', $project->getName())); + $projectElement->appendChild($this->createNodeWithTextContent('office', $project->getOfficeToCode())); + $projectElement->appendChild($this->createNodeWithTextContent('shortname', $project->getShortName())); + $projectElement->appendChild($this->createNodeWithTextContent('type', $project->getTypeToCode())); + + $financialsElement = $this->createElement('financials'); + $projectElement->appendChild($financialsElement); + + $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $project->getVatCodeToCode())); + + $projects = $project->getProjects(); + + $projectsElement = $this->createElement('projects'); + $projectElement->appendChild($projectsElement); + + $inheritArray = array('authoriser' => 'getAuthoriserToCode', 'billable' => 'getBillableToString', 'customer' => 'getCustomerToCode', 'rate' => 'getRateToCode'); + + foreach ($inheritArray as $inheritVar => $method) { + $methodLocked = "get" . ucfirst($inheritVar) . "Locked"; + $methodInherit = "get" . ucfirst($inheritVar) . "Inherit"; + $elementVar = ""; + + if ($projects->$methodLocked() !== true || $projects->$methodInherit() !== true) { + $elementVar = $projects->$method(); + } elseif ($inheritVar == 'billable') { + $projects->setBillableForRatio(false); + } + + $attributesArray = array('locked' => $methodLocked, 'inherit' => $methodInherit); + + if ($inheritVar == 'billable') { + $attributesArray['forratio'] = 'getBillableForRatioToString'; + } + + $projectsElement->appendChild($this->createNodeWithTextContent($inheritVar, $elementVar, $projects, $attributesArray)); + } + + $projectsElement->appendChild($this->createNodeWithTextContent('invoicedescription', $projects->getInvoiceDescription())); + $projectsElement->appendChild($this->createNodeWithTextContent('validfrom', $projects->getValidFromToString())); + $projectsElement->appendChild($this->createNodeWithTextContent('validtill', $projects->getValidTillToString())); + + $quantities = $projects->getQuantities(); + + if (!empty($quantities)) { + // Make quantities element + $quantitiesElement = $this->createElement('quantities'); + $projectsElement->appendChild($quantitiesElement); + + // Go through each quantity assigned to the project project + foreach ($quantities as $quantity) { + // Makes quantity element + $quantityElement = $this->createElement('quantity'); + $quantitiesElement->appendChild($quantityElement); + + $quantityElement->appendChild($this->createNodeWithTextContent('label', $quantity->getLabel())); + $quantityElement->appendChild($this->createNodeWithTextContent('rate', $quantity->getRateToCode())); + $quantityElement->appendChild($this->createNodeWithTextContent('billable', $quantity->getBillableToString(), $quantity, array('locked' => 'getBillableLockedToString'))); + $quantityElement->appendChild($this->createNodeWithTextContent('mandatory', $quantity->getMandatoryToString())); + } + } + } +} \ No newline at end of file diff --git a/src/DomDocuments/RatesDocument.php b/src/DomDocuments/RatesDocument.php new file mode 100644 index 00000000..1c2cac53 --- /dev/null +++ b/src/DomDocuments/RatesDocument.php @@ -0,0 +1,85 @@ + + */ +class RatesDocument extends BaseDocument +{ + final protected function getRootTagName(): string + { + return "projectrates"; + } + + /** + * Turns a passed Rate class into the required markup for interacting + * with Twinfield. + * + * This method doesn't return anything, instead just adds the Rate to + * this DOMDOcument instance for submission usage. + * + * @access public + * @param Rate $rate + * @return void | [Adds to this instance] + */ + public function addRate(Rate $rate) + { + $rateElement = $this->createElement('projectrate'); + $this->rootElement->appendChild($rateElement); + + $status = $rate->getStatus(); + + if (!empty($status)) { + $rateElement->setAttribute('status', $status); + } + + $rateElement->appendChild($this->createNodeWithTextContent('code', $rate->getCode())); + $rateElement->appendChild($this->createNodeWithTextContent('currency', $rate->getCurrencyToCode())); + $rateElement->appendChild($this->createNodeWithTextContent('name', $rate->getName())); + $rateElement->appendChild($this->createNodeWithTextContent('office', $rate->getOfficeToCode())); + $rateElement->appendChild($this->createNodeWithTextContent('shortname', $rate->getShortName())); + $rateElement->appendChild($this->createNodeWithTextContent('type', $rate->getType())); + $rateElement->appendChild($this->createNodeWithTextContent('unit', $rate->getUnit())); + + $rateChanges = $rate->getRateChanges(); + + if (!empty($rateChanges)) { + // Make ratechanges element + $rateChangesElement = $this->createElement('ratechanges'); + $rateElement->appendChild($rateChangesElement); + + // Go through each rate change assigned to the rate + foreach ($rateChanges as $rateChange) { + // Makes ratechange element + $rateChangeElement = $this->createElement('ratechange'); + $rateChangesElement->appendChild($rateChangeElement); + + $id = $rateChange->getID(); + + if (!empty($id)) { + $rateChangeElement->setAttribute('id', $id); + } + + $status = $rateChange->getStatus(); + + if (!empty($status)) { + $rateChangeElement->setAttribute('status', $status); + } + + $rateChangeElement->appendChild($this->createNodeWithTextContent('begindate', $rateChange->getBeginDateToString())); + $rateChangeElement->appendChild($this->createNodeWithTextContent('enddate', $rateChange->getEndDateToString())); + $rateChangeElement->appendChild($this->createNodeWithTextContent('externalrate', $rateChange->getExternalRate())); + $rateChangeElement->appendChild($this->createNodeWithTextContent('internalrate', $rateChange->getInternalRate())); + } + } + } +} diff --git a/src/DomDocuments/SuppliersDocument.php b/src/DomDocuments/SuppliersDocument.php index 5f35dab5..f15d5705 100644 --- a/src/DomDocuments/SuppliersDocument.php +++ b/src/DomDocuments/SuppliersDocument.php @@ -4,43 +4,27 @@ use PhpTwinfield\Supplier; /** - * The Document Holder for making new XML customers. Is a child class + * The Document Holder for making new XML Supplier. Is a child class * of DOMDocument and makes the required DOM tree for the interaction in - * creating a new customer. + * creating a new Supplier. * * @package PhpTwinfield * @subpackage Invoice\DOM - * @author Leon Rowland + * @author Leon Rowland , extended by Yannick Aerssens * @copyright (c) 2013, Pronamic */ -class SuppliersDocument extends \DOMDocument +class SuppliersDocument extends BaseDocument { - /** - * Holds the element - * that all additional elements should be a child of - * @var \DOMElement - */ - private $dimensionElement; - - /** - * Creates the element and adds it to the property - * dimensionElement - * - * @access public - */ - public function __construct() + final protected function getRootTagName(): string { - parent::__construct('1.0', 'UTF-8'); - - $this->dimensionElement = $this->createElement('dimension'); - $this->appendChild($this->dimensionElement); + return "dimensions"; } /** * Turns a passed Supplier class into the required markup for interacting * with Twinfield. * - * This method doesn't return anything, instead just adds the invoice to + * This method doesn't return anything, instead just adds the Supplier to * this DOMDOcument instance for submission usage. * * @access public @@ -49,190 +33,230 @@ public function __construct() */ public function addSupplier(Supplier $supplier) { - // Elements and their associated methods for customer - $supplierTags = array( - 'code' => 'getCode', - 'name' => 'getName', - 'type' => 'getType', - 'website' => 'getWebsite', - 'office' => 'getOffice', - ); - - if ($supplier->getOffice()) { - $supplierTags['office'] = 'getOffice'; - } + $supplierElement = $this->createElement('dimension'); + $this->rootElement->appendChild($supplierElement); $status = $supplier->getStatus(); - if (!empty($status)) { - $this->dimensionElement->setAttribute('status', $status); - } - - // Go through each customer element and use the assigned method - foreach ($supplierTags as $tag => $method) { - - // Make text node for method value - $node = $this->createTextNode($supplier->$method()); - - // Make the actual element and assign the node - $element = $this->createElement($tag); - $element->appendChild($node); - // Add the full element - $this->dimensionElement->appendChild($element); + if (!empty($status)) { + $supplierElement->setAttribute('status', $status); } - // Check if the financial information should be supplied - if ($supplier->getDueDays() > 0) { - - // Financial elements and their methods - $financialsTags = array( - 'duedays' => 'getDueDays', - 'payavailable' => 'getPayAvailable', - 'paycode' => 'getPayCode', - 'vatcode' => 'getVatCode', - 'ebilling' => 'getEBilling', - 'ebillmail' => 'getEBillMail' - ); - - // Make the financial element - $financialElement = $this->createElement('financials'); - $this->dimensionElement->appendChild($financialElement); - - // Go through each financial element and use the assigned method - foreach ($financialsTags as $tag => $method) { - - // Make the text node for the method value - $nodeValue = $supplier->$method(); - if (is_bool($nodeValue)) { - $nodeValue = ($nodeValue) ? 'true' : 'false'; - } - $node = $this->createTextNode($nodeValue); - - // Make the actual element and assign the node - $element = $this->createElement($tag); - $element->appendChild($node); - - // Add the full element - $financialElement->appendChild($element); + $supplierElement->appendChild($this->createNodeWithTextContent('beginperiod', $supplier->getBeginPeriod())); + $supplierElement->appendChild($this->createNodeWithTextContent('beginyear', $supplier->getBeginYear())); + $supplierElement->appendChild($this->createNodeWithTextContent('code', $supplier->getCode())); + $supplierElement->appendChild($this->createNodeWithTextContent('endperiod', $supplier->getEndPeriod())); + $supplierElement->appendChild($this->createNodeWithTextContent('endyear', $supplier->getEndYear())); + $supplierElement->appendChild($this->createNodeWithTextContent('name', $supplier->getName())); + $supplierElement->appendChild($this->createNodeWithTextContent('office', $supplier->getOfficeToCode())); + $supplierElement->appendChild($this->createNodeWithTextContent('shortname', $supplier->getShortName())); + $supplierElement->appendChild($this->createNodeWithTextContent('type', $supplier->getTypeToCode())); + $supplierElement->appendChild($this->createNodeWithTextContent('website', $supplier->getWebsite())); + + $financials = $supplier->getFinancials(); + + $financialsElement = $this->createElement('financials'); + $supplierElement->appendChild($financialsElement); + + $financialsElement->appendChild($this->createNodeWithTextContent('duedays', $financials->getDueDays())); + $financialsElement->appendChild($this->createNodeWithTextContent('meansofpayment', $financials->getMeansOfPayment())); + $financialsElement->appendChild($this->createNodeWithTextContent('payavailable', $financials->getPayAvailableToString())); + $financialsElement->appendChild($this->createNodeWithTextContent('paycode', $financials->getPayCodeToCode())); + $financialsElement->appendChild($this->createNodeWithTextContent('relationsreference', $financials->getRelationsReference())); + $financialsElement->appendChild($this->createNodeWithTextContent('substitutewith', $financials->getSubstituteWithToCode())); + $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $financials->getVatCodeToCode())); + + $childValidations = $financials->getChildValidations(); + + if (!empty($childValidations)) { + // Make childvalidations element + $childValidationsElement = $this->createElement('childvalidations'); + $financialsElement->appendChild($childValidationsElement); + + // Go through each childvalidation assigned to the supplier financials + foreach ($childValidations as $childValidation) { + // Make childvalidation element + $childValidationsElement->appendChild($this->createNodeWithTextContent('childvalidation', $childValidation->getElementValue(), $childValidation, array('level' => 'getLevel', 'type' => 'getType'))); } } - $addresses = $supplier->getAddresses(); - if (!empty($addresses)) { - - // Address elements and their methods - $addressTags = array( - 'name' => 'getName', - 'contact' => 'getContact', - 'country' => 'getCountry', - 'city' => 'getCity', - 'postcode' => 'getPostcode', - 'telephone' => 'getTelephone', - 'telefax' => 'getFax', - 'email' => 'getEmail', - 'field1' => 'getField1', - 'field2' => 'getField2', - 'field3' => 'getField3', - 'field4' => 'getField4', - 'field5' => 'getField5', - 'field6' => 'getField6' - ); + if (!empty($addresses)) { // Make addresses element $addressesElement = $this->createElement('addresses'); - $this->dimensionElement->appendChild($addressesElement); + $supplierElement->appendChild($addressesElement); - // Go through each address assigned to the customer + // Go through each address assigned to the supplier foreach ($addresses as $address) { - - // Makes new address element + // Make address element $addressElement = $this->createElement('address'); $addressesElement->appendChild($addressElement); - // Set attributes - $addressElement->setAttribute('default', $address->getDefault()); - $addressElement->setAttribute('type', $address->getType()); + $default = $address->getDefaultToString(); - // Go through each address element and use the assigned method - foreach ($addressTags as $tag => $method) { + if (!empty($default)) { + $addressElement->setAttribute('default', $default); + } - // Make the text node for the method value - $node = $this->createTextNode($address->$method()); + $id = $address->getID(); - // Make the actual element and assign the text node - $element = $this->createElement($tag); - $element->appendChild($node); + if (!empty($id)) { + $addressElement->setAttribute('id', $id); + } - // Add the completed element - $addressElement->appendChild($element); + $type = $address->getType(); + + if (!empty($type)) { + $addressElement->setAttribute('type', $type); } + + $addressElement->appendChild($this->createNodeWithTextContent('city', $address->getCity())); + $addressElement->appendChild($this->createNodeWithTextContent('country', $address->getCountryToCode())); + $addressElement->appendChild($this->createNodeWithTextContent('email', $address->getEmail())); + $addressElement->appendChild($this->createNodeWithTextContent('field1', $address->getField1())); + $addressElement->appendChild($this->createNodeWithTextContent('field2', $address->getField2())); + $addressElement->appendChild($this->createNodeWithTextContent('field3', $address->getField3())); + $addressElement->appendChild($this->createNodeWithTextContent('field4', $address->getField4())); + $addressElement->appendChild($this->createNodeWithTextContent('field5', $address->getField5())); + $addressElement->appendChild($this->createNodeWithTextContent('field6', $address->getField6())); + $addressElement->appendChild($this->createNodeWithTextContent('name', $address->getName())); + $addressElement->appendChild($this->createNodeWithTextContent('postcode', $address->getPostcode())); + $addressElement->appendChild($this->createNodeWithTextContent('telefax', $address->getTelefax())); + $addressElement->appendChild($this->createNodeWithTextContent('telephone', $address->getTelephone())); } } $banks = $supplier->getBanks(); - if (!empty($banks)) { - - // Bank elements and their methods - $bankTags = array( - 'ascription' => 'getAscription', - 'accountnumber' => 'getAccountnumber', - 'bankname' => 'getBankname', - 'biccode' => 'getBiccode', - 'city' => 'getCity', - 'country' => 'getCountry', - 'iban' => 'getIban', - 'natbiccode' => 'getNatbiccode', - 'postcode' => 'getPostcode', - 'state' => 'getState' - ); + if (!empty($banks)) { // Make banks element $banksElement = $this->createElement('banks'); - $this->dimensionElement->appendChild($banksElement); + $supplierElement->appendChild($banksElement); - // Go through each bank assigned to the customer + // Go through each bank assigned to the supplier foreach ($banks as $bank) { - - // Makes new bank element + // Make bank element $bankElement = $this->createElement('bank'); $banksElement->appendChild($bankElement); - // Set attributes - $bankElement->setAttribute('default', $bank->getDefault()); + $blocked = $bank->getBlockedToString(); - // Go through each bank element and use the assigned method - foreach ($bankTags as $tag => $method) { + if (!empty($blocked)) { + $bankElement->setAttribute('blocked', $blocked); + } - // Make the text node for the method value - $node = $this->createTextNode($bank->$method()); + $default = $bank->getDefaultToString(); - // Make the actual element and assign the text node - $element = $this->createElement($tag); - $element->appendChild($node); + if (!empty($default)) { + $bankElement->setAttribute('default', $default); + } + + $id = $bank->getID(); - // Add the completed element - $bankElement->appendChild($element); + if (!empty($id)) { + $bankElement->setAttribute('id', $id); } - // Bank address fields + $bankAddressElement = $this->createElement('address'); + $bankAddressElement->appendChild($this->createNodeWithTextContent('field2', $bank->getField2())); + $bankAddressElement->appendChild($this->createNodeWithTextContent('field3', $bank->getField3())); + $bankElement->appendChild($bankAddressElement); + + $bankElement->appendChild($this->createNodeWithTextContent('ascription', $bank->getAscription())); + $bankElement->appendChild($this->createNodeWithTextContent('accountnumber', $bank->getAccountNumber())); + $bankElement->appendChild($this->createNodeWithTextContent('bankname', $bank->getBankName())); + $bankElement->appendChild($this->createNodeWithTextContent('biccode', $bank->getBicCode())); + $bankElement->appendChild($this->createNodeWithTextContent('city', $bank->getCity())); + $bankElement->appendChild($this->createNodeWithTextContent('country', $bank->getCountryToCode())); + $bankElement->appendChild($this->createNodeWithTextContent('iban', $bank->getIban())); + $bankElement->appendChild($this->createNodeWithTextContent('natbiccode', $bank->getNatBicCode())); + $bankElement->appendChild($this->createNodeWithTextContent('postcode', $bank->getPostcode())); + $bankElement->appendChild($this->createNodeWithTextContent('state', $bank->getState())); + } + } + + $remittanceAdviceElement = $this->createElement('remittanceadvice'); + $supplierElement->appendChild($remittanceAdviceElement); - // Make the text nodes for the bank address fields - $field2Node = $this->createTextNode($bank->getAddressField2()); - $field3Node = $this->createTextNode($bank->getAddressField3()); + $remittanceAdviceElement->appendChild($this->createNodeWithTextContent('sendmail', $supplier->getRemittanceAdviceSendMail())); + $remittanceAdviceElement->appendChild($this->createNodeWithTextContent('sendtype', $supplier->getRemittanceAdviceSendType())); - // Make the actual elements and assign the text nodes - $field2Element = $this->createElement('field2'); - $field3Element = $this->createElement('field3'); - $field2Element->appendChild($field2Node); - $field3Element->appendChild($field3Node); + $group = $supplier->getGroupToCode(); - // Combine the fields in an address element and add that to the bank element - $addressElement = $this->createElement('address'); - $addressElement->appendChild($field2Element); - $addressElement->appendChild($field3Element); - $bankElement->appendChild($addressElement); + if (!empty($group)) { + $groupsElement = $this->createElement('groups'); + $groupsElement->appendChild($this->createNodeWithTextContent('group', $group)); + $supplierElement->appendChild($groupsElement); + } + + $postingRules = $supplier->getPostingRules(); + + if (!empty($postingRules)) { + // Make postingrules element + $postingRulesElement = $this->createElement('postingrules'); + $supplierElement->appendChild($postingRulesElement); + + // Go through each posting rule assigned to the supplier + foreach ($postingRules as $postingRule) { + // Make postingrule element + $postingRuleElement = $this->createElement('postingrule'); + $postingRulesElement->appendChild($postingRuleElement); + + $id = $postingRule->getID(); + + if (!empty($id)) { + $postingRuleElement->setAttribute('id', $id); + } + + $status = $postingRule->getStatus(); + + if (!empty($status)) { + $postingRuleElement->setAttribute('status', $status); + } + + $postingRuleElement->appendChild($this->createNodeWithTextContent('amount', $postingRule->getAmountToFloat())); + $postingRuleElement->appendChild($this->createNodeWithTextContent('currency', $postingRule->getCurrencyToCode())); + $postingRuleElement->appendChild($this->createNodeWithTextContent('description', $postingRule->getDescription())); + + $postingRuleLines = $postingRule->getLines(); + + if (!empty($postingRuleLines)) { + // Make lines element + $postingRuleLinesElement = $this->createElement('lines'); + $postingRuleElement->appendChild($postingRuleLinesElement); + + // Go through each line assigned to the supplier posting rule + foreach ($postingRuleLines as $postingRuleLine) { + // Make line element + $postingRuleLineElement = $this->createElement('line'); + $postingRuleLinesElement->appendChild($postingRuleLineElement); + + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension1', $postingRuleLine->getDimension1ToCode())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension2', $postingRuleLine->getDimension2ToCode())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension3', $postingRuleLine->getDimension3ToCode())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('description', $postingRuleLine->getDescription())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('office', $postingRuleLine->getOfficeToCode())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('ratio', $postingRuleLine->getRatio())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('vatcode', $postingRuleLine->getVatCodeToCode())); + } + } } } + + $paymentconditionsElement = $this->createElement('paymentconditions'); + $supplierElement->appendChild($paymentconditionsElement); + + $paymentconditionElement = $this->createElement('paymentcondition'); + $paymentconditionsElement->appendChild($paymentconditionElement); + + $paymentconditionElement->appendChild($this->createNodeWithTextContent('discountdays', $supplier->getPaymentConditionDiscountDays())); + $paymentconditionElement->appendChild($this->createNodeWithTextContent('discountpercentage', $supplier->getPaymentConditionDiscountPercentage())); + + $blockedAccountPaymentConditionsElement = $this->createElement('blockedaccountpaymentconditions'); + $supplierElement->appendChild($blockedAccountPaymentConditionsElement); + + $blockedAccountPaymentConditionsElement->appendChild($this->createNodeWithTextContent('includevat', $supplier->getBlockedAccountPaymentConditionsIncludeVat())); + $blockedAccountPaymentConditionsElement->appendChild($this->createNodeWithTextContent('percentage', $supplier->getBlockedAccountPaymentConditionsPercentage())); } } diff --git a/src/DomDocuments/VatCodesDocument.php b/src/DomDocuments/VatCodesDocument.php new file mode 100644 index 00000000..ea924e43 --- /dev/null +++ b/src/DomDocuments/VatCodesDocument.php @@ -0,0 +1,96 @@ + + */ +class VatCodesDocument extends BaseDocument +{ + final protected function getRootTagName(): string + { + return "vat"; + } + + /** + * Turns a passed VatCode class into the required markup for interacting + * with Twinfield. + * + * This method doesn't return anything, instead just adds the VatCode to + * this DOMDOcument instance for submission usage. + * + * @access public + * @param VatCode $vatCode + * @return void | [Adds to this instance] + */ + public function addVatCode(VatCode $vatCode) + { + $vatCodeElement = $this->rootElement; + + $status = $vatCode->getStatus(); + + if (!empty($status)) { + $vatCodeElement->setAttribute('status', $status); + } + + $vatCodeElement->appendChild($this->createNodeWithTextContent('code', $vatCode->getCode())); + $vatCodeElement->appendChild($this->createNodeWithTextContent('name', $vatCode->getName())); + $vatCodeElement->appendChild($this->createNodeWithTextContent('shortname', $vatCode->getShortName())); + $vatCodeElement->appendChild($this->createNodeWithTextContent('type', $vatCode->getType())); + + $percentages = $vatCode->getPercentages(); + + if (!empty($percentages)) { + // Make percentages element + $percentagesElement = $this->createElement('percentages'); + $vatCodeElement->appendChild($percentagesElement); + + // Go through each percentage assigned to the vatCode + foreach ($percentages as $percentage) { + // Makes percentage element + $percentageElement = $this->createElement('percentage'); + $percentagesElement->appendChild($percentageElement); + + $percentageElement->appendChild($this->createNodeWithTextContent('date', $percentage->getDateToString())); + $percentageElement->appendChild($this->createNodeWithTextContent('name', $percentage->getName())); + $percentageElement->appendChild($this->createNodeWithTextContent('percentage', $percentage->getPercentage())); + $percentageElement->appendChild($this->createNodeWithTextContent('shortname', $percentage->getShortName())); + + $accounts = $percentage->getAccounts(); + + if (!empty($accounts)) { + // Make accounts element + $accountsElement = $this->createElement('accounts'); + $percentageElement->appendChild($accountsElement); + + // Go through each account assigned to the vat code percentage + foreach ($accounts as $account) { + // Makes account element + $accountElement = $this->createElement('account'); + $accountsElement->appendChild($accountElement); + + $id = $account->getID(); + + if (!empty($id)) { + $accountElement->setAttribute('id', $id); + } + + $accountElement->appendChild($this->createNodeWithTextContent('dim1', $account->getDim1ToCode())); + $accountElement->appendChild($this->createNodeWithTextContent('group', $account->getGroupToCode())); + $accountElement->appendChild($this->createNodeWithTextContent('groupcountry', $account->getGroupCountryToCode())); + $accountElement->appendChild($this->createNodeWithTextContent('linetype', $account->getLineType())); + $accountElement->appendChild($this->createNodeWithTextContent('percentage', $account->getPercentage())); + } + } + } + } + } +} From 12cc62855cd08eb9015f7bb69a5b92db23a9da1b Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:24:50 +0200 Subject: [PATCH 052/388] Add files via upload --- src/ApiConnectors/ActivityApiConnector.php | 126 +++++++++++++++++ src/ApiConnectors/ArticleApiConnector.php | 48 +++++-- src/ApiConnectors/AssetMethodApiConnector.php | 125 +++++++++++++++++ src/ApiConnectors/BaseApiConnector.php | 71 +++++++++- .../CashBankBookApiConnector.php | 52 +++++++ src/ApiConnectors/CostCenterApiConnector.php | 126 +++++++++++++++++ src/ApiConnectors/CountryApiConnector.php | 52 +++++++ src/ApiConnectors/CurrencyApiConnector.php | 129 ++++++++++++++++++ src/ApiConnectors/CustomerApiConnector.php | 101 +++++++------- .../DimensionGroupApiConnector.php | 125 +++++++++++++++++ .../DimensionTypeApiConnector.php | 125 +++++++++++++++++ src/ApiConnectors/FixedAssetApiConnector.php | 125 +++++++++++++++++ .../GeneralLedgerApiConnector.php | 126 +++++++++++++++++ src/ApiConnectors/InvoiceApiConnector.php | 55 ++++++-- src/ApiConnectors/InvoiceTypeApiConnector.php | 86 ++++++++++++ src/ApiConnectors/OfficeApiConnector.php | 51 ++++--- src/ApiConnectors/PayCodeApiConnector.php | 52 +++++++ src/ApiConnectors/ProjectApiConnector.php | 126 +++++++++++++++++ src/ApiConnectors/RateApiConnector.php | 125 +++++++++++++++++ src/ApiConnectors/SupplierApiConnector.php | 118 +++++++--------- src/ApiConnectors/TransactionApiConnector.php | 2 +- src/ApiConnectors/UserApiConnector.php | 94 +++++++++++-- src/ApiConnectors/UserRoleApiConnector.php | 52 +++++++ src/ApiConnectors/VatCodeApiConnector.php | 98 +++++++++++-- src/ApiConnectors/VatGroupApiConnector.php | 52 +++++++ 25 files changed, 2056 insertions(+), 186 deletions(-) create mode 100644 src/ApiConnectors/ActivityApiConnector.php create mode 100644 src/ApiConnectors/AssetMethodApiConnector.php create mode 100644 src/ApiConnectors/CashBankBookApiConnector.php create mode 100644 src/ApiConnectors/CostCenterApiConnector.php create mode 100644 src/ApiConnectors/CountryApiConnector.php create mode 100644 src/ApiConnectors/CurrencyApiConnector.php create mode 100644 src/ApiConnectors/DimensionGroupApiConnector.php create mode 100644 src/ApiConnectors/DimensionTypeApiConnector.php create mode 100644 src/ApiConnectors/FixedAssetApiConnector.php create mode 100644 src/ApiConnectors/GeneralLedgerApiConnector.php create mode 100644 src/ApiConnectors/InvoiceTypeApiConnector.php create mode 100644 src/ApiConnectors/PayCodeApiConnector.php create mode 100644 src/ApiConnectors/ProjectApiConnector.php create mode 100644 src/ApiConnectors/RateApiConnector.php create mode 100644 src/ApiConnectors/UserRoleApiConnector.php create mode 100644 src/ApiConnectors/VatGroupApiConnector.php diff --git a/src/ApiConnectors/ActivityApiConnector.php b/src/ApiConnectors/ActivityApiConnector.php new file mode 100644 index 00000000..393165e7 --- /dev/null +++ b/src/ApiConnectors/ActivityApiConnector.php @@ -0,0 +1,126 @@ + + */ +class ActivityApiConnector extends BaseApiConnector +{ + /** + * Requests a specific Activity based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return Activity|bool The requested activity or false if it can't be found. + * @throws Exception + */ + public function get(string $code, Office $office): Activity + { + // Make a request to read a single Activity. Set the required values + $request_activity = new Request\Read\Activity(); + $request_activity + ->setOffice($office->getCode()) + ->setCode($code); + + // Send the Request document and set the response to this instance. + $response = $this->sendXmlDocument($request_activity); + + return ActivityMapper::map($response); + } + + /** + * Sends a Activity instance to Twinfield to update or add. + * + * @param Activity $activity + * @return Activity + * @throws Exception + */ + public function send(Activity $activity): Activity + { + foreach($this->sendAll([$activity]) as $each) { + return $each->unwrap(); + } + } + + /** + * @param Activity[] $activities + * @return MappedResponseCollection + * @throws Exception + */ + public function sendAll(array $activities): MappedResponseCollection + { + Assert::allIsInstanceOf($activities, Activity::class); + + /** @var Response[] $responses */ + $responses = []; + + foreach ($this->getProcessXmlService()->chunk($activities) as $chunk) { + + $activitiesDocument = new ActivitiesDocument(); + + foreach ($chunk as $activity) { + $activitiesDocument->addActivity($activity); + } + + $responses[] = $this->sendXmlDocument($activitiesDocument); + } + + return $this->getProcessXmlService()->mapAll($responses, "dimension", function(Response $response): Activity { + return ActivityMapper::map($response); + }); + } + + /** + * List all activities. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return Activity[] The activities found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $forcedOptions['dimtype'] = "ACT"; + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options, $forcedOptions); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_DIMENSIONS_PROJECTS, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $activityArrayListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); + + return $this->mapListAll("Activity", $response->data, $activityArrayListAllTags); + } +} \ No newline at end of file diff --git a/src/ApiConnectors/ArticleApiConnector.php b/src/ApiConnectors/ArticleApiConnector.php index b825dbaa..62bbbe0d 100644 --- a/src/ApiConnectors/ArticleApiConnector.php +++ b/src/ApiConnectors/ArticleApiConnector.php @@ -10,6 +10,7 @@ use PhpTwinfield\Request as Request; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; +use PhpTwinfield\Services\FinderService; use Webmozart\Assert\Assert; /** @@ -19,7 +20,7 @@ * If you require more complex interactions or a heavier amount of control over the requests to/from then look inside * the methods or see the advanced guide detailing the required usages. * - * @author Willem van de Sande + * @author Willem van de Sande , extended by Yannick Aerssens */ class ArticleApiConnector extends BaseApiConnector { @@ -55,12 +56,8 @@ public function get(string $code, Office $office): Article */ public function send(Article $article): Article { - $articleResponses = $this->sendAll([$article]); - - Assert::count($articleResponses, 1); - - foreach ($articleResponses as $articleResponse) { - return $articleResponse->unwrap(); + foreach($this->sendAll([$article]) as $each) { + return $each->unwrap(); } } @@ -77,7 +74,6 @@ public function sendAll(array $articles): MappedResponseCollection $responses = []; foreach ($this->getProcessXmlService()->chunk($articles) as $chunk) { - $articlesDocument = new ArticlesDocument(); foreach ($chunk as $article) { @@ -91,4 +87,38 @@ public function sendAll(array $articles): MappedResponseCollection return ArticleMapper::map($response); }); } -} + + /** + * List all articles. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return Article[] The articles found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_ITEMS, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $articleArrayListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); + + return $this->mapListAll("Article", $response->data, $articleArrayListAllTags); + } +} \ No newline at end of file diff --git a/src/ApiConnectors/AssetMethodApiConnector.php b/src/ApiConnectors/AssetMethodApiConnector.php new file mode 100644 index 00000000..ead16b6d --- /dev/null +++ b/src/ApiConnectors/AssetMethodApiConnector.php @@ -0,0 +1,125 @@ + + */ +class AssetMethodApiConnector extends BaseApiConnector +{ + /** + * Requests a specific AssetMethod based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return AssetMethod|bool The requested asset method or false if it can't be found. + * @throws Exception + */ + public function get(string $code, Office $office): AssetMethod + { + // Make a request to read a single AssetMethod. Set the required values + $request_assetMethod = new Request\AssetMethod(); + $request_assetMethod + ->setOffice($office->getCode()) + ->setCode($code); + + // Send the Request document and set the response to this instance. + $response = $this->sendXmlDocument($request_assetMethod); + + return AssetMethodMapper::map($response); + } + + /** + * Sends an AssetMethod instance to Twinfield to update or add. + * + * @param AssetMethod $assetMethod + * @return AssetMethod + * @throws Exception + */ + public function send(AssetMethod $assetMethod): AssetMethod + { + foreach($this->sendAll([$assetMethod]) as $each) { + return $each->unwrap(); + } + } + + /** + * @param AssetMethod[] $assetMethods + * @return MappedResponseCollection + * @throws Exception + */ + public function sendAll(array $assetMethods): MappedResponseCollection + { + Assert::allIsInstanceOf($assetMethods, AssetMethod::class); + + /** @var Response[] $responses */ + $responses = []; + + foreach ($this->getProcessXmlService()->chunk($assetMethods) as $chunk) { + + $assetMethodsDocument = new AssetMethodsDocument(); + + foreach ($chunk as $assetMethod) { + $assetMethodsDocument->addAssetMethod($assetMethod); + } + + $responses[] = $this->sendXmlDocument($assetMethodsDocument); + } + + return $this->getProcessXmlService()->mapAll($responses, "assetmethod", function(Response $response): AssetMethod { + return AssetMethodMapper::map($response); + }); + } + + /** + * List all asset methods. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return AssetMethod[] The asset methods found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_ASSET_METHODS, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $assetMethodArrayListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); + + return $this->mapListAll("AssetMethod", $response->data, $assetMethodArrayListAllTags); + } +} \ No newline at end of file diff --git a/src/ApiConnectors/BaseApiConnector.php b/src/ApiConnectors/BaseApiConnector.php index fa33353b..7d1be143 100644 --- a/src/ApiConnectors/BaseApiConnector.php +++ b/src/ApiConnectors/BaseApiConnector.php @@ -46,6 +46,11 @@ public function __construct(AuthenticatedConnection $connection) { $this->connection = $connection; } + + public function getConnection() + { + return $this->connection; + } /** * @see sendXmlDocument() @@ -161,4 +166,68 @@ protected function getFinderService(): FinderService { return $this->connection->getAuthenticatedClient(Services::FINDER()); } -} + + /** + * Convert options array to an ArrayOfString which is accepted by Twinfield. + * + * @param array $options + * @param array|null $forcedOptions + * @return array + * @throws Exception + */ + public function convertOptionsToArrayOfString(array $options, array $forcedOptions = null): array { + if (isset($options['ArrayOfString'])) { + return $options; + } else { + $optionsArrayOfString = array('ArrayOfString' => array()); + + foreach ($forcedOptions as $key => $value) { + unset($options[$key]); + $optionsArrayOfString['ArrayOfString'][] = array($key, $value); + } + + foreach ($options as $key => $value) { + $optionsArrayOfString['ArrayOfString'][] = array($key, $value); + } + + return $optionsArrayOfString; + } + } + + /** + * Map the response of a listAll to an array of the requested class + * + * @param string $className + * @param object $data + * @param array $objectListAllTags + * @return array + * @throws Exception + */ + public function mapListAll(string $className, object $data, array $objectListAllTags): array { + if ($data->TotalRows == 0) { + return []; + } + + $objects = []; + + foreach ($data->Items->ArrayOfString as $responseArrayElement) { + $class = "\\PhpTwinfield\\" . $className; + + $object = new $class(); + + if (isset($responseArrayElement->string[0])) { + $elementArray = $responseArrayElement->string; + } else { + $elementArray = $responseArrayElement; + } + + foreach ($objectListAllTags as $key => $method) { + $object->$method($elementArray[$key]); + } + + $objects[] = $object; + } + + return $objects; + } +} \ No newline at end of file diff --git a/src/ApiConnectors/CashBankBookApiConnector.php b/src/ApiConnectors/CashBankBookApiConnector.php new file mode 100644 index 00000000..19104101 --- /dev/null +++ b/src/ApiConnectors/CashBankBookApiConnector.php @@ -0,0 +1,52 @@ + + */ +class CashBankBooksApiConnector extends BaseApiConnector +{ + /** + * List all cash and bank books. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return CashBankBook[] The cash and bank books found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_CASHBOOKS_AND_BANKS, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $vatGroupListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); + + return $this->mapListAll("CashBankBook", $response->data, $vatGroupListAllTags); + } +} \ No newline at end of file diff --git a/src/ApiConnectors/CostCenterApiConnector.php b/src/ApiConnectors/CostCenterApiConnector.php new file mode 100644 index 00000000..9ca4f271 --- /dev/null +++ b/src/ApiConnectors/CostCenterApiConnector.php @@ -0,0 +1,126 @@ + + */ +class CostCenterApiConnector extends BaseApiConnector +{ + /** + * Requests a specific CostCenter based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return CostCenter|bool The requested cost center or false if it can't be found. + * @throws Exception + */ + public function get(string $code, Office $office): CostCenter + { + // Make a request to read a single CostCenter. Set the required values + $request_costCenter = new Request\Read\CostCenter(); + $request_costCenter + ->setOffice($office->getCode()) + ->setCode($code); + + // Send the Request document and set the response to this instance. + $response = $this->sendXmlDocument($request_costCenter); + + return CostCenterMapper::map($response); + } + + /** + * Sends a CostCenter instance to Twinfield to update or add. + * + * @param CostCenter $costCenter + * @return CostCenter + * @throws Exception + */ + public function send(CostCenter $costCenter): CostCenter + { + foreach($this->sendAll([$costCenter]) as $each) { + return $each->unwrap(); + } + } + + /** + * @param CostCenter[] $costCenters + * @return MappedResponseCollection + * @throws Exception + */ + public function sendAll(array $costCenters): MappedResponseCollection + { + Assert::allIsInstanceOf($costCenters, CostCenter::class); + + /** @var Response[] $responses */ + $responses = []; + + foreach ($this->getProcessXmlService()->chunk($costCenters) as $chunk) { + + $costCentersDocument = new CostCentersDocument(); + + foreach ($chunk as $costCenter) { + $costCentersDocument->addCostCenter($costCenter); + } + + $responses[] = $this->sendXmlDocument($costCentersDocument); + } + + return $this->getProcessXmlService()->mapAll($responses, "dimension", function(Response $response): CostCenter { + return CostCenterMapper::map($response); + }); + } + + /** + * List all cost centers. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return CostCenter[] The cost centers found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $forcedOptions['dimtype'] = "KPL"; + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options, $forcedOptions); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_DIMENSIONS_FINANCIALS, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $costCenterArrayListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); + + return $this->mapListAll("CostCenter", $response->data, $costCenterArrayListAllTags); + } +} \ No newline at end of file diff --git a/src/ApiConnectors/CountryApiConnector.php b/src/ApiConnectors/CountryApiConnector.php new file mode 100644 index 00000000..91479ab7 --- /dev/null +++ b/src/ApiConnectors/CountryApiConnector.php @@ -0,0 +1,52 @@ + + */ +class CountryApiConnector extends BaseApiConnector +{ + /** + * List all countries. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return Country[] The countries found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_COUNTRIES, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $countryListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); + + return $this->mapListAll("Country", $response->data, $countryListAllTags); + } +} \ No newline at end of file diff --git a/src/ApiConnectors/CurrencyApiConnector.php b/src/ApiConnectors/CurrencyApiConnector.php new file mode 100644 index 00000000..acaace00 --- /dev/null +++ b/src/ApiConnectors/CurrencyApiConnector.php @@ -0,0 +1,129 @@ + + */ +class CurrencyApiConnector extends BaseApiConnector +{ + /** + * Requests a specific Currency based off the passed in code and optionally the office. + * NOTE: The Twinfield API does not currently support reading currencies + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return Currency|bool The requested currency or false if it can't be found. + * @throws Exception + */ + + /* + public function get(string $code, Office $office): Currency + { + // Make a request to read a single Currency. Set the required values + $request_currency = new Request\Read\Currency(); + $request_currency + ->setOffice($office->getCode()) + ->setCode($code); + + // Send the Request document and set the response to this instance. + $response = $this->sendXmlDocument($request_currency); + + return CurrencyMapper::map($response); + } + */ + + /** + * Sends a Currency instance to Twinfield to update or add. + * + * @param Currency $currency + * @return Currency + * @throws Exception + */ + public function send(Currency $currency): Currency + { + foreach($this->sendAll([$currency]) as $each) { + return $each->unwrap(); + } + } + + /** + * @param Currency[] $currencies + * @return MappedResponseCollection + * @throws Exception + */ + public function sendAll(array $currencies): MappedResponseCollection + { + Assert::allIsInstanceOf($currencies, Currency::class); + + /** @var Response[] $responses */ + $responses = []; + + foreach ($this->getProcessXmlService()->chunk($currencies) as $chunk) { + + $currenciesDocument = new CurrenciesDocument(); + + foreach ($chunk as $currency) { + $currenciesDocument->addCurrency($currency); + } + + $responses[] = $this->sendXmlDocument($currenciesDocument); + } + + return $this->getProcessXmlService()->mapAll($responses, "currency", function(Response $response): Currency { + return CurrencyMapper::map($response); + }); + } + + /** + * List all currencies. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return Currency[] The currencies found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_CURRENCIES, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $currencyArrayListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); + + return $this->mapListAll("Currency", $response->data, $currencyArrayListAllTags); + } +} \ No newline at end of file diff --git a/src/ApiConnectors/CustomerApiConnector.php b/src/ApiConnectors/CustomerApiConnector.php index 0f42276d..47bfe7fa 100644 --- a/src/ApiConnectors/CustomerApiConnector.php +++ b/src/ApiConnectors/CustomerApiConnector.php @@ -10,6 +10,7 @@ use PhpTwinfield\Request as Request; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; +use PhpTwinfield\Services\FinderService; use Webmozart\Assert\Assert; /** @@ -19,17 +20,18 @@ * If you require more complex interactions or a heavier amount of control over the requests to/from then look inside * the methods or see the advanced guide detailing the required usages. * - * @author Leon Rowland + * @author Leon Rowland , extended by Yannick Aerssens * @copyright (c) 2013, Pronamic */ class CustomerApiConnector extends BaseApiConnector { /** - * Requests a specific customer based off the passed in code and the office. + * Requests a specific Customer based off the passed in code and optionally the office. * * @param string $code - * @param Office $office - * @return Customer The requested customer + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return Customer|bool The requested customer or false if it can't be found. * @throws Exception */ public function get(string $code, Office $office): Customer @@ -42,52 +44,12 @@ public function get(string $code, Office $office): Customer // Send the Request document and set the response to this instance. $response = $this->sendXmlDocument($request_customer); - return CustomerMapper::map($response); - } - - /** - * Requests all customers from the List Dimension Type. - * - * @param Office $office - * @return array A multidimensional array in the following form: - * [$customerId => ['name' => $name, 'shortName' => $shortName], ...] - * - * @throws Exception - */ - public function listAll(Office $office): array - { - // Make a request to a list of all customers - $request_customers = new Request\Catalog\Dimension($office, "DEB"); - - // Send the Request document and set the response to this instance. - $response = $this->sendXmlDocument($request_customers); - - // Get the raw response document - $responseDOM = $response->getResponseDocument(); - - // Prepared empty customer array - $customers = []; - - // Store in an array by customer id - /** @var \DOMElement $customer */ - foreach ($responseDOM->getElementsByTagName('dimension') as $customer) { - $customer_id = $customer->textContent; - if ($customer_id == "DEB") { - continue; - } - - $customers[$customer->textContent] = array( - 'name' => $customer->getAttribute('name'), - 'shortName' => $customer->getAttribute('shortname'), - ); - } - - return $customers; + return CustomerMapper::map($response); } /** - * Sends a \PhpTwinfield\Customer\Customer instance to Twinfield to update or add. + * Sends a Customer instance to Twinfield to update or add. * * @param Customer $customer * @return Customer @@ -95,12 +57,8 @@ public function listAll(Office $office): array */ public function send(Customer $customer): Customer { - $customerResponses = $this->sendAll([$customer]); - - Assert::count($customerResponses, 1); - - foreach ($customerResponses as $customerResponse) { - return $customerResponse->unwrap(); + foreach($this->sendAll([$customer]) as $each) { + return $each->unwrap(); } } @@ -113,10 +71,10 @@ public function sendAll(array $customers): MappedResponseCollection { Assert::allIsInstanceOf($customers, Customer::class); + /** @var Response[] $responses */ $responses = []; foreach ($this->getProcessXmlService()->chunk($customers) as $chunk) { - $customersDocument = new CustomersDocument(); foreach ($chunk as $customer) { @@ -130,4 +88,39 @@ public function sendAll(array $customers): MappedResponseCollection return CustomerMapper::map($response); }); } -} + + /** + * List all customers. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return Customer[] The customers found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $forcedOptions['dimtype'] = "DEB"; + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options, $forcedOptions); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_DIMENSIONS_FINANCIALS, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $customerListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); + + return $this->mapListAll("Customer", $response->data, $customerListAllTags); + } +} \ No newline at end of file diff --git a/src/ApiConnectors/DimensionGroupApiConnector.php b/src/ApiConnectors/DimensionGroupApiConnector.php new file mode 100644 index 00000000..9f5d339a --- /dev/null +++ b/src/ApiConnectors/DimensionGroupApiConnector.php @@ -0,0 +1,125 @@ + + */ +class DimensionGroupApiConnector extends BaseApiConnector +{ + /** + * Requests a specific DimensionGroup based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return DimensionGroup|bool The requested dimension group or false if it can't be found. + * @throws Exception + */ + public function get(string $code, Office $office): DimensionGroup + { + // Make a request to read a single DimensionGroup. Set the required values + $request_dimensionGroup = new Request\DimensionGroup(); + $request_dimensionGroup + ->setOffice($office->getCode()) + ->setCode($code); + + // Send the Request document and set the response to this instance. + $response = $this->sendXmlDocument($request_dimensionGroup); + + return DimensionGroupMapper::map($response); + } + + /** + * Sends an DimensionGroup instance to Twinfield to update or add. + * + * @param DimensionGroup $dimensionGroup + * @return DimensionGroup + * @throws Exception + */ + public function send(DimensionGroup $dimensionGroup): DimensionGroup + { + foreach($this->sendAll([$dimensionGroup]) as $each) { + return $each->unwrap(); + } + } + + /** + * @param DimensionGroup[] $dimensionGroups + * @return MappedResponseCollection + * @throws Exception + */ + public function sendAll(array $dimensionGroups): MappedResponseCollection + { + Assert::allIsInstanceOf($dimensionGroups, DimensionGroup::class); + + /** @var Response[] $responses */ + $responses = []; + + foreach ($this->getProcessXmlService()->chunk($dimensionGroups) as $chunk) { + + $dimensionGroupsDocument = new DimensionGroupsDocument(); + + foreach ($chunk as $dimensionGroup) { + $dimensionGroupsDocument->addDimensionGroup($dimensionGroup); + } + + $responses[] = $this->sendXmlDocument($dimensionGroupsDocument); + } + + return $this->getProcessXmlService()->mapAll($responses, "dimensiongroup", function(Response $response): DimensionGroup { + return DimensionGroupMapper::map($response); + }); + } + + /** + * List all dimension groups. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return DimensionGroup[] The dimension groups found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_DIMENSION_GROUPS, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $dimensionGroupListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); + + return $this->mapListAll("DimensionGroup", $response->data, $dimensionGroupListAllTags); + } +} \ No newline at end of file diff --git a/src/ApiConnectors/DimensionTypeApiConnector.php b/src/ApiConnectors/DimensionTypeApiConnector.php new file mode 100644 index 00000000..879a8a46 --- /dev/null +++ b/src/ApiConnectors/DimensionTypeApiConnector.php @@ -0,0 +1,125 @@ + + */ +class DimensionTypeApiConnector extends BaseApiConnector +{ + /** + * Requests a specific DimensionType based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return DimensionType|bool The requested dimension type or false if it can't be found. + * @throws Exception + */ + public function get(string $code, Office $office): DimensionType + { + // Make a request to read a single DimensionType. Set the required values + $request_dimensionType = new Request\DimensionType(); + $request_dimensionType + ->setOffice($office->getCode()) + ->setCode($code); + + // Send the Request document and set the response to this instance. + $response = $this->sendXmlDocument($request_dimensionType); + + return DimensionTypeMapper::map($response); + } + + /** + * Sends an DimensionType instance to Twinfield to update or add. + * + * @param DimensionType $dimensionType + * @return DimensionType + * @throws Exception + */ + public function send(DimensionType $dimensionType): DimensionType + { + foreach($this->sendAll([$dimensionType]) as $each) { + return $each->unwrap(); + } + } + + /** + * @param DimensionType[] $dimensionTypes + * @return MappedResponseCollection + * @throws Exception + */ + public function sendAll(array $dimensionTypes): MappedResponseCollection + { + Assert::allIsInstanceOf($dimensionTypes, DimensionType::class); + + /** @var Response[] $responses */ + $responses = []; + + foreach ($this->getProcessXmlService()->chunk($dimensionTypes) as $chunk) { + + $dimensionTypesDocument = new DimensionTypesDocument(); + + foreach ($chunk as $dimensionType) { + $dimensionTypesDocument->addDimensionType($dimensionType); + } + + $responses[] = $this->sendXmlDocument($dimensionTypesDocument); + } + + return $this->getProcessXmlService()->mapAll($responses, "dimensiontype", function(Response $response): DimensionType { + return DimensionTypeMapper::map($response); + }); + } + + /** + * List all dimension types. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return DimensionType[] The dimension types found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_DIMENSION_TYPES, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $dimensionTypeListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); + + return $this->mapListAll("DimensionType", $response->data, $dimensionTypeListAllTags); + } +} \ No newline at end of file diff --git a/src/ApiConnectors/FixedAssetApiConnector.php b/src/ApiConnectors/FixedAssetApiConnector.php new file mode 100644 index 00000000..b4b14d0b --- /dev/null +++ b/src/ApiConnectors/FixedAssetApiConnector.php @@ -0,0 +1,125 @@ + + */ +class FixedAssetApiConnector extends BaseApiConnector +{ + /** + * Requests a specific FixedAsset based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return FixedAsset|bool The requested fixed asset or false if it can't be found. + * @throws Exception + */ + public function get(string $code, Office $office): FixedAsset + { + // Make a request to read a single FixedAsset. Set the required values + $request_fixedAsset = new Request\Read\FixedAsset(); + $request_fixedAsset + ->setOffice($office->getCode()) + ->setCode($code); + + // Send the Request document and set the response to this instance. + $response = $this->sendXmlDocument($request_fixedAsset); + + return FixedAssetMapper::map($response); + } + + /** + * Sends a FixedAsset instance to Twinfield to update or add. + * + * @param FixedAsset $fixedAsset + * @return FixedAsset + * @throws Exception + */ + public function send(FixedAsset $fixedAsset): FixedAsset + { + foreach($this->sendAll([$fixedAsset]) as $each) { + return $each->unwrap(); + } + } + + /** + * @param FixedAsset[] $fixedAssets + * @return MappedResponseCollection + * @throws Exception + */ + public function sendAll(array $fixedAssets): MappedResponseCollection + { + Assert::allIsInstanceOf($fixedAssets, FixedAsset::class); + + /** @var Response[] $responses */ + $responses = []; + + foreach ($this->getProcessXmlService()->chunk($fixedAssets) as $chunk) { + $fixedAssetsDocument = new FixedAssetsDocument(); + + foreach ($chunk as $fixedAsset) { + $fixedAssetsDocument->addFixedAsset($fixedAsset); + } + + $responses[] = $this->sendXmlDocument($fixedAssetsDocument); + } + + return $this->getProcessXmlService()->mapAll($responses, "dimension", function(Response $response): FixedAsset { + return FixedAssetMapper::map($response); + }); + } + + /** + * List all fixed assets. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return FixedAsset[] The fixed assets found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $forcedOptions['dimtype'] = "AST"; + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options, $forcedOptions); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_DIMENSIONS_FINANCIALS, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $fixedAssetListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); + + return $this->mapListAll("FixedAsset", $response->data, $fixedAssetListAllTags); + } +} \ No newline at end of file diff --git a/src/ApiConnectors/GeneralLedgerApiConnector.php b/src/ApiConnectors/GeneralLedgerApiConnector.php new file mode 100644 index 00000000..46d7cb6f --- /dev/null +++ b/src/ApiConnectors/GeneralLedgerApiConnector.php @@ -0,0 +1,126 @@ + + */ +class GeneralLedgerApiConnector extends BaseApiConnector +{ + /** + * Requests a specific GeneralLedger based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return GeneralLedger|bool The requested general ledger or false if it can't be found. + * @throws Exception + */ + public function get(string $code, string $dimType, Office $office): GeneralLedger + { + // Make a request to read a single GeneralLedger. Set the required values + $request_generalLedger = new Request\Read\GeneralLedger(); + $request_generalLedger + ->setOffice($office->getCode()) + ->setDimType($dimType) + ->setCode($code); + + // Send the Request document and set the response to this instance. + $response = $this->sendXmlDocument($request_generalLedger); + + return GeneralLedgerMapper::map($response); + } + + /** + * Sends a GeneralLedger instance to Twinfield to update or add. + * + * @param GeneralLedger $generalLedger + * @return GeneralLedger + * @throws Exception + */ + public function send(GeneralLedger $generalLedger): GeneralLedger + { + foreach($this->sendAll([$generalLedger]) as $each) { + return $each->unwrap(); + } + } + + /** + * @param GeneralLedger[] $generalLedgers + * @return MappedResponseCollection + * @throws Exception + */ + public function sendAll(array $generalLedgers): MappedResponseCollection + { + Assert::allIsInstanceOf($generalLedgers, GeneralLedger::class); + + /** @var Response[] $responses */ + $responses = []; + + foreach ($this->getProcessXmlService()->chunk($generalLedgers) as $chunk) { + $generalLedgersDocument = new GeneralLedgersDocument(); + + foreach ($chunk as $generalLedger) { + $generalLedgersDocument->addGeneralLedger($generalLedger); + } + + $responses[] = $this->sendXmlDocument($generalLedgersDocument); + } + + return $this->getProcessXmlService()->mapAll($responses, "dimension", function(Response $response): GeneralLedger { + return GeneralLedgerMapper::map($response); + }); + } + + /** + * List all fixed assets. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return GeneralLedger[] The fixed assets found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $forcedOptions['level'] = 1; + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options, $forcedOptions); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_DIMENSIONS_FINANCIALS, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $generalLedgerListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); + + return $this->mapListAll("GeneralLedger", $response->data, $generalLedgerListAllTags); + } +} \ No newline at end of file diff --git a/src/ApiConnectors/InvoiceApiConnector.php b/src/ApiConnectors/InvoiceApiConnector.php index 3c9a6219..7fbec112 100644 --- a/src/ApiConnectors/InvoiceApiConnector.php +++ b/src/ApiConnectors/InvoiceApiConnector.php @@ -10,6 +10,7 @@ use PhpTwinfield\Request as Request; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; +use PhpTwinfield\Services\FinderService; use Webmozart\Assert\Assert; /** @@ -25,7 +26,7 @@ class InvoiceApiConnector extends BaseApiConnector { /** - * Requires a specific invoice based off the passed in code, invoiceNumber and optionally the office. + * Requires a specific Invoice based off the passed in code, invoiceNumber and optionally the office. * * @param string $code * @param string $invoiceNumber @@ -35,11 +36,11 @@ class InvoiceApiConnector extends BaseApiConnector */ public function get(string $code, string $invoiceNumber, Office $office) { - // Make a request to read a single invoice. Set the required values + // Make a request to read a single Invoice. Set the required values $request_invoice = new Request\Read\Invoice(); $request_invoice ->setCode($code) - ->setNumber($invoiceNumber) + ->setInvoiceNumber($invoiceNumber) ->setOffice($office->getCode()); // Send the Request document and set the response to this instance @@ -57,12 +58,8 @@ public function get(string $code, string $invoiceNumber, Office $office) */ public function send(Invoice $invoice): Invoice { - $invoiceResponses = $this->sendAll([$invoice]); - - Assert::count($invoiceResponses, 1); - - foreach ($invoiceResponses as $invoiceResponse) { - return $invoiceResponse->unwrap(); + foreach($this->sendAll([$invoice]) as $each) { + return $each->unwrap(); } } @@ -79,11 +76,10 @@ public function sendAll(array $invoices): MappedResponseCollection $responses = []; foreach ($this->getProcessXmlService()->chunk($invoices) as $chunk) { - $invoicesDocument = new InvoicesDocument(); foreach ($chunk as $invoice) { - $invoicesDocument->addInvoice($invoice); + $invoicesDocument->addInvoice($invoice, $this->getConnection()); } $responses[] = $this->sendXmlDocument($invoicesDocument); @@ -93,4 +89,41 @@ public function sendAll(array $invoices): MappedResponseCollection return InvoiceMapper::map($response); }); } + + /** + * List all sales invoices. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return Invoice[] The sales invoices found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_LIST_OF_AVAILABLE_INVOICES, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $invoiceListAllTags = array( + 0 => 'setInvoiceNumber', + 1 => 'setInvoiceAmountFromFloat', + 2 => 'setCustomerFromCode', + 3 => 'setCustomerName', + 4 => 'setDebitCreditFromString', + ); + + return $this->mapListAll("Invoice", $response->data, $invoiceListAllTags); + } } diff --git a/src/ApiConnectors/InvoiceTypeApiConnector.php b/src/ApiConnectors/InvoiceTypeApiConnector.php new file mode 100644 index 00000000..aa2f3848 --- /dev/null +++ b/src/ApiConnectors/InvoiceTypeApiConnector.php @@ -0,0 +1,86 @@ + + */ +class InvoiceTypeApiConnector extends BaseApiConnector +{ + /** + * List all Invoice types. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return InvoiceType[] The Invoice types found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_INVOICE_TYPES, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $invoiceTypeListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); + + return $this->mapListAll("InvoiceType", $response->data, $invoiceTypeListAllTags); + } + + /** + * Determine if a specified invoice type is of the inclusive or exclusive VAT type. + * + * @param string $pattern The search pattern. May contain wildcards * and ?, but should be the full code of the invoice type + * + * @return string Is the invoice type of the inclusive or exclusive VAT type. + */ + public function getInvoiceTypeVatType( + string $pattern + ): ?string { + $options = array('vat' => 'inclusive'); + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_INVOICE_TYPES, $pattern, 1, 1, 1, $optionsArrayOfString); + + if ($response->data->TotalRows == 0) { + return 'exclusive'; + } + + foreach ($response->data->Items->ArrayOfString as $invoiceTypeArray) { + if (isset($invoiceTypeArray->string[0])) { + if ($pattern === $invoiceTypeArray->string[0]) { + return 'inclusive'; + } + } else { + if ($pattern === $invoiceTypeArray[0]) { + return 'inclusive'; + } + } + } + + return 'exclusive'; + } +} \ No newline at end of file diff --git a/src/ApiConnectors/OfficeApiConnector.php b/src/ApiConnectors/OfficeApiConnector.php index 9d9d9c92..471e0243 100644 --- a/src/ApiConnectors/OfficeApiConnector.php +++ b/src/ApiConnectors/OfficeApiConnector.php @@ -3,9 +3,11 @@ namespace PhpTwinfield\ApiConnectors; use PhpTwinfield\Mappers\OfficeMapper; +use PhpTwinfield\Exception; use PhpTwinfield\Office; use PhpTwinfield\Services\FinderService; -use PhpTwinfield\Request\Catalog\Office as OfficeRequestDocument; +use PhpTwinfield\Request as Request; +use PhpTwinfield\Request\Catalog as RequestDocument; /** * A facade to make interaction with the the Twinfield service easier when trying to retrieve or send information about @@ -14,10 +16,29 @@ * If you require more complex interactions or a heavier amount of control over the requests to/from then look inside * the methods or see the advanced guide detailing the required usages. * - * @author Emile Bons + * @author Emile Bons , extended by Yannick Aerssens */ class OfficeApiConnector extends BaseApiConnector { + /** + * Requests a specific Office based off the passed in code. + * + * @param string $code + * @return Office|bool The requested office or false if it can't be found. + * @throws Exception + */ + public function get(string $code): Office + { + // Make a request to read a single Office. Set the required values + $request_office = new Request\Read\Office(); + $request_office->setCode($code); + + // Send the Request document and set the response to this instance. + $response = $this->sendXmlDocument($request_office); + + return OfficeMapper::map($response); + } + /** * List the available offices when you are using the OAuth based authentication and don't have an office code yet. * For more information following see. @@ -31,7 +52,8 @@ class OfficeApiConnector extends BaseApiConnector public function listAllWithoutOfficeCode(): array { $offices = []; - $document = new OfficeRequestDocument(); + $document = new RequestDocument(); + $document->add('type', 'offices'); $response = $this->getProcessXmlService()->sendDocument($document); $response->assertSuccessful(); @@ -64,21 +86,18 @@ public function listAll( int $maxRows = 100, array $options = [] ): array { - $response = $this->getFinderService()->searchFinder(FinderService::TYPE_OFFICES, $pattern, $field, $firstRow, $maxRows, $options); + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options); - if ($response->data->TotalRows == 0) { - return []; - } + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_OFFICES, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); - $offices = []; - foreach ($response->data->Items->ArrayOfString as $officeArray) { - $office = new Office(); - $office->setCode($officeArray->string[0]); - $office->setCountryCode($officeArray->string[2]); - $office->setName($officeArray->string[1]); - $offices[] = $office; - } + $officeListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + 2 => 'setCountryCode', + 3 => 'setVatPeriod', + 4 => 'setVatFirstQuarterStartsIn', + ); - return $offices; + return $this->mapListAll("Office", $response->data, $officeListAllTags); } } diff --git a/src/ApiConnectors/PayCodeApiConnector.php b/src/ApiConnectors/PayCodeApiConnector.php new file mode 100644 index 00000000..4d78fcaa --- /dev/null +++ b/src/ApiConnectors/PayCodeApiConnector.php @@ -0,0 +1,52 @@ + + */ +class PayCodeApiConnector extends BaseApiConnector +{ + /** + * List all pay codes. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return PayCode[] The pay codes found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_PAYMENT_TYPES, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $payCodeListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); + + return $this->mapListAll("PayCode", $response->data, $payCodeListAllTags); + } +} \ No newline at end of file diff --git a/src/ApiConnectors/ProjectApiConnector.php b/src/ApiConnectors/ProjectApiConnector.php new file mode 100644 index 00000000..8e9b00c9 --- /dev/null +++ b/src/ApiConnectors/ProjectApiConnector.php @@ -0,0 +1,126 @@ + + */ +class ProjectApiConnector extends BaseApiConnector +{ + /** + * Requests a specific Project based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return Project|bool The requested project or false if it can't be found. + * @throws Exception + */ + public function get(string $code, Office $office): Project + { + // Make a request to read a single Project. Set the required values + $request_project = new Request\Read\Project(); + $request_project + ->setOffice($office->getCode()) + ->setCode($code); + + // Send the Request document and set the response to this instance. + $response = $this->sendXmlDocument($request_project); + + return ProjectMapper::map($response); + } + + /** + * Sends a Project instance to Twinfield to update or add. + * + * @param Project $project + * @return Project + * @throws Exception + */ + public function send(Project $project): Project + { + foreach($this->sendAll([$project]) as $each) { + return $each->unwrap(); + } + } + + /** + * @param Project[] $projects + * @return MappedResponseCollection + * @throws Exception + */ + public function sendAll(array $projects): MappedResponseCollection + { + Assert::allIsInstanceOf($projects, Project::class); + + /** @var Response[] $responses */ + $responses = []; + + foreach ($this->getProcessXmlService()->chunk($projects) as $chunk) { + + $projectsDocument = new ProjectsDocument(); + + foreach ($chunk as $project) { + $projectsDocument->addProject($project); + } + + $responses[] = $this->sendXmlDocument($projectsDocument); + } + + return $this->getProcessXmlService()->mapAll($responses, "dimension", function(Response $response): Project { + return ProjectMapper::map($response); + }); + } + + /** + * List all projects. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return Project[] The projects found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $forcedOptions['dimtype'] = "PRJ"; + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options, $forcedOptions); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_DIMENSIONS_PROJECTS, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $projectListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); + + return $this->mapListAll("Project", $response->data, $projectListAllTags); + } +} \ No newline at end of file diff --git a/src/ApiConnectors/RateApiConnector.php b/src/ApiConnectors/RateApiConnector.php new file mode 100644 index 00000000..ef902c87 --- /dev/null +++ b/src/ApiConnectors/RateApiConnector.php @@ -0,0 +1,125 @@ + + */ +class RateApiConnector extends BaseApiConnector +{ + /** + * Requests a specific Rate based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return Rate|bool The requested rate or false if it can't be found. + * @throws Exception + */ + public function get(string $code, Office $office): Rate + { + // Make a request to read a single Rate. Set the required values + $request_rate = new Request\Read\Rate(); + $request_rate + ->setOffice($office->getCode()) + ->setCode($code); + + // Send the Request document and set the response to this instance. + $response = $this->sendXmlDocument($request_rate); + + return RateMapper::map($response); + } + + /** + * Sends a Rate instance to Twinfield to update or add. + * + * @param Rate $rate + * @return Rate + * @throws Exception + */ + public function send(Rate $rate): Rate + { + foreach($this->sendAll([$rate]) as $each) { + return $each->unwrap(); + } + } + + /** + * @param Rate[] $rates + * @return MappedResponseCollection + * @throws Exception + */ + public function sendAll(array $rates): MappedResponseCollection + { + Assert::allIsInstanceOf($rates, Rate::class); + + /** @var Response[] $responses */ + $responses = []; + + foreach ($this->getProcessXmlService()->chunk($rates) as $chunk) { + + $ratesDocument = new RatesDocument(); + + foreach ($chunk as $rate) { + $ratesDocument->addRate($rate); + } + + $responses[] = $this->sendXmlDocument($ratesDocument); + } + + return $this->getProcessXmlService()->mapAll($responses, "projectrate", function(Response $response): Rate { + return RateMapper::map($response); + }); + } + + /** + * List all rates. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return Rate[] The rates found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_TIME_PROJECT_RATES, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $rateListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); + + return $this->mapListAll("Rate", $response->data, $rateListAllTags); + } +} \ No newline at end of file diff --git a/src/ApiConnectors/SupplierApiConnector.php b/src/ApiConnectors/SupplierApiConnector.php index f6e692ee..5dc8606d 100644 --- a/src/ApiConnectors/SupplierApiConnector.php +++ b/src/ApiConnectors/SupplierApiConnector.php @@ -9,6 +9,7 @@ use PhpTwinfield\Request as Request; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; +use PhpTwinfield\Services\FinderService; use PhpTwinfield\Supplier; use Webmozart\Assert\Assert; @@ -19,78 +20,36 @@ * If you require more complex interactions or a heavier amount of control over the requests to/from then look inside * the methods or see the advanced guide detailing the required usages. * - * @author Leon Rowland + * @author Leon Rowland , extended by Yannick Aerssens * @copyright (c) 2013, Pronamic */ class SupplierApiConnector extends BaseApiConnector { /** - * Requests a specific supplier based off the passed in code and optionally the office. + * Requests a specific Supplier based off the passed in code and optionally the office. * * @param string $code - * @param Office $office - * @return Supplier The requested supplier + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return Supplier|bool The requested supplier or false if it can't be found. * @throws Exception */ - public function get($code, Office $office): Supplier + public function get(string $code, Office $office): Supplier { - // Make a request to read a single customer. Set the required values - $request_customer = new Request\Read\Supplier(); - $request_customer + // Make a request to read a single supplier. Set the required values + $request_supplier = new Request\Read\Supplier(); + $request_supplier ->setOffice($office->getCode()) ->setCode($code); - $response = $this->sendXmlDocument($request_customer); - - return SupplierMapper::map($response); - } - - /** - * Requests all customers from the List Dimension Type. - * - * @param Office $office - * @param string $dimType - * @return array A multidimensional array in the following form: - * [$supplierId => ['name' => $name, 'shortName' => $shortName], ...] - * @throws Exception - */ - public function listAll(Office $office, string $dimType = 'CRD'): array - { - - // Make a request to a list of all customers - $request_customers = new Request\Catalog\Dimension($office, $dimType); - // Send the Request document and set the response to this instance. - $response = $this->sendXmlDocument($request_customers); - - // Get the raw response document - $responseDOM = $response->getResponseDocument(); - - // Prepared empty customer array - $suppliers = []; - - // Store in an array by customer id - foreach ($responseDOM->getElementsByTagName('dimension') as $supplier) { - $supplier_id = $supplier->textContent; - - if (!is_numeric($supplier_id)) { - continue; - } + $response = $this->sendXmlDocument($request_supplier); - $suppliers[$supplier->textContent] = array( - 'name' => $supplier->getAttribute('name'), - 'shortName' => $supplier->getAttribute('shortname'), - ); - } - - return $suppliers; + return SupplierMapper::map($response); } /** - * Sends a \PhpTwinfield\Supplier\Supplier instance to Twinfield to update or add. - * - * If you want to map the response back into a customer use getResponse()->getResponseDocument()->asXML() into the - * SupplierMapper::map() method. + * Sends a Supplier instance to Twinfield to update or add. * * @param Supplier $supplier * @return Supplier @@ -98,19 +57,12 @@ public function listAll(Office $office, string $dimType = 'CRD'): array */ public function send(Supplier $supplier): Supplier { - $supplierResponses = $this->sendAll([$supplier]); - - Assert::count($supplierResponses, 1); - - foreach ($supplierResponses as $supplierResponse) { - return $supplierResponse->unwrap(); + foreach($this->sendAll([$fixedAsset]) as $each) { + return $each->unwrap(); } } - /** - * Sends a list of Transaction instances to Twinfield to add or update. - * * @param Supplier[] $suppliers * @return MappedResponseCollection * @throws Exception @@ -123,7 +75,6 @@ public function sendAll(array $suppliers): MappedResponseCollection $responses = []; foreach ($this->getProcessXmlService()->chunk($suppliers) as $chunk) { - $suppliersDocument = new SuppliersDocument(); foreach ($chunk as $supplier) { @@ -134,7 +85,42 @@ public function sendAll(array $suppliers): MappedResponseCollection } return $this->getProcessXmlService()->mapAll($responses, "dimension", function(Response $response): Supplier { - return SupplierMapper::map($response); + return SupplierMapper::map($response); }); } -} + + /** + * List all suppliers. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return Supplier[] The suppliers found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $forcedOptions['dimtype'] = "CRD"; + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options, $forcedOptions); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_DIMENSIONS_FINANCIALS, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $supplierListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); + + return $this->mapListAll("Supplier", $response->data, $supplierListAllTags); + } +} \ No newline at end of file diff --git a/src/ApiConnectors/TransactionApiConnector.php b/src/ApiConnectors/TransactionApiConnector.php index 6ca39c34..6e409caa 100644 --- a/src/ApiConnectors/TransactionApiConnector.php +++ b/src/ApiConnectors/TransactionApiConnector.php @@ -101,4 +101,4 @@ function (Response $subresponse) use ($classname): BaseTransaction { } ); } -} +} \ No newline at end of file diff --git a/src/ApiConnectors/UserApiConnector.php b/src/ApiConnectors/UserApiConnector.php index 255803c7..19a6d42b 100644 --- a/src/ApiConnectors/UserApiConnector.php +++ b/src/ApiConnectors/UserApiConnector.php @@ -2,8 +2,16 @@ namespace PhpTwinfield\ApiConnectors; +use PhpTwinfield\DomDocuments\UsersDocument; +use PhpTwinfield\Exception; +use PhpTwinfield\Mappers\UserMapper; +use PhpTwinfield\Office; +use PhpTwinfield\Request as Request; +use PhpTwinfield\Response\MappedResponseCollection; +use PhpTwinfield\Response\Response; use PhpTwinfield\Services\FinderService; use PhpTwinfield\User; +use Webmozart\Assert\Assert; /** * A facade to make interaction with the the Twinfield service easier when trying to retrieve or send information about @@ -12,7 +20,7 @@ * If you require more complex interactions or a heavier amount of control over the requests to/from then look inside * the methods or see the advanced guide detailing the required usages. * - * @author Emile Bons + * @author Emile Bons , extended by Yannick Aerssens */ class UserApiConnector extends BaseApiConnector { @@ -22,6 +30,71 @@ class UserApiConnector extends BaseApiConnector const MUTUAL_OFFICES_DISABLED = 0; const MUTUAL_OFFICES_ENABLED = 1; + /** + * Requests a specific User based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return User|bool The requested User or false if it can't be found. + * @throws Exception + */ + public function get(string $code, Office $office): User + { + // Make a request to read a single User. Set the required values + $request_user = new Request\Read\User(); + $request_user + ->setOffice($office->getCode()) + ->setCode($code); + + // Send the Request document and set the response to this instance. + $response = $this->sendXmlDocument($request_user); + + return UserMapper::map($response); + } + + /** + * Sends a User instance to Twinfield to update or add. + * + * @param User $user + * @return User + * @throws Exception + */ + public function send(User $user): User + { + foreach($this->sendAll([$user]) as $each) { + return $each->unwrap(); + } + } + + /** + * @param User[] $users + * @return MappedResponseCollection + * @throws Exception + */ + public function sendAll(array $users): MappedResponseCollection + { + Assert::allIsInstanceOf($users, User::class); + + /** @var Response[] $responses */ + $responses = []; + + foreach ($this->getProcessXmlService()->chunk($users) as $chunk) { + + $usersDocument = new UsersDocument(); + + foreach ($chunk as $user) { + $usersDocument->addUser($user); + } + + $responses[] = $this->sendXmlDocument($usersDocument); + } + + return $this->getProcessXmlService()->mapAll($responses, "user", function(Response $response): User { + return UserMapper::map($response); + }); + } + /** * List all users. * @@ -60,20 +133,15 @@ public function listAll( $options['mutualOffices'] = $mutualOffices; } - $response = $this->getFinderService()->searchFinder(FinderService::TYPE_USERS, $pattern, $field, $firstRow, $maxRows, $options); + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options); - if ($response->data->TotalRows == 0) { - return []; - } + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_USERS, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); - $users = []; - foreach ($response->data->Items->ArrayOfString as $userArray) { - $user = new User(); - $user->setCode($userArray->string[0]); - $user->setName($userArray->string[1]); - $users[] = $user; - } + $userListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); - return $users; + return $this->mapListAll("User", $response->data, $userListAllTags); } } diff --git a/src/ApiConnectors/UserRoleApiConnector.php b/src/ApiConnectors/UserRoleApiConnector.php new file mode 100644 index 00000000..48c05c2f --- /dev/null +++ b/src/ApiConnectors/UserRoleApiConnector.php @@ -0,0 +1,52 @@ + + */ +class UserRoleApiConnector extends BaseApiConnector +{ + /** + * List all user roles. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return UserRoles[] The user roles found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_USER_ROLES, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $userRoleListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); + + return $this->mapListAll("UserRole", $response->data, $userRoleListAllTags); + } +} \ No newline at end of file diff --git a/src/ApiConnectors/VatCodeApiConnector.php b/src/ApiConnectors/VatCodeApiConnector.php index 17b69251..9872dee2 100644 --- a/src/ApiConnectors/VatCodeApiConnector.php +++ b/src/ApiConnectors/VatCodeApiConnector.php @@ -2,20 +2,93 @@ namespace PhpTwinfield\ApiConnectors; +use PhpTwinfield\DomDocuments\VatCodesDocument; +use PhpTwinfield\Exception; +use PhpTwinfield\Mappers\VatCodeMapper; +use PhpTwinfield\Office; +use PhpTwinfield\Request as Request; +use PhpTwinfield\Response\MappedResponseCollection; +use PhpTwinfield\Response\Response; use PhpTwinfield\Services\FinderService; use PhpTwinfield\VatCode; +use Webmozart\Assert\Assert; /** * A facade to make interaction with the the Twinfield service easier when trying to retrieve or send information about - * VAT codes. + * VatCodes. * * If you require more complex interactions or a heavier amount of control over the requests to/from then look inside * the methods or see the advanced guide detailing the required usages. * - * @author Emile Bons + * @author Emile Bons , extended by Yannick Aerssens */ class VatCodeApiConnector extends BaseApiConnector { + /** + * Requests a specific VatCode based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return VatCode|bool The requested VAT code or false if it can't be found. + * @throws Exception + */ + public function get(string $code, Office $office): VatCode + { + // Make a request to read a single VatCode. Set the required values + $request_vatCode = new Request\Read\VatCode(); + $request_vatCode + ->setOffice($office->getCode()) + ->setCode($code); + + // Send the Request document and set the response to this instance. + $response = $this->sendXmlDocument($request_vatCode); + + return VatCodeMapper::map($response); + } + + /** + * Sends a VatCode instance to Twinfield to update or add. + * + * @param VatCode $vatCode + * @return VatCode + * @throws Exception + */ + public function send(VatCode $vatCode): VatCode + { + foreach($this->sendAll([$vatCode]) as $each) { + return $each->unwrap(); + } + } + + /** + * @param VatCode[] $vatCodes + * @return MappedResponseCollection + * @throws Exception + */ + public function sendAll(array $vatCodes): MappedResponseCollection + { + Assert::allIsInstanceOf($vatCodes, VatCode::class); + + /** @var Response[] $responses */ + $responses = []; + + foreach ($this->getProcessXmlService()->chunk($vatCodes) as $chunk) { + + $vatCodesDocument = new VatCodesDocument(); + + foreach ($chunk as $vatCode) { + $vatCodesDocument->addVatCode($vatCode); + } + + $responses[] = $this->sendXmlDocument($vatCodesDocument); + } + + return $this->getProcessXmlService()->mapAll($responses, "vat", function(Response $response): VatCode { + return VatCodeMapper::map($response); + }); + } + /** * List all VAT codes. * @@ -38,20 +111,15 @@ public function listAll( int $maxRows = 100, array $options = [] ): array { - $response = $this->getFinderService()->searchFinder(FinderService::TYPE_VAT_CODES, $pattern, $field, $firstRow, $maxRows, $options); + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options); - if ($response->data->TotalRows == 0) { - return []; - } + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_VAT_CODES, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); - $vatCodes = []; - foreach ($response->data->Items->ArrayOfString as $vatCodeArray) { - $vatCode = new VatCode(); - $vatCode->setCode($vatCodeArray->string[0]); - $vatCode->setName($vatCodeArray->string[1]); - $vatCodes[] = $vatCode; - } + $vatCodeListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); - return $vatCodes; + return $this->mapListAll("VatCode", $response->data, $vatCodeListAllTags); } -} +} \ No newline at end of file diff --git a/src/ApiConnectors/VatGroupApiConnector.php b/src/ApiConnectors/VatGroupApiConnector.php new file mode 100644 index 00000000..b2326e69 --- /dev/null +++ b/src/ApiConnectors/VatGroupApiConnector.php @@ -0,0 +1,52 @@ + + */ +class VatGroupApiConnector extends BaseApiConnector +{ + /** + * List all VAT groups. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return VatGroup[] The VAT groups found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_VAT_GROUPS, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $vatGroupListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); + + return $this->mapListAll("VatGroup", $response->data, $vatGroupListAllTags); + } +} \ No newline at end of file From 45e19c6acf2c2be2c1841742c56e523c41d9bc79 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:26:53 +0200 Subject: [PATCH 053/388] Add files via upload --- src/Fields/BehaviourField.php | 41 ++++++++++++++++++++ src/Fields/CodeField.php | 31 +++++++++++++++ src/Fields/CreatedField.php | 66 ++++++++++++++++++++++++++++++++ src/Fields/CurrencyField.php | 54 ++++++++++++++++++++++++++ src/Fields/CustomerField.php | 54 ++++++++++++++++++++++++++ src/Fields/DescriptionField.php | 32 ++++++++++++++++ src/Fields/Dim1Field.php | 54 ++++++++++++++++++++++++++ src/Fields/ElementValueField.php | 32 ++++++++++++++++ src/Fields/FreeText1Field.php | 32 ++++++++++++++++ src/Fields/FreeText2Field.php | 32 ++++++++++++++++ src/Fields/FreeText3Field.php | 32 ++++++++++++++++ src/Fields/IDField.php | 32 ++++++++++++++++ src/Fields/InUseField.php | 47 +++++++++++++++++++++++ src/Fields/ModifiedField.php | 66 ++++++++++++++++++++++++++++++++ src/Fields/NameField.php | 31 +++++++++++++++ src/Fields/NrOfPeriodsField.php | 32 ++++++++++++++++ src/Fields/OfficeField.php | 53 +++++++++++++++++++++++++ src/Fields/PercentageField.php | 32 ++++++++++++++++ src/Fields/PeriodField.php | 38 ++++++++++++++++++ src/Fields/RateField.php | 54 ++++++++++++++++++++++++++ src/Fields/ShortNameField.php | 31 +++++++++++++++ src/Fields/StatusField.php | 40 +++++++++++++++++++ src/Fields/TouchedField.php | 32 ++++++++++++++++ src/Fields/UIDField.php | 32 ++++++++++++++++ src/Fields/UserField.php | 55 ++++++++++++++++++++++++++ src/Fields/VatCodeField.php | 54 ++++++++++++++++++++++++++ 26 files changed, 1089 insertions(+) create mode 100644 src/Fields/BehaviourField.php create mode 100644 src/Fields/CodeField.php create mode 100644 src/Fields/CreatedField.php create mode 100644 src/Fields/CurrencyField.php create mode 100644 src/Fields/CustomerField.php create mode 100644 src/Fields/DescriptionField.php create mode 100644 src/Fields/Dim1Field.php create mode 100644 src/Fields/ElementValueField.php create mode 100644 src/Fields/FreeText1Field.php create mode 100644 src/Fields/FreeText2Field.php create mode 100644 src/Fields/FreeText3Field.php create mode 100644 src/Fields/IDField.php create mode 100644 src/Fields/InUseField.php create mode 100644 src/Fields/ModifiedField.php create mode 100644 src/Fields/NameField.php create mode 100644 src/Fields/NrOfPeriodsField.php create mode 100644 src/Fields/OfficeField.php create mode 100644 src/Fields/PercentageField.php create mode 100644 src/Fields/PeriodField.php create mode 100644 src/Fields/RateField.php create mode 100644 src/Fields/ShortNameField.php create mode 100644 src/Fields/StatusField.php create mode 100644 src/Fields/TouchedField.php create mode 100644 src/Fields/UIDField.php create mode 100644 src/Fields/UserField.php create mode 100644 src/Fields/VatCodeField.php diff --git a/src/Fields/BehaviourField.php b/src/Fields/BehaviourField.php new file mode 100644 index 00000000..6be80ced --- /dev/null +++ b/src/Fields/BehaviourField.php @@ -0,0 +1,41 @@ +behaviour; + } + + /** + * @param Behaviour|null $behaviour + * @return $this + */ + public function setBehaviour(?Behaviour $behaviour): self + { + $this->behaviour = $behaviour; + return $this; + } + + /** + * @param string|null $behaviourString + * @return $this + * @throws Exception + */ + public function setBehaviourFromString(?string $behaviourString) + { + return $this->setBehaviour(new Behaviour((string)$behaviourString)); + } +} \ No newline at end of file diff --git a/src/Fields/CodeField.php b/src/Fields/CodeField.php new file mode 100644 index 00000000..aa883829 --- /dev/null +++ b/src/Fields/CodeField.php @@ -0,0 +1,31 @@ +code; + } + + /** + * @param null|string $code + * @return $this + */ + public function setCode(?string $code): self + { + $this->code = $code; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/CreatedField.php b/src/Fields/CreatedField.php new file mode 100644 index 00000000..ee7fe59c --- /dev/null +++ b/src/Fields/CreatedField.php @@ -0,0 +1,66 @@ +created; + } + + /** + * @return string|null + */ + public function getCreatedToString(): ?string + { + if ($this->getCreated() != null) { + return Util::formatDateTime($this->getCreated()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $created + * @return $this + */ + public function setCreated(?\DateTimeInterface $created) + { + $this->created = $created; + return $this; + } + + /** + * @param string|null $createdString + * @return $this + * @throws Exception + */ + public function setCreatedFromString(?string $createdString) + { + if ((bool)strtotime($createdString)) { + return $this->setCreated(Util::parseDateTime($createdString)); + } else { + return $this->setCreated(null); + } + } +} \ No newline at end of file diff --git a/src/Fields/CurrencyField.php b/src/Fields/CurrencyField.php new file mode 100644 index 00000000..8ed0bc20 --- /dev/null +++ b/src/Fields/CurrencyField.php @@ -0,0 +1,54 @@ +currency; + } + + public function getCurrencyToCode(): ?string + { + if ($this->getCurrency() != null) { + return $this->currency->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setCurrency(?Currency $currency): self + { + $this->currency = $currency; + return $this; + } + + /** + * @param string|null $currencyCode + * @return $this + * @throws Exception + */ + public function setCurrencyFromCode(?string $currencyCode) + { + $currency = new Currency(); + $currency->setCode($currencyCode); + return $this->setCurrency($currency); + } +} \ No newline at end of file diff --git a/src/Fields/CustomerField.php b/src/Fields/CustomerField.php new file mode 100644 index 00000000..07ca6942 --- /dev/null +++ b/src/Fields/CustomerField.php @@ -0,0 +1,54 @@ +customer; + } + + public function getCustomerToCode(): ?string + { + if ($this->getCustomer() != null) { + return $this->customer->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setCustomer(?Customer $customer): self + { + $this->customer = $customer; + return $this; + } + + /** + * @param string|null $customerCode + * @return $this + * @throws Exception + */ + public function setCustomerFromCode(?string $customerCode) + { + $customer = new Customer(); + $customer->setCode($customerCode); + return $this->setCustomer($customer); + } +} diff --git a/src/Fields/DescriptionField.php b/src/Fields/DescriptionField.php new file mode 100644 index 00000000..6df17751 --- /dev/null +++ b/src/Fields/DescriptionField.php @@ -0,0 +1,32 @@ +description; + } + + /** + * @param null|string $description + * @return $this + */ + public function setDescription(?string $description): self + { + $this->description = $description; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Dim1Field.php b/src/Fields/Dim1Field.php new file mode 100644 index 00000000..6038ee17 --- /dev/null +++ b/src/Fields/Dim1Field.php @@ -0,0 +1,54 @@ +dim1; + } + + public function getDim1ToCode(): ?string + { + if ($this->getDim1() != null) { + return $this->dim1->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDim1(?GeneralLedger $dim1): self + { + $this->dim1 = $dim1; + return $this; + } + + /** + * @param string|null $dim1Code + * @return $this + * @throws Exception + */ + public function setDim1FromCode(?string $dim1Code) + { + $dim1 = new GeneralLedger(); + $dim1->setCode($dim1Code); + return $this->setDim1($dim1); + } +} \ No newline at end of file diff --git a/src/Fields/ElementValueField.php b/src/Fields/ElementValueField.php new file mode 100644 index 00000000..ba8adf61 --- /dev/null +++ b/src/Fields/ElementValueField.php @@ -0,0 +1,32 @@ +value; + } + + /** + * @param null|string $value + * @return $this + */ + public function setElementValue(?string $value): self + { + $this->value = $value; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/FreeText1Field.php b/src/Fields/FreeText1Field.php new file mode 100644 index 00000000..9f60251e --- /dev/null +++ b/src/Fields/FreeText1Field.php @@ -0,0 +1,32 @@ +freeText1; + } + + /** + * @param null|string $freeText1 + * @return $this + */ + public function setFreetext1(?string $freeText1): self + { + $this->freeText1 = $freeText1; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/FreeText2Field.php b/src/Fields/FreeText2Field.php new file mode 100644 index 00000000..ddc25e64 --- /dev/null +++ b/src/Fields/FreeText2Field.php @@ -0,0 +1,32 @@ +freeText2; + } + + /** + * @param null|string $freeText2 + * @return $this + */ + public function setFreetext2(?string $freeText2): self + { + $this->freeText2 = $freeText2; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/FreeText3Field.php b/src/Fields/FreeText3Field.php new file mode 100644 index 00000000..714440f6 --- /dev/null +++ b/src/Fields/FreeText3Field.php @@ -0,0 +1,32 @@ +freeText3; + } + + /** + * @param null|string $freeText3 + * @return $this + */ + public function setFreetext3(?string $freeText3): self + { + $this->freeText3 = $freeText3; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/IDField.php b/src/Fields/IDField.php new file mode 100644 index 00000000..bffb29d5 --- /dev/null +++ b/src/Fields/IDField.php @@ -0,0 +1,32 @@ +ID; + } + + /** + * @param null|int $ID + * @return $this + */ + public function setID(?int $ID): self + { + $this->ID = $ID; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/InUseField.php b/src/Fields/InUseField.php new file mode 100644 index 00000000..01c0da93 --- /dev/null +++ b/src/Fields/InUseField.php @@ -0,0 +1,47 @@ +inUse; + } + + public function getInUseToString(): ?string + { + return ($this->getInUse()) ? 'true' : 'false'; + } + + /** + * @param bool $inUse + * @return $this + */ + public function setInUse(?bool $inUse): self + { + $this->inUse = $inUse; + return $this; + } + + /** + * @param string|null $inUseString + * @return $this + * @throws Exception + */ + public function setInUseFromString(?string $inUseString) + { + return $this->setInUse(filter_var($inUseString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/ModifiedField.php b/src/Fields/ModifiedField.php new file mode 100644 index 00000000..e52ab189 --- /dev/null +++ b/src/Fields/ModifiedField.php @@ -0,0 +1,66 @@ +modified; + } + + /** + * @return string|null + */ + public function getModifiedToString(): ?string + { + if ($this->getModified() != null) { + return Util::formatDateTime($this->getModified()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $modified + * @return $this + */ + public function setModified(?\DateTimeInterface $modified) + { + $this->modified = $modified; + return $this; + } + + /** + * @param string|null $modifiedString + * @return $this + * @throws Exception + */ + public function setModifiedFromString(?string $modifiedString) + { + if ((bool)strtotime($modifiedString)) { + return $this->setModified(Util::parseDateTime($modifiedString)); + } else { + return $this->setModified(null); + } + } +} \ No newline at end of file diff --git a/src/Fields/NameField.php b/src/Fields/NameField.php new file mode 100644 index 00000000..d542794d --- /dev/null +++ b/src/Fields/NameField.php @@ -0,0 +1,31 @@ +name; + } + + /** + * @param null|string $name + * @return $this + */ + public function setName(?string $name): self + { + $this->name = $name; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/NrOfPeriodsField.php b/src/Fields/NrOfPeriodsField.php new file mode 100644 index 00000000..4cf207d2 --- /dev/null +++ b/src/Fields/NrOfPeriodsField.php @@ -0,0 +1,32 @@ +nrOfPeriods; + } + + /** + * @param null|int $nrOfPeriods + * @return $this + */ + public function setNrOfPeriods(?int $nrOfPeriods): self + { + $this->nrOfPeriods = $nrOfPeriods; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/OfficeField.php b/src/Fields/OfficeField.php new file mode 100644 index 00000000..1de4efd1 --- /dev/null +++ b/src/Fields/OfficeField.php @@ -0,0 +1,53 @@ +office; + } + + public function getOfficeToCode(): ?string + { + if ($this->getOffice() != null) { + return $this->office->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setOffice(?Office $office): self + { + $this->office = $office; + return $this; + } + + /** + * @param string|null $officeCode + * @return $this + * @throws Exception + */ + public function setOfficeFromCode(?string $officeCode) + { + $office = new Office(); + $office->setCode($officeCode); + return $this->setOffice($office); + } +} diff --git a/src/Fields/PercentageField.php b/src/Fields/PercentageField.php new file mode 100644 index 00000000..6a067250 --- /dev/null +++ b/src/Fields/PercentageField.php @@ -0,0 +1,32 @@ +percentage; + } + + /** + * @param null|float $percentage + * @return $this + */ + public function setPercentage(?float $percentage): self + { + $this->percentage = $percentage; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/PeriodField.php b/src/Fields/PeriodField.php new file mode 100644 index 00000000..32a030bc --- /dev/null +++ b/src/Fields/PeriodField.php @@ -0,0 +1,38 @@ +period; + } + + /** + * @param string|null $period + * @return $this + */ + public function setPeriod(?string $period): self + { + if (!preg_match("!\\d{4}/\\d{1,2}!", $period)) { + throw new \InvalidArgumentException("Period must be in YYYY/PP format (got: {$period}."); + } + + $this->period = $period; + + return $this; + } +} diff --git a/src/Fields/RateField.php b/src/Fields/RateField.php new file mode 100644 index 00000000..2b5bb755 --- /dev/null +++ b/src/Fields/RateField.php @@ -0,0 +1,54 @@ +rate; + } + + public function getRateToCode(): ?string + { + if ($this->getRate() != null) { + return $this->rate->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setRate(?Rate $rate): self + { + $this->rate = $rate; + return $this; + } + + /** + * @param string|null $rateCode + * @return $this + * @throws Exception + */ + public function setRateFromCode(?string $rateCode) + { + $rate = new Rate(); + $rate->setCode($rateCode); + return $this->setRate($rate); + } +} diff --git a/src/Fields/ShortNameField.php b/src/Fields/ShortNameField.php new file mode 100644 index 00000000..d32c7fe7 --- /dev/null +++ b/src/Fields/ShortNameField.php @@ -0,0 +1,31 @@ +shortName; + } + + /** + * @param null|string $shortName + * @return $this + */ + public function setShortName(?string $shortName): self + { + $this->shortName = $shortName; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/StatusField.php b/src/Fields/StatusField.php new file mode 100644 index 00000000..14297afe --- /dev/null +++ b/src/Fields/StatusField.php @@ -0,0 +1,40 @@ +status; + } + + /** + * @param Status|null $status + * @return $this + */ + public function setStatus(?Status $status): self + { + $this->status = $status; + return $this; + } + + /** + * @param string|null $statusString + * @return $this + * @throws Exception + */ + public function setStatusFromString(?string $statusString) + { + return $this->setStatus(new Status((string)$statusString)); + } +} \ No newline at end of file diff --git a/src/Fields/TouchedField.php b/src/Fields/TouchedField.php new file mode 100644 index 00000000..25baa093 --- /dev/null +++ b/src/Fields/TouchedField.php @@ -0,0 +1,32 @@ +touched; + } + + /** + * @param null|int $touched + * @return $this + */ + public function setTouched(?int $touched): self + { + $this->touched = $touched; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/UIDField.php b/src/Fields/UIDField.php new file mode 100644 index 00000000..f0f9d20a --- /dev/null +++ b/src/Fields/UIDField.php @@ -0,0 +1,32 @@ +UID; + } + + /** + * @param null|string $UID + * @return $this + */ + public function setUID(?string $UID): self + { + $this->UID = $UID; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/UserField.php b/src/Fields/UserField.php new file mode 100644 index 00000000..a8c756b1 --- /dev/null +++ b/src/Fields/UserField.php @@ -0,0 +1,55 @@ +user; + } + + public function getUserToCode(): ?string + { + if ($this->getUser() != null) { + return $this->user->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setUser(?User $user): self + { + $this->user = $user; + return $this; + } + + /** + * @param string|null $userCode + * @return $this + * @throws Exception + */ + public function setUserFromCode(?string $userCode) + { + $user = new User(); + $user->setCode($userCode); + return $this->setUser($user); + } +} + diff --git a/src/Fields/VatCodeField.php b/src/Fields/VatCodeField.php new file mode 100644 index 00000000..64ec772f --- /dev/null +++ b/src/Fields/VatCodeField.php @@ -0,0 +1,54 @@ +vatCode; + } + + public function getVatCodeToCode(): ?string + { + if ($this->getVatCode() != null) { + return $this->vatCode->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setVatCode(?VatCode $vatCode): self + { + $this->vatCode = $vatCode; + return $this; + } + + /** + * @param string|null $vatCodeCode + * @return $this + * @throws Exception + */ + public function setVatCodeFromCode(?string $vatCodeCode) + { + $vatCode = new VatCode(); + $vatCode->setCode($vatCodeCode); + return $this->setVatCode($vatCode); + } +} From 329c2c28b90df858f43232097ee7790a22e7990d Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:28:35 +0200 Subject: [PATCH 054/388] Add files via upload --- .../AssetMethod/AssetsToActivateField.php | 54 +++++++++++++++ src/Fields/AssetMethod/CalcMethodField.php | 41 ++++++++++++ .../DepreciateReconciliationField.php | 41 ++++++++++++ src/Fields/AssetMethod/DepreciationField.php | 54 +++++++++++++++ .../AssetMethod/DepreciationGroupField.php | 54 +++++++++++++++ src/Fields/AssetMethod/FreeTextTypeField.php | 41 ++++++++++++ src/Fields/AssetMethod/PurchaseValueField.php | 54 +++++++++++++++ .../AssetMethod/PurchaseValueGroupField.php | 54 +++++++++++++++ .../AssetMethod/ReconciliationField.php | 54 +++++++++++++++ src/Fields/AssetMethod/SalesField.php | 54 +++++++++++++++ src/Fields/AssetMethod/ToBeInvoicedField.php | 54 +++++++++++++++ src/Fields/Currency/CurrencyRateRateField.php | 32 +++++++++ src/Fields/Currency/StartDateField.php | 65 ++++++++++++++++++ .../Invoice/AllowDiscountOrPremiumField.php | 47 +++++++++++++ .../AllowChangePerformanceTypeField.php | 47 +++++++++++++ .../Article/AllowChangeUnitsPriceField.php | 47 +++++++++++++ .../Article/AllowChangeVatCodeField.php | 47 +++++++++++++ .../Article/AllowDecimalQuantityField.php | 47 +++++++++++++ .../Article/ArticleLineFreeText1Field.php | 54 +++++++++++++++ .../Article/ArticleLineFreeText2Field.php | 54 +++++++++++++++ .../Article/ArticlePercentageField.php | 47 +++++++++++++ .../Invoice/Article/ArticleTypeField.php | 41 ++++++++++++ src/Fields/Invoice/Article/SubCodeField.php | 32 +++++++++ .../Invoice/Article/UnitNamePluralField.php | 32 +++++++++ .../Invoice/Article/UnitNameSingularField.php | 32 +++++++++ src/Fields/Invoice/ArticleField.php | 54 +++++++++++++++ src/Fields/Invoice/BankField.php | 54 +++++++++++++++ src/Fields/Invoice/CalculateOnlyField.php | 47 +++++++++++++ src/Fields/Invoice/CustomerNameField.php | 32 +++++++++ .../Invoice/DeliverAddressNumberField.php | 32 +++++++++ src/Fields/Invoice/DueDateField.php | 66 +++++++++++++++++++ src/Fields/Invoice/FinancialCodeField.php | 32 +++++++++ src/Fields/Invoice/FinancialNumberField.php | 32 +++++++++ src/Fields/Invoice/FooterTextField.php | 32 +++++++++ src/Fields/Invoice/HeaderTextField.php | 32 +++++++++ .../Invoice/InvoiceAddressNumberField.php | 32 +++++++++ src/Fields/Invoice/InvoiceAmountField.php | 62 +++++++++++++++++ src/Fields/Invoice/InvoiceDateField.php | 66 +++++++++++++++++++ .../Invoice/InvoiceDebitCreditField.php | 41 ++++++++++++ src/Fields/Invoice/InvoiceNumberField.php | 32 +++++++++ src/Fields/Invoice/InvoiceStatusField.php | 41 ++++++++++++ src/Fields/Invoice/InvoiceTypeField.php | 54 +++++++++++++++ src/Fields/Invoice/PaymentMethodField.php | 41 ++++++++++++ src/Fields/Invoice/PerformanceDateField.php | 66 +++++++++++++++++++ src/Fields/Invoice/PerformanceTypeField.php | 41 ++++++++++++ src/Fields/Invoice/QuantityField.php | 32 +++++++++ src/Fields/Invoice/RaiseWarningField.php | 47 +++++++++++++ src/Fields/Invoice/SubArticleField.php | 54 +++++++++++++++ src/Fields/Invoice/UnitsField.php | 32 +++++++++ src/Fields/Invoice/UnitsPriceExclField.php | 62 +++++++++++++++++ src/Fields/Invoice/UnitsPriceIncField.php | 62 +++++++++++++++++ src/Fields/Invoice/ValueExclField.php | 62 +++++++++++++++++ src/Fields/Invoice/ValueIncField.php | 62 +++++++++++++++++ src/Fields/Invoice/VatValueField.php | 62 +++++++++++++++++ src/Fields/Office/CountryCodeField.php | 32 +++++++++ .../Office/VatFirstQuarterStartsInField.php | 32 +++++++++ src/Fields/Office/VatPeriodField.php | 32 +++++++++ src/Fields/Rate/BeginDateField.php | 66 +++++++++++++++++++ src/Fields/Rate/EndDateField.php | 66 +++++++++++++++++++ src/Fields/Rate/ExternalRateField.php | 32 +++++++++ src/Fields/Rate/InternalRateField.php | 32 +++++++++ src/Fields/Rate/RateTypeField.php | 41 ++++++++++++ src/Fields/Rate/UnitField.php | 32 +++++++++ src/Fields/User/IsCurrentUserField.php | 47 +++++++++++++ src/Fields/User/UserLevelField.php | 32 +++++++++ src/Fields/VatCode/DateField.php | 66 +++++++++++++++++++ src/Fields/VatCode/LineTypeField.php | 41 ++++++++++++ src/Fields/VatCode/VatCodeTypeField.php | 41 ++++++++++++ src/Fields/VatCode/VatGroupCountryField.php | 54 +++++++++++++++ src/Fields/VatCode/VatGroupField.php | 54 +++++++++++++++ 70 files changed, 3243 insertions(+) create mode 100644 src/Fields/AssetMethod/AssetsToActivateField.php create mode 100644 src/Fields/AssetMethod/CalcMethodField.php create mode 100644 src/Fields/AssetMethod/DepreciateReconciliationField.php create mode 100644 src/Fields/AssetMethod/DepreciationField.php create mode 100644 src/Fields/AssetMethod/DepreciationGroupField.php create mode 100644 src/Fields/AssetMethod/FreeTextTypeField.php create mode 100644 src/Fields/AssetMethod/PurchaseValueField.php create mode 100644 src/Fields/AssetMethod/PurchaseValueGroupField.php create mode 100644 src/Fields/AssetMethod/ReconciliationField.php create mode 100644 src/Fields/AssetMethod/SalesField.php create mode 100644 src/Fields/AssetMethod/ToBeInvoicedField.php create mode 100644 src/Fields/Currency/CurrencyRateRateField.php create mode 100644 src/Fields/Currency/StartDateField.php create mode 100644 src/Fields/Invoice/AllowDiscountOrPremiumField.php create mode 100644 src/Fields/Invoice/Article/AllowChangePerformanceTypeField.php create mode 100644 src/Fields/Invoice/Article/AllowChangeUnitsPriceField.php create mode 100644 src/Fields/Invoice/Article/AllowChangeVatCodeField.php create mode 100644 src/Fields/Invoice/Article/AllowDecimalQuantityField.php create mode 100644 src/Fields/Invoice/Article/ArticleLineFreeText1Field.php create mode 100644 src/Fields/Invoice/Article/ArticleLineFreeText2Field.php create mode 100644 src/Fields/Invoice/Article/ArticlePercentageField.php create mode 100644 src/Fields/Invoice/Article/ArticleTypeField.php create mode 100644 src/Fields/Invoice/Article/SubCodeField.php create mode 100644 src/Fields/Invoice/Article/UnitNamePluralField.php create mode 100644 src/Fields/Invoice/Article/UnitNameSingularField.php create mode 100644 src/Fields/Invoice/ArticleField.php create mode 100644 src/Fields/Invoice/BankField.php create mode 100644 src/Fields/Invoice/CalculateOnlyField.php create mode 100644 src/Fields/Invoice/CustomerNameField.php create mode 100644 src/Fields/Invoice/DeliverAddressNumberField.php create mode 100644 src/Fields/Invoice/DueDateField.php create mode 100644 src/Fields/Invoice/FinancialCodeField.php create mode 100644 src/Fields/Invoice/FinancialNumberField.php create mode 100644 src/Fields/Invoice/FooterTextField.php create mode 100644 src/Fields/Invoice/HeaderTextField.php create mode 100644 src/Fields/Invoice/InvoiceAddressNumberField.php create mode 100644 src/Fields/Invoice/InvoiceAmountField.php create mode 100644 src/Fields/Invoice/InvoiceDateField.php create mode 100644 src/Fields/Invoice/InvoiceDebitCreditField.php create mode 100644 src/Fields/Invoice/InvoiceNumberField.php create mode 100644 src/Fields/Invoice/InvoiceStatusField.php create mode 100644 src/Fields/Invoice/InvoiceTypeField.php create mode 100644 src/Fields/Invoice/PaymentMethodField.php create mode 100644 src/Fields/Invoice/PerformanceDateField.php create mode 100644 src/Fields/Invoice/PerformanceTypeField.php create mode 100644 src/Fields/Invoice/QuantityField.php create mode 100644 src/Fields/Invoice/RaiseWarningField.php create mode 100644 src/Fields/Invoice/SubArticleField.php create mode 100644 src/Fields/Invoice/UnitsField.php create mode 100644 src/Fields/Invoice/UnitsPriceExclField.php create mode 100644 src/Fields/Invoice/UnitsPriceIncField.php create mode 100644 src/Fields/Invoice/ValueExclField.php create mode 100644 src/Fields/Invoice/ValueIncField.php create mode 100644 src/Fields/Invoice/VatValueField.php create mode 100644 src/Fields/Office/CountryCodeField.php create mode 100644 src/Fields/Office/VatFirstQuarterStartsInField.php create mode 100644 src/Fields/Office/VatPeriodField.php create mode 100644 src/Fields/Rate/BeginDateField.php create mode 100644 src/Fields/Rate/EndDateField.php create mode 100644 src/Fields/Rate/ExternalRateField.php create mode 100644 src/Fields/Rate/InternalRateField.php create mode 100644 src/Fields/Rate/RateTypeField.php create mode 100644 src/Fields/Rate/UnitField.php create mode 100644 src/Fields/User/IsCurrentUserField.php create mode 100644 src/Fields/User/UserLevelField.php create mode 100644 src/Fields/VatCode/DateField.php create mode 100644 src/Fields/VatCode/LineTypeField.php create mode 100644 src/Fields/VatCode/VatCodeTypeField.php create mode 100644 src/Fields/VatCode/VatGroupCountryField.php create mode 100644 src/Fields/VatCode/VatGroupField.php diff --git a/src/Fields/AssetMethod/AssetsToActivateField.php b/src/Fields/AssetMethod/AssetsToActivateField.php new file mode 100644 index 00000000..e493dda2 --- /dev/null +++ b/src/Fields/AssetMethod/AssetsToActivateField.php @@ -0,0 +1,54 @@ +assetsToActivate; + } + + public function getAssetsToActivateToCode(): ?string + { + if ($this->getAssetsToActivate() != null) { + return $this->assetsToActivate->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setAssetsToActivate(?GeneralLedger $assetsToActivate): self + { + $this->assetsToActivate = $assetsToActivate; + return $this; + } + + /** + * @param string|null $assetsToActivateCode + * @return $this + * @throws Exception + */ + public function setAssetsToActivateFromCode(?string $assetsToActivateCode) + { + $assetsToActivate = new GeneralLedger(); + $assetsToActivate->setCode($assetsToActivateCode); + return $this->setAssetsToActivate($assetsToActivate); + } +} \ No newline at end of file diff --git a/src/Fields/AssetMethod/CalcMethodField.php b/src/Fields/AssetMethod/CalcMethodField.php new file mode 100644 index 00000000..f88e05ba --- /dev/null +++ b/src/Fields/AssetMethod/CalcMethodField.php @@ -0,0 +1,41 @@ +calcMethod; + } + + /** + * @param CalcMethod|null $calcMethod + * @return $this + */ + public function setCalcMethod(?CalcMethod $calcMethod): self + { + $this->calcMethod = $calcMethod; + return $this; + } + + /** + * @param string|null $calcMethodString + * @return $this + * @throws Exception + */ + public function setCalcMethodFromString(?string $calcMethodString) + { + return $this->setCalcMethod(new CalcMethod((string)$calcMethodString)); + } +} \ No newline at end of file diff --git a/src/Fields/AssetMethod/DepreciateReconciliationField.php b/src/Fields/AssetMethod/DepreciateReconciliationField.php new file mode 100644 index 00000000..63000ee8 --- /dev/null +++ b/src/Fields/AssetMethod/DepreciateReconciliationField.php @@ -0,0 +1,41 @@ +depreciateReconciliation; + } + + /** + * @param DepreciateReconciliation|null $depreciateReconciliation + * @return $this + */ + public function setDepreciateReconciliation(?DepreciateReconciliation $depreciateReconciliation): self + { + $this->depreciateReconciliation = $depreciateReconciliation; + return $this; + } + + /** + * @param string|null $depreciateReconciliationString + * @return $this + * @throws Exception + */ + public function setDepreciateReconciliationFromString(?string $depreciateReconciliationString) + { + return $this->setDepreciateReconciliation(new DepreciateReconciliation((string)$depreciateReconciliationString)); + } +} \ No newline at end of file diff --git a/src/Fields/AssetMethod/DepreciationField.php b/src/Fields/AssetMethod/DepreciationField.php new file mode 100644 index 00000000..64f10f1c --- /dev/null +++ b/src/Fields/AssetMethod/DepreciationField.php @@ -0,0 +1,54 @@ +depreciation; + } + + public function getDepreciationToCode(): ?string + { + if ($this->getDepreciation() != null) { + return $this->depreciation->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDepreciation(?GeneralLedger $depreciation): self + { + $this->depreciation = $depreciation; + return $this; + } + + /** + * @param string|null $depreciationCode + * @return $this + * @throws Exception + */ + public function setDepreciationFromCode(?string $depreciationCode) + { + $depreciation = new GeneralLedger(); + $depreciation->setCode($depreciationCode); + return $this->setDepreciation($depreciation); + } +} \ No newline at end of file diff --git a/src/Fields/AssetMethod/DepreciationGroupField.php b/src/Fields/AssetMethod/DepreciationGroupField.php new file mode 100644 index 00000000..0b547b1c --- /dev/null +++ b/src/Fields/AssetMethod/DepreciationGroupField.php @@ -0,0 +1,54 @@ +depreciationGroup; + } + + public function getDepreciationGroupToCode(): ?string + { + if ($this->getDepreciationGroup() != null) { + return $this->depreciationGroup->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDepreciationGroup(?DimensionGroup $depreciationGroup): self + { + $this->depreciationGroup = $depreciationGroup; + return $this; + } + + /** + * @param string|null $depreciationGroupCode + * @return $this + * @throws Exception + */ + public function setDepreciationGroupFromCode(?string $depreciationGroupCode) + { + $depreciationGroup = new DimensionGroup(); + $depreciationGroup->setCode($depreciationGroupCode); + return $this->setDepreciationGroup($depreciationGroup); + } +} \ No newline at end of file diff --git a/src/Fields/AssetMethod/FreeTextTypeField.php b/src/Fields/AssetMethod/FreeTextTypeField.php new file mode 100644 index 00000000..ba4ed360 --- /dev/null +++ b/src/Fields/AssetMethod/FreeTextTypeField.php @@ -0,0 +1,41 @@ +type; + } + + /** + * @param FreeTextType|null $type + * @return $this + */ + public function setType(?FreeTextType $type): self + { + $this->type = $type; + return $this; + } + + /** + * @param string|null $typeString + * @return $this + * @throws Exception + */ + public function setTypeFromString(?string $typeString) + { + return $this->setType(new FreeTextType((string)$typeString)); + } +} \ No newline at end of file diff --git a/src/Fields/AssetMethod/PurchaseValueField.php b/src/Fields/AssetMethod/PurchaseValueField.php new file mode 100644 index 00000000..68875c3f --- /dev/null +++ b/src/Fields/AssetMethod/PurchaseValueField.php @@ -0,0 +1,54 @@ +purchaseValue; + } + + public function getPurchaseValueToCode(): ?string + { + if ($this->getPurchaseValue() != null) { + return $this->purchaseValue->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setPurchaseValue(?GeneralLedger $purchaseValue): self + { + $this->purchaseValue = $purchaseValue; + return $this; + } + + /** + * @param string|null $purchaseValueCode + * @return $this + * @throws Exception + */ + public function setPurchaseValueFromCode(?string $purchaseValueCode) + { + $purchaseValue = new GeneralLedger(); + $purchaseValue->setCode($purchaseValueCode); + return $this->setPurchaseValue($purchaseValue); + } +} \ No newline at end of file diff --git a/src/Fields/AssetMethod/PurchaseValueGroupField.php b/src/Fields/AssetMethod/PurchaseValueGroupField.php new file mode 100644 index 00000000..d930b332 --- /dev/null +++ b/src/Fields/AssetMethod/PurchaseValueGroupField.php @@ -0,0 +1,54 @@ +purchaseValueGroup; + } + + public function getPurchaseValueGroupToCode(): ?string + { + if ($this->getPurchaseValueGroup() != null) { + return $this->purchaseValueGroup->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setPurchaseValueGroup(?DimensionGroup $purchaseValueGroup): self + { + $this->purchaseValueGroup = $purchaseValueGroup; + return $this; + } + + /** + * @param string|null $purchaseValueGroupCode + * @return $this + * @throws Exception + */ + public function setPurchaseValueGroupFromCode(?string $purchaseValueGroupCode) + { + $purchaseValueGroup = new DimensionGroup(); + $purchaseValueGroup->setCode($purchaseValueGroupCode); + return $this->setPurchaseValueGroup($purchaseValueGroup); + } +} \ No newline at end of file diff --git a/src/Fields/AssetMethod/ReconciliationField.php b/src/Fields/AssetMethod/ReconciliationField.php new file mode 100644 index 00000000..c5a7b05c --- /dev/null +++ b/src/Fields/AssetMethod/ReconciliationField.php @@ -0,0 +1,54 @@ +reconciliation; + } + + public function getReconciliationToCode(): ?string + { + if ($this->getReconciliation() != null) { + return $this->reconciliation->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setReconciliation(?GeneralLedger $reconciliation): self + { + $this->reconciliation = $reconciliation; + return $this; + } + + /** + * @param string|null $reconciliationCode + * @return $this + * @throws Exception + */ + public function setReconciliationFromCode(?string $reconciliationCode) + { + $reconciliation = new GeneralLedger(); + $reconciliation->setCode($reconciliationCode); + return $this->setReconciliation($reconciliation); + } +} \ No newline at end of file diff --git a/src/Fields/AssetMethod/SalesField.php b/src/Fields/AssetMethod/SalesField.php new file mode 100644 index 00000000..c5a8230c --- /dev/null +++ b/src/Fields/AssetMethod/SalesField.php @@ -0,0 +1,54 @@ +sales; + } + + public function getSalesToCode(): ?string + { + if ($this->getSales() != null) { + return $this->sales->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setSales(?GeneralLedger $sales): self + { + $this->sales = $sales; + return $this; + } + + /** + * @param string|null $salesCode + * @return $this + * @throws Exception + */ + public function setSalesFromCode(?string $salesCode) + { + $sales = new GeneralLedger(); + $sales->setCode($salesCode); + return $this->setSales($sales); + } +} \ No newline at end of file diff --git a/src/Fields/AssetMethod/ToBeInvoicedField.php b/src/Fields/AssetMethod/ToBeInvoicedField.php new file mode 100644 index 00000000..08b3c69b --- /dev/null +++ b/src/Fields/AssetMethod/ToBeInvoicedField.php @@ -0,0 +1,54 @@ +toBeInvoiced; + } + + public function getToBeInvoicedToCode(): ?string + { + if ($this->getToBeInvoiced() != null) { + return $this->toBeInvoiced->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setToBeInvoiced(?GeneralLedger $toBeInvoiced): self + { + $this->toBeInvoiced = $toBeInvoiced; + return $this; + } + + /** + * @param string|null $toBeInvoicedCode + * @return $this + * @throws Exception + */ + public function setToBeInvoicedFromCode(?string $toBeInvoicedCode) + { + $toBeInvoiced = new GeneralLedger(); + $toBeInvoiced->setCode($toBeInvoicedCode); + return $this->setToBeInvoiced($toBeInvoiced); + } +} \ No newline at end of file diff --git a/src/Fields/Currency/CurrencyRateRateField.php b/src/Fields/Currency/CurrencyRateRateField.php new file mode 100644 index 00000000..71398cf3 --- /dev/null +++ b/src/Fields/Currency/CurrencyRateRateField.php @@ -0,0 +1,32 @@ +rate; + } + + /** + * @param null|float $rate + * @return $this + */ + public function setRate(?float $rate): self + { + $this->rate = $rate; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Currency/StartDateField.php b/src/Fields/Currency/StartDateField.php new file mode 100644 index 00000000..ffc7b1b0 --- /dev/null +++ b/src/Fields/Currency/StartDateField.php @@ -0,0 +1,65 @@ +startDate; + } + + /** + * @return string|null + */ + public function getStartDateToString(): ?string + { + if ($this->getStartDate() != null) { + return Util::formatDate($this->getStartDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $startDate + * @return $this + */ + public function setStartDate(?\DateTimeInterface $startDate) + { + $this->startDate = $startDate; + return $this; + } + + /** + * @param string|null $startDateString + * @return $this + * @throws Exception + */ + public function setStartDateFromString(?string $startDateString) + { + if ((bool)strtotime($startDateString)) { + return $this->setStartDate(Util::parseDate($startDateString)); + } else { + return $this->setStartDate(null); + } + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/AllowDiscountOrPremiumField.php b/src/Fields/Invoice/AllowDiscountOrPremiumField.php new file mode 100644 index 00000000..54aabe65 --- /dev/null +++ b/src/Fields/Invoice/AllowDiscountOrPremiumField.php @@ -0,0 +1,47 @@ +allowDiscountOrPremium; + } + + public function getAllowDiscountOrPremiumToString(): ?string + { + return ($this->getAllowDiscountOrPremium()) ? 'true' : 'false'; + } + + /** + * @param bool $allowDiscountOrPremium + * @return $this + */ + public function setAllowDiscountOrPremium(?bool $allowDiscountOrPremium): self + { + $this->allowDiscountOrPremium = $allowDiscountOrPremium; + return $this; + } + + /** + * @param string|null $allowDiscountOrPremiumString + * @return $this + * @throws Exception + */ + public function setAllowDiscountOrPremiumFromString(?string $allowDiscountOrPremiumString) + { + return $this->setAllowDiscountOrPremium(filter_var($allowDiscountOrPremiumString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/Article/AllowChangePerformanceTypeField.php b/src/Fields/Invoice/Article/AllowChangePerformanceTypeField.php new file mode 100644 index 00000000..bdc10c2e --- /dev/null +++ b/src/Fields/Invoice/Article/AllowChangePerformanceTypeField.php @@ -0,0 +1,47 @@ +allowChangePerformanceType; + } + + public function getAllowChangePerformanceTypeToString(): ?string + { + return ($this->getAllowChangePerformanceType()) ? 'true' : 'false'; + } + + /** + * @param bool $allowChangePerformanceType + * @return $this + */ + public function setAllowChangePerformanceType(?bool $allowChangePerformanceType): self + { + $this->allowChangePerformanceType = $allowChangePerformanceType; + return $this; + } + + /** + * @param string|null $allowChangePerformanceTypeString + * @return $this + * @throws Exception + */ + public function setAllowChangePerformanceTypeFromString(?string $allowChangePerformanceTypeString) + { + return $this->setAllowChangePerformanceType(filter_var($allowChangePerformanceTypeString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/Article/AllowChangeUnitsPriceField.php b/src/Fields/Invoice/Article/AllowChangeUnitsPriceField.php new file mode 100644 index 00000000..c8c51909 --- /dev/null +++ b/src/Fields/Invoice/Article/AllowChangeUnitsPriceField.php @@ -0,0 +1,47 @@ +allowChangeUnitsPrice; + } + + public function getAllowChangeUnitsPriceToString(): ?string + { + return ($this->getAllowChangeUnitsPrice()) ? 'true' : 'false'; + } + + /** + * @param bool $allowChangeUnitsPrice + * @return $this + */ + public function setAllowChangeUnitsPrice(?bool $allowChangeUnitsPrice): self + { + $this->allowChangeUnitsPrice = $allowChangeUnitsPrice; + return $this; + } + + /** + * @param string|null $allowChangeUnitsPriceString + * @return $this + * @throws Exception + */ + public function setAllowChangeUnitsPriceFromString(?string $allowChangeUnitsPriceString) + { + return $this->setAllowChangeUnitsPrice(filter_var($allowChangeUnitsPriceString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/Article/AllowChangeVatCodeField.php b/src/Fields/Invoice/Article/AllowChangeVatCodeField.php new file mode 100644 index 00000000..fde5bb6f --- /dev/null +++ b/src/Fields/Invoice/Article/AllowChangeVatCodeField.php @@ -0,0 +1,47 @@ +allowChangeVatCode; + } + + public function getAllowChangeVatCodeToString(): ?string + { + return ($this->getAllowChangeVatCode()) ? 'true' : 'false'; + } + + /** + * @param bool $allowChangeVatCode + * @return $this + */ + public function setAllowChangeVatCode(?bool $allowChangeVatCode): self + { + $this->allowChangeVatCode = $allowChangeVatCode; + return $this; + } + + /** + * @param string|null $allowChangeVatCodeString + * @return $this + * @throws Exception + */ + public function setAllowChangeVatCodeFromString(?string $allowChangeVatCodeString) + { + return $this->setAllowChangeVatCode(filter_var($allowChangeVatCodeString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/Article/AllowDecimalQuantityField.php b/src/Fields/Invoice/Article/AllowDecimalQuantityField.php new file mode 100644 index 00000000..1ba81b39 --- /dev/null +++ b/src/Fields/Invoice/Article/AllowDecimalQuantityField.php @@ -0,0 +1,47 @@ +allowDecimalQuantity; + } + + public function getAllowDecimalQuantityToString(): ?string + { + return ($this->getAllowDecimalQuantity()) ? 'true' : 'false'; + } + + /** + * @param bool $allowDecimalQuantity + * @return $this + */ + public function setAllowDecimalQuantity(?bool $allowDecimalQuantity): self + { + $this->allowDecimalQuantity = $allowDecimalQuantity; + return $this; + } + + /** + * @param string|null $allowDecimalQuantityString + * @return $this + * @throws Exception + */ + public function setAllowDecimalQuantityFromString(?string $allowDecimalQuantityString) + { + return $this->setAllowDecimalQuantity(filter_var($allowDecimalQuantityString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/Article/ArticleLineFreeText1Field.php b/src/Fields/Invoice/Article/ArticleLineFreeText1Field.php new file mode 100644 index 00000000..28e58215 --- /dev/null +++ b/src/Fields/Invoice/Article/ArticleLineFreeText1Field.php @@ -0,0 +1,54 @@ +freeText1; + } + + public function getFreeText1ToCode(): ?string + { + if ($this->getFreeText1() != null) { + return $this->freeText1->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setFreeText1(?GeneralLedger $freeText1): self + { + $this->freeText1 = $freeText1; + return $this; + } + + /** + * @param string|null $freeText1Code + * @return $this + * @throws Exception + */ + public function setFreeText1FromCode(?string $freeText1Code) + { + $freeText1 = new GeneralLedger(); + $freeText1->setCode($freeText1Code); + return $this->setFreeText1($freeText1); + } +} diff --git a/src/Fields/Invoice/Article/ArticleLineFreeText2Field.php b/src/Fields/Invoice/Article/ArticleLineFreeText2Field.php new file mode 100644 index 00000000..084df49e --- /dev/null +++ b/src/Fields/Invoice/Article/ArticleLineFreeText2Field.php @@ -0,0 +1,54 @@ +freeText2; + } + + public function getFreeText2ToCode(): ?string + { + if ($this->getFreeText2() != null) { + return $this->freeText2->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setFreeText2(?CostCenter $freeText2): self + { + $this->freeText2 = $freeText2; + return $this; + } + + /** + * @param string|null $freeText2Code + * @return $this + * @throws Exception + */ + public function setFreeText2FromCode(?string $freeText2Code) + { + $freeText2 = new CostCenter(); + $freeText2->setCode($freeText2Code); + return $this->setFreeText2($freeText2); + } +} diff --git a/src/Fields/Invoice/Article/ArticlePercentageField.php b/src/Fields/Invoice/Article/ArticlePercentageField.php new file mode 100644 index 00000000..6c09aa80 --- /dev/null +++ b/src/Fields/Invoice/Article/ArticlePercentageField.php @@ -0,0 +1,47 @@ +percentage; + } + + public function getPercentageToString(): ?string + { + return ($this->getPercentage()) ? 'true' : 'false'; + } + + /** + * @param bool $percentage + * @return $this + */ + public function setPercentage(?bool $percentage): self + { + $this->percentage = $percentage; + return $this; + } + + /** + * @param string|null $percentageString + * @return $this + * @throws Exception + */ + public function setPercentageFromString(?string $percentageString) + { + return $this->setPercentage(filter_var($percentageString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/Article/ArticleTypeField.php b/src/Fields/Invoice/Article/ArticleTypeField.php new file mode 100644 index 00000000..19bac60c --- /dev/null +++ b/src/Fields/Invoice/Article/ArticleTypeField.php @@ -0,0 +1,41 @@ +type; + } + + /** + * @param ArticleType|null $type + * @return $this + */ + public function setType(?ArticleType $type): self + { + $this->type = $type; + return $this; + } + + /** + * @param string|null $typeString + * @return $this + * @throws Exception + */ + public function setTypeFromString(?string $typeString) + { + return $this->setType(new ArticleType((string)$typeString)); + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/Article/SubCodeField.php b/src/Fields/Invoice/Article/SubCodeField.php new file mode 100644 index 00000000..c283bf5d --- /dev/null +++ b/src/Fields/Invoice/Article/SubCodeField.php @@ -0,0 +1,32 @@ +subCode; + } + + /** + * @param null|string $subCode + * @return $this + */ + public function setSubCode(?string $subCode): self + { + $this->subCode = $subCode; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/Article/UnitNamePluralField.php b/src/Fields/Invoice/Article/UnitNamePluralField.php new file mode 100644 index 00000000..01100be2 --- /dev/null +++ b/src/Fields/Invoice/Article/UnitNamePluralField.php @@ -0,0 +1,32 @@ +unitNamePlural; + } + + /** + * @param null|string $unitNamePlural + * @return $this + */ + public function setUnitNamePlural(?string $unitNamePlural): self + { + $this->unitNamePlural = $unitNamePlural; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/Article/UnitNameSingularField.php b/src/Fields/Invoice/Article/UnitNameSingularField.php new file mode 100644 index 00000000..058a8758 --- /dev/null +++ b/src/Fields/Invoice/Article/UnitNameSingularField.php @@ -0,0 +1,32 @@ +unitNameSingular; + } + + /** + * @param null|string $unitNameSingular + * @return $this + */ + public function setUnitNameSingular(?string $unitNameSingular): self + { + $this->unitNameSingular = $unitNameSingular; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/ArticleField.php b/src/Fields/Invoice/ArticleField.php new file mode 100644 index 00000000..c15d26f9 --- /dev/null +++ b/src/Fields/Invoice/ArticleField.php @@ -0,0 +1,54 @@ +article; + } + + public function getArticleToCode(): ?string + { + if ($this->getArticle() != null) { + return $this->article->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setArticle(?Article $article): self + { + $this->article = $article; + return $this; + } + + /** + * @param string|null $articleCode + * @return $this + * @throws Exception + */ + public function setArticleFromCode(?string $articleCode) + { + $article = new Article(); + $article->setCode($articleCode); + return $this->setArticle($article); + } +} diff --git a/src/Fields/Invoice/BankField.php b/src/Fields/Invoice/BankField.php new file mode 100644 index 00000000..c1fd1d8b --- /dev/null +++ b/src/Fields/Invoice/BankField.php @@ -0,0 +1,54 @@ +bank; + } + + public function getBankToCode(): ?string + { + if ($this->getBank() != null) { + return $this->bank->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setBank(?CashBankBook $bank): self + { + $this->bank = $bank; + return $this; + } + + /** + * @param string|null $bankCode + * @return $this + * @throws Exception + */ + public function setBankFromCode(?string $bankCode) + { + $bank = new CashBankBook(); + $bank->setCode($bankCode); + return $this->setBank($bank); + } +} diff --git a/src/Fields/Invoice/CalculateOnlyField.php b/src/Fields/Invoice/CalculateOnlyField.php new file mode 100644 index 00000000..b1f44fb0 --- /dev/null +++ b/src/Fields/Invoice/CalculateOnlyField.php @@ -0,0 +1,47 @@ +calculateOnly; + } + + public function getCalculateOnlyToString(): ?string + { + return ($this->getCalculateOnly()) ? 'true' : 'false'; + } + + /** + * @param bool $calculateOnly + * @return $this + */ + public function setCalculateOnly(?bool $calculateOnly): self + { + $this->calculateOnly = $calculateOnly; + return $this; + } + + /** + * @param string|null $calculateOnlyString + * @return $this + * @throws Exception + */ + public function setCalculateOnlyFromString(?string $calculateOnlyString) + { + return $this->setCalculateOnly(filter_var($calculateOnlyString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/CustomerNameField.php b/src/Fields/Invoice/CustomerNameField.php new file mode 100644 index 00000000..088ea076 --- /dev/null +++ b/src/Fields/Invoice/CustomerNameField.php @@ -0,0 +1,32 @@ +customerName; + } + + /** + * @param null|string $customerName + * @return $this + */ + public function setCustomerName(?string $customerName): self + { + $this->customerName = $customerName; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/DeliverAddressNumberField.php b/src/Fields/Invoice/DeliverAddressNumberField.php new file mode 100644 index 00000000..6eca97dc --- /dev/null +++ b/src/Fields/Invoice/DeliverAddressNumberField.php @@ -0,0 +1,32 @@ +deliverAddressNumber; + } + + /** + * @param null|int $deliverAddressNumber + * @return $this + */ + public function setDeliverAddressNumber(?int $deliverAddressNumber): self + { + $this->deliverAddressNumber = $deliverAddressNumber; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/DueDateField.php b/src/Fields/Invoice/DueDateField.php new file mode 100644 index 00000000..18e967c1 --- /dev/null +++ b/src/Fields/Invoice/DueDateField.php @@ -0,0 +1,66 @@ +dueDate; + } + + /** + * @return string|null + */ + public function getDueDateToString(): ?string + { + if ($this->getDueDate() != null) { + return Util::formatDate($this->getDueDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $dueDate + * @return $this + */ + public function setDueDate(?\DateTimeInterface $dueDate) + { + $this->dueDate = $dueDate; + return $this; + } + + /** + * @param string|null $dueDateString + * @return $this + * @throws Exception + */ + public function setDueDateFromString(?string $dueDateString) + { + if ((bool)strtotime($dueDateString)) { + return $this->setDueDate(Util::parseDate($dueDateString)); + } else { + return $this->setDueDate(null); + } + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/FinancialCodeField.php b/src/Fields/Invoice/FinancialCodeField.php new file mode 100644 index 00000000..9f362e93 --- /dev/null +++ b/src/Fields/Invoice/FinancialCodeField.php @@ -0,0 +1,32 @@ +code; + } + + /** + * @param null|string $financialCode + * @return $this + */ + public function setFinancialCode(?string $financialCode): self + { + $this->financialCode = $financialCode; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/FinancialNumberField.php b/src/Fields/Invoice/FinancialNumberField.php new file mode 100644 index 00000000..f517b16f --- /dev/null +++ b/src/Fields/Invoice/FinancialNumberField.php @@ -0,0 +1,32 @@ +financialNumber; + } + + /** + * @param null|int $financialNumber + * @return $this + */ + public function setFinancialNumber(?int $financialNumber): self + { + $this->financialNumber = $financialNumber; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/FooterTextField.php b/src/Fields/Invoice/FooterTextField.php new file mode 100644 index 00000000..1984a35d --- /dev/null +++ b/src/Fields/Invoice/FooterTextField.php @@ -0,0 +1,32 @@ +footerText; + } + + /** + * @param null|string $footerText + * @return $this + */ + public function setFooterText(?string $footerText): self + { + $this->footerText = $footerText; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/HeaderTextField.php b/src/Fields/Invoice/HeaderTextField.php new file mode 100644 index 00000000..a8e480d1 --- /dev/null +++ b/src/Fields/Invoice/HeaderTextField.php @@ -0,0 +1,32 @@ +headerText; + } + + /** + * @param null|string $headerText + * @return $this + */ + public function setHeaderText(?string $headerText): self + { + $this->headerText = $headerText; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/InvoiceAddressNumberField.php b/src/Fields/Invoice/InvoiceAddressNumberField.php new file mode 100644 index 00000000..66e58741 --- /dev/null +++ b/src/Fields/Invoice/InvoiceAddressNumberField.php @@ -0,0 +1,32 @@ +invoiceAddressNumber; + } + + /** + * @param null|int $invoiceAddressNumber + * @return $this + */ + public function setInvoiceAddressNumber(?int $invoiceAddressNumber): self + { + $this->invoiceAddressNumber = $invoiceAddressNumber; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/InvoiceAmountField.php b/src/Fields/Invoice/InvoiceAmountField.php new file mode 100644 index 00000000..41900a92 --- /dev/null +++ b/src/Fields/Invoice/InvoiceAmountField.php @@ -0,0 +1,62 @@ +invoiceAmount; + } + + /** + * @return float|null + */ + public function getInvoiceAmountToFloat(): ?float + { + if ($this->getInvoiceAmount() != null) { + return Util::formatMoney($this->getInvoiceAmount()); + } else { + return 0; + } + } + + /** + * @param Money|null $invoiceAmount + * @return $this + */ + public function setInvoiceAmount(?Money $invoiceAmount) + { + $this->invoiceAmount = $invoiceAmount; + + return $this; + } + + /** + * @param float|null $invoiceAmountFloat + * @return $this + * @throws Exception + */ + public function setInvoiceAmountFromFloat(?float $invoiceAmountFloat) + { + if ((float)$invoiceAmountFloat) { + return $this->setInvoiceAmount(Money::EUR(100 * $invoiceAmountFloat)); + } else { + return $this->setInvoiceAmount(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/InvoiceDateField.php b/src/Fields/Invoice/InvoiceDateField.php new file mode 100644 index 00000000..03a4b03f --- /dev/null +++ b/src/Fields/Invoice/InvoiceDateField.php @@ -0,0 +1,66 @@ +invoiceDate; + } + + /** + * @return string|null + */ + public function getInvoiceDateToString(): ?string + { + if ($this->getInvoiceDate() != null) { + return Util::formatDate($this->getInvoiceDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $invoiceDate + * @return $this + */ + public function setInvoiceDate(?\DateTimeInterface $invoiceDate) + { + $this->invoiceDate = $invoiceDate; + return $this; + } + + /** + * @param string|null $invoiceDateString + * @return $this + * @throws Exception + */ + public function setInvoiceDateFromString(?string $invoiceDateString) + { + if ((bool)strtotime($invoiceDateString)) { + return $this->setInvoiceDate(Util::parseDate($invoiceDateString)); + } else { + return $this->setInvoiceDate(null); + } + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/InvoiceDebitCreditField.php b/src/Fields/Invoice/InvoiceDebitCreditField.php new file mode 100644 index 00000000..68dd2c13 --- /dev/null +++ b/src/Fields/Invoice/InvoiceDebitCreditField.php @@ -0,0 +1,41 @@ +debitCredit; + } + + /** + * @param InvoiceDebitCredit|null $debitCredit + * @return $this + */ + public function setDebitCredit(?InvoiceDebitCredit $debitCredit): self + { + $this->debitCredit = $debitCredit; + return $this; + } + + /** + * @param string|null $debitCreditString + * @return $this + * @throws Exception + */ + public function setDebitCreditFromString(?string $debitCreditString) + { + return $this->setDebitCredit(new InvoiceDebitCredit((string)$debitCreditString)); + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/InvoiceNumberField.php b/src/Fields/Invoice/InvoiceNumberField.php new file mode 100644 index 00000000..36251c0c --- /dev/null +++ b/src/Fields/Invoice/InvoiceNumberField.php @@ -0,0 +1,32 @@ +invoiceNumber; + } + + /** + * @param null|int $invoiceNumber + * @return $this + */ + public function setInvoiceNumber(?int $invoiceNumber): self + { + $this->invoiceNumber = $invoiceNumber; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/InvoiceStatusField.php b/src/Fields/Invoice/InvoiceStatusField.php new file mode 100644 index 00000000..337de4ed --- /dev/null +++ b/src/Fields/Invoice/InvoiceStatusField.php @@ -0,0 +1,41 @@ +status; + } + + /** + * @param InvoiceStatus|null $status + * @return $this + */ + public function setStatus(?InvoiceStatus $status): self + { + $this->status = $status; + return $this; + } + + /** + * @param string|null $statusString + * @return $this + * @throws Exception + */ + public function setStatusFromString(?string $statusString) + { + return $this->setStatus(new InvoiceStatus((string)$statusString)); + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/InvoiceTypeField.php b/src/Fields/Invoice/InvoiceTypeField.php new file mode 100644 index 00000000..3b72eb4c --- /dev/null +++ b/src/Fields/Invoice/InvoiceTypeField.php @@ -0,0 +1,54 @@ +invoiceType; + } + + public function getInvoiceTypeToCode(): ?string + { + if ($this->getInvoiceType() != null) { + return $this->invoiceType->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setInvoiceType(?InvoiceType $invoiceType): self + { + $this->invoiceType = $invoiceType; + return $this; + } + + /** + * @param string|null $invoiceTypeCode + * @return $this + * @throws Exception + */ + public function setInvoiceTypeFromCode(?string $invoiceTypeCode) + { + $invoiceType = new InvoiceType(); + $invoiceType->setCode($invoiceTypeCode); + return $this->setInvoiceType($invoiceType); + } +} diff --git a/src/Fields/Invoice/PaymentMethodField.php b/src/Fields/Invoice/PaymentMethodField.php new file mode 100644 index 00000000..565924df --- /dev/null +++ b/src/Fields/Invoice/PaymentMethodField.php @@ -0,0 +1,41 @@ +paymentMethod; + } + + /** + * @param PaymentMethod|null $paymentMethod + * @return $this + */ + public function setPaymentMethod(?PaymentMethod $paymentMethod): self + { + $this->paymentMethod = $paymentMethod; + return $this; + } + + /** + * @param string|null $paymentMethodString + * @return $this + * @throws Exception + */ + public function setPaymentMethodFromString(?string $paymentMethodString) + { + return $this->setPaymentMethod(new PaymentMethod((string)$paymentMethodString)); + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/PerformanceDateField.php b/src/Fields/Invoice/PerformanceDateField.php new file mode 100644 index 00000000..b08efba4 --- /dev/null +++ b/src/Fields/Invoice/PerformanceDateField.php @@ -0,0 +1,66 @@ +performanceDate; + } + + /** + * @return string|null + */ + public function getPerformanceDateToString(): ?string + { + if ($this->getPerformanceDate() != null) { + return Util::formatDate($this->getPerformanceDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $performanceDate + * @return $this + */ + public function setPerformanceDate(?\DateTimeInterface $performanceDate) + { + $this->performanceDate = $performanceDate; + return $this; + } + + /** + * @param string|null $performanceDateString + * @return $this + * @throws Exception + */ + public function setPerformanceDateFromString(?string $performanceDateString) + { + if ((bool)strtotime($performanceDateString)) { + return $this->setPerformanceDate(Util::parseDate($performanceDateString)); + } else { + return $this->setPerformanceDate(null); + } + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/PerformanceTypeField.php b/src/Fields/Invoice/PerformanceTypeField.php new file mode 100644 index 00000000..1d33a61e --- /dev/null +++ b/src/Fields/Invoice/PerformanceTypeField.php @@ -0,0 +1,41 @@ +performanceType; + } + + /** + * @param PerformanceType|null $performanceType + * @return $this + */ + public function setPerformanceType(?PerformanceType $performanceType): self + { + $this->performanceType = $performanceType; + return $this; + } + + /** + * @param string|null $performanceTypeString + * @return $this + * @throws Exception + */ + public function setPerformanceTypeFromString(?string $performanceTypeString) + { + return $this->setPerformanceType(new PerformanceType((string)$performanceTypeString)); + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/QuantityField.php b/src/Fields/Invoice/QuantityField.php new file mode 100644 index 00000000..c601b209 --- /dev/null +++ b/src/Fields/Invoice/QuantityField.php @@ -0,0 +1,32 @@ +quantity; + } + + /** + * @param null|int $quantity + * @return $this + */ + public function setQuantity(?int $quantity): self + { + $this->quantity = $quantity; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/RaiseWarningField.php b/src/Fields/Invoice/RaiseWarningField.php new file mode 100644 index 00000000..993aef3c --- /dev/null +++ b/src/Fields/Invoice/RaiseWarningField.php @@ -0,0 +1,47 @@ +raiseWarning; + } + + public function getRaiseWarningToString(): ?string + { + return ($this->getRaiseWarning()) ? 'true' : 'false'; + } + + /** + * @param bool $raiseWarning + * @return $this + */ + public function setRaiseWarning(?bool $raiseWarning): self + { + $this->raiseWarning = $raiseWarning; + return $this; + } + + /** + * @param string|null $raiseWarningString + * @return $this + * @throws Exception + */ + public function setRaiseWarningFromString(?string $raiseWarningString) + { + return $this->setRaiseWarning(filter_var($raiseWarningString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/SubArticleField.php b/src/Fields/Invoice/SubArticleField.php new file mode 100644 index 00000000..fab4ff83 --- /dev/null +++ b/src/Fields/Invoice/SubArticleField.php @@ -0,0 +1,54 @@ +subArticle; + } + + public function getSubArticleToSubCode(): ?string + { + if ($this->getSubArticle() != null) { + return $this->subArticle->getSubCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setSubArticle(?ArticleLine $subArticle): self + { + $this->subArticle = $subArticle; + return $this; + } + + /** + * @param string|null $subArticleCode + * @return $this + * @throws Exception + */ + public function setSubArticleFromSubCode(?string $subArticleCode) + { + $subArticle = new ArticleLine(); + $subArticle->setSubCode($subArticleCode); + return $this->setSubArticle($subArticle); + } +} diff --git a/src/Fields/Invoice/UnitsField.php b/src/Fields/Invoice/UnitsField.php new file mode 100644 index 00000000..7aa0a54d --- /dev/null +++ b/src/Fields/Invoice/UnitsField.php @@ -0,0 +1,32 @@ +units; + } + + /** + * @param null|int $units + * @return $this + */ + public function setUnits(?int $units): self + { + $this->units = $units; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/UnitsPriceExclField.php b/src/Fields/Invoice/UnitsPriceExclField.php new file mode 100644 index 00000000..88859b69 --- /dev/null +++ b/src/Fields/Invoice/UnitsPriceExclField.php @@ -0,0 +1,62 @@ +unitsPriceExcl; + } + + /** + * @return float|null + */ + public function getUnitsPriceExclToFloat(): ?float + { + if ($this->getUnitsPriceExcl() != null) { + return Util::formatMoney($this->getUnitsPriceExcl()); + } else { + return 0; + } + } + + /** + * @param Money|null $unitsPriceExcl + * @return $this + */ + public function setUnitsPriceExcl(?Money $unitsPriceExcl) + { + $this->unitsPriceExcl = $unitsPriceExcl; + + return $this; + } + + /** + * @param float|null $unitsPriceExclFloat + * @return $this + * @throws Exception + */ + public function setUnitsPriceExclFromFloat(?float $unitsPriceExclFloat) + { + if ((float)$unitsPriceExclFloat) { + return $this->setUnitsPriceExcl(Money::EUR(100 * $unitsPriceExclFloat)); + } else { + return $this->setUnitsPriceExcl(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/UnitsPriceIncField.php b/src/Fields/Invoice/UnitsPriceIncField.php new file mode 100644 index 00000000..0e6268f3 --- /dev/null +++ b/src/Fields/Invoice/UnitsPriceIncField.php @@ -0,0 +1,62 @@ +unitsPriceInc; + } + + /** + * @return float|null + */ + public function getUnitsPriceIncToFloat(): ?float + { + if ($this->getUnitsPriceInc() != null) { + return Util::formatMoney($this->getUnitsPriceInc()); + } else { + return 0; + } + } + + /** + * @param Money|null $unitsPriceInc + * @return $this + */ + public function setUnitsPriceInc(?Money $unitsPriceInc) + { + $this->unitsPriceInc = $unitsPriceInc; + + return $this; + } + + /** + * @param float|null $unitsPriceIncFloat + * @return $this + * @throws Exception + */ + public function setUnitsPriceIncFromFloat(?float $unitsPriceIncFloat) + { + if ((float)$unitsPriceIncFloat) { + return $this->setUnitsPriceInc(Money::EUR(100 * $unitsPriceIncFloat)); + } else { + return $this->setUnitsPriceInc(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/ValueExclField.php b/src/Fields/Invoice/ValueExclField.php new file mode 100644 index 00000000..d4fb1fac --- /dev/null +++ b/src/Fields/Invoice/ValueExclField.php @@ -0,0 +1,62 @@ +valueExcl; + } + + /** + * @return float|null + */ + public function getValueExclToFloat(): ?float + { + if ($this->getValueExcl() != null) { + return Util::formatMoney($this->getValueExcl()); + } else { + return 0; + } + } + + /** + * @param Money|null $valueExcl + * @return $this + */ + public function setValueExcl(?Money $valueExcl) + { + $this->valueExcl = $valueExcl; + + return $this; + } + + /** + * @param float|null $valueExclFloat + * @return $this + * @throws Exception + */ + public function setValueExclFromFloat(?float $valueExclFloat) + { + if ((float)$valueExclFloat) { + return $this->setValueExcl(Money::EUR(100 * $valueExclFloat)); + } else { + return $this->setValueExcl(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/ValueIncField.php b/src/Fields/Invoice/ValueIncField.php new file mode 100644 index 00000000..80b2e210 --- /dev/null +++ b/src/Fields/Invoice/ValueIncField.php @@ -0,0 +1,62 @@ +valueInc; + } + + /** + * @return float|null + */ + public function getValueIncToFloat(): ?float + { + if ($this->getValueInc() != null) { + return Util::formatMoney($this->getValueInc()); + } else { + return 0; + } + } + + /** + * @param Money|null $valueInc + * @return $this + */ + public function setValueInc(?Money $valueInc) + { + $this->valueInc = $valueInc; + + return $this; + } + + /** + * @param float|null $valueIncFloat + * @return $this + * @throws Exception + */ + public function setValueIncFromFloat(?float $valueIncFloat) + { + if ((float)$valueIncFloat) { + return $this->setValueInc(Money::EUR(100 * $valueIncFloat)); + } else { + return $this->setValueInc(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Invoice/VatValueField.php b/src/Fields/Invoice/VatValueField.php new file mode 100644 index 00000000..c1cb1161 --- /dev/null +++ b/src/Fields/Invoice/VatValueField.php @@ -0,0 +1,62 @@ +vatValue; + } + + /** + * @return float|null + */ + public function getVatValueToFloat(): ?float + { + if ($this->getVatValue() != null) { + return Util::formatMoney($this->getVatValue()); + } else { + return 0; + } + } + + /** + * @param Money|null $vatValue + * @return $this + */ + public function setVatValue(?Money $vatValue) + { + $this->vatValue = $vatValue; + + return $this; + } + + /** + * @param float|null $vatValueFloat + * @return $this + * @throws Exception + */ + public function setVatValueFromFloat(?float $vatValueFloat) + { + if ((float)$vatValueFloat) { + return $this->setVatValue(Money::EUR(100 * $vatValueFloat)); + } else { + return $this->setVatValue(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Office/CountryCodeField.php b/src/Fields/Office/CountryCodeField.php new file mode 100644 index 00000000..e9b1d432 --- /dev/null +++ b/src/Fields/Office/CountryCodeField.php @@ -0,0 +1,32 @@ +countryCode; + } + + /** + * @param null|string $countryCode + * @return $this + */ + public function setCountryCode(?string $countryCode): self + { + $this->countryCode = $countryCode; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Office/VatFirstQuarterStartsInField.php b/src/Fields/Office/VatFirstQuarterStartsInField.php new file mode 100644 index 00000000..9121db8a --- /dev/null +++ b/src/Fields/Office/VatFirstQuarterStartsInField.php @@ -0,0 +1,32 @@ +vatFirstQuarterStartsIn; + } + + /** + * @param null|string $vatFirstQuarterStartsIn + * @return $this + */ + public function setVatFirstQuarterStartsIn(?string $vatFirstQuarterStartsIn): self + { + $this->vatFirstQuarterStartsIn = $vatFirstQuarterStartsIn; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Office/VatPeriodField.php b/src/Fields/Office/VatPeriodField.php new file mode 100644 index 00000000..91659020 --- /dev/null +++ b/src/Fields/Office/VatPeriodField.php @@ -0,0 +1,32 @@ +vatPeriod; + } + + /** + * @param null|string $vatPeriod + * @return $this + */ + public function setVatPeriod(?string $vatPeriod): self + { + $this->vatPeriod = $vatPeriod; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Rate/BeginDateField.php b/src/Fields/Rate/BeginDateField.php new file mode 100644 index 00000000..c285bf06 --- /dev/null +++ b/src/Fields/Rate/BeginDateField.php @@ -0,0 +1,66 @@ +beginDate; + } + + /** + * @return string|null + */ + public function getBeginDateToString(): ?string + { + if ($this->getBeginDate() != null) { + return Util::formatDate($this->getBeginDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $beginDate + * @return $this + */ + public function setBeginDate(?\DateTimeInterface $beginDate) + { + $this->beginDate = $beginDate; + return $this; + } + + /** + * @param string|null $beginDateString + * @return $this + * @throws Exception + */ + public function setBeginDateFromString(?string $beginDateString) + { + if ((bool)strtotime($beginDateString)) { + return $this->setBeginDate(Util::parseDate($beginDateString)); + } else { + return $this->setBeginDate(null); + } + } +} \ No newline at end of file diff --git a/src/Fields/Rate/EndDateField.php b/src/Fields/Rate/EndDateField.php new file mode 100644 index 00000000..0feee1f2 --- /dev/null +++ b/src/Fields/Rate/EndDateField.php @@ -0,0 +1,66 @@ +endDate; + } + + /** + * @return string|null + */ + public function getEndDateToString(): ?string + { + if ($this->getEndDate() != null) { + return Util::formatDate($this->getEndDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $endDate + * @return $this + */ + public function setEndDate(?\DateTimeInterface $endDate) + { + $this->endDate = $endDate; + return $this; + } + + /** + * @param string|null $endDateString + * @return $this + * @throws Exception + */ + public function setEndDateFromString(?string $endDateString) + { + if ((bool)strtotime($endDateString)) { + return $this->setEndDate(Util::parseDate($endDateString)); + } else { + return $this->setEndDate(null); + } + } +} \ No newline at end of file diff --git a/src/Fields/Rate/ExternalRateField.php b/src/Fields/Rate/ExternalRateField.php new file mode 100644 index 00000000..bbb6fb55 --- /dev/null +++ b/src/Fields/Rate/ExternalRateField.php @@ -0,0 +1,32 @@ +externalRate; + } + + /** + * @param null|float $externalRate + * @return $this + */ + public function setExternalRate(?float $externalRate): self + { + $this->externalRate = $externalRate; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Rate/InternalRateField.php b/src/Fields/Rate/InternalRateField.php new file mode 100644 index 00000000..821688b2 --- /dev/null +++ b/src/Fields/Rate/InternalRateField.php @@ -0,0 +1,32 @@ +internalRate; + } + + /** + * @param null|float $internalRate + * @return $this + */ + public function setInternalRate(?float $internalRate): self + { + $this->internalRate = $internalRate; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Rate/RateTypeField.php b/src/Fields/Rate/RateTypeField.php new file mode 100644 index 00000000..6a05f17d --- /dev/null +++ b/src/Fields/Rate/RateTypeField.php @@ -0,0 +1,41 @@ +type; + } + + /** + * @param RateType|null $type + * @return $this + */ + public function setType(?RateType $type): self + { + $this->type = $type; + return $this; + } + + /** + * @param string|null $typeString + * @return $this + * @throws Exception + */ + public function setTypeFromString(?string $typeString) + { + return $this->setType(new RateType((string)$typeString)); + } +} \ No newline at end of file diff --git a/src/Fields/Rate/UnitField.php b/src/Fields/Rate/UnitField.php new file mode 100644 index 00000000..6bd5e173 --- /dev/null +++ b/src/Fields/Rate/UnitField.php @@ -0,0 +1,32 @@ +unit; + } + + /** + * @param null|int $unit + * @return $this + */ + public function setUnit(?int $unit): self + { + $this->unit = $unit; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/User/IsCurrentUserField.php b/src/Fields/User/IsCurrentUserField.php new file mode 100644 index 00000000..cc7149dc --- /dev/null +++ b/src/Fields/User/IsCurrentUserField.php @@ -0,0 +1,47 @@ +isCurrentUser; + } + + public function getIsCurrentUserToString(): ?string + { + return ($this->getIsCurrentUser()) ? 'true' : 'false'; + } + + /** + * @param bool $isCurrentUser + * @return $this + */ + public function setIsCurrentUser(?bool $isCurrentUser): self + { + $this->isCurrentUser = $isCurrentUser; + return $this; + } + + /** + * @param string|null $isCurrentUserString + * @return $this + * @throws Exception + */ + public function setIsCurrentUserFromString(?string $isCurrentUserString) + { + return $this->setIsCurrentUser(filter_var($isCurrentUserString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/User/UserLevelField.php b/src/Fields/User/UserLevelField.php new file mode 100644 index 00000000..7157b36e --- /dev/null +++ b/src/Fields/User/UserLevelField.php @@ -0,0 +1,32 @@ +level; + } + + /** + * @param null|string $level + * @return $this + */ + public function setLevel(?string $level): self + { + $this->level = $level; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/VatCode/DateField.php b/src/Fields/VatCode/DateField.php new file mode 100644 index 00000000..1c2bdc65 --- /dev/null +++ b/src/Fields/VatCode/DateField.php @@ -0,0 +1,66 @@ +date; + } + + /** + * @return string|null + */ + public function getDateToString(): ?string + { + if ($this->getDate() != null) { + return Util::formatDate($this->getDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $date + * @return $this + */ + public function setDate(?\DateTimeInterface $date) + { + $this->date = $date; + return $this; + } + + /** + * @param string|null $dateString + * @return $this + * @throws Exception + */ + public function setDateFromString(?string $dateString) + { + if ((bool)strtotime($dateString)) { + return $this->setDate(Util::parseDate($dateString)); + } else { + return $this->setDate(null); + } + } +} \ No newline at end of file diff --git a/src/Fields/VatCode/LineTypeField.php b/src/Fields/VatCode/LineTypeField.php new file mode 100644 index 00000000..2cc5c26c --- /dev/null +++ b/src/Fields/VatCode/LineTypeField.php @@ -0,0 +1,41 @@ +linetype; + } + + /** + * @param LineType|null $linetype + * @return $this + */ + public function setLineType(?LineType $linetype): self + { + $this->linetype = $linetype; + return $this; + } + + /** + * @param string|null $lineTypeString + * @return $this + * @throws Exception + */ + public function setLineTypeFromString(?string $lineTypeString) + { + return $this->setLineType(new LineType((string)$lineTypeString)); + } +} \ No newline at end of file diff --git a/src/Fields/VatCode/VatCodeTypeField.php b/src/Fields/VatCode/VatCodeTypeField.php new file mode 100644 index 00000000..c6e6ac51 --- /dev/null +++ b/src/Fields/VatCode/VatCodeTypeField.php @@ -0,0 +1,41 @@ +type; + } + + /** + * @param VatType|null $type + * @return $this + */ + public function setType(?VatType $type): self + { + $this->type = $type; + return $this; + } + + /** + * @param string|null $typeString + * @return $this + * @throws Exception + */ + public function setTypeFromString(?string $typeString) + { + return $this->setType(new VatType((string)$typeString)); + } +} \ No newline at end of file diff --git a/src/Fields/VatCode/VatGroupCountryField.php b/src/Fields/VatCode/VatGroupCountryField.php new file mode 100644 index 00000000..e1d5cc65 --- /dev/null +++ b/src/Fields/VatCode/VatGroupCountryField.php @@ -0,0 +1,54 @@ +groupCountry; + } + + public function getGroupCountryToCode(): ?string + { + if ($this->getGroupCountry() != null) { + return $this->groupCountry->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setGroupCountry(?Country $groupCountry): self + { + $this->groupCountry = $groupCountry; + return $this; + } + + /** + * @param string|null $groupCountryCode + * @return $this + * @throws Exception + */ + public function setGroupCountryFromCode(?string $groupCountryCode) + { + $groupCountry = new Country(); + $groupCountry->setCode($groupCountryCode); + return $this->setGroupCountry($groupCountry); + } +} \ No newline at end of file diff --git a/src/Fields/VatCode/VatGroupField.php b/src/Fields/VatCode/VatGroupField.php new file mode 100644 index 00000000..a8f15ce2 --- /dev/null +++ b/src/Fields/VatCode/VatGroupField.php @@ -0,0 +1,54 @@ +group; + } + + public function getGroupToCode(): ?string + { + if ($this->getGroup() != null) { + return $this->group->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setGroup(?VatGroup $group): self + { + $this->group = $group; + return $this; + } + + /** + * @param string|null $groupCode + * @return $this + * @throws Exception + */ + public function setGroupFromCode(?string $groupCode) + { + $group = new VatGroup(); + $group->setCode($groupCode); + return $this->setGroup($group); + } +} \ No newline at end of file From 277b0aa43cf591c5e7e18fb6e423402826e6ed74 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:30:53 +0200 Subject: [PATCH 055/388] Add files via upload --- src/Fields/Level1234/AccountTypeField.php | 41 ++++++++++++ src/Fields/Level1234/AmountField.php | 62 +++++++++++++++++ src/Fields/Level1234/BeginYearField.php | 32 +++++++++ src/Fields/Level1234/DimensionGroupField.php | 54 +++++++++++++++ src/Fields/Level1234/DimensionTypeField.php | 54 +++++++++++++++ src/Fields/Level1234/EndYearField.php | 32 +++++++++ .../GeneralLedgerBeginPeriodField.php | 32 +++++++++ .../Level1234/GeneralLedgerEndPeriodField.php | 32 +++++++++ .../Level1234/GeneralLedgerTypeField.php | 41 ++++++++++++ .../Level1234/Level34/AuthoriserField.php | 54 +++++++++++++++ .../Level34/AuthoriserInheritField.php | 47 +++++++++++++ .../Level34/AuthoriserLockedField.php | 47 +++++++++++++ .../Level1234/Level34/BillableField.php | 47 +++++++++++++ .../Level34/BillableForRatioField.php | 47 +++++++++++++ .../Level34/BillableInheritField.php | 47 +++++++++++++ .../Level1234/Level34/BillableLockedField.php | 47 +++++++++++++ .../Level34/CustomerInheritField.php | 47 +++++++++++++ .../Level1234/Level34/CustomerLockedField.php | 47 +++++++++++++ .../Level34/FixedAsset/AmountLockedField.php | 47 +++++++++++++ .../Level34/FixedAsset/BeginPeriodField.php | 38 +++++++++++ .../FixedAsset/BeginPeriodLockedField.php | 47 +++++++++++++ .../Level34/FixedAsset/Dim1LockedField.php | 47 +++++++++++++ .../Level34/FixedAsset/Dim2Field.php | 54 +++++++++++++++ .../Level34/FixedAsset/Dim2LockedField.php | 47 +++++++++++++ .../Level34/FixedAsset/Dim3Field.php | 54 +++++++++++++++ .../Level34/FixedAsset/Dim3LockedField.php | 47 +++++++++++++ .../Level34/FixedAsset/Dim4Field.php | 54 +++++++++++++++ .../Level34/FixedAsset/Dim4LockedField.php | 47 +++++++++++++ .../Level34/FixedAsset/Dim5Field.php | 54 +++++++++++++++ .../Level34/FixedAsset/Dim5LockedField.php | 47 +++++++++++++ .../Level34/FixedAsset/Dim6Field.php | 54 +++++++++++++++ .../Level34/FixedAsset/Dim6LockedField.php | 47 +++++++++++++ .../FixedAsset/FixedAssetCodeField.php | 40 +++++++++++ .../FixedAsset/FixedAssetCodeLockedField.php | 47 +++++++++++++ .../FixedAsset/FixedAssetsMethodField.php | 54 +++++++++++++++ .../FixedAssetsMethodLockedField.php | 47 +++++++++++++ .../FixedAsset/FixedAssetsStatusField.php | 41 ++++++++++++ .../FixedAssetsStatusLockedField.php | 47 +++++++++++++ .../FixedAsset/FreeText1LockedField.php | 47 +++++++++++++ .../FixedAsset/FreeText2LockedField.php | 47 +++++++++++++ .../FixedAsset/FreeText3LockedField.php | 47 +++++++++++++ .../Level34/FixedAsset/FreeText4Field.php | 32 +++++++++ .../FixedAsset/FreeText4LockedField.php | 47 +++++++++++++ .../Level34/FixedAsset/FreeText5Field.php | 32 +++++++++ .../FixedAsset/FreeText5LockedField.php | 47 +++++++++++++ .../FixedAsset/LastDepreciationField.php | 38 +++++++++++ .../LastDepreciationLockedField.php | 47 +++++++++++++ .../Level34/FixedAsset/LineField.php | 32 +++++++++ .../Level34/FixedAsset/LineLockedField.php | 47 +++++++++++++ .../FixedAsset/NrOfPeriodsInheritedField.php | 47 +++++++++++++ .../FixedAsset/NrOfPeriodsLockedField.php | 47 +++++++++++++ .../Level34/FixedAsset/NumberField.php | 32 +++++++++ .../Level34/FixedAsset/NumberLockedField.php | 47 +++++++++++++ .../FixedAsset/PercentageLockedField.php | 47 +++++++++++++ .../Level34/FixedAsset/PeriodLockedField.php | 47 +++++++++++++ .../Level34/FixedAsset/PurchaseDateField.php | 66 +++++++++++++++++++ .../FixedAsset/PurchaseDateLockedField.php | 47 +++++++++++++ .../Level34/FixedAsset/ResidualValueField.php | 62 +++++++++++++++++ .../FixedAsset/ResidualValueLockedField.php | 47 +++++++++++++ .../Level34/FixedAsset/SellDateField.php | 66 +++++++++++++++++++ .../FixedAsset/SellDateLockedField.php | 47 +++++++++++++ .../Level34/FixedAsset/StopValueField.php | 62 +++++++++++++++++ .../FixedAsset/StopValueLockedField.php | 47 +++++++++++++ .../TransactionLinesLockedField.php | 47 +++++++++++++ .../Level34/InvoiceDescriptionField.php | 32 +++++++++ src/Fields/Level1234/Level34/LabelField.php | 32 +++++++++ .../Level1234/Level34/MandatoryField.php | 47 +++++++++++++ .../Level1234/Level34/RateInheritField.php | 47 +++++++++++++ .../Level1234/Level34/RateLockedField.php | 47 +++++++++++++ .../Level1234/Level34/ValidFromField.php | 66 +++++++++++++++++++ .../Level1234/Level34/ValidTillField.php | 66 +++++++++++++++++++ src/Fields/Level1234/LevelField.php | 32 +++++++++ src/Fields/Level1234/MatchTypeField.php | 41 ++++++++++++ src/Fields/Level1234/SubAnalyseField.php | 41 ++++++++++++ src/Fields/Level1234/SubstituteWithField.php | 54 +++++++++++++++ .../Level1234/SubstituteWithIDField.php | 32 +++++++++ .../Level1234/SubstitutionLevelField.php | 32 +++++++++ src/Fields/Level1234/VatCodeFixedField.php | 47 +++++++++++++ 78 files changed, 3607 insertions(+) create mode 100644 src/Fields/Level1234/AccountTypeField.php create mode 100644 src/Fields/Level1234/AmountField.php create mode 100644 src/Fields/Level1234/BeginYearField.php create mode 100644 src/Fields/Level1234/DimensionGroupField.php create mode 100644 src/Fields/Level1234/DimensionTypeField.php create mode 100644 src/Fields/Level1234/EndYearField.php create mode 100644 src/Fields/Level1234/GeneralLedgerBeginPeriodField.php create mode 100644 src/Fields/Level1234/GeneralLedgerEndPeriodField.php create mode 100644 src/Fields/Level1234/GeneralLedgerTypeField.php create mode 100644 src/Fields/Level1234/Level34/AuthoriserField.php create mode 100644 src/Fields/Level1234/Level34/AuthoriserInheritField.php create mode 100644 src/Fields/Level1234/Level34/AuthoriserLockedField.php create mode 100644 src/Fields/Level1234/Level34/BillableField.php create mode 100644 src/Fields/Level1234/Level34/BillableForRatioField.php create mode 100644 src/Fields/Level1234/Level34/BillableInheritField.php create mode 100644 src/Fields/Level1234/Level34/BillableLockedField.php create mode 100644 src/Fields/Level1234/Level34/CustomerInheritField.php create mode 100644 src/Fields/Level1234/Level34/CustomerLockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/AmountLockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/BeginPeriodField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/BeginPeriodLockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/Dim1LockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/Dim2LockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/Dim3Field.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/Dim3LockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/Dim4LockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/Dim5Field.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/Dim5LockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/Dim6Field.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/Dim6LockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/FixedAssetCodeField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/FixedAssetCodeLockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/FixedAssetsMethodField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/FixedAssetsMethodLockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusLockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/FreeText1LockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/FreeText2LockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/FreeText3LockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/FreeText4Field.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/FreeText4LockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/FreeText5Field.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/FreeText5LockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/LastDepreciationField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/LastDepreciationLockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/LineField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/LineLockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/NrOfPeriodsInheritedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/NrOfPeriodsLockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/NumberField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/NumberLockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/PercentageLockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/PeriodLockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/PurchaseDateField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/PurchaseDateLockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/ResidualValueField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/ResidualValueLockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/SellDateField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/SellDateLockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/StopValueField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/StopValueLockedField.php create mode 100644 src/Fields/Level1234/Level34/FixedAsset/TransactionLinesLockedField.php create mode 100644 src/Fields/Level1234/Level34/InvoiceDescriptionField.php create mode 100644 src/Fields/Level1234/Level34/LabelField.php create mode 100644 src/Fields/Level1234/Level34/MandatoryField.php create mode 100644 src/Fields/Level1234/Level34/RateInheritField.php create mode 100644 src/Fields/Level1234/Level34/RateLockedField.php create mode 100644 src/Fields/Level1234/Level34/ValidFromField.php create mode 100644 src/Fields/Level1234/Level34/ValidTillField.php create mode 100644 src/Fields/Level1234/LevelField.php create mode 100644 src/Fields/Level1234/MatchTypeField.php create mode 100644 src/Fields/Level1234/SubAnalyseField.php create mode 100644 src/Fields/Level1234/SubstituteWithField.php create mode 100644 src/Fields/Level1234/SubstituteWithIDField.php create mode 100644 src/Fields/Level1234/SubstitutionLevelField.php create mode 100644 src/Fields/Level1234/VatCodeFixedField.php diff --git a/src/Fields/Level1234/AccountTypeField.php b/src/Fields/Level1234/AccountTypeField.php new file mode 100644 index 00000000..1a47a5f9 --- /dev/null +++ b/src/Fields/Level1234/AccountTypeField.php @@ -0,0 +1,41 @@ +accountType; + } + + /** + * @param AccountType|null $accountType + * @return $this + */ + public function setAccountType(?AccountType $accountType): self + { + $this->accountType = $accountType; + return $this; + } + + /** + * @param string|null $accountTypeString + * @return $this + * @throws Exception + */ + public function setAccountTypeFromString(?string $accountTypeString) + { + return $this->setAccountType(new AccountType((string)$accountTypeString)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/AmountField.php b/src/Fields/Level1234/AmountField.php new file mode 100644 index 00000000..55066e71 --- /dev/null +++ b/src/Fields/Level1234/AmountField.php @@ -0,0 +1,62 @@ +amount; + } + + /** + * @return float|null + */ + public function getAmountToFloat(): ?float + { + if ($this->getAmount() != null) { + return Util::formatMoney($this->getAmount()); + } else { + return 0; + } + } + + /** + * @param Money|null $amount + * @return $this + */ + public function setAmount(?Money $amount) + { + $this->amount = $amount; + + return $this; + } + + /** + * @param float|null $amountFloat + * @return $this + * @throws Exception + */ + public function setAmountFromFloat(?float $amountFloat) + { + if ((float)$amountFloat) { + return $this->setAmount(Money::EUR(100 * $amountFloat)); + } else { + return $this->setAmount(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/BeginYearField.php b/src/Fields/Level1234/BeginYearField.php new file mode 100644 index 00000000..5c9870f9 --- /dev/null +++ b/src/Fields/Level1234/BeginYearField.php @@ -0,0 +1,32 @@ +beginYear; + } + + /** + * @param null|int $beginYear + * @return $this + */ + public function setBeginYear(?int $beginYear): self + { + $this->beginYear = $beginYear; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/DimensionGroupField.php b/src/Fields/Level1234/DimensionGroupField.php new file mode 100644 index 00000000..9876915a --- /dev/null +++ b/src/Fields/Level1234/DimensionGroupField.php @@ -0,0 +1,54 @@ +group; + } + + public function getGroupToCode(): ?string + { + if ($this->getGroup() != null) { + return $this->group->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setGroup(?DimensionGroup $group): self + { + $this->group = $group; + return $this; + } + + /** + * @param string|null $groupCode + * @return $this + * @throws Exception + */ + public function setGroupFromCode(?string $groupCode) + { + $group = new DimensionGroup(); + $group->setCode($groupCode); + return $this->setGroup($group); + } +} diff --git a/src/Fields/Level1234/DimensionTypeField.php b/src/Fields/Level1234/DimensionTypeField.php new file mode 100644 index 00000000..bf08779a --- /dev/null +++ b/src/Fields/Level1234/DimensionTypeField.php @@ -0,0 +1,54 @@ +type; + } + + public function getTypeToCode(): ?string + { + if ($this->getType() != null) { + return $this->type->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setType(?DimensionType $type): self + { + $this->type = $type; + return $this; + } + + /** + * @param string|null $typeCode + * @return $this + * @throws Exception + */ + public function setTypeFromCode(?string $typeCode) + { + $type = new DimensionType(); + $type->setCode($typeCode); + return $this->setType($type); + } +} diff --git a/src/Fields/Level1234/EndYearField.php b/src/Fields/Level1234/EndYearField.php new file mode 100644 index 00000000..6db01e3c --- /dev/null +++ b/src/Fields/Level1234/EndYearField.php @@ -0,0 +1,32 @@ +endYear; + } + + /** + * @param null|int $endYear + * @return $this + */ + public function setEndYear(?int $endYear): self + { + $this->endYear = $endYear; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/GeneralLedgerBeginPeriodField.php b/src/Fields/Level1234/GeneralLedgerBeginPeriodField.php new file mode 100644 index 00000000..2ab7379c --- /dev/null +++ b/src/Fields/Level1234/GeneralLedgerBeginPeriodField.php @@ -0,0 +1,32 @@ +beginPeriod; + } + + /** + * @param null|int $beginPeriod + * @return $this + */ + public function setBeginPeriod(?int $beginPeriod): self + { + $this->beginPeriod = $beginPeriod; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/GeneralLedgerEndPeriodField.php b/src/Fields/Level1234/GeneralLedgerEndPeriodField.php new file mode 100644 index 00000000..8dd91d39 --- /dev/null +++ b/src/Fields/Level1234/GeneralLedgerEndPeriodField.php @@ -0,0 +1,32 @@ +endPeriod; + } + + /** + * @param null|int $endPeriod + * @return $this + */ + public function setEndPeriod(?int $endPeriod): self + { + $this->endPeriod = $endPeriod; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/GeneralLedgerTypeField.php b/src/Fields/Level1234/GeneralLedgerTypeField.php new file mode 100644 index 00000000..60d80a82 --- /dev/null +++ b/src/Fields/Level1234/GeneralLedgerTypeField.php @@ -0,0 +1,41 @@ +type; + } + + /** + * @param GeneralLedgerType|null $type + * @return $this + */ + public function setType(?GeneralLedgerType $type): self + { + $this->type = $type; + return $this; + } + + /** + * @param string|null $typeString + * @return $this + * @throws Exception + */ + public function setTypeFromString(?string $typeString) + { + return $this->setType(new GeneralLedgerType((string)$typeString)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/AuthoriserField.php b/src/Fields/Level1234/Level34/AuthoriserField.php new file mode 100644 index 00000000..c2720aa5 --- /dev/null +++ b/src/Fields/Level1234/Level34/AuthoriserField.php @@ -0,0 +1,54 @@ +authoriser; + } + + public function getAuthoriserToCode(): ?string + { + if ($this->getAuthoriser() != null) { + return $this->authoriser->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setAuthoriser(?User $authoriser): self + { + $this->authoriser = $authoriser; + return $this; + } + + /** + * @param string|null $authoriserCode + * @return $this + * @throws Exception + */ + public function setAuthoriserFromCode(?string $authoriserCode) + { + $authoriser = new User(); + $authoriser->setCode($authoriserCode); + return $this->setAuthoriser($authoriser); + } +} diff --git a/src/Fields/Level1234/Level34/AuthoriserInheritField.php b/src/Fields/Level1234/Level34/AuthoriserInheritField.php new file mode 100644 index 00000000..2bcd3efe --- /dev/null +++ b/src/Fields/Level1234/Level34/AuthoriserInheritField.php @@ -0,0 +1,47 @@ +authoriserInherit; + } + + public function getAuthoriserInheritToString(): ?string + { + return ($this->getAuthoriserInherit()) ? 'true' : 'false'; + } + + /** + * @param bool $authoriserInherit + * @return $this + */ + public function setAuthoriserInherit(?bool $authoriserInherit): self + { + $this->authoriserInherit = $authoriserInherit; + return $this; + } + + /** + * @param string|null $authoriserInheritString + * @return $this + * @throws Exception + */ + public function setAuthoriserInheritFromString(?string $authoriserInheritString) + { + return $this->setAuthoriserInherit(filter_var($authoriserInheritString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/AuthoriserLockedField.php b/src/Fields/Level1234/Level34/AuthoriserLockedField.php new file mode 100644 index 00000000..200c5535 --- /dev/null +++ b/src/Fields/Level1234/Level34/AuthoriserLockedField.php @@ -0,0 +1,47 @@ +authoriserLocked; + } + + public function getAuthoriserLockedToString(): ?string + { + return ($this->getAuthoriserLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $authoriserLocked + * @return $this + */ + public function setAuthoriserLocked(?bool $authoriserLocked): self + { + $this->authoriserLocked = $authoriserLocked; + return $this; + } + + /** + * @param string|null $authoriserLockedString + * @return $this + * @throws Exception + */ + public function setAuthoriserLockedFromString(?string $authoriserLockedString) + { + return $this->setAuthoriserLocked(filter_var($authoriserLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/BillableField.php b/src/Fields/Level1234/Level34/BillableField.php new file mode 100644 index 00000000..f5baf53f --- /dev/null +++ b/src/Fields/Level1234/Level34/BillableField.php @@ -0,0 +1,47 @@ +billable; + } + + public function getBillableToString(): ?string + { + return ($this->getBillable()) ? 'true' : 'false'; + } + + /** + * @param bool $billable + * @return $this + */ + public function setBillable(?bool $billable): self + { + $this->billable = $billable; + return $this; + } + + /** + * @param string|null $billableString + * @return $this + * @throws Exception + */ + public function setBillableFromString(?string $billableString) + { + return $this->setBillable(filter_var($billableString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/BillableForRatioField.php b/src/Fields/Level1234/Level34/BillableForRatioField.php new file mode 100644 index 00000000..c7c7675f --- /dev/null +++ b/src/Fields/Level1234/Level34/BillableForRatioField.php @@ -0,0 +1,47 @@ +billableForRatio; + } + + public function getBillableForRatioToString(): ?string + { + return ($this->getBillableForRatio()) ? 'true' : 'false'; + } + + /** + * @param bool $billableForRatio + * @return $this + */ + public function setBillableForRatio(?bool $billableForRatio): self + { + $this->billableForRatio = $billableForRatio; + return $this; + } + + /** + * @param string|null $billableForRatioString + * @return $this + * @throws Exception + */ + public function setBillableForRatioFromString(?string $billableForRatioString) + { + return $this->setBillableForRatio(filter_var($billableForRatioString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/BillableInheritField.php b/src/Fields/Level1234/Level34/BillableInheritField.php new file mode 100644 index 00000000..01b2fcca --- /dev/null +++ b/src/Fields/Level1234/Level34/BillableInheritField.php @@ -0,0 +1,47 @@ +billableInherit; + } + + public function getBillableInheritToString(): ?string + { + return ($this->getBillableInherit()) ? 'true' : 'false'; + } + + /** + * @param bool $billableInherit + * @return $this + */ + public function setBillableInherit(?bool $billableInherit): self + { + $this->billableInherit = $billableInherit; + return $this; + } + + /** + * @param string|null $billableInheritString + * @return $this + * @throws Exception + */ + public function setBillableInheritFromString(?string $billableInheritString) + { + return $this->setBillableInherit(filter_var($billableInheritString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/BillableLockedField.php b/src/Fields/Level1234/Level34/BillableLockedField.php new file mode 100644 index 00000000..80214279 --- /dev/null +++ b/src/Fields/Level1234/Level34/BillableLockedField.php @@ -0,0 +1,47 @@ +billableLocked; + } + + public function getBillableLockedToString(): ?string + { + return ($this->getBillableLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $billableLocked + * @return $this + */ + public function setBillableLocked(?bool $billableLocked): self + { + $this->billableLocked = $billableLocked; + return $this; + } + + /** + * @param string|null $billableLockedString + * @return $this + * @throws Exception + */ + public function setBillableLockedFromString(?string $billableLockedString) + { + return $this->setBillableLocked(filter_var($billableLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/CustomerInheritField.php b/src/Fields/Level1234/Level34/CustomerInheritField.php new file mode 100644 index 00000000..9689efbe --- /dev/null +++ b/src/Fields/Level1234/Level34/CustomerInheritField.php @@ -0,0 +1,47 @@ +customerInherit; + } + + public function getCustomerInheritToString(): ?string + { + return ($this->getCustomerInherit()) ? 'true' : 'false'; + } + + /** + * @param bool $customerInherit + * @return $this + */ + public function setCustomerInherit(?bool $customerInherit): self + { + $this->customerInherit = $customerInherit; + return $this; + } + + /** + * @param string|null $customerInheritString + * @return $this + * @throws Exception + */ + public function setCustomerInheritFromString(?string $customerInheritString) + { + return $this->setCustomerInherit(filter_var($customerInheritString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/CustomerLockedField.php b/src/Fields/Level1234/Level34/CustomerLockedField.php new file mode 100644 index 00000000..7bd75018 --- /dev/null +++ b/src/Fields/Level1234/Level34/CustomerLockedField.php @@ -0,0 +1,47 @@ +customerLocked; + } + + public function getCustomerLockedToString(): ?string + { + return ($this->getCustomerLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $customerLocked + * @return $this + */ + public function setCustomerLocked(?bool $customerLocked): self + { + $this->customerLocked = $customerLocked; + return $this; + } + + /** + * @param string|null $customerLockedString + * @return $this + * @throws Exception + */ + public function setCustomerLockedFromString(?string $customerLockedString) + { + return $this->setCustomerLocked(filter_var($customerLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/AmountLockedField.php b/src/Fields/Level1234/Level34/FixedAsset/AmountLockedField.php new file mode 100644 index 00000000..a5b56b51 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/AmountLockedField.php @@ -0,0 +1,47 @@ +amountLocked; + } + + public function getAmountLockedToString(): ?string + { + return ($this->getAmountLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $amountLocked + * @return $this + */ + public function setAmountLocked(?bool $amountLocked): self + { + $this->amountLocked = $amountLocked; + return $this; + } + + /** + * @param string|null $amountLockedString + * @return $this + * @throws Exception + */ + public function setAmountLockedFromString(?string $amountLockedString) + { + return $this->setAmountLocked(filter_var($amountLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/BeginPeriodField.php b/src/Fields/Level1234/Level34/FixedAsset/BeginPeriodField.php new file mode 100644 index 00000000..051a75ee --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/BeginPeriodField.php @@ -0,0 +1,38 @@ +beginPeriod; + } + + /** + * @param string|null $beginPeriod + * @return $this + */ + public function setBeginPeriod(?string $beginPeriod): self + { + if (!preg_match("!\\d{4}/\\d{1,2}!", $beginPeriod)) { + $beginPeriod = ''; + } + + $this->beginPeriod = $beginPeriod; + + return $this; + } +} diff --git a/src/Fields/Level1234/Level34/FixedAsset/BeginPeriodLockedField.php b/src/Fields/Level1234/Level34/FixedAsset/BeginPeriodLockedField.php new file mode 100644 index 00000000..8fe2e0c0 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/BeginPeriodLockedField.php @@ -0,0 +1,47 @@ +beginPeriodLocked; + } + + public function getBeginPeriodLockedToString(): ?string + { + return ($this->getBeginPeriodLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $beginPeriodLocked + * @return $this + */ + public function setBeginPeriodLocked(?bool $beginPeriodLocked): self + { + $this->beginPeriodLocked = $beginPeriodLocked; + return $this; + } + + /** + * @param string|null $beginPeriodLockedString + * @return $this + * @throws Exception + */ + public function setBeginPeriodLockedFromString(?string $beginPeriodLockedString) + { + return $this->setBeginPeriodLocked(filter_var($beginPeriodLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim1LockedField.php b/src/Fields/Level1234/Level34/FixedAsset/Dim1LockedField.php new file mode 100644 index 00000000..eb0de991 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/Dim1LockedField.php @@ -0,0 +1,47 @@ +dim1Locked; + } + + public function getDim1LockedToString(): ?string + { + return ($this->getDim1Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $dim1Locked + * @return $this + */ + public function setDim1Locked(?bool $dim1Locked): self + { + $this->dim1Locked = $dim1Locked; + return $this; + } + + /** + * @param string|null $dim1LockedString + * @return $this + * @throws Exception + */ + public function setDim1LockedFromString(?string $dim1LockedString) + { + return $this->setDim1Locked(filter_var($dim1LockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php b/src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php new file mode 100644 index 00000000..11e8696b --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php @@ -0,0 +1,54 @@ +dim2; + } + + public function getDim2ToCode(): ?string + { + if ($this->getDim2() != null) { + return $this->dim2->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDim2($dim2): self + { + $this->dim2 = $dim2; + return $this; + } + + /** + * @param string|null $dim2Code + * @return $this + * @throws Exception + */ + public function setDim2FromCode(?string $dim2Code) + { + $dim2 = new Dummy(); + $dim2->setCode($dim2Code); + return $this->setDim2($dim2); + } +} diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim2LockedField.php b/src/Fields/Level1234/Level34/FixedAsset/Dim2LockedField.php new file mode 100644 index 00000000..ba1a8e90 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/Dim2LockedField.php @@ -0,0 +1,47 @@ +dim2Locked; + } + + public function getDim2LockedToString(): ?string + { + return ($this->getDim2Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $dim2Locked + * @return $this + */ + public function setDim2Locked(?bool $dim2Locked): self + { + $this->dim2Locked = $dim2Locked; + return $this; + } + + /** + * @param string|null $dim2LockedString + * @return $this + * @throws Exception + */ + public function setDim2LockedFromString(?string $dim2LockedString) + { + return $this->setDim2Locked(filter_var($dim2LockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim3Field.php b/src/Fields/Level1234/Level34/FixedAsset/Dim3Field.php new file mode 100644 index 00000000..c1540d66 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/Dim3Field.php @@ -0,0 +1,54 @@ +dim3; + } + + public function getDim3ToCode(): ?string + { + if ($this->getDim3() != null) { + return $this->dim3->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDim3($dim3): self + { + $this->dim3 = $dim3; + return $this; + } + + /** + * @param string|null $dim3Code + * @return $this + * @throws Exception + */ + public function setDim3FromCode(?string $dim3Code) + { + $dim3 = new Dummy(); + $dim3->setCode($dim3Code); + return $this->setDim3($dim3); + } +} diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim3LockedField.php b/src/Fields/Level1234/Level34/FixedAsset/Dim3LockedField.php new file mode 100644 index 00000000..f8492a58 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/Dim3LockedField.php @@ -0,0 +1,47 @@ +dim3Locked; + } + + public function getDim3LockedToString(): ?string + { + return ($this->getDim3Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $dim3Locked + * @return $this + */ + public function setDim3Locked(?bool $dim3Locked): self + { + $this->dim3Locked = $dim3Locked; + return $this; + } + + /** + * @param string|null $dim3LockedString + * @return $this + * @throws Exception + */ + public function setDim3LockedFromString(?string $dim3LockedString) + { + return $this->setDim3Locked(filter_var($dim3LockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php b/src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php new file mode 100644 index 00000000..4d9d19fb --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php @@ -0,0 +1,54 @@ +dim4; + } + + public function getDim4ToCode(): ?string + { + if ($this->getDim4() != null) { + return $this->dim4->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDim4($dim4): self + { + $this->dim4 = $dim4; + return $this; + } + + /** + * @param string|null $dim4Code + * @return $this + * @throws Exception + */ + public function setDim4FromCode(?string $dim4Code) + { + $dim4 = new Dummy(); + $dim4->setCode($dim4Code); + return $this->setDim4($dim4); + } +} diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim4LockedField.php b/src/Fields/Level1234/Level34/FixedAsset/Dim4LockedField.php new file mode 100644 index 00000000..ff899ab7 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/Dim4LockedField.php @@ -0,0 +1,47 @@ +dim4Locked; + } + + public function getDim4LockedToString(): ?string + { + return ($this->getDim4Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $dim4Locked + * @return $this + */ + public function setDim4Locked(?bool $dim4Locked): self + { + $this->dim4Locked = $dim4Locked; + return $this; + } + + /** + * @param string|null $dim4LockedString + * @return $this + * @throws Exception + */ + public function setDim4LockedFromString(?string $dim4LockedString) + { + return $this->setDim4Locked(filter_var($dim4LockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim5Field.php b/src/Fields/Level1234/Level34/FixedAsset/Dim5Field.php new file mode 100644 index 00000000..67901e9e --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/Dim5Field.php @@ -0,0 +1,54 @@ +dim5; + } + + public function getDim5ToCode(): ?string + { + if ($this->getDim5() != null) { + return $this->dim5->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDim5($dim5): self + { + $this->dim5 = $dim5; + return $this; + } + + /** + * @param string|null $dim5Code + * @return $this + * @throws Exception + */ + public function setDim5FromCode(?string $dim5Code) + { + $dim5 = new Dummy(); + $dim5->setCode($dim5Code); + return $this->setDim5($dim5); + } +} diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim5LockedField.php b/src/Fields/Level1234/Level34/FixedAsset/Dim5LockedField.php new file mode 100644 index 00000000..97d86b10 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/Dim5LockedField.php @@ -0,0 +1,47 @@ +dim5Locked; + } + + public function getDim5LockedToString(): ?string + { + return ($this->getDim5Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $dim5Locked + * @return $this + */ + public function setDim5Locked(?bool $dim5Locked): self + { + $this->dim5Locked = $dim5Locked; + return $this; + } + + /** + * @param string|null $dim5LockedString + * @return $this + * @throws Exception + */ + public function setDim5LockedFromString(?string $dim5LockedString) + { + return $this->setDim5Locked(filter_var($dim5LockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim6Field.php b/src/Fields/Level1234/Level34/FixedAsset/Dim6Field.php new file mode 100644 index 00000000..f4f5c6c8 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/Dim6Field.php @@ -0,0 +1,54 @@ +dim6; + } + + public function getDim6ToCode(): ?string + { + if ($this->getDim6() != null) { + return $this->dim6->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDim6($dim6): self + { + $this->dim6 = $dim6; + return $this; + } + + /** + * @param string|null $dim6Code + * @return $this + * @throws Exception + */ + public function setDim6FromCode(?string $dim6Code) + { + $dim6 = new Dummy(); + $dim6->setCode($dim6Code); + return $this->setDim6($dim6); + } +} diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim6LockedField.php b/src/Fields/Level1234/Level34/FixedAsset/Dim6LockedField.php new file mode 100644 index 00000000..45021937 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/Dim6LockedField.php @@ -0,0 +1,47 @@ +dim6Locked; + } + + public function getDim6LockedToString(): ?string + { + return ($this->getDim6Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $dim6Locked + * @return $this + */ + public function setDim6Locked(?bool $dim6Locked): self + { + $this->dim6Locked = $dim6Locked; + return $this; + } + + /** + * @param string|null $dim6LockedString + * @return $this + * @throws Exception + */ + public function setDim6LockedFromString(?string $dim6LockedString) + { + return $this->setDim6Locked(filter_var($dim6LockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetCodeField.php b/src/Fields/Level1234/Level34/FixedAsset/FixedAssetCodeField.php new file mode 100644 index 00000000..6bd027cb --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/FixedAssetCodeField.php @@ -0,0 +1,40 @@ +code; + } + + public function getCodeToCode(): ?string + { + if ($this->getCode() != null) { + return $this->code->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setCode($code): self + { + $this->code = $code; + return $this; + } +} diff --git a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetCodeLockedField.php b/src/Fields/Level1234/Level34/FixedAsset/FixedAssetCodeLockedField.php new file mode 100644 index 00000000..12e88646 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/FixedAssetCodeLockedField.php @@ -0,0 +1,47 @@ +codeLocked; + } + + public function getCodeLockedToString(): ?string + { + return ($this->getCodeLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $codeLocked + * @return $this + */ + public function setCodeLocked(?bool $codeLocked): self + { + $this->codeLocked = $codeLocked; + return $this; + } + + /** + * @param string|null $codeLockedString + * @return $this + * @throws Exception + */ + public function setCodeLockedFromString(?string $codeLockedString) + { + return $this->setCodeLocked(filter_var($codeLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsMethodField.php b/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsMethodField.php new file mode 100644 index 00000000..abead77b --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsMethodField.php @@ -0,0 +1,54 @@ +method; + } + + public function getMethodToCode(): ?string + { + if ($this->getMethod() != null) { + return $this->method->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setMethod(?AssetMethod $method): self + { + $this->method = $method; + return $this; + } + + /** + * @param string|null $methodCode + * @return $this + * @throws Exception + */ + public function setMethodFromCode(?string $methodCode) + { + $method = new AssetMethod(); + $method->setCode($methodCode); + return $this->setMethod($method); + } +} diff --git a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsMethodLockedField.php b/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsMethodLockedField.php new file mode 100644 index 00000000..88ecb0f6 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsMethodLockedField.php @@ -0,0 +1,47 @@ +methodLocked; + } + + public function getMethodLockedToString(): ?string + { + return ($this->getMethodLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $methodLocked + * @return $this + */ + public function setMethodLocked(?bool $methodLocked): self + { + $this->methodLocked = $methodLocked; + return $this; + } + + /** + * @param string|null $methodLockedString + * @return $this + * @throws Exception + */ + public function setMethodLockedFromString(?string $methodLockedString) + { + return $this->setMethodLocked(filter_var($methodLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusField.php b/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusField.php new file mode 100644 index 00000000..8640b99c --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusField.php @@ -0,0 +1,41 @@ +fixedAssetsStatus; + } + + /** + * @param FixedAssetsStatus|null $status + * @return $this + */ + public function setStatus(?FixedAssetsStatus $status): self + { + $this->status = $status; + return $this; + } + + /** + * @param string|null $statusString + * @return $this + * @throws Exception + */ + public function setStatusFromString(?string $statusString) + { + return $this->setStatus(new FixedAssetsStatus((string)$statusString)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusLockedField.php b/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusLockedField.php new file mode 100644 index 00000000..c85db61c --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusLockedField.php @@ -0,0 +1,47 @@ +statusLocked; + } + + public function getStatusLockedToString(): ?string + { + return ($this->getStatusLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $statusLocked + * @return $this + */ + public function setStatusLocked(?bool $statusLocked): self + { + $this->statusLocked = $statusLocked; + return $this; + } + + /** + * @param string|null $statusLockedString + * @return $this + * @throws Exception + */ + public function setStatusLockedFromString(?string $statusLockedString) + { + return $this->setStatusLocked(filter_var($statusLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/FreeText1LockedField.php b/src/Fields/Level1234/Level34/FixedAsset/FreeText1LockedField.php new file mode 100644 index 00000000..f6e3f31b --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/FreeText1LockedField.php @@ -0,0 +1,47 @@ +freeText1Locked; + } + + public function getFreeText1LockedToString(): ?string + { + return ($this->getFreeText1Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $freeText1Locked + * @return $this + */ + public function setFreeText1Locked(?bool $freeText1Locked): self + { + $this->freeText1Locked = $freeText1Locked; + return $this; + } + + /** + * @param string|null $freeText1LockedString + * @return $this + * @throws Exception + */ + public function setFreeText1LockedFromString(?string $freeText1LockedString) + { + return $this->setFreeText1Locked(filter_var($freeText1LockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/FreeText2LockedField.php b/src/Fields/Level1234/Level34/FixedAsset/FreeText2LockedField.php new file mode 100644 index 00000000..7d7b1f1e --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/FreeText2LockedField.php @@ -0,0 +1,47 @@ +freeText2Locked; + } + + public function getFreeText2LockedToString(): ?string + { + return ($this->getFreeText2Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $freeText2Locked + * @return $this + */ + public function setFreeText2Locked(?bool $freeText2Locked): self + { + $this->freeText2Locked = $freeText2Locked; + return $this; + } + + /** + * @param string|null $freeText2LockedString + * @return $this + * @throws Exception + */ + public function setFreeText2LockedFromString(?string $freeText2LockedString) + { + return $this->setFreeText2Locked(filter_var($freeText2LockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/FreeText3LockedField.php b/src/Fields/Level1234/Level34/FixedAsset/FreeText3LockedField.php new file mode 100644 index 00000000..a03e4759 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/FreeText3LockedField.php @@ -0,0 +1,47 @@ +freeText3Locked; + } + + public function getFreeText3LockedToString(): ?string + { + return ($this->getFreeText3Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $freeText3Locked + * @return $this + */ + public function setFreeText3Locked(?bool $freeText3Locked): self + { + $this->freeText3Locked = $freeText3Locked; + return $this; + } + + /** + * @param string|null $freeText3LockedString + * @return $this + * @throws Exception + */ + public function setFreeText3LockedFromString(?string $freeText3LockedString) + { + return $this->setFreeText3Locked(filter_var($freeText3LockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/FreeText4Field.php b/src/Fields/Level1234/Level34/FixedAsset/FreeText4Field.php new file mode 100644 index 00000000..be86dee2 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/FreeText4Field.php @@ -0,0 +1,32 @@ +freeText4; + } + + /** + * @param null|string $freeText4 + * @return $this + */ + public function setFreetext4(?string $freeText4): self + { + $this->freeText4 = $freeText4; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/FreeText4LockedField.php b/src/Fields/Level1234/Level34/FixedAsset/FreeText4LockedField.php new file mode 100644 index 00000000..47cca078 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/FreeText4LockedField.php @@ -0,0 +1,47 @@ +freeText4Locked; + } + + public function getFreeText4LockedToString(): ?string + { + return ($this->getFreeText4Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $freeText4Locked + * @return $this + */ + public function setFreeText4Locked(?bool $freeText4Locked): self + { + $this->freeText4Locked = $freeText4Locked; + return $this; + } + + /** + * @param string|null $freeText4LockedString + * @return $this + * @throws Exception + */ + public function setFreeText4LockedFromString(?string $freeText4LockedString) + { + return $this->setFreeText4Locked(filter_var($freeText4LockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/FreeText5Field.php b/src/Fields/Level1234/Level34/FixedAsset/FreeText5Field.php new file mode 100644 index 00000000..d3cb284c --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/FreeText5Field.php @@ -0,0 +1,32 @@ +freeText5; + } + + /** + * @param null|string $freeText5 + * @return $this + */ + public function setFreetext5(?string $freeText5): self + { + $this->freeText5 = $freeText5; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/FreeText5LockedField.php b/src/Fields/Level1234/Level34/FixedAsset/FreeText5LockedField.php new file mode 100644 index 00000000..3466b770 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/FreeText5LockedField.php @@ -0,0 +1,47 @@ +freeText5Locked; + } + + public function getFreeText5LockedToString(): ?string + { + return ($this->getFreeText5Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $freeText5Locked + * @return $this + */ + public function setFreeText5Locked(?bool $freeText5Locked): self + { + $this->freeText5Locked = $freeText5Locked; + return $this; + } + + /** + * @param string|null $freeText5LockedString + * @return $this + * @throws Exception + */ + public function setFreeText5LockedFromString(?string $freeText5LockedString) + { + return $this->setFreeText5Locked(filter_var($freeText5LockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/LastDepreciationField.php b/src/Fields/Level1234/Level34/FixedAsset/LastDepreciationField.php new file mode 100644 index 00000000..a59d6dbf --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/LastDepreciationField.php @@ -0,0 +1,38 @@ +lastDepreciation; + } + + /** + * @param string|null $lastDepreciation + * @return $this + */ + public function setLastDepreciation(?string $lastDepreciation): self + { + if (!preg_match("!\\d{4}/\\d{1,2}!", $lastDepreciation)) { + $lastDepreciation = ''; + } + + $this->lastDepreciation = $lastDepreciation; + + return $this; + } +} diff --git a/src/Fields/Level1234/Level34/FixedAsset/LastDepreciationLockedField.php b/src/Fields/Level1234/Level34/FixedAsset/LastDepreciationLockedField.php new file mode 100644 index 00000000..9fdbd22b --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/LastDepreciationLockedField.php @@ -0,0 +1,47 @@ +lastDepreciationLocked; + } + + public function getLastDepreciationLockedToString(): ?string + { + return ($this->getLastDepreciationLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $lastDepreciationLocked + * @return $this + */ + public function setLastDepreciationLocked(?bool $lastDepreciationLocked): self + { + $this->lastDepreciationLocked = $lastDepreciationLocked; + return $this; + } + + /** + * @param string|null $lastDepreciationLockedString + * @return $this + * @throws Exception + */ + public function setLastDepreciationLockedFromString(?string $lastDepreciationLockedString) + { + return $this->setLastDepreciationLocked(filter_var($lastDepreciationLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/LineField.php b/src/Fields/Level1234/Level34/FixedAsset/LineField.php new file mode 100644 index 00000000..a6fa8d10 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/LineField.php @@ -0,0 +1,32 @@ +line; + } + + /** + * @param null|int $line + * @return $this + */ + public function setLine(?int $line): self + { + $this->line = $line; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/LineLockedField.php b/src/Fields/Level1234/Level34/FixedAsset/LineLockedField.php new file mode 100644 index 00000000..2968291c --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/LineLockedField.php @@ -0,0 +1,47 @@ +lineLocked; + } + + public function getLineLockedToString(): ?string + { + return ($this->getLineLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $lineLocked + * @return $this + */ + public function setLineLocked(?bool $lineLocked): self + { + $this->lineLocked = $lineLocked; + return $this; + } + + /** + * @param string|null $lineLockedString + * @return $this + * @throws Exception + */ + public function setLineLockedFromString(?string $lineLockedString) + { + return $this->setLineLocked(filter_var($lineLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/NrOfPeriodsInheritedField.php b/src/Fields/Level1234/Level34/FixedAsset/NrOfPeriodsInheritedField.php new file mode 100644 index 00000000..112d36e6 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/NrOfPeriodsInheritedField.php @@ -0,0 +1,47 @@ +nrOfPeriodsInherited; + } + + public function getNrOfPeriodsInheritedToString(): ?string + { + return ($this->getNrOfPeriodsInherited()) ? 'true' : 'false'; + } + + /** + * @param bool $nrOfPeriodsInherited + * @return $this + */ + public function setNrOfPeriodsInherited(?bool $nrOfPeriodsInherited): self + { + $this->nrOfPeriodsInherited = $nrOfPeriodsInherited; + return $this; + } + + /** + * @param string|null $nrOfPeriodsInheritedString + * @return $this + * @throws Exception + */ + public function setNrOfPeriodsInheritedFromString(?string $nrOfPeriodsInheritedString) + { + return $this->setNrOfPeriodsInherited(filter_var($nrOfPeriodsInheritedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/NrOfPeriodsLockedField.php b/src/Fields/Level1234/Level34/FixedAsset/NrOfPeriodsLockedField.php new file mode 100644 index 00000000..009b064f --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/NrOfPeriodsLockedField.php @@ -0,0 +1,47 @@ +nrOfPeriodsLocked; + } + + public function getNrOfPeriodsLockedToString(): ?string + { + return ($this->getNrOfPeriodsLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $nrOfPeriodsLocked + * @return $this + */ + public function setNrOfPeriodsLocked(?bool $nrOfPeriodsLocked): self + { + $this->nrOfPeriodsLocked = $nrOfPeriodsLocked; + return $this; + } + + /** + * @param string|null $nrOfPeriodsLockedString + * @return $this + * @throws Exception + */ + public function setNrOfPeriodsLockedFromString(?string $nrOfPeriodsLockedString) + { + return $this->setNrOfPeriodsLocked(filter_var($nrOfPeriodsLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/NumberField.php b/src/Fields/Level1234/Level34/FixedAsset/NumberField.php new file mode 100644 index 00000000..38b67d0c --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/NumberField.php @@ -0,0 +1,32 @@ +number; + } + + /** + * @param null|int $number + * @return $this + */ + public function setNumber(?int $number): self + { + $this->number = $number; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/NumberLockedField.php b/src/Fields/Level1234/Level34/FixedAsset/NumberLockedField.php new file mode 100644 index 00000000..e8ba56e4 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/NumberLockedField.php @@ -0,0 +1,47 @@ +numberLocked; + } + + public function getNumberLockedToString(): ?string + { + return ($this->getNumberLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $numberLocked + * @return $this + */ + public function setNumberLocked(?bool $numberLocked): self + { + $this->numberLocked = $numberLocked; + return $this; + } + + /** + * @param string|null $numberLockedString + * @return $this + * @throws Exception + */ + public function setNumberLockedFromString(?string $numberLockedString) + { + return $this->setNumberLocked(filter_var($numberLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/PercentageLockedField.php b/src/Fields/Level1234/Level34/FixedAsset/PercentageLockedField.php new file mode 100644 index 00000000..1a14a825 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/PercentageLockedField.php @@ -0,0 +1,47 @@ +percentageLocked; + } + + public function getPercentageLockedToString(): ?string + { + return ($this->getPercentageLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $percentageLocked + * @return $this + */ + public function setPercentageLocked(?bool $percentageLocked): self + { + $this->percentageLocked = $percentageLocked; + return $this; + } + + /** + * @param string|null $percentageLockedString + * @return $this + * @throws Exception + */ + public function setPercentageLockedFromString(?string $percentageLockedString) + { + return $this->setPercentageLocked(filter_var($percentageLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/PeriodLockedField.php b/src/Fields/Level1234/Level34/FixedAsset/PeriodLockedField.php new file mode 100644 index 00000000..635bf011 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/PeriodLockedField.php @@ -0,0 +1,47 @@ +periodLocked; + } + + public function getPeriodLockedToString(): ?string + { + return ($this->getPeriodLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $periodLocked + * @return $this + */ + public function setPeriodLocked(?bool $periodLocked): self + { + $this->periodLocked = $periodLocked; + return $this; + } + + /** + * @param string|null $periodLockedString + * @return $this + * @throws Exception + */ + public function setPeriodLockedFromString(?string $periodLockedString) + { + return $this->setPeriodLocked(filter_var($periodLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/PurchaseDateField.php b/src/Fields/Level1234/Level34/FixedAsset/PurchaseDateField.php new file mode 100644 index 00000000..d2a42a45 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/PurchaseDateField.php @@ -0,0 +1,66 @@ +purchaseDate; + } + + /** + * @return string|null + */ + public function getPurchaseDateToString(): ?string + { + if ($this->getPurchaseDate() != null) { + return Util::formatDate($this->getPurchaseDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $purchaseDate + * @return $this + */ + public function setPurchaseDate(?\DateTimeInterface $purchaseDate) + { + $this->purchaseDate = $purchaseDate; + return $this; + } + + /** + * @param string|null $purchaseDateString + * @return $this + * @throws Exception + */ + public function setPurchaseDateFromString(?string $purchaseDateString) + { + if ((bool)strtotime($purchaseDateString)) { + return $this->setPurchaseDate(Util::parseDate($purchaseDateString)); + } else { + return $this->setPurchaseDate(null); + } + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/PurchaseDateLockedField.php b/src/Fields/Level1234/Level34/FixedAsset/PurchaseDateLockedField.php new file mode 100644 index 00000000..6ba046c2 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/PurchaseDateLockedField.php @@ -0,0 +1,47 @@ +purchaseDateLocked; + } + + public function getPurchaseDateLockedToString(): ?string + { + return ($this->getPurchaseDateLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $purchaseDateLocked + * @return $this + */ + public function setPurchaseDateLocked(?bool $purchaseDateLocked): self + { + $this->purchaseDateLocked = $purchaseDateLocked; + return $this; + } + + /** + * @param string|null $purchaseDateLockedString + * @return $this + * @throws Exception + */ + public function setPurchaseDateLockedFromString(?string $purchaseDateLockedString) + { + return $this->setPurchaseDateLocked(filter_var($purchaseDateLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/ResidualValueField.php b/src/Fields/Level1234/Level34/FixedAsset/ResidualValueField.php new file mode 100644 index 00000000..aa54ee8a --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/ResidualValueField.php @@ -0,0 +1,62 @@ +residualValue; + } + + /** + * @return float|null + */ + public function getResidualValueToFloat(): ?float + { + if ($this->getResidualValue() != null) { + return Util::formatMoney($this->getResidualValue()); + } else { + return 0; + } + } + + /** + * @param Money|null $residualValue + * @return $this + */ + public function setResidualValue(?Money $residualValue) + { + $this->residualValue = $residualValue; + + return $this; + } + + /** + * @param float|null $residualValueFloat + * @return $this + * @throws Exception + */ + public function setResidualValueFromFloat(?float $residualValueFloat) + { + if ((float)$residualValueFloat) { + return $this->setResidualValue(Money::EUR(100 * $residualValueFloat)); + } else { + return $this->setResidualValue(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/ResidualValueLockedField.php b/src/Fields/Level1234/Level34/FixedAsset/ResidualValueLockedField.php new file mode 100644 index 00000000..58010b76 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/ResidualValueLockedField.php @@ -0,0 +1,47 @@ +residualValueLocked; + } + + public function getResidualValueLockedToString(): ?string + { + return ($this->getResidualValueLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $residualValueLocked + * @return $this + */ + public function setResidualValueLocked(?bool $residualValueLocked): self + { + $this->residualValueLocked = $residualValueLocked; + return $this; + } + + /** + * @param string|null $residualValueLockedString + * @return $this + * @throws Exception + */ + public function setResidualValueLockedFromString(?string $residualValueLockedString) + { + return $this->setResidualValueLocked(filter_var($residualValueLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/SellDateField.php b/src/Fields/Level1234/Level34/FixedAsset/SellDateField.php new file mode 100644 index 00000000..3d121338 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/SellDateField.php @@ -0,0 +1,66 @@ +sellDate; + } + + /** + * @return string|null + */ + public function getSellDateToString(): ?string + { + if ($this->getSellDate() != null) { + return Util::formatDate($this->getSellDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $sellDate + * @return $this + */ + public function setSellDate(?\DateTimeInterface $sellDate) + { + $this->sellDate = $sellDate; + return $this; + } + + /** + * @param string|null $sellDateString + * @return $this + * @throws Exception + */ + public function setSellDateFromString(?string $sellDateString) + { + if ((bool)strtotime($sellDateString)) { + return $this->setSellDate(Util::parseDate($sellDateString)); + } else { + return $this->setSellDate(null); + } + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/SellDateLockedField.php b/src/Fields/Level1234/Level34/FixedAsset/SellDateLockedField.php new file mode 100644 index 00000000..25bf1697 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/SellDateLockedField.php @@ -0,0 +1,47 @@ +sellDateLocked; + } + + public function getSellDateLockedToString(): ?string + { + return ($this->getSellDateLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $sellDateLocked + * @return $this + */ + public function setSellDateLocked(?bool $sellDateLocked): self + { + $this->sellDateLocked = $sellDateLocked; + return $this; + } + + /** + * @param string|null $sellDateLockedString + * @return $this + * @throws Exception + */ + public function setSellDateLockedFromString(?string $sellDateLockedString) + { + return $this->setSellDateLocked(filter_var($sellDateLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/StopValueField.php b/src/Fields/Level1234/Level34/FixedAsset/StopValueField.php new file mode 100644 index 00000000..380cc326 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/StopValueField.php @@ -0,0 +1,62 @@ +stopValue; + } + + /** + * @return float|null + */ + public function getStopValueToFloat(): ?float + { + if ($this->getStopValue() != null) { + return Util::formatMoney($this->getStopValue()); + } else { + return 0; + } + } + + /** + * @param Money|null $stopValue + * @return $this + */ + public function setStopValue(?Money $stopValue) + { + $this->stopValue = $stopValue; + + return $this; + } + + /** + * @param float|null $stopValueFloat + * @return $this + * @throws Exception + */ + public function setStopValueFromFloat(?float $stopValueFloat) + { + if ((float)$stopValueFloat) { + return $this->setStopValue(Money::EUR(100 * $stopValueFloat)); + } else { + return $this->setStopValue(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/StopValueLockedField.php b/src/Fields/Level1234/Level34/FixedAsset/StopValueLockedField.php new file mode 100644 index 00000000..9a07ed83 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/StopValueLockedField.php @@ -0,0 +1,47 @@ +stopValueLocked; + } + + public function getStopValueLockedToString(): ?string + { + return ($this->getStopValueLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $stopValueLocked + * @return $this + */ + public function setStopValueLocked(?bool $stopValueLocked): self + { + $this->stopValueLocked = $stopValueLocked; + return $this; + } + + /** + * @param string|null $stopValueLockedString + * @return $this + * @throws Exception + */ + public function setStopValueLockedFromString(?string $stopValueLockedString) + { + return $this->setStopValueLocked(filter_var($stopValueLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/TransactionLinesLockedField.php b/src/Fields/Level1234/Level34/FixedAsset/TransactionLinesLockedField.php new file mode 100644 index 00000000..6dbf4783 --- /dev/null +++ b/src/Fields/Level1234/Level34/FixedAsset/TransactionLinesLockedField.php @@ -0,0 +1,47 @@ +transactionLinesLocked; + } + + public function getTransactionLinesLockedToString(): ?string + { + return ($this->getTransactionLinesLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $transactionLinesLocked + * @return $this + */ + public function setTransactionLinesLocked(?bool $transactionLinesLocked): self + { + $this->transactionLinesLocked = $transactionLinesLocked; + return $this; + } + + /** + * @param string|null $transactionLinesLockedString + * @return $this + * @throws Exception + */ + public function setTransactionLinesLockedFromString(?string $transactionLinesLockedString) + { + return $this->setTransactionLinesLocked(filter_var($transactionLinesLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/InvoiceDescriptionField.php b/src/Fields/Level1234/Level34/InvoiceDescriptionField.php new file mode 100644 index 00000000..dc24d480 --- /dev/null +++ b/src/Fields/Level1234/Level34/InvoiceDescriptionField.php @@ -0,0 +1,32 @@ +invoiceDescription; + } + + /** + * @param null|string $invoiceDescription + * @return $this + */ + public function setInvoiceDescription(?string $invoiceDescription): self + { + $this->invoiceDescription = $invoiceDescription; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/LabelField.php b/src/Fields/Level1234/Level34/LabelField.php new file mode 100644 index 00000000..6eb6c6cc --- /dev/null +++ b/src/Fields/Level1234/Level34/LabelField.php @@ -0,0 +1,32 @@ +label; + } + + /** + * @param null|string $label + * @return $this + */ + public function setLabel(?string $label): self + { + $this->label = $label; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/MandatoryField.php b/src/Fields/Level1234/Level34/MandatoryField.php new file mode 100644 index 00000000..82c39558 --- /dev/null +++ b/src/Fields/Level1234/Level34/MandatoryField.php @@ -0,0 +1,47 @@ +mandatory; + } + + public function getMandatoryToString(): ?string + { + return ($this->getMandatory()) ? 'true' : 'false'; + } + + /** + * @param bool $mandatory + * @return $this + */ + public function setMandatory(?bool $mandatory): self + { + $this->mandatory = $mandatory; + return $this; + } + + /** + * @param string|null $mandatoryString + * @return $this + * @throws Exception + */ + public function setMandatoryFromString(?string $mandatoryString) + { + return $this->setMandatory(filter_var($mandatoryString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/RateInheritField.php b/src/Fields/Level1234/Level34/RateInheritField.php new file mode 100644 index 00000000..374a11d8 --- /dev/null +++ b/src/Fields/Level1234/Level34/RateInheritField.php @@ -0,0 +1,47 @@ +rateInherit; + } + + public function getRateInheritToString(): ?string + { + return ($this->getRateInherit()) ? 'true' : 'false'; + } + + /** + * @param bool $rateInherit + * @return $this + */ + public function setRateInherit(?bool $rateInherit): self + { + $this->rateInherit = $rateInherit; + return $this; + } + + /** + * @param string|null $rateInheritString + * @return $this + * @throws Exception + */ + public function setRateInheritFromString(?string $rateInheritString) + { + return $this->setRateInherit(filter_var($rateInheritString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/RateLockedField.php b/src/Fields/Level1234/Level34/RateLockedField.php new file mode 100644 index 00000000..65cb1a4f --- /dev/null +++ b/src/Fields/Level1234/Level34/RateLockedField.php @@ -0,0 +1,47 @@ +rateLocked; + } + + public function getRateLockedToString(): ?string + { + return ($this->getRateLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $rateLocked + * @return $this + */ + public function setRateLocked(?bool $rateLocked): self + { + $this->rateLocked = $rateLocked; + return $this; + } + + /** + * @param string|null $rateLockedString + * @return $this + * @throws Exception + */ + public function setRateLockedFromString(?string $rateLockedString) + { + return $this->setRateLocked(filter_var($rateLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/ValidFromField.php b/src/Fields/Level1234/Level34/ValidFromField.php new file mode 100644 index 00000000..1cfb3f64 --- /dev/null +++ b/src/Fields/Level1234/Level34/ValidFromField.php @@ -0,0 +1,66 @@ +validFrom; + } + + /** + * @return string|null + */ + public function getValidFromToString(): ?string + { + if ($this->getValidFrom() != null) { + return Util::formatDate($this->getValidFrom()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $validFrom + * @return $this + */ + public function setValidFrom(?\DateTimeInterface $validFrom) + { + $this->validFrom = $validFrom; + return $this; + } + + /** + * @param string|null $validFromString + * @return $this + * @throws Exception + */ + public function setValidFromFromString(?string $validFromString) + { + if ((bool)strtotime($validFromString)) { + return $this->setValidFrom(Util::parseDate($validFromString)); + } else { + return $this->setValidFrom(null); + } + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/ValidTillField.php b/src/Fields/Level1234/Level34/ValidTillField.php new file mode 100644 index 00000000..70fbb0d8 --- /dev/null +++ b/src/Fields/Level1234/Level34/ValidTillField.php @@ -0,0 +1,66 @@ +validTill; + } + + /** + * @return string|null + */ + public function getValidTillToString(): ?string + { + if ($this->getValidTill() != null) { + return Util::formatDate($this->getValidTill()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $validTill + * @return $this + */ + public function setValidTill(?\DateTimeInterface $validTill) + { + $this->validTill = $validTill; + return $this; + } + + /** + * @param string|null $validTillString + * @return $this + * @throws Exception + */ + public function setValidTillFromString(?string $validTillString) + { + if ((bool)strtotime($validTillString)) { + return $this->setValidTill(Util::parseDate($validTillString)); + } else { + return $this->setValidTill(null); + } + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/LevelField.php b/src/Fields/Level1234/LevelField.php new file mode 100644 index 00000000..f9d2ed54 --- /dev/null +++ b/src/Fields/Level1234/LevelField.php @@ -0,0 +1,32 @@ +level; + } + + /** + * @param null|int $level + * @return $this + */ + public function setLevel(?int $level): self + { + $this->level = $level; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/MatchTypeField.php b/src/Fields/Level1234/MatchTypeField.php new file mode 100644 index 00000000..bed20d43 --- /dev/null +++ b/src/Fields/Level1234/MatchTypeField.php @@ -0,0 +1,41 @@ +matchType; + } + + /** + * @param MatchType|null $matchType + * @return $this + */ + public function setMatchType(?MatchType $matchType): self + { + $this->matchType = $matchType; + return $this; + } + + /** + * @param string|null $matchTypeString + * @return $this + * @throws Exception + */ + public function setMatchTypeFromString(?string $matchTypeString) + { + return $this->setMatchType(new MatchType((string)$matchTypeString)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/SubAnalyseField.php b/src/Fields/Level1234/SubAnalyseField.php new file mode 100644 index 00000000..0d152787 --- /dev/null +++ b/src/Fields/Level1234/SubAnalyseField.php @@ -0,0 +1,41 @@ +subAnalyse; + } + + /** + * @param SubAnalyse|null $subAnalyse + * @return $this + */ + public function setSubAnalyse(?SubAnalyse $subAnalyse): self + { + $this->subAnalyse = $subAnalyse; + return $this; + } + + /** + * @param string|null $subAnalyseString + * @return $this + * @throws Exception + */ + public function setSubAnalyseFromString(?string $subAnalyseString) + { + return $this->setSubAnalyse(new SubAnalyse((string)$subAnalyseString)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/SubstituteWithField.php b/src/Fields/Level1234/SubstituteWithField.php new file mode 100644 index 00000000..2862ee11 --- /dev/null +++ b/src/Fields/Level1234/SubstituteWithField.php @@ -0,0 +1,54 @@ +substituteWith; + } + + public function getSubstituteWithToCode(): ?string + { + if ($this->getSubstituteWith() != null) { + return $this->substituteWith->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setSubstituteWith($substituteWith): self + { + $this->substituteWith = $substituteWith; + return $this; + } + + /** + * @param string|null $substituteWithCode + * @return $this + * @throws Exception + */ + public function setSubstituteWithFromCode(?string $substituteWithCode) + { + $substituteWith = new Dummy(); + $substituteWith->setCode($substituteWithCode); + return $this->setSubstituteWith($substituteWith); + } +} diff --git a/src/Fields/Level1234/SubstituteWithIDField.php b/src/Fields/Level1234/SubstituteWithIDField.php new file mode 100644 index 00000000..013eb897 --- /dev/null +++ b/src/Fields/Level1234/SubstituteWithIDField.php @@ -0,0 +1,32 @@ +substituteWithID; + } + + /** + * @param null|string $substituteWithID + * @return $this + */ + public function setSubstituteWithID(?string $substituteWithID): self + { + $this->substituteWithID = $substituteWithID; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/SubstitutionLevelField.php b/src/Fields/Level1234/SubstitutionLevelField.php new file mode 100644 index 00000000..12a9d637 --- /dev/null +++ b/src/Fields/Level1234/SubstitutionLevelField.php @@ -0,0 +1,32 @@ +substitutionLevel; + } + + /** + * @param null|int $substitutionLevel + * @return $this + */ + public function setSubstitutionLevel(?int $substitutionLevel): self + { + $this->substitutionLevel = $substitutionLevel; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/VatCodeFixedField.php b/src/Fields/Level1234/VatCodeFixedField.php new file mode 100644 index 00000000..3f3cf627 --- /dev/null +++ b/src/Fields/Level1234/VatCodeFixedField.php @@ -0,0 +1,47 @@ +vatCodeFixed; + } + + public function getVatCodeFixedToString(): ?string + { + return ($this->getVatCodeFixed()) ? 'true' : 'false'; + } + + /** + * @param bool $vatCodeFixed + * @return $this + */ + public function setVatCodeFixed(?bool $vatCodeFixed): self + { + $this->vatCodeFixed = $vatCodeFixed; + return $this; + } + + /** + * @param string|null $vatCodeFixedString + * @return $this + * @throws Exception + */ + public function setVatCodeFixedFromString(?string $vatCodeFixedString) + { + return $this->setVatCodeFixed(filter_var($vatCodeFixedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file From dcbd3d6e0370c82a93d7642639b5912833be5f6a Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:33:22 +0200 Subject: [PATCH 056/388] Add files via upload --- .../DimensionGroup/DimensionCodeField.php | 54 +++++++++++++++ .../DimensionTypeFinancialsField.php | 32 +++++++++ .../DimensionType/DimensionTypeTimeField.php | 32 +++++++++ .../Level1234/DimensionType/Label1Field.php | 32 +++++++++ .../Level1234/DimensionType/Label2Field.php | 32 +++++++++ .../Level1234/DimensionType/Label3Field.php | 32 +++++++++ .../Level1234/DimensionType/Label4Field.php | 32 +++++++++ .../Level1234/DimensionType/Label5Field.php | 32 +++++++++ .../Level1234/DimensionType/Label6Field.php | 32 +++++++++ .../Level1234/DimensionType/MaskField.php | 32 +++++++++ .../Level1234/Level2/AccountNumberField.php | 32 +++++++++ .../Level1234/Level2/AddressField2Field.php | 32 +++++++++ .../Level1234/Level2/AddressField3Field.php | 32 +++++++++ .../Level1234/Level2/AddressTypeField.php | 41 ++++++++++++ .../Level1234/Level2/AscriptionField.php | 32 +++++++++ .../Level1234/Level2/BankBlockedField.php | 47 +++++++++++++ src/Fields/Level1234/Level2/BankNameField.php | 32 +++++++++ src/Fields/Level1234/Level2/BicCodeField.php | 32 +++++++++ src/Fields/Level1234/Level2/CityField.php | 32 +++++++++ src/Fields/Level1234/Level2/CountryField.php | 54 +++++++++++++++ .../Level2/Customer/BaseCreditLimitField.php | 62 +++++++++++++++++ .../Level2/Customer/BlockedField.php | 47 +++++++++++++ .../Level2/Customer/BlockedLockedField.php | 47 +++++++++++++ .../Level2/Customer/BlockedModifiedField.php | 66 +++++++++++++++++++ .../Level2/Customer/CollectionSchemaField.php | 41 ++++++++++++ .../Level2/Customer/CommentField.php | 32 +++++++++ .../Customer/CustomerFreeText1Field.php | 47 +++++++++++++ .../Level2/Customer/DiscountArticleField.php | 54 +++++++++++++++ .../Customer/DiscountArticleIDField.php | 32 +++++++++ .../Level2/Customer/EBillMailField.php | 32 +++++++++ .../Level2/Customer/EBillingField.php | 47 +++++++++++++ .../Level2/Customer/FirstRunDateField.php | 66 +++++++++++++++++++ .../Level2/Customer/ReminderEmailField.php | 32 +++++++++ .../Level2/Customer/ResponsibleUserField.php | 55 ++++++++++++++++ .../Level2/Customer/SendReminderField.php | 41 ++++++++++++ .../Level2/Customer/SignatureDateField.php | 66 +++++++++++++++++++ src/Fields/Level1234/Level2/DefaultField.php | 47 +++++++++++++ .../Level1234/Level2/Dimension1Field.php | 54 +++++++++++++++ .../Level1234/Level2/Dimension1IDField.php | 32 +++++++++ .../Level1234/Level2/Dimension2Field.php | 54 +++++++++++++++ .../Level1234/Level2/Dimension2IDField.php | 32 +++++++++ .../Level1234/Level2/Dimension3Field.php | 54 +++++++++++++++ .../Level1234/Level2/Dimension3IDField.php | 32 +++++++++ src/Fields/Level1234/Level2/DueDaysField.php | 32 +++++++++ src/Fields/Level1234/Level2/EmailField.php | 32 +++++++++ src/Fields/Level1234/Level2/Field1Field.php | 32 +++++++++ src/Fields/Level1234/Level2/Field2Field.php | 32 +++++++++ src/Fields/Level1234/Level2/Field3Field.php | 32 +++++++++ src/Fields/Level1234/Level2/Field4Field.php | 32 +++++++++ src/Fields/Level1234/Level2/Field5Field.php | 32 +++++++++ src/Fields/Level1234/Level2/Field6Field.php | 32 +++++++++ src/Fields/Level1234/Level2/IbanField.php | 32 +++++++++ .../Level1234/Level2/MeansOfPaymentField.php | 41 ++++++++++++ .../Level1234/Level2/NatBicCodeField.php | 32 +++++++++ .../Level1234/Level2/PayAvailableField.php | 47 +++++++++++++ src/Fields/Level1234/Level2/PayCodeField.php | 54 +++++++++++++++ .../Level1234/Level2/PayCodeIDField.php | 32 +++++++++ .../PaymentConditionDiscountDaysField.php | 32 +++++++++ ...aymentConditionDiscountPercentageField.php | 32 +++++++++ src/Fields/Level1234/Level2/PostcodeField.php | 32 +++++++++ src/Fields/Level1234/Level2/RatioField.php | 32 +++++++++ .../Level2/RemittanceAdviceSendMailField.php | 32 +++++++++ .../Level2/RemittanceAdviceSendTypeField.php | 41 ++++++++++++ src/Fields/Level1234/Level2/StateField.php | 32 +++++++++ ...ccountPaymentConditionsIncludeVatField.php | 41 ++++++++++++ ...ccountPaymentConditionsPercentageField.php | 32 +++++++++ .../Supplier/RelationsReferenceField.php | 32 +++++++++ src/Fields/Level1234/Level2/TelefaxField.php | 32 +++++++++ .../Level1234/Level2/TelephoneField.php | 32 +++++++++ src/Fields/Level1234/Level2/WebsiteField.php | 32 +++++++++ 70 files changed, 2708 insertions(+) create mode 100644 src/Fields/Level1234/DimensionGroup/DimensionCodeField.php create mode 100644 src/Fields/Level1234/DimensionType/DimensionTypeFinancialsField.php create mode 100644 src/Fields/Level1234/DimensionType/DimensionTypeTimeField.php create mode 100644 src/Fields/Level1234/DimensionType/Label1Field.php create mode 100644 src/Fields/Level1234/DimensionType/Label2Field.php create mode 100644 src/Fields/Level1234/DimensionType/Label3Field.php create mode 100644 src/Fields/Level1234/DimensionType/Label4Field.php create mode 100644 src/Fields/Level1234/DimensionType/Label5Field.php create mode 100644 src/Fields/Level1234/DimensionType/Label6Field.php create mode 100644 src/Fields/Level1234/DimensionType/MaskField.php create mode 100644 src/Fields/Level1234/Level2/AccountNumberField.php create mode 100644 src/Fields/Level1234/Level2/AddressField2Field.php create mode 100644 src/Fields/Level1234/Level2/AddressField3Field.php create mode 100644 src/Fields/Level1234/Level2/AddressTypeField.php create mode 100644 src/Fields/Level1234/Level2/AscriptionField.php create mode 100644 src/Fields/Level1234/Level2/BankBlockedField.php create mode 100644 src/Fields/Level1234/Level2/BankNameField.php create mode 100644 src/Fields/Level1234/Level2/BicCodeField.php create mode 100644 src/Fields/Level1234/Level2/CityField.php create mode 100644 src/Fields/Level1234/Level2/CountryField.php create mode 100644 src/Fields/Level1234/Level2/Customer/BaseCreditLimitField.php create mode 100644 src/Fields/Level1234/Level2/Customer/BlockedField.php create mode 100644 src/Fields/Level1234/Level2/Customer/BlockedLockedField.php create mode 100644 src/Fields/Level1234/Level2/Customer/BlockedModifiedField.php create mode 100644 src/Fields/Level1234/Level2/Customer/CollectionSchemaField.php create mode 100644 src/Fields/Level1234/Level2/Customer/CommentField.php create mode 100644 src/Fields/Level1234/Level2/Customer/CustomerFreeText1Field.php create mode 100644 src/Fields/Level1234/Level2/Customer/DiscountArticleField.php create mode 100644 src/Fields/Level1234/Level2/Customer/DiscountArticleIDField.php create mode 100644 src/Fields/Level1234/Level2/Customer/EBillMailField.php create mode 100644 src/Fields/Level1234/Level2/Customer/EBillingField.php create mode 100644 src/Fields/Level1234/Level2/Customer/FirstRunDateField.php create mode 100644 src/Fields/Level1234/Level2/Customer/ReminderEmailField.php create mode 100644 src/Fields/Level1234/Level2/Customer/ResponsibleUserField.php create mode 100644 src/Fields/Level1234/Level2/Customer/SendReminderField.php create mode 100644 src/Fields/Level1234/Level2/Customer/SignatureDateField.php create mode 100644 src/Fields/Level1234/Level2/DefaultField.php create mode 100644 src/Fields/Level1234/Level2/Dimension1Field.php create mode 100644 src/Fields/Level1234/Level2/Dimension1IDField.php create mode 100644 src/Fields/Level1234/Level2/Dimension2Field.php create mode 100644 src/Fields/Level1234/Level2/Dimension2IDField.php create mode 100644 src/Fields/Level1234/Level2/Dimension3Field.php create mode 100644 src/Fields/Level1234/Level2/Dimension3IDField.php create mode 100644 src/Fields/Level1234/Level2/DueDaysField.php create mode 100644 src/Fields/Level1234/Level2/EmailField.php create mode 100644 src/Fields/Level1234/Level2/Field1Field.php create mode 100644 src/Fields/Level1234/Level2/Field2Field.php create mode 100644 src/Fields/Level1234/Level2/Field3Field.php create mode 100644 src/Fields/Level1234/Level2/Field4Field.php create mode 100644 src/Fields/Level1234/Level2/Field5Field.php create mode 100644 src/Fields/Level1234/Level2/Field6Field.php create mode 100644 src/Fields/Level1234/Level2/IbanField.php create mode 100644 src/Fields/Level1234/Level2/MeansOfPaymentField.php create mode 100644 src/Fields/Level1234/Level2/NatBicCodeField.php create mode 100644 src/Fields/Level1234/Level2/PayAvailableField.php create mode 100644 src/Fields/Level1234/Level2/PayCodeField.php create mode 100644 src/Fields/Level1234/Level2/PayCodeIDField.php create mode 100644 src/Fields/Level1234/Level2/PaymentConditionDiscountDaysField.php create mode 100644 src/Fields/Level1234/Level2/PaymentConditionDiscountPercentageField.php create mode 100644 src/Fields/Level1234/Level2/PostcodeField.php create mode 100644 src/Fields/Level1234/Level2/RatioField.php create mode 100644 src/Fields/Level1234/Level2/RemittanceAdviceSendMailField.php create mode 100644 src/Fields/Level1234/Level2/RemittanceAdviceSendTypeField.php create mode 100644 src/Fields/Level1234/Level2/StateField.php create mode 100644 src/Fields/Level1234/Level2/Supplier/BlockedAccountPaymentConditionsIncludeVatField.php create mode 100644 src/Fields/Level1234/Level2/Supplier/BlockedAccountPaymentConditionsPercentageField.php create mode 100644 src/Fields/Level1234/Level2/Supplier/RelationsReferenceField.php create mode 100644 src/Fields/Level1234/Level2/TelefaxField.php create mode 100644 src/Fields/Level1234/Level2/TelephoneField.php create mode 100644 src/Fields/Level1234/Level2/WebsiteField.php diff --git a/src/Fields/Level1234/DimensionGroup/DimensionCodeField.php b/src/Fields/Level1234/DimensionGroup/DimensionCodeField.php new file mode 100644 index 00000000..e8d04f02 --- /dev/null +++ b/src/Fields/Level1234/DimensionGroup/DimensionCodeField.php @@ -0,0 +1,54 @@ +code; + } + + public function getCodeToCode(): ?string + { + if ($this->getCode() != null) { + return $this->code->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setCode($code): self + { + $this->code = $code; + return $this; + } + + /** + * @param string|null $codeCode + * @return $this + * @throws Exception + */ + public function setCodeFromCode(?string $codeCode) + { + $code = new Dummy(); + $code->setCode($codeCode); + return $this->setCode($code); + } +} diff --git a/src/Fields/Level1234/DimensionType/DimensionTypeFinancialsField.php b/src/Fields/Level1234/DimensionType/DimensionTypeFinancialsField.php new file mode 100644 index 00000000..9c309887 --- /dev/null +++ b/src/Fields/Level1234/DimensionType/DimensionTypeFinancialsField.php @@ -0,0 +1,32 @@ +financials; + } + + /** + * @param null|int $financials + * @return $this + */ + public function setFinancials(?int $financials): self + { + $this->financials = $financials; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/DimensionType/DimensionTypeTimeField.php b/src/Fields/Level1234/DimensionType/DimensionTypeTimeField.php new file mode 100644 index 00000000..fc821496 --- /dev/null +++ b/src/Fields/Level1234/DimensionType/DimensionTypeTimeField.php @@ -0,0 +1,32 @@ +time; + } + + /** + * @param null|int $time + * @return $this + */ + public function setTime(?int $time): self + { + $this->time = $time; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/DimensionType/Label1Field.php b/src/Fields/Level1234/DimensionType/Label1Field.php new file mode 100644 index 00000000..c1065ee3 --- /dev/null +++ b/src/Fields/Level1234/DimensionType/Label1Field.php @@ -0,0 +1,32 @@ +label1; + } + + /** + * @param null|string $label1 + * @return $this + */ + public function setLabel1(?string $label1): self + { + $this->label1 = $label1; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/DimensionType/Label2Field.php b/src/Fields/Level1234/DimensionType/Label2Field.php new file mode 100644 index 00000000..63ecd9a5 --- /dev/null +++ b/src/Fields/Level1234/DimensionType/Label2Field.php @@ -0,0 +1,32 @@ +label2; + } + + /** + * @param null|string $label2 + * @return $this + */ + public function setLabel2(?string $label2): self + { + $this->label2 = $label2; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/DimensionType/Label3Field.php b/src/Fields/Level1234/DimensionType/Label3Field.php new file mode 100644 index 00000000..6dec4ebc --- /dev/null +++ b/src/Fields/Level1234/DimensionType/Label3Field.php @@ -0,0 +1,32 @@ +label3; + } + + /** + * @param null|string $label3 + * @return $this + */ + public function setLabel3(?string $label3): self + { + $this->label3 = $label3; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/DimensionType/Label4Field.php b/src/Fields/Level1234/DimensionType/Label4Field.php new file mode 100644 index 00000000..ea220b50 --- /dev/null +++ b/src/Fields/Level1234/DimensionType/Label4Field.php @@ -0,0 +1,32 @@ +label4; + } + + /** + * @param null|string $label4 + * @return $this + */ + public function setLabel4(?string $label4): self + { + $this->label4 = $label4; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/DimensionType/Label5Field.php b/src/Fields/Level1234/DimensionType/Label5Field.php new file mode 100644 index 00000000..60b4b9ac --- /dev/null +++ b/src/Fields/Level1234/DimensionType/Label5Field.php @@ -0,0 +1,32 @@ +label5; + } + + /** + * @param null|string $label5 + * @return $this + */ + public function setLabel5(?string $label5): self + { + $this->label5 = $label5; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/DimensionType/Label6Field.php b/src/Fields/Level1234/DimensionType/Label6Field.php new file mode 100644 index 00000000..becfaf4c --- /dev/null +++ b/src/Fields/Level1234/DimensionType/Label6Field.php @@ -0,0 +1,32 @@ +label6; + } + + /** + * @param null|string $label6 + * @return $this + */ + public function setLabel6(?string $label6): self + { + $this->label6 = $label6; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/DimensionType/MaskField.php b/src/Fields/Level1234/DimensionType/MaskField.php new file mode 100644 index 00000000..e23f13c0 --- /dev/null +++ b/src/Fields/Level1234/DimensionType/MaskField.php @@ -0,0 +1,32 @@ +mask; + } + + /** + * @param null|string $mask + * @return $this + */ + public function setMask(?string $mask): self + { + $this->mask = $mask; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/AccountNumberField.php b/src/Fields/Level1234/Level2/AccountNumberField.php new file mode 100644 index 00000000..06580e25 --- /dev/null +++ b/src/Fields/Level1234/Level2/AccountNumberField.php @@ -0,0 +1,32 @@ +accountNumber; + } + + /** + * @param null|string $accountNumber + * @return $this + */ + public function setAccountNumber(?string $accountNumber): self + { + $this->accountNumber = $accountNumber; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/AddressField2Field.php b/src/Fields/Level1234/Level2/AddressField2Field.php new file mode 100644 index 00000000..f973ab74 --- /dev/null +++ b/src/Fields/Level1234/Level2/AddressField2Field.php @@ -0,0 +1,32 @@ +field2; + } + + /** + * @param null|string $field2 + * @return $this + */ + public function setField2(?string $field2): self + { + $this->field2 = $field2; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/AddressField3Field.php b/src/Fields/Level1234/Level2/AddressField3Field.php new file mode 100644 index 00000000..f6c2e887 --- /dev/null +++ b/src/Fields/Level1234/Level2/AddressField3Field.php @@ -0,0 +1,32 @@ +field3; + } + + /** + * @param null|string $field3 + * @return $this + */ + public function setField3(?string $field3): self + { + $this->field3 = $field3; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/AddressTypeField.php b/src/Fields/Level1234/Level2/AddressTypeField.php new file mode 100644 index 00000000..d850d4c0 --- /dev/null +++ b/src/Fields/Level1234/Level2/AddressTypeField.php @@ -0,0 +1,41 @@ +type; + } + + /** + * @param AddressType|null $type + * @return $this + */ + public function setType(?AddressType $type): self + { + $this->type = $type; + return $this; + } + + /** + * @param string|null $typeString + * @return $this + * @throws Exception + */ + public function setTypeFromString(?string $typeString) + { + return $this->setType(new AddressType((string)$typeString)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/AscriptionField.php b/src/Fields/Level1234/Level2/AscriptionField.php new file mode 100644 index 00000000..b232e281 --- /dev/null +++ b/src/Fields/Level1234/Level2/AscriptionField.php @@ -0,0 +1,32 @@ +ascription; + } + + /** + * @param null|string $ascription + * @return $this + */ + public function setAscription(?string $ascription): self + { + $this->ascription = $ascription; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/BankBlockedField.php b/src/Fields/Level1234/Level2/BankBlockedField.php new file mode 100644 index 00000000..fee8ace0 --- /dev/null +++ b/src/Fields/Level1234/Level2/BankBlockedField.php @@ -0,0 +1,47 @@ +blocked; + } + + public function getBlockedToString(): ?string + { + return ($this->getBlocked()) ? 'true' : 'false'; + } + + /** + * @param bool $blocked + * @return $this + */ + public function setBlocked(?bool $blocked): self + { + $this->blocked = $blocked; + return $this; + } + + /** + * @param string|null $blockedString + * @return $this + * @throws Exception + */ + public function setBlockedFromString(?string $blockedString) + { + return $this->setBlocked(filter_var($blockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/BankNameField.php b/src/Fields/Level1234/Level2/BankNameField.php new file mode 100644 index 00000000..822be4c1 --- /dev/null +++ b/src/Fields/Level1234/Level2/BankNameField.php @@ -0,0 +1,32 @@ +bankName; + } + + /** + * @param null|string $bankName + * @return $this + */ + public function setBankName(?string $bankName): self + { + $this->bankName = $bankName; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/BicCodeField.php b/src/Fields/Level1234/Level2/BicCodeField.php new file mode 100644 index 00000000..875ba9ed --- /dev/null +++ b/src/Fields/Level1234/Level2/BicCodeField.php @@ -0,0 +1,32 @@ +bicCode; + } + + /** + * @param null|string $bicCode + * @return $this + */ + public function setBicCode(?string $bicCode): self + { + $this->bicCode = $bicCode; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/CityField.php b/src/Fields/Level1234/Level2/CityField.php new file mode 100644 index 00000000..3f9cf912 --- /dev/null +++ b/src/Fields/Level1234/Level2/CityField.php @@ -0,0 +1,32 @@ +city; + } + + /** + * @param null|string $city + * @return $this + */ + public function setCity(?string $city): self + { + $this->city = $city; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/CountryField.php b/src/Fields/Level1234/Level2/CountryField.php new file mode 100644 index 00000000..96cab4ab --- /dev/null +++ b/src/Fields/Level1234/Level2/CountryField.php @@ -0,0 +1,54 @@ +country; + } + + public function getCountryToCode(): ?string + { + if ($this->getCountry() != null) { + return $this->country->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setCountry(?Country $country): self + { + $this->country = $country; + return $this; + } + + /** + * @param string|null $countryCode + * @return $this + * @throws Exception + */ + public function setCountryFromCode(?string $countryCode) + { + $country = new Country(); + $country->setCode($countryCode); + return $this->setCountry($country); + } +} diff --git a/src/Fields/Level1234/Level2/Customer/BaseCreditLimitField.php b/src/Fields/Level1234/Level2/Customer/BaseCreditLimitField.php new file mode 100644 index 00000000..161e86be --- /dev/null +++ b/src/Fields/Level1234/Level2/Customer/BaseCreditLimitField.php @@ -0,0 +1,62 @@ +baseCreditLimit; + } + + /** + * @return float|null + */ + public function getBaseCreditLimitToFloat(): ?float + { + if ($this->getBaseCreditLimit() != null) { + return Util::formatMoney($this->getBaseCreditLimit()); + } else { + return 0; + } + } + + /** + * @param Money|null $baseCreditLimit + * @return $this + */ + public function setBaseCreditLimit(?Money $baseCreditLimit) + { + $this->baseCreditLimit = $baseCreditLimit; + + return $this; + } + + /** + * @param float|null $baseCreditLimitFloat + * @return $this + * @throws Exception + */ + public function setBaseCreditLimitFromFloat(?float $baseCreditLimitFloat) + { + if ((float)$baseCreditLimitFloat) { + return $this->setBaseCreditLimit(Money::EUR(100 * $baseCreditLimitFloat)); + } else { + return $this->setBaseCreditLimit(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/BlockedField.php b/src/Fields/Level1234/Level2/Customer/BlockedField.php new file mode 100644 index 00000000..127a078d --- /dev/null +++ b/src/Fields/Level1234/Level2/Customer/BlockedField.php @@ -0,0 +1,47 @@ +blocked; + } + + public function getBlockedToString(): ?string + { + return ($this->getBlocked()) ? 'true' : 'false'; + } + + /** + * @param bool $blocked + * @return $this + */ + public function setBlocked(?bool $blocked): self + { + $this->blocked = $blocked; + return $this; + } + + /** + * @param string|null $blockedString + * @return $this + * @throws Exception + */ + public function setBlockedFromString(?string $blockedString) + { + return $this->setBlocked(filter_var($blockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/BlockedLockedField.php b/src/Fields/Level1234/Level2/Customer/BlockedLockedField.php new file mode 100644 index 00000000..b76f05bc --- /dev/null +++ b/src/Fields/Level1234/Level2/Customer/BlockedLockedField.php @@ -0,0 +1,47 @@ +blockedLocked; + } + + public function getBlockedLockedToString(): ?string + { + return ($this->getBlockedLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $blockedLocked + * @return $this + */ + public function setBlockedLocked(?bool $blockedLocked): self + { + $this->blockedLocked = $blockedLocked; + return $this; + } + + /** + * @param string|null $blockedLockedString + * @return $this + * @throws Exception + */ + public function setBlockedLockedFromString(?string $blockedLockedString) + { + return $this->setBlockedLocked(filter_var($blockedLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/BlockedModifiedField.php b/src/Fields/Level1234/Level2/Customer/BlockedModifiedField.php new file mode 100644 index 00000000..51459bad --- /dev/null +++ b/src/Fields/Level1234/Level2/Customer/BlockedModifiedField.php @@ -0,0 +1,66 @@ +blockedModified; + } + + /** + * @return string|null + */ + public function getBlockedModifiedToString(): ?string + { + if ($this->getBlockedModified() != null) { + return Util::formatDateTime($this->getBlockedModified()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $blockedModified + * @return $this + */ + public function setBlockedModified(?\DateTimeInterface $blockedModified) + { + $this->blockedModified = $blockedModified; + return $this; + } + + /** + * @param string|null $blockedModifiedString + * @return $this + * @throws Exception + */ + public function setBlockedModifiedFromString(?string $blockedModifiedString) + { + if ((bool)strtotime($blockedModifiedString)) { + return $this->setBlockedModified(Util::parseDateTime($blockedModifiedString)); + } else { + return $this->setBlockedModified(null); + } + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/CollectionSchemaField.php b/src/Fields/Level1234/Level2/Customer/CollectionSchemaField.php new file mode 100644 index 00000000..06807a14 --- /dev/null +++ b/src/Fields/Level1234/Level2/Customer/CollectionSchemaField.php @@ -0,0 +1,41 @@ +collectionSchema; + } + + /** + * @param CollectionSchema|null $collectionSchema + * @return $this + */ + public function setCollectionSchema(?CollectionSchema $collectionSchema): self + { + $this->collectionSchema = $collectionSchema; + return $this; + } + + /** + * @param string|null $collectionSchemaString + * @return $this + * @throws Exception + */ + public function setCollectionSchemaFromString(?string $collectionSchemaString) + { + return $this->setCollectionSchema(new CollectionSchema((string)$collectionSchemaString)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/CommentField.php b/src/Fields/Level1234/Level2/Customer/CommentField.php new file mode 100644 index 00000000..0132a1c2 --- /dev/null +++ b/src/Fields/Level1234/Level2/Customer/CommentField.php @@ -0,0 +1,32 @@ +comment; + } + + /** + * @param null|string $comment + * @return $this + */ + public function setComment(?string $comment) + { + $this->comment = $comment; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/CustomerFreeText1Field.php b/src/Fields/Level1234/Level2/Customer/CustomerFreeText1Field.php new file mode 100644 index 00000000..b13b0b31 --- /dev/null +++ b/src/Fields/Level1234/Level2/Customer/CustomerFreeText1Field.php @@ -0,0 +1,47 @@ +freeText1; + } + + public function getFreeText1ToString(): ?string + { + return ($this->getFreeText1()) ? 'true' : 'false'; + } + + /** + * @param bool $freeText1 + * @return $this + */ + public function setFreeText1(?bool $freeText1): self + { + $this->freeText1 = $freeText1; + return $this; + } + + /** + * @param string|null $freeText1String + * @return $this + * @throws Exception + */ + public function setFreeText1FromString(?string $freeText1String) + { + return $this->setFreeText1(filter_var($freeText1String, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/DiscountArticleField.php b/src/Fields/Level1234/Level2/Customer/DiscountArticleField.php new file mode 100644 index 00000000..d9408e6e --- /dev/null +++ b/src/Fields/Level1234/Level2/Customer/DiscountArticleField.php @@ -0,0 +1,54 @@ +discountArticle; + } + + public function getDiscountArticleToCode(): ?string + { + if ($this->getDiscountArticle() != null) { + return $this->discountArticle->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDiscountArticle(?Article $discountArticle): self + { + $this->discountArticle = $discountArticle; + return $this; + } + + /** + * @param string|null $discountArticleCode + * @return $this + * @throws Exception + */ + public function setDiscountArticleFromCode(?string $discountArticleCode) + { + $discountArticle = new Article(); + $discountArticle->setCode($discountArticleCode); + return $this->setDiscountArticle($discountArticle); + } +} diff --git a/src/Fields/Level1234/Level2/Customer/DiscountArticleIDField.php b/src/Fields/Level1234/Level2/Customer/DiscountArticleIDField.php new file mode 100644 index 00000000..b99406eb --- /dev/null +++ b/src/Fields/Level1234/Level2/Customer/DiscountArticleIDField.php @@ -0,0 +1,32 @@ +discountArticleID; + } + + /** + * @param null|string $discountArticleID + * @return $this + */ + public function setDiscountArticleID(?string $discountArticleID): self + { + $this->discountArticleID = $discountArticleID; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/EBillMailField.php b/src/Fields/Level1234/Level2/Customer/EBillMailField.php new file mode 100644 index 00000000..c4993380 --- /dev/null +++ b/src/Fields/Level1234/Level2/Customer/EBillMailField.php @@ -0,0 +1,32 @@ +eBillMail; + } + + /** + * @param null|string $eBillMail + * @return $this + */ + public function setEBillMail(?string $eBillMail): self + { + $this->eBillMail = $eBillMail; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/EBillingField.php b/src/Fields/Level1234/Level2/Customer/EBillingField.php new file mode 100644 index 00000000..2844141e --- /dev/null +++ b/src/Fields/Level1234/Level2/Customer/EBillingField.php @@ -0,0 +1,47 @@ +eBilling; + } + + public function getEBillingToString(): ?string + { + return ($this->getEBilling()) ? 'true' : 'false'; + } + + /** + * @param bool $eBilling + * @return $this + */ + public function setEBilling(?bool $eBilling): self + { + $this->eBilling = $eBilling; + return $this; + } + + /** + * @param string|null $eBillingString + * @return $this + * @throws Exception + */ + public function setEBillingFromString(?string $eBillingString) + { + return $this->setEBilling(filter_var($eBillingString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/FirstRunDateField.php b/src/Fields/Level1234/Level2/Customer/FirstRunDateField.php new file mode 100644 index 00000000..3ff0769e --- /dev/null +++ b/src/Fields/Level1234/Level2/Customer/FirstRunDateField.php @@ -0,0 +1,66 @@ +firstRunDate; + } + + /** + * @return string|null + */ + public function getFirstRunDateToString(): ?string + { + if ($this->getFirstRunDate() != null) { + return Util::formatDate($this->getFirstRunDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $firstRunDate + * @return $this + */ + public function setFirstRunDate(?\DateTimeInterface $firstRunDate) + { + $this->firstRunDate = $firstRunDate; + return $this; + } + + /** + * @param string|null $firstRunDateString + * @return $this + * @throws Exception + */ + public function setFirstRunDateFromString(?string $firstRunDateString) + { + if ((bool)strtotime($firstRunDateString)) { + return $this->setFirstRunDate(Util::parseDate($firstRunDateString)); + } else { + return $this->setFirstRunDate(null); + } + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/ReminderEmailField.php b/src/Fields/Level1234/Level2/Customer/ReminderEmailField.php new file mode 100644 index 00000000..fc9f315d --- /dev/null +++ b/src/Fields/Level1234/Level2/Customer/ReminderEmailField.php @@ -0,0 +1,32 @@ +reminderEmail; + } + + /** + * @param null|string $reminderEmail + * @return $this + */ + public function setReminderEmail(?string $reminderEmail): self + { + $this->reminderEmail = $reminderEmail; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/ResponsibleUserField.php b/src/Fields/Level1234/Level2/Customer/ResponsibleUserField.php new file mode 100644 index 00000000..23003a9c --- /dev/null +++ b/src/Fields/Level1234/Level2/Customer/ResponsibleUserField.php @@ -0,0 +1,55 @@ +responsibleUser; + } + + public function getResponsibleUserToCode(): ?string + { + if ($this->getResponsibleUser() != null) { + return $this->responsibleUser->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setResponsibleUser(?User $responsibleUser): self + { + $this->responsibleUser = $responsibleUser; + return $this; + } + + /** + * @param string|null $responsibleUserCode + * @return $this + * @throws Exception + */ + public function setResponsibleUserFromCode(?string $responsibleUserCode) + { + $responsibleUser = new User(); + $responsibleUser->setCode($responsibleUserCode); + return $this->setResponsibleUser($responsibleUser); + } +} + diff --git a/src/Fields/Level1234/Level2/Customer/SendReminderField.php b/src/Fields/Level1234/Level2/Customer/SendReminderField.php new file mode 100644 index 00000000..1d2efe33 --- /dev/null +++ b/src/Fields/Level1234/Level2/Customer/SendReminderField.php @@ -0,0 +1,41 @@ +sendReminder; + } + + /** + * @param SendReminder|null $sendReminder + * @return $this + */ + public function setSendReminder(?SendReminder $sendReminder): self + { + $this->sendReminder = $sendReminder; + return $this; + } + + /** + * @param string|null $sendReminderString + * @return $this + * @throws Exception + */ + public function setSendReminderFromString(?string $sendReminderString) + { + return $this->setSendReminder(new SendReminder((string)$sendReminderString)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/SignatureDateField.php b/src/Fields/Level1234/Level2/Customer/SignatureDateField.php new file mode 100644 index 00000000..4a965e25 --- /dev/null +++ b/src/Fields/Level1234/Level2/Customer/SignatureDateField.php @@ -0,0 +1,66 @@ +signatureDate; + } + + /** + * @return string|null + */ + public function getSignatureDateToString(): ?string + { + if ($this->getSignatureDate() != null) { + return Util::formatDate($this->getSignatureDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $signatureDate + * @return $this + */ + public function setSignatureDate(?\DateTimeInterface $signatureDate) + { + $this->signatureDate = $signatureDate; + return $this; + } + + /** + * @param string|null $signatureDateString + * @return $this + * @throws Exception + */ + public function setSignatureDateFromString(?string $signatureDateString) + { + if ((bool)strtotime($signatureDateString)) { + return $this->setSignatureDate(Util::parseDate($signatureDateString)); + } else { + return $this->setSignatureDate(null); + } + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/DefaultField.php b/src/Fields/Level1234/Level2/DefaultField.php new file mode 100644 index 00000000..e93b4057 --- /dev/null +++ b/src/Fields/Level1234/Level2/DefaultField.php @@ -0,0 +1,47 @@ +default; + } + + public function getDefaultToString(): ?string + { + return ($this->getDefault()) ? 'true' : 'false'; + } + + /** + * @param bool $default + * @return $this + */ + public function setDefault(?bool $default): self + { + $this->default = $default; + return $this; + } + + /** + * @param string|null $defaultString + * @return $this + * @throws Exception + */ + public function setDefaultFromString(?string $defaultString) + { + return $this->setDefault(filter_var($defaultString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Dimension1Field.php b/src/Fields/Level1234/Level2/Dimension1Field.php new file mode 100644 index 00000000..50549417 --- /dev/null +++ b/src/Fields/Level1234/Level2/Dimension1Field.php @@ -0,0 +1,54 @@ +dimension1; + } + + public function getDimension1ToCode(): ?string + { + if ($this->getDimension1() != null) { + return $this->dimension1->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDimension1(?GeneralLedger $dimension1): self + { + $this->dimension1 = $dimension1; + return $this; + } + + /** + * @param string|null $dimension1Code + * @return $this + * @throws Exception + */ + public function setDimension1FromCode(?string $dimension1Code) + { + $dimension1 = new GeneralLedger(); + $dimension1->setCode($dimension1Code); + return $this->setDimension1($dimension1); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Dimension1IDField.php b/src/Fields/Level1234/Level2/Dimension1IDField.php new file mode 100644 index 00000000..3c4a0d72 --- /dev/null +++ b/src/Fields/Level1234/Level2/Dimension1IDField.php @@ -0,0 +1,32 @@ +dimension1ID; + } + + /** + * @param null|string $dimension1ID + * @return $this + */ + public function setDimension1ID(?string $dimension1ID): self + { + $this->dimension1ID = $dimension1ID; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Dimension2Field.php b/src/Fields/Level1234/Level2/Dimension2Field.php new file mode 100644 index 00000000..29374a84 --- /dev/null +++ b/src/Fields/Level1234/Level2/Dimension2Field.php @@ -0,0 +1,54 @@ +dimension2; + } + + public function getDimension2ToCode(): ?string + { + if ($this->getDimension2() != null) { + return $this->dimension2->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDimension2(?CostCenter $dimension2): self + { + $this->dimension2 = $dimension2; + return $this; + } + + /** + * @param string|null $dimension2Code + * @return $this + * @throws Exception + */ + public function setDimension2FromCode(?string $dimension2Code) + { + $dimension2 = new CostCenter(); + $dimension2->setCode($dimension2Code); + return $this->setDimension2($dimension2); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Dimension2IDField.php b/src/Fields/Level1234/Level2/Dimension2IDField.php new file mode 100644 index 00000000..3ff0c220 --- /dev/null +++ b/src/Fields/Level1234/Level2/Dimension2IDField.php @@ -0,0 +1,32 @@ +dimension2ID; + } + + /** + * @param null|string $dimension2ID + * @return $this + */ + public function setDimension2ID(?string $dimension2ID): self + { + $this->dimension2ID = $dimension2ID; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Dimension3Field.php b/src/Fields/Level1234/Level2/Dimension3Field.php new file mode 100644 index 00000000..3e97dcf5 --- /dev/null +++ b/src/Fields/Level1234/Level2/Dimension3Field.php @@ -0,0 +1,54 @@ +dimension3; + } + + public function getDimension3ToCode(): ?string + { + if ($this->getDimension3() != null) { + return $this->dimension3->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDimension3($dimension3): self + { + $this->dimension3 = $dimension3; + return $this; + } + + /** + * @param string|null $dimension3Code + * @return $this + * @throws Exception + */ + public function setDimension3FromCode(?string $dimension3Code) + { + $dimension3 = new Dummy(); + $dimension3->setCode($dimension3Code); + return $this->setDimension3($dimension3); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Dimension3IDField.php b/src/Fields/Level1234/Level2/Dimension3IDField.php new file mode 100644 index 00000000..5ef84657 --- /dev/null +++ b/src/Fields/Level1234/Level2/Dimension3IDField.php @@ -0,0 +1,32 @@ +dimension3ID; + } + + /** + * @param null|string $dimension3ID + * @return $this + */ + public function setDimension3ID(?string $dimension3ID): self + { + $this->dimension3ID = $dimension3ID; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/DueDaysField.php b/src/Fields/Level1234/Level2/DueDaysField.php new file mode 100644 index 00000000..9d5abb77 --- /dev/null +++ b/src/Fields/Level1234/Level2/DueDaysField.php @@ -0,0 +1,32 @@ +dueDays; + } + + /** + * @param null|int $dueDays + * @return $this + */ + public function setDueDays(?int $dueDays): self + { + $this->dueDays = $dueDays; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/EmailField.php b/src/Fields/Level1234/Level2/EmailField.php new file mode 100644 index 00000000..4271afd1 --- /dev/null +++ b/src/Fields/Level1234/Level2/EmailField.php @@ -0,0 +1,32 @@ +email; + } + + /** + * @param null|string $email + * @return $this + */ + public function setEmail(?string $email): self + { + $this->email = $email; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Field1Field.php b/src/Fields/Level1234/Level2/Field1Field.php new file mode 100644 index 00000000..bb3ef90b --- /dev/null +++ b/src/Fields/Level1234/Level2/Field1Field.php @@ -0,0 +1,32 @@ +field1; + } + + /** + * @param null|string $field1 + * @return $this + */ + public function setField1(?string $field1): self + { + $this->field1 = $field1; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Field2Field.php b/src/Fields/Level1234/Level2/Field2Field.php new file mode 100644 index 00000000..c7a2a02d --- /dev/null +++ b/src/Fields/Level1234/Level2/Field2Field.php @@ -0,0 +1,32 @@ +field2; + } + + /** + * @param null|string $field2 + * @return $this + */ + public function setField2(?string $field2): self + { + $this->field2 = $field2; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Field3Field.php b/src/Fields/Level1234/Level2/Field3Field.php new file mode 100644 index 00000000..9ada5734 --- /dev/null +++ b/src/Fields/Level1234/Level2/Field3Field.php @@ -0,0 +1,32 @@ +field3; + } + + /** + * @param null|string $field3 + * @return $this + */ + public function setField3(?string $field3): self + { + $this->field3 = $field3; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Field4Field.php b/src/Fields/Level1234/Level2/Field4Field.php new file mode 100644 index 00000000..718a5c2e --- /dev/null +++ b/src/Fields/Level1234/Level2/Field4Field.php @@ -0,0 +1,32 @@ +field4; + } + + /** + * @param null|string $field4 + * @return $this + */ + public function setField4(?string $field4): self + { + $this->field4 = $field4; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Field5Field.php b/src/Fields/Level1234/Level2/Field5Field.php new file mode 100644 index 00000000..64fa8602 --- /dev/null +++ b/src/Fields/Level1234/Level2/Field5Field.php @@ -0,0 +1,32 @@ +field5; + } + + /** + * @param null|string $field5 + * @return $this + */ + public function setField5(?string $field5): self + { + $this->field5 = $field5; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Field6Field.php b/src/Fields/Level1234/Level2/Field6Field.php new file mode 100644 index 00000000..a5246952 --- /dev/null +++ b/src/Fields/Level1234/Level2/Field6Field.php @@ -0,0 +1,32 @@ +field6; + } + + /** + * @param null|string $field6 + * @return $this + */ + public function setField6(?string $field6): self + { + $this->field6 = $field6; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/IbanField.php b/src/Fields/Level1234/Level2/IbanField.php new file mode 100644 index 00000000..11d2c71a --- /dev/null +++ b/src/Fields/Level1234/Level2/IbanField.php @@ -0,0 +1,32 @@ +iban; + } + + /** + * @param null|string $iban + * @return $this + */ + public function setIban(?string $iban): self + { + $this->iban = $iban; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/MeansOfPaymentField.php b/src/Fields/Level1234/Level2/MeansOfPaymentField.php new file mode 100644 index 00000000..ee8b92df --- /dev/null +++ b/src/Fields/Level1234/Level2/MeansOfPaymentField.php @@ -0,0 +1,41 @@ +meansOfPayment; + } + + /** + * @param MeansOfPayment|null $meansOfPayment + * @return $this + */ + public function setMeansOfPayment(?MeansOfPayment $meansOfPayment): self + { + $this->meansOfPayment = $meansOfPayment; + return $this; + } + + /** + * @param string|null $meansOfPaymentString + * @return $this + * @throws Exception + */ + public function setMeansOfPaymentFromString(?string $meansOfPaymentString) + { + return $this->setMeansOfPayment(new MeansOfPayment((string)$meansOfPaymentString)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/NatBicCodeField.php b/src/Fields/Level1234/Level2/NatBicCodeField.php new file mode 100644 index 00000000..7b90bd8e --- /dev/null +++ b/src/Fields/Level1234/Level2/NatBicCodeField.php @@ -0,0 +1,32 @@ +natBicCode; + } + + /** + * @param null|string $natBicCode + * @return $this + */ + public function setNatBicCode(?string $natBicCode): self + { + $this->natBicCode = $natBicCode; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/PayAvailableField.php b/src/Fields/Level1234/Level2/PayAvailableField.php new file mode 100644 index 00000000..904f2099 --- /dev/null +++ b/src/Fields/Level1234/Level2/PayAvailableField.php @@ -0,0 +1,47 @@ +payAvailable; + } + + public function getPayAvailableToString(): ?string + { + return ($this->getPayAvailable()) ? 'true' : 'false'; + } + + /** + * @param bool $payAvailable + * @return $this + */ + public function setPayAvailable(?bool $payAvailable): self + { + $this->payAvailable = $payAvailable; + return $this; + } + + /** + * @param string|null $payAvailableString + * @return $this + * @throws Exception + */ + public function setPayAvailableFromString(?string $payAvailableString) + { + return $this->setPayAvailable(filter_var($payAvailableString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/PayCodeField.php b/src/Fields/Level1234/Level2/PayCodeField.php new file mode 100644 index 00000000..c50dd6f3 --- /dev/null +++ b/src/Fields/Level1234/Level2/PayCodeField.php @@ -0,0 +1,54 @@ +payCode; + } + + public function getPayCodeToCode(): ?string + { + if ($this->getPayCode() != null) { + return $this->payCode->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setPayCode(?PayCode $payCode): self + { + $this->payCode = $payCode; + return $this; + } + + /** + * @param string|null $payCodeCode + * @return $this + * @throws Exception + */ + public function setPayCodeFromCode(?string $payCodeCode) + { + $payCode = new PayCode(); + $payCode->setCode($payCodeCode); + return $this->setPayCode($payCode); + } +} diff --git a/src/Fields/Level1234/Level2/PayCodeIDField.php b/src/Fields/Level1234/Level2/PayCodeIDField.php new file mode 100644 index 00000000..c6a80501 --- /dev/null +++ b/src/Fields/Level1234/Level2/PayCodeIDField.php @@ -0,0 +1,32 @@ +payCodeID; + } + + /** + * @param null|string $payCodeID + * @return $this + */ + public function setPayCodeID(?string $payCodeID): self + { + $this->payCodeID = $payCodeID; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/PaymentConditionDiscountDaysField.php b/src/Fields/Level1234/Level2/PaymentConditionDiscountDaysField.php new file mode 100644 index 00000000..ce317c34 --- /dev/null +++ b/src/Fields/Level1234/Level2/PaymentConditionDiscountDaysField.php @@ -0,0 +1,32 @@ +paymentConditionDiscountDays; + } + + /** + * @param null|int $paymentConditionDiscountDays + * @return $this + */ + public function setPaymentConditionDiscountDays(?int $paymentConditionDiscountDays): self + { + $this->paymentConditionDiscountDays = $paymentConditionDiscountDays; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/PaymentConditionDiscountPercentageField.php b/src/Fields/Level1234/Level2/PaymentConditionDiscountPercentageField.php new file mode 100644 index 00000000..3939e2f5 --- /dev/null +++ b/src/Fields/Level1234/Level2/PaymentConditionDiscountPercentageField.php @@ -0,0 +1,32 @@ +paymentConditionDiscountPercentage; + } + + /** + * @param null|float $paymentConditionDiscountPercentage + * @return $this + */ + public function setPaymentConditionDiscountPercentage(?float $paymentConditionDiscountPercentage): self + { + $this->paymentConditionDiscountPercentage = $paymentConditionDiscountPercentage; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/PostcodeField.php b/src/Fields/Level1234/Level2/PostcodeField.php new file mode 100644 index 00000000..8cdf7da1 --- /dev/null +++ b/src/Fields/Level1234/Level2/PostcodeField.php @@ -0,0 +1,32 @@ +postcode; + } + + /** + * @param null|string $postcode + * @return $this + */ + public function setPostcode(?string $postcode): self + { + $this->postcode = $postcode; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/RatioField.php b/src/Fields/Level1234/Level2/RatioField.php new file mode 100644 index 00000000..087c7141 --- /dev/null +++ b/src/Fields/Level1234/Level2/RatioField.php @@ -0,0 +1,32 @@ +ratio; + } + + /** + * @param null|float $ratio + * @return $this + */ + public function setRatio(?float $ratio): self + { + $this->ratio = $ratio; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/RemittanceAdviceSendMailField.php b/src/Fields/Level1234/Level2/RemittanceAdviceSendMailField.php new file mode 100644 index 00000000..f1b46f79 --- /dev/null +++ b/src/Fields/Level1234/Level2/RemittanceAdviceSendMailField.php @@ -0,0 +1,32 @@ +remittanceAdviceSendMail; + } + + /** + * @param null|string $remittanceAdviceSendMail + * @return $this + */ + public function setRemittanceAdviceSendMail(?string $remittanceAdviceSendMail): self + { + $this->remittanceAdviceSendMail = $remittanceAdviceSendMail; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/RemittanceAdviceSendTypeField.php b/src/Fields/Level1234/Level2/RemittanceAdviceSendTypeField.php new file mode 100644 index 00000000..b3367ea7 --- /dev/null +++ b/src/Fields/Level1234/Level2/RemittanceAdviceSendTypeField.php @@ -0,0 +1,41 @@ +remittanceAdviceSendType; + } + + /** + * @param RemittanceAdviceSendType|null $remittanceAdviceSendType + * @return $this + */ + public function setRemittanceAdviceSendType(?RemittanceAdviceSendType $remittanceAdviceSendType): self + { + $this->remittanceAdviceSendType = $remittanceAdviceSendType; + return $this; + } + + /** + * @param string|null $remittanceAdviceSendTypeString + * @return $this + * @throws Exception + */ + public function setRemittanceAdviceSendTypeFromString(?string $remittanceAdviceSendTypeString) + { + return $this->setRemittanceAdviceSendType(new RemittanceAdviceSendType((string)$remittanceAdviceSendTypeString)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/StateField.php b/src/Fields/Level1234/Level2/StateField.php new file mode 100644 index 00000000..870f04ef --- /dev/null +++ b/src/Fields/Level1234/Level2/StateField.php @@ -0,0 +1,32 @@ +state; + } + + /** + * @param null|string $state + * @return $this + */ + public function setState(?string $state): self + { + $this->state = $state; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Supplier/BlockedAccountPaymentConditionsIncludeVatField.php b/src/Fields/Level1234/Level2/Supplier/BlockedAccountPaymentConditionsIncludeVatField.php new file mode 100644 index 00000000..6cb07828 --- /dev/null +++ b/src/Fields/Level1234/Level2/Supplier/BlockedAccountPaymentConditionsIncludeVatField.php @@ -0,0 +1,41 @@ +blockedAccountPaymentConditionsIncludeVat; + } + + /** + * @param BlockedAccountPaymentConditionsIncludeVat|null $blockedAccountPaymentConditionsIncludeVat + * @return $this + */ + public function setBlockedAccountPaymentConditionsIncludeVat(?BlockedAccountPaymentConditionsIncludeVat $blockedAccountPaymentConditionsIncludeVat): self + { + $this->blockedAccountPaymentConditionsIncludeVat = $blockedAccountPaymentConditionsIncludeVat; + return $this; + } + + /** + * @param string|null $blockedAccountPaymentConditionsIncludeVatString + * @return $this + * @throws Exception + */ + public function setBlockedAccountPaymentConditionsIncludeVatFromString(?string $blockedAccountPaymentConditionsIncludeVatString) + { + return $this->setBlockedAccountPaymentConditionsIncludeVat(new BlockedAccountPaymentConditionsIncludeVat((string)$blockedAccountPaymentConditionsIncludeVatString)); + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Supplier/BlockedAccountPaymentConditionsPercentageField.php b/src/Fields/Level1234/Level2/Supplier/BlockedAccountPaymentConditionsPercentageField.php new file mode 100644 index 00000000..6d50a36a --- /dev/null +++ b/src/Fields/Level1234/Level2/Supplier/BlockedAccountPaymentConditionsPercentageField.php @@ -0,0 +1,32 @@ +blockedAccountPaymentConditionsPercentage; + } + + /** + * @param null|float $blockedAccountPaymentConditionsPercentage + * @return $this + */ + public function setBlockedAccountPaymentConditionsPercentage(?float $blockedAccountPaymentConditionsPercentage): self + { + $this->blockedAccountPaymentConditionsPercentage = $blockedAccountPaymentConditionsPercentage; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Supplier/RelationsReferenceField.php b/src/Fields/Level1234/Level2/Supplier/RelationsReferenceField.php new file mode 100644 index 00000000..10d475a5 --- /dev/null +++ b/src/Fields/Level1234/Level2/Supplier/RelationsReferenceField.php @@ -0,0 +1,32 @@ +relationsReference; + } + + /** + * @param null|string $relationsReference + * @return $this + */ + public function setRelationsReference(?string $relationsReference): self + { + $this->relationsReference = $relationsReference; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/TelefaxField.php b/src/Fields/Level1234/Level2/TelefaxField.php new file mode 100644 index 00000000..1776b518 --- /dev/null +++ b/src/Fields/Level1234/Level2/TelefaxField.php @@ -0,0 +1,32 @@ +telefax; + } + + /** + * @param null|string $telefax + * @return $this + */ + public function setTelefax(?string $telefax): self + { + $this->telefax = $telefax; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/TelephoneField.php b/src/Fields/Level1234/Level2/TelephoneField.php new file mode 100644 index 00000000..8c995787 --- /dev/null +++ b/src/Fields/Level1234/Level2/TelephoneField.php @@ -0,0 +1,32 @@ +telephone; + } + + /** + * @param null|string $telephone + * @return $this + */ + public function setTelephone(?string $telephone): self + { + $this->telephone = $telephone; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/WebsiteField.php b/src/Fields/Level1234/Level2/WebsiteField.php new file mode 100644 index 00000000..f14fe873 --- /dev/null +++ b/src/Fields/Level1234/Level2/WebsiteField.php @@ -0,0 +1,32 @@ +website; + } + + /** + * @param null|string $website + * @return $this + */ + public function setWebsite(?string $website): self + { + $this->website = $website; + return $this; + } +} \ No newline at end of file From 846c82e70e8ff0de83789b57486e9835b358daed Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:51:26 +0200 Subject: [PATCH 057/388] Update readme.md --- readme.md | 174 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 159 insertions(+), 15 deletions(-) diff --git a/readme.md b/readme.md index 9c6035fa..9258bb1a 100644 --- a/readme.md +++ b/readme.md @@ -16,30 +16,159 @@ composer require 'php-twinfield/twinfield:^2.0' ## Usage ### Authentication -You need to set up a `\PhpTwinfield\Secure\AuthenticatedConnection` class with your credentials. When using basic -username and password authentication, the `\PhpTwinfield\Secure\WebservicesAuthentication` class should be used, as follows: +You need to set up a `\PhpTwinfield\Secure\AuthenticatedConnection` class with your credentials. + +#### Session Login +**:warning: Note that Twinfield has stated that session login is deprecated and will be removed. End of life date will be announced later. See https://c3.twinfield.com/webservices/documentation/#/ApiReference/Authentication/WebServices** + +When using basic username and password authentication, the `\PhpTwinfield\Secure\WebservicesAuthentication` class should be used, as follows: ```php $connection = new Secure\WebservicesAuthentication("username", "password", "organization"); ``` +#### OAuth2 In order to use OAuth2 to authenticate with Twinfield, one should use the `\PhpTwinfield\Secure\Provider\OAuthProvider` to retrieve an `\League\OAuth2\Client\Token\AccessToken` object, and extract the refresh token from this object. Furthermore, it is required to set up a default `\PhpTwinfield\Office`, that will be used during requests to Twinfield. **Please note:** when a different office is specified when sending a request through one of the `ApiConnectors`, this Office will override the default. -Using this information, we can create an instance of the `\PhpTwinfield\Secure\OpenIdConnectAuthentication` class, as follows: +##### Request a client ID/Secret from Twinfield +Go to the [Twinfield web site](https://www.twinfield.nl/openid-connect-request/) in order to register your OpenID Connect / OAuth 2.0 client and get your Client ID and Secret. Fill in your personal information en pick the following: +* Flow: Authorization Code +* Consent: Your choice +* Redirect URL: The full URI where the following code is available on your domain/server +* Add more redirect URL's?: Your choice +* Post logout URL: Your choice, can be left blank +* Add more post logout URL's?: Your choice + +##### Grant Authorisation and retrieve intitial Access Token +On loading a page containing the following code the user will be redirected to the Twinfield Login page. +After succesfull login and optionally consent (see above) the user will be redirected back to the page at which point the Access Token and Refresh Token can be retrieved. + +For more information, please refer to: https://github.com/thephpleague/oauth2-client#usage ```php +$provider = new \PhpTwinfield\Secure\Provider\OAuthProvider([ + 'clientId' => 'someClientId', // The Client ID assigned to you by Twinfield + 'clientSecret' => 'someClientSecret', // The Client Secret assigned to you by Twinfield + 'redirectUri' => 'https://example.org/', // The full URL your filled in at Redirect URL when you requested your client ID +]); + +// If we don't have an authorization code then get one +if (!isset($_GET['code'])) { + //Optionally limit your scope if you don't require all. + $options = [ + 'scope' => ['twf.user','twf.organisation','twf.organisationUser','offline_access','openid'] + ]; + + $authorizationUrl = $provider->getAuthorizationUrl($options); + + // Get the state generated for you and store it to the session. + $_SESSION['oauth2state'] = $provider->getState(); + + // Redirect the user to the authorization URL. + header('Location: ' . $authorizationUrl); + exit; + +// Check given state against previously stored one to mitigate CSRF attack +} elseif (empty($_GET['state']) || (isset($_SESSION['oauth2state']) && $_GET['state'] !== $_SESSION['oauth2state'])) { + if (isset($_SESSION['oauth2state'])) { + unset($_SESSION['oauth2state']); + } + + exit('Invalid state'); +} else { + try { + // Try to get an access token using the authorization code grant. + $accessToken = $provider->getAccessToken('authorization_code', [ + 'code' => $_GET['code'] + ]); + + //Twinfield's Refresh Token is valid for 550 days. + //Remember to put in place functionality to request the user to renew their authorization. + //This can be done by requesting the user to reload this page and logging into Twinfield + //before the refresh token is invalidated after 550 days. + $refresh_expiry = strtotime(date('Ymd') . " +550 days"); + + //Save Refresh Token and Refresh Token Expiry Time to storage + $refreshTokenStorage = array(); + $refreshTokenStorage['refresh_token'] = $accessToken->getRefreshToken(); + $refreshTokenStorage['refresh_expiry'] = $refresh_expiry; + + SaveRefreshTokenToStore($refreshTokenStorage); + + //OPTIONAL: Save Access Token, Access Token Expiry Time and Cluster to storage + $validationUrl = "https://login.twinfield.com/auth/authentication/connect/accesstokenvalidation?token="; + $validationResult = @file_get_contents($validationUrl . urlencode($accessToken->getToken())); + + if ($validationResult !== false) { + $resultDecoded = \json_decode($validationResult, true); + $accessTokenStorage = array(); + $accessTokenStorage['access_token'] = $accessToken->getToken(); + $accessTokenStorage['access_expiry'] = $accessToken->getExpires(); + $accessTokenStorage['access_cluster'] = $resultDecoded["twf.clusterUrl"]; + SaveAccessTokenToStore($accessTokenStorage); + } + } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) { + // Failed to get the access token or user details. + exit($e->getMessage()); + } +} +``` + +##### Optionally: Store a valid access token and cluster through a sceduled task/cron job running in the background +Running the following code every 60 minutes (or a bit less as Access Tokens are valid for exactly 60 minutes) will reduce connection time when working with the Api (by about 2 seconds). It will also reduce connection load on Twinfield when making more than 20-30 connections/day. + +```php +$refreshTokenStorage = retrieveRefreshTokenFromStore(); + $provider = new OAuthProvider([ 'clientId' => 'someClientId', 'clientSecret' => 'someClientSecret', 'redirectUri' => 'https://example.org/' ]); -$accessToken = $provider->getAccessToken("authorization_code", ["code" => ...]); -$refreshToken = $accessToken->getRefreshToken(); + +$accessToken = $provider->getAccessToken('refresh_token', [ + 'refresh_token' => $refreshTokenStorage['refresh_token'] +]); + +$validationUrl = "https://login.twinfield.com/auth/authentication/connect/accesstokenvalidation?token="; +$validationResult = @file_get_contents($validationUrl . urlencode($accessToken->getToken())); + +if ($validationResult !== false) { + $resultDecoded = \json_decode($validationResult, true); + + $tokenStorage = array(); + $tokenStorage['access_token'] = $accessToken->getToken(); + $tokenStorage['access_expiry'] = $accessToken->getExpires(); + $tokenStorage['access_cluster'] = $resultDecoded["twf.clusterUrl"]; + + SaveAccessTokenToStore($tokenStorage); +} +``` + +##### Connection +Using the stored Refresh Token and optionally Access Token/Cluster, we can create an instance of the `\PhpTwinfield\Secure\OpenIdConnectAuthentication` class, as follows: + +```php +$provider = new OAuthProvider([ + 'clientId' => 'someClientId', + 'clientSecret' => 'someClientSecret', + 'redirectUri' => 'https://example.org/' +]); + +//Retrieve Refresh Token and Refresh Token Expiry Time from storage +$refreshTokenStorage = retrieveRefreshTokenFromStore(); + +//OPTIONAL: Retrieve Access Token, Access Token Expiry Time and Cluster from storage +$accessTokenStorage = retrieveAccessTokenFromStore(); + $office = \PhpTwinfield\Office::fromCode("someOfficeCode"); -$connection = new \PhpTwinfield\Secure\OpenIdConnectAuthentication($provider, $refreshToken, $office); +if ($accessTokenStorage['access_expiry'] > time()) { + $connection = new \PhpTwinfield\Secure\OpenIdConnectAuthentication($provider, $refreshTokenStorage['refresh_token'], $office, $accessTokenStorage['access_token'], $accessTokenStorage['access_cluster']); +} else { + $connection = new \PhpTwinfield\Secure\OpenIdConnectAuthentication($provider, $refreshTokenStorage['refresh_token'], $office) +} ``` -For more information about retrieving the initial `AccessToken`, please refer to: https://github.com/thephpleague/oauth2-client#usage ### Getting data from the API In order to communicate with the Twinfield API, you need to create an `ApiConnector` instance for the corresponding @@ -187,18 +316,33 @@ support for another resource. | Component | get() | listAll() | send() | delete() | Mapper | | --------------------------------------------------------------------------------------------------------------- | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | -| [Articles](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Articles) | :white_check_mark: | | :white_check_mark: | | :white_check_mark: | -| [BankTransaction](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankTransactions)| | | :white_check_mark: | :white_check_mark: | | +| [Activities](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Activities) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| [Articles](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Articles) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| [Asset Methods](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/AssetMethods) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| [Browse Data](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Request/BrowseData) | :white_check_mark: | | | | :white_check_mark: | +| Cash and Bank books | | :white_check_mark: | | | :white_check_mark: | +| [Cost Center](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/CostCenters) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| Countries | | :white_check_mark: | | | :white_check_mark: | +| [Currencies](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Currencies) | | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | [Customer](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| [Dimension Groups](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionGroups) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| [Dimension Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionTypes) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | [Electronic Bank Statements](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankStatements)| | | :white_check_mark: | | | -| [Sales Invoices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | :white_check_mark: | | :white_check_mark: | | :white_check_mark: | +| [Fixed Assets](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/FixedAssets) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| [General Ledger Accounts](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/BalanceSheets) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | [Matching](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Miscellaneous/Matching) | | | :white_check_mark: | | :white_check_mark: | | -| [Offices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Offices) | | :white_check_mark: | | | :white_check_mark: | +| [Offices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Offices) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | +| Paycodes | | :white_check_mark: | | | :white_check_mark: | +| [Projects](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Projects) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| [Rates](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Rates) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| [Sales Invoices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | :white_check_mark: | | :white_check_mark: | | :white_check_mark: | +| [Sales Invoice Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | | :white_check_mark: | | | :white_check_mark: | | [Suppliers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| Transactions:
[Purchase](https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions), [Sale](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions), [Journal](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/JournalTransactions), [Cash](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/CashTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| [Users](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Users) | | :white_check_mark: | | | | -| [Vat types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/VAT) | | :white_check_mark: | | | | -| [Browse Data](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Request/BrowseData) | :white_check_mark: | | | | :white_check_mark: | +| Transactions:
[Purchase](https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions), [Sale](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions), [Journal](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/JournalTransactions), [Cash](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/CashTransactions), [Bank](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| [Users](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Users) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | +| User Roles | | :white_check_mark: | | | :white_check_mark: | +| [VAT](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/VAT) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| VAT Groups | | :white_check_mark: | | | :white_check_mark: | ## Links From 1f57e4fd1f6e4a313525c442374be85f3a1bf4d1 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:53:04 +0200 Subject: [PATCH 058/388] Update readme.md --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 9258bb1a..5cd032c2 100644 --- a/readme.md +++ b/readme.md @@ -321,7 +321,7 @@ support for another resource. | [Asset Methods](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/AssetMethods) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | [Browse Data](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Request/BrowseData) | :white_check_mark: | | | | :white_check_mark: | | Cash and Bank books | | :white_check_mark: | | | :white_check_mark: | -| [Cost Center](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/CostCenters) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| [Cost Centers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/CostCenters) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | Countries | | :white_check_mark: | | | :white_check_mark: | | [Currencies](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Currencies) | | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | [Customer](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | @@ -335,7 +335,7 @@ support for another resource. | Paycodes | | :white_check_mark: | | | :white_check_mark: | | [Projects](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Projects) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | [Rates](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Rates) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| [Sales Invoices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | :white_check_mark: | | :white_check_mark: | | :white_check_mark: | +| [Sales Invoices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | [Sales Invoice Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | | :white_check_mark: | | | :white_check_mark: | | [Suppliers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | Transactions:
[Purchase](https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions), [Sale](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions), [Journal](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/JournalTransactions), [Cash](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/CashTransactions), [Bank](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | From bc80b80c2e0d7ab07f2223871a666a85411d7159 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 17:53:49 +0200 Subject: [PATCH 059/388] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 5cd032c2..176603e3 100644 --- a/readme.md +++ b/readme.md @@ -324,7 +324,7 @@ support for another resource. | [Cost Centers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/CostCenters) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | Countries | | :white_check_mark: | | | :white_check_mark: | | [Currencies](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Currencies) | | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| [Customer](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| [Customers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | [Dimension Groups](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionGroups) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | [Dimension Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionTypes) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | [Electronic Bank Statements](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankStatements)| | | :white_check_mark: | | | From 4a75d98e0f278173ae7406432b275a7d0090cbde Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 18:01:09 +0200 Subject: [PATCH 060/388] Add files via upload --- src/ApiConnectors/CashBankBookApiConnector.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ApiConnectors/CashBankBookApiConnector.php b/src/ApiConnectors/CashBankBookApiConnector.php index 19104101..f2165485 100644 --- a/src/ApiConnectors/CashBankBookApiConnector.php +++ b/src/ApiConnectors/CashBankBookApiConnector.php @@ -14,7 +14,7 @@ * * @author Yannick Aerssens */ -class CashBankBooksApiConnector extends BaseApiConnector +class CashBankBookApiConnector extends BaseApiConnector { /** * List all cash and bank books. @@ -42,11 +42,11 @@ public function listAll( $response = $this->getFinderService()->searchFinder(FinderService::TYPE_CASHBOOKS_AND_BANKS, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); - $vatGroupListAllTags = array( + $cashBankBookListAllTags = array( 0 => 'setCode', 1 => 'setName', ); - return $this->mapListAll("CashBankBook", $response->data, $vatGroupListAllTags); + return $this->mapListAll("CashBankBook", $response->data, $cashBankBookListAllTags); } } \ No newline at end of file From 7697544b043e4a536cee81430a52d49f11f9f396 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 18:01:23 +0200 Subject: [PATCH 061/388] Add files via upload --- src/Mappers/CashBankBookMapper.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Mappers/CashBankBookMapper.php b/src/Mappers/CashBankBookMapper.php index 8e66b28d..1e7578ad 100644 --- a/src/Mappers/CashBankBookMapper.php +++ b/src/Mappers/CashBankBookMapper.php @@ -26,20 +26,20 @@ class CashBankBookMapper extends BaseMapper public static function map(Response $response) { // Generate new CashBankBook object - $vatGroup = new CashBankBook(); + $cashBankBook = new CashBankBook(); // Gets the raw DOMDocument response. $responseDOM = $response->getResponseDocument(); - // Get the root/vat group element - $vatGroupElement = $responseDOM->documentElement; + // Get the root/cash or bank book element + $cashBankBookElement = $responseDOM->documentElement; - // Set the vat group elements from the vat group element - $vatGroup->setCode(self::getField($vatGroup, $vatGroupElement, 'code')) - ->setName(self::getField($vatGroup, $vatGroupElement, 'name')) - ->setShortName(self::getField($vatGroup, $vatGroupElement, 'shortname')); + // Set the cash or bank book elements from the cash or bank book element + $cashBankBook->setCode(self::getField($cashBankBook, $cashBankBookElement, 'code')) + ->setName(self::getField($cashBankBook, $cashBankBookElement, 'name')) + ->setShortName(self::getField($cashBankBook, $cashBankBookElement, 'shortname')); // Return the complete object - return $vatGroup; + return $cashBankBook; } } \ No newline at end of file From ce8ac22792c3e4fdc4f77445354b528ea627a55a Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 19:18:10 +0200 Subject: [PATCH 062/388] Update InvoiceIntegrationTest.php --- .../InvoiceIntegrationTest.php | 94 +++++++++---------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 225a7747..a90b20d5 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -48,15 +48,15 @@ public function testGetConceptInvoiceWorks() $this->assertInstanceOf(Invoice::class, $invoice); $this->assertEquals(Office::fromCode("11024"), $invoice->getOffice()); - $this->assertSame('FACTUUR', $invoice->getInvoiceType()); + $this->assertSame('FACTUUR', $invoice->getInvoiceTypeToCode()); $this->assertSame('5', $invoice->getInvoiceNumber()); - $this->assertSame('20120831', $invoice->getInvoiceDate()); - $this->assertSame('BNK', $invoice->getBank()); + $this->assertSame('20120831', $invoice->getInvoiceDateToString()); + $this->assertSame('BNK', $invoice->getBankToCode()); $this->assertSame('1', $invoice->getInvoiceAddressNumber()); $this->assertSame('1', $invoice->getDeliverAddressNumber()); - $this->assertSame('1000', $invoice->getCustomer()->getCode()); + $this->assertSame('1000', $invoice->getCustomerToCode()); $this->assertSame('2012/8', $invoice->getPeriod()); - $this->assertSame('EUR', $invoice->getCurrency()); + $this->assertSame('EUR', $invoice->getCurrencyToCode()); $this->assertSame('concept', $invoice->getStatus()); $this->assertSame('cash', $invoice->getPaymentMethod()); @@ -68,22 +68,22 @@ public function testGetConceptInvoiceWorks() $invoiceLine = $invoiceLines['1']; $this->assertSame('1', $invoiceLine->getID()); - $this->assertSame('0', $invoiceLine->getArticle()); - $this->assertSame('118', $invoiceLine->getSubArticle()); + $this->assertSame('0', $invoiceLine->getArticleToCode()); + $this->assertSame('118', $invoiceLine->getSubArticleToSubCode()); $this->assertSame('1', $invoiceLine->getQuantity()); $this->assertSame('1', $invoiceLine->getUnits()); - $this->assertSame('true', $invoiceLine->getAllowDiscountOrPremium()); + $this->assertSame('true', $invoiceLine->getAllowDiscountOrPremiumToString()); $this->assertSame('CoalesceFunctioningOnImpatienceTShirt', $invoiceLine->getDescription()); - $this->assertSame('15.00', $invoiceLine->getValueExcl()); - $this->assertSame('0.00', $invoiceLine->getVatValue()); - $this->assertSame('15.00', $invoiceLine->getValueInc()); - $this->assertSame('15.00', $invoiceLine->getUnitsPriceExcl()); - $this->assertSame('8020', $invoiceLine->getDim1()); + $this->assertSame('15.00', $invoiceLine->getValueExclToFloat()); + $this->assertSame('0.00', $invoiceLine->getVatValueToFloat()); + $this->assertSame('15.00', $invoiceLine->getValueIncToFloat()); + $this->assertSame('15.00', $invoiceLine->getUnitsPriceExclToFloat()); + $this->assertSame('8020', $invoiceLine->getDim1ToCode()); // TODO - Vat lines - $this->assertSame('15.00', $invoice->getTotals()->getValueInc()); - $this->assertSame('15.00', $invoice->getTotals()->getValueExcl()); + $this->assertSame('15.00', $invoice->getTotals()->getValueIncToFloat()); + $this->assertSame('15.00', $invoice->getTotals()->getValueExclToFloat()); $this->assertNull($invoice->getFinancialNumber()); $this->assertNull($invoice->getFinancialCode()); @@ -103,15 +103,15 @@ public function testGetFinalInvoiceWorks() $this->assertInstanceOf(Invoice::class, $invoice); $this->assertEquals(Office::fromCode("11024"), $invoice->getOffice()); - $this->assertSame('FACTUUR', $invoice->getInvoiceType()); + $this->assertSame('FACTUUR', $invoice->getInvoiceTypeToCode()); $this->assertSame('5', $invoice->getInvoiceNumber()); - $this->assertSame('20120831', $invoice->getInvoiceDate()); - $this->assertSame('BNK', $invoice->getBank()); + $this->assertSame('20120831', $invoice->getInvoiceDateToString()); + $this->assertSame('BNK', $invoice->getBankToCode()); $this->assertSame('1', $invoice->getInvoiceAddressNumber()); $this->assertSame('1', $invoice->getDeliverAddressNumber()); - $this->assertSame('1000', $invoice->getCustomer()->getCode()); + $this->assertSame('1000', $invoice->getCustomerToCode()); $this->assertSame('2012/8', $invoice->getPeriod()); - $this->assertSame('EUR', $invoice->getCurrency()); + $this->assertSame('EUR', $invoice->getCurrencyToCode()); $this->assertSame('final', $invoice->getStatus()); $this->assertSame('cash', $invoice->getPaymentMethod()); @@ -123,22 +123,22 @@ public function testGetFinalInvoiceWorks() $invoiceLine = $invoiceLines['1']; $this->assertSame('1', $invoiceLine->getID()); - $this->assertSame('0', $invoiceLine->getArticle()); - $this->assertSame('118', $invoiceLine->getSubArticle()); + $this->assertSame('0', $invoiceLine->getArticleToCode()); + $this->assertSame('118', $invoiceLine->getSubArticleToSubCode()); $this->assertSame('1', $invoiceLine->getQuantity()); $this->assertSame('1', $invoiceLine->getUnits()); - $this->assertSame('true', $invoiceLine->getAllowDiscountOrPremium()); + $this->assertSame('true', $invoiceLine->getAllowDiscountOrPremiumToString()); $this->assertSame('CoalesceFunctioningOnImpatienceTShirt', $invoiceLine->getDescription()); - $this->assertSame('15.00', $invoiceLine->getValueExcl()); - $this->assertSame('0.00', $invoiceLine->getVatValue()); - $this->assertSame('15.00', $invoiceLine->getValueInc()); - $this->assertSame('15.00', $invoiceLine->getUnitsPriceExcl()); - $this->assertSame('8020', $invoiceLine->getDim1()); + $this->assertSame('15.00', $invoiceLine->getValueExclToFloat()); + $this->assertSame('0.00', $invoiceLine->getVatValueToFloat()); + $this->assertSame('15.00', $invoiceLine->getValueIncToFloat()); + $this->assertSame('15.00', $invoiceLine->getUnitsPriceExclToFloat()); + $this->assertSame('8020', $invoiceLine->getDim1ToCode()); // TODO - Vat lines - $this->assertSame('15.00', $invoice->getTotals()->getValueInc()); - $this->assertSame('15.00', $invoice->getTotals()->getValueExcl()); + $this->assertSame('15.00', $invoice->getTotals()->getValueIncToFloat()); + $this->assertSame('15.00', $invoice->getTotals()->getValueExclToFloat()); $this->assertSame('123456789', $invoice->getFinancialNumber()); $this->assertSame('123456789', $invoice->getFinancialCode()); @@ -151,37 +151,37 @@ public function testSendInvoiceWorks() $invoice = new Invoice(); $invoice->setOffice(Office::fromCode('11024')); - $invoice->setInvoiceType('FACTUUR'); + $invoice->setInvoiceTypeFromCode('FACTUUR'); $invoice->setInvoiceNumber('5'); - $invoice->setInvoiceDate('20120831'); - $invoice->setBank('BNK'); + $invoice->setInvoiceDateFromString('20120831'); + $invoice->setBankFromCode('BNK'); $invoice->setInvoiceAddressNumber('1'); $invoice->setDeliverAddressNumber('1'); $invoice->setCustomer($customer); $invoice->setPeriod('2012/8'); - $invoice->setCurrency('EUR'); - $invoice->setStatus('concept'); - $invoice->setPaymentMethod('cash'); + $invoice->setCurrencyFromCode('EUR'); + $invoice->setStatusFromString('concept'); + $invoice->setPaymentMethodFromString('cash'); $invoiceLine = new InvoiceLine(); $invoiceLine->setID('1'); - $invoiceLine->setArticle('4'); - $invoiceLine->setSubArticle('118'); + $invoiceLine->setArticleFromCode('4'); + $invoiceLine->setSubArticleFromSubCode('118'); $invoiceLine->setQuantity('1'); $invoiceLine->setUnits('1'); - $invoiceLine->setAllowDiscountOrPremium('true'); + $invoiceLine->setAllowDiscountOrPremiumFromString('true'); $invoiceLine->setDescription('CoalesceFunctioningOnImpatienceTShirt'); - $invoiceLine->setValueExcl('15.00'); - $invoiceLine->setVatValue('0.00'); - $invoiceLine->setValueInc('15.00'); - $invoiceLine->setUnitsPriceExcl('15.00'); - $invoiceLine->setDim1('8020'); - $invoiceLine->setVatCode('VN'); + $invoiceLine->setValueExclFromFloat('15.00'); + $invoiceLine->setVatValueFromFloat('0.00'); + $invoiceLine->setValueIncFromFloat('15.00'); + $invoiceLine->setUnitsPriceExclFromFloat('15.00'); + $invoiceLine->setDim1FromCode('8020'); + $invoiceLine->setVatCodeFromCode('VN'); $invoice->addLine($invoiceLine); $totals = new InvoiceTotals(); - $totals->setValueExcl('15.00'); - $totals->setValueInc('15.00'); + $totals->setValueExclFromFloat('15.00'); + $totals->setValueIncFromFloat('15.00'); $invoice->setTotals($totals); $this->processXmlService From 2ce5ea9ebbfefab07775a74e0a9e5f1988532d25 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 19:24:00 +0200 Subject: [PATCH 063/388] Update CustomerIntegrationTest.php --- .../CustomerIntegrationTest.php | 54 +++++++++---------- 1 file changed, 26 insertions(+), 28 deletions(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 07f0bbfc..8c73fc6d 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -50,17 +50,17 @@ public function testGetCustomerWorks() $customer = $this->customerApiConnector->get('CODE', $this->office); $this->assertInstanceOf(Customer::class, $customer); - $this->assertSame('001', $customer->getOffice()->getCode()); - $this->assertSame('DEB', $customer->getType()); + $this->assertSame('001', $customer->getOfficeToCode()); + $this->assertSame('DEB', $customer->getTypeToCode()); $this->assertSame('Customer 0', $customer->getName()); $this->assertSame('http://www.example.com', $customer->getWebsite()); // Financials $this->assertSame('30', $customer->getDueDays()); $this->assertSame(true, $customer->getPayAvailable()); - $this->assertSame('SEPANLDD', $customer->getPayCode()); + $this->assertSame('SEPANLDD', $customer->getPayCodeToCode()); $this->assertSame(false, $customer->getEBilling()); - $this->assertSame('VN', $customer->getVatCode()); + $this->assertSame('VN', $customer->getVatCodeToCode()); // Collect Mandate $collectMandate = $customer->getCollectMandate(); @@ -80,13 +80,12 @@ public function testGetCustomerWorks() $this->assertSame('invoice', $address->getType()); $this->assertSame(true, $address->getDefault()); $this->assertSame('Customer 0', $address->getName()); - $this->assertSame('NL', $address->getCountry()); + $this->assertSame('NL', $address->getCountryToCode()); $this->assertSame('Place', $address->getCity()); $this->assertSame('1000', $address->getPostcode()); $this->assertSame('010-123452000', $address->getTelephone()); - $this->assertSame('010-12342000', $address->getFax()); + $this->assertSame('010-12342000', $address->getTelefax()); $this->assertSame('info@example.com', $address->getEmail()); - $this->assertSame('', $address->getContact()); $this->assertSame('Customer 1', $address->getField1()); $this->assertSame('Streetname part 1 - 1', $address->getField2()); $this->assertSame('Streetname part 1 - 2', $address->getField3()); @@ -105,13 +104,13 @@ public function testGetCustomerWorks() $this->assertSame('-1', $bank->getID()); $this->assertSame(true, $bank->getDefault()); $this->assertSame('Customer 1', $bank->getAscription()); - $this->assertSame('123456789', $bank->getAccountnumber()); - $this->assertSame('ABN Amro', $bank->getBankname()); - $this->assertSame('ABNANL2A', $bank->getBiccode()); + $this->assertSame('123456789', $bank->getAccountNumber()); + $this->assertSame('ABN Amro', $bank->getBankName()); + $this->assertSame('ABNANL2A', $bank->getBicCode()); $this->assertSame('Place', $bank->getCity()); - $this->assertSame('NL', $bank->getCountry()); + $this->assertSame('NL', $bank->getCountryToCode()); $this->assertSame('NL02ABNA0123456789', $bank->getIban()); - $this->assertSame('', $bank->getNatbiccode()); + $this->assertSame('', $bank->getNatBicCode()); $this->assertSame('', $bank->getPostcode()); $this->assertSame('', $bank->getState()); $this->assertNull($bank->getAddressField2()); @@ -119,24 +118,23 @@ public function testGetCustomerWorks() $this->assertSame('1097', $customer->getCode()); $this->assertSame('c5027760-476e-4081-85fb-351c983aea54', $customer->getUID()); - $this->assertSame('false', $customer->getInUse()); + $this->assertSame('false', $customer->getInUseToString()); $this->assertSame('normal', $customer->getBehaviour()); $this->assertSame('0', $customer->getTouched()); $this->assertSame('0', $customer->getBeginPeriod()); $this->assertSame('0', $customer->getBeginYear()); $this->assertSame('0', $customer->getEndPeriod()); $this->assertSame('0', $customer->getEndYear()); - $this->assertSame('true', $customer->getEditDimensionName()); // Creditmanagement $creditmanagement = $customer->getCreditManagement(); - $this->assertSame('', $creditmanagement->getResponsibleUser()); - $this->assertSame('0.00', $creditmanagement->getBaseCreditLimit()); + $this->assertSame('', $creditmanagement->getResponsibleUserToCode()); + $this->assertSame('0.00', $creditmanagement->getBaseCreditLimitToFloat()); $this->assertSame(true, $creditmanagement->getSendReminder()); $this->assertSame('', $creditmanagement->getReminderEmail()); $this->assertSame(false, $creditmanagement->getBlocked()); - $this->assertSame('', $creditmanagement->getFreeText1()); + $this->assertSame('', $creditmanagement->getFreeText1ToString()); $this->assertSame('', $creditmanagement->getFreeText2()); $this->assertSame('', $creditmanagement->getFreeText3()); $this->assertSame('', $creditmanagement->getComment()); @@ -173,18 +171,18 @@ public function testSendCustomerWorks() $customer->setName('Customer 0'); $customer->setDueDays('30'); $customer->setPayAvailable(true); - $customer->setPayCode('SEPANLDD'); + $customer->setPayCodeFromCode('SEPANLDD'); $address = new CustomerAddress(); $address->setID('1'); - $address->setType('invoice'); + $address->setTypeFromString('invoice'); $address->setDefault(true); $address->setName('Customer 0'); - $address->setCountry('NL'); + $address->setCountryFromCode('NL'); $address->setCity('Place'); $address->setPostcode('1000'); $address->setTelephone('010-123452000'); - $address->setFax('010-12342000'); + $address->setTelefax('010-12342000'); $address->setEmail('info@example.com'); $address->setField1('Customer 1'); $address->setField2('Streetname part 1 - 1'); @@ -194,23 +192,23 @@ public function testSendCustomerWorks() $bank = new CustomerBank(); $bank->setDefault(true); $bank->setAscription('Customer 1'); - $bank->setAccountnumber('123456789'); + $bank->setAccountNumber('123456789'); $bank->setAddressField2(''); $bank->setAddressField3(''); - $bank->setBankname('ABN Amro'); - $bank->setBiccode('ABNANL2A'); + $bank->setBankName('ABN Amro'); + $bank->setBicCode('ABNANL2A'); $bank->setCity('Place'); - $bank->setCountry('NL'); + $bank->setCountryFromCode('NL'); $bank->setIban('NL02ABNA0123456789'); - $bank->setNatbiccode(''); + $bank->setNatBicCode(''); $bank->setPostcode(''); $bank->setState(''); $customer->addBank($bank); $collectMandate = new CustomerCollectMandate(); $collectMandate->setID('1'); - $collectMandate->setSignatureDate(new \DateTimeImmutable('2018-06-04')); - $collectMandate->setFirstRunDate(new \DateTimeImmutable('2018-06-08')); + $collectMandate->setSignatureDateFromString('20180604'); + $collectMandate->setFirstRunDateFromString('20180608'); $customer->setCollectMandate($collectMandate); $this->processXmlService From 649310183e6b8e301660a18b9b4967741374b2be Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 19:25:18 +0200 Subject: [PATCH 064/388] Update CustomerIntegrationTest.php --- tests/IntegrationTests/CustomerIntegrationTest.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 8c73fc6d..258a336b 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -56,11 +56,12 @@ public function testGetCustomerWorks() $this->assertSame('http://www.example.com', $customer->getWebsite()); // Financials - $this->assertSame('30', $customer->getDueDays()); - $this->assertSame(true, $customer->getPayAvailable()); - $this->assertSame('SEPANLDD', $customer->getPayCodeToCode()); - $this->assertSame(false, $customer->getEBilling()); - $this->assertSame('VN', $customer->getVatCodeToCode()); + $financials = $customer->getFinancials(); + $this->assertSame('30', $financials->getDueDays()); + $this->assertSame(true, $financials->getPayAvailable()); + $this->assertSame('SEPANLDD', $financials->getPayCodeToCode()); + $this->assertSame(false, $financials->getEBilling()); + $this->assertSame('VN', $financials->getVatCodeToCode()); // Collect Mandate $collectMandate = $customer->getCollectMandate(); From ecee94c86f79b907c9a422f3c1eb8b3e851ca14d Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 19:29:12 +0200 Subject: [PATCH 065/388] Update CustomerIntegrationTest.php --- tests/IntegrationTests/CustomerIntegrationTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 258a336b..b0ad2cbd 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -57,7 +57,7 @@ public function testGetCustomerWorks() // Financials $financials = $customer->getFinancials(); - $this->assertSame('30', $financials->getDueDays()); + $this->assertSame(30, $financials->getDueDays()); $this->assertSame(true, $financials->getPayAvailable()); $this->assertSame('SEPANLDD', $financials->getPayCodeToCode()); $this->assertSame(false, $financials->getEBilling()); @@ -170,7 +170,7 @@ public function testSendCustomerWorks() $customer = new Customer(); $customer->setOffice(Office::fromCode('001')); $customer->setName('Customer 0'); - $customer->setDueDays('30'); + $customer->setDueDays(30); $customer->setPayAvailable(true); $customer->setPayCodeFromCode('SEPANLDD'); From 95aa0d03e469791bba007e2bea6542791c53f47e Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 9 May 2019 19:30:09 +0200 Subject: [PATCH 066/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index a90b20d5..3ea777e4 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -49,7 +49,7 @@ public function testGetConceptInvoiceWorks() $this->assertInstanceOf(Invoice::class, $invoice); $this->assertEquals(Office::fromCode("11024"), $invoice->getOffice()); $this->assertSame('FACTUUR', $invoice->getInvoiceTypeToCode()); - $this->assertSame('5', $invoice->getInvoiceNumber()); + $this->assertSame(5, $invoice->getInvoiceNumber()); $this->assertSame('20120831', $invoice->getInvoiceDateToString()); $this->assertSame('BNK', $invoice->getBankToCode()); $this->assertSame('1', $invoice->getInvoiceAddressNumber()); @@ -104,7 +104,7 @@ public function testGetFinalInvoiceWorks() $this->assertInstanceOf(Invoice::class, $invoice); $this->assertEquals(Office::fromCode("11024"), $invoice->getOffice()); $this->assertSame('FACTUUR', $invoice->getInvoiceTypeToCode()); - $this->assertSame('5', $invoice->getInvoiceNumber()); + $this->assertSame(5, $invoice->getInvoiceNumber()); $this->assertSame('20120831', $invoice->getInvoiceDateToString()); $this->assertSame('BNK', $invoice->getBankToCode()); $this->assertSame('1', $invoice->getInvoiceAddressNumber()); @@ -152,7 +152,7 @@ public function testSendInvoiceWorks() $invoice = new Invoice(); $invoice->setOffice(Office::fromCode('11024')); $invoice->setInvoiceTypeFromCode('FACTUUR'); - $invoice->setInvoiceNumber('5'); + $invoice->setInvoiceNumber(5); $invoice->setInvoiceDateFromString('20120831'); $invoice->setBankFromCode('BNK'); $invoice->setInvoiceAddressNumber('1'); From 3c3ee21dd3296bb76f239937142378af57dc1b42 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 11:09:11 +0200 Subject: [PATCH 067/388] Update .travis.yml --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 754323e7..6852b0c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,7 @@ language: php dist: trusty php: -- 7.1 - 7.2 -- 7.3 -- nightly matrix: fast_finish: true From cadf23b5b430c90cf595819f19818e403efa6e44 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 11:15:25 +0200 Subject: [PATCH 068/388] Update InvoiceIntegrationTest.php --- .../InvoiceIntegrationTest.php | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 3ea777e4..9198f36f 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -52,8 +52,8 @@ public function testGetConceptInvoiceWorks() $this->assertSame(5, $invoice->getInvoiceNumber()); $this->assertSame('20120831', $invoice->getInvoiceDateToString()); $this->assertSame('BNK', $invoice->getBankToCode()); - $this->assertSame('1', $invoice->getInvoiceAddressNumber()); - $this->assertSame('1', $invoice->getDeliverAddressNumber()); + $this->assertSame(1, $invoice->getInvoiceAddressNumber()); + $this->assertSame(1, $invoice->getDeliverAddressNumber()); $this->assertSame('1000', $invoice->getCustomerToCode()); $this->assertSame('2012/8', $invoice->getPeriod()); $this->assertSame('EUR', $invoice->getCurrencyToCode()); @@ -67,23 +67,23 @@ public function testGetConceptInvoiceWorks() /** @var InvoiceLine $invoiceLine */ $invoiceLine = $invoiceLines['1']; - $this->assertSame('1', $invoiceLine->getID()); + $this->assertSame(1, $invoiceLine->getID()); $this->assertSame('0', $invoiceLine->getArticleToCode()); $this->assertSame('118', $invoiceLine->getSubArticleToSubCode()); - $this->assertSame('1', $invoiceLine->getQuantity()); - $this->assertSame('1', $invoiceLine->getUnits()); + $this->assertSame(1, $invoiceLine->getQuantity()); + $this->assertSame(1, $invoiceLine->getUnits()); $this->assertSame('true', $invoiceLine->getAllowDiscountOrPremiumToString()); $this->assertSame('CoalesceFunctioningOnImpatienceTShirt', $invoiceLine->getDescription()); - $this->assertSame('15.00', $invoiceLine->getValueExclToFloat()); - $this->assertSame('0.00', $invoiceLine->getVatValueToFloat()); - $this->assertSame('15.00', $invoiceLine->getValueIncToFloat()); - $this->assertSame('15.00', $invoiceLine->getUnitsPriceExclToFloat()); + $this->assertSame(15.00, $invoiceLine->getValueExclToFloat()); + $this->assertSame(0.00, $invoiceLine->getVatValueToFloat()); + $this->assertSame(15.00, $invoiceLine->getValueIncToFloat()); + $this->assertSame(15.00, $invoiceLine->getUnitsPriceExclToFloat()); $this->assertSame('8020', $invoiceLine->getDim1ToCode()); // TODO - Vat lines - $this->assertSame('15.00', $invoice->getTotals()->getValueIncToFloat()); - $this->assertSame('15.00', $invoice->getTotals()->getValueExclToFloat()); + $this->assertSame(15.00, $invoice->getTotals()->getValueIncToFloat()); + $this->assertSame(15.00, $invoice->getTotals()->getValueExclToFloat()); $this->assertNull($invoice->getFinancialNumber()); $this->assertNull($invoice->getFinancialCode()); @@ -107,8 +107,8 @@ public function testGetFinalInvoiceWorks() $this->assertSame(5, $invoice->getInvoiceNumber()); $this->assertSame('20120831', $invoice->getInvoiceDateToString()); $this->assertSame('BNK', $invoice->getBankToCode()); - $this->assertSame('1', $invoice->getInvoiceAddressNumber()); - $this->assertSame('1', $invoice->getDeliverAddressNumber()); + $this->assertSame(1, $invoice->getInvoiceAddressNumber()); + $this->assertSame(1, $invoice->getDeliverAddressNumber()); $this->assertSame('1000', $invoice->getCustomerToCode()); $this->assertSame('2012/8', $invoice->getPeriod()); $this->assertSame('EUR', $invoice->getCurrencyToCode()); @@ -122,23 +122,23 @@ public function testGetFinalInvoiceWorks() /** @var InvoiceLine $invoiceLine */ $invoiceLine = $invoiceLines['1']; - $this->assertSame('1', $invoiceLine->getID()); + $this->assertSame(1, $invoiceLine->getID()); $this->assertSame('0', $invoiceLine->getArticleToCode()); $this->assertSame('118', $invoiceLine->getSubArticleToSubCode()); - $this->assertSame('1', $invoiceLine->getQuantity()); - $this->assertSame('1', $invoiceLine->getUnits()); + $this->assertSame(1, $invoiceLine->getQuantity()); + $this->assertSame(1, $invoiceLine->getUnits()); $this->assertSame('true', $invoiceLine->getAllowDiscountOrPremiumToString()); $this->assertSame('CoalesceFunctioningOnImpatienceTShirt', $invoiceLine->getDescription()); - $this->assertSame('15.00', $invoiceLine->getValueExclToFloat()); - $this->assertSame('0.00', $invoiceLine->getVatValueToFloat()); - $this->assertSame('15.00', $invoiceLine->getValueIncToFloat()); - $this->assertSame('15.00', $invoiceLine->getUnitsPriceExclToFloat()); + $this->assertSame(15.00, $invoiceLine->getValueExclToFloat()); + $this->assertSame(0.00, $invoiceLine->getVatValueToFloat()); + $this->assertSame(15.00, $invoiceLine->getValueIncToFloat()); + $this->assertSame(15.00, $invoiceLine->getUnitsPriceExclToFloat()); $this->assertSame('8020', $invoiceLine->getDim1ToCode()); // TODO - Vat lines - $this->assertSame('15.00', $invoice->getTotals()->getValueIncToFloat()); - $this->assertSame('15.00', $invoice->getTotals()->getValueExclToFloat()); + $this->assertSame(15.00, $invoice->getTotals()->getValueIncToFloat()); + $this->assertSame(15.00, $invoice->getTotals()->getValueExclToFloat()); $this->assertSame('123456789', $invoice->getFinancialNumber()); $this->assertSame('123456789', $invoice->getFinancialCode()); @@ -155,8 +155,8 @@ public function testSendInvoiceWorks() $invoice->setInvoiceNumber(5); $invoice->setInvoiceDateFromString('20120831'); $invoice->setBankFromCode('BNK'); - $invoice->setInvoiceAddressNumber('1'); - $invoice->setDeliverAddressNumber('1'); + $invoice->setInvoiceAddressNumber(1); + $invoice->setDeliverAddressNumber(1); $invoice->setCustomer($customer); $invoice->setPeriod('2012/8'); $invoice->setCurrencyFromCode('EUR'); @@ -164,24 +164,24 @@ public function testSendInvoiceWorks() $invoice->setPaymentMethodFromString('cash'); $invoiceLine = new InvoiceLine(); - $invoiceLine->setID('1'); + $invoiceLine->setID(1); $invoiceLine->setArticleFromCode('4'); $invoiceLine->setSubArticleFromSubCode('118'); - $invoiceLine->setQuantity('1'); - $invoiceLine->setUnits('1'); + $invoiceLine->setQuantity(1); + $invoiceLine->setUnits(1); $invoiceLine->setAllowDiscountOrPremiumFromString('true'); $invoiceLine->setDescription('CoalesceFunctioningOnImpatienceTShirt'); - $invoiceLine->setValueExclFromFloat('15.00'); - $invoiceLine->setVatValueFromFloat('0.00'); - $invoiceLine->setValueIncFromFloat('15.00'); - $invoiceLine->setUnitsPriceExclFromFloat('15.00'); + $invoiceLine->setValueExclFromFloat(15.00); + $invoiceLine->setVatValueFromFloat(0.00); + $invoiceLine->setValueIncFromFloat(15.00); + $invoiceLine->setUnitsPriceExclFromFloat(15.00); $invoiceLine->setDim1FromCode('8020'); $invoiceLine->setVatCodeFromCode('VN'); $invoice->addLine($invoiceLine); $totals = new InvoiceTotals(); - $totals->setValueExclFromFloat('15.00'); - $totals->setValueIncFromFloat('15.00'); + $totals->setValueExclFromFloat(15.00); + $totals->setValueIncFromFloat(15.00); $invoice->setTotals($totals); $this->processXmlService From a38b37990dbc9634a66fea4cb73d20b5ffb99e09 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 11:19:52 +0200 Subject: [PATCH 069/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 9198f36f..b296984e 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -57,8 +57,8 @@ public function testGetConceptInvoiceWorks() $this->assertSame('1000', $invoice->getCustomerToCode()); $this->assertSame('2012/8', $invoice->getPeriod()); $this->assertSame('EUR', $invoice->getCurrencyToCode()); - $this->assertSame('concept', $invoice->getStatus()); - $this->assertSame('cash', $invoice->getPaymentMethod()); + $this->assertSame(Enums\InvoiceStatus::CONCEPT(), $invoice->getStatus()); + $this->assertSame(Enums\PaymentMethod::CASH(), $invoice->getPaymentMethod()); $invoiceLines = $invoice->getLines(); $this->assertCount(1, $invoiceLines); @@ -112,8 +112,8 @@ public function testGetFinalInvoiceWorks() $this->assertSame('1000', $invoice->getCustomerToCode()); $this->assertSame('2012/8', $invoice->getPeriod()); $this->assertSame('EUR', $invoice->getCurrencyToCode()); - $this->assertSame('final', $invoice->getStatus()); - $this->assertSame('cash', $invoice->getPaymentMethod()); + $this->assertSame(Enums\InvoiceStatus::FINAL(), $invoice->getStatus()); + $this->assertSame(Enums\PaymentMethod::CASH(), $invoice->getPaymentMethod()); $invoiceLines = $invoice->getLines(); $this->assertCount(1, $invoiceLines); From 65368f5b258958fc4fff51abfc037af711f46192 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 11:39:18 +0200 Subject: [PATCH 070/388] Add files via upload --- src/Mappers/BrowseDataMapper.php | 10 +++++----- src/Mappers/BrowseDefinitionMapper.php | 24 ++++++++++++------------ src/Mappers/BrowseFieldMapper.php | 10 +++++----- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Mappers/BrowseDataMapper.php b/src/Mappers/BrowseDataMapper.php index 13d06e8a..a8771381 100644 --- a/src/Mappers/BrowseDataMapper.php +++ b/src/Mappers/BrowseDataMapper.php @@ -55,10 +55,10 @@ public static function map(Response $response) $keyElement = $rowElement->getElementsByTagName('key')[0]; $browseDataRow - ->setOffice(Office::fromCode(self::getField($keyElement, 'office'))) - ->setCode(self::getField($keyElement, 'code')) - ->setNumber(self::getField($keyElement, 'number')) - ->setLine(self::getField($keyElement, 'line')); + ->setOffice(Office::fromCode(self::getField($browseDataRow, $keyElement, 'office'))) + ->setCode(self::getField($browseDataRow, $keyElement, 'code')) + ->setNumber(self::getField($browseDataRow, $keyElement, 'number')) + ->setLine(self::getField($browseDataRow, $keyElement, 'line')); $browseData->addRow($browseDataRow); @@ -104,4 +104,4 @@ private static function parseBrowseDataValue(string $type, string $value) return $value; } } -} +} \ No newline at end of file diff --git a/src/Mappers/BrowseDefinitionMapper.php b/src/Mappers/BrowseDefinitionMapper.php index 76d7a648..06198d1e 100644 --- a/src/Mappers/BrowseDefinitionMapper.php +++ b/src/Mappers/BrowseDefinitionMapper.php @@ -29,32 +29,32 @@ public static function map(Response $response) $browseDefinitionElement = $document->documentElement; $browseDefinition - ->setOffice(Office::fromCode(self::getField($browseDefinitionElement, 'office'))) - ->setCode(self::getField($browseDefinitionElement, 'code')) - ->setName(self::getField($browseDefinitionElement, 'name')) - ->setShortName(self::getField($browseDefinitionElement, 'shortname')) - ->setVisible(self::getField($browseDefinitionElement, 'visible')); + ->setOffice(Office::fromCode(self::getField($browseDefinition, $browseDefinitionElement, 'office'))) + ->setCode(self::getField($browseDefinition, $browseDefinitionElement, 'code')) + ->setName(self::getField($browseDefinition, $browseDefinitionElement, 'name')) + ->setShortName(self::getField($browseDefinition, $browseDefinitionElement, 'shortname')) + ->setVisible(self::getField($browseDefinition, $browseDefinitionElement, 'visible')); foreach ($browseDefinitionElement->getElementsByTagName('column') as $columnElement) { $browseColumn = new BrowseColumn(); $browseColumn ->setId($columnElement->getAttribute('id')) - ->setField(self::getField($columnElement, 'field')) - ->setVisible(Util::parseBoolean(self::getField($columnElement, 'visible'))) - ->setAsk(Util::parseBoolean(self::getField($columnElement, 'ask'))) - ->setOperator(new BrowseColumnOperator(self::getField($columnElement, 'operator'))); + ->setField(self::getField($browseColumn, $columnElement, 'field')) + ->setVisible(Util::parseBoolean(self::getField($browseColumn, $columnElement, 'visible'))) + ->setAsk(Util::parseBoolean(self::getField($browseColumn, $columnElement, 'ask'))) + ->setOperator(new BrowseColumnOperator(self::getField($browseColumn, $columnElement, 'operator'))); - $label = self::getField($columnElement, 'label'); + $label = self::getField($browseColumn, $columnElement, 'label'); if (!empty($label)) { $browseColumn->setLabel($label); } - $from = self::getField($columnElement, 'from'); + $from = self::getField($browseColumn, $columnElement, 'from'); if (!empty($from)) { $browseColumn->setFrom($from); } - $to = self::getField($columnElement, 'to'); + $to = self::getField($browseColumn, $columnElement, 'to'); if (!empty($to)) { $browseColumn->setTo($to); } diff --git a/src/Mappers/BrowseFieldMapper.php b/src/Mappers/BrowseFieldMapper.php index 3765680d..b22482cd 100644 --- a/src/Mappers/BrowseFieldMapper.php +++ b/src/Mappers/BrowseFieldMapper.php @@ -25,15 +25,15 @@ public static function map(Response $response) foreach ($browseFieldsElement->getElementsByTagName('browsefield') as $browseFieldElement) { $browseField = new BrowseField(); $browseField - ->setCode(self::getField($browseFieldElement, 'code')) - ->setDataType(self::getField($browseFieldElement, 'datatype')); + ->setCode(self::getField($browseField, $browseFieldElement, 'code')) + ->setDataType(self::getField($browseField, $browseFieldElement, 'datatype')); - $finder = self::getField($browseFieldElement, 'finder'); + $finder = self::getField($browseField, $browseFieldElement, 'finder'); if (!empty($finder)) { $browseField->setFinder($finder); } - $canOrder = self::getField($browseFieldElement, 'canorder'); + $canOrder = self::getField($browseField, $browseFieldElement, 'canorder'); if (!empty($canOrder)) { $browseField->setCanOrder($canOrder); } @@ -55,4 +55,4 @@ public static function map(Response $response) return $browseFields; } -} +} \ No newline at end of file From a3c7a40772408637eabf0380e4f1d6c78179bf22 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 11:39:40 +0200 Subject: [PATCH 071/388] Add files via upload --- src/Mappers/BrowseDataMapper.php | 10 +++++----- src/Mappers/BrowseDefinitionMapper.php | 24 ++++++++++++------------ src/Mappers/BrowseFieldMapper.php | 10 +++++----- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Mappers/BrowseDataMapper.php b/src/Mappers/BrowseDataMapper.php index 13d06e8a..a8771381 100644 --- a/src/Mappers/BrowseDataMapper.php +++ b/src/Mappers/BrowseDataMapper.php @@ -55,10 +55,10 @@ public static function map(Response $response) $keyElement = $rowElement->getElementsByTagName('key')[0]; $browseDataRow - ->setOffice(Office::fromCode(self::getField($keyElement, 'office'))) - ->setCode(self::getField($keyElement, 'code')) - ->setNumber(self::getField($keyElement, 'number')) - ->setLine(self::getField($keyElement, 'line')); + ->setOffice(Office::fromCode(self::getField($browseDataRow, $keyElement, 'office'))) + ->setCode(self::getField($browseDataRow, $keyElement, 'code')) + ->setNumber(self::getField($browseDataRow, $keyElement, 'number')) + ->setLine(self::getField($browseDataRow, $keyElement, 'line')); $browseData->addRow($browseDataRow); @@ -104,4 +104,4 @@ private static function parseBrowseDataValue(string $type, string $value) return $value; } } -} +} \ No newline at end of file diff --git a/src/Mappers/BrowseDefinitionMapper.php b/src/Mappers/BrowseDefinitionMapper.php index 76d7a648..06198d1e 100644 --- a/src/Mappers/BrowseDefinitionMapper.php +++ b/src/Mappers/BrowseDefinitionMapper.php @@ -29,32 +29,32 @@ public static function map(Response $response) $browseDefinitionElement = $document->documentElement; $browseDefinition - ->setOffice(Office::fromCode(self::getField($browseDefinitionElement, 'office'))) - ->setCode(self::getField($browseDefinitionElement, 'code')) - ->setName(self::getField($browseDefinitionElement, 'name')) - ->setShortName(self::getField($browseDefinitionElement, 'shortname')) - ->setVisible(self::getField($browseDefinitionElement, 'visible')); + ->setOffice(Office::fromCode(self::getField($browseDefinition, $browseDefinitionElement, 'office'))) + ->setCode(self::getField($browseDefinition, $browseDefinitionElement, 'code')) + ->setName(self::getField($browseDefinition, $browseDefinitionElement, 'name')) + ->setShortName(self::getField($browseDefinition, $browseDefinitionElement, 'shortname')) + ->setVisible(self::getField($browseDefinition, $browseDefinitionElement, 'visible')); foreach ($browseDefinitionElement->getElementsByTagName('column') as $columnElement) { $browseColumn = new BrowseColumn(); $browseColumn ->setId($columnElement->getAttribute('id')) - ->setField(self::getField($columnElement, 'field')) - ->setVisible(Util::parseBoolean(self::getField($columnElement, 'visible'))) - ->setAsk(Util::parseBoolean(self::getField($columnElement, 'ask'))) - ->setOperator(new BrowseColumnOperator(self::getField($columnElement, 'operator'))); + ->setField(self::getField($browseColumn, $columnElement, 'field')) + ->setVisible(Util::parseBoolean(self::getField($browseColumn, $columnElement, 'visible'))) + ->setAsk(Util::parseBoolean(self::getField($browseColumn, $columnElement, 'ask'))) + ->setOperator(new BrowseColumnOperator(self::getField($browseColumn, $columnElement, 'operator'))); - $label = self::getField($columnElement, 'label'); + $label = self::getField($browseColumn, $columnElement, 'label'); if (!empty($label)) { $browseColumn->setLabel($label); } - $from = self::getField($columnElement, 'from'); + $from = self::getField($browseColumn, $columnElement, 'from'); if (!empty($from)) { $browseColumn->setFrom($from); } - $to = self::getField($columnElement, 'to'); + $to = self::getField($browseColumn, $columnElement, 'to'); if (!empty($to)) { $browseColumn->setTo($to); } diff --git a/src/Mappers/BrowseFieldMapper.php b/src/Mappers/BrowseFieldMapper.php index 3765680d..b22482cd 100644 --- a/src/Mappers/BrowseFieldMapper.php +++ b/src/Mappers/BrowseFieldMapper.php @@ -25,15 +25,15 @@ public static function map(Response $response) foreach ($browseFieldsElement->getElementsByTagName('browsefield') as $browseFieldElement) { $browseField = new BrowseField(); $browseField - ->setCode(self::getField($browseFieldElement, 'code')) - ->setDataType(self::getField($browseFieldElement, 'datatype')); + ->setCode(self::getField($browseField, $browseFieldElement, 'code')) + ->setDataType(self::getField($browseField, $browseFieldElement, 'datatype')); - $finder = self::getField($browseFieldElement, 'finder'); + $finder = self::getField($browseField, $browseFieldElement, 'finder'); if (!empty($finder)) { $browseField->setFinder($finder); } - $canOrder = self::getField($browseFieldElement, 'canorder'); + $canOrder = self::getField($browseField, $browseFieldElement, 'canorder'); if (!empty($canOrder)) { $browseField->setCanOrder($canOrder); } @@ -55,4 +55,4 @@ public static function map(Response $response) return $browseFields; } -} +} \ No newline at end of file From 8a7fd7f47f53aab13027669ffb789a787a26f634 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 11:43:37 +0200 Subject: [PATCH 072/388] Update Dim2Field.php --- src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php b/src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php index 11e8696b..13f159fe 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php +++ b/src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php @@ -1,6 +1,6 @@ Date: Fri, 10 May 2019 11:43:56 +0200 Subject: [PATCH 073/388] Update Dim2Field.php --- src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php b/src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php index 11e8696b..13f159fe 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php +++ b/src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php @@ -1,6 +1,6 @@ Date: Fri, 10 May 2019 11:46:04 +0200 Subject: [PATCH 074/388] Update MatchSetMapper.php --- src/Mappers/MatchSetMapper.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Mappers/MatchSetMapper.php b/src/Mappers/MatchSetMapper.php index 81eba2d1..f2ec2a04 100644 --- a/src/Mappers/MatchSetMapper.php +++ b/src/Mappers/MatchSetMapper.php @@ -60,15 +60,15 @@ private static function getMatchReferenceFrom( ): MatchReferenceInterface { return new MatchReference( $office, - self::getField($lineElement, 'transcode'), - self::getField($lineElement, 'transnumber'), - self::getField($lineElement, 'transline') + self::getField(null, $lineElement, 'transcode'), + self::getField(null, $lineElement, 'transnumber'), + self::getField(null, $lineElement, 'transline') ); } private static function getMatchValueFrom(\DOMElement $lineElement): ?Money { - $matchValue = self::getField($lineElement, 'matchvalue'); + $matchValue = self::getField(null, $lineElement, 'matchvalue'); if ($matchValue === null) { return null; From 2e60d5f42c0ed71093bee60d285b7a7f8b3ddb1a Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 11:46:15 +0200 Subject: [PATCH 075/388] Update MatchSetMapper.php --- src/Mappers/MatchSetMapper.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Mappers/MatchSetMapper.php b/src/Mappers/MatchSetMapper.php index 81eba2d1..f2ec2a04 100644 --- a/src/Mappers/MatchSetMapper.php +++ b/src/Mappers/MatchSetMapper.php @@ -60,15 +60,15 @@ private static function getMatchReferenceFrom( ): MatchReferenceInterface { return new MatchReference( $office, - self::getField($lineElement, 'transcode'), - self::getField($lineElement, 'transnumber'), - self::getField($lineElement, 'transline') + self::getField(null, $lineElement, 'transcode'), + self::getField(null, $lineElement, 'transnumber'), + self::getField(null, $lineElement, 'transline') ); } private static function getMatchValueFrom(\DOMElement $lineElement): ?Money { - $matchValue = self::getField($lineElement, 'matchvalue'); + $matchValue = self::getField(null, $lineElement, 'matchvalue'); if ($matchValue === null) { return null; From a1dd512643412088ed783830673bff71daedfaa4 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 11:47:36 +0200 Subject: [PATCH 076/388] Update BaseMapper.php --- src/Mappers/BaseMapper.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index f8395d57..24729b8d 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -87,7 +87,9 @@ protected static function getField($object, \DOMElement $element, string $fieldT return null; } - self::checkForMessage($object, $fieldElement); + if (isset($object)) { + self::checkForMessage($object, $fieldElement); + } if ($fieldElement->textContent === "") { return null; @@ -203,4 +205,4 @@ protected static function parseObjectAttribute(string $className, $object, \DOME return $object2; } -} \ No newline at end of file +} From 560d22e1cc10bafec6239e75357c1934f8a1c10d Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 11:47:46 +0200 Subject: [PATCH 077/388] Update BaseMapper.php --- src/Mappers/BaseMapper.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index f8395d57..24729b8d 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -87,7 +87,9 @@ protected static function getField($object, \DOMElement $element, string $fieldT return null; } - self::checkForMessage($object, $fieldElement); + if (isset($object)) { + self::checkForMessage($object, $fieldElement); + } if ($fieldElement->textContent === "") { return null; @@ -203,4 +205,4 @@ protected static function parseObjectAttribute(string $className, $object, \DOME return $object2; } -} \ No newline at end of file +} From 03ff08932f20b754f1c2c7e56b098c3320ce483e Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 11:51:12 +0200 Subject: [PATCH 078/388] Add files via upload --- src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php | 2 +- src/Fields/Level1234/Level34/FixedAsset/Dim5Field.php | 2 +- src/Fields/Level1234/Level34/FixedAsset/Dim6Field.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php b/src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php index 4d9d19fb..763114a4 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php +++ b/src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php @@ -1,6 +1,6 @@ Date: Fri, 10 May 2019 11:51:41 +0200 Subject: [PATCH 079/388] Add files via upload --- src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php | 2 +- src/Fields/Level1234/Level34/FixedAsset/Dim5Field.php | 2 +- src/Fields/Level1234/Level34/FixedAsset/Dim6Field.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php b/src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php index 4d9d19fb..763114a4 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php +++ b/src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php @@ -1,6 +1,6 @@ Date: Fri, 10 May 2019 12:03:26 +0200 Subject: [PATCH 080/388] Add files via upload --- src/ApiConnectors/CashBankBookApiConnector.php | 1 + src/ApiConnectors/CountryApiConnector.php | 1 + src/ApiConnectors/InvoiceTypeApiConnector.php | 1 + src/ApiConnectors/OfficeApiConnector.php | 2 +- src/ApiConnectors/PayCodeApiConnector.php | 1 + src/ApiConnectors/SupplierApiConnector.php | 2 +- src/ApiConnectors/UserRoleApiConnector.php | 5 +++-- src/ApiConnectors/VatGroupApiConnector.php | 1 + 8 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ApiConnectors/CashBankBookApiConnector.php b/src/ApiConnectors/CashBankBookApiConnector.php index f2165485..1381897c 100644 --- a/src/ApiConnectors/CashBankBookApiConnector.php +++ b/src/ApiConnectors/CashBankBookApiConnector.php @@ -2,6 +2,7 @@ namespace PhpTwinfield\ApiConnectors; +use PhpTwinfield\CashBankBook; use PhpTwinfield\Exception; use PhpTwinfield\Services\FinderService; diff --git a/src/ApiConnectors/CountryApiConnector.php b/src/ApiConnectors/CountryApiConnector.php index 91479ab7..e3c67634 100644 --- a/src/ApiConnectors/CountryApiConnector.php +++ b/src/ApiConnectors/CountryApiConnector.php @@ -2,6 +2,7 @@ namespace PhpTwinfield\ApiConnectors; +use PhpTwinfield\Country; use PhpTwinfield\Exception; use PhpTwinfield\Services\FinderService; diff --git a/src/ApiConnectors/InvoiceTypeApiConnector.php b/src/ApiConnectors/InvoiceTypeApiConnector.php index aa2f3848..e1ab7606 100644 --- a/src/ApiConnectors/InvoiceTypeApiConnector.php +++ b/src/ApiConnectors/InvoiceTypeApiConnector.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\ApiConnectors; use PhpTwinfield\Exception; +use PhpTwinfield\InvoiceType; use PhpTwinfield\Services\FinderService; /** diff --git a/src/ApiConnectors/OfficeApiConnector.php b/src/ApiConnectors/OfficeApiConnector.php index 471e0243..0ad1ab8b 100644 --- a/src/ApiConnectors/OfficeApiConnector.php +++ b/src/ApiConnectors/OfficeApiConnector.php @@ -7,7 +7,7 @@ use PhpTwinfield\Office; use PhpTwinfield\Services\FinderService; use PhpTwinfield\Request as Request; -use PhpTwinfield\Request\Catalog as RequestDocument; +use PhpTwinfield\Request\Catalog\Catalog as RequestDocument; /** * A facade to make interaction with the the Twinfield service easier when trying to retrieve or send information about diff --git a/src/ApiConnectors/PayCodeApiConnector.php b/src/ApiConnectors/PayCodeApiConnector.php index 4d78fcaa..84938793 100644 --- a/src/ApiConnectors/PayCodeApiConnector.php +++ b/src/ApiConnectors/PayCodeApiConnector.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\ApiConnectors; use PhpTwinfield\Exception; +use PhpTwinfield\PayCode; use PhpTwinfield\Services\FinderService; /** diff --git a/src/ApiConnectors/SupplierApiConnector.php b/src/ApiConnectors/SupplierApiConnector.php index 5dc8606d..adb2fab7 100644 --- a/src/ApiConnectors/SupplierApiConnector.php +++ b/src/ApiConnectors/SupplierApiConnector.php @@ -57,7 +57,7 @@ public function get(string $code, Office $office): Supplier */ public function send(Supplier $supplier): Supplier { - foreach($this->sendAll([$fixedAsset]) as $each) { + foreach($this->sendAll([$supplier]) as $each) { return $each->unwrap(); } } diff --git a/src/ApiConnectors/UserRoleApiConnector.php b/src/ApiConnectors/UserRoleApiConnector.php index 48c05c2f..9e72ede0 100644 --- a/src/ApiConnectors/UserRoleApiConnector.php +++ b/src/ApiConnectors/UserRoleApiConnector.php @@ -4,10 +4,11 @@ use PhpTwinfield\Exception; use PhpTwinfield\Services\FinderService; +use PhpTwinfield\UserRole; /** * A facade to make interaction with the the Twinfield service easier when trying to retrieve or send information about - * UserRoles. + * UserRole. * * If you require more complex interactions or a heavier amount of control over the requests to/from then look inside * the methods or see the advanced guide detailing the required usages. @@ -29,7 +30,7 @@ class UserRoleApiConnector extends BaseApiConnector * to add multiple options. An option name may be used once, specifying an option multiple * times will cause an error. * - * @return UserRoles[] The user roles found. + * @return UserRole[] The user roles found. */ public function listAll( string $pattern = '*', diff --git a/src/ApiConnectors/VatGroupApiConnector.php b/src/ApiConnectors/VatGroupApiConnector.php index b2326e69..3a9d802c 100644 --- a/src/ApiConnectors/VatGroupApiConnector.php +++ b/src/ApiConnectors/VatGroupApiConnector.php @@ -4,6 +4,7 @@ use PhpTwinfield\Exception; use PhpTwinfield\Services\FinderService; +use PhpTwinfield\VatGroup; /** * A facade to make interaction with the the Twinfield service easier when trying to retrieve or send information about From d92f5938a947f04aa906ec94c6bfa9b668997dde Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:03:55 +0200 Subject: [PATCH 081/388] Add files via upload --- src/ApiConnectors/CashBankBookApiConnector.php | 1 + src/ApiConnectors/CountryApiConnector.php | 1 + src/ApiConnectors/InvoiceTypeApiConnector.php | 1 + src/ApiConnectors/OfficeApiConnector.php | 2 +- src/ApiConnectors/PayCodeApiConnector.php | 1 + src/ApiConnectors/SupplierApiConnector.php | 2 +- src/ApiConnectors/UserRoleApiConnector.php | 5 +++-- src/ApiConnectors/VatGroupApiConnector.php | 1 + 8 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ApiConnectors/CashBankBookApiConnector.php b/src/ApiConnectors/CashBankBookApiConnector.php index f2165485..1381897c 100644 --- a/src/ApiConnectors/CashBankBookApiConnector.php +++ b/src/ApiConnectors/CashBankBookApiConnector.php @@ -2,6 +2,7 @@ namespace PhpTwinfield\ApiConnectors; +use PhpTwinfield\CashBankBook; use PhpTwinfield\Exception; use PhpTwinfield\Services\FinderService; diff --git a/src/ApiConnectors/CountryApiConnector.php b/src/ApiConnectors/CountryApiConnector.php index 91479ab7..e3c67634 100644 --- a/src/ApiConnectors/CountryApiConnector.php +++ b/src/ApiConnectors/CountryApiConnector.php @@ -2,6 +2,7 @@ namespace PhpTwinfield\ApiConnectors; +use PhpTwinfield\Country; use PhpTwinfield\Exception; use PhpTwinfield\Services\FinderService; diff --git a/src/ApiConnectors/InvoiceTypeApiConnector.php b/src/ApiConnectors/InvoiceTypeApiConnector.php index aa2f3848..e1ab7606 100644 --- a/src/ApiConnectors/InvoiceTypeApiConnector.php +++ b/src/ApiConnectors/InvoiceTypeApiConnector.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\ApiConnectors; use PhpTwinfield\Exception; +use PhpTwinfield\InvoiceType; use PhpTwinfield\Services\FinderService; /** diff --git a/src/ApiConnectors/OfficeApiConnector.php b/src/ApiConnectors/OfficeApiConnector.php index 471e0243..0ad1ab8b 100644 --- a/src/ApiConnectors/OfficeApiConnector.php +++ b/src/ApiConnectors/OfficeApiConnector.php @@ -7,7 +7,7 @@ use PhpTwinfield\Office; use PhpTwinfield\Services\FinderService; use PhpTwinfield\Request as Request; -use PhpTwinfield\Request\Catalog as RequestDocument; +use PhpTwinfield\Request\Catalog\Catalog as RequestDocument; /** * A facade to make interaction with the the Twinfield service easier when trying to retrieve or send information about diff --git a/src/ApiConnectors/PayCodeApiConnector.php b/src/ApiConnectors/PayCodeApiConnector.php index 4d78fcaa..84938793 100644 --- a/src/ApiConnectors/PayCodeApiConnector.php +++ b/src/ApiConnectors/PayCodeApiConnector.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\ApiConnectors; use PhpTwinfield\Exception; +use PhpTwinfield\PayCode; use PhpTwinfield\Services\FinderService; /** diff --git a/src/ApiConnectors/SupplierApiConnector.php b/src/ApiConnectors/SupplierApiConnector.php index 5dc8606d..adb2fab7 100644 --- a/src/ApiConnectors/SupplierApiConnector.php +++ b/src/ApiConnectors/SupplierApiConnector.php @@ -57,7 +57,7 @@ public function get(string $code, Office $office): Supplier */ public function send(Supplier $supplier): Supplier { - foreach($this->sendAll([$fixedAsset]) as $each) { + foreach($this->sendAll([$supplier]) as $each) { return $each->unwrap(); } } diff --git a/src/ApiConnectors/UserRoleApiConnector.php b/src/ApiConnectors/UserRoleApiConnector.php index 48c05c2f..9e72ede0 100644 --- a/src/ApiConnectors/UserRoleApiConnector.php +++ b/src/ApiConnectors/UserRoleApiConnector.php @@ -4,10 +4,11 @@ use PhpTwinfield\Exception; use PhpTwinfield\Services\FinderService; +use PhpTwinfield\UserRole; /** * A facade to make interaction with the the Twinfield service easier when trying to retrieve or send information about - * UserRoles. + * UserRole. * * If you require more complex interactions or a heavier amount of control over the requests to/from then look inside * the methods or see the advanced guide detailing the required usages. @@ -29,7 +30,7 @@ class UserRoleApiConnector extends BaseApiConnector * to add multiple options. An option name may be used once, specifying an option multiple * times will cause an error. * - * @return UserRoles[] The user roles found. + * @return UserRole[] The user roles found. */ public function listAll( string $pattern = '*', diff --git a/src/ApiConnectors/VatGroupApiConnector.php b/src/ApiConnectors/VatGroupApiConnector.php index b2326e69..3a9d802c 100644 --- a/src/ApiConnectors/VatGroupApiConnector.php +++ b/src/ApiConnectors/VatGroupApiConnector.php @@ -4,6 +4,7 @@ use PhpTwinfield\Exception; use PhpTwinfield\Services\FinderService; +use PhpTwinfield\VatGroup; /** * A facade to make interaction with the the Twinfield service easier when trying to retrieve or send information about From 4f4526a3ecd3683797914ea96b0e108c04af0f53 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:04:08 +0200 Subject: [PATCH 082/388] Add files via upload --- src/DomDocuments/UsersDocument.php | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/DomDocuments/UsersDocument.php diff --git a/src/DomDocuments/UsersDocument.php b/src/DomDocuments/UsersDocument.php new file mode 100644 index 00000000..99c6ff97 --- /dev/null +++ b/src/DomDocuments/UsersDocument.php @@ -0,0 +1,49 @@ + + */ +class UsersDocument extends BaseDocument +{ + final protected function getRootTagName(): string + { + return "users"; + } + + /** + * Turns a passed User class into the required markup for interacting + * with Twinfield. + * + * This method doesn't return anything, instead just adds the User to + * this DOMDOcument instance for submission usage. + * + * @access public + * @param User $user + * @return void | [Adds to this instance] + */ + public function addUser(User $user) + { + $userElement = $this->createElement('user'); + $this->rootElement->appendChild($userElement); + + $status = $user->getStatus(); + + if (!empty($status)) { + $userElement->setAttribute('status', $status); + } + + $userElement->appendChild($this->createNodeWithTextContent('code', $user->getCode())); + $userElement->appendChild($this->createNodeWithTextContent('name', $user->getName())); + $userElement->appendChild($this->createNodeWithTextContent('shortname', $user->getShortName())); + } +} From 280be7574b9a35c3f80742bb5ed273e41bef5cb6 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:04:23 +0200 Subject: [PATCH 083/388] Add files via upload --- src/DomDocuments/UsersDocument.php | 49 ++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/DomDocuments/UsersDocument.php diff --git a/src/DomDocuments/UsersDocument.php b/src/DomDocuments/UsersDocument.php new file mode 100644 index 00000000..99c6ff97 --- /dev/null +++ b/src/DomDocuments/UsersDocument.php @@ -0,0 +1,49 @@ + + */ +class UsersDocument extends BaseDocument +{ + final protected function getRootTagName(): string + { + return "users"; + } + + /** + * Turns a passed User class into the required markup for interacting + * with Twinfield. + * + * This method doesn't return anything, instead just adds the User to + * this DOMDOcument instance for submission usage. + * + * @access public + * @param User $user + * @return void | [Adds to this instance] + */ + public function addUser(User $user) + { + $userElement = $this->createElement('user'); + $this->rootElement->appendChild($userElement); + + $status = $user->getStatus(); + + if (!empty($status)) { + $userElement->setAttribute('status', $status); + } + + $userElement->appendChild($this->createNodeWithTextContent('code', $user->getCode())); + $userElement->appendChild($this->createNodeWithTextContent('name', $user->getName())); + $userElement->appendChild($this->createNodeWithTextContent('shortname', $user->getShortName())); + } +} From 21886a013658ffad18f0aba41da1863fe27810d9 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:10:46 +0200 Subject: [PATCH 084/388] Add files via upload --- src/CustomerFinancials.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CustomerFinancials.php b/src/CustomerFinancials.php index 81fb5c4f..c0f1ad52 100644 --- a/src/CustomerFinancials.php +++ b/src/CustomerFinancials.php @@ -61,12 +61,12 @@ public function __construct() public function getCollectMandate(): CustomerCollectMandate { - return $this->collectmandate; + return $this->collectMandate; } - public function setCollectMandate(CustomerCollectMandate $collectmandate) + public function setCollectMandate(CustomerCollectMandate $collectMandate) { - $this->collectmandate = $collectmandate; + $this->collectMandate = $collectMandate; return $this; } From abd8ec9f2fe14a0f0cf5db1a948bfa3d42220fc2 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:11:10 +0200 Subject: [PATCH 085/388] Add files via upload --- src/CustomerFinancials.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CustomerFinancials.php b/src/CustomerFinancials.php index 81fb5c4f..c0f1ad52 100644 --- a/src/CustomerFinancials.php +++ b/src/CustomerFinancials.php @@ -61,12 +61,12 @@ public function __construct() public function getCollectMandate(): CustomerCollectMandate { - return $this->collectmandate; + return $this->collectMandate; } - public function setCollectMandate(CustomerCollectMandate $collectmandate) + public function setCollectMandate(CustomerCollectMandate $collectMandate) { - $this->collectmandate = $collectmandate; + $this->collectMandate = $collectMandate; return $this; } From c79b49840f8f29a3f29b98ebdd4ddab847986fd5 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:11:38 +0200 Subject: [PATCH 086/388] Add files via upload --- src/Request/AssetMethod.php | 4 ++-- src/Request/DimensionGroup.php | 4 ++-- src/Request/DimensionType.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Request/AssetMethod.php b/src/Request/AssetMethod.php index 6e81d070..5d13f405 100644 --- a/src/Request/AssetMethod.php +++ b/src/Request/AssetMethod.php @@ -67,7 +67,7 @@ protected function add($element, $value) * * @access public * @param int $office - * @return \PhpTwinfield\Request + * @return \PhpTwinfield\Request\AssetMethod */ public function setOffice($office) { @@ -80,7 +80,7 @@ public function setOffice($office) * * @access public * @param string $code - * @return \PhpTwinfield\Request + * @return \PhpTwinfield\Request\AssetMethod */ public function setCode($code) { diff --git a/src/Request/DimensionGroup.php b/src/Request/DimensionGroup.php index 4b6bf415..f90fb379 100644 --- a/src/Request/DimensionGroup.php +++ b/src/Request/DimensionGroup.php @@ -67,7 +67,7 @@ protected function add($element, $value) * * @access public * @param int $office - * @return \PhpTwinfield\Request + * @return \PhpTwinfield\Request\DimensionGroup */ public function setOffice($office) { @@ -80,7 +80,7 @@ public function setOffice($office) * * @access public * @param string $code - * @return \PhpTwinfield\Request + * @return \PhpTwinfield\Request\DimensionGroup */ public function setCode($code) { diff --git a/src/Request/DimensionType.php b/src/Request/DimensionType.php index d7e78322..2e18a4ab 100644 --- a/src/Request/DimensionType.php +++ b/src/Request/DimensionType.php @@ -67,7 +67,7 @@ protected function add($element, $value) * * @access public * @param int $office - * @return \PhpTwinfield\Request + * @return \PhpTwinfield\Request\DimensionType */ public function setOffice($office) { @@ -80,7 +80,7 @@ public function setOffice($office) * * @access public * @param string $code - * @return \PhpTwinfield\Request + * @return \PhpTwinfield\Request\DimensionType */ public function setCode($code) { From 4324947d6346f60346ef0201f84ad80b8d1110a2 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:11:58 +0200 Subject: [PATCH 087/388] Add files via upload --- src/Request/AssetMethod.php | 4 ++-- src/Request/DimensionGroup.php | 4 ++-- src/Request/DimensionType.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Request/AssetMethod.php b/src/Request/AssetMethod.php index 6e81d070..5d13f405 100644 --- a/src/Request/AssetMethod.php +++ b/src/Request/AssetMethod.php @@ -67,7 +67,7 @@ protected function add($element, $value) * * @access public * @param int $office - * @return \PhpTwinfield\Request + * @return \PhpTwinfield\Request\AssetMethod */ public function setOffice($office) { @@ -80,7 +80,7 @@ public function setOffice($office) * * @access public * @param string $code - * @return \PhpTwinfield\Request + * @return \PhpTwinfield\Request\AssetMethod */ public function setCode($code) { diff --git a/src/Request/DimensionGroup.php b/src/Request/DimensionGroup.php index 4b6bf415..f90fb379 100644 --- a/src/Request/DimensionGroup.php +++ b/src/Request/DimensionGroup.php @@ -67,7 +67,7 @@ protected function add($element, $value) * * @access public * @param int $office - * @return \PhpTwinfield\Request + * @return \PhpTwinfield\Request\DimensionGroup */ public function setOffice($office) { @@ -80,7 +80,7 @@ public function setOffice($office) * * @access public * @param string $code - * @return \PhpTwinfield\Request + * @return \PhpTwinfield\Request\DimensionGroup */ public function setCode($code) { diff --git a/src/Request/DimensionType.php b/src/Request/DimensionType.php index d7e78322..2e18a4ab 100644 --- a/src/Request/DimensionType.php +++ b/src/Request/DimensionType.php @@ -67,7 +67,7 @@ protected function add($element, $value) * * @access public * @param int $office - * @return \PhpTwinfield\Request + * @return \PhpTwinfield\Request\DimensionType */ public function setOffice($office) { @@ -80,7 +80,7 @@ public function setOffice($office) * * @access public * @param string $code - * @return \PhpTwinfield\Request + * @return \PhpTwinfield\Request\DimensionType */ public function setCode($code) { From 4922946abf40f29e8f3e6097e3aa21223560c0e8 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:12:17 +0200 Subject: [PATCH 088/388] Add files via upload --- src/Request/Read/Read.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Request/Read/Read.php b/src/Request/Read/Read.php index 49a28961..7b2d1bc0 100644 --- a/src/Request/Read/Read.php +++ b/src/Request/Read/Read.php @@ -64,7 +64,7 @@ protected function add($element, $value) * * @access public * @param int $office - * @return \PhpTwinfield\Request\Read + * @return \PhpTwinfield\Request\Read\Read */ public function setOffice($office) { @@ -77,7 +77,7 @@ public function setOffice($office) * * @access public * @param string $code - * @return \PhpTwinfield\Request\Read + * @return \PhpTwinfield\Request\Read\Read */ public function setCode($code) { @@ -90,7 +90,7 @@ public function setCode($code) * * @access public * @param string $dimType - * @return \PhpTwinfield\Request\Read + * @return \PhpTwinfield\Request\Read\Read */ public function setDimType($dimType) { @@ -103,7 +103,7 @@ public function setDimType($dimType) * * @access public * @param string $number - * @return \PhpTwinfield\Request\Read + * @return \PhpTwinfield\Request\Read\Read */ public function setNumber($number) { From ea5b39572bbd9456df4c39f5da603a5de524147a Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:12:33 +0200 Subject: [PATCH 089/388] Add files via upload --- src/Request/Read/Read.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Request/Read/Read.php b/src/Request/Read/Read.php index 49a28961..7b2d1bc0 100644 --- a/src/Request/Read/Read.php +++ b/src/Request/Read/Read.php @@ -64,7 +64,7 @@ protected function add($element, $value) * * @access public * @param int $office - * @return \PhpTwinfield\Request\Read + * @return \PhpTwinfield\Request\Read\Read */ public function setOffice($office) { @@ -77,7 +77,7 @@ public function setOffice($office) * * @access public * @param string $code - * @return \PhpTwinfield\Request\Read + * @return \PhpTwinfield\Request\Read\Read */ public function setCode($code) { @@ -90,7 +90,7 @@ public function setCode($code) * * @access public * @param string $dimType - * @return \PhpTwinfield\Request\Read + * @return \PhpTwinfield\Request\Read\Read */ public function setDimType($dimType) { @@ -103,7 +103,7 @@ public function setDimType($dimType) * * @access public * @param string $number - * @return \PhpTwinfield\Request\Read + * @return \PhpTwinfield\Request\Read\Read */ public function setNumber($number) { From 6994681a62f2e794935f02655c9ac585932d79e7 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:12:53 +0200 Subject: [PATCH 090/388] Add files via upload --- src/Fields/Rate/RateTypeField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Fields/Rate/RateTypeField.php b/src/Fields/Rate/RateTypeField.php index 6a05f17d..8cb95007 100644 --- a/src/Fields/Rate/RateTypeField.php +++ b/src/Fields/Rate/RateTypeField.php @@ -10,7 +10,7 @@ trait RateTypeField * Rate type field * Used by: Rate * - * @var type|null + * @var RateType|null */ private $type; From a45f044ae79af6439195a6bcfb5a579ca5d53251 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:13:13 +0200 Subject: [PATCH 091/388] Add files via upload --- src/Fields/Rate/RateTypeField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Fields/Rate/RateTypeField.php b/src/Fields/Rate/RateTypeField.php index 6a05f17d..8cb95007 100644 --- a/src/Fields/Rate/RateTypeField.php +++ b/src/Fields/Rate/RateTypeField.php @@ -10,7 +10,7 @@ trait RateTypeField * Rate type field * Used by: Rate * - * @var type|null + * @var RateType|null */ private $type; From 3388a484a2dcd6aa588c493aa71daa1afa632cc7 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:13:33 +0200 Subject: [PATCH 092/388] Add files via upload --- src/Fields/VatCode/VatCodeTypeField.php | 2 +- src/Fields/VatCode/VatGroupCountryField.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Fields/VatCode/VatCodeTypeField.php b/src/Fields/VatCode/VatCodeTypeField.php index c6e6ac51..a77ba16e 100644 --- a/src/Fields/VatCode/VatCodeTypeField.php +++ b/src/Fields/VatCode/VatCodeTypeField.php @@ -10,7 +10,7 @@ trait VatCodeTypeField * VAT code type field * Used by: VatCode * - * @var type|null + * @var VatType|null */ private $type; diff --git a/src/Fields/VatCode/VatGroupCountryField.php b/src/Fields/VatCode/VatGroupCountryField.php index e1d5cc65..85813667 100644 --- a/src/Fields/VatCode/VatGroupCountryField.php +++ b/src/Fields/VatCode/VatGroupCountryField.php @@ -13,7 +13,7 @@ trait VatGroupCountryField { /** - * @var VatGroupCountry|null + * @var Country|null */ private $groupCountry; From 15fe15fe89e2ceb3d3be48d8d09784233ac71c39 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:13:52 +0200 Subject: [PATCH 093/388] Add files via upload --- src/Fields/VatCode/VatCodeTypeField.php | 2 +- src/Fields/VatCode/VatGroupCountryField.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Fields/VatCode/VatCodeTypeField.php b/src/Fields/VatCode/VatCodeTypeField.php index c6e6ac51..a77ba16e 100644 --- a/src/Fields/VatCode/VatCodeTypeField.php +++ b/src/Fields/VatCode/VatCodeTypeField.php @@ -10,7 +10,7 @@ trait VatCodeTypeField * VAT code type field * Used by: VatCode * - * @var type|null + * @var VatType|null */ private $type; diff --git a/src/Fields/VatCode/VatGroupCountryField.php b/src/Fields/VatCode/VatGroupCountryField.php index e1d5cc65..85813667 100644 --- a/src/Fields/VatCode/VatGroupCountryField.php +++ b/src/Fields/VatCode/VatGroupCountryField.php @@ -13,7 +13,7 @@ trait VatGroupCountryField { /** - * @var VatGroupCountry|null + * @var Country|null */ private $groupCountry; From fdceb0e79b32e66547991ecefca34bbce5c5b5f1 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:14:07 +0200 Subject: [PATCH 094/388] Add files via upload --- src/Fields/Invoice/FinancialCodeField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Fields/Invoice/FinancialCodeField.php b/src/Fields/Invoice/FinancialCodeField.php index 9f362e93..44888729 100644 --- a/src/Fields/Invoice/FinancialCodeField.php +++ b/src/Fields/Invoice/FinancialCodeField.php @@ -17,7 +17,7 @@ trait FinancialCodeField */ public function getFinancialCode(): ?string { - return $this->code; + return $this->financialCode; } /** From 2f775b567b7149b662bc3a332cafaf8305675d20 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:14:22 +0200 Subject: [PATCH 095/388] Add files via upload --- src/Fields/Invoice/FinancialCodeField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Fields/Invoice/FinancialCodeField.php b/src/Fields/Invoice/FinancialCodeField.php index 9f362e93..44888729 100644 --- a/src/Fields/Invoice/FinancialCodeField.php +++ b/src/Fields/Invoice/FinancialCodeField.php @@ -17,7 +17,7 @@ trait FinancialCodeField */ public function getFinancialCode(): ?string { - return $this->code; + return $this->financialCode; } /** From 675bc181531e1426559fc08175f192a70e83f997 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:14:41 +0200 Subject: [PATCH 096/388] Add files via upload --- .../Level1234/Level34/FixedAsset/FixedAssetsStatusField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusField.php b/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusField.php index 8640b99c..107f4736 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusField.php +++ b/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusField.php @@ -16,7 +16,7 @@ trait FixedAssetsStatusField public function getStatus(): ?FixedAssetsStatus { - return $this->fixedAssetsStatus; + return $this->status; } /** From 61eb13fa6c5896382fd82827c19bda5bc4ac038e Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:14:58 +0200 Subject: [PATCH 097/388] Add files via upload --- .../Level1234/Level34/FixedAsset/FixedAssetsStatusField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusField.php b/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusField.php index 8640b99c..107f4736 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusField.php +++ b/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusField.php @@ -16,7 +16,7 @@ trait FixedAssetsStatusField public function getStatus(): ?FixedAssetsStatus { - return $this->fixedAssetsStatus; + return $this->status; } /** From 40ad801f75cd68209b64ed9bbadc62016a0db265 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:22:20 +0200 Subject: [PATCH 098/388] Add files via upload --- src/Request/Catalog/Office.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/Request/Catalog/Office.php diff --git a/src/Request/Catalog/Office.php b/src/Request/Catalog/Office.php new file mode 100644 index 00000000..14035f5b --- /dev/null +++ b/src/Request/Catalog/Office.php @@ -0,0 +1,27 @@ + + * @copyright (c) 2013, Pronamic + * @version 0.0.1 + */ +class Office extends Catalog +{ + /** + * Adds the only required element for this request. + * + * No other methods exist or are required, + * + * @access public + */ + public function __construct() + { + parent::__construct(); + $this->add('type', 'offices'); + } +} \ No newline at end of file From e1b0116368fbf0443014cca80d9e88d4833f571b Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:22:35 +0200 Subject: [PATCH 099/388] Add files via upload --- src/Request/Catalog/Office.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/Request/Catalog/Office.php diff --git a/src/Request/Catalog/Office.php b/src/Request/Catalog/Office.php new file mode 100644 index 00000000..14035f5b --- /dev/null +++ b/src/Request/Catalog/Office.php @@ -0,0 +1,27 @@ + + * @copyright (c) 2013, Pronamic + * @version 0.0.1 + */ +class Office extends Catalog +{ + /** + * Adds the only required element for this request. + * + * No other methods exist or are required, + * + * @access public + */ + public function __construct() + { + parent::__construct(); + $this->add('type', 'offices'); + } +} \ No newline at end of file From dcf50f03e1b7f3537a4404b2faa2f74ca274fa28 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:22:46 +0200 Subject: [PATCH 100/388] Add files via upload --- src/ApiConnectors/OfficeApiConnector.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ApiConnectors/OfficeApiConnector.php b/src/ApiConnectors/OfficeApiConnector.php index 0ad1ab8b..cc7be08b 100644 --- a/src/ApiConnectors/OfficeApiConnector.php +++ b/src/ApiConnectors/OfficeApiConnector.php @@ -7,7 +7,7 @@ use PhpTwinfield\Office; use PhpTwinfield\Services\FinderService; use PhpTwinfield\Request as Request; -use PhpTwinfield\Request\Catalog\Catalog as RequestDocument; +use PhpTwinfield\Request\Catalog\Office as OfficeRequestDocument; /** * A facade to make interaction with the the Twinfield service easier when trying to retrieve or send information about @@ -52,8 +52,7 @@ public function get(string $code): Office public function listAllWithoutOfficeCode(): array { $offices = []; - $document = new RequestDocument(); - $document->add('type', 'offices'); + $document = new OfficeRequestDocument(); $response = $this->getProcessXmlService()->sendDocument($document); $response->assertSuccessful(); From 999491cd9aabaefbb3d4892ff95ae8b2b2f2a592 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:22:59 +0200 Subject: [PATCH 101/388] Add files via upload --- src/ApiConnectors/OfficeApiConnector.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ApiConnectors/OfficeApiConnector.php b/src/ApiConnectors/OfficeApiConnector.php index 0ad1ab8b..cc7be08b 100644 --- a/src/ApiConnectors/OfficeApiConnector.php +++ b/src/ApiConnectors/OfficeApiConnector.php @@ -7,7 +7,7 @@ use PhpTwinfield\Office; use PhpTwinfield\Services\FinderService; use PhpTwinfield\Request as Request; -use PhpTwinfield\Request\Catalog\Catalog as RequestDocument; +use PhpTwinfield\Request\Catalog\Office as OfficeRequestDocument; /** * A facade to make interaction with the the Twinfield service easier when trying to retrieve or send information about @@ -52,8 +52,7 @@ public function get(string $code): Office public function listAllWithoutOfficeCode(): array { $offices = []; - $document = new RequestDocument(); - $document->add('type', 'offices'); + $document = new OfficeRequestDocument(); $response = $this->getProcessXmlService()->sendDocument($document); $response->assertSuccessful(); From 8963c082c24519f9def754451e8ef4639862f979 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:23:50 +0200 Subject: [PATCH 102/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index b296984e..3649cca9 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -57,8 +57,8 @@ public function testGetConceptInvoiceWorks() $this->assertSame('1000', $invoice->getCustomerToCode()); $this->assertSame('2012/8', $invoice->getPeriod()); $this->assertSame('EUR', $invoice->getCurrencyToCode()); - $this->assertSame(Enums\InvoiceStatus::CONCEPT(), $invoice->getStatus()); - $this->assertSame(Enums\PaymentMethod::CASH(), $invoice->getPaymentMethod()); + $this->assertSame(\PhpTwinfield\Enums\InvoiceStatus::CONCEPT(), $invoice->getStatus()); + $this->assertSame(\PhpTwinfield\Enums\PaymentMethod::CASH(), $invoice->getPaymentMethod()); $invoiceLines = $invoice->getLines(); $this->assertCount(1, $invoiceLines); @@ -112,8 +112,8 @@ public function testGetFinalInvoiceWorks() $this->assertSame('1000', $invoice->getCustomerToCode()); $this->assertSame('2012/8', $invoice->getPeriod()); $this->assertSame('EUR', $invoice->getCurrencyToCode()); - $this->assertSame(Enums\InvoiceStatus::FINAL(), $invoice->getStatus()); - $this->assertSame(Enums\PaymentMethod::CASH(), $invoice->getPaymentMethod()); + $this->assertSame(\PhpTwinfield\Enums\InvoiceStatus::FINAL(), $invoice->getStatus()); + $this->assertSame(\PhpTwinfield\Enums\PaymentMethod::CASH(), $invoice->getPaymentMethod()); $invoiceLines = $invoice->getLines(); $this->assertCount(1, $invoiceLines); From f4d13323ea4a5894f16b4574c8404ec6a25efc14 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:29:17 +0200 Subject: [PATCH 103/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 3649cca9..ad8dd538 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -57,8 +57,8 @@ public function testGetConceptInvoiceWorks() $this->assertSame('1000', $invoice->getCustomerToCode()); $this->assertSame('2012/8', $invoice->getPeriod()); $this->assertSame('EUR', $invoice->getCurrencyToCode()); - $this->assertSame(\PhpTwinfield\Enums\InvoiceStatus::CONCEPT(), $invoice->getStatus()); - $this->assertSame(\PhpTwinfield\Enums\PaymentMethod::CASH(), $invoice->getPaymentMethod()); + $this->assertSame(\PhpTwinfield\Enums\InvoiceStatus::CONCEPT, $invoice->getStatus()); + $this->assertSame(\PhpTwinfield\Enums\PaymentMethod::CASH, $invoice->getPaymentMethod()); $invoiceLines = $invoice->getLines(); $this->assertCount(1, $invoiceLines); @@ -112,8 +112,8 @@ public function testGetFinalInvoiceWorks() $this->assertSame('1000', $invoice->getCustomerToCode()); $this->assertSame('2012/8', $invoice->getPeriod()); $this->assertSame('EUR', $invoice->getCurrencyToCode()); - $this->assertSame(\PhpTwinfield\Enums\InvoiceStatus::FINAL(), $invoice->getStatus()); - $this->assertSame(\PhpTwinfield\Enums\PaymentMethod::CASH(), $invoice->getPaymentMethod()); + $this->assertSame(\PhpTwinfield\Enums\InvoiceStatus::FINAL, $invoice->getStatus()); + $this->assertSame(\PhpTwinfield\Enums\PaymentMethod::CASH, $invoice->getPaymentMethod()); $invoiceLines = $invoice->getLines(); $this->assertCount(1, $invoiceLines); From 0b15ca941072995fc9a8c9119df00a4b4c94a3b5 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:34:40 +0200 Subject: [PATCH 104/388] Update CustomerIntegrationTest.php --- tests/IntegrationTests/CustomerIntegrationTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index b0ad2cbd..1f2a784f 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -11,6 +11,7 @@ use PhpTwinfield\Mappers\CustomerMapper; use PhpTwinfield\Office; use PhpTwinfield\Response\Response; +use PhpTwinfield\Services\FinderService; /** * @covers Customer @@ -64,7 +65,7 @@ public function testGetCustomerWorks() $this->assertSame('VN', $financials->getVatCodeToCode()); // Collect Mandate - $collectMandate = $customer->getCollectMandate(); + $collectMandate = $financials->getCollectMandate(); $this->assertSame('1', $collectMandate->getID()); $this->assertEquals(new \DateTimeImmutable('2018-06-04'), $collectMandate->getSignatureDate()); $this->assertEquals(new \DateTimeImmutable('2018-06-08'), $collectMandate->getFirstRunDate()); From ea608966db5d99eb2f3bcb5aebb28449d6605bb7 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:36:29 +0200 Subject: [PATCH 105/388] Update CustomerIntegrationTest.php --- tests/IntegrationTests/CustomerIntegrationTest.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 1f2a784f..68529059 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -171,9 +171,12 @@ public function testSendCustomerWorks() $customer = new Customer(); $customer->setOffice(Office::fromCode('001')); $customer->setName('Customer 0'); - $customer->setDueDays(30); - $customer->setPayAvailable(true); - $customer->setPayCodeFromCode('SEPANLDD'); + + $financials = new CustomerFinancials(); + $financials->setDueDays(30); + $financials->setPayAvailable(true); + $financials->setPayCodeFromCode('SEPANLDD'); + $customer->setFinancials($financials); $address = new CustomerAddress(); $address->setID('1'); From 525c804a025ba3f5371e7028e41601e6c69ec09d Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:37:12 +0200 Subject: [PATCH 106/388] Update CustomerIntegrationTest.php --- tests/IntegrationTests/CustomerIntegrationTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 68529059..e8f06b2e 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -7,6 +7,7 @@ use PhpTwinfield\CustomerAddress; use PhpTwinfield\CustomerBank; use PhpTwinfield\CustomerCollectMandate; +use PhpTwinfield\CustomerFinancials; use PhpTwinfield\DomDocuments\CustomersDocument; use PhpTwinfield\Mappers\CustomerMapper; use PhpTwinfield\Office; @@ -19,6 +20,7 @@ * @covers CustomerBank * @covers CustomerCollectMandate * @covers CustomerCreditManagement + * @covers CustomerFinancials * @covers CustomersDocument * @covers CustomerMapper * @covers CustomerApiConnector From bfcc7011b2e30db8bc954aafdc63ca7daa8c9b70 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 12:41:32 +0200 Subject: [PATCH 107/388] Update CustomerIntegrationTest.php --- .../CustomerIntegrationTest.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index e8f06b2e..8fdcf413 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -68,7 +68,7 @@ public function testGetCustomerWorks() // Collect Mandate $collectMandate = $financials->getCollectMandate(); - $this->assertSame('1', $collectMandate->getID()); + $this->assertSame(1, $collectMandate->getID()); $this->assertEquals(new \DateTimeImmutable('2018-06-04'), $collectMandate->getSignatureDate()); $this->assertEquals(new \DateTimeImmutable('2018-06-08'), $collectMandate->getFirstRunDate()); @@ -80,7 +80,7 @@ public function testGetCustomerWorks() /** @var CustomerAddress $address */ $address = $addresses['1']; - $this->assertSame('1', $address->getID()); + $this->assertSame(1, $address->getID()); $this->assertSame('invoice', $address->getType()); $this->assertSame(true, $address->getDefault()); $this->assertSame('Customer 0', $address->getName()); @@ -105,7 +105,7 @@ public function testGetCustomerWorks() /** @var CustomerBank $bank */ $bank = $banks['-1']; - $this->assertSame('-1', $bank->getID()); + $this->assertSame(-1, $bank->getID()); $this->assertSame(true, $bank->getDefault()); $this->assertSame('Customer 1', $bank->getAscription()); $this->assertSame('123456789', $bank->getAccountNumber()); @@ -124,17 +124,17 @@ public function testGetCustomerWorks() $this->assertSame('c5027760-476e-4081-85fb-351c983aea54', $customer->getUID()); $this->assertSame('false', $customer->getInUseToString()); $this->assertSame('normal', $customer->getBehaviour()); - $this->assertSame('0', $customer->getTouched()); - $this->assertSame('0', $customer->getBeginPeriod()); - $this->assertSame('0', $customer->getBeginYear()); - $this->assertSame('0', $customer->getEndPeriod()); - $this->assertSame('0', $customer->getEndYear()); + $this->assertSame(0, $customer->getTouched()); + $this->assertSame(0, $customer->getBeginPeriod()); + $this->assertSame(0, $customer->getBeginYear()); + $this->assertSame(0, $customer->getEndPeriod()); + $this->assertSame(0, $customer->getEndYear()); // Creditmanagement $creditmanagement = $customer->getCreditManagement(); $this->assertSame('', $creditmanagement->getResponsibleUserToCode()); - $this->assertSame('0.00', $creditmanagement->getBaseCreditLimitToFloat()); + $this->assertSame(0.00, $creditmanagement->getBaseCreditLimitToFloat()); $this->assertSame(true, $creditmanagement->getSendReminder()); $this->assertSame('', $creditmanagement->getReminderEmail()); $this->assertSame(false, $creditmanagement->getBlocked()); From cc86bb8acf7b5b3db5d7d01b721c6040b98983d5 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 13:20:03 +0200 Subject: [PATCH 108/388] Update CustomerIntegrationTest.php --- .../IntegrationTests/CustomerIntegrationTest.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 8fdcf413..6e407562 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -12,7 +12,6 @@ use PhpTwinfield\Mappers\CustomerMapper; use PhpTwinfield\Office; use PhpTwinfield\Response\Response; -use PhpTwinfield\Services\FinderService; /** * @covers Customer @@ -81,7 +80,7 @@ public function testGetCustomerWorks() $address = $addresses['1']; $this->assertSame(1, $address->getID()); - $this->assertSame('invoice', $address->getType()); + $this->assertSame(\PhpTwinfield\Enums\AddressType::INVOICE(), $address->getType()); $this->assertSame(true, $address->getDefault()); $this->assertSame('Customer 0', $address->getName()); $this->assertSame('NL', $address->getCountryToCode()); @@ -148,13 +147,13 @@ public function testListAllCustomersWorks() { $response = Response::fromString(file_get_contents(__DIR__ . '/resources/customerListResponse.xml')); - $this->processXmlService + $this->finderService ->expects($this->once()) - ->method("sendDocument") - ->with($this->isInstanceOf(\PhpTwinfield\Request\Catalog\Dimension::class)) + ->method("searchFinder") + ->with($this->isInstanceOf(\PhpTwinfield\Customer::class)) ->willReturn($response); - $customers = $this->customerApiConnector->listAll($this->office); + $customers = $this->customerApiConnector->listAll(); $this->assertCount(3, $customers); @@ -181,7 +180,7 @@ public function testSendCustomerWorks() $customer->setFinancials($financials); $address = new CustomerAddress(); - $address->setID('1'); + $address->setID(1); $address->setTypeFromString('invoice'); $address->setDefault(true); $address->setName('Customer 0'); @@ -213,7 +212,7 @@ public function testSendCustomerWorks() $customer->addBank($bank); $collectMandate = new CustomerCollectMandate(); - $collectMandate->setID('1'); + $collectMandate->setID(1); $collectMandate->setSignatureDateFromString('20180604'); $collectMandate->setFirstRunDateFromString('20180608'); $customer->setCollectMandate($collectMandate); From b249972fb416bb1bf56d433c2f053883eb8e905f Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 13:28:06 +0200 Subject: [PATCH 109/388] Update CustomerIntegrationTest.php --- tests/IntegrationTests/CustomerIntegrationTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 6e407562..ea5a4af0 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -150,7 +150,6 @@ public function testListAllCustomersWorks() $this->finderService ->expects($this->once()) ->method("searchFinder") - ->with($this->isInstanceOf(\PhpTwinfield\Customer::class)) ->willReturn($response); $customers = $this->customerApiConnector->listAll(); From 25ae87b4b42822a1dc71937705b98c22572113a7 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 13:49:54 +0200 Subject: [PATCH 110/388] Update CustomerIntegrationTest.php --- tests/IntegrationTests/CustomerIntegrationTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index ea5a4af0..774cf386 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -150,6 +150,7 @@ public function testListAllCustomersWorks() $this->finderService ->expects($this->once()) ->method("searchFinder") + ->with($this->isInstanceOf(\PhpTwinfield\Response\Response::class)) ->willReturn($response); $customers = $this->customerApiConnector->listAll(); From 1e5021b315a168b75b2e77eb9d4fb8babdcfd236 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 13:50:24 +0200 Subject: [PATCH 111/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index ad8dd538..3649cca9 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -57,8 +57,8 @@ public function testGetConceptInvoiceWorks() $this->assertSame('1000', $invoice->getCustomerToCode()); $this->assertSame('2012/8', $invoice->getPeriod()); $this->assertSame('EUR', $invoice->getCurrencyToCode()); - $this->assertSame(\PhpTwinfield\Enums\InvoiceStatus::CONCEPT, $invoice->getStatus()); - $this->assertSame(\PhpTwinfield\Enums\PaymentMethod::CASH, $invoice->getPaymentMethod()); + $this->assertSame(\PhpTwinfield\Enums\InvoiceStatus::CONCEPT(), $invoice->getStatus()); + $this->assertSame(\PhpTwinfield\Enums\PaymentMethod::CASH(), $invoice->getPaymentMethod()); $invoiceLines = $invoice->getLines(); $this->assertCount(1, $invoiceLines); @@ -112,8 +112,8 @@ public function testGetFinalInvoiceWorks() $this->assertSame('1000', $invoice->getCustomerToCode()); $this->assertSame('2012/8', $invoice->getPeriod()); $this->assertSame('EUR', $invoice->getCurrencyToCode()); - $this->assertSame(\PhpTwinfield\Enums\InvoiceStatus::FINAL, $invoice->getStatus()); - $this->assertSame(\PhpTwinfield\Enums\PaymentMethod::CASH, $invoice->getPaymentMethod()); + $this->assertSame(\PhpTwinfield\Enums\InvoiceStatus::FINAL(), $invoice->getStatus()); + $this->assertSame(\PhpTwinfield\Enums\PaymentMethod::CASH(), $invoice->getPaymentMethod()); $invoiceLines = $invoice->getLines(); $this->assertCount(1, $invoiceLines); From 1cc0345d0d828aeaa5416d336d83e87fde6fe6ae Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 14:07:45 +0200 Subject: [PATCH 112/388] Update CustomerIntegrationTest.php --- tests/IntegrationTests/CustomerIntegrationTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 774cf386..48dbc3b4 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -199,8 +199,8 @@ public function testSendCustomerWorks() $bank->setDefault(true); $bank->setAscription('Customer 1'); $bank->setAccountNumber('123456789'); - $bank->setAddressField2(''); - $bank->setAddressField3(''); + $bank->setField2(''); + $bank->setField3(''); $bank->setBankName('ABN Amro'); $bank->setBicCode('ABNANL2A'); $bank->setCity('Place'); From 7dcdc24b7c00f895ee1d0814bfaace450214409d Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 14:09:43 +0200 Subject: [PATCH 113/388] Update BaseApiConnector.php --- src/ApiConnectors/BaseApiConnector.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ApiConnectors/BaseApiConnector.php b/src/ApiConnectors/BaseApiConnector.php index 7d1be143..dea8f536 100644 --- a/src/ApiConnectors/BaseApiConnector.php +++ b/src/ApiConnectors/BaseApiConnector.php @@ -180,10 +180,12 @@ public function convertOptionsToArrayOfString(array $options, array $forcedOptio return $options; } else { $optionsArrayOfString = array('ArrayOfString' => array()); - - foreach ($forcedOptions as $key => $value) { - unset($options[$key]); - $optionsArrayOfString['ArrayOfString'][] = array($key, $value); + + if (isset($forcedOptions)) { + foreach ($forcedOptions as $key => $value) { + unset($options[$key]); + $optionsArrayOfString['ArrayOfString'][] = array($key, $value); + } } foreach ($options as $key => $value) { @@ -230,4 +232,4 @@ public function mapListAll(string $className, object $data, array $objectListAll return $objects; } -} \ No newline at end of file +} From 558179e28a6a029acc5962c7a04e66e46220b71e Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 14:09:53 +0200 Subject: [PATCH 114/388] Update BaseApiConnector.php --- src/ApiConnectors/BaseApiConnector.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ApiConnectors/BaseApiConnector.php b/src/ApiConnectors/BaseApiConnector.php index 7d1be143..dea8f536 100644 --- a/src/ApiConnectors/BaseApiConnector.php +++ b/src/ApiConnectors/BaseApiConnector.php @@ -180,10 +180,12 @@ public function convertOptionsToArrayOfString(array $options, array $forcedOptio return $options; } else { $optionsArrayOfString = array('ArrayOfString' => array()); - - foreach ($forcedOptions as $key => $value) { - unset($options[$key]); - $optionsArrayOfString['ArrayOfString'][] = array($key, $value); + + if (isset($forcedOptions)) { + foreach ($forcedOptions as $key => $value) { + unset($options[$key]); + $optionsArrayOfString['ArrayOfString'][] = array($key, $value); + } } foreach ($options as $key => $value) { @@ -230,4 +232,4 @@ public function mapListAll(string $className, object $data, array $objectListAll return $objects; } -} \ No newline at end of file +} From 0815216f1bc754b8aa10c81f1c824acc30561bdc Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 14:16:07 +0200 Subject: [PATCH 115/388] Update OfficeTest.php --- tests/UnitTests/Supplier/OfficeTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/UnitTests/Supplier/OfficeTest.php b/tests/UnitTests/Supplier/OfficeTest.php index 1501c1fe..419d5c79 100644 --- a/tests/UnitTests/Supplier/OfficeTest.php +++ b/tests/UnitTests/Supplier/OfficeTest.php @@ -51,6 +51,6 @@ public function testSetOfficeAndSerializes(Supplier $customer) $xpath = new \DOMXPath($document); - $this->assertEquals($xpath->query('/dimension/office')->item(0)->nodeValue, $this->office); + $this->assertEquals($xpath->query('/office')->item(0)->nodeValue, $this->office); } } From 6ab95f7c3116d5906360499cc10eef164648cbe4 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 20:18:03 +0200 Subject: [PATCH 116/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 3649cca9..483ee382 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -57,7 +57,8 @@ public function testGetConceptInvoiceWorks() $this->assertSame('1000', $invoice->getCustomerToCode()); $this->assertSame('2012/8', $invoice->getPeriod()); $this->assertSame('EUR', $invoice->getCurrencyToCode()); - $this->assertSame(\PhpTwinfield\Enums\InvoiceStatus::CONCEPT(), $invoice->getStatus()); + $ReflectObject = new ReflectionClass('\PhpTwinfield\Enums\InvoiceStatus'); + $this->assertSame($ReflectObject->getConstant('CONCEPT'), $invoice->getStatus()); $this->assertSame(\PhpTwinfield\Enums\PaymentMethod::CASH(), $invoice->getPaymentMethod()); $invoiceLines = $invoice->getLines(); From 38bc2e9c918dbbb729ecc27920f310ed840215e7 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 20:21:07 +0200 Subject: [PATCH 117/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 483ee382..71d634cb 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -57,7 +57,7 @@ public function testGetConceptInvoiceWorks() $this->assertSame('1000', $invoice->getCustomerToCode()); $this->assertSame('2012/8', $invoice->getPeriod()); $this->assertSame('EUR', $invoice->getCurrencyToCode()); - $ReflectObject = new ReflectionClass('\PhpTwinfield\Enums\InvoiceStatus'); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\InvoiceStatus'); $this->assertSame($ReflectObject->getConstant('CONCEPT'), $invoice->getStatus()); $this->assertSame(\PhpTwinfield\Enums\PaymentMethod::CASH(), $invoice->getPaymentMethod()); From f0fd1cefe54233b86680949d5ac4bfe078f6362f Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 20:29:55 +0200 Subject: [PATCH 118/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 71d634cb..06515b21 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -58,8 +58,8 @@ public function testGetConceptInvoiceWorks() $this->assertSame('2012/8', $invoice->getPeriod()); $this->assertSame('EUR', $invoice->getCurrencyToCode()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\InvoiceStatus'); - $this->assertSame($ReflectObject->getConstant('CONCEPT'), $invoice->getStatus()); - $this->assertSame(\PhpTwinfield\Enums\PaymentMethod::CASH(), $invoice->getPaymentMethod()); + $this->assertSame($ReflectObject->getConstant('CONCEPT'), (string)$invoice->getStatus()); + $this->assertSame(\PhpTwinfield\Enums\PaymentMethod::CASH(), (string)$invoice->getPaymentMethod()); $invoiceLines = $invoice->getLines(); $this->assertCount(1, $invoiceLines); From e2dd73e9a7cda81263474a0aed8ac5c6ed04edeb Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 20:36:04 +0200 Subject: [PATCH 119/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 06515b21..c17df993 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -59,7 +59,8 @@ public function testGetConceptInvoiceWorks() $this->assertSame('EUR', $invoice->getCurrencyToCode()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\InvoiceStatus'); $this->assertSame($ReflectObject->getConstant('CONCEPT'), (string)$invoice->getStatus()); - $this->assertSame(\PhpTwinfield\Enums\PaymentMethod::CASH(), (string)$invoice->getPaymentMethod()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PaymentMethod'); + $this->assertSame($ReflectObject->getConstant('CASH'), (string)$invoice->getPaymentMethod()); $invoiceLines = $invoice->getLines(); $this->assertCount(1, $invoiceLines); From a9bba1f3c7e2c1f4884a205f0b2ad3d9e449dce8 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 20:44:05 +0200 Subject: [PATCH 120/388] Update invoiceConceptGetResponse.xml --- .../resources/invoiceConceptGetResponse.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/IntegrationTests/resources/invoiceConceptGetResponse.xml b/tests/IntegrationTests/resources/invoiceConceptGetResponse.xml index 2a490e88..bf499baa 100644 --- a/tests/IntegrationTests/resources/invoiceConceptGetResponse.xml +++ b/tests/IntegrationTests/resources/invoiceConceptGetResponse.xml @@ -14,8 +14,8 @@ EUR concept cash - - + HEADER + FOOTER @@ -40,7 +40,8 @@ VN 0.00 - + + From ffd6d2b1970a82e365f8a755527ca313c3a834b5 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 20:44:40 +0200 Subject: [PATCH 121/388] Update invoiceFinalGetResponse.xml --- .../IntegrationTests/resources/invoiceFinalGetResponse.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/IntegrationTests/resources/invoiceFinalGetResponse.xml b/tests/IntegrationTests/resources/invoiceFinalGetResponse.xml index 3fd4cf55..357f8214 100644 --- a/tests/IntegrationTests/resources/invoiceFinalGetResponse.xml +++ b/tests/IntegrationTests/resources/invoiceFinalGetResponse.xml @@ -14,8 +14,8 @@ EUR final cash - - + HEADER + FOOTER @@ -40,7 +40,8 @@ VN 0.00 - + + From 5436b393a55cbbb40c91ea07b4c7f4db4f9106cb Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 20:47:31 +0200 Subject: [PATCH 122/388] Update InvoiceIntegrationTest.php --- .../InvoiceIntegrationTest.php | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index c17df993..f2ac2da3 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -8,6 +8,7 @@ use PhpTwinfield\Invoice; use PhpTwinfield\InvoiceLine; use PhpTwinfield\InvoiceTotals; +use PhpTwinfield\InvoiceVatLine; use PhpTwinfield\Mappers\InvoiceMapper; use PhpTwinfield\Office; use PhpTwinfield\Response\Response; @@ -16,6 +17,7 @@ * @covers Invoice * @covers InvoiceLine * @covers InvoiceTotals + * @covers InvoiceVatLine * @covers InvoicesDocument * @covers InvoiceMapper * @covers InvoiceApiConnector @@ -61,6 +63,8 @@ public function testGetConceptInvoiceWorks() $this->assertSame($ReflectObject->getConstant('CONCEPT'), (string)$invoice->getStatus()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PaymentMethod'); $this->assertSame($ReflectObject->getConstant('CASH'), (string)$invoice->getPaymentMethod()); + $this->assertSame('HEADER', $invoice->getHeaderText()); + $this->assertSame('FOOTER', $invoice->getFooterText()); $invoiceLines = $invoice->getLines(); $this->assertCount(1, $invoiceLines); @@ -74,7 +78,7 @@ public function testGetConceptInvoiceWorks() $this->assertSame('118', $invoiceLine->getSubArticleToSubCode()); $this->assertSame(1, $invoiceLine->getQuantity()); $this->assertSame(1, $invoiceLine->getUnits()); - $this->assertSame('true', $invoiceLine->getAllowDiscountOrPremiumToString()); + $this->assertSame(true, $invoiceLine->getAllowDiscountOrPremium()); $this->assertSame('CoalesceFunctioningOnImpatienceTShirt', $invoiceLine->getDescription()); $this->assertSame(15.00, $invoiceLine->getValueExclToFloat()); $this->assertSame(0.00, $invoiceLine->getVatValueToFloat()); @@ -82,7 +86,17 @@ public function testGetConceptInvoiceWorks() $this->assertSame(15.00, $invoiceLine->getUnitsPriceExclToFloat()); $this->assertSame('8020', $invoiceLine->getDim1ToCode()); - // TODO - Vat lines + $invoiceVatLines = $invoice->getVatLines(); + $this->assertCount(1, $invoiceVatLines); + $this->assertArrayHasKey('1', $invoiceVatLines); + + /** @var InvoiceVatLine $invoiceVatLine */ + $invoiceVatLine = $invoiceVatLines['1']; + + $this->assertSame('VN', $invoiceLine->getVatCodeToCode()); + $this->assertSame(0.00, $invoiceLine->getVatValueToFloat()); + $this->assertNull($invoiceLine->getPerformanceType()); + $this->assertNull($invoiceLine->getPerformanceDateToString()); $this->assertSame(15.00, $invoice->getTotals()->getValueIncToFloat()); $this->assertSame(15.00, $invoice->getTotals()->getValueExclToFloat()); @@ -114,8 +128,12 @@ public function testGetFinalInvoiceWorks() $this->assertSame('1000', $invoice->getCustomerToCode()); $this->assertSame('2012/8', $invoice->getPeriod()); $this->assertSame('EUR', $invoice->getCurrencyToCode()); - $this->assertSame(\PhpTwinfield\Enums\InvoiceStatus::FINAL(), $invoice->getStatus()); - $this->assertSame(\PhpTwinfield\Enums\PaymentMethod::CASH(), $invoice->getPaymentMethod()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\InvoiceStatus'); + $this->assertSame($ReflectObject->getConstant('FINAL'), (string)$invoice->getStatus()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PaymentMethod'); + $this->assertSame($ReflectObject->getConstant('CASH'), (string)$invoice->getPaymentMethod()); + $this->assertSame('HEADER', $invoice->getHeaderText()); + $this->assertSame('FOOTER', $invoice->getFooterText()); $invoiceLines = $invoice->getLines(); $this->assertCount(1, $invoiceLines); @@ -129,7 +147,7 @@ public function testGetFinalInvoiceWorks() $this->assertSame('118', $invoiceLine->getSubArticleToSubCode()); $this->assertSame(1, $invoiceLine->getQuantity()); $this->assertSame(1, $invoiceLine->getUnits()); - $this->assertSame('true', $invoiceLine->getAllowDiscountOrPremiumToString()); + $this->assertSame(true, $invoiceLine->getAllowDiscountOrPremium()); $this->assertSame('CoalesceFunctioningOnImpatienceTShirt', $invoiceLine->getDescription()); $this->assertSame(15.00, $invoiceLine->getValueExclToFloat()); $this->assertSame(0.00, $invoiceLine->getVatValueToFloat()); @@ -137,7 +155,17 @@ public function testGetFinalInvoiceWorks() $this->assertSame(15.00, $invoiceLine->getUnitsPriceExclToFloat()); $this->assertSame('8020', $invoiceLine->getDim1ToCode()); - // TODO - Vat lines + $invoiceVatLines = $invoice->getVatLines(); + $this->assertCount(1, $invoiceVatLines); + $this->assertArrayHasKey('1', $invoiceVatLines); + + /** @var InvoiceVatLine $invoiceVatLine */ + $invoiceVatLine = $invoiceVatLines['1']; + + $this->assertSame('VN', $invoiceLine->getVatCodeToCode()); + $this->assertSame(0.00, $invoiceLine->getVatValueToFloat()); + $this->assertNull($invoiceLine->getPerformanceType()); + $this->assertNull($invoiceLine->getPerformanceDateToString()); $this->assertSame(15.00, $invoice->getTotals()->getValueIncToFloat()); $this->assertSame(15.00, $invoice->getTotals()->getValueExclToFloat()); @@ -164,6 +192,8 @@ public function testSendInvoiceWorks() $invoice->setCurrencyFromCode('EUR'); $invoice->setStatusFromString('concept'); $invoice->setPaymentMethodFromString('cash'); + $invoice->setHeaderText('HEADER'); + $invoice->setFooterText('FOOTER'); $invoiceLine = new InvoiceLine(); $invoiceLine->setID(1); From d478078a4656140d3ec5f083e58b64af28c25276 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 20:49:13 +0200 Subject: [PATCH 123/388] Update invoiceSendRequest.xml --- tests/IntegrationTests/resources/invoiceSendRequest.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/IntegrationTests/resources/invoiceSendRequest.xml b/tests/IntegrationTests/resources/invoiceSendRequest.xml index 06ef0277..188e78df 100644 --- a/tests/IntegrationTests/resources/invoiceSendRequest.xml +++ b/tests/IntegrationTests/resources/invoiceSendRequest.xml @@ -13,6 +13,8 @@ BNK 1 1 + HEADER + FOOTER From f4e3a6576b99f465b2e60fc2b70950b973a24cdb Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 20:49:21 +0200 Subject: [PATCH 124/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index f2ac2da3..37b2c6e1 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -211,11 +211,6 @@ public function testSendInvoiceWorks() $invoiceLine->setVatCodeFromCode('VN'); $invoice->addLine($invoiceLine); - $totals = new InvoiceTotals(); - $totals->setValueExclFromFloat(15.00); - $totals->setValueIncFromFloat(15.00); - $invoice->setTotals($totals); - $this->processXmlService ->expects($this->once()) ->method("sendDocument") From ffb39cfe1f802f75d1272f55b712316feca4b3e7 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 20:51:59 +0200 Subject: [PATCH 125/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 37b2c6e1..bdd3b2ac 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -88,7 +88,6 @@ public function testGetConceptInvoiceWorks() $invoiceVatLines = $invoice->getVatLines(); $this->assertCount(1, $invoiceVatLines); - $this->assertArrayHasKey('1', $invoiceVatLines); /** @var InvoiceVatLine $invoiceVatLine */ $invoiceVatLine = $invoiceVatLines['1']; @@ -137,7 +136,6 @@ public function testGetFinalInvoiceWorks() $invoiceLines = $invoice->getLines(); $this->assertCount(1, $invoiceLines); - $this->assertArrayHasKey('1', $invoiceLines); /** @var InvoiceLine $invoiceLine */ $invoiceLine = $invoiceLines['1']; From 1984b5cd02455ab019de8b76a9bc3cfd83d244e0 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 20:52:26 +0200 Subject: [PATCH 126/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index bdd3b2ac..281ea451 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -136,6 +136,7 @@ public function testGetFinalInvoiceWorks() $invoiceLines = $invoice->getLines(); $this->assertCount(1, $invoiceLines); + $this->assertArrayHasKey('1', $invoiceLines); /** @var InvoiceLine $invoiceLine */ $invoiceLine = $invoiceLines['1']; @@ -155,7 +156,6 @@ public function testGetFinalInvoiceWorks() $invoiceVatLines = $invoice->getVatLines(); $this->assertCount(1, $invoiceVatLines); - $this->assertArrayHasKey('1', $invoiceVatLines); /** @var InvoiceVatLine $invoiceVatLine */ $invoiceVatLine = $invoiceVatLines['1']; From 28a7fc8c6943ac4ca59a5e12d64ab6fae323fe95 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 20:52:40 +0200 Subject: [PATCH 127/388] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6852b0c8..15c0454d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: php dist: trusty php: -- 7.2 +- 7.1 matrix: fast_finish: true From 86ec46d5366265d28ae34ddba5baf4a82a21d18b Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 20:57:34 +0200 Subject: [PATCH 128/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 281ea451..18001672 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -90,7 +90,7 @@ public function testGetConceptInvoiceWorks() $this->assertCount(1, $invoiceVatLines); /** @var InvoiceVatLine $invoiceVatLine */ - $invoiceVatLine = $invoiceVatLines['1']; + $invoiceVatLine = current($invoiceVatLines); $this->assertSame('VN', $invoiceLine->getVatCodeToCode()); $this->assertSame(0.00, $invoiceLine->getVatValueToFloat()); @@ -158,7 +158,7 @@ public function testGetFinalInvoiceWorks() $this->assertCount(1, $invoiceVatLines); /** @var InvoiceVatLine $invoiceVatLine */ - $invoiceVatLine = $invoiceVatLines['1']; + $invoiceVatLine = current($invoiceVatLines); $this->assertSame('VN', $invoiceLine->getVatCodeToCode()); $this->assertSame(0.00, $invoiceLine->getVatValueToFloat()); From 77cd8a8a81afd33b782448d60eec45b24a464858 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:00:19 +0200 Subject: [PATCH 129/388] Update CustomerIntegrationTest.php --- tests/IntegrationTests/CustomerIntegrationTest.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 48dbc3b4..d4d7d6f9 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -80,7 +80,8 @@ public function testGetCustomerWorks() $address = $addresses['1']; $this->assertSame(1, $address->getID()); - $this->assertSame(\PhpTwinfield\Enums\AddressType::INVOICE(), $address->getType()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\AddressType'); + $this->assertSame($ReflectObject->getConstant('INVOICE'), (string)$address->getType()); $this->assertSame(true, $address->getDefault()); $this->assertSame('Customer 0', $address->getName()); $this->assertSame('NL', $address->getCountryToCode()); @@ -121,8 +122,9 @@ public function testGetCustomerWorks() $this->assertSame('1097', $customer->getCode()); $this->assertSame('c5027760-476e-4081-85fb-351c983aea54', $customer->getUID()); - $this->assertSame('false', $customer->getInUseToString()); - $this->assertSame('normal', $customer->getBehaviour()); + $this->assertSame(false, $customer->getInUse()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\Behaviour'); + $this->assertSame($ReflectObject->getConstant('NORMAL'), (string)$customer->getBehaviour()); $this->assertSame(0, $customer->getTouched()); $this->assertSame(0, $customer->getBeginPeriod()); $this->assertSame(0, $customer->getBeginYear()); From a949c7a3149073d29b3a8947ce8650a401138dac Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:00:37 +0200 Subject: [PATCH 130/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 18001672..12df1ae0 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -168,8 +168,8 @@ public function testGetFinalInvoiceWorks() $this->assertSame(15.00, $invoice->getTotals()->getValueIncToFloat()); $this->assertSame(15.00, $invoice->getTotals()->getValueExclToFloat()); - $this->assertSame('123456789', $invoice->getFinancialNumber()); - $this->assertSame('123456789', $invoice->getFinancialCode()); + $this->assertSame(123456789, $invoice->getFinancialNumber()); + $this->assertSame(123456789, $invoice->getFinancialCode()); } public function testSendInvoiceWorks() From 3ef3db456819a4ea6d513267c4532f2bab3c7467 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:03:39 +0200 Subject: [PATCH 131/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 12df1ae0..91a7c3f3 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -169,7 +169,7 @@ public function testGetFinalInvoiceWorks() $this->assertSame(15.00, $invoice->getTotals()->getValueExclToFloat()); $this->assertSame(123456789, $invoice->getFinancialNumber()); - $this->assertSame(123456789, $invoice->getFinancialCode()); + $this->assertSame('123456789', $invoice->getFinancialCode()); } public function testSendInvoiceWorks() From dc4f0ed4cb119b8620d1402cb9765d65814a498b Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:04:19 +0200 Subject: [PATCH 132/388] Update CustomerIntegrationTest.php --- tests/IntegrationTests/CustomerIntegrationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index d4d7d6f9..4487b757 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -95,7 +95,7 @@ public function testGetCustomerWorks() $this->assertSame('Streetname part 1 - 2', $address->getField3()); $this->assertSame('NL099887766B01', $address->getField4()); $this->assertSame('99887766', $address->getField5()); - $this->assertSame('', $address->getField6()); + $this->assertNull($address->getField6()); // Banks $banks = $customer->getBanks(); From 50aa80e704b0e6effd68160cd99536b94f75be1c Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:09:08 +0200 Subject: [PATCH 133/388] Update CustomerIntegrationTest.php --- tests/IntegrationTests/CustomerIntegrationTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 4487b757..92764a69 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -114,9 +114,9 @@ public function testGetCustomerWorks() $this->assertSame('Place', $bank->getCity()); $this->assertSame('NL', $bank->getCountryToCode()); $this->assertSame('NL02ABNA0123456789', $bank->getIban()); - $this->assertSame('', $bank->getNatBicCode()); - $this->assertSame('', $bank->getPostcode()); - $this->assertSame('', $bank->getState()); + $this->assertNull($bank->getNatBicCode()); + $this->assertNull($bank->getPostcode()); + $this->assertNull($bank->getState()); $this->assertNull($bank->getAddressField2()); $this->assertNull($bank->getAddressField3()); From d9625745361a9abcd212820ee63b5ea85740d358 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:12:16 +0200 Subject: [PATCH 134/388] Update CustomersDocumentUnitTest.php --- .../CustomersDocumentUnitTest.php | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php index 338fb12c..56fe8668 100644 --- a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php @@ -6,6 +6,7 @@ use PhpTwinfield\CustomerAddress; use PhpTwinfield\CustomerBank; use PhpTwinfield\CustomerCreditManagement; +use PhpTwinfield\CustomerFinancials; use PhpTwinfield\DomDocuments\CustomersDocument; use PhpTwinfield\Office; use PHPUnit\Framework\TestCase; @@ -31,19 +32,21 @@ public function testXmlIsCreatedPerSpec() $customer->setName('Chuck Norris'); $customer->setWebsite('http://example.org'); $customer->setOffice(Office::fromCode("DEV-10000")); - $customer->setStatus('active'); + $customer->setStatusFromString('active'); - $customer->setDueDays(1); - $customer->setPayAvailable(true); - $customer->setPayCode('pay-code'); - $customer->setVatCode('vat-code'); - $customer->setEBilling(true); - $customer->setEBillMail('ebillingmail@mail.com'); + $financials = new CustomerFinancials(); + $financials->setDueDays(1); + $financials->setPayAvailable(true); + $financials->setPayCodeFromCode('pay-code'); + $financials->setVatCodeFromCode('vat-code'); + $financials->setEBilling(true); + $financials->setEBillMail('ebillingmail@mail.com'); + $customer->setFinancials($financials); $customer->setCreditManagement( (new CustomerCreditManagement()) - ->setResponsibleUser('responsible-user') - ->setBaseCreditLimit(50) + ->setResponsibleUserFromCode('responsible-user') + ->setBaseCreditLimitFromFloat(50) ->setSendReminder(true) ->setReminderEmail('reminderemail@mail.com') ->setBlocked(false) @@ -54,14 +57,13 @@ public function testXmlIsCreatedPerSpec() $customer->addAddress( (new CustomerAddress()) ->setDefault(true) - ->setType('invoice') + ->setTypeFromString('invoice') ->setName('My Address') - ->setContact('My Contact') ->setCountry('nl') ->setCity('city') ->setPostcode('postal code') ->setTelephone('phone number') - ->setFax('fax number') + ->setTelefax('fax number') ->setEmail('email@mail.com') ->setField1('field 1') ->setField2('field 2') @@ -74,17 +76,17 @@ public function testXmlIsCreatedPerSpec() (new CustomerBank()) ->setDefault(true) ->setAscription('ascriptor') - ->setAccountnumber('account number') - ->setBankname('bank name') - ->setBiccode('bic code') + ->setAccountNumber('account number') + ->setBankName('bank name') + ->setBicCode('bic code') ->setCity('city') ->setCountry('nl') ->setIban('iban') - ->setNatbiccode('nat-bic') + ->setNatBicCode('nat-bic') ->setPostcode('postcode') ->setState('state') - ->setAddressField2('address 2') - ->setAddressField3('address 3') + ->setField2('address 2') + ->setField3('address 3') ); $this->document->addCustomer($customer); @@ -94,7 +96,7 @@ public function testXmlIsCreatedPerSpec() $customer->setName('Nuck Chorris'); $customer->setWebsite('http://example.org'); $customer->setOffice(Office::fromCode("DEV-00001")); - $customer->setStatus('deleted'); + $customer->setStatusFromString('deleted'); $this->document->addCustomer($customer); @@ -129,7 +131,6 @@ public function testXmlIsCreatedPerSpec()
My Address - My Contact nl city postal code @@ -176,4 +177,4 @@ public function testXmlIsCreatedPerSpec() $this->document->saveXML() ); } -} \ No newline at end of file +} From 60626cca891947a52e40bb0980f72a0b9447a07d Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:13:24 +0200 Subject: [PATCH 135/388] Update CustomerIntegrationTest.php --- tests/IntegrationTests/CustomerIntegrationTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 92764a69..0a6e49b3 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -117,8 +117,8 @@ public function testGetCustomerWorks() $this->assertNull($bank->getNatBicCode()); $this->assertNull($bank->getPostcode()); $this->assertNull($bank->getState()); - $this->assertNull($bank->getAddressField2()); - $this->assertNull($bank->getAddressField3()); + $this->assertNull($bank->getField2()); + $this->assertNull($bank->getField3()); $this->assertSame('1097', $customer->getCode()); $this->assertSame('c5027760-476e-4081-85fb-351c983aea54', $customer->getUID()); From e4eaace322274942e17863cb5d722ccfbb3abbf1 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:17:27 +0200 Subject: [PATCH 136/388] Update CustomerIntegrationTest.php --- tests/IntegrationTests/CustomerIntegrationTest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 0a6e49b3..6e86b8e0 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -134,15 +134,15 @@ public function testGetCustomerWorks() // Creditmanagement $creditmanagement = $customer->getCreditManagement(); - $this->assertSame('', $creditmanagement->getResponsibleUserToCode()); + $this->assertNull($creditmanagement->getResponsibleUserToCode()); $this->assertSame(0.00, $creditmanagement->getBaseCreditLimitToFloat()); $this->assertSame(true, $creditmanagement->getSendReminder()); - $this->assertSame('', $creditmanagement->getReminderEmail()); + $this->assertNull($creditmanagement->getReminderEmail()); $this->assertSame(false, $creditmanagement->getBlocked()); - $this->assertSame('', $creditmanagement->getFreeText1ToString()); - $this->assertSame('', $creditmanagement->getFreeText2()); - $this->assertSame('', $creditmanagement->getFreeText3()); - $this->assertSame('', $creditmanagement->getComment()); + $this->assertNull($creditmanagement->getFreeText1ToString()); + $this->assertNull($creditmanagement->getFreeText2()); + $this->assertNull($creditmanagement->getFreeText3()); + $this->assertNull($creditmanagement->getComment()); } public function testListAllCustomersWorks() From bbb0cab6792c7df2bc3bafd0c4985305cd35122b Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:21:29 +0200 Subject: [PATCH 137/388] Update CustomerIntegrationTest.php --- tests/IntegrationTests/CustomerIntegrationTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 6e86b8e0..a88b5f00 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -136,7 +136,8 @@ public function testGetCustomerWorks() $this->assertNull($creditmanagement->getResponsibleUserToCode()); $this->assertSame(0.00, $creditmanagement->getBaseCreditLimitToFloat()); - $this->assertSame(true, $creditmanagement->getSendReminder()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\SendReminder'); + $this->assertSame($ReflectObject->getConstant('TRUE'), (string)$creditmanagement->getSendReminder()); $this->assertNull($creditmanagement->getReminderEmail()); $this->assertSame(false, $creditmanagement->getBlocked()); $this->assertNull($creditmanagement->getFreeText1ToString()); From 18c7d49d6f9681e8c896bfff1a64ce40f510455f Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:22:22 +0200 Subject: [PATCH 138/388] Update CustomersDocumentUnitTest.php --- tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php index 56fe8668..ba5fac91 100644 --- a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php @@ -47,7 +47,7 @@ public function testXmlIsCreatedPerSpec() (new CustomerCreditManagement()) ->setResponsibleUserFromCode('responsible-user') ->setBaseCreditLimitFromFloat(50) - ->setSendReminder(true) + ->setSendReminderFromString('true') ->setReminderEmail('reminderemail@mail.com') ->setBlocked(false) ->setFreeText1('free1') From b60586d321ac606998fcb0856b8db84889a7f5a8 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:22:42 +0200 Subject: [PATCH 139/388] Update CustomersDocumentUnitTest.php --- tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php index ba5fac91..8a2cdce8 100644 --- a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php @@ -50,7 +50,7 @@ public function testXmlIsCreatedPerSpec() ->setSendReminderFromString('true') ->setReminderEmail('reminderemail@mail.com') ->setBlocked(false) - ->setFreeText1('free1') + ->setFreeText1FromString('free1') ->setFreeText2('free2') ->setComment('comment comment') ); From 7502527ea55c7cb23c49ac6d9d28059a4ac5dd8c Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:23:33 +0200 Subject: [PATCH 140/388] Update CustomersDocumentUnitTest.php --- tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php index 8a2cdce8..92f79e23 100644 --- a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php @@ -50,7 +50,7 @@ public function testXmlIsCreatedPerSpec() ->setSendReminderFromString('true') ->setReminderEmail('reminderemail@mail.com') ->setBlocked(false) - ->setFreeText1FromString('free1') + ->setFreeText1FromString('true') ->setFreeText2('free2') ->setComment('comment comment') ); @@ -124,7 +124,7 @@ public function testXmlIsCreatedPerSpec() true reminderemail@mail.com false - free1 + true free2 comment comment From 64ab1e2864f6f8c2fbfcdde67080870d43265d1f Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:26:48 +0200 Subject: [PATCH 141/388] Update customerGetResponse.xml --- tests/IntegrationTests/resources/customerGetResponse.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/resources/customerGetResponse.xml b/tests/IntegrationTests/resources/customerGetResponse.xml index 29aff77b..4dc7585e 100644 --- a/tests/IntegrationTests/resources/customerGetResponse.xml +++ b/tests/IntegrationTests/resources/customerGetResponse.xml @@ -82,7 +82,7 @@ true false - + false From 17d8e7a831c2dadb690c3a5be119f14221359221 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:26:52 +0200 Subject: [PATCH 142/388] Update CustomerIntegrationTest.php --- tests/IntegrationTests/CustomerIntegrationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index a88b5f00..9f8af1ad 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -140,7 +140,7 @@ public function testGetCustomerWorks() $this->assertSame($ReflectObject->getConstant('TRUE'), (string)$creditmanagement->getSendReminder()); $this->assertNull($creditmanagement->getReminderEmail()); $this->assertSame(false, $creditmanagement->getBlocked()); - $this->assertNull($creditmanagement->getFreeText1ToString()); + $this->assertSame(false, $creditmanagement->getFreeText1()); $this->assertNull($creditmanagement->getFreeText2()); $this->assertNull($creditmanagement->getFreeText3()); $this->assertNull($creditmanagement->getComment()); From 3a7e127a40eb28ca47490e0da6fbbf507f78104e Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:29:31 +0200 Subject: [PATCH 143/388] Update customerGetResponse.xml --- tests/IntegrationTests/resources/customerGetResponse.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/resources/customerGetResponse.xml b/tests/IntegrationTests/resources/customerGetResponse.xml index 4dc7585e..29aff77b 100644 --- a/tests/IntegrationTests/resources/customerGetResponse.xml +++ b/tests/IntegrationTests/resources/customerGetResponse.xml @@ -82,7 +82,7 @@ true false - false + From b78f07415979958ef1f85c87dd37fe18eacb3267 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:30:15 +0200 Subject: [PATCH 144/388] Update CustomersDocumentUnitTest.php --- tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php index 92f79e23..7077dfa7 100644 --- a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php @@ -59,7 +59,7 @@ public function testXmlIsCreatedPerSpec() ->setDefault(true) ->setTypeFromString('invoice') ->setName('My Address') - ->setCountry('nl') + ->setCountryFromCode('nl') ->setCity('city') ->setPostcode('postal code') ->setTelephone('phone number') @@ -80,7 +80,7 @@ public function testXmlIsCreatedPerSpec() ->setBankName('bank name') ->setBicCode('bic code') ->setCity('city') - ->setCountry('nl') + ->setCountryFromCode('nl') ->setIban('iban') ->setNatBicCode('nat-bic') ->setPostcode('postcode') From 6442b99b765fb607a783c76fbaf9e55de99b8fe4 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:33:42 +0200 Subject: [PATCH 145/388] Update OfficeTest.php --- tests/UnitTests/Supplier/OfficeTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/UnitTests/Supplier/OfficeTest.php b/tests/UnitTests/Supplier/OfficeTest.php index 419d5c79..65fc87c5 100644 --- a/tests/UnitTests/Supplier/OfficeTest.php +++ b/tests/UnitTests/Supplier/OfficeTest.php @@ -49,8 +49,8 @@ public function testSetOfficeAndSerializes(Supplier $customer) $document->addSupplier($customer); - $xpath = new \DOMXPath($document); - - $this->assertEquals($xpath->query('/office')->item(0)->nodeValue, $this->office); + $documentDOM = new \DOMDocument($document); + + $this->assertEquals($documentDOM->getElementsByTagName('office')->item(0)->nodeValue, $this->office); } } From d2a56384cdaab67c5efae5cacab598477b8a1d42 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:44:14 +0200 Subject: [PATCH 146/388] Update CustomerBank.php --- src/CustomerBank.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CustomerBank.php b/src/CustomerBank.php index a440607a..e47fb839 100644 --- a/src/CustomerBank.php +++ b/src/CustomerBank.php @@ -42,6 +42,6 @@ class CustomerBank extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } -} \ No newline at end of file +} From 3a2974775c86932c6c28025eb3843332fb0071af Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:48:10 +0200 Subject: [PATCH 147/388] Update CustomerIntegrationTest.php --- tests/IntegrationTests/CustomerIntegrationTest.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 9f8af1ad..362a3224 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -180,6 +180,13 @@ public function testSendCustomerWorks() $financials->setDueDays(30); $financials->setPayAvailable(true); $financials->setPayCodeFromCode('SEPANLDD'); + + $collectMandate = new CustomerCollectMandate(); + $collectMandate->setID(1); + $collectMandate->setSignatureDateFromString('20180604'); + $collectMandate->setFirstRunDateFromString('20180608'); + $financials->setCollectMandate($collectMandate); + $customer->setFinancials($financials); $address = new CustomerAddress(); @@ -214,12 +221,6 @@ public function testSendCustomerWorks() $bank->setState(''); $customer->addBank($bank); - $collectMandate = new CustomerCollectMandate(); - $collectMandate->setID(1); - $collectMandate->setSignatureDateFromString('20180604'); - $collectMandate->setFirstRunDateFromString('20180608'); - $customer->setCollectMandate($collectMandate); - $this->processXmlService ->expects($this->once()) ->method("sendDocument") From 20868adea4b66438b6e9ec1e1e4114e183b37c46 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:51:58 +0200 Subject: [PATCH 148/388] Add files via upload --- src/ArticleLine.php | 2 +- src/AssetMethodFreeText.php | 2 +- src/CustomerAddress.php | 2 +- src/CustomerBank.php | 2 +- src/CustomerCollectMandate.php | 2 +- src/CustomerPostingRule.php | 2 +- src/InvoiceLine.php | 2 +- src/RateRateChange.php | 2 +- src/SupplierAddress.php | 2 +- src/SupplierBank.php | 2 +- src/SupplierPostingRule.php | 2 +- src/VatCodeAccount.php | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/ArticleLine.php b/src/ArticleLine.php index 6286332b..ce4fcd83 100644 --- a/src/ArticleLine.php +++ b/src/ArticleLine.php @@ -36,6 +36,6 @@ class ArticleLine extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } } diff --git a/src/AssetMethodFreeText.php b/src/AssetMethodFreeText.php index 1844b2dd..78e599d9 100644 --- a/src/AssetMethodFreeText.php +++ b/src/AssetMethodFreeText.php @@ -18,6 +18,6 @@ class AssetMethodFreeText extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } } diff --git a/src/CustomerAddress.php b/src/CustomerAddress.php index 87f15be1..26ab4de3 100644 --- a/src/CustomerAddress.php +++ b/src/CustomerAddress.php @@ -44,6 +44,6 @@ class CustomerAddress extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } } \ No newline at end of file diff --git a/src/CustomerBank.php b/src/CustomerBank.php index e47fb839..74010dcd 100644 --- a/src/CustomerBank.php +++ b/src/CustomerBank.php @@ -44,4 +44,4 @@ public function __construct() { $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } -} +} \ No newline at end of file diff --git a/src/CustomerCollectMandate.php b/src/CustomerCollectMandate.php index 88e310cc..b728e48a 100644 --- a/src/CustomerCollectMandate.php +++ b/src/CustomerCollectMandate.php @@ -18,6 +18,6 @@ class CustomerCollectMandate extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } } diff --git a/src/CustomerPostingRule.php b/src/CustomerPostingRule.php index 1030c50b..f25168ca 100644 --- a/src/CustomerPostingRule.php +++ b/src/CustomerPostingRule.php @@ -24,7 +24,7 @@ class CustomerPostingRule extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } public function getLines() diff --git a/src/InvoiceLine.php b/src/InvoiceLine.php index ed400e72..746f1617 100644 --- a/src/InvoiceLine.php +++ b/src/InvoiceLine.php @@ -49,7 +49,7 @@ class InvoiceLine extends BaseObject public function __construct($quantity = null, $article = null, $freeText1 = null, $freeText2 = null) { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); $this->quantity = $quantity; $this->article = $article; $this->setFreeText1($freeText1); diff --git a/src/RateRateChange.php b/src/RateRateChange.php index e207aff5..eca9a303 100644 --- a/src/RateRateChange.php +++ b/src/RateRateChange.php @@ -24,6 +24,6 @@ class RateRateChange extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } } diff --git a/src/SupplierAddress.php b/src/SupplierAddress.php index caf6575d..3bd20584 100644 --- a/src/SupplierAddress.php +++ b/src/SupplierAddress.php @@ -44,6 +44,6 @@ class SupplierAddress extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } } diff --git a/src/SupplierBank.php b/src/SupplierBank.php index 9621e4c0..2af51df8 100644 --- a/src/SupplierBank.php +++ b/src/SupplierBank.php @@ -42,6 +42,6 @@ class SupplierBank extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } } \ No newline at end of file diff --git a/src/SupplierPostingRule.php b/src/SupplierPostingRule.php index abbb5e02..9386c77a 100644 --- a/src/SupplierPostingRule.php +++ b/src/SupplierPostingRule.php @@ -24,7 +24,7 @@ class SupplierPostingRule extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } public function getLines() diff --git a/src/VatCodeAccount.php b/src/VatCodeAccount.php index 97d55556..15eb5d9c 100644 --- a/src/VatCodeAccount.php +++ b/src/VatCodeAccount.php @@ -24,6 +24,6 @@ class VatCodeAccount extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } } From 26f597e60dc869fed5dc940251ddc253eb203fc6 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 10 May 2019 21:52:26 +0200 Subject: [PATCH 149/388] Add files via upload --- src/ArticleLine.php | 2 +- src/AssetMethodFreeText.php | 2 +- src/CustomerAddress.php | 2 +- src/CustomerBank.php | 2 +- src/CustomerCollectMandate.php | 2 +- src/CustomerPostingRule.php | 2 +- src/InvoiceLine.php | 2 +- src/RateRateChange.php | 2 +- src/SupplierAddress.php | 2 +- src/SupplierBank.php | 2 +- src/SupplierPostingRule.php | 2 +- src/VatCodeAccount.php | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/ArticleLine.php b/src/ArticleLine.php index 6286332b..ce4fcd83 100644 --- a/src/ArticleLine.php +++ b/src/ArticleLine.php @@ -36,6 +36,6 @@ class ArticleLine extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } } diff --git a/src/AssetMethodFreeText.php b/src/AssetMethodFreeText.php index 1844b2dd..78e599d9 100644 --- a/src/AssetMethodFreeText.php +++ b/src/AssetMethodFreeText.php @@ -18,6 +18,6 @@ class AssetMethodFreeText extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } } diff --git a/src/CustomerAddress.php b/src/CustomerAddress.php index 87f15be1..26ab4de3 100644 --- a/src/CustomerAddress.php +++ b/src/CustomerAddress.php @@ -44,6 +44,6 @@ class CustomerAddress extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } } \ No newline at end of file diff --git a/src/CustomerBank.php b/src/CustomerBank.php index a440607a..74010dcd 100644 --- a/src/CustomerBank.php +++ b/src/CustomerBank.php @@ -42,6 +42,6 @@ class CustomerBank extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } } \ No newline at end of file diff --git a/src/CustomerCollectMandate.php b/src/CustomerCollectMandate.php index 88e310cc..b728e48a 100644 --- a/src/CustomerCollectMandate.php +++ b/src/CustomerCollectMandate.php @@ -18,6 +18,6 @@ class CustomerCollectMandate extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } } diff --git a/src/CustomerPostingRule.php b/src/CustomerPostingRule.php index 1030c50b..f25168ca 100644 --- a/src/CustomerPostingRule.php +++ b/src/CustomerPostingRule.php @@ -24,7 +24,7 @@ class CustomerPostingRule extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } public function getLines() diff --git a/src/InvoiceLine.php b/src/InvoiceLine.php index ed400e72..746f1617 100644 --- a/src/InvoiceLine.php +++ b/src/InvoiceLine.php @@ -49,7 +49,7 @@ class InvoiceLine extends BaseObject public function __construct($quantity = null, $article = null, $freeText1 = null, $freeText2 = null) { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); $this->quantity = $quantity; $this->article = $article; $this->setFreeText1($freeText1); diff --git a/src/RateRateChange.php b/src/RateRateChange.php index e207aff5..eca9a303 100644 --- a/src/RateRateChange.php +++ b/src/RateRateChange.php @@ -24,6 +24,6 @@ class RateRateChange extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } } diff --git a/src/SupplierAddress.php b/src/SupplierAddress.php index caf6575d..3bd20584 100644 --- a/src/SupplierAddress.php +++ b/src/SupplierAddress.php @@ -44,6 +44,6 @@ class SupplierAddress extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } } diff --git a/src/SupplierBank.php b/src/SupplierBank.php index 9621e4c0..2af51df8 100644 --- a/src/SupplierBank.php +++ b/src/SupplierBank.php @@ -42,6 +42,6 @@ class SupplierBank extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } } \ No newline at end of file diff --git a/src/SupplierPostingRule.php b/src/SupplierPostingRule.php index abbb5e02..9386c77a 100644 --- a/src/SupplierPostingRule.php +++ b/src/SupplierPostingRule.php @@ -24,7 +24,7 @@ class SupplierPostingRule extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } public function getLines() diff --git a/src/VatCodeAccount.php b/src/VatCodeAccount.php index 97d55556..15eb5d9c 100644 --- a/src/VatCodeAccount.php +++ b/src/VatCodeAccount.php @@ -24,6 +24,6 @@ class VatCodeAccount extends BaseObject public function __construct() { - $this->ID = uniqid(); + $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); } } From ec19be2ec54753cc693af776d696327a4c7fe992 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 09:27:05 +0200 Subject: [PATCH 150/388] Update CustomersDocumentUnitTest.php --- .../CustomersDocumentUnitTest.php | 123 ++++++++++++++---- 1 file changed, 97 insertions(+), 26 deletions(-) diff --git a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php index 7077dfa7..ecdc9967 100644 --- a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php @@ -105,37 +105,49 @@ public function testXmlIsCreatedPerSpec() + 0 + 0 D123456 + 0 + 0 Chuck Norris + DEV-10000 + DEB http://example.org - DEV-10000 + core 1 + true + ebillingmail@mail.com true pay-code + vat-code - true - ebillingmail@mail.com - + + + 20190510929 + + + - responsible-user 50 - true - reminderemail@mail.com - false - true + false + comment comment + true free2 - comment comment + + responsible-user + reminderemail@mail.com + true + + + -
- My Address - nl +
city - postal code - phone number - fax number + nl email@mail.com field 1 field 2 @@ -143,10 +155,18 @@ public function testXmlIsCreatedPerSpec() field 4 field 5 field 6 + My Address + postal code + fax number + phone number
- + +
+ address 2 + address 3 +
ascriptor account number bank name @@ -157,19 +177,70 @@ public function testXmlIsCreatedPerSpec() nat-bic postcode state -
- address 2 - address 3 -
+ + + + + + + + + + - D654321 - Nuck Chorris - DEB - http://example.org - DEV-00001 + 0 + 0 + D654321 + 0 + 0 + Nuck Chorris + DEV-00001 + + DEB + http://example.org + + core + 30 + false + + + false + + + + + + 20190510798 + + + + + 0 + false + + false + + + + + true + + + + + + + + + + + + + + XML From 37b26a59afac59d7d8c58c8c03dcc827e420451d Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 09:34:43 +0200 Subject: [PATCH 151/388] Add files via upload --- src/CustomerCollectMandate.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CustomerCollectMandate.php b/src/CustomerCollectMandate.php index b728e48a..ab5ca2fe 100644 --- a/src/CustomerCollectMandate.php +++ b/src/CustomerCollectMandate.php @@ -2,7 +2,7 @@ namespace PhpTwinfield; -use PhpTwinfield\Fields\IDField; +use PhpTwinfield\Fields\Level1234\Level2\Customer\CollectMandateIDField; use PhpTwinfield\Fields\Level1234\Level2\Customer\FirstRunDateField; use PhpTwinfield\Fields\Level1234\Level2\Customer\SignatureDateField; @@ -12,12 +12,12 @@ */ class CustomerCollectMandate extends BaseObject { + use CollectMandateIDField; use FirstRunDateField; - use IDField; use SignatureDateField; - + public function __construct() { - $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); + $this->ID = uniqid(); } } From 22b0e631a36a71026a8039e923ac6d38dfe12fe6 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 09:34:58 +0200 Subject: [PATCH 152/388] Add files via upload --- src/Fields/IDField.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Fields/IDField.php b/src/Fields/IDField.php index bffb29d5..6b3c94ff 100644 --- a/src/Fields/IDField.php +++ b/src/Fields/IDField.php @@ -6,7 +6,7 @@ trait IDField { /** * ID field - * Used by: ArticleLine, AssetMethodFreeText, CustomerAddress, CustomerBank, CustomerCollectMandate, CustomerPostingRule, InvoiceLine, RateRateChange, SupplierAddress, SupplierBank, SupplierPostingRule, VatCodeAccount + * Used by: ArticleLine, AssetMethodFreeText, CustomerAddress, CustomerBank, CustomerPostingRule, InvoiceLine, RateRateChange, SupplierAddress, SupplierBank, SupplierPostingRule, VatCodeAccount * * @var int|null */ From 90f7b3c4c9fa2bcc962d9ccb2c0ddfe66a20b2fa Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 09:35:12 +0200 Subject: [PATCH 153/388] Add files via upload --- .../Level2/Customer/CollectMandateIDField.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/Fields/Level1234/Level2/Customer/CollectMandateIDField.php diff --git a/src/Fields/Level1234/Level2/Customer/CollectMandateIDField.php b/src/Fields/Level1234/Level2/Customer/CollectMandateIDField.php new file mode 100644 index 00000000..ecedddbd --- /dev/null +++ b/src/Fields/Level1234/Level2/Customer/CollectMandateIDField.php @@ -0,0 +1,32 @@ +ID; + } + + /** + * @param null|string $ID + * @return $this + */ + public function setID(?string $ID): self + { + $this->ID = $ID; + return $this; + } +} \ No newline at end of file From 78293c8c2c2303436bf6940cc559677f9d63e885 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 09:41:05 +0200 Subject: [PATCH 154/388] Add files via upload --- src/ArticleLine.php | 5 ----- src/AssetMethodFreeText.php | 5 ----- src/CustomerAddress.php | 5 ----- src/CustomerBank.php | 5 ----- src/CustomerPostingRule.php | 5 ----- src/InvoiceLine.php | 1 - src/RateRateChange.php | 5 ----- src/SupplierAddress.php | 5 ----- src/SupplierBank.php | 5 ----- src/SupplierPostingRule.php | 5 ----- src/VatCodeAccount.php | 5 ----- 11 files changed, 51 deletions(-) diff --git a/src/ArticleLine.php b/src/ArticleLine.php index ce4fcd83..42e5f81b 100644 --- a/src/ArticleLine.php +++ b/src/ArticleLine.php @@ -33,9 +33,4 @@ class ArticleLine extends BaseObject use UnitsField; use UnitsPriceExclField; use UnitsPriceIncField; - - public function __construct() - { - $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); - } } diff --git a/src/AssetMethodFreeText.php b/src/AssetMethodFreeText.php index 78e599d9..06577d64 100644 --- a/src/AssetMethodFreeText.php +++ b/src/AssetMethodFreeText.php @@ -15,9 +15,4 @@ class AssetMethodFreeText extends BaseObject use ElementValueField; use FreeTextTypeField; use IDField; - - public function __construct() - { - $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); - } } diff --git a/src/CustomerAddress.php b/src/CustomerAddress.php index 26ab4de3..4884d488 100644 --- a/src/CustomerAddress.php +++ b/src/CustomerAddress.php @@ -41,9 +41,4 @@ class CustomerAddress extends BaseObject use PostcodeField; use TelefaxField; use TelephoneField; - - public function __construct() - { - $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); - } } \ No newline at end of file diff --git a/src/CustomerBank.php b/src/CustomerBank.php index 74010dcd..e555eca0 100644 --- a/src/CustomerBank.php +++ b/src/CustomerBank.php @@ -39,9 +39,4 @@ class CustomerBank extends BaseObject use NatBicCodeField; use PostcodeField; use StateField; - - public function __construct() - { - $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); - } } \ No newline at end of file diff --git a/src/CustomerPostingRule.php b/src/CustomerPostingRule.php index f25168ca..69fa10fe 100644 --- a/src/CustomerPostingRule.php +++ b/src/CustomerPostingRule.php @@ -22,11 +22,6 @@ class CustomerPostingRule extends BaseObject private $lines = []; - public function __construct() - { - $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); - } - public function getLines() { return $this->lines; diff --git a/src/InvoiceLine.php b/src/InvoiceLine.php index 746f1617..cebcd97f 100644 --- a/src/InvoiceLine.php +++ b/src/InvoiceLine.php @@ -49,7 +49,6 @@ class InvoiceLine extends BaseObject public function __construct($quantity = null, $article = null, $freeText1 = null, $freeText2 = null) { - $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); $this->quantity = $quantity; $this->article = $article; $this->setFreeText1($freeText1); diff --git a/src/RateRateChange.php b/src/RateRateChange.php index eca9a303..7842981c 100644 --- a/src/RateRateChange.php +++ b/src/RateRateChange.php @@ -21,9 +21,4 @@ class RateRateChange extends BaseObject use IDField; use InternalRateField; use StatusField; - - public function __construct() - { - $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); - } } diff --git a/src/SupplierAddress.php b/src/SupplierAddress.php index 3bd20584..71e714da 100644 --- a/src/SupplierAddress.php +++ b/src/SupplierAddress.php @@ -41,9 +41,4 @@ class SupplierAddress extends BaseObject use PostcodeField; use TelefaxField; use TelephoneField; - - public function __construct() - { - $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); - } } diff --git a/src/SupplierBank.php b/src/SupplierBank.php index 2af51df8..f6164f73 100644 --- a/src/SupplierBank.php +++ b/src/SupplierBank.php @@ -39,9 +39,4 @@ class SupplierBank extends BaseObject use NatBicCodeField; use PostcodeField; use StateField; - - public function __construct() - { - $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); - } } \ No newline at end of file diff --git a/src/SupplierPostingRule.php b/src/SupplierPostingRule.php index 9386c77a..dcba4413 100644 --- a/src/SupplierPostingRule.php +++ b/src/SupplierPostingRule.php @@ -22,11 +22,6 @@ class SupplierPostingRule extends BaseObject private $lines = []; - public function __construct() - { - $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); - } - public function getLines() { return $this->lines; diff --git a/src/VatCodeAccount.php b/src/VatCodeAccount.php index 15eb5d9c..2fe8b738 100644 --- a/src/VatCodeAccount.php +++ b/src/VatCodeAccount.php @@ -21,9 +21,4 @@ class VatCodeAccount extends BaseObject use PercentageField; use VatGroupCountryField; use VatGroupField; - - public function __construct() - { - $this->ID = (int)(date('Ymd'). sprintf("%03d", mt_rand(1, 999))); - } } From a0e09e347c0347a8255369bc11cabccebac19302 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 09:46:09 +0200 Subject: [PATCH 155/388] Add files via upload --- src/CustomerCollectMandate.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/CustomerCollectMandate.php b/src/CustomerCollectMandate.php index ab5ca2fe..1bcf0d91 100644 --- a/src/CustomerCollectMandate.php +++ b/src/CustomerCollectMandate.php @@ -15,9 +15,4 @@ class CustomerCollectMandate extends BaseObject use CollectMandateIDField; use FirstRunDateField; use SignatureDateField; - - public function __construct() - { - $this->ID = uniqid(); - } } From 30525ba6b881c2f1b98103eccb3c5e9047ff98af Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 09:46:14 +0200 Subject: [PATCH 156/388] Update CustomersDocumentUnitTest.php --- .../DomDocuments/CustomersDocumentUnitTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php index ecdc9967..0eb45c33 100644 --- a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php @@ -126,7 +126,7 @@ public function testXmlIsCreatedPerSpec() vat-code - 20190510929 + @@ -137,15 +137,15 @@ public function testXmlIsCreatedPerSpec() true free2 - responsible-user reminderemail@mail.com + responsible-user true -
+
city nl email@mail.com @@ -162,7 +162,7 @@ public function testXmlIsCreatedPerSpec()
- +
address 2 address 3 @@ -213,7 +213,7 @@ public function testXmlIsCreatedPerSpec() - 20190510798 + From 8a7bc934eddd814fa348656df3ee1584fdd5fb97 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 09:48:35 +0200 Subject: [PATCH 157/388] Update CustomersDocumentUnitTest.php --- tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php index 0eb45c33..2d41031d 100644 --- a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php @@ -120,6 +120,7 @@ public function testXmlIsCreatedPerSpec() 1 true ebillingmail@mail.com + true pay-code From 85d8245ddc6615abfc39816df13bfdd47020ba1c Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 09:51:42 +0200 Subject: [PATCH 158/388] Update customerSendRequest.xml --- .../resources/customerSendRequest.xml | 143 +++++++++++------- 1 file changed, 88 insertions(+), 55 deletions(-) diff --git a/tests/IntegrationTests/resources/customerSendRequest.xml b/tests/IntegrationTests/resources/customerSendRequest.xml index 64cf0c15..46f74023 100644 --- a/tests/IntegrationTests/resources/customerSendRequest.xml +++ b/tests/IntegrationTests/resources/customerSendRequest.xml @@ -1,56 +1,89 @@ - - Customer 0 - DEB - 001 - - 30 - true - SEPANLDD - - false - - - 1 - 20180604 - 20180608 - - - -
- Customer 0 - - NL - Place - 1000 - 010-123452000 - 010-12342000 - info@example.com - Customer 1 - Streetname part 1 - 1 - Streetname part 1 - 2 - - - -
-
- - - Customer 1 - 123456789 - ABN Amro - ABNANL2A - Place - NL - NL02ABNA0123456789 - - - -
- - -
-
-
-
-
+ + 0 + 0 + + 0 + 0 + Customer 0 + 001 + + DEB + + + core + 30 + false + + + true + SEPANLDD + + + + 20180608 + 1 + 20180604 + + + + 0 + false + + false + + + + + true + + + + + +
+ Place + NL + info@example.com + Customer 1 + Streetname part 1 - 1 + Streetname part 1 - 2 + + + + Customer 0 + 1000 + 010-12342000 + 010-123452000 +
+
+ + +
+ + +
+ Customer 1 + 123456789 + ABN Amro + ABNANL2A + Place + NL + NL02ABNA0123456789 + + + +
+
+ + + + + + + + + + +
+ From 5e21647f761e2d33e7a6212dc40b61efaa0de6c2 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 09:54:11 +0200 Subject: [PATCH 159/388] Update CustomerIntegrationTest.php --- tests/IntegrationTests/CustomerIntegrationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 362a3224..35e1c295 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -67,7 +67,7 @@ public function testGetCustomerWorks() // Collect Mandate $collectMandate = $financials->getCollectMandate(); - $this->assertSame(1, $collectMandate->getID()); + $this->assertSame('1', $collectMandate->getID()); $this->assertEquals(new \DateTimeImmutable('2018-06-04'), $collectMandate->getSignatureDate()); $this->assertEquals(new \DateTimeImmutable('2018-06-08'), $collectMandate->getFirstRunDate()); From aa75d5bbb5ce363438958a4335b7c35f3fc24a43 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 10:10:07 +0200 Subject: [PATCH 160/388] Add files via upload --- src/Mappers/BaseMapper.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index 24729b8d..8ace7f77 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -141,7 +141,20 @@ protected static function parseEnumAttribute(string $enumName, ?string $value) $enum = "\\PhpTwinfield\\Enums\\" . $enumName; - return new $enum($value); + try { + $classReflex = new \ReflectionClass($enum); + $classConstants = $classReflex->getConstants(); + + foreach ($classConstants as $classConstant) { + if ($value == $classConstant->getValue()) { + return new $enum($value); + } + } + } catch (\ReflectionException $e) { + return null; + } + + return null; } protected static function parseMoneyAttribute(?float $value): ?Money @@ -205,4 +218,4 @@ protected static function parseObjectAttribute(string $className, $object, \DOME return $object2; } -} +} \ No newline at end of file From bcdf4538173f93dc3d51d5ef74ad12ed7cc0ed32 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 10:12:52 +0200 Subject: [PATCH 161/388] Update CustomerApiConnectorTest.php --- tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php b/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php index 38fcd670..eb7e875d 100644 --- a/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php @@ -63,6 +63,5 @@ public function testSendAllReturnsMappedObjects() $this->assertInstanceOf(Customer::class, $mapped); $this->assertEquals("D1001", $mapped->getCode()); $this->assertEquals("Hr E G H Küppers en/of MW M.J. Küppers-Veeneman", $mapped->getName()); - $this->assertEquals("BE", $mapped->getCountry()); } -} \ No newline at end of file +} From 3c4d000d1db735131d2d16bfcaf97c0ce57ba0db Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 10:14:15 +0200 Subject: [PATCH 162/388] Add files via upload --- src/Mappers/BaseMapper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index 8ace7f77..823ae2ba 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -146,7 +146,7 @@ protected static function parseEnumAttribute(string $enumName, ?string $value) $classConstants = $classReflex->getConstants(); foreach ($classConstants as $classConstant) { - if ($value == $classConstant->getValue()) { + if ($value == $classConstant) { return new $enum($value); } } From 381872a58f81bbbcde9f0402a70ec256133b82d6 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 10:26:51 +0200 Subject: [PATCH 163/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 91a7c3f3..eeae5628 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -174,6 +174,9 @@ public function testGetFinalInvoiceWorks() public function testSendInvoiceWorks() { + $invoiceTypeMockContext = $this->createMock(\PhpTwinfield\ApiConnectors\InvoiceTypeApiConnector::class); + $invoiceTypeMockContext->method("getInvoiceTypeVatType")->willReturn('exclusive'); + $customer = new Customer(); $customer->setCode('1000'); From 11d1ba72d8f25f4c482d9331416a870354834803 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 10:31:08 +0200 Subject: [PATCH 164/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index eeae5628..073d22f6 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -174,7 +174,7 @@ public function testGetFinalInvoiceWorks() public function testSendInvoiceWorks() { - $invoiceTypeMockContext = $this->createMock(\PhpTwinfield\ApiConnectors\InvoiceTypeApiConnector::class); + $invoiceTypeMockContext = $this->createMock(InvoiceTypeApiConnector::class); $invoiceTypeMockContext->method("getInvoiceTypeVatType")->willReturn('exclusive'); $customer = new Customer(); From e81d620a92cb422899d306c47148b178ea5f52d1 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 10:51:11 +0200 Subject: [PATCH 165/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 073d22f6..5e4103c4 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -174,8 +174,11 @@ public function testGetFinalInvoiceWorks() public function testSendInvoiceWorks() { - $invoiceTypeMockContext = $this->createMock(InvoiceTypeApiConnector::class); - $invoiceTypeMockContext->method("getInvoiceTypeVatType")->willReturn('exclusive'); + + $invoiceTypeApiConnector = $this->getMockBuilder('\PhpTwinfield\ApiConnectors\InvoiceTypeApiConnector') + ->getMock(); + + $invoiceTypeApiConnector->method("getInvoiceTypeVatType")->willReturn('exclusive'); $customer = new Customer(); $customer->setCode('1000'); From 85a2c6640ee2d87908e2b381968e27fed2927c6d Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 10:56:02 +0200 Subject: [PATCH 166/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 5e4103c4..39665bfb 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -176,6 +176,7 @@ public function testSendInvoiceWorks() { $invoiceTypeApiConnector = $this->getMockBuilder('\PhpTwinfield\ApiConnectors\InvoiceTypeApiConnector') + ->setConstructorArgs($this->connection) ->getMock(); $invoiceTypeApiConnector->method("getInvoiceTypeVatType")->willReturn('exclusive'); From 9c0e99cd503beceb5f2e6cfd3d558b762d956d43 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 10:58:41 +0200 Subject: [PATCH 167/388] Add files via upload --- src/DomDocuments/InvoicesDocument.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DomDocuments/InvoicesDocument.php b/src/DomDocuments/InvoicesDocument.php index a59b53b5..df6f1979 100644 --- a/src/DomDocuments/InvoicesDocument.php +++ b/src/DomDocuments/InvoicesDocument.php @@ -71,7 +71,7 @@ public function addInvoice(Invoice $invoice, $connection) $headerElement->appendChild($this->createNodeWithTextContent('status', $invoice->getStatus())); $invoiceTypeApiConnector = new \PhpTwinfield\ApiConnectors\InvoiceTypeApiConnector($connection); - $invoiceVatType = $invoiceTypeApiConnector->getInvoiceTypeVatType('FACTUUR'); + $invoiceVatType = $invoiceTypeApiConnector->getInvoiceTypeVatType($invoice->getInvoiceTypeToCode()); $articleApiConnector = new \PhpTwinfield\ApiConnectors\ArticleApiConnector($connection); From 50ef823a9206c015f83cb668c0061f92416c9094 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 10:58:45 +0200 Subject: [PATCH 168/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 39665bfb..1b695e53 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -176,7 +176,7 @@ public function testSendInvoiceWorks() { $invoiceTypeApiConnector = $this->getMockBuilder('\PhpTwinfield\ApiConnectors\InvoiceTypeApiConnector') - ->setConstructorArgs($this->connection) + ->setConstructorArgs(array($this->connection)) ->getMock(); $invoiceTypeApiConnector->method("getInvoiceTypeVatType")->willReturn('exclusive'); From c5b02fdda5177b9c88169a883c09bb76f77a0479 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 11:07:07 +0200 Subject: [PATCH 169/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 1b695e53..59c91ee8 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -34,6 +34,12 @@ protected function setUp() parent::setUp(); $this->invoiceApiConnector = new InvoiceApiConnector($this->connection); + + $this->invoiceTypeApiConnector = $this->getMockBuilder('\PhpTwinfield\ApiConnectors\InvoiceTypeApiConnector') + ->setConstructorArgs(array($this->connection)) + ->getMock(); + + $this->invoiceTypeApiConnector->method("getInvoiceTypeVatType")->willReturn('exclusive'); } public function testGetConceptInvoiceWorks() @@ -173,14 +179,7 @@ public function testGetFinalInvoiceWorks() } public function testSendInvoiceWorks() - { - - $invoiceTypeApiConnector = $this->getMockBuilder('\PhpTwinfield\ApiConnectors\InvoiceTypeApiConnector') - ->setConstructorArgs(array($this->connection)) - ->getMock(); - - $invoiceTypeApiConnector->method("getInvoiceTypeVatType")->willReturn('exclusive'); - + { $customer = new Customer(); $customer->setCode('1000'); From ab32877347282eb0abcb0aae1f97c5cad67bd6fe Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 11:20:14 +0200 Subject: [PATCH 170/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 59c91ee8..078ecb8a 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -28,6 +28,11 @@ class InvoiceIntegrationTest extends BaseIntegrationTest * @var InvoiceApiConnector|\PHPUnit_Framework_MockObject_MockObject */ private $invoiceApiConnector; + + /** + * @var InvoiceTypeApiConnector|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceTypeApiConnector; protected function setUp() { From 7df8bbc64e858bd5024299d238ac9ac6b7c06747 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 11:26:36 +0200 Subject: [PATCH 171/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 078ecb8a..9e136161 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\IntegrationTests; use PhpTwinfield\ApiConnectors\InvoiceApiConnector; +use PhpTwinfield\ApiConnectors\InvoiceTypeApiConnector; use PhpTwinfield\Customer; use PhpTwinfield\DomDocuments\InvoicesDocument; use PhpTwinfield\Invoice; @@ -40,11 +41,11 @@ protected function setUp() $this->invoiceApiConnector = new InvoiceApiConnector($this->connection); - $this->invoiceTypeApiConnector = $this->getMockBuilder('\PhpTwinfield\ApiConnectors\InvoiceTypeApiConnector') + $this->invoiceTypeApiConnector = $this->createMock(InvoiceTypeApiConnector::class); + $this->invoiceTypeApiConnector ->setConstructorArgs(array($this->connection)) - ->getMock(); - - $this->invoiceTypeApiConnector->method("getInvoiceTypeVatType")->willReturn('exclusive'); + ->method("getInvoiceTypeVatType") + ->willReturn('exclusive'); } public function testGetConceptInvoiceWorks() From 6f318d8f5123334e98ae6d203c6203a2b99726ee Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 11:28:43 +0200 Subject: [PATCH 172/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 9e136161..08cf078b 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -43,7 +43,6 @@ protected function setUp() $this->invoiceTypeApiConnector = $this->createMock(InvoiceTypeApiConnector::class); $this->invoiceTypeApiConnector - ->setConstructorArgs(array($this->connection)) ->method("getInvoiceTypeVatType") ->willReturn('exclusive'); } From 00bcb124bdb104f1945c179bfc4acaed4a95b6e2 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 11:34:40 +0200 Subject: [PATCH 173/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 08cf078b..87721c5f 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -41,10 +41,7 @@ protected function setUp() $this->invoiceApiConnector = new InvoiceApiConnector($this->connection); - $this->invoiceTypeApiConnector = $this->createMock(InvoiceTypeApiConnector::class); - $this->invoiceTypeApiConnector - ->method("getInvoiceTypeVatType") - ->willReturn('exclusive'); + $this->invoiceTypeApiConnector = $this->getMockBuilder('InvoiceTypeApiConnector')->disableOriginalConstructor()->getMock(); } public function testGetConceptInvoiceWorks() From dc760ab71785346f52813d7672df4f7726736623 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 11:37:53 +0200 Subject: [PATCH 174/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 87721c5f..2c46f86c 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -33,7 +33,7 @@ class InvoiceIntegrationTest extends BaseIntegrationTest /** * @var InvoiceTypeApiConnector|\PHPUnit_Framework_MockObject_MockObject */ - protected $invoiceTypeApiConnector; + public $invoiceTypeApiConnector; protected function setUp() { From 45c5e8f6c3743db8930d0ef2d2449e11bedbba05 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 11:45:19 +0200 Subject: [PATCH 175/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 2c46f86c..7a947282 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -29,11 +29,6 @@ class InvoiceIntegrationTest extends BaseIntegrationTest * @var InvoiceApiConnector|\PHPUnit_Framework_MockObject_MockObject */ private $invoiceApiConnector; - - /** - * @var InvoiceTypeApiConnector|\PHPUnit_Framework_MockObject_MockObject - */ - public $invoiceTypeApiConnector; protected function setUp() { @@ -41,7 +36,10 @@ protected function setUp() $this->invoiceApiConnector = new InvoiceApiConnector($this->connection); - $this->invoiceTypeApiConnector = $this->getMockBuilder('InvoiceTypeApiConnector')->disableOriginalConstructor()->getMock(); + $mock = \Mockery::mock('overload:'.InvoiceTypeApiConnector::class); + $mock->shouldReceive('getInvoiceTypeVatType')->andReturnUsing(function() { + return 'exclusive'; + }); } public function testGetConceptInvoiceWorks() From fc922fc38809ca42d12fa74c15290d3af0cfba49 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 11:50:55 +0200 Subject: [PATCH 176/388] Update composer.json --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 499e9f7a..9fd19557 100644 --- a/composer.json +++ b/composer.json @@ -55,6 +55,7 @@ "league/oauth2-client": "^2.2", "mediact/dependency-guard": "^1.0", "phpstan/phpstan": "^0.10.1", - "phpunit/phpunit": "^7.3" + "phpunit/phpunit": "^7.3", + "mockery/mockery" } } From 79d02ade9ff1a380cd96c33875e59a734eb229da Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 11:52:47 +0200 Subject: [PATCH 177/388] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9fd19557..052f5938 100644 --- a/composer.json +++ b/composer.json @@ -56,6 +56,6 @@ "mediact/dependency-guard": "^1.0", "phpstan/phpstan": "^0.10.1", "phpunit/phpunit": "^7.3", - "mockery/mockery" + "mockery/mockery": "dev-master" } } From 609bcb2d2a28f2bc038016e7e833ec0e2107bc64 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 11:58:38 +0200 Subject: [PATCH 178/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 7a947282..3cf36c1e 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -2,8 +2,10 @@ namespace PhpTwinfield\IntegrationTests; +use PhpTwinfield\ApiConnectors\ArticleApiConnector; use PhpTwinfield\ApiConnectors\InvoiceApiConnector; use PhpTwinfield\ApiConnectors\InvoiceTypeApiConnector; +use PhpTwinfield\Article; use PhpTwinfield\Customer; use PhpTwinfield\DomDocuments\InvoicesDocument; use PhpTwinfield\Invoice; @@ -36,10 +38,18 @@ protected function setUp() $this->invoiceApiConnector = new InvoiceApiConnector($this->connection); - $mock = \Mockery::mock('overload:'.InvoiceTypeApiConnector::class); - $mock->shouldReceive('getInvoiceTypeVatType')->andReturnUsing(function() { + $mockInvoiceTypeApiConnector = \Mockery::mock('overload:'.InvoiceTypeApiConnector::class); + $mockInvoiceTypeApiConnector->shouldReceive('getInvoiceTypeVatType')->andReturnUsing(function() { return 'exclusive'; }); + + $article = new Article; + $article->getAllowChangeVatCode == true + + $mockArticleApiConnector = \Mockery::mock('overload:'.ArticleApiConnector::class); + $mockArticleApiConnector->shouldReceive('get')->andReturnUsing(function() { + return $article; + }); } public function testGetConceptInvoiceWorks() From 1be57e6bc12e496bea5e907cae027a73df6c85f2 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 12:00:30 +0200 Subject: [PATCH 179/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 3cf36c1e..ed757527 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -44,7 +44,7 @@ protected function setUp() }); $article = new Article; - $article->getAllowChangeVatCode == true + $article->getAllowChangeVatCode == true; $mockArticleApiConnector = \Mockery::mock('overload:'.ArticleApiConnector::class); $mockArticleApiConnector->shouldReceive('get')->andReturnUsing(function() { From f09fe2de78e2525bb44516e8d2ac0196d46d4b52 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 12:03:41 +0200 Subject: [PATCH 180/388] Add files via upload --- src/DomDocuments/InvoicesDocument.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DomDocuments/InvoicesDocument.php b/src/DomDocuments/InvoicesDocument.php index df6f1979..f3001edb 100644 --- a/src/DomDocuments/InvoicesDocument.php +++ b/src/DomDocuments/InvoicesDocument.php @@ -115,7 +115,7 @@ public function addInvoice(Invoice $invoice, $connection) $article = $articleApiConnector->get($line->getArticleToCode(), $invoice->getOffice()); - if ($article->getAllowChangeVatCode == true) { + if ($article->getAllowChangeVatCode() == true) { $lineElement->appendChild($this->createNodeWithTextContent('vatcode', $line->getVatCodeToCode())); } } From 201b771571998dfef35138431475f98412007192 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 12:03:44 +0200 Subject: [PATCH 181/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index ed757527..bae806b9 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -44,7 +44,7 @@ protected function setUp() }); $article = new Article; - $article->getAllowChangeVatCode == true; + $article->setAllowChangeVatCode(true); $mockArticleApiConnector = \Mockery::mock('overload:'.ArticleApiConnector::class); $mockArticleApiConnector->shouldReceive('get')->andReturnUsing(function() { From 6544d91b9b3df104818ed62779350b630c18aaea Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 12:05:59 +0200 Subject: [PATCH 182/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index bae806b9..c8d47eac 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -42,12 +42,11 @@ protected function setUp() $mockInvoiceTypeApiConnector->shouldReceive('getInvoiceTypeVatType')->andReturnUsing(function() { return 'exclusive'; }); - - $article = new Article; - $article->setAllowChangeVatCode(true); - + $mockArticleApiConnector = \Mockery::mock('overload:'.ArticleApiConnector::class); $mockArticleApiConnector->shouldReceive('get')->andReturnUsing(function() { + $article = new Article; + $article->setAllowChangeVatCode(true); return $article; }); } From 757073eb211c1e25bec516f55965cd91fe056674 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 12:10:00 +0200 Subject: [PATCH 183/388] Update invoiceSendRequest.xml --- .../resources/invoiceSendRequest.xml | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/tests/IntegrationTests/resources/invoiceSendRequest.xml b/tests/IntegrationTests/resources/invoiceSendRequest.xml index 188e78df..07cccf2c 100644 --- a/tests/IntegrationTests/resources/invoiceSendRequest.xml +++ b/tests/IntegrationTests/resources/invoiceSendRequest.xml @@ -2,30 +2,38 @@
- 1000 - 11024 - FACTUUR - 5 - concept - EUR - 2012/8 - 20120831 BNK - 1 + EUR + 1000 1 - HEADER + FOOTER + HEADER + 1 + 20120831 + 5 + FACTUUR + 11024 + cash + 2012/8 + concept
- 1 + true
4
- 118 CoalesceFunctioningOnImpatienceTShirt - 15.00 + 8020 + + + + + + 1 + 118 1 + 15 VN - 8020
From f12e5e89e4ae448b159733981eb1f80310ec66a8 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 12:18:43 +0200 Subject: [PATCH 184/388] Update invoiceFinalGetResponse.xml --- tests/IntegrationTests/resources/invoiceFinalGetResponse.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/resources/invoiceFinalGetResponse.xml b/tests/IntegrationTests/resources/invoiceFinalGetResponse.xml index 357f8214..c672c4ec 100644 --- a/tests/IntegrationTests/resources/invoiceFinalGetResponse.xml +++ b/tests/IntegrationTests/resources/invoiceFinalGetResponse.xml @@ -10,7 +10,7 @@ 1 1 1000 - 2012/8 + 2012/08 EUR final cash From d0290b0e9b4cc568fbcfc78acf9c2cc1efd55cd0 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 12:18:46 +0200 Subject: [PATCH 185/388] Update invoiceConceptGetResponse.xml --- tests/IntegrationTests/resources/invoiceConceptGetResponse.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/resources/invoiceConceptGetResponse.xml b/tests/IntegrationTests/resources/invoiceConceptGetResponse.xml index bf499baa..64459c1f 100644 --- a/tests/IntegrationTests/resources/invoiceConceptGetResponse.xml +++ b/tests/IntegrationTests/resources/invoiceConceptGetResponse.xml @@ -10,7 +10,7 @@ 1 1 1000 - 2012/8 + 2012/08 EUR concept cash From 19a25cb5d17b5c15e9d5d346e02715ddff40de16 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 12:18:49 +0200 Subject: [PATCH 186/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index c8d47eac..91f8933c 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -72,7 +72,7 @@ public function testGetConceptInvoiceWorks() $this->assertSame(1, $invoice->getInvoiceAddressNumber()); $this->assertSame(1, $invoice->getDeliverAddressNumber()); $this->assertSame('1000', $invoice->getCustomerToCode()); - $this->assertSame('2012/8', $invoice->getPeriod()); + $this->assertSame('2012/08', $invoice->getPeriod()); $this->assertSame('EUR', $invoice->getCurrencyToCode()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\InvoiceStatus'); $this->assertSame($ReflectObject->getConstant('CONCEPT'), (string)$invoice->getStatus()); @@ -140,7 +140,7 @@ public function testGetFinalInvoiceWorks() $this->assertSame(1, $invoice->getInvoiceAddressNumber()); $this->assertSame(1, $invoice->getDeliverAddressNumber()); $this->assertSame('1000', $invoice->getCustomerToCode()); - $this->assertSame('2012/8', $invoice->getPeriod()); + $this->assertSame('2012/08', $invoice->getPeriod()); $this->assertSame('EUR', $invoice->getCurrencyToCode()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\InvoiceStatus'); $this->assertSame($ReflectObject->getConstant('FINAL'), (string)$invoice->getStatus()); @@ -201,7 +201,7 @@ public function testSendInvoiceWorks() $invoice->setInvoiceAddressNumber(1); $invoice->setDeliverAddressNumber(1); $invoice->setCustomer($customer); - $invoice->setPeriod('2012/8'); + $invoice->setPeriod('2012/08'); $invoice->setCurrencyFromCode('EUR'); $invoice->setStatusFromString('concept'); $invoice->setPaymentMethodFromString('cash'); From f47795364dee75ec3fe0c56adb4bc6c4e4945bce Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 12:18:52 +0200 Subject: [PATCH 187/388] Update invoiceSendRequest.xml --- tests/IntegrationTests/resources/invoiceSendRequest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/resources/invoiceSendRequest.xml b/tests/IntegrationTests/resources/invoiceSendRequest.xml index 07cccf2c..55be3f6e 100644 --- a/tests/IntegrationTests/resources/invoiceSendRequest.xml +++ b/tests/IntegrationTests/resources/invoiceSendRequest.xml @@ -15,7 +15,7 @@ FACTUUR 11024 cash - 2012/8 + 2012/08 concept From 6b5c4470c6a569d2cd137027124d3b399853dd7b Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 12:29:34 +0200 Subject: [PATCH 188/388] Add files via upload --- src/Fields/PeriodField.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Fields/PeriodField.php b/src/Fields/PeriodField.php index 32a030bc..30cbce06 100644 --- a/src/Fields/PeriodField.php +++ b/src/Fields/PeriodField.php @@ -5,8 +5,7 @@ trait PeriodField { /** - * Period in 'YYYY/PP' format (e.g. '2013/05'). If this tag is not included or if it is left empty, the period is - * determined by the system based on the provided transaction date. + * Period in 'YYYY/PP' format (e.g. '2013/05') * Used by: FixedAssetTransactionLine, Invoice * * @var string @@ -28,7 +27,7 @@ public function getPeriod(): ?string public function setPeriod(?string $period): self { if (!preg_match("!\\d{4}/\\d{1,2}!", $period)) { - throw new \InvalidArgumentException("Period must be in YYYY/PP format (got: {$period}."); + $period = ''; } $this->period = $period; From 3c15fba78186dfb94dc74f3c5d096e92f8a5cd5c Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 12:29:51 +0200 Subject: [PATCH 189/388] Add files via upload --- src/Fields/Level1234/Level34/FixedAsset/BeginPeriodField.php | 3 +-- .../Level1234/Level34/FixedAsset/LastDepreciationField.php | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Fields/Level1234/Level34/FixedAsset/BeginPeriodField.php b/src/Fields/Level1234/Level34/FixedAsset/BeginPeriodField.php index 051a75ee..1fac240a 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/BeginPeriodField.php +++ b/src/Fields/Level1234/Level34/FixedAsset/BeginPeriodField.php @@ -5,8 +5,7 @@ trait BeginPeriodField { /** - * BeginPeriod in 'YYYY/PP' format (e.g. '2013/05'). If this tag is not included or if it is left empty, the beginPeriod is - * determined by the system based on the provided transaction date. + * Begin period in 'YYYY/PP' format (e.g. '2013/05') * Used by: FixedAssetFixedAssets * * @var string diff --git a/src/Fields/Level1234/Level34/FixedAsset/LastDepreciationField.php b/src/Fields/Level1234/Level34/FixedAsset/LastDepreciationField.php index a59d6dbf..448dc222 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/LastDepreciationField.php +++ b/src/Fields/Level1234/Level34/FixedAsset/LastDepreciationField.php @@ -5,8 +5,7 @@ trait LastDepreciationField { /** - * LastDepreciation in 'YYYY/PP' format (e.g. '2013/05'). If this tag is not included or if it is left empty, the lastDepreciation is - * determined by the system based on the provided transaction date. + * Last depreciation in 'YYYY/PP' format (e.g. '2013/05') * Used by: FixedAssetFixedAssets * * @var string From 97634c1b2bf702b523851f6df1e9d082c0069ff0 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 12:39:39 +0200 Subject: [PATCH 190/388] Update OfficeTest.php --- tests/UnitTests/Supplier/OfficeTest.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/UnitTests/Supplier/OfficeTest.php b/tests/UnitTests/Supplier/OfficeTest.php index 65fc87c5..98befed6 100644 --- a/tests/UnitTests/Supplier/OfficeTest.php +++ b/tests/UnitTests/Supplier/OfficeTest.php @@ -48,9 +48,7 @@ public function testSetOfficeAndSerializes(Supplier $customer) $document = new SuppliersDocument; $document->addSupplier($customer); - - $documentDOM = new \DOMDocument($document); - $this->assertEquals($documentDOM->getElementsByTagName('office')->item(0)->nodeValue, $this->office); + $this->assertEquals($document->getElementsByTagName('office')->item(0)->nodeValue, $this->office); } } From 0637b3eb051d8a213e16a1bf2b3841f15fe0d7f4 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 12:54:30 +0200 Subject: [PATCH 191/388] Update CustomerIntegrationTest.php --- .../CustomerIntegrationTest.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 35e1c295..588181ba 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -148,26 +148,25 @@ public function testGetCustomerWorks() public function testListAllCustomersWorks() { - $response = Response::fromString(file_get_contents(__DIR__ . '/resources/customerListResponse.xml')); + $response = (object)json_decode(file_get_contents(__DIR__ . '/resources/customerListResponse.json'), true); $this->finderService ->expects($this->once()) ->method("searchFinder") - ->with($this->isInstanceOf(\PhpTwinfield\Response\Response::class)) ->willReturn($response); $customers = $this->customerApiConnector->listAll(); $this->assertCount(3, $customers); - $this->assertArrayHasKey('D1000', $customers); - $this->assertSame('John Doe', $customers['D1000']['name']); + $this->assertSame('D1000', $customers[0]->getCode()); + $this->assertSame('John Doe', $customers[0]->getName()); - $this->assertArrayHasKey('D1001', $customers); - $this->assertSame('B. Terwel', $customers['D1001']['name']); - - $this->assertArrayHasKey('D1002', $customers); - $this->assertSame('Hr E G H Küppers en/of MW M.J. Küppers-Veeneman', $customers['D1002']['name']); + $this->assertSame('D1001', $customers[1]->getCode()); + $this->assertSame('B. Terwel', $customers[1]->getName()); + + $this->assertSame('D1002', $customers[2]->getCode()); + $this->assertSame('Hr E G H Küppers en/of MW M.J. Küppers-Veeneman', $customers[2]->getName()); } public function testSendCustomerWorks() From 00463eee342193943e968d6b1bf131513c8353c6 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 12:54:32 +0200 Subject: [PATCH 192/388] Create customerListResponse.json --- tests/IntegrationTests/resources/customerListResponse.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 tests/IntegrationTests/resources/customerListResponse.json diff --git a/tests/IntegrationTests/resources/customerListResponse.json b/tests/IntegrationTests/resources/customerListResponse.json new file mode 100644 index 00000000..4e019565 --- /dev/null +++ b/tests/IntegrationTests/resources/customerListResponse.json @@ -0,0 +1 @@ +{"SearchResult":{},"data":{"TotalRows":3,"Columns":{"string":["Code","Naam"]},"Items":{"ArrayOfString":[{"string":["D1000","John Doe"]},{"string":["D1001","B. Terwel"]},{"string":["D1002","Hr E G H Küppers en/of MW M.J. Küppers-Veeneman"]}]}}} From 9619d3c3c564e8cb0432645562cd17fdfb6c029e Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 12:54:37 +0200 Subject: [PATCH 193/388] Delete customerListResponse.xml --- tests/IntegrationTests/resources/customerListResponse.xml | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 tests/IntegrationTests/resources/customerListResponse.xml diff --git a/tests/IntegrationTests/resources/customerListResponse.xml b/tests/IntegrationTests/resources/customerListResponse.xml deleted file mode 100644 index e4985032..00000000 --- a/tests/IntegrationTests/resources/customerListResponse.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - D1000 - D1001 - D1002 - DEB - From 6585b01c622f199d0b36847808aff12684d88618 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 13:08:14 +0200 Subject: [PATCH 194/388] Update CustomerIntegrationTest.php --- tests/IntegrationTests/CustomerIntegrationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 588181ba..138ee574 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -148,7 +148,7 @@ public function testGetCustomerWorks() public function testListAllCustomersWorks() { - $response = (object)json_decode(file_get_contents(__DIR__ . '/resources/customerListResponse.json'), true); + $response = json_decode(file_get_contents(__DIR__ . '/resources/customerListResponse.json')); $this->finderService ->expects($this->once()) From b26be1c34b58d55da0b25ca2ddb8d9e8a84cc750 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 13:12:07 +0200 Subject: [PATCH 195/388] Update CustomerIntegrationTest.php --- tests/IntegrationTests/CustomerIntegrationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 138ee574..f3822006 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -148,7 +148,7 @@ public function testGetCustomerWorks() public function testListAllCustomersWorks() { - $response = json_decode(file_get_contents(__DIR__ . '/resources/customerListResponse.json')); + $response = (object)json_decode(file_get_contents(__DIR__ . '/resources/customerListResponse.json')); $this->finderService ->expects($this->once()) From 703b4cd5ebabbe59885d2621a2335f7b4df84ae4 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 13:20:48 +0200 Subject: [PATCH 196/388] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 15c0454d..5a321994 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: php dist: trusty php: -- 7.1 +- 7.3 matrix: fast_finish: true From 1e94c04d6ae25b399552e3abf04ece4e07270b38 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 13:22:53 +0200 Subject: [PATCH 197/388] Add files via upload --- src/ApiConnectors/BaseApiConnector.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ApiConnectors/BaseApiConnector.php b/src/ApiConnectors/BaseApiConnector.php index dea8f536..f613e40d 100644 --- a/src/ApiConnectors/BaseApiConnector.php +++ b/src/ApiConnectors/BaseApiConnector.php @@ -46,7 +46,7 @@ public function __construct(AuthenticatedConnection $connection) { $this->connection = $connection; } - + public function getConnection() { return $this->connection; @@ -180,7 +180,7 @@ public function convertOptionsToArrayOfString(array $options, array $forcedOptio return $options; } else { $optionsArrayOfString = array('ArrayOfString' => array()); - + if (isset($forcedOptions)) { foreach ($forcedOptions as $key => $value) { unset($options[$key]); @@ -200,12 +200,12 @@ public function convertOptionsToArrayOfString(array $options, array $forcedOptio * Map the response of a listAll to an array of the requested class * * @param string $className - * @param object $data + * @param $data * @param array $objectListAllTags * @return array * @throws Exception */ - public function mapListAll(string $className, object $data, array $objectListAllTags): array { + public function mapListAll(string $className, $data, array $objectListAllTags): array { if ($data->TotalRows == 0) { return []; } @@ -232,4 +232,4 @@ public function mapListAll(string $className, object $data, array $objectListAll return $objects; } -} +} \ No newline at end of file From cd1cb4688cad09165ba1bbf9cd49af872a498712 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 13:22:58 +0200 Subject: [PATCH 198/388] Update .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5a321994..15c0454d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: php dist: trusty php: -- 7.3 +- 7.1 matrix: fast_finish: true From 2df7f55040b9b3ca3ea968ba13ffce706156eee6 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 13:30:52 +0200 Subject: [PATCH 199/388] Update .travis.yml --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 15c0454d..754323e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,9 @@ dist: trusty php: - 7.1 +- 7.2 +- 7.3 +- nightly matrix: fast_finish: true From 128aed7ebcd48dcd09ba1fe71f5dbbe617b3ad81 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 22:03:21 +0200 Subject: [PATCH 200/388] Upload --- src/Activity.php | 6 +- src/ApiConnectors/BaseApiConnector.php | 2 +- src/ApiConnectors/InvoiceApiConnector.php | 2 +- src/ApiConnectors/OfficeApiConnector.php | 2 +- src/Article.php | 8 +- src/ArticleLine.php | 8 +- src/CostCenter.php | 6 +- src/Customer.php | 18 +-- src/CustomerAddress.php | 4 +- src/CustomerChildValidation.php | 4 +- src/CustomerCollectMandate.php | 4 +- src/CustomerCreditManagement.php | 4 +- src/DimensionGroupDimension.php | 8 +- src/DimensionTypeLevels.php | 8 +- src/DomDocuments/ActivitiesDocument.php | 10 +- src/DomDocuments/ArticlesDocument.php | 8 +- src/DomDocuments/AssetMethodsDocument.php | 22 ++-- src/DomDocuments/CostCentersDocument.php | 4 +- src/DomDocuments/CurrenciesDocument.php | 2 +- src/DomDocuments/CustomersDocument.php | 32 +++--- src/DomDocuments/DimensionGroupsDocument.php | 6 +- src/DomDocuments/DimensionTypesDocument.php | 2 +- src/DomDocuments/FixedAssetsDocument.php | 26 ++--- src/DomDocuments/GeneralLedgersDocument.php | 8 +- src/DomDocuments/InvoicesDocument.php | 22 ++-- src/DomDocuments/ProjectsDocument.php | 10 +- src/DomDocuments/RatesDocument.php | 4 +- src/DomDocuments/SuppliersDocument.php | 28 ++--- src/DomDocuments/VatCodesDocument.php | 6 +- ...LedgerType.php => ChildValidationType.php} | 32 +++--- .../AssetMethod/AssetsToActivateField.php | 4 +- src/Fields/AssetMethod/DepreciationField.php | 4 +- .../AssetMethod/DepreciationGroupField.php | 4 +- src/Fields/AssetMethod/PurchaseValueField.php | 4 +- .../AssetMethod/PurchaseValueGroupField.php | 4 +- .../AssetMethod/ReconciliationField.php | 4 +- src/Fields/AssetMethod/SalesField.php | 4 +- src/Fields/AssetMethod/ToBeInvoicedField.php | 4 +- src/Fields/CurrencyField.php | 4 +- src/Fields/CustomerField.php | 4 +- src/Fields/Dim1Field.php | 4 +- ...eFreeText1Field.php => FreeText1Field.php} | 108 +++++++++--------- ...eFreeText2Field.php => FreeText2Field.php} | 108 +++++++++--------- ...ercentageField.php => PercentageField.php} | 92 +++++++-------- .../{ArticleTypeField.php => TypeField.php} | 80 ++++++------- src/Fields/Invoice/ArticleField.php | 4 +- src/Fields/Invoice/BankField.php | 4 +- ...itCreditField.php => DebitCreditField.php} | 80 ++++++------- src/Fields/Invoice/InvoiceTypeField.php | 4 +- ...InvoiceStatusField.php => StatusField.php} | 80 ++++++------- src/Fields/Invoice/SubArticleField.php | 4 +- ...inPeriodField.php => BeginPeriodField.php} | 62 +++++----- .../{DimensionCodeField.php => CodeField.php} | 108 +++++++++--------- .../GroupField.php} | 108 +++++++++--------- ...inancialsField.php => FinancialsField.php} | 62 +++++----- ...mensionTypeTimeField.php => TimeField.php} | 62 +++++----- .../TypeField.php} | 108 +++++++++--------- ...rEndPeriodField.php => EndPeriodField.php} | 62 +++++----- .../Level1234/Level2/AddressField2Field.php | 12 +- .../Level1234/Level2/AddressField3Field.php | 12 +- src/Fields/Level1234/Level2/CountryField.php | 4 +- .../Level2/Customer/DiscountArticleField.php | 4 +- ...rFreeText1Field.php => FreeText1Field.php} | 92 +++++++-------- ...{CollectMandateIDField.php => IDField.php} | 62 +++++----- .../Level2/Customer/ResponsibleUserField.php | 4 +- .../Level1234/Level2/Dimension1Field.php | 4 +- .../Level1234/Level2/Dimension2Field.php | 4 +- .../Level1234/Level2/Dimension3Field.php | 4 +- src/Fields/Level1234/Level2/PayCodeField.php | 4 +- .../{AddressTypeField.php => TypeField.php} | 80 ++++++------- .../Level1234/Level34/AuthoriserField.php | 4 +- ...{FixedAssetCodeField.php => CodeField.php} | 80 ++++++------- ...odeLockedField.php => CodeLockedField.php} | 92 +++++++-------- .../Level34/FixedAsset/Dim2Field.php | 4 +- .../Level34/FixedAsset/Dim3Field.php | 4 +- .../Level34/FixedAsset/Dim4Field.php | 4 +- .../Level34/FixedAsset/Dim5Field.php | 4 +- .../Level34/FixedAsset/Dim6Field.php | 4 +- ...dAssetsMethodField.php => MethodField.php} | 108 +++++++++--------- ...dLockedField.php => MethodLockedField.php} | 92 +++++++-------- ...dAssetsStatusField.php => StatusField.php} | 80 ++++++------- ...sLockedField.php => StatusLockedField.php} | 92 +++++++-------- src/Fields/Level1234/SubstituteWithField.php | 4 +- ...neralLedgerTypeField.php => TypeField.php} | 80 ++++++------- src/Fields/Office/CountryCodeField.php | 42 +++++-- src/Fields/OfficeField.php | 4 +- src/Fields/RateField.php | 4 +- src/Fields/UserField.php | 4 +- ...CountryField.php => GroupCountryField.php} | 106 ++++++++--------- .../{VatGroupField.php => GroupField.php} | 106 ++++++++--------- src/Fields/VatCode/LineTypeField.php | 8 +- .../{VatCodeTypeField.php => TypeField.php} | 80 ++++++------- src/Fields/VatCodeField.php | 4 +- src/FixedAsset.php | 12 +- src/FixedAssetFixedAssets.php | 16 +-- src/FixedAssetTransactionLine.php | 8 +- src/GeneralLedger.php | 16 +-- src/GeneralLedgerChildValidation.php | 4 +- src/Invoice.php | 8 +- src/Mappers/ArticleMapper.php | 4 +- src/Mappers/AssetMethodMapper.php | 16 +-- src/Mappers/BaseMapper.php | 2 +- src/Mappers/CustomerMapper.php | 10 +- src/Mappers/FixedAssetMapper.php | 2 +- src/Mappers/GeneralLedgerMapper.php | 2 +- src/Mappers/InvoiceMapper.php | 2 +- src/Mappers/MatchSetMapper.php | 2 +- src/Mappers/SupplierMapper.php | 10 +- src/Mappers/VatCodeMapper.php | 2 +- src/Project.php | 6 +- src/Supplier.php | 18 +-- src/SupplierAddress.php | 4 +- src/SupplierChildValidation.php | 4 +- src/SupplierPostingRule.php | 2 +- src/VatCode.php | 4 +- src/VatCodeAccount.php | 8 +- .../CustomerIntegrationTest.php | 24 ++-- .../InvoiceIntegrationTest.php | 40 +++---- .../CustomersDocumentUnitTest.php | 14 +-- 119 files changed, 1522 insertions(+), 1500 deletions(-) rename src/Enums/{GeneralLedgerType.php => ChildValidationType.php} (52%) rename src/Fields/Invoice/Article/{ArticleLineFreeText1Field.php => FreeText1Field.php} (82%) rename src/Fields/Invoice/Article/{ArticleLineFreeText2Field.php => FreeText2Field.php} (82%) rename src/Fields/Invoice/Article/{ArticlePercentageField.php => PercentageField.php} (89%) rename src/Fields/Invoice/Article/{ArticleTypeField.php => TypeField.php} (88%) rename src/Fields/Invoice/{InvoiceDebitCreditField.php => DebitCreditField.php} (88%) rename src/Fields/Invoice/{InvoiceStatusField.php => StatusField.php} (88%) rename src/Fields/Level1234/{GeneralLedgerBeginPeriodField.php => BeginPeriodField.php} (89%) rename src/Fields/Level1234/DimensionGroup/{DimensionCodeField.php => CodeField.php} (82%) rename src/Fields/Level1234/{DimensionGroupField.php => DimensionGroup/GroupField.php} (79%) rename src/Fields/Level1234/DimensionType/{DimensionTypeFinancialsField.php => FinancialsField.php} (82%) rename src/Fields/Level1234/DimensionType/{DimensionTypeTimeField.php => TimeField.php} (83%) rename src/Fields/Level1234/{DimensionTypeField.php => DimensionType/TypeField.php} (80%) rename src/Fields/Level1234/{GeneralLedgerEndPeriodField.php => EndPeriodField.php} (89%) rename src/Fields/Level1234/Level2/Customer/{CustomerFreeText1Field.php => FreeText1Field.php} (92%) rename src/Fields/Level1234/Level2/Customer/{CollectMandateIDField.php => IDField.php} (89%) rename src/Fields/Level1234/Level2/{AddressTypeField.php => TypeField.php} (89%) rename src/Fields/Level1234/Level34/FixedAsset/{FixedAssetCodeField.php => CodeField.php} (84%) rename src/Fields/Level1234/Level34/FixedAsset/{FixedAssetCodeLockedField.php => CodeLockedField.php} (88%) rename src/Fields/Level1234/Level34/FixedAsset/{FixedAssetsMethodField.php => MethodField.php} (80%) rename src/Fields/Level1234/Level34/FixedAsset/{FixedAssetsMethodLockedField.php => MethodLockedField.php} (88%) rename src/Fields/Level1234/Level34/FixedAsset/{FixedAssetsStatusField.php => StatusField.php} (88%) rename src/Fields/Level1234/Level34/FixedAsset/{FixedAssetsStatusLockedField.php => StatusLockedField.php} (88%) rename src/Fields/Level1234/{GeneralLedgerTypeField.php => TypeField.php} (55%) rename src/Fields/VatCode/{VatGroupCountryField.php => GroupCountryField.php} (82%) rename src/Fields/VatCode/{VatGroupField.php => GroupField.php} (82%) rename src/Fields/VatCode/{VatCodeTypeField.php => TypeField.php} (91%) diff --git a/src/Activity.php b/src/Activity.php index 594aaf99..a6cc3f7f 100644 --- a/src/Activity.php +++ b/src/Activity.php @@ -5,7 +5,7 @@ use PhpTwinfield\Fields\BehaviourField; use PhpTwinfield\Fields\CodeField; use PhpTwinfield\Fields\InUseField; -use PhpTwinfield\Fields\Level1234\DimensionTypeField; +use PhpTwinfield\Fields\Level1234\DimensionType\TypeField; use PhpTwinfield\Fields\NameField; use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\ShortNameField; @@ -23,13 +23,13 @@ class Activity extends BaseObject { use BehaviourField; use CodeField; - use DimensionTypeField; use InUseField; use NameField; use OfficeField; use ShortNameField; use StatusField; use TouchedField; + use TypeField; use UIDField; use VatCodeField; @@ -37,7 +37,7 @@ class Activity extends BaseObject public function __construct() { - $this->setTypeFromCode('ACT'); + $this->setTypeFromString('ACT'); $this->setProjects(new ActivityProjects); } diff --git a/src/ApiConnectors/BaseApiConnector.php b/src/ApiConnectors/BaseApiConnector.php index 10ddeb88..f613e40d 100644 --- a/src/ApiConnectors/BaseApiConnector.php +++ b/src/ApiConnectors/BaseApiConnector.php @@ -232,4 +232,4 @@ public function mapListAll(string $className, $data, array $objectListAllTags): return $objects; } -} +} \ No newline at end of file diff --git a/src/ApiConnectors/InvoiceApiConnector.php b/src/ApiConnectors/InvoiceApiConnector.php index 7fbec112..5012bbdf 100644 --- a/src/ApiConnectors/InvoiceApiConnector.php +++ b/src/ApiConnectors/InvoiceApiConnector.php @@ -119,7 +119,7 @@ public function listAll( $invoiceListAllTags = array( 0 => 'setInvoiceNumber', 1 => 'setInvoiceAmountFromFloat', - 2 => 'setCustomerFromCode', + 2 => 'setCustomerFromString', 3 => 'setCustomerName', 4 => 'setDebitCreditFromString', ); diff --git a/src/ApiConnectors/OfficeApiConnector.php b/src/ApiConnectors/OfficeApiConnector.php index cc7be08b..534dfdd3 100644 --- a/src/ApiConnectors/OfficeApiConnector.php +++ b/src/ApiConnectors/OfficeApiConnector.php @@ -92,7 +92,7 @@ public function listAll( $officeListAllTags = array( 0 => 'setCode', 1 => 'setName', - 2 => 'setCountryCode', + 2 => 'setCountryCodeFromString', 3 => 'setVatPeriod', 4 => 'setVatFirstQuarterStartsIn', ); diff --git a/src/Article.php b/src/Article.php index 8dd71d7a..ce600a12 100644 --- a/src/Article.php +++ b/src/Article.php @@ -8,8 +8,8 @@ use PhpTwinfield\Fields\Invoice\Article\AllowChangeUnitsPriceField; use PhpTwinfield\Fields\Invoice\Article\AllowChangeVatCodeField; use PhpTwinfield\Fields\Invoice\Article\AllowDecimalQuantityField; -use PhpTwinfield\Fields\Invoice\Article\ArticlePercentageField; -use PhpTwinfield\Fields\Invoice\Article\ArticleTypeField; +use PhpTwinfield\Fields\Invoice\Article\PercentageField; +use PhpTwinfield\Fields\Invoice\Article\TypeField; use PhpTwinfield\Fields\Invoice\Article\UnitNamePluralField; use PhpTwinfield\Fields\Invoice\Article\UnitNameSingularField; use PhpTwinfield\Fields\Invoice\PerformanceTypeField; @@ -30,14 +30,14 @@ class Article extends BaseObject use AllowChangeVatCodeField; use AllowDecimalQuantityField; use AllowDiscountOrPremiumField; - use ArticlePercentageField; - use ArticleTypeField; use CodeField; use NameField; use OfficeField; + use PercentageField; use PerformanceTypeField; use ShortNameField; use StatusField; + use TypeField; use UnitNamePluralField; use UnitNameSingularField; use VatCodeField; diff --git a/src/ArticleLine.php b/src/ArticleLine.php index 42e5f81b..b5109166 100644 --- a/src/ArticleLine.php +++ b/src/ArticleLine.php @@ -5,8 +5,8 @@ use PhpTwinfield\Fields\FreeText3Field; use PhpTwinfield\Fields\IDField; use PhpTwinfield\Fields\InUseField; -use PhpTwinfield\Fields\Invoice\Article\ArticleLineFreeText1Field; -use PhpTwinfield\Fields\Invoice\Article\ArticleLineFreeText2Field; +use PhpTwinfield\Fields\Invoice\Article\FreeText1Field; +use PhpTwinfield\Fields\Invoice\Article\FreeText2Field; use PhpTwinfield\Fields\Invoice\Article\SubCodeField; use PhpTwinfield\Fields\Invoice\UnitsField; use PhpTwinfield\Fields\Invoice\UnitsPriceExclField; @@ -21,8 +21,8 @@ */ class ArticleLine extends BaseObject { - use ArticleLineFreeText1Field; - use ArticleLineFreeText2Field; + use FreeText1Field; + use FreeText2Field; use FreeText3Field; use IDField; use InUseField; diff --git a/src/CostCenter.php b/src/CostCenter.php index d649ec58..0a1fa227 100644 --- a/src/CostCenter.php +++ b/src/CostCenter.php @@ -5,7 +5,7 @@ use PhpTwinfield\Fields\BehaviourField; use PhpTwinfield\Fields\CodeField; use PhpTwinfield\Fields\InUseField; -use PhpTwinfield\Fields\Level1234\DimensionTypeField; +use PhpTwinfield\Fields\Level1234\DimensionType\TypeField; use PhpTwinfield\Fields\NameField; use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\ShortNameField; @@ -22,17 +22,17 @@ class CostCenter extends BaseObject { use BehaviourField; use CodeField; - use DimensionTypeField; use InUseField; use NameField; use OfficeField; use ShortNameField; use StatusField; use TouchedField; + use TypeField; use UIDField; public function __construct() { - $this->setTypeFromCode('KPL'); + $this->setTypeFromString('KPL'); } } diff --git a/src/Customer.php b/src/Customer.php index 0b6b6801..8d891e14 100644 --- a/src/Customer.php +++ b/src/Customer.php @@ -5,12 +5,12 @@ use PhpTwinfield\Fields\BehaviourField; use PhpTwinfield\Fields\CodeField; use PhpTwinfield\Fields\InUseField; +use PhpTwinfield\Fields\Level1234\BeginPeriodField; use PhpTwinfield\Fields\Level1234\BeginYearField; -use PhpTwinfield\Fields\Level1234\DimensionGroupField; -use PhpTwinfield\Fields\Level1234\DimensionTypeField; +use PhpTwinfield\Fields\Level1234\DimensionGroup\GroupField; +use PhpTwinfield\Fields\Level1234\DimensionType\TypeField; +use PhpTwinfield\Fields\Level1234\EndPeriodField; use PhpTwinfield\Fields\Level1234\EndYearField; -use PhpTwinfield\Fields\Level1234\GeneralLedgerBeginPeriodField; -use PhpTwinfield\Fields\Level1234\GeneralLedgerEndPeriodField; use PhpTwinfield\Fields\Level1234\Level2\Customer\DiscountArticleField; use PhpTwinfield\Fields\Level1234\Level2\Customer\DiscountArticleIDField; use PhpTwinfield\Fields\Level1234\Level2\PaymentConditionDiscountDaysField; @@ -31,16 +31,15 @@ */ class Customer extends BaseObject { + use BeginPeriodField; use BeginYearField; use BehaviourField; use CodeField; - use DimensionGroupField; - use DimensionTypeField; use DiscountArticleField; use DiscountArticleIDField; + use EndPeriodField; use EndYearField; - use GeneralLedgerBeginPeriodField; - use GeneralLedgerEndPeriodField; + use GroupField; use InUseField; use NameField; use OfficeField; @@ -51,6 +50,7 @@ class Customer extends BaseObject use ShortNameField; use StatusField; use TouchedField; + use TypeField; use UIDField; use WebsiteField; @@ -66,7 +66,7 @@ public function __construct() $this->setBeginYear(0); $this->setEndPeriod(0); $this->setEndYear(0); - $this->setTypeFromCode('DEB'); + $this->setTypeFromString('DEB'); $this->setCreditManagement(new CustomerCreditManagement); $this->setFinancials(new CustomerFinancials); diff --git a/src/CustomerAddress.php b/src/CustomerAddress.php index 4884d488..9e3c7b93 100644 --- a/src/CustomerAddress.php +++ b/src/CustomerAddress.php @@ -3,7 +3,6 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\IDField; -use PhpTwinfield\Fields\Level1234\Level2\AddressTypeField; use PhpTwinfield\Fields\Level1234\Level2\CityField; use PhpTwinfield\Fields\Level1234\Level2\CountryField; use PhpTwinfield\Fields\Level1234\Level2\DefaultField; @@ -17,6 +16,7 @@ use PhpTwinfield\Fields\Level1234\Level2\PostcodeField; use PhpTwinfield\Fields\Level1234\Level2\TelefaxField; use PhpTwinfield\Fields\Level1234\Level2\TelephoneField; +use PhpTwinfield\Fields\Level1234\Level2\TypeField; use PhpTwinfield\Fields\NameField; /** @@ -25,7 +25,6 @@ */ class CustomerAddress extends BaseObject { - use AddressTypeField; use CityField; use CountryField; use DefaultField; @@ -41,4 +40,5 @@ class CustomerAddress extends BaseObject use PostcodeField; use TelefaxField; use TelephoneField; + use TypeField; } \ No newline at end of file diff --git a/src/CustomerChildValidation.php b/src/CustomerChildValidation.php index b06bff43..36789b57 100644 --- a/src/CustomerChildValidation.php +++ b/src/CustomerChildValidation.php @@ -4,7 +4,7 @@ use PhpTwinfield\Fields\ElementValueField; use PhpTwinfield\Fields\Level1234\LevelField; -use PhpTwinfield\Fields\Level1234\GeneralLedgerTypeField; +use PhpTwinfield\Fields\Level1234\TypeField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers @@ -14,5 +14,5 @@ class CustomerChildValidation extends BaseObject { use ElementValueField; use LevelField; - use GeneralLedgerTypeField; + use TypeField; } diff --git a/src/CustomerCollectMandate.php b/src/CustomerCollectMandate.php index 1bcf0d91..7860d69e 100644 --- a/src/CustomerCollectMandate.php +++ b/src/CustomerCollectMandate.php @@ -2,8 +2,8 @@ namespace PhpTwinfield; -use PhpTwinfield\Fields\Level1234\Level2\Customer\CollectMandateIDField; use PhpTwinfield\Fields\Level1234\Level2\Customer\FirstRunDateField; +use PhpTwinfield\Fields\Level1234\Level2\Customer\IDField; use PhpTwinfield\Fields\Level1234\Level2\Customer\SignatureDateField; /** @@ -12,7 +12,7 @@ */ class CustomerCollectMandate extends BaseObject { - use CollectMandateIDField; use FirstRunDateField; + use IDField; use SignatureDateField; } diff --git a/src/CustomerCreditManagement.php b/src/CustomerCreditManagement.php index 9a3aefb2..ddb1addd 100644 --- a/src/CustomerCreditManagement.php +++ b/src/CustomerCreditManagement.php @@ -9,7 +9,7 @@ use PhpTwinfield\Fields\Level1234\Level2\Customer\BlockedLockedField; use PhpTwinfield\Fields\Level1234\Level2\Customer\BlockedModifiedField; use PhpTwinfield\Fields\Level1234\Level2\Customer\CommentField; -use PhpTwinfield\Fields\Level1234\Level2\Customer\CustomerFreeText1Field; +use PhpTwinfield\Fields\Level1234\Level2\Customer\FreeText1Field; use PhpTwinfield\Fields\Level1234\Level2\Customer\ReminderEmailField; use PhpTwinfield\Fields\Level1234\Level2\Customer\ResponsibleUserField; use PhpTwinfield\Fields\Level1234\Level2\Customer\SendReminderField; @@ -25,7 +25,7 @@ class CustomerCreditManagement extends BaseObject use BlockedLockedField; use BlockedModifiedField; use CommentField; - use CustomerFreeText1Field; + use FreeText1Field; use FreeText2Field; use FreeText3Field; use ReminderEmailField; diff --git a/src/DimensionGroupDimension.php b/src/DimensionGroupDimension.php index 3825b7f4..a43ee168 100644 --- a/src/DimensionGroupDimension.php +++ b/src/DimensionGroupDimension.php @@ -2,8 +2,8 @@ namespace PhpTwinfield; -use PhpTwinfield\Fields\Level1234\DimensionGroup\DimensionCodeField; -use PhpTwinfield\Fields\Level1234\DimensionTypeField; +use PhpTwinfield\Fields\Level1234\DimensionGroup\CodeField; +use PhpTwinfield\Fields\Level1234\DimensionType\TypeField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionGroups @@ -11,6 +11,6 @@ */ class DimensionGroupDimension extends BaseObject { - use DimensionCodeField; - use DimensionTypeField; + use CodeField; + use TypeField; } diff --git a/src/DimensionTypeLevels.php b/src/DimensionTypeLevels.php index 124a1480..c1a23b36 100644 --- a/src/DimensionTypeLevels.php +++ b/src/DimensionTypeLevels.php @@ -2,8 +2,8 @@ namespace PhpTwinfield; -use PhpTwinfield\Fields\Level1234\DimensionType\DimensionTypeFinancialsField; -use PhpTwinfield\Fields\Level1234\DimensionType\DimensionTypeTimeField; +use PhpTwinfield\Fields\Level1234\DimensionType\FinancialsField; +use PhpTwinfield\Fields\Level1234\DimensionType\TimeField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionTypes @@ -11,6 +11,6 @@ */ class DimensionTypeLevels extends BaseObject { - use DimensionTypeFinancialsField; - use DimensionTypeTimeField; + use FinancialsField; + use TimeField; } diff --git a/src/DomDocuments/ActivitiesDocument.php b/src/DomDocuments/ActivitiesDocument.php index 65723afb..2e87cc38 100644 --- a/src/DomDocuments/ActivitiesDocument.php +++ b/src/DomDocuments/ActivitiesDocument.php @@ -44,21 +44,21 @@ public function addActivity(Activity $activity) $activityElement->appendChild($this->createNodeWithTextContent('code', $activity->getCode())); $activityElement->appendChild($this->createNodeWithTextContent('name', $activity->getName())); - $activityElement->appendChild($this->createNodeWithTextContent('office', $activity->getOfficeToCode())); + $activityElement->appendChild($this->createNodeWithTextContent('office', $activity->getOfficeToString())); $activityElement->appendChild($this->createNodeWithTextContent('shortname', $activity->getShortName())); - $activityElement->appendChild($this->createNodeWithTextContent('type', $activity->getTypeToCode())); + $activityElement->appendChild($this->createNodeWithTextContent('type', $activity->getTypeToString())); $financialsElement = $this->createElement('financials'); $activityElement->appendChild($financialsElement); - $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $activity->getVatCodeToCode())); + $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $activity->getVatCodeToString())); $projects = $activity->getProjects(); $projectsElement = $this->createElement('projects'); $activityElement->appendChild($projectsElement); - $inheritArray = array('authoriser' => 'getAuthoriserToCode', 'billable' => 'getBillableToString', 'customer' => 'getCustomerToCode', 'rate' => 'getRateToCode'); + $inheritArray = array('authoriser' => 'getAuthoriserToString', 'billable' => 'getBillableToString', 'customer' => 'getCustomerToString', 'rate' => 'getRateToString'); foreach ($inheritArray as $inheritVar => $method) { $methodLocked = "get" . ucfirst($inheritVar) . "Locked"; @@ -98,7 +98,7 @@ public function addActivity(Activity $activity) $quantitiesElement->appendChild($quantityElement); $quantityElement->appendChild($this->createNodeWithTextContent('label', $quantity->getLabel())); - $quantityElement->appendChild($this->createNodeWithTextContent('rate', $quantity->getRateToCode())); + $quantityElement->appendChild($this->createNodeWithTextContent('rate', $quantity->getRateToString())); $quantityElement->appendChild($this->createNodeWithTextContent('billable', $quantity->getBillableToString(), $quantity, array('locked' => 'getBillableLockedToString'))); $quantityElement->appendChild($this->createNodeWithTextContent('mandatory', $quantity->getMandatoryToString())); } diff --git a/src/DomDocuments/ArticlesDocument.php b/src/DomDocuments/ArticlesDocument.php index c1a7cd73..a3c2f39b 100644 --- a/src/DomDocuments/ArticlesDocument.php +++ b/src/DomDocuments/ArticlesDocument.php @@ -52,7 +52,7 @@ public function addArticle(Article $article) $headerElement->appendChild($this->createNodeWithTextContent('allowdecimalquantity', $article->getAllowDecimalQuantityToString())); $headerElement->appendChild($this->createNodeWithTextContent('allowdiscountorpremium', $article->getAllowDiscountOrPremiumToString())); $headerElement->appendChild($this->createNodeWithTextContent('code', $article->getCode())); - $headerElement->appendChild($this->createNodeWithTextContent('office', $article->getOfficeToCode())); + $headerElement->appendChild($this->createNodeWithTextContent('office', $article->getOfficeToString())); $headerElement->appendChild($this->createNodeWithTextContent('name', $article->getName())); $headerElement->appendChild($this->createNodeWithTextContent('percentage', $article->getPercentageToString())); $headerElement->appendChild($this->createNodeWithTextContent('performancetype', $article->getPerformanceType())); @@ -60,7 +60,7 @@ public function addArticle(Article $article) $headerElement->appendChild($this->createNodeWithTextContent('type', $article->getType())); $headerElement->appendChild($this->createNodeWithTextContent('unitnameplural', $article->getUnitNamePlural())); $headerElement->appendChild($this->createNodeWithTextContent('unitnamesingular', $article->getUnitNameSingular())); - $headerElement->appendChild($this->createNodeWithTextContent('vatcode', $article->getVatCodeToCode())); + $headerElement->appendChild($this->createNodeWithTextContent('vatcode', $article->getVatCodeToString())); //Clear VAT code in case of a discount/premium article with percentage set to true to prevent errors if ($article->getType() != "normal" && $article->getPercentage() == true) { @@ -92,8 +92,8 @@ public function addArticle(Article $article) $lineElement->setAttribute('status', $status); } - $lineElement->appendChild($this->createNodeWithTextContent('freetext1', $line->getFreeText1ToCode())); - $lineElement->appendChild($this->createNodeWithTextContent('freetext2', $line->getFreeText2ToCode())); + $lineElement->appendChild($this->createNodeWithTextContent('freetext1', $line->getFreeText1ToString())); + $lineElement->appendChild($this->createNodeWithTextContent('freetext2', $line->getFreeText2ToString())); $lineElement->appendChild($this->createNodeWithTextContent('freetext3', $line->getFreeText3())); $lineElement->appendChild($this->createNodeWithTextContent('name', $line->getName())); $lineElement->appendChild($this->createNodeWithTextContent('shortname', $line->getShortName())); diff --git a/src/DomDocuments/AssetMethodsDocument.php b/src/DomDocuments/AssetMethodsDocument.php index 6d25378f..7459b797 100644 --- a/src/DomDocuments/AssetMethodsDocument.php +++ b/src/DomDocuments/AssetMethodsDocument.php @@ -41,7 +41,7 @@ public function addAssetMethod(AssetMethod $assetMethod) $assetMethodElement->appendChild($this->createNodeWithTextContent('depreciatereconciliation', $assetMethod->getDepreciateReconciliation())); $assetMethodElement->appendChild($this->createNodeWithTextContent('name', $assetMethod->getName())); $assetMethodElement->appendChild($this->createNodeWithTextContent('nrofperiods', $assetMethod->getNrOfPeriods())); - $assetMethodElement->appendChild($this->createNodeWithTextContent('office', $assetMethod->getOfficeToCode())); + $assetMethodElement->appendChild($this->createNodeWithTextContent('office', $assetMethod->getOfficeToString())); $assetMethodElement->appendChild($this->createNodeWithTextContent('percentage', $assetMethod->getPercentage())); $assetMethodElement->appendChild($this->createNodeWithTextContent('shortname', $assetMethod->getShortName())); @@ -50,22 +50,22 @@ public function addAssetMethod(AssetMethod $assetMethod) $balanceAccountsElement = $this->createElement('balanceaccounts'); $assetMethodElement->appendChild($balanceAccountsElement); - $balanceAccountsElement->appendChild($this->createNodeWithTextContent('assetstoactivate', $balanceAccounts->getAssetsToActivateToCode())); - $balanceAccountsElement->appendChild($this->createNodeWithTextContent('depreciation', $balanceAccounts->getDepreciationToCode())); - $balanceAccountsElement->appendChild($this->createNodeWithTextContent('depreciationgroup', $balanceAccounts->getDepreciationGroupToCode())); - $balanceAccountsElement->appendChild($this->createNodeWithTextContent('purchasevalue', $balanceAccounts->getPurchaseValueToCode())); - $balanceAccountsElement->appendChild($this->createNodeWithTextContent('purchasevaluegroup', $balanceAccounts->getPurchaseValueGroupToCode())); - $balanceAccountsElement->appendChild($this->createNodeWithTextContent('reconciliation', $balanceAccounts->getReconciliationToCode())); - $balanceAccountsElement->appendChild($this->createNodeWithTextContent('tobeinvoiced', $balanceAccounts->getToBeInvoicedToCode())); + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('assetstoactivate', $balanceAccounts->getAssetsToActivateToString())); + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('depreciation', $balanceAccounts->getDepreciationToString())); + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('depreciationgroup', $balanceAccounts->getDepreciationGroupToString())); + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('purchasevalue', $balanceAccounts->getPurchaseValueToString())); + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('purchasevaluegroup', $balanceAccounts->getPurchaseValueGroupToString())); + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('reconciliation', $balanceAccounts->getReconciliationToString())); + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('tobeinvoiced', $balanceAccounts->getToBeInvoicedToString())); $profitLossAccounts = $assetMethod->getProfitLossAccounts(); $profitLossAccountsElement = $this->createElement('profitlossaccounts'); $assetMethodElement->appendChild($profitLossAccountsElement); - $profitLossAccountsElement->appendChild($this->createNodeWithTextContent('depreciation', $profitLossAccounts->getDepreciationToCode())); - $profitLossAccountsElement->appendChild($this->createNodeWithTextContent('reconciliation', $profitLossAccounts->getReconciliationToCode())); - $profitLossAccountsElement->appendChild($this->createNodeWithTextContent('sales', $profitLossAccounts->getSalesToCode())); + $profitLossAccountsElement->appendChild($this->createNodeWithTextContent('depreciation', $profitLossAccounts->getDepreciationToString())); + $profitLossAccountsElement->appendChild($this->createNodeWithTextContent('reconciliation', $profitLossAccounts->getReconciliationToString())); + $profitLossAccountsElement->appendChild($this->createNodeWithTextContent('sales', $profitLossAccounts->getSalesToString())); $freeTexts = $assetMethod->getFreeTexts(); diff --git a/src/DomDocuments/CostCentersDocument.php b/src/DomDocuments/CostCentersDocument.php index ac22394b..81dc3d8d 100644 --- a/src/DomDocuments/CostCentersDocument.php +++ b/src/DomDocuments/CostCentersDocument.php @@ -44,7 +44,7 @@ public function addCostCenter(CostCenter $costCenter) $costCenterElement->appendChild($this->createNodeWithTextContent('code', $costCenter->getCode())); $costCenterElement->appendChild($this->createNodeWithTextContent('name', $costCenter->getName())); - $costCenterElement->appendChild($this->createNodeWithTextContent('office', $costCenter->getOfficeToCode())); - $costCenterElement->appendChild($this->createNodeWithTextContent('type', $costCenter->getTypeToCode())); + $costCenterElement->appendChild($this->createNodeWithTextContent('office', $costCenter->getOfficeToString())); + $costCenterElement->appendChild($this->createNodeWithTextContent('type', $costCenter->getTypeToString())); } } diff --git a/src/DomDocuments/CurrenciesDocument.php b/src/DomDocuments/CurrenciesDocument.php index 260c372f..a92ec65f 100644 --- a/src/DomDocuments/CurrenciesDocument.php +++ b/src/DomDocuments/CurrenciesDocument.php @@ -44,7 +44,7 @@ public function addCurrency(Currency $currency) $currencyElement->appendChild($this->createNodeWithTextContent('code', $currency->getCode())); $currencyElement->appendChild($this->createNodeWithTextContent('name', $currency->getName())); - $currencyElement->appendChild($this->createNodeWithTextContent('office', $currency->getOfficeToCode())); + $currencyElement->appendChild($this->createNodeWithTextContent('office', $currency->getOfficeToString())); $currencyElement->appendChild($this->createNodeWithTextContent('shortname', $currency->getShortName())); $rates = $currency->getRates(); diff --git a/src/DomDocuments/CustomersDocument.php b/src/DomDocuments/CustomersDocument.php index 8ca18d2a..e5bd411f 100644 --- a/src/DomDocuments/CustomersDocument.php +++ b/src/DomDocuments/CustomersDocument.php @@ -48,9 +48,9 @@ public function addCustomer(Customer $customer) $customerElement->appendChild($this->createNodeWithTextContent('endperiod', $customer->getEndPeriod())); $customerElement->appendChild($this->createNodeWithTextContent('endyear', $customer->getEndYear())); $customerElement->appendChild($this->createNodeWithTextContent('name', $customer->getName())); - $customerElement->appendChild($this->createNodeWithTextContent('office', $customer->getOfficeToCode())); + $customerElement->appendChild($this->createNodeWithTextContent('office', $customer->getOfficeToString())); $customerElement->appendChild($this->createNodeWithTextContent('shortname', $customer->getShortName())); - $customerElement->appendChild($this->createNodeWithTextContent('type', $customer->getTypeToCode())); + $customerElement->appendChild($this->createNodeWithTextContent('type', $customer->getTypeToString())); $customerElement->appendChild($this->createNodeWithTextContent('website', $customer->getWebsite())); $financials = $customer->getFinancials(); @@ -64,9 +64,9 @@ public function addCustomer(Customer $customer) $financialsElement->appendChild($this->createNodeWithTextContent('ebillmail', $financials->getEBillMail())); $financialsElement->appendChild($this->createNodeWithTextContent('meansofpayment', $financials->getMeansOfPayment())); $financialsElement->appendChild($this->createNodeWithTextContent('payavailable', $financials->getPayAvailableToString())); - $financialsElement->appendChild($this->createNodeWithTextContent('paycode', $financials->getPayCodeToCode())); - $financialsElement->appendChild($this->createNodeWithTextContent('substitutewith', $financials->getSubstituteWithToCode())); - $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $financials->getVatCodeToCode())); + $financialsElement->appendChild($this->createNodeWithTextContent('paycode', $financials->getPayCodeToString())); + $financialsElement->appendChild($this->createNodeWithTextContent('substitutewith', $financials->getSubstituteWithToString())); + $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $financials->getVatCodeToString())); $collectMandate = $financials->getCollectMandate(); @@ -105,14 +105,14 @@ public function addCustomer(Customer $customer) $creditManagementElement->appendChild($this->createNodeWithTextContent('freetext2', $creditManagement->getFreeText2())); $creditManagementElement->appendChild($this->createNodeWithTextContent('freetext3', $creditManagement->getFreeText3())); $creditManagementElement->appendChild($this->createNodeWithTextContent('reminderemail', $creditManagement->getReminderEmail())); - $creditManagementElement->appendChild($this->createNodeWithTextContent('responsibleuser', $creditManagement->getResponsibleUserToCode())); + $creditManagementElement->appendChild($this->createNodeWithTextContent('responsibleuser', $creditManagement->getResponsibleUserToString())); $creditManagementElement->appendChild($this->createNodeWithTextContent('sendreminder', $creditManagement->getSendReminder())); // Make invoicing element $invoicingElement = $this->createElement('invoicing'); $customerElement->appendChild($invoicingElement); - $invoicingElement->appendChild($this->createNodeWithTextContent('discountarticle', $customer->getDiscountArticleToCode())); + $invoicingElement->appendChild($this->createNodeWithTextContent('discountarticle', $customer->getDiscountArticleToString())); $addresses = $customer->getAddresses(); @@ -146,7 +146,7 @@ public function addCustomer(Customer $customer) } $addressElement->appendChild($this->createNodeWithTextContent('city', $address->getCity())); - $addressElement->appendChild($this->createNodeWithTextContent('country', $address->getCountryToCode())); + $addressElement->appendChild($this->createNodeWithTextContent('country', $address->getCountryToString())); $addressElement->appendChild($this->createNodeWithTextContent('email', $address->getEmail())); $addressElement->appendChild($this->createNodeWithTextContent('field1', $address->getField1())); $addressElement->appendChild($this->createNodeWithTextContent('field2', $address->getField2())); @@ -196,7 +196,7 @@ public function addCustomer(Customer $customer) $bankElement->appendChild($this->createNodeWithTextContent('bankname', $bank->getBankName())); $bankElement->appendChild($this->createNodeWithTextContent('biccode', $bank->getBicCode())); $bankElement->appendChild($this->createNodeWithTextContent('city', $bank->getCity())); - $bankElement->appendChild($this->createNodeWithTextContent('country', $bank->getCountryToCode())); + $bankElement->appendChild($this->createNodeWithTextContent('country', $bank->getCountryToString())); $bankElement->appendChild($this->createNodeWithTextContent('iban', $bank->getIban())); $bankElement->appendChild($this->createNodeWithTextContent('natbiccode', $bank->getNatBicCode())); $bankElement->appendChild($this->createNodeWithTextContent('postcode', $bank->getPostcode())); @@ -210,7 +210,7 @@ public function addCustomer(Customer $customer) $remittanceAdviceElement->appendChild($this->createNodeWithTextContent('sendmail', $customer->getRemittanceAdviceSendMail())); $remittanceAdviceElement->appendChild($this->createNodeWithTextContent('sendtype', $customer->getRemittanceAdviceSendType())); - $group = $customer->getGroupToCode(); + $group = $customer->getGroupToString(); if (!empty($group)) { $groupsElement = $this->createElement('groups'); @@ -244,7 +244,7 @@ public function addCustomer(Customer $customer) } $postingRuleElement->appendChild($this->createNodeWithTextContent('amount', $postingRule->getAmountToFloat())); - $postingRuleElement->appendChild($this->createNodeWithTextContent('currency', $postingRule->getCurrencyToCode())); + $postingRuleElement->appendChild($this->createNodeWithTextContent('currency', $postingRule->getCurrencyToString())); $postingRuleElement->appendChild($this->createNodeWithTextContent('description', $postingRule->getDescription())); $postingRuleLines = $postingRule->getLines(); @@ -260,13 +260,13 @@ public function addCustomer(Customer $customer) $postingRuleLineElement = $this->createElement('line'); $postingRuleLinesElement->appendChild($postingRuleLineElement); - $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension1', $postingRuleLine->getDimension1ToCode())); - $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension2', $postingRuleLine->getDimension2ToCode())); - $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension3', $postingRuleLine->getDimension3ToCode())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension1', $postingRuleLine->getDimension1ToString())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension2', $postingRuleLine->getDimension2ToString())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension3', $postingRuleLine->getDimension3ToString())); $postingRuleLineElement->appendChild($this->createNodeWithTextContent('description', $postingRuleLine->getDescription())); - $postingRuleLineElement->appendChild($this->createNodeWithTextContent('office', $postingRuleLine->getOfficeToCode())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('office', $postingRuleLine->getOfficeToString())); $postingRuleLineElement->appendChild($this->createNodeWithTextContent('ratio', $postingRuleLine->getRatio())); - $postingRuleLineElement->appendChild($this->createNodeWithTextContent('vatcode', $postingRuleLine->getVatCodeToCode())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('vatcode', $postingRuleLine->getVatCodeToString())); } } } diff --git a/src/DomDocuments/DimensionGroupsDocument.php b/src/DomDocuments/DimensionGroupsDocument.php index cd178d35..c33ebae9 100644 --- a/src/DomDocuments/DimensionGroupsDocument.php +++ b/src/DomDocuments/DimensionGroupsDocument.php @@ -44,7 +44,7 @@ public function addDimensionGroup(DimensionGroup $dimensionGroup) $dimensionGroupElement->appendChild($this->createNodeWithTextContent('code', $dimensionGroup->getCode())); $dimensionGroupElement->appendChild($this->createNodeWithTextContent('name', $dimensionGroup->getName())); - $dimensionGroupElement->appendChild($this->createNodeWithTextContent('office', $dimensionGroup->getOfficeToCode())); + $dimensionGroupElement->appendChild($this->createNodeWithTextContent('office', $dimensionGroup->getOfficeToString())); $dimensionGroupElement->appendChild($this->createNodeWithTextContent('shortname', $dimensionGroup->getShortName())); $dimensions = $dimensionGroup->getDimensions(); @@ -60,8 +60,8 @@ public function addDimensionGroup(DimensionGroup $dimensionGroup) $dimensionElement = $this->createElement('dimension'); $dimensionsElement->appendChild($dimensionElement); - $dimensionElement->appendChild($this->createNodeWithTextContent('code', $dimension->getCodeToCode())); - $dimensionElement->appendChild($this->createNodeWithTextContent('type', $dimension->getTypeToCode())); + $dimensionElement->appendChild($this->createNodeWithTextContent('code', $dimension->getCodeToString())); + $dimensionElement->appendChild($this->createNodeWithTextContent('type', $dimension->getTypeToString())); } } } diff --git a/src/DomDocuments/DimensionTypesDocument.php b/src/DomDocuments/DimensionTypesDocument.php index b89c35c2..4b46bb4a 100644 --- a/src/DomDocuments/DimensionTypesDocument.php +++ b/src/DomDocuments/DimensionTypesDocument.php @@ -39,7 +39,7 @@ public function addDimensionType(DimensionType $dimensionType) $dimensionTypeElement->appendChild($this->createNodeWithTextContent('code', $dimensionType->getCode())); $dimensionTypeElement->appendChild($this->createNodeWithTextContent('mask', $dimensionType->getMask())); $dimensionTypeElement->appendChild($this->createNodeWithTextContent('name', $dimensionType->getName())); - $dimensionTypeElement->appendChild($this->createNodeWithTextContent('office', $dimensionType->getOfficeToCode())); + $dimensionTypeElement->appendChild($this->createNodeWithTextContent('office', $dimensionType->getOfficeToString())); $dimensionTypeElement->appendChild($this->createNodeWithTextContent('shortname', $dimensionType->getShortName())); $address = $dimensionType->getAddress(); diff --git a/src/DomDocuments/FixedAssetsDocument.php b/src/DomDocuments/FixedAssetsDocument.php index 8349f318..c0bb4449 100644 --- a/src/DomDocuments/FixedAssetsDocument.php +++ b/src/DomDocuments/FixedAssetsDocument.php @@ -44,8 +44,8 @@ public function addFixedAsset(FixedAsset $fixedAsset) $fixedAssetElement->appendChild($this->createNodeWithTextContent('code', $fixedAsset->getCode())); $fixedAssetElement->appendChild($this->createNodeWithTextContent('name', $fixedAsset->getName())); - $fixedAssetElement->appendChild($this->createNodeWithTextContent('office', $fixedAsset->getOfficeToCode())); - $fixedAssetElement->appendChild($this->createNodeWithTextContent('type', $fixedAsset->getTypeToCode())); + $fixedAssetElement->appendChild($this->createNodeWithTextContent('office', $fixedAsset->getOfficeToString())); + $fixedAssetElement->appendChild($this->createNodeWithTextContent('type', $fixedAsset->getTypeToString())); $financials = $fixedAsset->getFinancials(); @@ -53,8 +53,8 @@ public function addFixedAsset(FixedAsset $fixedAsset) $fixedAssetElement->appendChild($financialsElement); $financialsElement->appendChild($this->createNodeWithTextContent('substitutionlevel', $financials->getSubstitutionLevel())); - $financialsElement->appendChild($this->createNodeWithTextContent('substitutewith', $financials->getSubstituteWithToCode())); - $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $financials->getVatCodeToCode())); + $financialsElement->appendChild($this->createNodeWithTextContent('substitutewith', $financials->getSubstituteWithToString())); + $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $financials->getVatCodeToString())); $fixedAssets = $fixedAsset->getFixedAssets(); @@ -68,7 +68,7 @@ public function addFixedAsset(FixedAsset $fixedAsset) $fixedAssetsElement->appendChild($this->createNodeWithTextContent('freetext4', $fixedAssets->getFreeText4())); $fixedAssetsElement->appendChild($this->createNodeWithTextContent('freetext5', $fixedAssets->getFreeText5())); $fixedAssetsElement->appendChild($this->createNodeWithTextContent('lastdepreciation', $fixedAssets->getLastDepreciation())); - $fixedAssetsElement->appendChild($this->createNodeWithTextContent('method', $fixedAssets->getMethodToCode())); + $fixedAssetsElement->appendChild($this->createNodeWithTextContent('method', $fixedAssets->getMethodToString())); $fixedAssetsElement->appendChild($this->createNodeWithTextContent('nrofperiods', $fixedAssets->getNrOfPeriods())); $fixedAssetsElement->appendChild($this->createNodeWithTextContent('percentage', $fixedAssets->getPercentage())); $fixedAssetsElement->appendChild($this->createNodeWithTextContent('purchasedate', $fixedAssets->getPurchaseDateToString())); @@ -90,20 +90,20 @@ public function addFixedAsset(FixedAsset $fixedAsset) $transactionLinesElement->appendChild($transactionLineElement); $transactionLineElement->appendChild($this->createNodeWithTextContent('amount', $transactionLine->getAmountToFloat())); - $transactionLineElement->appendChild($this->createNodeWithTextContent('code', $transactionLine->getCodeToCode())); - $transactionLineElement->appendChild($this->createNodeWithTextContent('dim1', $transactionLine->getDim1ToCode())); - $transactionLineElement->appendChild($this->createNodeWithTextContent('dim2', $transactionLine->getDim2ToCode())); - $transactionLineElement->appendChild($this->createNodeWithTextContent('dim3', $transactionLine->getDim3ToCode())); - $transactionLineElement->appendChild($this->createNodeWithTextContent('dim4', $transactionLine->getDim4ToCode())); - $transactionLineElement->appendChild($this->createNodeWithTextContent('dim5', $transactionLine->getDim5ToCode())); - $transactionLineElement->appendChild($this->createNodeWithTextContent('dim6', $transactionLine->getDim6ToCode())); + $transactionLineElement->appendChild($this->createNodeWithTextContent('code', $transactionLine->getCodeToString())); + $transactionLineElement->appendChild($this->createNodeWithTextContent('dim1', $transactionLine->getDim1ToString())); + $transactionLineElement->appendChild($this->createNodeWithTextContent('dim2', $transactionLine->getDim2ToString())); + $transactionLineElement->appendChild($this->createNodeWithTextContent('dim3', $transactionLine->getDim3ToString())); + $transactionLineElement->appendChild($this->createNodeWithTextContent('dim4', $transactionLine->getDim4ToString())); + $transactionLineElement->appendChild($this->createNodeWithTextContent('dim5', $transactionLine->getDim5ToString())); + $transactionLineElement->appendChild($this->createNodeWithTextContent('dim6', $transactionLine->getDim6ToString())); $transactionLineElement->appendChild($this->createNodeWithTextContent('line', $transactionLine->getLine())); $transactionLineElement->appendChild($this->createNodeWithTextContent('number', $transactionLine->getNumber())); $transactionLineElement->appendChild($this->createNodeWithTextContent('period', $transactionLine->getPeriod())); } } - $group = $fixedAsset->getGroupToCode(); + $group = $fixedAsset->getGroupToString(); if (!empty($group)) { $groupsElement = $this->createElement('groups'); diff --git a/src/DomDocuments/GeneralLedgersDocument.php b/src/DomDocuments/GeneralLedgersDocument.php index 823ba6e5..3f3b1205 100644 --- a/src/DomDocuments/GeneralLedgersDocument.php +++ b/src/DomDocuments/GeneralLedgersDocument.php @@ -48,9 +48,9 @@ public function addGeneralLedger(GeneralLedger $generalLedger) $generalLedgerElement->appendChild($this->createNodeWithTextContent('endperiod', $generalLedger->getEndPeriod())); $generalLedgerElement->appendChild($this->createNodeWithTextContent('endyear', $generalLedger->getEndYear())); $generalLedgerElement->appendChild($this->createNodeWithTextContent('name', $generalLedger->getName())); - $generalLedgerElement->appendChild($this->createNodeWithTextContent('office', $generalLedger->getOfficeToCode())); + $generalLedgerElement->appendChild($this->createNodeWithTextContent('office', $generalLedger->getOfficeToString())); $generalLedgerElement->appendChild($this->createNodeWithTextContent('shortname', $generalLedger->getShortName())); - $generalLedgerElement->appendChild($this->createNodeWithTextContent('type', $generalLedger->getTypeToCode())); + $generalLedgerElement->appendChild($this->createNodeWithTextContent('type', $generalLedger->getTypeToString())); $financials = $generalLedger->getFinancials(); @@ -60,7 +60,7 @@ public function addGeneralLedger(GeneralLedger $generalLedger) $financialsElement->appendChild($this->createNodeWithTextContent('accounttype', $financials->getAccountType())); $financialsElement->appendChild($this->createNodeWithTextContent('matchtype', $financials->getMatchType())); $financialsElement->appendChild($this->createNodeWithTextContent('subanalyse', $financials->getSubAnalyse())); - $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $financials->getVatCodeToCode())); + $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $financials->getVatCodeToString())); $childValidations = $financials->getChildValidations(); @@ -76,7 +76,7 @@ public function addGeneralLedger(GeneralLedger $generalLedger) } } - $group = $generalLedger->getGroupToCode(); + $group = $generalLedger->getGroupToString(); if (!empty($group)) { $groupsElement = $this->createElement('groups'); diff --git a/src/DomDocuments/InvoicesDocument.php b/src/DomDocuments/InvoicesDocument.php index f3001edb..144a2e0d 100644 --- a/src/DomDocuments/InvoicesDocument.php +++ b/src/DomDocuments/InvoicesDocument.php @@ -54,9 +54,9 @@ public function addInvoice(Invoice $invoice, $connection) $headerElement->setAttribute('raisewarning', $raiseWarning); } - $headerElement->appendChild($this->createNodeWithTextContent('bank', $invoice->getBankToCode())); - $headerElement->appendChild($this->createNodeWithTextContent('currency', $invoice->getCurrencyToCode())); - $headerElement->appendChild($this->createNodeWithTextContent('customer', $invoice->getCustomerToCode())); + $headerElement->appendChild($this->createNodeWithTextContent('bank', $invoice->getBankToString())); + $headerElement->appendChild($this->createNodeWithTextContent('currency', $invoice->getCurrencyToString())); + $headerElement->appendChild($this->createNodeWithTextContent('customer', $invoice->getCustomerToString())); $headerElement->appendChild($this->createNodeWithTextContent('deliveraddressnumber', $invoice->getDeliverAddressNumber())); $headerElement->appendChild($this->createNodeWithTextContent('duedate', $invoice->getDueDateToString())); $headerElement->appendChild($this->createNodeWithTextContent('footertext', $invoice->getFooterText())); @@ -64,14 +64,14 @@ public function addInvoice(Invoice $invoice, $connection) $headerElement->appendChild($this->createNodeWithTextContent('invoiceaddressnumber', $invoice->getInvoiceAddressNumber())); $headerElement->appendChild($this->createNodeWithTextContent('invoicedate', $invoice->getInvoiceDateToString())); $headerElement->appendChild($this->createNodeWithTextContent('invoicenumber', $invoice->getInvoiceNumber())); - $headerElement->appendChild($this->createNodeWithTextContent('invoicetype', $invoice->getInvoiceTypeToCode())); - $headerElement->appendChild($this->createNodeWithTextContent('office', $invoice->getOfficeToCode())); + $headerElement->appendChild($this->createNodeWithTextContent('invoicetype', $invoice->getInvoiceTypeToString())); + $headerElement->appendChild($this->createNodeWithTextContent('office', $invoice->getOfficeToString())); $headerElement->appendChild($this->createNodeWithTextContent('paymentmethod', $invoice->getPaymentMethod())); $headerElement->appendChild($this->createNodeWithTextContent('period', $invoice->getPeriod())); $headerElement->appendChild($this->createNodeWithTextContent('status', $invoice->getStatus())); $invoiceTypeApiConnector = new \PhpTwinfield\ApiConnectors\InvoiceTypeApiConnector($connection); - $invoiceVatType = $invoiceTypeApiConnector->getInvoiceTypeVatType($invoice->getInvoiceTypeToCode()); + $invoiceVatType = $invoiceTypeApiConnector->getInvoiceTypeVatType($invoice->getInvoiceTypeToString()); $articleApiConnector = new \PhpTwinfield\ApiConnectors\ArticleApiConnector($connection); @@ -95,16 +95,16 @@ public function addInvoice(Invoice $invoice, $connection) } $lineElement->appendChild($this->createNodeWithTextContent('allowdiscountorpremium', $line->getAllowDiscountOrPremiumToString())); - $lineElement->appendChild($this->createNodeWithTextContent('article', $line->getArticleToCode())); + $lineElement->appendChild($this->createNodeWithTextContent('article', $line->getArticleToString())); $lineElement->appendChild($this->createNodeWithTextContent('description', $line->getDescription())); - $lineElement->appendChild($this->createNodeWithTextContent('dim1', $line->getDim1ToCode())); + $lineElement->appendChild($this->createNodeWithTextContent('dim1', $line->getDim1ToString())); $lineElement->appendChild($this->createNodeWithTextContent('freetext1', $line->getFreeText1())); $lineElement->appendChild($this->createNodeWithTextContent('freetext2', $line->getFreeText2())); $lineElement->appendChild($this->createNodeWithTextContent('freetext3', $line->getFreeText3())); $lineElement->appendChild($this->createNodeWithTextContent('performancedate', $line->getPerformanceDateToString())); $lineElement->appendChild($this->createNodeWithTextContent('performancetype', $line->getPerformanceType())); $lineElement->appendChild($this->createNodeWithTextContent('quantity', $line->getQuantity())); - $lineElement->appendChild($this->createNodeWithTextContent('subarticle', $line->getSubArticleToSubCode())); + $lineElement->appendChild($this->createNodeWithTextContent('subarticle', $line->getSubArticleToString())); $lineElement->appendChild($this->createNodeWithTextContent('units', $line->getUnits())); if ($invoiceVatType == 'inclusive') { @@ -113,10 +113,10 @@ public function addInvoice(Invoice $invoice, $connection) $lineElement->appendChild($this->createNodeWithTextContent('unitspriceexcl', $line->getUnitsPriceExclToFloat())); } - $article = $articleApiConnector->get($line->getArticleToCode(), $invoice->getOffice()); + $article = $articleApiConnector->get($line->getArticleToString(), $invoice->getOffice()); if ($article->getAllowChangeVatCode() == true) { - $lineElement->appendChild($this->createNodeWithTextContent('vatcode', $line->getVatCodeToCode())); + $lineElement->appendChild($this->createNodeWithTextContent('vatcode', $line->getVatCodeToString())); } } } diff --git a/src/DomDocuments/ProjectsDocument.php b/src/DomDocuments/ProjectsDocument.php index eae6beed..8bacf77e 100644 --- a/src/DomDocuments/ProjectsDocument.php +++ b/src/DomDocuments/ProjectsDocument.php @@ -44,21 +44,21 @@ public function addProject(Project $project) $projectElement->appendChild($this->createNodeWithTextContent('code', $project->getCode())); $projectElement->appendChild($this->createNodeWithTextContent('name', $project->getName())); - $projectElement->appendChild($this->createNodeWithTextContent('office', $project->getOfficeToCode())); + $projectElement->appendChild($this->createNodeWithTextContent('office', $project->getOfficeToString())); $projectElement->appendChild($this->createNodeWithTextContent('shortname', $project->getShortName())); - $projectElement->appendChild($this->createNodeWithTextContent('type', $project->getTypeToCode())); + $projectElement->appendChild($this->createNodeWithTextContent('type', $project->getTypeToString())); $financialsElement = $this->createElement('financials'); $projectElement->appendChild($financialsElement); - $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $project->getVatCodeToCode())); + $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $project->getVatCodeToString())); $projects = $project->getProjects(); $projectsElement = $this->createElement('projects'); $projectElement->appendChild($projectsElement); - $inheritArray = array('authoriser' => 'getAuthoriserToCode', 'billable' => 'getBillableToString', 'customer' => 'getCustomerToCode', 'rate' => 'getRateToCode'); + $inheritArray = array('authoriser' => 'getAuthoriserToString', 'billable' => 'getBillableToString', 'customer' => 'getCustomerToString', 'rate' => 'getRateToString'); foreach ($inheritArray as $inheritVar => $method) { $methodLocked = "get" . ucfirst($inheritVar) . "Locked"; @@ -98,7 +98,7 @@ public function addProject(Project $project) $quantitiesElement->appendChild($quantityElement); $quantityElement->appendChild($this->createNodeWithTextContent('label', $quantity->getLabel())); - $quantityElement->appendChild($this->createNodeWithTextContent('rate', $quantity->getRateToCode())); + $quantityElement->appendChild($this->createNodeWithTextContent('rate', $quantity->getRateToString())); $quantityElement->appendChild($this->createNodeWithTextContent('billable', $quantity->getBillableToString(), $quantity, array('locked' => 'getBillableLockedToString'))); $quantityElement->appendChild($this->createNodeWithTextContent('mandatory', $quantity->getMandatoryToString())); } diff --git a/src/DomDocuments/RatesDocument.php b/src/DomDocuments/RatesDocument.php index 1c2cac53..4ca1346f 100644 --- a/src/DomDocuments/RatesDocument.php +++ b/src/DomDocuments/RatesDocument.php @@ -43,9 +43,9 @@ public function addRate(Rate $rate) } $rateElement->appendChild($this->createNodeWithTextContent('code', $rate->getCode())); - $rateElement->appendChild($this->createNodeWithTextContent('currency', $rate->getCurrencyToCode())); + $rateElement->appendChild($this->createNodeWithTextContent('currency', $rate->getCurrencyToString())); $rateElement->appendChild($this->createNodeWithTextContent('name', $rate->getName())); - $rateElement->appendChild($this->createNodeWithTextContent('office', $rate->getOfficeToCode())); + $rateElement->appendChild($this->createNodeWithTextContent('office', $rate->getOfficeToString())); $rateElement->appendChild($this->createNodeWithTextContent('shortname', $rate->getShortName())); $rateElement->appendChild($this->createNodeWithTextContent('type', $rate->getType())); $rateElement->appendChild($this->createNodeWithTextContent('unit', $rate->getUnit())); diff --git a/src/DomDocuments/SuppliersDocument.php b/src/DomDocuments/SuppliersDocument.php index f15d5705..55d15cdc 100644 --- a/src/DomDocuments/SuppliersDocument.php +++ b/src/DomDocuments/SuppliersDocument.php @@ -48,9 +48,9 @@ public function addSupplier(Supplier $supplier) $supplierElement->appendChild($this->createNodeWithTextContent('endperiod', $supplier->getEndPeriod())); $supplierElement->appendChild($this->createNodeWithTextContent('endyear', $supplier->getEndYear())); $supplierElement->appendChild($this->createNodeWithTextContent('name', $supplier->getName())); - $supplierElement->appendChild($this->createNodeWithTextContent('office', $supplier->getOfficeToCode())); + $supplierElement->appendChild($this->createNodeWithTextContent('office', $supplier->getOfficeToString())); $supplierElement->appendChild($this->createNodeWithTextContent('shortname', $supplier->getShortName())); - $supplierElement->appendChild($this->createNodeWithTextContent('type', $supplier->getTypeToCode())); + $supplierElement->appendChild($this->createNodeWithTextContent('type', $supplier->getTypeToString())); $supplierElement->appendChild($this->createNodeWithTextContent('website', $supplier->getWebsite())); $financials = $supplier->getFinancials(); @@ -61,10 +61,10 @@ public function addSupplier(Supplier $supplier) $financialsElement->appendChild($this->createNodeWithTextContent('duedays', $financials->getDueDays())); $financialsElement->appendChild($this->createNodeWithTextContent('meansofpayment', $financials->getMeansOfPayment())); $financialsElement->appendChild($this->createNodeWithTextContent('payavailable', $financials->getPayAvailableToString())); - $financialsElement->appendChild($this->createNodeWithTextContent('paycode', $financials->getPayCodeToCode())); + $financialsElement->appendChild($this->createNodeWithTextContent('paycode', $financials->getPayCodeToString())); $financialsElement->appendChild($this->createNodeWithTextContent('relationsreference', $financials->getRelationsReference())); - $financialsElement->appendChild($this->createNodeWithTextContent('substitutewith', $financials->getSubstituteWithToCode())); - $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $financials->getVatCodeToCode())); + $financialsElement->appendChild($this->createNodeWithTextContent('substitutewith', $financials->getSubstituteWithToString())); + $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $financials->getVatCodeToString())); $childValidations = $financials->getChildValidations(); @@ -112,7 +112,7 @@ public function addSupplier(Supplier $supplier) } $addressElement->appendChild($this->createNodeWithTextContent('city', $address->getCity())); - $addressElement->appendChild($this->createNodeWithTextContent('country', $address->getCountryToCode())); + $addressElement->appendChild($this->createNodeWithTextContent('country', $address->getCountryToString())); $addressElement->appendChild($this->createNodeWithTextContent('email', $address->getEmail())); $addressElement->appendChild($this->createNodeWithTextContent('field1', $address->getField1())); $addressElement->appendChild($this->createNodeWithTextContent('field2', $address->getField2())); @@ -168,7 +168,7 @@ public function addSupplier(Supplier $supplier) $bankElement->appendChild($this->createNodeWithTextContent('bankname', $bank->getBankName())); $bankElement->appendChild($this->createNodeWithTextContent('biccode', $bank->getBicCode())); $bankElement->appendChild($this->createNodeWithTextContent('city', $bank->getCity())); - $bankElement->appendChild($this->createNodeWithTextContent('country', $bank->getCountryToCode())); + $bankElement->appendChild($this->createNodeWithTextContent('country', $bank->getCountryToString())); $bankElement->appendChild($this->createNodeWithTextContent('iban', $bank->getIban())); $bankElement->appendChild($this->createNodeWithTextContent('natbiccode', $bank->getNatBicCode())); $bankElement->appendChild($this->createNodeWithTextContent('postcode', $bank->getPostcode())); @@ -182,7 +182,7 @@ public function addSupplier(Supplier $supplier) $remittanceAdviceElement->appendChild($this->createNodeWithTextContent('sendmail', $supplier->getRemittanceAdviceSendMail())); $remittanceAdviceElement->appendChild($this->createNodeWithTextContent('sendtype', $supplier->getRemittanceAdviceSendType())); - $group = $supplier->getGroupToCode(); + $group = $supplier->getGroupToString(); if (!empty($group)) { $groupsElement = $this->createElement('groups'); @@ -216,7 +216,7 @@ public function addSupplier(Supplier $supplier) } $postingRuleElement->appendChild($this->createNodeWithTextContent('amount', $postingRule->getAmountToFloat())); - $postingRuleElement->appendChild($this->createNodeWithTextContent('currency', $postingRule->getCurrencyToCode())); + $postingRuleElement->appendChild($this->createNodeWithTextContent('currency', $postingRule->getCurrencyToString())); $postingRuleElement->appendChild($this->createNodeWithTextContent('description', $postingRule->getDescription())); $postingRuleLines = $postingRule->getLines(); @@ -232,13 +232,13 @@ public function addSupplier(Supplier $supplier) $postingRuleLineElement = $this->createElement('line'); $postingRuleLinesElement->appendChild($postingRuleLineElement); - $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension1', $postingRuleLine->getDimension1ToCode())); - $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension2', $postingRuleLine->getDimension2ToCode())); - $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension3', $postingRuleLine->getDimension3ToCode())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension1', $postingRuleLine->getDimension1ToString())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension2', $postingRuleLine->getDimension2ToString())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension3', $postingRuleLine->getDimension3ToString())); $postingRuleLineElement->appendChild($this->createNodeWithTextContent('description', $postingRuleLine->getDescription())); - $postingRuleLineElement->appendChild($this->createNodeWithTextContent('office', $postingRuleLine->getOfficeToCode())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('office', $postingRuleLine->getOfficeToString())); $postingRuleLineElement->appendChild($this->createNodeWithTextContent('ratio', $postingRuleLine->getRatio())); - $postingRuleLineElement->appendChild($this->createNodeWithTextContent('vatcode', $postingRuleLine->getVatCodeToCode())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('vatcode', $postingRuleLine->getVatCodeToString())); } } } diff --git a/src/DomDocuments/VatCodesDocument.php b/src/DomDocuments/VatCodesDocument.php index ea924e43..f2573a0a 100644 --- a/src/DomDocuments/VatCodesDocument.php +++ b/src/DomDocuments/VatCodesDocument.php @@ -83,9 +83,9 @@ public function addVatCode(VatCode $vatCode) $accountElement->setAttribute('id', $id); } - $accountElement->appendChild($this->createNodeWithTextContent('dim1', $account->getDim1ToCode())); - $accountElement->appendChild($this->createNodeWithTextContent('group', $account->getGroupToCode())); - $accountElement->appendChild($this->createNodeWithTextContent('groupcountry', $account->getGroupCountryToCode())); + $accountElement->appendChild($this->createNodeWithTextContent('dim1', $account->getDim1ToString())); + $accountElement->appendChild($this->createNodeWithTextContent('group', $account->getGroupToString())); + $accountElement->appendChild($this->createNodeWithTextContent('groupcountry', $account->getGroupCountryToString())); $accountElement->appendChild($this->createNodeWithTextContent('linetype', $account->getLineType())); $accountElement->appendChild($this->createNodeWithTextContent('percentage', $account->getPercentage())); } diff --git a/src/Enums/GeneralLedgerType.php b/src/Enums/ChildValidationType.php similarity index 52% rename from src/Enums/GeneralLedgerType.php rename to src/Enums/ChildValidationType.php index 1c474865..e8aa812d 100644 --- a/src/Enums/GeneralLedgerType.php +++ b/src/Enums/ChildValidationType.php @@ -1,17 +1,17 @@ -assetsToActivate; } - public function getAssetsToActivateToCode(): ?string + public function getAssetsToActivateToString(): ?string { if ($this->getAssetsToActivate() != null) { return $this->assetsToActivate->getCode(); @@ -45,7 +45,7 @@ public function setAssetsToActivate(?GeneralLedger $assetsToActivate): self * @return $this * @throws Exception */ - public function setAssetsToActivateFromCode(?string $assetsToActivateCode) + public function setAssetsToActivateFromString(?string $assetsToActivateCode) { $assetsToActivate = new GeneralLedger(); $assetsToActivate->setCode($assetsToActivateCode); diff --git a/src/Fields/AssetMethod/DepreciationField.php b/src/Fields/AssetMethod/DepreciationField.php index 64f10f1c..84cdb7e4 100644 --- a/src/Fields/AssetMethod/DepreciationField.php +++ b/src/Fields/AssetMethod/DepreciationField.php @@ -22,7 +22,7 @@ public function getDepreciation(): ?GeneralLedger return $this->depreciation; } - public function getDepreciationToCode(): ?string + public function getDepreciationToString(): ?string { if ($this->getDepreciation() != null) { return $this->depreciation->getCode(); @@ -45,7 +45,7 @@ public function setDepreciation(?GeneralLedger $depreciation): self * @return $this * @throws Exception */ - public function setDepreciationFromCode(?string $depreciationCode) + public function setDepreciationFromString(?string $depreciationCode) { $depreciation = new GeneralLedger(); $depreciation->setCode($depreciationCode); diff --git a/src/Fields/AssetMethod/DepreciationGroupField.php b/src/Fields/AssetMethod/DepreciationGroupField.php index 0b547b1c..4a7fe10b 100644 --- a/src/Fields/AssetMethod/DepreciationGroupField.php +++ b/src/Fields/AssetMethod/DepreciationGroupField.php @@ -22,7 +22,7 @@ public function getDepreciationGroup(): ?DimensionGroup return $this->depreciationGroup; } - public function getDepreciationGroupToCode(): ?string + public function getDepreciationGroupToString(): ?string { if ($this->getDepreciationGroup() != null) { return $this->depreciationGroup->getCode(); @@ -45,7 +45,7 @@ public function setDepreciationGroup(?DimensionGroup $depreciationGroup): self * @return $this * @throws Exception */ - public function setDepreciationGroupFromCode(?string $depreciationGroupCode) + public function setDepreciationGroupFromString(?string $depreciationGroupCode) { $depreciationGroup = new DimensionGroup(); $depreciationGroup->setCode($depreciationGroupCode); diff --git a/src/Fields/AssetMethod/PurchaseValueField.php b/src/Fields/AssetMethod/PurchaseValueField.php index 68875c3f..82fb62bc 100644 --- a/src/Fields/AssetMethod/PurchaseValueField.php +++ b/src/Fields/AssetMethod/PurchaseValueField.php @@ -22,7 +22,7 @@ public function getPurchaseValue(): ?GeneralLedger return $this->purchaseValue; } - public function getPurchaseValueToCode(): ?string + public function getPurchaseValueToString(): ?string { if ($this->getPurchaseValue() != null) { return $this->purchaseValue->getCode(); @@ -45,7 +45,7 @@ public function setPurchaseValue(?GeneralLedger $purchaseValue): self * @return $this * @throws Exception */ - public function setPurchaseValueFromCode(?string $purchaseValueCode) + public function setPurchaseValueFromString(?string $purchaseValueCode) { $purchaseValue = new GeneralLedger(); $purchaseValue->setCode($purchaseValueCode); diff --git a/src/Fields/AssetMethod/PurchaseValueGroupField.php b/src/Fields/AssetMethod/PurchaseValueGroupField.php index d930b332..404f7aca 100644 --- a/src/Fields/AssetMethod/PurchaseValueGroupField.php +++ b/src/Fields/AssetMethod/PurchaseValueGroupField.php @@ -22,7 +22,7 @@ public function getPurchaseValueGroup(): ?DimensionGroup return $this->purchaseValueGroup; } - public function getPurchaseValueGroupToCode(): ?string + public function getPurchaseValueGroupToString(): ?string { if ($this->getPurchaseValueGroup() != null) { return $this->purchaseValueGroup->getCode(); @@ -45,7 +45,7 @@ public function setPurchaseValueGroup(?DimensionGroup $purchaseValueGroup): self * @return $this * @throws Exception */ - public function setPurchaseValueGroupFromCode(?string $purchaseValueGroupCode) + public function setPurchaseValueGroupFromString(?string $purchaseValueGroupCode) { $purchaseValueGroup = new DimensionGroup(); $purchaseValueGroup->setCode($purchaseValueGroupCode); diff --git a/src/Fields/AssetMethod/ReconciliationField.php b/src/Fields/AssetMethod/ReconciliationField.php index c5a7b05c..0e10916e 100644 --- a/src/Fields/AssetMethod/ReconciliationField.php +++ b/src/Fields/AssetMethod/ReconciliationField.php @@ -22,7 +22,7 @@ public function getReconciliation(): ?GeneralLedger return $this->reconciliation; } - public function getReconciliationToCode(): ?string + public function getReconciliationToString(): ?string { if ($this->getReconciliation() != null) { return $this->reconciliation->getCode(); @@ -45,7 +45,7 @@ public function setReconciliation(?GeneralLedger $reconciliation): self * @return $this * @throws Exception */ - public function setReconciliationFromCode(?string $reconciliationCode) + public function setReconciliationFromString(?string $reconciliationCode) { $reconciliation = new GeneralLedger(); $reconciliation->setCode($reconciliationCode); diff --git a/src/Fields/AssetMethod/SalesField.php b/src/Fields/AssetMethod/SalesField.php index c5a8230c..d69dcd8b 100644 --- a/src/Fields/AssetMethod/SalesField.php +++ b/src/Fields/AssetMethod/SalesField.php @@ -22,7 +22,7 @@ public function getSales(): ?GeneralLedger return $this->sales; } - public function getSalesToCode(): ?string + public function getSalesToString(): ?string { if ($this->getSales() != null) { return $this->sales->getCode(); @@ -45,7 +45,7 @@ public function setSales(?GeneralLedger $sales): self * @return $this * @throws Exception */ - public function setSalesFromCode(?string $salesCode) + public function setSalesFromString(?string $salesCode) { $sales = new GeneralLedger(); $sales->setCode($salesCode); diff --git a/src/Fields/AssetMethod/ToBeInvoicedField.php b/src/Fields/AssetMethod/ToBeInvoicedField.php index 08b3c69b..e7269e3a 100644 --- a/src/Fields/AssetMethod/ToBeInvoicedField.php +++ b/src/Fields/AssetMethod/ToBeInvoicedField.php @@ -22,7 +22,7 @@ public function getToBeInvoiced(): ?GeneralLedger return $this->toBeInvoiced; } - public function getToBeInvoicedToCode(): ?string + public function getToBeInvoicedToString(): ?string { if ($this->getToBeInvoiced() != null) { return $this->toBeInvoiced->getCode(); @@ -45,7 +45,7 @@ public function setToBeInvoiced(?GeneralLedger $toBeInvoiced): self * @return $this * @throws Exception */ - public function setToBeInvoicedFromCode(?string $toBeInvoicedCode) + public function setToBeInvoicedFromString(?string $toBeInvoicedCode) { $toBeInvoiced = new GeneralLedger(); $toBeInvoiced->setCode($toBeInvoicedCode); diff --git a/src/Fields/CurrencyField.php b/src/Fields/CurrencyField.php index 8ed0bc20..00d84aff 100644 --- a/src/Fields/CurrencyField.php +++ b/src/Fields/CurrencyField.php @@ -22,7 +22,7 @@ public function getCurrency(): ?Currency return $this->currency; } - public function getCurrencyToCode(): ?string + public function getCurrencyToString(): ?string { if ($this->getCurrency() != null) { return $this->currency->getCode(); @@ -45,7 +45,7 @@ public function setCurrency(?Currency $currency): self * @return $this * @throws Exception */ - public function setCurrencyFromCode(?string $currencyCode) + public function setCurrencyFromString(?string $currencyCode) { $currency = new Currency(); $currency->setCode($currencyCode); diff --git a/src/Fields/CustomerField.php b/src/Fields/CustomerField.php index 07ca6942..f724be2b 100644 --- a/src/Fields/CustomerField.php +++ b/src/Fields/CustomerField.php @@ -22,7 +22,7 @@ public function getCustomer(): ?Customer return $this->customer; } - public function getCustomerToCode(): ?string + public function getCustomerToString(): ?string { if ($this->getCustomer() != null) { return $this->customer->getCode(); @@ -45,7 +45,7 @@ public function setCustomer(?Customer $customer): self * @return $this * @throws Exception */ - public function setCustomerFromCode(?string $customerCode) + public function setCustomerFromString(?string $customerCode) { $customer = new Customer(); $customer->setCode($customerCode); diff --git a/src/Fields/Dim1Field.php b/src/Fields/Dim1Field.php index 6038ee17..70a67115 100644 --- a/src/Fields/Dim1Field.php +++ b/src/Fields/Dim1Field.php @@ -22,7 +22,7 @@ public function getDim1(): ?GeneralLedger return $this->dim1; } - public function getDim1ToCode(): ?string + public function getDim1ToString(): ?string { if ($this->getDim1() != null) { return $this->dim1->getCode(); @@ -45,7 +45,7 @@ public function setDim1(?GeneralLedger $dim1): self * @return $this * @throws Exception */ - public function setDim1FromCode(?string $dim1Code) + public function setDim1FromString(?string $dim1Code) { $dim1 = new GeneralLedger(); $dim1->setCode($dim1Code); diff --git a/src/Fields/Invoice/Article/ArticleLineFreeText1Field.php b/src/Fields/Invoice/Article/FreeText1Field.php similarity index 82% rename from src/Fields/Invoice/Article/ArticleLineFreeText1Field.php rename to src/Fields/Invoice/Article/FreeText1Field.php index 28e58215..c23b6034 100644 --- a/src/Fields/Invoice/Article/ArticleLineFreeText1Field.php +++ b/src/Fields/Invoice/Article/FreeText1Field.php @@ -1,54 +1,54 @@ -freeText1; - } - - public function getFreeText1ToCode(): ?string - { - if ($this->getFreeText1() != null) { - return $this->freeText1->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setFreeText1(?GeneralLedger $freeText1): self - { - $this->freeText1 = $freeText1; - return $this; - } - - /** - * @param string|null $freeText1Code - * @return $this - * @throws Exception - */ - public function setFreeText1FromCode(?string $freeText1Code) - { - $freeText1 = new GeneralLedger(); - $freeText1->setCode($freeText1Code); - return $this->setFreeText1($freeText1); - } -} +freeText1; + } + + public function getFreeText1ToString(): ?string + { + if ($this->getFreeText1() != null) { + return $this->freeText1->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setFreeText1(?GeneralLedger $freeText1): self + { + $this->freeText1 = $freeText1; + return $this; + } + + /** + * @param string|null $freeText1Code + * @return $this + * @throws Exception + */ + public function setFreeText1FromString(?string $freeText1Code) + { + $freeText1 = new GeneralLedger(); + $freeText1->setCode($freeText1Code); + return $this->setFreeText1($freeText1); + } +} diff --git a/src/Fields/Invoice/Article/ArticleLineFreeText2Field.php b/src/Fields/Invoice/Article/FreeText2Field.php similarity index 82% rename from src/Fields/Invoice/Article/ArticleLineFreeText2Field.php rename to src/Fields/Invoice/Article/FreeText2Field.php index 084df49e..fc800bb2 100644 --- a/src/Fields/Invoice/Article/ArticleLineFreeText2Field.php +++ b/src/Fields/Invoice/Article/FreeText2Field.php @@ -1,54 +1,54 @@ -freeText2; - } - - public function getFreeText2ToCode(): ?string - { - if ($this->getFreeText2() != null) { - return $this->freeText2->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setFreeText2(?CostCenter $freeText2): self - { - $this->freeText2 = $freeText2; - return $this; - } - - /** - * @param string|null $freeText2Code - * @return $this - * @throws Exception - */ - public function setFreeText2FromCode(?string $freeText2Code) - { - $freeText2 = new CostCenter(); - $freeText2->setCode($freeText2Code); - return $this->setFreeText2($freeText2); - } -} +freeText2; + } + + public function getFreeText2ToString(): ?string + { + if ($this->getFreeText2() != null) { + return $this->freeText2->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setFreeText2(?CostCenter $freeText2): self + { + $this->freeText2 = $freeText2; + return $this; + } + + /** + * @param string|null $freeText2Code + * @return $this + * @throws Exception + */ + public function setFreeText2FromString(?string $freeText2Code) + { + $freeText2 = new CostCenter(); + $freeText2->setCode($freeText2Code); + return $this->setFreeText2($freeText2); + } +} diff --git a/src/Fields/Invoice/Article/ArticlePercentageField.php b/src/Fields/Invoice/Article/PercentageField.php similarity index 89% rename from src/Fields/Invoice/Article/ArticlePercentageField.php rename to src/Fields/Invoice/Article/PercentageField.php index 6c09aa80..272de3c8 100644 --- a/src/Fields/Invoice/Article/ArticlePercentageField.php +++ b/src/Fields/Invoice/Article/PercentageField.php @@ -1,47 +1,47 @@ -percentage; - } - - public function getPercentageToString(): ?string - { - return ($this->getPercentage()) ? 'true' : 'false'; - } - - /** - * @param bool $percentage - * @return $this - */ - public function setPercentage(?bool $percentage): self - { - $this->percentage = $percentage; - return $this; - } - - /** - * @param string|null $percentageString - * @return $this - * @throws Exception - */ - public function setPercentageFromString(?string $percentageString) - { - return $this->setPercentage(filter_var($percentageString, FILTER_VALIDATE_BOOLEAN)); - } +percentage; + } + + public function getPercentageToString(): ?string + { + return ($this->getPercentage()) ? 'true' : 'false'; + } + + /** + * @param bool $percentage + * @return $this + */ + public function setPercentage(?bool $percentage): self + { + $this->percentage = $percentage; + return $this; + } + + /** + * @param string|null $percentageString + * @return $this + * @throws Exception + */ + public function setPercentageFromString(?string $percentageString) + { + return $this->setPercentage(filter_var($percentageString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Invoice/Article/ArticleTypeField.php b/src/Fields/Invoice/Article/TypeField.php similarity index 88% rename from src/Fields/Invoice/Article/ArticleTypeField.php rename to src/Fields/Invoice/Article/TypeField.php index 19bac60c..cbfb6b4f 100644 --- a/src/Fields/Invoice/Article/ArticleTypeField.php +++ b/src/Fields/Invoice/Article/TypeField.php @@ -1,41 +1,41 @@ -type; - } - - /** - * @param ArticleType|null $type - * @return $this - */ - public function setType(?ArticleType $type): self - { - $this->type = $type; - return $this; - } - - /** - * @param string|null $typeString - * @return $this - * @throws Exception - */ - public function setTypeFromString(?string $typeString) - { - return $this->setType(new ArticleType((string)$typeString)); - } +type; + } + + /** + * @param ArticleType|null $type + * @return $this + */ + public function setType(?ArticleType $type): self + { + $this->type = $type; + return $this; + } + + /** + * @param string|null $typeString + * @return $this + * @throws Exception + */ + public function setTypeFromString(?string $typeString) + { + return $this->setType(new ArticleType((string)$typeString)); + } } \ No newline at end of file diff --git a/src/Fields/Invoice/ArticleField.php b/src/Fields/Invoice/ArticleField.php index c15d26f9..477bda88 100644 --- a/src/Fields/Invoice/ArticleField.php +++ b/src/Fields/Invoice/ArticleField.php @@ -22,7 +22,7 @@ public function getArticle(): ?Article return $this->article; } - public function getArticleToCode(): ?string + public function getArticleToString(): ?string { if ($this->getArticle() != null) { return $this->article->getCode(); @@ -45,7 +45,7 @@ public function setArticle(?Article $article): self * @return $this * @throws Exception */ - public function setArticleFromCode(?string $articleCode) + public function setArticleFromString(?string $articleCode) { $article = new Article(); $article->setCode($articleCode); diff --git a/src/Fields/Invoice/BankField.php b/src/Fields/Invoice/BankField.php index c1fd1d8b..ba1f0564 100644 --- a/src/Fields/Invoice/BankField.php +++ b/src/Fields/Invoice/BankField.php @@ -22,7 +22,7 @@ public function getBank(): ?CashBankBook return $this->bank; } - public function getBankToCode(): ?string + public function getBankToString(): ?string { if ($this->getBank() != null) { return $this->bank->getCode(); @@ -45,7 +45,7 @@ public function setBank(?CashBankBook $bank): self * @return $this * @throws Exception */ - public function setBankFromCode(?string $bankCode) + public function setBankFromString(?string $bankCode) { $bank = new CashBankBook(); $bank->setCode($bankCode); diff --git a/src/Fields/Invoice/InvoiceDebitCreditField.php b/src/Fields/Invoice/DebitCreditField.php similarity index 88% rename from src/Fields/Invoice/InvoiceDebitCreditField.php rename to src/Fields/Invoice/DebitCreditField.php index 68dd2c13..1091fb58 100644 --- a/src/Fields/Invoice/InvoiceDebitCreditField.php +++ b/src/Fields/Invoice/DebitCreditField.php @@ -1,41 +1,41 @@ -debitCredit; - } - - /** - * @param InvoiceDebitCredit|null $debitCredit - * @return $this - */ - public function setDebitCredit(?InvoiceDebitCredit $debitCredit): self - { - $this->debitCredit = $debitCredit; - return $this; - } - - /** - * @param string|null $debitCreditString - * @return $this - * @throws Exception - */ - public function setDebitCreditFromString(?string $debitCreditString) - { - return $this->setDebitCredit(new InvoiceDebitCredit((string)$debitCreditString)); - } +debitCredit; + } + + /** + * @param InvoiceDebitCredit|null $debitCredit + * @return $this + */ + public function setDebitCredit(?InvoiceDebitCredit $debitCredit): self + { + $this->debitCredit = $debitCredit; + return $this; + } + + /** + * @param string|null $debitCreditString + * @return $this + * @throws Exception + */ + public function setDebitCreditFromString(?string $debitCreditString) + { + return $this->setDebitCredit(new InvoiceDebitCredit((string)$debitCreditString)); + } } \ No newline at end of file diff --git a/src/Fields/Invoice/InvoiceTypeField.php b/src/Fields/Invoice/InvoiceTypeField.php index 3b72eb4c..abc3eb30 100644 --- a/src/Fields/Invoice/InvoiceTypeField.php +++ b/src/Fields/Invoice/InvoiceTypeField.php @@ -22,7 +22,7 @@ public function getInvoiceType(): ?InvoiceType return $this->invoiceType; } - public function getInvoiceTypeToCode(): ?string + public function getInvoiceTypeToString(): ?string { if ($this->getInvoiceType() != null) { return $this->invoiceType->getCode(); @@ -45,7 +45,7 @@ public function setInvoiceType(?InvoiceType $invoiceType): self * @return $this * @throws Exception */ - public function setInvoiceTypeFromCode(?string $invoiceTypeCode) + public function setInvoiceTypeFromString(?string $invoiceTypeCode) { $invoiceType = new InvoiceType(); $invoiceType->setCode($invoiceTypeCode); diff --git a/src/Fields/Invoice/InvoiceStatusField.php b/src/Fields/Invoice/StatusField.php similarity index 88% rename from src/Fields/Invoice/InvoiceStatusField.php rename to src/Fields/Invoice/StatusField.php index 337de4ed..55f935c1 100644 --- a/src/Fields/Invoice/InvoiceStatusField.php +++ b/src/Fields/Invoice/StatusField.php @@ -1,41 +1,41 @@ -status; - } - - /** - * @param InvoiceStatus|null $status - * @return $this - */ - public function setStatus(?InvoiceStatus $status): self - { - $this->status = $status; - return $this; - } - - /** - * @param string|null $statusString - * @return $this - * @throws Exception - */ - public function setStatusFromString(?string $statusString) - { - return $this->setStatus(new InvoiceStatus((string)$statusString)); - } +status; + } + + /** + * @param InvoiceStatus|null $status + * @return $this + */ + public function setStatus(?InvoiceStatus $status): self + { + $this->status = $status; + return $this; + } + + /** + * @param string|null $statusString + * @return $this + * @throws Exception + */ + public function setStatusFromString(?string $statusString) + { + return $this->setStatus(new InvoiceStatus((string)$statusString)); + } } \ No newline at end of file diff --git a/src/Fields/Invoice/SubArticleField.php b/src/Fields/Invoice/SubArticleField.php index fab4ff83..a256d967 100644 --- a/src/Fields/Invoice/SubArticleField.php +++ b/src/Fields/Invoice/SubArticleField.php @@ -22,7 +22,7 @@ public function getSubArticle(): ?ArticleLine return $this->subArticle; } - public function getSubArticleToSubCode(): ?string + public function getSubArticleToString(): ?string { if ($this->getSubArticle() != null) { return $this->subArticle->getSubCode(); @@ -45,7 +45,7 @@ public function setSubArticle(?ArticleLine $subArticle): self * @return $this * @throws Exception */ - public function setSubArticleFromSubCode(?string $subArticleCode) + public function setSubArticleFromString(?string $subArticleCode) { $subArticle = new ArticleLine(); $subArticle->setSubCode($subArticleCode); diff --git a/src/Fields/Level1234/GeneralLedgerBeginPeriodField.php b/src/Fields/Level1234/BeginPeriodField.php similarity index 89% rename from src/Fields/Level1234/GeneralLedgerBeginPeriodField.php rename to src/Fields/Level1234/BeginPeriodField.php index 2ab7379c..72108980 100644 --- a/src/Fields/Level1234/GeneralLedgerBeginPeriodField.php +++ b/src/Fields/Level1234/BeginPeriodField.php @@ -1,32 +1,32 @@ -beginPeriod; - } - - /** - * @param null|int $beginPeriod - * @return $this - */ - public function setBeginPeriod(?int $beginPeriod): self - { - $this->beginPeriod = $beginPeriod; - return $this; - } +beginPeriod; + } + + /** + * @param null|int $beginPeriod + * @return $this + */ + public function setBeginPeriod(?int $beginPeriod): self + { + $this->beginPeriod = $beginPeriod; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/DimensionGroup/DimensionCodeField.php b/src/Fields/Level1234/DimensionGroup/CodeField.php similarity index 82% rename from src/Fields/Level1234/DimensionGroup/DimensionCodeField.php rename to src/Fields/Level1234/DimensionGroup/CodeField.php index e8d04f02..3ddea308 100644 --- a/src/Fields/Level1234/DimensionGroup/DimensionCodeField.php +++ b/src/Fields/Level1234/DimensionGroup/CodeField.php @@ -1,54 +1,54 @@ -code; - } - - public function getCodeToCode(): ?string - { - if ($this->getCode() != null) { - return $this->code->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setCode($code): self - { - $this->code = $code; - return $this; - } - - /** - * @param string|null $codeCode - * @return $this - * @throws Exception - */ - public function setCodeFromCode(?string $codeCode) - { - $code = new Dummy(); - $code->setCode($codeCode); - return $this->setCode($code); - } -} +code; + } + + public function getCodeToString(): ?string + { + if ($this->getCode() != null) { + return $this->code->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setCode($code): self + { + $this->code = $code; + return $this; + } + + /** + * @param string|null $codeCode + * @return $this + * @throws Exception + */ + public function setCodeFromString(?string $codeCode) + { + $code = new Dummy(); + $code->setCode($codeCode); + return $this->setCode($code); + } +} diff --git a/src/Fields/Level1234/DimensionGroupField.php b/src/Fields/Level1234/DimensionGroup/GroupField.php similarity index 79% rename from src/Fields/Level1234/DimensionGroupField.php rename to src/Fields/Level1234/DimensionGroup/GroupField.php index 9876915a..05d4dc5c 100644 --- a/src/Fields/Level1234/DimensionGroupField.php +++ b/src/Fields/Level1234/DimensionGroup/GroupField.php @@ -1,54 +1,54 @@ -group; - } - - public function getGroupToCode(): ?string - { - if ($this->getGroup() != null) { - return $this->group->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setGroup(?DimensionGroup $group): self - { - $this->group = $group; - return $this; - } - - /** - * @param string|null $groupCode - * @return $this - * @throws Exception - */ - public function setGroupFromCode(?string $groupCode) - { - $group = new DimensionGroup(); - $group->setCode($groupCode); - return $this->setGroup($group); - } -} +group; + } + + public function getGroupToString(): ?string + { + if ($this->getGroup() != null) { + return $this->group->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setGroup(?DimensionGroup $group): self + { + $this->group = $group; + return $this; + } + + /** + * @param string|null $groupCode + * @return $this + * @throws Exception + */ + public function setGroupFromString(?string $groupCode) + { + $group = new DimensionGroup(); + $group->setCode($groupCode); + return $this->setGroup($group); + } +} diff --git a/src/Fields/Level1234/DimensionType/DimensionTypeFinancialsField.php b/src/Fields/Level1234/DimensionType/FinancialsField.php similarity index 82% rename from src/Fields/Level1234/DimensionType/DimensionTypeFinancialsField.php rename to src/Fields/Level1234/DimensionType/FinancialsField.php index 9c309887..3b0725a0 100644 --- a/src/Fields/Level1234/DimensionType/DimensionTypeFinancialsField.php +++ b/src/Fields/Level1234/DimensionType/FinancialsField.php @@ -1,32 +1,32 @@ -financials; - } - - /** - * @param null|int $financials - * @return $this - */ - public function setFinancials(?int $financials): self - { - $this->financials = $financials; - return $this; - } +financials; + } + + /** + * @param null|int $financials + * @return $this + */ + public function setFinancials(?int $financials): self + { + $this->financials = $financials; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/DimensionType/DimensionTypeTimeField.php b/src/Fields/Level1234/DimensionType/TimeField.php similarity index 83% rename from src/Fields/Level1234/DimensionType/DimensionTypeTimeField.php rename to src/Fields/Level1234/DimensionType/TimeField.php index fc821496..aeae646e 100644 --- a/src/Fields/Level1234/DimensionType/DimensionTypeTimeField.php +++ b/src/Fields/Level1234/DimensionType/TimeField.php @@ -1,32 +1,32 @@ -time; - } - - /** - * @param null|int $time - * @return $this - */ - public function setTime(?int $time): self - { - $this->time = $time; - return $this; - } +time; + } + + /** + * @param null|int $time + * @return $this + */ + public function setTime(?int $time): self + { + $this->time = $time; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/DimensionTypeField.php b/src/Fields/Level1234/DimensionType/TypeField.php similarity index 80% rename from src/Fields/Level1234/DimensionTypeField.php rename to src/Fields/Level1234/DimensionType/TypeField.php index bf08779a..ec0d9ed6 100644 --- a/src/Fields/Level1234/DimensionTypeField.php +++ b/src/Fields/Level1234/DimensionType/TypeField.php @@ -1,54 +1,54 @@ -type; - } - - public function getTypeToCode(): ?string - { - if ($this->getType() != null) { - return $this->type->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setType(?DimensionType $type): self - { - $this->type = $type; - return $this; - } - - /** - * @param string|null $typeCode - * @return $this - * @throws Exception - */ - public function setTypeFromCode(?string $typeCode) - { - $type = new DimensionType(); - $type->setCode($typeCode); - return $this->setType($type); - } -} +type; + } + + public function getTypeToString(): ?string + { + if ($this->getType() != null) { + return $this->type->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setType(?DimensionType $type): self + { + $this->type = $type; + return $this; + } + + /** + * @param string|null $typeCode + * @return $this + * @throws Exception + */ + public function setTypeFromString(?string $typeCode) + { + $type = new DimensionType(); + $type->setCode($typeCode); + return $this->setType($type); + } +} diff --git a/src/Fields/Level1234/GeneralLedgerEndPeriodField.php b/src/Fields/Level1234/EndPeriodField.php similarity index 89% rename from src/Fields/Level1234/GeneralLedgerEndPeriodField.php rename to src/Fields/Level1234/EndPeriodField.php index 8dd91d39..ecb23732 100644 --- a/src/Fields/Level1234/GeneralLedgerEndPeriodField.php +++ b/src/Fields/Level1234/EndPeriodField.php @@ -1,32 +1,32 @@ -endPeriod; - } - - /** - * @param null|int $endPeriod - * @return $this - */ - public function setEndPeriod(?int $endPeriod): self - { - $this->endPeriod = $endPeriod; - return $this; - } +endPeriod; + } + + /** + * @param null|int $endPeriod + * @return $this + */ + public function setEndPeriod(?int $endPeriod): self + { + $this->endPeriod = $endPeriod; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/AddressField2Field.php b/src/Fields/Level1234/Level2/AddressField2Field.php index f973ab74..d32eae16 100644 --- a/src/Fields/Level1234/Level2/AddressField2Field.php +++ b/src/Fields/Level1234/Level2/AddressField2Field.php @@ -10,23 +10,23 @@ trait AddressField2Field * * @var string|null */ - private $field2; + private $addressField2; /** * @return null|string */ - public function getField2(): ?string + public function getAddressField2(): ?string { - return $this->field2; + return $this->addressField2; } /** - * @param null|string $field2 + * @param null|string $addressField2 * @return $this */ - public function setField2(?string $field2): self + public function setAddressField2(?string $addressField2): self { - $this->field2 = $field2; + $this->addressField2 = $addressField2; return $this; } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/AddressField3Field.php b/src/Fields/Level1234/Level2/AddressField3Field.php index f6c2e887..80b2b037 100644 --- a/src/Fields/Level1234/Level2/AddressField3Field.php +++ b/src/Fields/Level1234/Level2/AddressField3Field.php @@ -10,23 +10,23 @@ trait AddressField3Field * * @var string|null */ - private $field3; + private $addressField3; /** * @return null|string */ - public function getField3(): ?string + public function getAddressField3(): ?string { - return $this->field3; + return $this->addressField3; } /** - * @param null|string $field3 + * @param null|string $addressField3 * @return $this */ - public function setField3(?string $field3): self + public function setAddressField3(?string $addressField3): self { - $this->field3 = $field3; + $this->addressField3 = $addressField3; return $this; } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/CountryField.php b/src/Fields/Level1234/Level2/CountryField.php index 96cab4ab..36a110fa 100644 --- a/src/Fields/Level1234/Level2/CountryField.php +++ b/src/Fields/Level1234/Level2/CountryField.php @@ -22,7 +22,7 @@ public function getCountry(): ?Country return $this->country; } - public function getCountryToCode(): ?string + public function getCountryToString(): ?string { if ($this->getCountry() != null) { return $this->country->getCode(); @@ -45,7 +45,7 @@ public function setCountry(?Country $country): self * @return $this * @throws Exception */ - public function setCountryFromCode(?string $countryCode) + public function setCountryFromString(?string $countryCode) { $country = new Country(); $country->setCode($countryCode); diff --git a/src/Fields/Level1234/Level2/Customer/DiscountArticleField.php b/src/Fields/Level1234/Level2/Customer/DiscountArticleField.php index d9408e6e..3516143d 100644 --- a/src/Fields/Level1234/Level2/Customer/DiscountArticleField.php +++ b/src/Fields/Level1234/Level2/Customer/DiscountArticleField.php @@ -22,7 +22,7 @@ public function getDiscountArticle(): ?Article return $this->discountArticle; } - public function getDiscountArticleToCode(): ?string + public function getDiscountArticleToString(): ?string { if ($this->getDiscountArticle() != null) { return $this->discountArticle->getCode(); @@ -45,7 +45,7 @@ public function setDiscountArticle(?Article $discountArticle): self * @return $this * @throws Exception */ - public function setDiscountArticleFromCode(?string $discountArticleCode) + public function setDiscountArticleFromString(?string $discountArticleCode) { $discountArticle = new Article(); $discountArticle->setCode($discountArticleCode); diff --git a/src/Fields/Level1234/Level2/Customer/CustomerFreeText1Field.php b/src/Fields/Level1234/Level2/Customer/FreeText1Field.php similarity index 92% rename from src/Fields/Level1234/Level2/Customer/CustomerFreeText1Field.php rename to src/Fields/Level1234/Level2/Customer/FreeText1Field.php index b13b0b31..5788c0b1 100644 --- a/src/Fields/Level1234/Level2/Customer/CustomerFreeText1Field.php +++ b/src/Fields/Level1234/Level2/Customer/FreeText1Field.php @@ -1,47 +1,47 @@ -freeText1; - } - - public function getFreeText1ToString(): ?string - { - return ($this->getFreeText1()) ? 'true' : 'false'; - } - - /** - * @param bool $freeText1 - * @return $this - */ - public function setFreeText1(?bool $freeText1): self - { - $this->freeText1 = $freeText1; - return $this; - } - - /** - * @param string|null $freeText1String - * @return $this - * @throws Exception - */ - public function setFreeText1FromString(?string $freeText1String) - { - return $this->setFreeText1(filter_var($freeText1String, FILTER_VALIDATE_BOOLEAN)); - } +freeText1; + } + + public function getFreeText1ToString(): ?string + { + return ($this->getFreeText1()) ? 'true' : 'false'; + } + + /** + * @param bool $freeText1 + * @return $this + */ + public function setFreeText1(?bool $freeText1): self + { + $this->freeText1 = $freeText1; + return $this; + } + + /** + * @param string|null $freeText1String + * @return $this + * @throws Exception + */ + public function setFreeText1FromString(?string $freeText1String) + { + return $this->setFreeText1(filter_var($freeText1String, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/CollectMandateIDField.php b/src/Fields/Level1234/Level2/Customer/IDField.php similarity index 89% rename from src/Fields/Level1234/Level2/Customer/CollectMandateIDField.php rename to src/Fields/Level1234/Level2/Customer/IDField.php index ecedddbd..362b58fb 100644 --- a/src/Fields/Level1234/Level2/Customer/CollectMandateIDField.php +++ b/src/Fields/Level1234/Level2/Customer/IDField.php @@ -1,32 +1,32 @@ -ID; - } - - /** - * @param null|string $ID - * @return $this - */ - public function setID(?string $ID): self - { - $this->ID = $ID; - return $this; - } +ID; + } + + /** + * @param null|string $ID + * @return $this + */ + public function setID(?string $ID): self + { + $this->ID = $ID; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/ResponsibleUserField.php b/src/Fields/Level1234/Level2/Customer/ResponsibleUserField.php index 23003a9c..51bdeeec 100644 --- a/src/Fields/Level1234/Level2/Customer/ResponsibleUserField.php +++ b/src/Fields/Level1234/Level2/Customer/ResponsibleUserField.php @@ -22,7 +22,7 @@ public function getResponsibleUser(): ?User return $this->responsibleUser; } - public function getResponsibleUserToCode(): ?string + public function getResponsibleUserToString(): ?string { if ($this->getResponsibleUser() != null) { return $this->responsibleUser->getCode(); @@ -45,7 +45,7 @@ public function setResponsibleUser(?User $responsibleUser): self * @return $this * @throws Exception */ - public function setResponsibleUserFromCode(?string $responsibleUserCode) + public function setResponsibleUserFromString(?string $responsibleUserCode) { $responsibleUser = new User(); $responsibleUser->setCode($responsibleUserCode); diff --git a/src/Fields/Level1234/Level2/Dimension1Field.php b/src/Fields/Level1234/Level2/Dimension1Field.php index 50549417..d1b60a56 100644 --- a/src/Fields/Level1234/Level2/Dimension1Field.php +++ b/src/Fields/Level1234/Level2/Dimension1Field.php @@ -22,7 +22,7 @@ public function getDimension1(): ?GeneralLedger return $this->dimension1; } - public function getDimension1ToCode(): ?string + public function getDimension1ToString(): ?string { if ($this->getDimension1() != null) { return $this->dimension1->getCode(); @@ -45,7 +45,7 @@ public function setDimension1(?GeneralLedger $dimension1): self * @return $this * @throws Exception */ - public function setDimension1FromCode(?string $dimension1Code) + public function setDimension1FromString(?string $dimension1Code) { $dimension1 = new GeneralLedger(); $dimension1->setCode($dimension1Code); diff --git a/src/Fields/Level1234/Level2/Dimension2Field.php b/src/Fields/Level1234/Level2/Dimension2Field.php index 29374a84..810a2e75 100644 --- a/src/Fields/Level1234/Level2/Dimension2Field.php +++ b/src/Fields/Level1234/Level2/Dimension2Field.php @@ -22,7 +22,7 @@ public function getDimension2(): ?CostCenter return $this->dimension2; } - public function getDimension2ToCode(): ?string + public function getDimension2ToString(): ?string { if ($this->getDimension2() != null) { return $this->dimension2->getCode(); @@ -45,7 +45,7 @@ public function setDimension2(?CostCenter $dimension2): self * @return $this * @throws Exception */ - public function setDimension2FromCode(?string $dimension2Code) + public function setDimension2FromString(?string $dimension2Code) { $dimension2 = new CostCenter(); $dimension2->setCode($dimension2Code); diff --git a/src/Fields/Level1234/Level2/Dimension3Field.php b/src/Fields/Level1234/Level2/Dimension3Field.php index 3e97dcf5..2afe81c6 100644 --- a/src/Fields/Level1234/Level2/Dimension3Field.php +++ b/src/Fields/Level1234/Level2/Dimension3Field.php @@ -22,7 +22,7 @@ public function getDimension3() return $this->dimension3; } - public function getDimension3ToCode(): ?string + public function getDimension3ToString(): ?string { if ($this->getDimension3() != null) { return $this->dimension3->getCode(); @@ -45,7 +45,7 @@ public function setDimension3($dimension3): self * @return $this * @throws Exception */ - public function setDimension3FromCode(?string $dimension3Code) + public function setDimension3FromString(?string $dimension3Code) { $dimension3 = new Dummy(); $dimension3->setCode($dimension3Code); diff --git a/src/Fields/Level1234/Level2/PayCodeField.php b/src/Fields/Level1234/Level2/PayCodeField.php index c50dd6f3..34c7590e 100644 --- a/src/Fields/Level1234/Level2/PayCodeField.php +++ b/src/Fields/Level1234/Level2/PayCodeField.php @@ -22,7 +22,7 @@ public function getPayCode(): ?PayCode return $this->payCode; } - public function getPayCodeToCode(): ?string + public function getPayCodeToString(): ?string { if ($this->getPayCode() != null) { return $this->payCode->getCode(); @@ -45,7 +45,7 @@ public function setPayCode(?PayCode $payCode): self * @return $this * @throws Exception */ - public function setPayCodeFromCode(?string $payCodeCode) + public function setPayCodeFromString(?string $payCodeCode) { $payCode = new PayCode(); $payCode->setCode($payCodeCode); diff --git a/src/Fields/Level1234/Level2/AddressTypeField.php b/src/Fields/Level1234/Level2/TypeField.php similarity index 89% rename from src/Fields/Level1234/Level2/AddressTypeField.php rename to src/Fields/Level1234/Level2/TypeField.php index d850d4c0..ff76023a 100644 --- a/src/Fields/Level1234/Level2/AddressTypeField.php +++ b/src/Fields/Level1234/Level2/TypeField.php @@ -1,41 +1,41 @@ -type; - } - - /** - * @param AddressType|null $type - * @return $this - */ - public function setType(?AddressType $type): self - { - $this->type = $type; - return $this; - } - - /** - * @param string|null $typeString - * @return $this - * @throws Exception - */ - public function setTypeFromString(?string $typeString) - { - return $this->setType(new AddressType((string)$typeString)); - } +type; + } + + /** + * @param AddressType|null $type + * @return $this + */ + public function setType(?AddressType $type): self + { + $this->type = $type; + return $this; + } + + /** + * @param string|null $typeString + * @return $this + * @throws Exception + */ + public function setTypeFromString(?string $typeString) + { + return $this->setType(new AddressType((string)$typeString)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/AuthoriserField.php b/src/Fields/Level1234/Level34/AuthoriserField.php index c2720aa5..8b7b667d 100644 --- a/src/Fields/Level1234/Level34/AuthoriserField.php +++ b/src/Fields/Level1234/Level34/AuthoriserField.php @@ -22,7 +22,7 @@ public function getAuthoriser(): ?User return $this->authoriser; } - public function getAuthoriserToCode(): ?string + public function getAuthoriserToString(): ?string { if ($this->getAuthoriser() != null) { return $this->authoriser->getCode(); @@ -45,7 +45,7 @@ public function setAuthoriser(?User $authoriser): self * @return $this * @throws Exception */ - public function setAuthoriserFromCode(?string $authoriserCode) + public function setAuthoriserFromString(?string $authoriserCode) { $authoriser = new User(); $authoriser->setCode($authoriserCode); diff --git a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetCodeField.php b/src/Fields/Level1234/Level34/FixedAsset/CodeField.php similarity index 84% rename from src/Fields/Level1234/Level34/FixedAsset/FixedAssetCodeField.php rename to src/Fields/Level1234/Level34/FixedAsset/CodeField.php index 6bd027cb..55151704 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetCodeField.php +++ b/src/Fields/Level1234/Level34/FixedAsset/CodeField.php @@ -1,40 +1,40 @@ -code; - } - - public function getCodeToCode(): ?string - { - if ($this->getCode() != null) { - return $this->code->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setCode($code): self - { - $this->code = $code; - return $this; - } -} +code; + } + + public function getCodeToString(): ?string + { + if ($this->getCode() != null) { + return $this->code->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setCode($code): self + { + $this->code = $code; + return $this; + } +} diff --git a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetCodeLockedField.php b/src/Fields/Level1234/Level34/FixedAsset/CodeLockedField.php similarity index 88% rename from src/Fields/Level1234/Level34/FixedAsset/FixedAssetCodeLockedField.php rename to src/Fields/Level1234/Level34/FixedAsset/CodeLockedField.php index 12e88646..25111b1a 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetCodeLockedField.php +++ b/src/Fields/Level1234/Level34/FixedAsset/CodeLockedField.php @@ -1,47 +1,47 @@ -codeLocked; - } - - public function getCodeLockedToString(): ?string - { - return ($this->getCodeLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $codeLocked - * @return $this - */ - public function setCodeLocked(?bool $codeLocked): self - { - $this->codeLocked = $codeLocked; - return $this; - } - - /** - * @param string|null $codeLockedString - * @return $this - * @throws Exception - */ - public function setCodeLockedFromString(?string $codeLockedString) - { - return $this->setCodeLocked(filter_var($codeLockedString, FILTER_VALIDATE_BOOLEAN)); - } +codeLocked; + } + + public function getCodeLockedToString(): ?string + { + return ($this->getCodeLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $codeLocked + * @return $this + */ + public function setCodeLocked(?bool $codeLocked): self + { + $this->codeLocked = $codeLocked; + return $this; + } + + /** + * @param string|null $codeLockedString + * @return $this + * @throws Exception + */ + public function setCodeLockedFromString(?string $codeLockedString) + { + return $this->setCodeLocked(filter_var($codeLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php b/src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php index 13f159fe..ae919497 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php +++ b/src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php @@ -22,7 +22,7 @@ public function getDim2() return $this->dim2; } - public function getDim2ToCode(): ?string + public function getDim2ToString(): ?string { if ($this->getDim2() != null) { return $this->dim2->getCode(); @@ -45,7 +45,7 @@ public function setDim2($dim2): self * @return $this * @throws Exception */ - public function setDim2FromCode(?string $dim2Code) + public function setDim2FromString(?string $dim2Code) { $dim2 = new Dummy(); $dim2->setCode($dim2Code); diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim3Field.php b/src/Fields/Level1234/Level34/FixedAsset/Dim3Field.php index c1540d66..71b36d14 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/Dim3Field.php +++ b/src/Fields/Level1234/Level34/FixedAsset/Dim3Field.php @@ -22,7 +22,7 @@ public function getDim3() return $this->dim3; } - public function getDim3ToCode(): ?string + public function getDim3ToString(): ?string { if ($this->getDim3() != null) { return $this->dim3->getCode(); @@ -45,7 +45,7 @@ public function setDim3($dim3): self * @return $this * @throws Exception */ - public function setDim3FromCode(?string $dim3Code) + public function setDim3FromString(?string $dim3Code) { $dim3 = new Dummy(); $dim3->setCode($dim3Code); diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php b/src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php index 763114a4..228faea0 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php +++ b/src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php @@ -22,7 +22,7 @@ public function getDim4() return $this->dim4; } - public function getDim4ToCode(): ?string + public function getDim4ToString(): ?string { if ($this->getDim4() != null) { return $this->dim4->getCode(); @@ -45,7 +45,7 @@ public function setDim4($dim4): self * @return $this * @throws Exception */ - public function setDim4FromCode(?string $dim4Code) + public function setDim4FromString(?string $dim4Code) { $dim4 = new Dummy(); $dim4->setCode($dim4Code); diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim5Field.php b/src/Fields/Level1234/Level34/FixedAsset/Dim5Field.php index 126c8bb1..c66489e7 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/Dim5Field.php +++ b/src/Fields/Level1234/Level34/FixedAsset/Dim5Field.php @@ -22,7 +22,7 @@ public function getDim5() return $this->dim5; } - public function getDim5ToCode(): ?string + public function getDim5ToString(): ?string { if ($this->getDim5() != null) { return $this->dim5->getCode(); @@ -45,7 +45,7 @@ public function setDim5($dim5): self * @return $this * @throws Exception */ - public function setDim5FromCode(?string $dim5Code) + public function setDim5FromString(?string $dim5Code) { $dim5 = new Dummy(); $dim5->setCode($dim5Code); diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim6Field.php b/src/Fields/Level1234/Level34/FixedAsset/Dim6Field.php index 60a3a70d..cbe05420 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/Dim6Field.php +++ b/src/Fields/Level1234/Level34/FixedAsset/Dim6Field.php @@ -22,7 +22,7 @@ public function getDim6() return $this->dim6; } - public function getDim6ToCode(): ?string + public function getDim6ToString(): ?string { if ($this->getDim6() != null) { return $this->dim6->getCode(); @@ -45,7 +45,7 @@ public function setDim6($dim6): self * @return $this * @throws Exception */ - public function setDim6FromCode(?string $dim6Code) + public function setDim6FromString(?string $dim6Code) { $dim6 = new Dummy(); $dim6->setCode($dim6Code); diff --git a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsMethodField.php b/src/Fields/Level1234/Level34/FixedAsset/MethodField.php similarity index 80% rename from src/Fields/Level1234/Level34/FixedAsset/FixedAssetsMethodField.php rename to src/Fields/Level1234/Level34/FixedAsset/MethodField.php index abead77b..7da4a172 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsMethodField.php +++ b/src/Fields/Level1234/Level34/FixedAsset/MethodField.php @@ -1,54 +1,54 @@ -method; - } - - public function getMethodToCode(): ?string - { - if ($this->getMethod() != null) { - return $this->method->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setMethod(?AssetMethod $method): self - { - $this->method = $method; - return $this; - } - - /** - * @param string|null $methodCode - * @return $this - * @throws Exception - */ - public function setMethodFromCode(?string $methodCode) - { - $method = new AssetMethod(); - $method->setCode($methodCode); - return $this->setMethod($method); - } -} +method; + } + + public function getMethodToString(): ?string + { + if ($this->getMethod() != null) { + return $this->method->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setMethod(?AssetMethod $method): self + { + $this->method = $method; + return $this; + } + + /** + * @param string|null $methodCode + * @return $this + * @throws Exception + */ + public function setMethodFromString(?string $methodCode) + { + $method = new AssetMethod(); + $method->setCode($methodCode); + return $this->setMethod($method); + } +} diff --git a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsMethodLockedField.php b/src/Fields/Level1234/Level34/FixedAsset/MethodLockedField.php similarity index 88% rename from src/Fields/Level1234/Level34/FixedAsset/FixedAssetsMethodLockedField.php rename to src/Fields/Level1234/Level34/FixedAsset/MethodLockedField.php index 88ecb0f6..4f4fe26a 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsMethodLockedField.php +++ b/src/Fields/Level1234/Level34/FixedAsset/MethodLockedField.php @@ -1,47 +1,47 @@ -methodLocked; - } - - public function getMethodLockedToString(): ?string - { - return ($this->getMethodLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $methodLocked - * @return $this - */ - public function setMethodLocked(?bool $methodLocked): self - { - $this->methodLocked = $methodLocked; - return $this; - } - - /** - * @param string|null $methodLockedString - * @return $this - * @throws Exception - */ - public function setMethodLockedFromString(?string $methodLockedString) - { - return $this->setMethodLocked(filter_var($methodLockedString, FILTER_VALIDATE_BOOLEAN)); - } +methodLocked; + } + + public function getMethodLockedToString(): ?string + { + return ($this->getMethodLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $methodLocked + * @return $this + */ + public function setMethodLocked(?bool $methodLocked): self + { + $this->methodLocked = $methodLocked; + return $this; + } + + /** + * @param string|null $methodLockedString + * @return $this + * @throws Exception + */ + public function setMethodLockedFromString(?string $methodLockedString) + { + return $this->setMethodLocked(filter_var($methodLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusField.php b/src/Fields/Level1234/Level34/FixedAsset/StatusField.php similarity index 88% rename from src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusField.php rename to src/Fields/Level1234/Level34/FixedAsset/StatusField.php index 107f4736..f260cbb6 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusField.php +++ b/src/Fields/Level1234/Level34/FixedAsset/StatusField.php @@ -1,41 +1,41 @@ -status; - } - - /** - * @param FixedAssetsStatus|null $status - * @return $this - */ - public function setStatus(?FixedAssetsStatus $status): self - { - $this->status = $status; - return $this; - } - - /** - * @param string|null $statusString - * @return $this - * @throws Exception - */ - public function setStatusFromString(?string $statusString) - { - return $this->setStatus(new FixedAssetsStatus((string)$statusString)); - } +status; + } + + /** + * @param FixedAssetsStatus|null $status + * @return $this + */ + public function setStatus(?FixedAssetsStatus $status): self + { + $this->status = $status; + return $this; + } + + /** + * @param string|null $statusString + * @return $this + * @throws Exception + */ + public function setStatusFromString(?string $statusString) + { + return $this->setStatus(new FixedAssetsStatus((string)$statusString)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusLockedField.php b/src/Fields/Level1234/Level34/FixedAsset/StatusLockedField.php similarity index 88% rename from src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusLockedField.php rename to src/Fields/Level1234/Level34/FixedAsset/StatusLockedField.php index c85db61c..e9d0d743 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/FixedAssetsStatusLockedField.php +++ b/src/Fields/Level1234/Level34/FixedAsset/StatusLockedField.php @@ -1,47 +1,47 @@ -statusLocked; - } - - public function getStatusLockedToString(): ?string - { - return ($this->getStatusLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $statusLocked - * @return $this - */ - public function setStatusLocked(?bool $statusLocked): self - { - $this->statusLocked = $statusLocked; - return $this; - } - - /** - * @param string|null $statusLockedString - * @return $this - * @throws Exception - */ - public function setStatusLockedFromString(?string $statusLockedString) - { - return $this->setStatusLocked(filter_var($statusLockedString, FILTER_VALIDATE_BOOLEAN)); - } +statusLocked; + } + + public function getStatusLockedToString(): ?string + { + return ($this->getStatusLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $statusLocked + * @return $this + */ + public function setStatusLocked(?bool $statusLocked): self + { + $this->statusLocked = $statusLocked; + return $this; + } + + /** + * @param string|null $statusLockedString + * @return $this + * @throws Exception + */ + public function setStatusLockedFromString(?string $statusLockedString) + { + return $this->setStatusLocked(filter_var($statusLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/SubstituteWithField.php b/src/Fields/Level1234/SubstituteWithField.php index 2862ee11..3c2c95b8 100644 --- a/src/Fields/Level1234/SubstituteWithField.php +++ b/src/Fields/Level1234/SubstituteWithField.php @@ -22,7 +22,7 @@ public function getSubstituteWith() return $this->substituteWith; } - public function getSubstituteWithToCode(): ?string + public function getSubstituteWithToString(): ?string { if ($this->getSubstituteWith() != null) { return $this->substituteWith->getCode(); @@ -45,7 +45,7 @@ public function setSubstituteWith($substituteWith): self * @return $this * @throws Exception */ - public function setSubstituteWithFromCode(?string $substituteWithCode) + public function setSubstituteWithFromString(?string $substituteWithCode) { $substituteWith = new Dummy(); $substituteWith->setCode($substituteWithCode); diff --git a/src/Fields/Level1234/GeneralLedgerTypeField.php b/src/Fields/Level1234/TypeField.php similarity index 55% rename from src/Fields/Level1234/GeneralLedgerTypeField.php rename to src/Fields/Level1234/TypeField.php index 60d80a82..b6a9f523 100644 --- a/src/Fields/Level1234/GeneralLedgerTypeField.php +++ b/src/Fields/Level1234/TypeField.php @@ -1,41 +1,41 @@ -type; - } - - /** - * @param GeneralLedgerType|null $type - * @return $this - */ - public function setType(?GeneralLedgerType $type): self - { - $this->type = $type; - return $this; - } - - /** - * @param string|null $typeString - * @return $this - * @throws Exception - */ - public function setTypeFromString(?string $typeString) - { - return $this->setType(new GeneralLedgerType((string)$typeString)); - } +type; + } + + /** + * @param ChildValidationType|null $type + * @return $this + */ + public function setType(?ChildValidationType $type): self + { + $this->type = $type; + return $this; + } + + /** + * @param string|null $typeString + * @return $this + * @throws Exception + */ + public function setTypeFromString(?string $typeString) + { + return $this->setType(new ChildValidationType((string)$typeString)); + } } \ No newline at end of file diff --git a/src/Fields/Office/CountryCodeField.php b/src/Fields/Office/CountryCodeField.php index e9b1d432..3b18fe44 100644 --- a/src/Fields/Office/CountryCodeField.php +++ b/src/Fields/Office/CountryCodeField.php @@ -2,31 +2,53 @@ namespace PhpTwinfield\Fields\Office; +use PhpTwinfield\Country; + +/** + * The country + * Used by: Office + * + * @package PhpTwinfield\Traits + */ trait CountryCodeField { /** - * Country code field - * Used by: Office - * - * @var string|null + * @var Country|null */ private $countryCode; - /** - * @return null|string - */ - public function getCountryCode(): ?string + public function getCountryCode(): ?Country { return $this->countryCode; } + public function getCountryCodeToString(): ?string + { + if ($this->getCountryCode() != null) { + return $this->countryCode->getCode(); + } else { + return null; + } + } + /** - * @param null|string $countryCode * @return $this */ - public function setCountryCode(?string $countryCode): self + public function setCountryCode(?Country $countryCode): self { $this->countryCode = $countryCode; return $this; } + + /** + * @param string|null $countryCode + * @return $this + * @throws Exception + */ + public function setCountryCodeFromString(?string $countryCode) + { + $countryCode = new Country(); + $countryCode->setCode($countryCode); + return $this->setCountryCode($countryCode); + } } \ No newline at end of file diff --git a/src/Fields/OfficeField.php b/src/Fields/OfficeField.php index 1de4efd1..bb147f7e 100644 --- a/src/Fields/OfficeField.php +++ b/src/Fields/OfficeField.php @@ -21,7 +21,7 @@ public function getOffice(): ?Office return $this->office; } - public function getOfficeToCode(): ?string + public function getOfficeToString(): ?string { if ($this->getOffice() != null) { return $this->office->getCode(); @@ -44,7 +44,7 @@ public function setOffice(?Office $office): self * @return $this * @throws Exception */ - public function setOfficeFromCode(?string $officeCode) + public function setOfficeFromString(?string $officeCode) { $office = new Office(); $office->setCode($officeCode); diff --git a/src/Fields/RateField.php b/src/Fields/RateField.php index 2b5bb755..d40b7d12 100644 --- a/src/Fields/RateField.php +++ b/src/Fields/RateField.php @@ -22,7 +22,7 @@ public function getRate(): ?Rate return $this->rate; } - public function getRateToCode(): ?string + public function getRateToString(): ?string { if ($this->getRate() != null) { return $this->rate->getCode(); @@ -45,7 +45,7 @@ public function setRate(?Rate $rate): self * @return $this * @throws Exception */ - public function setRateFromCode(?string $rateCode) + public function setRateFromString(?string $rateCode) { $rate = new Rate(); $rate->setCode($rateCode); diff --git a/src/Fields/UserField.php b/src/Fields/UserField.php index a8c756b1..e0fddfc8 100644 --- a/src/Fields/UserField.php +++ b/src/Fields/UserField.php @@ -22,7 +22,7 @@ public function getUser(): ?User return $this->user; } - public function getUserToCode(): ?string + public function getUserToString(): ?string { if ($this->getUser() != null) { return $this->user->getCode(); @@ -45,7 +45,7 @@ public function setUser(?User $user): self * @return $this * @throws Exception */ - public function setUserFromCode(?string $userCode) + public function setUserFromString(?string $userCode) { $user = new User(); $user->setCode($userCode); diff --git a/src/Fields/VatCode/VatGroupCountryField.php b/src/Fields/VatCode/GroupCountryField.php similarity index 82% rename from src/Fields/VatCode/VatGroupCountryField.php rename to src/Fields/VatCode/GroupCountryField.php index 85813667..8489e9b6 100644 --- a/src/Fields/VatCode/VatGroupCountryField.php +++ b/src/Fields/VatCode/GroupCountryField.php @@ -1,54 +1,54 @@ -groupCountry; - } - - public function getGroupCountryToCode(): ?string - { - if ($this->getGroupCountry() != null) { - return $this->groupCountry->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setGroupCountry(?Country $groupCountry): self - { - $this->groupCountry = $groupCountry; - return $this; - } - - /** - * @param string|null $groupCountryCode - * @return $this - * @throws Exception - */ - public function setGroupCountryFromCode(?string $groupCountryCode) - { - $groupCountry = new Country(); - $groupCountry->setCode($groupCountryCode); - return $this->setGroupCountry($groupCountry); - } +groupCountry; + } + + public function getGroupCountryToString(): ?string + { + if ($this->getGroupCountry() != null) { + return $this->groupCountry->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setGroupCountry(?Country $groupCountry): self + { + $this->groupCountry = $groupCountry; + return $this; + } + + /** + * @param string|null $groupCountryCode + * @return $this + * @throws Exception + */ + public function setGroupCountryFromString(?string $groupCountryCode) + { + $groupCountry = new Country(); + $groupCountry->setCode($groupCountryCode); + return $this->setGroupCountry($groupCountry); + } } \ No newline at end of file diff --git a/src/Fields/VatCode/VatGroupField.php b/src/Fields/VatCode/GroupField.php similarity index 82% rename from src/Fields/VatCode/VatGroupField.php rename to src/Fields/VatCode/GroupField.php index a8f15ce2..8b7bef8a 100644 --- a/src/Fields/VatCode/VatGroupField.php +++ b/src/Fields/VatCode/GroupField.php @@ -1,54 +1,54 @@ -group; - } - - public function getGroupToCode(): ?string - { - if ($this->getGroup() != null) { - return $this->group->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setGroup(?VatGroup $group): self - { - $this->group = $group; - return $this; - } - - /** - * @param string|null $groupCode - * @return $this - * @throws Exception - */ - public function setGroupFromCode(?string $groupCode) - { - $group = new VatGroup(); - $group->setCode($groupCode); - return $this->setGroup($group); - } +group; + } + + public function getGroupToString(): ?string + { + if ($this->getGroup() != null) { + return $this->group->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setGroup(?VatGroup $group): self + { + $this->group = $group; + return $this; + } + + /** + * @param string|null $groupCode + * @return $this + * @throws Exception + */ + public function setGroupFromString(?string $groupCode) + { + $group = new VatGroup(); + $group->setCode($groupCode); + return $this->setGroup($group); + } } \ No newline at end of file diff --git a/src/Fields/VatCode/LineTypeField.php b/src/Fields/VatCode/LineTypeField.php index 2cc5c26c..d291c235 100644 --- a/src/Fields/VatCode/LineTypeField.php +++ b/src/Fields/VatCode/LineTypeField.php @@ -12,20 +12,20 @@ trait LineTypeField * * @var LineType|null */ - private $linetype; + private $lineType; public function getLineType(): ?LineType { - return $this->linetype; + return $this->lineType; } /** * @param LineType|null $linetype * @return $this */ - public function setLineType(?LineType $linetype): self + public function setLineType(?LineType $lineType): self { - $this->linetype = $linetype; + $this->lineType = $lineType; return $this; } diff --git a/src/Fields/VatCode/VatCodeTypeField.php b/src/Fields/VatCode/TypeField.php similarity index 91% rename from src/Fields/VatCode/VatCodeTypeField.php rename to src/Fields/VatCode/TypeField.php index a77ba16e..d685c0c1 100644 --- a/src/Fields/VatCode/VatCodeTypeField.php +++ b/src/Fields/VatCode/TypeField.php @@ -1,41 +1,41 @@ -type; - } - - /** - * @param VatType|null $type - * @return $this - */ - public function setType(?VatType $type): self - { - $this->type = $type; - return $this; - } - - /** - * @param string|null $typeString - * @return $this - * @throws Exception - */ - public function setTypeFromString(?string $typeString) - { - return $this->setType(new VatType((string)$typeString)); - } +type; + } + + /** + * @param VatType|null $type + * @return $this + */ + public function setType(?VatType $type): self + { + $this->type = $type; + return $this; + } + + /** + * @param string|null $typeString + * @return $this + * @throws Exception + */ + public function setTypeFromString(?string $typeString) + { + return $this->setType(new VatType((string)$typeString)); + } } \ No newline at end of file diff --git a/src/Fields/VatCodeField.php b/src/Fields/VatCodeField.php index 64ec772f..a5d1a5da 100644 --- a/src/Fields/VatCodeField.php +++ b/src/Fields/VatCodeField.php @@ -22,7 +22,7 @@ public function getVatCode(): ?VatCode return $this->vatCode; } - public function getVatCodeToCode(): ?string + public function getVatCodeToString(): ?string { if ($this->getVatCode() != null) { return $this->vatCode->getCode(); @@ -45,7 +45,7 @@ public function setVatCode(?VatCode $vatCode): self * @return $this * @throws Exception */ - public function setVatCodeFromCode(?string $vatCodeCode) + public function setVatCodeFromString(?string $vatCodeCode) { $vatCode = new VatCode(); $vatCode->setCode($vatCodeCode); diff --git a/src/FixedAsset.php b/src/FixedAsset.php index 122b21c8..19cbc5b5 100644 --- a/src/FixedAsset.php +++ b/src/FixedAsset.php @@ -5,8 +5,8 @@ use PhpTwinfield\Fields\BehaviourField; use PhpTwinfield\Fields\CodeField; use PhpTwinfield\Fields\InUseField; -use PhpTwinfield\Fields\Level1234\DimensionGroupField; -use PhpTwinfield\Fields\Level1234\DimensionTypeField; +use PhpTwinfield\Fields\Level1234\DimensionGroup\GroupField; +use PhpTwinfield\Fields\Level1234\DimensionType\TypeField; use PhpTwinfield\Fields\NameField; use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\ShortNameField; @@ -23,22 +23,22 @@ class FixedAsset extends BaseObject { use BehaviourField; use CodeField; - use DimensionGroupField; - use DimensionTypeField; + use GroupField; use InUseField; use NameField; use OfficeField; use ShortNameField; use StatusField; use TouchedField; + use TypeField; use UIDField; private $financials; private $fixedAssets; - + public function __construct() { - $this->setTypeFromCode('AST'); + $this->setTypeFromString('AST'); $this->setFinancials(new FixedAssetFinancials); $this->setFixedAssets(new FixedAssetFixedAssets); } diff --git a/src/FixedAssetFixedAssets.php b/src/FixedAssetFixedAssets.php index 2f8351f7..5427e477 100644 --- a/src/FixedAssetFixedAssets.php +++ b/src/FixedAssetFixedAssets.php @@ -7,10 +7,6 @@ use PhpTwinfield\Fields\FreeText3Field; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\BeginPeriodField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\BeginPeriodLockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\FixedAssetsMethodField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\FixedAssetsMethodLockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\FixedAssetsStatusField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\FixedAssetsStatusLockedField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\FreeText1LockedField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\FreeText2LockedField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\FreeText3LockedField; @@ -20,6 +16,8 @@ use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\FreeText5LockedField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\LastDepreciationField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\LastDepreciationLockedField; +use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\MethodField; +use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\MethodLockedField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\NrOfPeriodsInheritedField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\NrOfPeriodsLockedField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\PercentageLockedField; @@ -29,6 +27,8 @@ use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\ResidualValueLockedField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\SellDateField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\SellDateLockedField; +use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\StatusField; +use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\StatusLockedField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\StopValueField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\StopValueLockedField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\TransactionLinesLockedField; @@ -43,10 +43,6 @@ class FixedAssetFixedAssets extends BaseObject { use BeginPeriodField; use BeginPeriodLockedField; - use FixedAssetsMethodField; - use FixedAssetsMethodLockedField; - use FixedAssetsStatusField; - use FixedAssetsStatusLockedField; use FreeText1Field; use FreeText1LockedField; use FreeText2Field; @@ -59,6 +55,8 @@ class FixedAssetFixedAssets extends BaseObject use FreeText5LockedField; use LastDepreciationField; use LastDepreciationLockedField; + use MethodField; + use MethodLockedField; use NrOfPeriodsField; use NrOfPeriodsInheritedField; use NrOfPeriodsLockedField; @@ -70,6 +68,8 @@ class FixedAssetFixedAssets extends BaseObject use ResidualValueLockedField; use SellDateField; use SellDateLockedField; + use StatusField; + use StatusLockedField; use StopValueField; use StopValueLockedField; use TransactionLinesLockedField; diff --git a/src/FixedAssetTransactionLine.php b/src/FixedAssetTransactionLine.php index 1a91c152..ead21e7c 100644 --- a/src/FixedAssetTransactionLine.php +++ b/src/FixedAssetTransactionLine.php @@ -5,6 +5,8 @@ use PhpTwinfield\Fields\Dim1Field; use PhpTwinfield\Fields\Level1234\AmountField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\AmountLockedField; +use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\CodeField; +use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\CodeLockedField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\Dim1LockedField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\Dim2Field; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\Dim2LockedField; @@ -16,8 +18,6 @@ use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\Dim5LockedField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\Dim6Field; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\Dim6LockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\FixedAssetCodeField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\FixedAssetCodeLockedField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\LineField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\LineLockedField; use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\NumberField; @@ -33,6 +33,8 @@ class FixedAssetTransactionLine extends BaseObject { use AmountField; use AmountLockedField; + use CodeField; + use CodeLockedField; use Dim1Field; use Dim1LockedField; use Dim2Field; @@ -45,8 +47,6 @@ class FixedAssetTransactionLine extends BaseObject use Dim5LockedField; use Dim6Field; use Dim6LockedField; - use FixedAssetCodeField; - use FixedAssetCodeLockedField; use LineField; use LineLockedField; use NumberField; diff --git a/src/GeneralLedger.php b/src/GeneralLedger.php index 2776d2bb..76973c4e 100644 --- a/src/GeneralLedger.php +++ b/src/GeneralLedger.php @@ -5,12 +5,12 @@ use PhpTwinfield\Fields\BehaviourField; use PhpTwinfield\Fields\CodeField; use PhpTwinfield\Fields\InUseField; +use PhpTwinfield\Fields\Level1234\BeginPeriodField; use PhpTwinfield\Fields\Level1234\BeginYearField; -use PhpTwinfield\Fields\Level1234\DimensionGroupField; -use PhpTwinfield\Fields\Level1234\DimensionTypeField; +use PhpTwinfield\Fields\Level1234\DimensionGroup\GroupField; +use PhpTwinfield\Fields\Level1234\DimensionType\TypeField; +use PhpTwinfield\Fields\Level1234\EndPeriodField; use PhpTwinfield\Fields\Level1234\EndYearField; -use PhpTwinfield\Fields\Level1234\GeneralLedgerBeginPeriodField; -use PhpTwinfield\Fields\Level1234\GeneralLedgerEndPeriodField; use PhpTwinfield\Fields\NameField; use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\ShortNameField; @@ -25,20 +25,20 @@ */ class GeneralLedger extends BaseObject { + use BeginPeriodField; use BeginYearField; use BehaviourField; use CodeField; - use DimensionGroupField; - use DimensionTypeField; + use EndPeriodField; use EndYearField; - use GeneralLedgerBeginPeriodField; - use GeneralLedgerEndPeriodField; + use GroupField; use InUseField; use NameField; use OfficeField; use ShortNameField; use StatusField; use TouchedField; + use TypeField; use UIDField; private $financials; diff --git a/src/GeneralLedgerChildValidation.php b/src/GeneralLedgerChildValidation.php index 876800af..8becf6a4 100644 --- a/src/GeneralLedgerChildValidation.php +++ b/src/GeneralLedgerChildValidation.php @@ -4,7 +4,7 @@ use PhpTwinfield\Fields\ElementValueField; use PhpTwinfield\Fields\Level1234\LevelField; -use PhpTwinfield\Fields\Level1234\GeneralLedgerTypeField; +use PhpTwinfield\Fields\Level1234\TypeField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/BalanceSheets @@ -14,5 +14,5 @@ class GeneralLedgerChildValidation extends BaseObject { use ElementValueField; use LevelField; - use GeneralLedgerTypeField; + use TypeField; } diff --git a/src/Invoice.php b/src/Invoice.php index e4851d0a..55b8968b 100644 --- a/src/Invoice.php +++ b/src/Invoice.php @@ -6,6 +6,7 @@ use PhpTwinfield\Fields\Invoice\BankField; use PhpTwinfield\Fields\Invoice\CalculateOnlyField; use PhpTwinfield\Fields\Invoice\CustomerNameField; +use PhpTwinfield\Fields\Invoice\DebitCreditField; use PhpTwinfield\Fields\Invoice\DeliverAddressNumberField; use PhpTwinfield\Fields\Invoice\DueDateField; use PhpTwinfield\Fields\Invoice\FinancialCodeField; @@ -15,13 +16,12 @@ use PhpTwinfield\Fields\Invoice\InvoiceAddressNumberField; use PhpTwinfield\Fields\Invoice\InvoiceAmountField; use PhpTwinfield\Fields\Invoice\InvoiceDateField; -use PhpTwinfield\Fields\Invoice\InvoiceDebitCreditField; use PhpTwinfield\Fields\Invoice\InvoiceNumberField; use PhpTwinfield\Fields\Invoice\InvoiceTypeField; -use PhpTwinfield\Fields\Invoice\InvoiceStatusField; use PhpTwinfield\Fields\Invoice\PaymentMethodField; use PhpTwinfield\Fields\Invoice\PerformanceDateField; use PhpTwinfield\Fields\Invoice\RaiseWarningField; +use PhpTwinfield\Fields\Invoice\StatusField; use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\PeriodField; @@ -52,6 +52,7 @@ class Invoice extends BaseObject use CurrencyField; use CustomerField; use CustomerNameField; + use DebitCreditField; use DeliverAddressNumberField; use DueDateField; use FinancialCodeField; @@ -61,15 +62,14 @@ class Invoice extends BaseObject use InvoiceAddressNumberField; use InvoiceAmountField; use InvoiceDateField; - use InvoiceDebitCreditField; use InvoiceNumberField; use InvoiceTypeField; - use InvoiceStatusField; use OfficeField; use PaymentMethodField; use PerformanceDateField; use PeriodField; use RaiseWarningField; + use StatusField; private $totals; private $lines = []; diff --git a/src/Mappers/ArticleMapper.php b/src/Mappers/ArticleMapper.php index 7370fbcc..3df96711 100644 --- a/src/Mappers/ArticleMapper.php +++ b/src/Mappers/ArticleMapper.php @@ -91,8 +91,8 @@ public static function map(Response $response) $articleLine->setStatusFromString($lineElement->getAttribute('status')); // Set the article line elements - $articleLine->setFreeText1(self::parseObjectAttribute('GeneralLedger', $articleLine, $lineElement, 'freetext1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) - ->setFreeText2(self::parseObjectAttribute('CostCenter', $articleLine, $lineElement, 'freetext2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + $articleLine->setFreeText1(self::parseObjectAttribute('GeneralLedger', $articleLine, $lineElement, 'freetext1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setFreeText2(self::parseObjectAttribute('CostCenter', $articleLine, $lineElement, 'freetext2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setFreeText3(self::getField($articleLine, $lineElement, 'freetext3')) ->setUnits(self::getField($articleLine, $lineElement, 'units')) ->setName(self::getField($articleLine, $lineElement, 'name')) diff --git a/src/Mappers/AssetMethodMapper.php b/src/Mappers/AssetMethodMapper.php index cc6df732..6a88c8c6 100644 --- a/src/Mappers/AssetMethodMapper.php +++ b/src/Mappers/AssetMethodMapper.php @@ -65,13 +65,13 @@ public static function map(Response $response) // Set the asset method balance account elements from the balance accounts element $assetMethodBalanceAccounts - ->setAssetsToActivate(self::parseObjectAttribute('GeneralLedger', $assetMethodBalanceAccounts, $balanceAccountsElement, 'assetstoactivate', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) - ->setDepreciation(self::parseObjectAttribute('GeneralLedger', $assetMethodBalanceAccounts, $balanceAccountsElement, 'depreciation', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setAssetsToActivate(self::parseObjectAttribute('GeneralLedger', $assetMethodBalanceAccounts, $balanceAccountsElement, 'assetstoactivate', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setDepreciation(self::parseObjectAttribute('GeneralLedger', $assetMethodBalanceAccounts, $balanceAccountsElement, 'depreciation', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setDepreciationGroup(self::parseObjectAttribute('DimensionGroup', $assetMethodBalanceAccounts, $balanceAccountsElement, 'depreciationgroup', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setPurchaseValue(self::parseObjectAttribute('GeneralLedger', $assetMethodBalanceAccounts, $balanceAccountsElement, 'purchasevalue', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setPurchaseValue(self::parseObjectAttribute('GeneralLedger', $assetMethodBalanceAccounts, $balanceAccountsElement, 'purchasevalue', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setPurchaseValueGroup(self::parseObjectAttribute('DimensionGroup', $assetMethodBalanceAccounts, $balanceAccountsElement, 'purchasevaluegroup', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setReconciliation(self::parseObjectAttribute('GeneralLedger', $assetMethodBalanceAccounts, $balanceAccountsElement, 'reconciliation', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) - ->setToBeInvoiced(self::parseObjectAttribute('GeneralLedger', $assetMethodBalanceAccounts, $balanceAccountsElement, 'tobeinvoiced', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))); + ->setReconciliation(self::parseObjectAttribute('GeneralLedger', $assetMethodBalanceAccounts, $balanceAccountsElement, 'reconciliation', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setToBeInvoiced(self::parseObjectAttribute('GeneralLedger', $assetMethodBalanceAccounts, $balanceAccountsElement, 'tobeinvoiced', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))); // Set the custom class to the assetmethod $assetmethod->setBalanceAccounts($assetMethodBalanceAccounts); @@ -86,9 +86,9 @@ public static function map(Response $response) // Set the asset method profit loss account elements from the profit loss accounts element $assetMethodProfitLossAccounts - ->setDepreciation(self::parseObjectAttribute('GeneralLedger', $assetMethodProfitLossAccounts, $profitLossAccountsElement, 'depreciation', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) - ->setReconciliation(self::parseObjectAttribute('GeneralLedger', $assetMethodProfitLossAccounts, $profitLossAccountsElement, 'reconciliation', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) - ->setSales(self::parseObjectAttribute('GeneralLedger', $assetMethodProfitLossAccounts, $profitLossAccountsElement, 'sales', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))); + ->setDepreciation(self::parseObjectAttribute('GeneralLedger', $assetMethodProfitLossAccounts, $profitLossAccountsElement, 'depreciation', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setReconciliation(self::parseObjectAttribute('GeneralLedger', $assetMethodProfitLossAccounts, $profitLossAccountsElement, 'reconciliation', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setSales(self::parseObjectAttribute('GeneralLedger', $assetMethodProfitLossAccounts, $profitLossAccountsElement, 'sales', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))); // Set the custom class to the assetmethod $assetmethod->setProfitLossAccounts($assetMethodProfitLossAccounts); diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index 0e3dd969..823ae2ba 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -218,4 +218,4 @@ protected static function parseObjectAttribute(string $className, $object, \DOME return $object2; } -} +} \ No newline at end of file diff --git a/src/Mappers/CustomerMapper.php b/src/Mappers/CustomerMapper.php index 86599edc..f2357016 100644 --- a/src/Mappers/CustomerMapper.php +++ b/src/Mappers/CustomerMapper.php @@ -85,7 +85,7 @@ public static function map(Response $response) ->setPayCode(self::parseObjectAttribute('PayCode', $customerFinancials, $financialsElement, 'paycode', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setSubAnalyse(self::parseEnumAttribute('SubAnalyse', self::getField($customerFinancials, $financialsElement, 'subanalyse'))) ->setSubstitutionLevel(self::getField($customerFinancials, $financialsElement, 'substitutionlevel')) - ->setSubstituteWith(self::parseObjectAttribute('UnknownDimension', $customerFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setSubstituteWith(self::parseObjectAttribute('UnknownDimension', $customerFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setVatCode(self::parseObjectAttribute('VatCode', $customerFinancials, $financialsElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); // Set the financials elements from the financials element attributes @@ -127,7 +127,7 @@ public static function map(Response $response) // Set the child validation elements from the child validation element en element attributes $customerChildValidation->setLevel($childValidationElement->getAttribute('level')) - ->setType(self::parseEnumAttribute('GeneralLedgerType', $childValidationElement->getAttribute('type'))) + ->setType(self::parseEnumAttribute('ChildValidationType', $childValidationElement->getAttribute('type'))) ->setElementValue($childValidationElement->textContent); // Add the child validation to the customer financials class @@ -295,9 +295,9 @@ public static function map(Response $response) // Set the line elements from the line element $customerLine->setDescription(self::getField($customerLine, $lineElement, 'description')) - ->setDimension1(self::parseObjectAttribute('GeneralLedger', $customerLine, $lineElement, 'dimension1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) - ->setDimension2(self::parseObjectAttribute('CostCenter', $customerLine, $lineElement, 'dimension2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) - ->setDimension3(self::parseObjectAttribute('UnknownDimension', $customerLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setDimension1(self::parseObjectAttribute('GeneralLedger', $customerLine, $lineElement, 'dimension1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setDimension2(self::parseObjectAttribute('CostCenter', $customerLine, $lineElement, 'dimension2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setDimension3(self::parseObjectAttribute('UnknownDimension', $customerLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setOffice(self::parseObjectAttribute('Office', $customerLine, $lineElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setRatio(self::getField($customerLine, $lineElement, 'ratio')) ->setVatCode(self::parseObjectAttribute('VatCode', $customerLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); diff --git a/src/Mappers/FixedAssetMapper.php b/src/Mappers/FixedAssetMapper.php index 35b57fd8..1431327b 100644 --- a/src/Mappers/FixedAssetMapper.php +++ b/src/Mappers/FixedAssetMapper.php @@ -64,7 +64,7 @@ public static function map(Response $response) ->setMatchType(self::parseEnumAttribute('MatchType', self::getField($fixedAssetFinancials, $financialsElement, 'matchtype'))) ->setSubAnalyse(self::parseEnumAttribute('SubAnalyse', self::getField($fixedAssetFinancials, $financialsElement, 'subanalyse'))) ->setSubstitutionLevel(self::getField($fixedAssetFinancials, $financialsElement, 'substitutionlevel')) - ->setSubstituteWith(self::parseObjectAttribute('CostCenter', $fixedAssetFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setSubstituteWith(self::parseObjectAttribute('CostCenter', $fixedAssetFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setVatCode(self::parseObjectAttribute('VatCode', $fixedAssetFinancials, $financialsElement, 'vatcode')); // Set the financials elements from the financials element attributes diff --git a/src/Mappers/GeneralLedgerMapper.php b/src/Mappers/GeneralLedgerMapper.php index 5631505a..db531390 100644 --- a/src/Mappers/GeneralLedgerMapper.php +++ b/src/Mappers/GeneralLedgerMapper.php @@ -88,7 +88,7 @@ public static function map(Response $response) // Set the child validation elements from the child validation element en element attributes $generalLedgerChildValidation->setLevel($childValidationElement->getAttribute('level')); - $generalLedgerChildValidation->setType(self::parseEnumAttribute('GeneralLedgerType', $childValidationElement->getAttribute('type'))); + $generalLedgerChildValidation->setType(self::parseEnumAttribute('ChildValidationType', $childValidationElement->getAttribute('type'))); $generalLedgerChildValidation->setElementValue($childValidationElement->textContent); // Add the child validation to the general ledger financials class diff --git a/src/Mappers/InvoiceMapper.php b/src/Mappers/InvoiceMapper.php index 07b9a0b1..6cb896e7 100644 --- a/src/Mappers/InvoiceMapper.php +++ b/src/Mappers/InvoiceMapper.php @@ -100,7 +100,7 @@ public static function map(Response $response) ->setPerformanceDate(self::parseDateAttribute(self::getField($invoiceLine, $lineElement, 'performancedate'))) ->setPerformanceType(self::parseEnumAttribute('PerformanceType', self::getField($invoiceLine, $lineElement, 'performancetype'))) ->setQuantity(self::getField($invoiceLine, $lineElement, 'quantity')) - ->setSubArticleFromSubCode(self::getField($invoiceLine, $lineElement, 'subarticle')) + ->setSubArticleFromString(self::getField($invoiceLine, $lineElement, 'subarticle')) ->setUnits(self::getField($invoiceLine, $lineElement, 'units')) ->setUnitsPriceExcl(self::parseMoneyAttribute(self::getField($invoiceLine, $lineElement, 'unitspriceexcl'))) ->setUnitsPriceInc(self::parseMoneyAttribute(self::getField($invoiceLine, $lineElement, 'unitspriceinc'))) diff --git a/src/Mappers/MatchSetMapper.php b/src/Mappers/MatchSetMapper.php index f2ec2a04..9caf2d47 100644 --- a/src/Mappers/MatchSetMapper.php +++ b/src/Mappers/MatchSetMapper.php @@ -77,4 +77,4 @@ private static function getMatchValueFrom(\DOMElement $lineElement): ?Money // TODO: Perhaps not hard code this to EUR, but the element doesn't seem to contain a currency return Util::parseMoney($matchValue, new Currency('EUR')); } -} +} \ No newline at end of file diff --git a/src/Mappers/SupplierMapper.php b/src/Mappers/SupplierMapper.php index 8d67eb46..ff09c2c9 100644 --- a/src/Mappers/SupplierMapper.php +++ b/src/Mappers/SupplierMapper.php @@ -77,7 +77,7 @@ public static function map(Response $response) ->setRelationsReference(self::getField($supplierFinancials, $financialsElement, 'relationsreference')) ->setSubAnalyse(self::parseEnumAttribute('SubAnalyse', self::getField($supplierFinancials, $financialsElement, 'subanalyse'))) ->setSubstitutionLevel(self::getField($supplierFinancials, $financialsElement, 'substitutionlevel')) - ->setSubstituteWith(self::parseObjectAttribute('UnknownDimension', $supplierFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setSubstituteWith(self::parseObjectAttribute('UnknownDimension', $supplierFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setVatCode(self::parseObjectAttribute('VatCode', $supplierFinancials, $financialsElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); // Set the financials elements from the financials element attributes @@ -100,7 +100,7 @@ public static function map(Response $response) // Set the child validation elements from the child validation element en element attributes $supplierChildValidation->setLevel($childValidationElement->getAttribute('level')) - ->setType(self::parseEnumAttribute('GeneralLedgerType', $childValidationElement->getAttribute('type'))) + ->setType(self::parseEnumAttribute('ChildValidationType', $childValidationElement->getAttribute('type'))) ->setElementValue($childValidationElement->textContent); // Add the child validation to the supplier financials class @@ -242,9 +242,9 @@ public static function map(Response $response) // Set the line elements from the line element $supplierLine->setDescription(self::getField($supplierLine, $lineElement, 'description')) - ->setDimension1(self::parseObjectAttribute('GeneralLedger', $supplierLine, $lineElement, 'dimension1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) - ->setDimension2(self::parseObjectAttribute('CostCenter', $supplierLine, $lineElement, 'dimension2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) - ->setDimension3(self::parseObjectAttribute('UnknownDimension', $supplierLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + ->setDimension1(self::parseObjectAttribute('GeneralLedger', $supplierLine, $lineElement, 'dimension1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setDimension2(self::parseObjectAttribute('CostCenter', $supplierLine, $lineElement, 'dimension2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setDimension3(self::parseObjectAttribute('UnknownDimension', $supplierLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setOffice(self::parseObjectAttribute('Office', $supplierLine, $lineElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setRatio(self::getField($supplierLine, $lineElement, 'ratio')) ->setVatCode(self::parseObjectAttribute('VatCode', $supplierLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); diff --git a/src/Mappers/VatCodeMapper.php b/src/Mappers/VatCodeMapper.php index d852a64d..a2f8ce49 100644 --- a/src/Mappers/VatCodeMapper.php +++ b/src/Mappers/VatCodeMapper.php @@ -89,7 +89,7 @@ public static function map(Response $response) $vatCodeAccount->setID($accountElement->getAttribute('id')); // Set the vat code percentage account elements from the account element - $vatCodeAccount->setDim1(self::parseObjectAttribute('GeneralLedger', $vatCodeAccount, $accountElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromCode'))) + $vatCodeAccount->setDim1(self::parseObjectAttribute('GeneralLedger', $vatCodeAccount, $accountElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setGroup(self::parseObjectAttribute('VatGroup', $vatCodeAccount, $accountElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setGroupCountry(self::parseObjectAttribute('Country', $vatCodeAccount, $accountElement, 'groupcountry', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setLineType(self::parseEnumAttribute('LineType', self::getField($vatCodeAccount, $accountElement, 'linetype'))) diff --git a/src/Project.php b/src/Project.php index 947189c7..a55b0495 100644 --- a/src/Project.php +++ b/src/Project.php @@ -5,7 +5,7 @@ use PhpTwinfield\Fields\BehaviourField; use PhpTwinfield\Fields\CodeField; use PhpTwinfield\Fields\InUseField; -use PhpTwinfield\Fields\Level1234\DimensionTypeField; +use PhpTwinfield\Fields\Level1234\DimensionType\TypeField; use PhpTwinfield\Fields\NameField; use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\ShortNameField; @@ -23,13 +23,13 @@ class Project extends BaseObject { use BehaviourField; use CodeField; - use DimensionTypeField; use InUseField; use NameField; use OfficeField; use ShortNameField; use StatusField; use TouchedField; + use TypeField; use UIDField; use VatCodeField; @@ -37,7 +37,7 @@ class Project extends BaseObject public function __construct() { - $this->setTypeFromCode('PRJ'); + $this->setTypeFromString('PRJ'); $this->setProjects(new ProjectProjects); } diff --git a/src/Supplier.php b/src/Supplier.php index 254901fb..51d8fdb8 100644 --- a/src/Supplier.php +++ b/src/Supplier.php @@ -5,12 +5,12 @@ use PhpTwinfield\Fields\BehaviourField; use PhpTwinfield\Fields\CodeField; use PhpTwinfield\Fields\InUseField; +use PhpTwinfield\Fields\Level1234\BeginPeriodField; use PhpTwinfield\Fields\Level1234\BeginYearField; -use PhpTwinfield\Fields\Level1234\DimensionGroupField; -use PhpTwinfield\Fields\Level1234\DimensionTypeField; +use PhpTwinfield\Fields\Level1234\DimensionGroup\GroupField; +use PhpTwinfield\Fields\Level1234\DimensionType\TypeField; +use PhpTwinfield\Fields\Level1234\EndPeriodField; use PhpTwinfield\Fields\Level1234\EndYearField; -use PhpTwinfield\Fields\Level1234\GeneralLedgerBeginPeriodField; -use PhpTwinfield\Fields\Level1234\GeneralLedgerEndPeriodField; use PhpTwinfield\Fields\Level1234\Level2\PaymentConditionDiscountDaysField; use PhpTwinfield\Fields\Level1234\Level2\PaymentConditionDiscountPercentageField; use PhpTwinfield\Fields\Level1234\Level2\RemittanceAdviceSendMailField; @@ -31,16 +31,15 @@ */ class Supplier extends BaseObject { + use BeginPeriodField; use BeginYearField; use BehaviourField; use BlockedAccountPaymentConditionsIncludeVatField; use BlockedAccountPaymentConditionsPercentageField; use CodeField; - use DimensionGroupField; - use DimensionTypeField; + use EndPeriodField; use EndYearField; - use GeneralLedgerBeginPeriodField; - use GeneralLedgerEndPeriodField; + use GroupField; use InUseField; use NameField; use OfficeField; @@ -51,6 +50,7 @@ class Supplier extends BaseObject use ShortNameField; use StatusField; use TouchedField; + use TypeField; use UIDField; use WebsiteField; @@ -65,7 +65,7 @@ public function __construct() $this->setBeginYear(0); $this->setEndPeriod(0); $this->setEndYear(0); - $this->setTypeFromCode('CRD'); + $this->setTypeFromString('CRD'); $this->setFinancials(new SupplierFinancials); } diff --git a/src/SupplierAddress.php b/src/SupplierAddress.php index 71e714da..6bc0b9e4 100644 --- a/src/SupplierAddress.php +++ b/src/SupplierAddress.php @@ -3,7 +3,6 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\IDField; -use PhpTwinfield\Fields\Level1234\Level2\AddressTypeField; use PhpTwinfield\Fields\Level1234\Level2\CityField; use PhpTwinfield\Fields\Level1234\Level2\CountryField; use PhpTwinfield\Fields\Level1234\Level2\DefaultField; @@ -17,6 +16,7 @@ use PhpTwinfield\Fields\Level1234\Level2\PostcodeField; use PhpTwinfield\Fields\Level1234\Level2\TelefaxField; use PhpTwinfield\Fields\Level1234\Level2\TelephoneField; +use PhpTwinfield\Fields\Level1234\Level2\TypeField; use PhpTwinfield\Fields\NameField; /** @@ -25,7 +25,6 @@ */ class SupplierAddress extends BaseObject { - use AddressTypeField; use CityField; use CountryField; use DefaultField; @@ -41,4 +40,5 @@ class SupplierAddress extends BaseObject use PostcodeField; use TelefaxField; use TelephoneField; + use TypeField; } diff --git a/src/SupplierChildValidation.php b/src/SupplierChildValidation.php index 63891886..65fd0b83 100644 --- a/src/SupplierChildValidation.php +++ b/src/SupplierChildValidation.php @@ -4,7 +4,7 @@ use PhpTwinfield\Fields\ElementValueField; use PhpTwinfield\Fields\Level1234\LevelField; -use PhpTwinfield\Fields\Level1234\GeneralLedgerTypeField; +use PhpTwinfield\Fields\Level1234\TypeField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers @@ -14,5 +14,5 @@ class SupplierChildValidation extends BaseObject { use ElementValueField; use LevelField; - use GeneralLedgerTypeField; + use TypeField; } diff --git a/src/SupplierPostingRule.php b/src/SupplierPostingRule.php index c582859e..d080956a 100644 --- a/src/SupplierPostingRule.php +++ b/src/SupplierPostingRule.php @@ -21,7 +21,7 @@ class SupplierPostingRule extends BaseObject use StatusField; private $lines = []; - + public function getLines() { return $this->lines; diff --git a/src/VatCode.php b/src/VatCode.php index 0e4815e3..6b9db814 100644 --- a/src/VatCode.php +++ b/src/VatCode.php @@ -12,7 +12,7 @@ use PhpTwinfield\Fields\TouchedField; use PhpTwinfield\Fields\UIDField; use PhpTwinfield\Fields\UserField; -use PhpTwinfield\Fields\VatCode\VatCodeTypeField; +use PhpTwinfield\Fields\VatCode\TypeField; /** * Class VatCode @@ -29,9 +29,9 @@ class VatCode extends BaseObject use ShortNameField; use StatusField; use TouchedField; + use TypeField; use UIDField; use UserField; - use VatCodeTypeField; private $percentages = []; diff --git a/src/VatCodeAccount.php b/src/VatCodeAccount.php index ddc4dcd5..aeebc52d 100644 --- a/src/VatCodeAccount.php +++ b/src/VatCodeAccount.php @@ -5,9 +5,9 @@ use PhpTwinfield\Fields\IDField; use PhpTwinfield\Fields\Dim1Field; use PhpTwinfield\Fields\PercentageField; +use PhpTwinfield\Fields\VatCode\GroupCountryField; +use PhpTwinfield\Fields\VatCode\GroupField; use PhpTwinfield\Fields\VatCode\LineTypeField; -use PhpTwinfield\Fields\VatCode\VatGroupCountryField; -use PhpTwinfield\Fields\VatCode\VatGroupField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/VAT @@ -17,8 +17,8 @@ class VatCodeAccount extends BaseObject { use IDField; use Dim1Field; + use GroupCountryField; + use GroupField; use LineTypeField; use PercentageField; - use VatGroupCountryField; - use VatGroupField; } diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index f3822006..a602befd 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -52,8 +52,8 @@ public function testGetCustomerWorks() $customer = $this->customerApiConnector->get('CODE', $this->office); $this->assertInstanceOf(Customer::class, $customer); - $this->assertSame('001', $customer->getOfficeToCode()); - $this->assertSame('DEB', $customer->getTypeToCode()); + $this->assertSame('001', $customer->getOfficeToString()); + $this->assertSame('DEB', $customer->getTypeToString()); $this->assertSame('Customer 0', $customer->getName()); $this->assertSame('http://www.example.com', $customer->getWebsite()); @@ -61,9 +61,9 @@ public function testGetCustomerWorks() $financials = $customer->getFinancials(); $this->assertSame(30, $financials->getDueDays()); $this->assertSame(true, $financials->getPayAvailable()); - $this->assertSame('SEPANLDD', $financials->getPayCodeToCode()); + $this->assertSame('SEPANLDD', $financials->getPayCodeToString()); $this->assertSame(false, $financials->getEBilling()); - $this->assertSame('VN', $financials->getVatCodeToCode()); + $this->assertSame('VN', $financials->getVatCodeToString()); // Collect Mandate $collectMandate = $financials->getCollectMandate(); @@ -84,15 +84,15 @@ public function testGetCustomerWorks() $this->assertSame($ReflectObject->getConstant('INVOICE'), (string)$address->getType()); $this->assertSame(true, $address->getDefault()); $this->assertSame('Customer 0', $address->getName()); - $this->assertSame('NL', $address->getCountryToCode()); + $this->assertSame('NL', $address->getCountryToString()); $this->assertSame('Place', $address->getCity()); $this->assertSame('1000', $address->getPostcode()); $this->assertSame('010-123452000', $address->getTelephone()); $this->assertSame('010-12342000', $address->getTelefax()); $this->assertSame('info@example.com', $address->getEmail()); $this->assertSame('Customer 1', $address->getField1()); - $this->assertSame('Streetname part 1 - 1', $address->getField2()); - $this->assertSame('Streetname part 1 - 2', $address->getField3()); + $this->assertSame('Streetname part 1 - 1', $address->getAddressField2()); + $this->assertSame('Streetname part 1 - 2', $address->getAddressField3()); $this->assertSame('NL099887766B01', $address->getField4()); $this->assertSame('99887766', $address->getField5()); $this->assertNull($address->getField6()); @@ -112,7 +112,7 @@ public function testGetCustomerWorks() $this->assertSame('ABN Amro', $bank->getBankName()); $this->assertSame('ABNANL2A', $bank->getBicCode()); $this->assertSame('Place', $bank->getCity()); - $this->assertSame('NL', $bank->getCountryToCode()); + $this->assertSame('NL', $bank->getCountryToString()); $this->assertSame('NL02ABNA0123456789', $bank->getIban()); $this->assertNull($bank->getNatBicCode()); $this->assertNull($bank->getPostcode()); @@ -134,7 +134,7 @@ public function testGetCustomerWorks() // Creditmanagement $creditmanagement = $customer->getCreditManagement(); - $this->assertNull($creditmanagement->getResponsibleUserToCode()); + $this->assertNull($creditmanagement->getResponsibleUserToString()); $this->assertSame(0.00, $creditmanagement->getBaseCreditLimitToFloat()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\SendReminder'); $this->assertSame($ReflectObject->getConstant('TRUE'), (string)$creditmanagement->getSendReminder()); @@ -178,7 +178,7 @@ public function testSendCustomerWorks() $financials = new CustomerFinancials(); $financials->setDueDays(30); $financials->setPayAvailable(true); - $financials->setPayCodeFromCode('SEPANLDD'); + $financials->setPayCodeFromString('SEPANLDD'); $collectMandate = new CustomerCollectMandate(); $collectMandate->setID(1); @@ -193,7 +193,7 @@ public function testSendCustomerWorks() $address->setTypeFromString('invoice'); $address->setDefault(true); $address->setName('Customer 0'); - $address->setCountryFromCode('NL'); + $address->setCountryFromString('NL'); $address->setCity('Place'); $address->setPostcode('1000'); $address->setTelephone('010-123452000'); @@ -213,7 +213,7 @@ public function testSendCustomerWorks() $bank->setBankName('ABN Amro'); $bank->setBicCode('ABNANL2A'); $bank->setCity('Place'); - $bank->setCountryFromCode('NL'); + $bank->setCountryFromString('NL'); $bank->setIban('NL02ABNA0123456789'); $bank->setNatBicCode(''); $bank->setPostcode(''); diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 91f8933c..747d44b0 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -65,15 +65,15 @@ public function testGetConceptInvoiceWorks() $this->assertInstanceOf(Invoice::class, $invoice); $this->assertEquals(Office::fromCode("11024"), $invoice->getOffice()); - $this->assertSame('FACTUUR', $invoice->getInvoiceTypeToCode()); + $this->assertSame('FACTUUR', $invoice->getInvoiceTypeToString()); $this->assertSame(5, $invoice->getInvoiceNumber()); $this->assertSame('20120831', $invoice->getInvoiceDateToString()); - $this->assertSame('BNK', $invoice->getBankToCode()); + $this->assertSame('BNK', $invoice->getBankToString()); $this->assertSame(1, $invoice->getInvoiceAddressNumber()); $this->assertSame(1, $invoice->getDeliverAddressNumber()); - $this->assertSame('1000', $invoice->getCustomerToCode()); + $this->assertSame('1000', $invoice->getCustomerToString()); $this->assertSame('2012/08', $invoice->getPeriod()); - $this->assertSame('EUR', $invoice->getCurrencyToCode()); + $this->assertSame('EUR', $invoice->getCurrencyToString()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\InvoiceStatus'); $this->assertSame($ReflectObject->getConstant('CONCEPT'), (string)$invoice->getStatus()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PaymentMethod'); @@ -89,7 +89,7 @@ public function testGetConceptInvoiceWorks() $invoiceLine = $invoiceLines['1']; $this->assertSame(1, $invoiceLine->getID()); - $this->assertSame('0', $invoiceLine->getArticleToCode()); + $this->assertSame('0', $invoiceLine->getArticleToString()); $this->assertSame('118', $invoiceLine->getSubArticleToSubCode()); $this->assertSame(1, $invoiceLine->getQuantity()); $this->assertSame(1, $invoiceLine->getUnits()); @@ -99,7 +99,7 @@ public function testGetConceptInvoiceWorks() $this->assertSame(0.00, $invoiceLine->getVatValueToFloat()); $this->assertSame(15.00, $invoiceLine->getValueIncToFloat()); $this->assertSame(15.00, $invoiceLine->getUnitsPriceExclToFloat()); - $this->assertSame('8020', $invoiceLine->getDim1ToCode()); + $this->assertSame('8020', $invoiceLine->getDim1ToString()); $invoiceVatLines = $invoice->getVatLines(); $this->assertCount(1, $invoiceVatLines); @@ -107,7 +107,7 @@ public function testGetConceptInvoiceWorks() /** @var InvoiceVatLine $invoiceVatLine */ $invoiceVatLine = current($invoiceVatLines); - $this->assertSame('VN', $invoiceLine->getVatCodeToCode()); + $this->assertSame('VN', $invoiceLine->getVatCodeToString()); $this->assertSame(0.00, $invoiceLine->getVatValueToFloat()); $this->assertNull($invoiceLine->getPerformanceType()); $this->assertNull($invoiceLine->getPerformanceDateToString()); @@ -133,15 +133,15 @@ public function testGetFinalInvoiceWorks() $this->assertInstanceOf(Invoice::class, $invoice); $this->assertEquals(Office::fromCode("11024"), $invoice->getOffice()); - $this->assertSame('FACTUUR', $invoice->getInvoiceTypeToCode()); + $this->assertSame('FACTUUR', $invoice->getInvoiceTypeToString()); $this->assertSame(5, $invoice->getInvoiceNumber()); $this->assertSame('20120831', $invoice->getInvoiceDateToString()); - $this->assertSame('BNK', $invoice->getBankToCode()); + $this->assertSame('BNK', $invoice->getBankToString()); $this->assertSame(1, $invoice->getInvoiceAddressNumber()); $this->assertSame(1, $invoice->getDeliverAddressNumber()); - $this->assertSame('1000', $invoice->getCustomerToCode()); + $this->assertSame('1000', $invoice->getCustomerToString()); $this->assertSame('2012/08', $invoice->getPeriod()); - $this->assertSame('EUR', $invoice->getCurrencyToCode()); + $this->assertSame('EUR', $invoice->getCurrencyToString()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\InvoiceStatus'); $this->assertSame($ReflectObject->getConstant('FINAL'), (string)$invoice->getStatus()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PaymentMethod'); @@ -157,7 +157,7 @@ public function testGetFinalInvoiceWorks() $invoiceLine = $invoiceLines['1']; $this->assertSame(1, $invoiceLine->getID()); - $this->assertSame('0', $invoiceLine->getArticleToCode()); + $this->assertSame('0', $invoiceLine->getArticleToString()); $this->assertSame('118', $invoiceLine->getSubArticleToSubCode()); $this->assertSame(1, $invoiceLine->getQuantity()); $this->assertSame(1, $invoiceLine->getUnits()); @@ -167,7 +167,7 @@ public function testGetFinalInvoiceWorks() $this->assertSame(0.00, $invoiceLine->getVatValueToFloat()); $this->assertSame(15.00, $invoiceLine->getValueIncToFloat()); $this->assertSame(15.00, $invoiceLine->getUnitsPriceExclToFloat()); - $this->assertSame('8020', $invoiceLine->getDim1ToCode()); + $this->assertSame('8020', $invoiceLine->getDim1ToString()); $invoiceVatLines = $invoice->getVatLines(); $this->assertCount(1, $invoiceVatLines); @@ -175,7 +175,7 @@ public function testGetFinalInvoiceWorks() /** @var InvoiceVatLine $invoiceVatLine */ $invoiceVatLine = current($invoiceVatLines); - $this->assertSame('VN', $invoiceLine->getVatCodeToCode()); + $this->assertSame('VN', $invoiceLine->getVatCodeToString()); $this->assertSame(0.00, $invoiceLine->getVatValueToFloat()); $this->assertNull($invoiceLine->getPerformanceType()); $this->assertNull($invoiceLine->getPerformanceDateToString()); @@ -194,15 +194,15 @@ public function testSendInvoiceWorks() $invoice = new Invoice(); $invoice->setOffice(Office::fromCode('11024')); - $invoice->setInvoiceTypeFromCode('FACTUUR'); + $invoice->setInvoiceTypeFromString('FACTUUR'); $invoice->setInvoiceNumber(5); $invoice->setInvoiceDateFromString('20120831'); - $invoice->setBankFromCode('BNK'); + $invoice->setBankFromString('BNK'); $invoice->setInvoiceAddressNumber(1); $invoice->setDeliverAddressNumber(1); $invoice->setCustomer($customer); $invoice->setPeriod('2012/08'); - $invoice->setCurrencyFromCode('EUR'); + $invoice->setCurrencyFromString('EUR'); $invoice->setStatusFromString('concept'); $invoice->setPaymentMethodFromString('cash'); $invoice->setHeaderText('HEADER'); @@ -210,7 +210,7 @@ public function testSendInvoiceWorks() $invoiceLine = new InvoiceLine(); $invoiceLine->setID(1); - $invoiceLine->setArticleFromCode('4'); + $invoiceLine->setArticleFromString('4'); $invoiceLine->setSubArticleFromSubCode('118'); $invoiceLine->setQuantity(1); $invoiceLine->setUnits(1); @@ -220,8 +220,8 @@ public function testSendInvoiceWorks() $invoiceLine->setVatValueFromFloat(0.00); $invoiceLine->setValueIncFromFloat(15.00); $invoiceLine->setUnitsPriceExclFromFloat(15.00); - $invoiceLine->setDim1FromCode('8020'); - $invoiceLine->setVatCodeFromCode('VN'); + $invoiceLine->setDim1FromString('8020'); + $invoiceLine->setVatCodeFromString('VN'); $invoice->addLine($invoiceLine); $this->processXmlService diff --git a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php index 2d41031d..d5923a2a 100644 --- a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php @@ -37,15 +37,15 @@ public function testXmlIsCreatedPerSpec() $financials = new CustomerFinancials(); $financials->setDueDays(1); $financials->setPayAvailable(true); - $financials->setPayCodeFromCode('pay-code'); - $financials->setVatCodeFromCode('vat-code'); + $financials->setPayCodeFromString('pay-code'); + $financials->setVatCodeFromString('vat-code'); $financials->setEBilling(true); $financials->setEBillMail('ebillingmail@mail.com'); $customer->setFinancials($financials); $customer->setCreditManagement( (new CustomerCreditManagement()) - ->setResponsibleUserFromCode('responsible-user') + ->setResponsibleUserFromString('responsible-user') ->setBaseCreditLimitFromFloat(50) ->setSendReminderFromString('true') ->setReminderEmail('reminderemail@mail.com') @@ -59,7 +59,7 @@ public function testXmlIsCreatedPerSpec() ->setDefault(true) ->setTypeFromString('invoice') ->setName('My Address') - ->setCountryFromCode('nl') + ->setCountryFromString('nl') ->setCity('city') ->setPostcode('postal code') ->setTelephone('phone number') @@ -75,18 +75,18 @@ public function testXmlIsCreatedPerSpec() $customer->addBank( (new CustomerBank()) ->setDefault(true) + ->setAddressField2('address 2') + ->setAddressField3('address 3') ->setAscription('ascriptor') ->setAccountNumber('account number') ->setBankName('bank name') ->setBicCode('bic code') ->setCity('city') - ->setCountryFromCode('nl') + ->setCountryFromString('nl') ->setIban('iban') ->setNatBicCode('nat-bic') ->setPostcode('postcode') ->setState('state') - ->setField2('address 2') - ->setField3('address 3') ); $this->document->addCustomer($customer); From 5c2d6ad61a53cf3e3060d4bf9c079e633b11389b Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 11 May 2019 22:10:47 +0200 Subject: [PATCH 201/388] Upload --- src/DomDocuments/CustomersDocument.php | 4 ++-- src/DomDocuments/SuppliersDocument.php | 4 ++-- src/Mappers/CustomerMapper.php | 8 ++++---- src/Mappers/SupplierMapper.php | 8 ++++---- tests/IntegrationTests/CustomerIntegrationTest.php | 12 ++++++------ tests/IntegrationTests/InvoiceIntegrationTest.php | 6 +++--- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/DomDocuments/CustomersDocument.php b/src/DomDocuments/CustomersDocument.php index e5bd411f..2820abc4 100644 --- a/src/DomDocuments/CustomersDocument.php +++ b/src/DomDocuments/CustomersDocument.php @@ -187,8 +187,8 @@ public function addCustomer(Customer $customer) } $bankAddressElement = $this->createElement('address'); - $bankAddressElement->appendChild($this->createNodeWithTextContent('field2', $bank->getField2())); - $bankAddressElement->appendChild($this->createNodeWithTextContent('field3', $bank->getField3())); + $bankAddressElement->appendChild($this->createNodeWithTextContent('field2', $bank->getAddressField2())); + $bankAddressElement->appendChild($this->createNodeWithTextContent('field3', $bank->getAddressField3())); $bankElement->appendChild($bankAddressElement); $bankElement->appendChild($this->createNodeWithTextContent('ascription', $bank->getAscription())); diff --git a/src/DomDocuments/SuppliersDocument.php b/src/DomDocuments/SuppliersDocument.php index 55d15cdc..04804b5c 100644 --- a/src/DomDocuments/SuppliersDocument.php +++ b/src/DomDocuments/SuppliersDocument.php @@ -159,8 +159,8 @@ public function addSupplier(Supplier $supplier) } $bankAddressElement = $this->createElement('address'); - $bankAddressElement->appendChild($this->createNodeWithTextContent('field2', $bank->getField2())); - $bankAddressElement->appendChild($this->createNodeWithTextContent('field3', $bank->getField3())); + $bankAddressElement->appendChild($this->createNodeWithTextContent('field2', $bank->getAddressField2())); + $bankAddressElement->appendChild($this->createNodeWithTextContent('field3', $bank->getAddressField3())); $bankElement->appendChild($bankAddressElement); $bankElement->appendChild($this->createNodeWithTextContent('ascription', $bank->getAscription())); diff --git a/src/Mappers/CustomerMapper.php b/src/Mappers/CustomerMapper.php index f2357016..24456def 100644 --- a/src/Mappers/CustomerMapper.php +++ b/src/Mappers/CustomerMapper.php @@ -237,14 +237,14 @@ public static function map(Response $response) ->setID($bankElement->getAttribute('id')); // Set the bank elements from the bank element - $customerBank->setAscription(self::getField($customerBank, $bankElement, 'ascription')) - ->setAccountNumber(self::getField($customerBank, $bankElement, 'accountnumber')) + $customerBank->setAccountNumber(self::getField($customerBank, $bankElement, 'accountnumber')) + ->setAddressField2(self::getField($customerBank, $bankElement, 'field2')) + ->setAddressField3(self::getField($customerBank, $bankElement, 'field3')) + ->setAscription(self::getField($customerBank, $bankElement, 'ascription')) ->setBankName(self::getField($customerBank, $bankElement, 'bankname')) ->setBicCode(self::getField($customerBank, $bankElement, 'biccode')) ->setCity(self::getField($customerBank, $bankElement, 'city')) ->setCountry(self::parseObjectAttribute('Country', $customerBank, $bankElement, 'country', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setField2(self::getField($customerBank, $bankElement, 'field2')) - ->setField3(self::getField($customerBank, $bankElement, 'field3')) ->setIban(self::getField($customerBank, $bankElement, 'iban')) ->setNatBicCode(self::getField($customerBank, $bankElement, 'natbiccode')) ->setPostcode(self::getField($customerBank, $bankElement, 'postcode')) diff --git a/src/Mappers/SupplierMapper.php b/src/Mappers/SupplierMapper.php index ff09c2c9..5d0e4b41 100644 --- a/src/Mappers/SupplierMapper.php +++ b/src/Mappers/SupplierMapper.php @@ -184,14 +184,14 @@ public static function map(Response $response) ->setID($bankElement->getAttribute('id')); // Set the bank elements from the bank element - $supplierBank->setAscription(self::getField($supplierBank, $bankElement, 'ascription')) - ->setAccountNumber(self::getField($supplierBank, $bankElement, 'accountnumber')) + $supplierBank->setAccountNumber(self::getField($supplierBank, $bankElement, 'accountnumber')) + ->setAddressField2(self::getField($supplierBank, $bankElement, 'field2')) + ->setAddressField3(self::getField($supplierBank, $bankElement, 'field3')) + ->setAscription(self::getField($supplierBank, $bankElement, 'ascription')) ->setBankName(self::getField($supplierBank, $bankElement, 'bankname')) ->setBicCode(self::getField($supplierBank, $bankElement, 'biccode')) ->setCity(self::getField($supplierBank, $bankElement, 'city')) ->setCountry(self::parseObjectAttribute('Country', $supplierBank, $bankElement, 'country', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setField2(self::getField($supplierBank, $bankElement, 'field2')) - ->setField3(self::getField($supplierBank, $bankElement, 'field3')) ->setIban(self::getField($supplierBank, $bankElement, 'iban')) ->setNatBicCode(self::getField($supplierBank, $bankElement, 'natbiccode')) ->setPostcode(self::getField($supplierBank, $bankElement, 'postcode')) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index a602befd..4c4f5b46 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -91,8 +91,8 @@ public function testGetCustomerWorks() $this->assertSame('010-12342000', $address->getTelefax()); $this->assertSame('info@example.com', $address->getEmail()); $this->assertSame('Customer 1', $address->getField1()); - $this->assertSame('Streetname part 1 - 1', $address->getAddressField2()); - $this->assertSame('Streetname part 1 - 2', $address->getAddressField3()); + $this->assertSame('Streetname part 1 - 1', $address->getField2()); + $this->assertSame('Streetname part 1 - 2', $address->getField3()); $this->assertSame('NL099887766B01', $address->getField4()); $this->assertSame('99887766', $address->getField5()); $this->assertNull($address->getField6()); @@ -117,8 +117,8 @@ public function testGetCustomerWorks() $this->assertNull($bank->getNatBicCode()); $this->assertNull($bank->getPostcode()); $this->assertNull($bank->getState()); - $this->assertNull($bank->getField2()); - $this->assertNull($bank->getField3()); + $this->assertNull($bank->getAddressField2()); + $this->assertNull($bank->getAddressField3()); $this->assertSame('1097', $customer->getCode()); $this->assertSame('c5027760-476e-4081-85fb-351c983aea54', $customer->getUID()); @@ -208,8 +208,8 @@ public function testSendCustomerWorks() $bank->setDefault(true); $bank->setAscription('Customer 1'); $bank->setAccountNumber('123456789'); - $bank->setField2(''); - $bank->setField3(''); + $bank->setAddressField2(''); + $bank->setAddressField3(''); $bank->setBankName('ABN Amro'); $bank->setBicCode('ABNANL2A'); $bank->setCity('Place'); diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 747d44b0..cb100051 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -90,7 +90,7 @@ public function testGetConceptInvoiceWorks() $this->assertSame(1, $invoiceLine->getID()); $this->assertSame('0', $invoiceLine->getArticleToString()); - $this->assertSame('118', $invoiceLine->getSubArticleToSubCode()); + $this->assertSame('118', $invoiceLine->getSubArticleToString()); $this->assertSame(1, $invoiceLine->getQuantity()); $this->assertSame(1, $invoiceLine->getUnits()); $this->assertSame(true, $invoiceLine->getAllowDiscountOrPremium()); @@ -158,7 +158,7 @@ public function testGetFinalInvoiceWorks() $this->assertSame(1, $invoiceLine->getID()); $this->assertSame('0', $invoiceLine->getArticleToString()); - $this->assertSame('118', $invoiceLine->getSubArticleToSubCode()); + $this->assertSame('118', $invoiceLine->getSubArticleToString()); $this->assertSame(1, $invoiceLine->getQuantity()); $this->assertSame(1, $invoiceLine->getUnits()); $this->assertSame(true, $invoiceLine->getAllowDiscountOrPremium()); @@ -211,7 +211,7 @@ public function testSendInvoiceWorks() $invoiceLine = new InvoiceLine(); $invoiceLine->setID(1); $invoiceLine->setArticleFromString('4'); - $invoiceLine->setSubArticleFromSubCode('118'); + $invoiceLine->setSubArticleFromString('118'); $invoiceLine->setQuantity(1); $invoiceLine->setUnits(1); $invoiceLine->setAllowDiscountOrPremiumFromString('true'); From d3213bddc3720ae8728a2edba8f1cc055a1c664c Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 12 May 2019 10:11:48 +0200 Subject: [PATCH 202/388] Upload --- src/Activity.php | 2 +- src/ActivityProjects.php | 28 ++-- src/ActivityQuantity.php | 8 +- src/CostCenter.php | 2 +- src/Customer.php | 26 ++-- src/CustomerAddress.php | 28 ++-- src/CustomerBank.php | 28 ++-- src/CustomerChildValidation.php | 4 +- src/CustomerCollectMandate.php | 6 +- src/CustomerCreditManagement.php | 18 +-- src/CustomerFinancials.php | 32 ++--- src/CustomerLine.php | 14 +- src/CustomerPostingRule.php | 2 +- src/DimensionGroupDimension.php | 4 +- src/DimensionType.php | 2 +- src/DimensionTypeAddress.php | 12 +- src/DimensionTypeLevels.php | 4 +- .../AccountTypeField.php | 80 +++++------ .../{Level1234 => Dimensions}/AmountField.php | 122 ++++++++-------- .../BeginPeriodField.php | 2 +- .../BeginYearField.php | 62 ++++----- .../DimensionGroup/CodeField.php | 2 +- .../DimensionGroup/GroupField.php | 2 +- .../DimensionType/FinancialsField.php | 2 +- .../DimensionType/Label1Field.php | 62 ++++----- .../DimensionType/Label2Field.php | 62 ++++----- .../DimensionType/Label3Field.php | 62 ++++----- .../DimensionType/Label4Field.php | 62 ++++----- .../DimensionType/Label5Field.php | 62 ++++----- .../DimensionType/Label6Field.php | 62 ++++----- .../DimensionType/MaskField.php | 62 ++++----- .../DimensionType/TimeField.php | 2 +- .../DimensionType/TypeField.php | 2 +- .../EndPeriodField.php | 2 +- .../EndYearField.php | 62 ++++----- .../Level2/AccountNumberField.php | 62 ++++----- .../Level2/AddressField2Field.php | 62 ++++----- .../Level2/AddressField3Field.php | 62 ++++----- .../Level2/AscriptionField.php | 62 ++++----- .../Level2/BankBlockedField.php | 92 ++++++------- .../Level2/BankNameField.php | 62 ++++----- .../Level2/BicCodeField.php | 62 ++++----- .../Level2/CityField.php | 62 ++++----- .../Level2/CountryField.php | 108 +++++++-------- .../Level2/Customer/BaseCreditLimitField.php | 122 ++++++++-------- .../Level2/Customer/BlockedField.php | 92 ++++++------- .../Level2/Customer/BlockedLockedField.php | 92 ++++++------- .../Level2/Customer/BlockedModifiedField.php | 130 +++++++++--------- .../Level2/Customer/CollectionSchemaField.php | 80 +++++------ .../Level2/Customer/CommentField.php | 62 ++++----- .../Level2/Customer/DiscountArticleField.php | 108 +++++++-------- .../Customer/DiscountArticleIDField.php | 62 ++++----- .../Level2/Customer/EBillMailField.php | 62 ++++----- .../Level2/Customer/EBillingField.php | 92 ++++++------- .../Level2/Customer/FirstRunDateField.php | 130 +++++++++--------- .../Level2/Customer/FreeText1Field.php | 2 +- .../Level2/Customer/IDField.php | 2 +- .../Level2/Customer/ReminderEmailField.php | 62 ++++----- .../Level2/Customer/ResponsibleUserField.php | 110 +++++++-------- .../Level2/Customer/SendReminderField.php | 80 +++++------ .../Level2/Customer/SignatureDateField.php | 130 +++++++++--------- .../Level2/DefaultField.php | 92 ++++++------- .../Level2/Dimension1Field.php | 106 +++++++------- .../Level2/Dimension1IDField.php | 62 ++++----- .../Level2/Dimension2Field.php | 106 +++++++------- .../Level2/Dimension2IDField.php | 62 ++++----- .../Level2/Dimension3Field.php | 106 +++++++------- .../Level2/Dimension3IDField.php | 62 ++++----- .../Level2/DueDaysField.php | 62 ++++----- .../Level2/EmailField.php | 62 ++++----- .../Level2/Field1Field.php | 62 ++++----- .../Level2/Field2Field.php | 62 ++++----- .../Level2/Field3Field.php | 62 ++++----- .../Level2/Field4Field.php | 62 ++++----- .../Level2/Field5Field.php | 62 ++++----- .../Level2/Field6Field.php | 62 ++++----- .../Level2/IbanField.php | 62 ++++----- .../Level2/MeansOfPaymentField.php | 80 +++++------ .../Level2/NatBicCodeField.php | 62 ++++----- .../Level2/PayAvailableField.php | 92 ++++++------- .../Level2/PayCodeField.php | 108 +++++++-------- .../Level2/PayCodeIDField.php | 62 ++++----- .../PaymentConditionDiscountDaysField.php | 62 ++++----- ...aymentConditionDiscountPercentageField.php | 62 ++++----- .../Level2/PostcodeField.php | 62 ++++----- .../Level2/RatioField.php | 62 ++++----- .../Level2/RemittanceAdviceSendMailField.php | 62 ++++----- .../Level2/RemittanceAdviceSendTypeField.php | 80 +++++------ .../Level2/StateField.php | 62 ++++----- ...ccountPaymentConditionsIncludeVatField.php | 80 +++++------ ...ccountPaymentConditionsPercentageField.php | 62 ++++----- .../Supplier/RelationsReferenceField.php | 62 ++++----- .../Level2/TelefaxField.php | 62 ++++----- .../Level2/TelephoneField.php | 62 ++++----- .../Level2/TypeField.php | 2 +- .../Level2/WebsiteField.php | 62 ++++----- .../Level34/AuthoriserField.php | 108 +++++++-------- .../Level34/AuthoriserInheritField.php | 92 ++++++------- .../Level34/AuthoriserLockedField.php | 92 ++++++------- .../Level34/BillableField.php | 92 ++++++------- .../Level34/BillableForRatioField.php | 92 ++++++------- .../Level34/BillableInheritField.php | 92 ++++++------- .../Level34/BillableLockedField.php | 92 ++++++------- .../Level34/CustomerInheritField.php | 92 ++++++------- .../Level34/CustomerLockedField.php | 92 ++++++------- .../Level34/FixedAsset/AmountLockedField.php | 92 ++++++------- .../Level34/FixedAsset/BeginPeriodField.php | 74 +++++----- .../FixedAsset/BeginPeriodLockedField.php | 92 ++++++------- .../Level34/FixedAsset/CodeField.php | 2 +- .../Level34/FixedAsset/CodeLockedField.php | 2 +- .../Level34/FixedAsset/Dim1LockedField.php | 92 ++++++------- .../Level34/FixedAsset/Dim2Field.php | 108 +++++++-------- .../Level34/FixedAsset/Dim2LockedField.php | 92 ++++++------- .../Level34/FixedAsset/Dim3Field.php | 108 +++++++-------- .../Level34/FixedAsset/Dim3LockedField.php | 92 ++++++------- .../Level34/FixedAsset/Dim4Field.php | 108 +++++++-------- .../Level34/FixedAsset/Dim4LockedField.php | 92 ++++++------- .../Level34/FixedAsset/Dim5Field.php | 108 +++++++-------- .../Level34/FixedAsset/Dim5LockedField.php | 92 ++++++------- .../Level34/FixedAsset/Dim6Field.php | 108 +++++++-------- .../Level34/FixedAsset/Dim6LockedField.php | 92 ++++++------- .../FixedAsset/FreeText1LockedField.php | 92 ++++++------- .../FixedAsset/FreeText2LockedField.php | 92 ++++++------- .../FixedAsset/FreeText3LockedField.php | 92 ++++++------- .../Level34/FixedAsset/FreeText4Field.php | 62 ++++----- .../FixedAsset/FreeText4LockedField.php | 92 ++++++------- .../Level34/FixedAsset/FreeText5Field.php | 62 ++++----- .../FixedAsset/FreeText5LockedField.php | 92 ++++++------- .../FixedAsset/LastDepreciationField.php | 74 +++++----- .../LastDepreciationLockedField.php | 92 ++++++------- .../Level34/FixedAsset/LineField.php | 62 ++++----- .../Level34/FixedAsset/LineLockedField.php | 92 ++++++------- .../Level34/FixedAsset/MethodField.php | 2 +- .../Level34/FixedAsset/MethodLockedField.php | 2 +- .../FixedAsset/NrOfPeriodsInheritedField.php | 92 ++++++------- .../FixedAsset/NrOfPeriodsLockedField.php | 92 ++++++------- .../Level34/FixedAsset/NumberField.php | 62 ++++----- .../Level34/FixedAsset/NumberLockedField.php | 92 ++++++------- .../FixedAsset/PercentageLockedField.php | 92 ++++++------- .../Level34/FixedAsset/PeriodLockedField.php | 92 ++++++------- .../Level34/FixedAsset/PurchaseDateField.php | 130 +++++++++--------- .../FixedAsset/PurchaseDateLockedField.php | 92 ++++++------- .../Level34/FixedAsset/ResidualValueField.php | 122 ++++++++-------- .../FixedAsset/ResidualValueLockedField.php | 92 ++++++------- .../Level34/FixedAsset/SellDateField.php | 130 +++++++++--------- .../FixedAsset/SellDateLockedField.php | 92 ++++++------- .../Level34/FixedAsset/StatusField.php | 2 +- .../Level34/FixedAsset/StatusLockedField.php | 2 +- .../Level34/FixedAsset/StopValueField.php | 122 ++++++++-------- .../FixedAsset/StopValueLockedField.php | 92 ++++++------- .../TransactionLinesLockedField.php | 92 ++++++------- .../Level34/InvoiceDescriptionField.php | 62 ++++----- .../Level34/LabelField.php | 62 ++++----- .../Level34/MandatoryField.php | 92 ++++++------- .../Level34/RateInheritField.php | 92 ++++++------- .../Level34/RateLockedField.php | 92 ++++++------- .../Level34/ValidFromField.php | 130 +++++++++--------- .../Level34/ValidTillField.php | 130 +++++++++--------- .../{Level1234 => Dimensions}/LevelField.php | 62 ++++----- .../MatchTypeField.php | 80 +++++------ .../SubAnalyseField.php | 80 +++++------ .../SubstituteWithField.php | 108 +++++++-------- .../SubstituteWithIDField.php | 62 ++++----- .../SubstitutionLevelField.php | 62 ++++----- .../{Level1234 => Dimensions}/TypeField.php | 2 +- .../VatCodeFixedField.php | 92 ++++++------- .../Rate/{RateTypeField.php => TypeField.php} | 80 +++++------ .../{UserLevelField.php => LevelField.php} | 62 ++++----- src/FixedAsset.php | 4 +- src/FixedAssetFinancials.php | 16 +-- src/FixedAssetFixedAssets.php | 54 ++++---- src/FixedAssetTransactionLine.php | 40 +++--- src/GeneralLedger.php | 12 +- src/GeneralLedgerChildValidation.php | 4 +- src/GeneralLedgerFinancials.php | 10 +- src/Project.php | 2 +- src/ProjectProjects.php | 28 ++-- src/ProjectQuantity.php | 8 +- src/Rate.php | 4 +- src/Supplier.php | 26 ++-- src/SupplierAddress.php | 28 ++-- src/SupplierBank.php | 28 ++-- src/SupplierChildValidation.php | 4 +- src/SupplierFinancials.php | 28 ++-- src/SupplierLine.php | 14 +- src/SupplierPostingRule.php | 2 +- src/User.php | 6 +- 187 files changed, 5856 insertions(+), 5856 deletions(-) rename src/Fields/{Level1234 => Dimensions}/AccountTypeField.php (91%) rename src/Fields/{Level1234 => Dimensions}/AmountField.php (91%) rename src/Fields/{Level1234 => Dimensions}/BeginPeriodField.php (92%) rename src/Fields/{Level1234 => Dimensions}/BeginYearField.php (87%) rename src/Fields/{Level1234 => Dimensions}/DimensionGroup/CodeField.php (93%) rename src/Fields/{Level1234 => Dimensions}/DimensionGroup/GroupField.php (94%) rename src/Fields/{Level1234 => Dimensions}/DimensionType/FinancialsField.php (89%) rename src/Fields/{Level1234 => Dimensions}/DimensionType/Label1Field.php (84%) rename src/Fields/{Level1234 => Dimensions}/DimensionType/Label2Field.php (84%) rename src/Fields/{Level1234 => Dimensions}/DimensionType/Label3Field.php (84%) rename src/Fields/{Level1234 => Dimensions}/DimensionType/Label4Field.php (84%) rename src/Fields/{Level1234 => Dimensions}/DimensionType/Label5Field.php (84%) rename src/Fields/{Level1234 => Dimensions}/DimensionType/Label6Field.php (84%) rename src/Fields/{Level1234 => Dimensions}/DimensionType/MaskField.php (83%) rename src/Fields/{Level1234 => Dimensions}/DimensionType/TimeField.php (88%) rename src/Fields/{Level1234 => Dimensions}/DimensionType/TypeField.php (94%) rename src/Fields/{Level1234 => Dimensions}/EndPeriodField.php (92%) rename src/Fields/{Level1234 => Dimensions}/EndYearField.php (87%) rename src/Fields/{Level1234 => Dimensions}/Level2/AccountNumberField.php (87%) rename src/Fields/{Level1234 => Dimensions}/Level2/AddressField2Field.php (87%) rename src/Fields/{Level1234 => Dimensions}/Level2/AddressField3Field.php (87%) rename src/Fields/{Level1234 => Dimensions}/Level2/AscriptionField.php (86%) rename src/Fields/{Level1234 => Dimensions}/Level2/BankBlockedField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level2/BankNameField.php (86%) rename src/Fields/{Level1234 => Dimensions}/Level2/BicCodeField.php (86%) rename src/Fields/{Level1234 => Dimensions}/Level2/CityField.php (86%) rename src/Fields/{Level1234 => Dimensions}/Level2/CountryField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level2/Customer/BaseCreditLimitField.php (91%) rename src/Fields/{Level1234 => Dimensions}/Level2/Customer/BlockedField.php (89%) rename src/Fields/{Level1234 => Dimensions}/Level2/Customer/BlockedLockedField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level2/Customer/BlockedModifiedField.php (92%) rename src/Fields/{Level1234 => Dimensions}/Level2/Customer/CollectionSchemaField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level2/Customer/CommentField.php (84%) rename src/Fields/{Level1234 => Dimensions}/Level2/Customer/DiscountArticleField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level2/Customer/DiscountArticleIDField.php (86%) rename src/Fields/{Level1234 => Dimensions}/Level2/Customer/EBillMailField.php (85%) rename src/Fields/{Level1234 => Dimensions}/Level2/Customer/EBillingField.php (89%) rename src/Fields/{Level1234 => Dimensions}/Level2/Customer/FirstRunDateField.php (92%) rename src/Fields/{Level1234 => Dimensions}/Level2/Customer/FreeText1Field.php (93%) rename src/Fields/{Level1234 => Dimensions}/Level2/Customer/IDField.php (88%) rename src/Fields/{Level1234 => Dimensions}/Level2/Customer/ReminderEmailField.php (86%) rename src/Fields/{Level1234 => Dimensions}/Level2/Customer/ResponsibleUserField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level2/Customer/SendReminderField.php (89%) rename src/Fields/{Level1234 => Dimensions}/Level2/Customer/SignatureDateField.php (92%) rename src/Fields/{Level1234 => Dimensions}/Level2/DefaultField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level2/Dimension1Field.php (91%) rename src/Fields/{Level1234 => Dimensions}/Level2/Dimension1IDField.php (87%) rename src/Fields/{Level1234 => Dimensions}/Level2/Dimension2Field.php (91%) rename src/Fields/{Level1234 => Dimensions}/Level2/Dimension2IDField.php (87%) rename src/Fields/{Level1234 => Dimensions}/Level2/Dimension3Field.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level2/Dimension3IDField.php (87%) rename src/Fields/{Level1234 => Dimensions}/Level2/DueDaysField.php (86%) rename src/Fields/{Level1234 => Dimensions}/Level2/EmailField.php (85%) rename src/Fields/{Level1234 => Dimensions}/Level2/Field1Field.php (86%) rename src/Fields/{Level1234 => Dimensions}/Level2/Field2Field.php (86%) rename src/Fields/{Level1234 => Dimensions}/Level2/Field3Field.php (86%) rename src/Fields/{Level1234 => Dimensions}/Level2/Field4Field.php (86%) rename src/Fields/{Level1234 => Dimensions}/Level2/Field5Field.php (86%) rename src/Fields/{Level1234 => Dimensions}/Level2/Field6Field.php (86%) rename src/Fields/{Level1234 => Dimensions}/Level2/IbanField.php (85%) rename src/Fields/{Level1234 => Dimensions}/Level2/MeansOfPaymentField.php (91%) rename src/Fields/{Level1234 => Dimensions}/Level2/NatBicCodeField.php (86%) rename src/Fields/{Level1234 => Dimensions}/Level2/PayAvailableField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level2/PayCodeField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level2/PayCodeIDField.php (86%) rename src/Fields/{Level1234 => Dimensions}/Level2/PaymentConditionDiscountDaysField.php (89%) rename src/Fields/{Level1234 => Dimensions}/Level2/PaymentConditionDiscountPercentageField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level2/PostcodeField.php (87%) rename src/Fields/{Level1234 => Dimensions}/Level2/RatioField.php (85%) rename src/Fields/{Level1234 => Dimensions}/Level2/RemittanceAdviceSendMailField.php (89%) rename src/Fields/{Level1234 => Dimensions}/Level2/RemittanceAdviceSendTypeField.php (92%) rename src/Fields/{Level1234 => Dimensions}/Level2/StateField.php (85%) rename src/Fields/{Level1234 => Dimensions}/Level2/Supplier/BlockedAccountPaymentConditionsIncludeVatField.php (93%) rename src/Fields/{Level1234 => Dimensions}/Level2/Supplier/BlockedAccountPaymentConditionsPercentageField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level2/Supplier/RelationsReferenceField.php (87%) rename src/Fields/{Level1234 => Dimensions}/Level2/TelefaxField.php (86%) rename src/Fields/{Level1234 => Dimensions}/Level2/TelephoneField.php (86%) rename src/Fields/{Level1234 => Dimensions}/Level2/TypeField.php (93%) rename src/Fields/{Level1234 => Dimensions}/Level2/WebsiteField.php (85%) rename src/Fields/{Level1234 => Dimensions}/Level34/AuthoriserField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level34/AuthoriserInheritField.php (91%) rename src/Fields/{Level1234 => Dimensions}/Level34/AuthoriserLockedField.php (91%) rename src/Fields/{Level1234 => Dimensions}/Level34/BillableField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level34/BillableForRatioField.php (91%) rename src/Fields/{Level1234 => Dimensions}/Level34/BillableInheritField.php (91%) rename src/Fields/{Level1234 => Dimensions}/Level34/BillableLockedField.php (91%) rename src/Fields/{Level1234 => Dimensions}/Level34/CustomerInheritField.php (91%) rename src/Fields/{Level1234 => Dimensions}/Level34/CustomerLockedField.php (91%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/AmountLockedField.php (89%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/BeginPeriodField.php (87%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/BeginPeriodLockedField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/CodeField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/CodeLockedField.php (93%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/Dim1LockedField.php (89%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/Dim2Field.php (88%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/Dim2LockedField.php (89%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/Dim3Field.php (88%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/Dim3LockedField.php (89%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/Dim4Field.php (88%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/Dim4LockedField.php (89%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/Dim5Field.php (88%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/Dim5LockedField.php (89%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/Dim6Field.php (88%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/Dim6LockedField.php (89%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/FreeText1LockedField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/FreeText2LockedField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/FreeText3LockedField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/FreeText4Field.php (84%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/FreeText4LockedField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/FreeText5Field.php (84%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/FreeText5LockedField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/LastDepreciationField.php (88%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/LastDepreciationLockedField.php (91%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/LineField.php (82%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/LineLockedField.php (89%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/MethodField.php (94%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/MethodLockedField.php (93%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/NrOfPeriodsInheritedField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/NrOfPeriodsLockedField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/NumberField.php (83%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/NumberLockedField.php (89%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/PercentageLockedField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/PeriodLockedField.php (89%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/PurchaseDateField.php (91%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/PurchaseDateLockedField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/ResidualValueField.php (91%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/ResidualValueLockedField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/SellDateField.php (91%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/SellDateLockedField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/StatusField.php (92%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/StatusLockedField.php (93%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/StopValueField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/StopValueLockedField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level34/FixedAsset/TransactionLinesLockedField.php (91%) rename src/Fields/{Level1234 => Dimensions}/Level34/InvoiceDescriptionField.php (88%) rename src/Fields/{Level1234 => Dimensions}/Level34/LabelField.php (85%) rename src/Fields/{Level1234 => Dimensions}/Level34/MandatoryField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level34/RateInheritField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level34/RateLockedField.php (90%) rename src/Fields/{Level1234 => Dimensions}/Level34/ValidFromField.php (92%) rename src/Fields/{Level1234 => Dimensions}/Level34/ValidTillField.php (92%) rename src/Fields/{Level1234 => Dimensions}/LevelField.php (89%) rename src/Fields/{Level1234 => Dimensions}/MatchTypeField.php (91%) rename src/Fields/{Level1234 => Dimensions}/SubAnalyseField.php (91%) rename src/Fields/{Level1234 => Dimensions}/SubstituteWithField.php (92%) rename src/Fields/{Level1234 => Dimensions}/SubstituteWithIDField.php (89%) rename src/Fields/{Level1234 => Dimensions}/SubstitutionLevelField.php (89%) rename src/Fields/{Level1234 => Dimensions}/TypeField.php (95%) rename src/Fields/{Level1234 => Dimensions}/VatCodeFixedField.php (91%) rename src/Fields/Rate/{RateTypeField.php => TypeField.php} (89%) rename src/Fields/User/{UserLevelField.php => LevelField.php} (85%) diff --git a/src/Activity.php b/src/Activity.php index a6cc3f7f..a4744cad 100644 --- a/src/Activity.php +++ b/src/Activity.php @@ -4,8 +4,8 @@ use PhpTwinfield\Fields\BehaviourField; use PhpTwinfield\Fields\CodeField; +use PhpTwinfield\Fields\Dimensions\DimensionType\TypeField; use PhpTwinfield\Fields\InUseField; -use PhpTwinfield\Fields\Level1234\DimensionType\TypeField; use PhpTwinfield\Fields\NameField; use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\ShortNameField; diff --git a/src/ActivityProjects.php b/src/ActivityProjects.php index 92720054..f9eb8c1d 100644 --- a/src/ActivityProjects.php +++ b/src/ActivityProjects.php @@ -3,20 +3,20 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\CustomerField; -use PhpTwinfield\Fields\Level1234\Level34\AuthoriserField; -use PhpTwinfield\Fields\Level1234\Level34\AuthoriserInheritField; -use PhpTwinfield\Fields\Level1234\Level34\AuthoriserLockedField; -use PhpTwinfield\Fields\Level1234\Level34\BillableField; -use PhpTwinfield\Fields\Level1234\Level34\BillableForRatioField; -use PhpTwinfield\Fields\Level1234\Level34\BillableInheritField; -use PhpTwinfield\Fields\Level1234\Level34\BillableLockedField; -use PhpTwinfield\Fields\Level1234\Level34\CustomerInheritField; -use PhpTwinfield\Fields\Level1234\Level34\CustomerLockedField; -use PhpTwinfield\Fields\Level1234\Level34\InvoiceDescriptionField; -use PhpTwinfield\Fields\Level1234\Level34\RateInheritField; -use PhpTwinfield\Fields\Level1234\Level34\RateLockedField; -use PhpTwinfield\Fields\Level1234\Level34\ValidFromField; -use PhpTwinfield\Fields\Level1234\Level34\ValidTillField; +use PhpTwinfield\Fields\Dimensions\Level34\AuthoriserField; +use PhpTwinfield\Fields\Dimensions\Level34\AuthoriserInheritField; +use PhpTwinfield\Fields\Dimensions\Level34\AuthoriserLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\BillableField; +use PhpTwinfield\Fields\Dimensions\Level34\BillableForRatioField; +use PhpTwinfield\Fields\Dimensions\Level34\BillableInheritField; +use PhpTwinfield\Fields\Dimensions\Level34\BillableLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\CustomerInheritField; +use PhpTwinfield\Fields\Dimensions\Level34\CustomerLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\InvoiceDescriptionField; +use PhpTwinfield\Fields\Dimensions\Level34\RateInheritField; +use PhpTwinfield\Fields\Dimensions\Level34\RateLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\ValidFromField; +use PhpTwinfield\Fields\Dimensions\Level34\ValidTillField; use PhpTwinfield\Fields\RateField; /** diff --git a/src/ActivityQuantity.php b/src/ActivityQuantity.php index eb84b5c1..be3c7887 100644 --- a/src/ActivityQuantity.php +++ b/src/ActivityQuantity.php @@ -2,10 +2,10 @@ namespace PhpTwinfield; -use PhpTwinfield\Fields\Level1234\Level34\BillableField; -use PhpTwinfield\Fields\Level1234\Level34\BillableLockedField; -use PhpTwinfield\Fields\Level1234\Level34\LabelField; -use PhpTwinfield\Fields\Level1234\Level34\MandatoryField; +use PhpTwinfield\Fields\Dimensions\Level34\BillableField; +use PhpTwinfield\Fields\Dimensions\Level34\BillableLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\LabelField; +use PhpTwinfield\Fields\Dimensions\Level34\MandatoryField; use PhpTwinfield\Fields\RateField; /** diff --git a/src/CostCenter.php b/src/CostCenter.php index 0a1fa227..f4b0e545 100644 --- a/src/CostCenter.php +++ b/src/CostCenter.php @@ -4,8 +4,8 @@ use PhpTwinfield\Fields\BehaviourField; use PhpTwinfield\Fields\CodeField; +use PhpTwinfield\Fields\Dimensions\DimensionType\TypeField; use PhpTwinfield\Fields\InUseField; -use PhpTwinfield\Fields\Level1234\DimensionType\TypeField; use PhpTwinfield\Fields\NameField; use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\ShortNameField; diff --git a/src/Customer.php b/src/Customer.php index 8d891e14..a65f5834 100644 --- a/src/Customer.php +++ b/src/Customer.php @@ -4,20 +4,20 @@ use PhpTwinfield\Fields\BehaviourField; use PhpTwinfield\Fields\CodeField; +use PhpTwinfield\Fields\Dimensions\BeginPeriodField; +use PhpTwinfield\Fields\Dimensions\BeginYearField; +use PhpTwinfield\Fields\Dimensions\DimensionGroup\GroupField; +use PhpTwinfield\Fields\Dimensions\DimensionType\TypeField; +use PhpTwinfield\Fields\Dimensions\EndPeriodField; +use PhpTwinfield\Fields\Dimensions\EndYearField; +use PhpTwinfield\Fields\Dimensions\Level2\Customer\DiscountArticleField; +use PhpTwinfield\Fields\Dimensions\Level2\Customer\DiscountArticleIDField; +use PhpTwinfield\Fields\Dimensions\Level2\PaymentConditionDiscountDaysField; +use PhpTwinfield\Fields\Dimensions\Level2\PaymentConditionDiscountPercentageField; +use PhpTwinfield\Fields\Dimensions\Level2\RemittanceAdviceSendMailField; +use PhpTwinfield\Fields\Dimensions\Level2\RemittanceAdviceSendTypeField; +use PhpTwinfield\Fields\Dimensions\Level2\WebsiteField; use PhpTwinfield\Fields\InUseField; -use PhpTwinfield\Fields\Level1234\BeginPeriodField; -use PhpTwinfield\Fields\Level1234\BeginYearField; -use PhpTwinfield\Fields\Level1234\DimensionGroup\GroupField; -use PhpTwinfield\Fields\Level1234\DimensionType\TypeField; -use PhpTwinfield\Fields\Level1234\EndPeriodField; -use PhpTwinfield\Fields\Level1234\EndYearField; -use PhpTwinfield\Fields\Level1234\Level2\Customer\DiscountArticleField; -use PhpTwinfield\Fields\Level1234\Level2\Customer\DiscountArticleIDField; -use PhpTwinfield\Fields\Level1234\Level2\PaymentConditionDiscountDaysField; -use PhpTwinfield\Fields\Level1234\Level2\PaymentConditionDiscountPercentageField; -use PhpTwinfield\Fields\Level1234\Level2\RemittanceAdviceSendMailField; -use PhpTwinfield\Fields\Level1234\Level2\RemittanceAdviceSendTypeField; -use PhpTwinfield\Fields\Level1234\Level2\WebsiteField; use PhpTwinfield\Fields\NameField; use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\ShortNameField; diff --git a/src/CustomerAddress.php b/src/CustomerAddress.php index 9e3c7b93..d5c5ba6c 100644 --- a/src/CustomerAddress.php +++ b/src/CustomerAddress.php @@ -2,21 +2,21 @@ namespace PhpTwinfield; +use PhpTwinfield\Fields\Dimensions\Level2\CityField; +use PhpTwinfield\Fields\Dimensions\Level2\CountryField; +use PhpTwinfield\Fields\Dimensions\Level2\DefaultField; +use PhpTwinfield\Fields\Dimensions\Level2\EmailField; +use PhpTwinfield\Fields\Dimensions\Level2\Field1Field; +use PhpTwinfield\Fields\Dimensions\Level2\Field2Field; +use PhpTwinfield\Fields\Dimensions\Level2\Field3Field; +use PhpTwinfield\Fields\Dimensions\Level2\Field4Field; +use PhpTwinfield\Fields\Dimensions\Level2\Field5Field; +use PhpTwinfield\Fields\Dimensions\Level2\Field6Field; +use PhpTwinfield\Fields\Dimensions\Level2\PostcodeField; +use PhpTwinfield\Fields\Dimensions\Level2\TelefaxField; +use PhpTwinfield\Fields\Dimensions\Level2\TelephoneField; +use PhpTwinfield\Fields\Dimensions\Level2\TypeField; use PhpTwinfield\Fields\IDField; -use PhpTwinfield\Fields\Level1234\Level2\CityField; -use PhpTwinfield\Fields\Level1234\Level2\CountryField; -use PhpTwinfield\Fields\Level1234\Level2\DefaultField; -use PhpTwinfield\Fields\Level1234\Level2\EmailField; -use PhpTwinfield\Fields\Level1234\Level2\Field1Field; -use PhpTwinfield\Fields\Level1234\Level2\Field2Field; -use PhpTwinfield\Fields\Level1234\Level2\Field3Field; -use PhpTwinfield\Fields\Level1234\Level2\Field4Field; -use PhpTwinfield\Fields\Level1234\Level2\Field5Field; -use PhpTwinfield\Fields\Level1234\Level2\Field6Field; -use PhpTwinfield\Fields\Level1234\Level2\PostcodeField; -use PhpTwinfield\Fields\Level1234\Level2\TelefaxField; -use PhpTwinfield\Fields\Level1234\Level2\TelephoneField; -use PhpTwinfield\Fields\Level1234\Level2\TypeField; use PhpTwinfield\Fields\NameField; /** diff --git a/src/CustomerBank.php b/src/CustomerBank.php index e555eca0..02258406 100644 --- a/src/CustomerBank.php +++ b/src/CustomerBank.php @@ -2,21 +2,21 @@ namespace PhpTwinfield; +use PhpTwinfield\Fields\Dimensions\Level2\AccountNumberField; +use PhpTwinfield\Fields\Dimensions\Level2\AddressField2Field; +use PhpTwinfield\Fields\Dimensions\Level2\AddressField3Field; +use PhpTwinfield\Fields\Dimensions\Level2\AscriptionField; +use PhpTwinfield\Fields\Dimensions\Level2\BankBlockedField; +use PhpTwinfield\Fields\Dimensions\Level2\BankNameField; +use PhpTwinfield\Fields\Dimensions\Level2\BicCodeField; +use PhpTwinfield\Fields\Dimensions\Level2\CityField; +use PhpTwinfield\Fields\Dimensions\Level2\CountryField; +use PhpTwinfield\Fields\Dimensions\Level2\DefaultField; +use PhpTwinfield\Fields\Dimensions\Level2\IbanField; +use PhpTwinfield\Fields\Dimensions\Level2\NatBicCodeField; +use PhpTwinfield\Fields\Dimensions\Level2\PostcodeField; +use PhpTwinfield\Fields\Dimensions\Level2\StateField; use PhpTwinfield\Fields\IDField; -use PhpTwinfield\Fields\Level1234\Level2\AccountNumberField; -use PhpTwinfield\Fields\Level1234\Level2\AddressField2Field; -use PhpTwinfield\Fields\Level1234\Level2\AddressField3Field; -use PhpTwinfield\Fields\Level1234\Level2\AscriptionField; -use PhpTwinfield\Fields\Level1234\Level2\BankBlockedField; -use PhpTwinfield\Fields\Level1234\Level2\BankNameField; -use PhpTwinfield\Fields\Level1234\Level2\BicCodeField; -use PhpTwinfield\Fields\Level1234\Level2\CityField; -use PhpTwinfield\Fields\Level1234\Level2\CountryField; -use PhpTwinfield\Fields\Level1234\Level2\DefaultField; -use PhpTwinfield\Fields\Level1234\Level2\IbanField; -use PhpTwinfield\Fields\Level1234\Level2\NatBicCodeField; -use PhpTwinfield\Fields\Level1234\Level2\PostcodeField; -use PhpTwinfield\Fields\Level1234\Level2\StateField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers diff --git a/src/CustomerChildValidation.php b/src/CustomerChildValidation.php index 36789b57..b590192b 100644 --- a/src/CustomerChildValidation.php +++ b/src/CustomerChildValidation.php @@ -2,9 +2,9 @@ namespace PhpTwinfield; +use PhpTwinfield\Fields\Dimensions\LevelField; +use PhpTwinfield\Fields\Dimensions\TypeField; use PhpTwinfield\Fields\ElementValueField; -use PhpTwinfield\Fields\Level1234\LevelField; -use PhpTwinfield\Fields\Level1234\TypeField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers diff --git a/src/CustomerCollectMandate.php b/src/CustomerCollectMandate.php index 7860d69e..42b2bd5b 100644 --- a/src/CustomerCollectMandate.php +++ b/src/CustomerCollectMandate.php @@ -2,9 +2,9 @@ namespace PhpTwinfield; -use PhpTwinfield\Fields\Level1234\Level2\Customer\FirstRunDateField; -use PhpTwinfield\Fields\Level1234\Level2\Customer\IDField; -use PhpTwinfield\Fields\Level1234\Level2\Customer\SignatureDateField; +use PhpTwinfield\Fields\Dimensions\Level2\Customer\FirstRunDateField; +use PhpTwinfield\Fields\Dimensions\Level2\Customer\IDField; +use PhpTwinfield\Fields\Dimensions\Level2\Customer\SignatureDateField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers diff --git a/src/CustomerCreditManagement.php b/src/CustomerCreditManagement.php index ddb1addd..a5f4d367 100644 --- a/src/CustomerCreditManagement.php +++ b/src/CustomerCreditManagement.php @@ -2,17 +2,17 @@ namespace PhpTwinfield; +use PhpTwinfield\Fields\Dimensions\Level2\Customer\BaseCreditLimitField; +use PhpTwinfield\Fields\Dimensions\Level2\Customer\BlockedField; +use PhpTwinfield\Fields\Dimensions\Level2\Customer\BlockedLockedField; +use PhpTwinfield\Fields\Dimensions\Level2\Customer\BlockedModifiedField; +use PhpTwinfield\Fields\Dimensions\Level2\Customer\CommentField; +use PhpTwinfield\Fields\Dimensions\Level2\Customer\FreeText1Field; +use PhpTwinfield\Fields\Dimensions\Level2\Customer\ReminderEmailField; +use PhpTwinfield\Fields\Dimensions\Level2\Customer\ResponsibleUserField; +use PhpTwinfield\Fields\Dimensions\Level2\Customer\SendReminderField; use PhpTwinfield\Fields\FreeText2Field; use PhpTwinfield\Fields\FreeText3Field; -use PhpTwinfield\Fields\Level1234\Level2\Customer\BaseCreditLimitField; -use PhpTwinfield\Fields\Level1234\Level2\Customer\BlockedField; -use PhpTwinfield\Fields\Level1234\Level2\Customer\BlockedLockedField; -use PhpTwinfield\Fields\Level1234\Level2\Customer\BlockedModifiedField; -use PhpTwinfield\Fields\Level1234\Level2\Customer\CommentField; -use PhpTwinfield\Fields\Level1234\Level2\Customer\FreeText1Field; -use PhpTwinfield\Fields\Level1234\Level2\Customer\ReminderEmailField; -use PhpTwinfield\Fields\Level1234\Level2\Customer\ResponsibleUserField; -use PhpTwinfield\Fields\Level1234\Level2\Customer\SendReminderField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers diff --git a/src/CustomerFinancials.php b/src/CustomerFinancials.php index c0f1ad52..154adb05 100644 --- a/src/CustomerFinancials.php +++ b/src/CustomerFinancials.php @@ -2,22 +2,22 @@ namespace PhpTwinfield; -use PhpTwinfield\Fields\Level1234\AccountTypeField; -use PhpTwinfield\Fields\Level1234\Level2\Customer\CollectionSchemaField; -use PhpTwinfield\Fields\Level1234\Level2\Customer\EBillingField; -use PhpTwinfield\Fields\Level1234\Level2\Customer\EBillMailField; -use PhpTwinfield\Fields\Level1234\Level2\DueDaysField; -use PhpTwinfield\Fields\Level1234\Level2\MeansOfPaymentField; -use PhpTwinfield\Fields\Level1234\Level2\PayAvailableField; -use PhpTwinfield\Fields\Level1234\Level2\PayCodeField; -use PhpTwinfield\Fields\Level1234\Level2\PayCodeIDField; -use PhpTwinfield\Fields\Level1234\LevelField; -use PhpTwinfield\Fields\Level1234\MatchTypeField; -use PhpTwinfield\Fields\Level1234\SubAnalyseField; -use PhpTwinfield\Fields\Level1234\SubstitutionLevelField; -use PhpTwinfield\Fields\Level1234\SubstituteWithField; -use PhpTwinfield\Fields\Level1234\SubstituteWithIDField; -use PhpTwinfield\Fields\Level1234\VatCodeFixedField; +use PhpTwinfield\Fields\Dimensions\AccountTypeField; +use PhpTwinfield\Fields\Dimensions\Level2\Customer\CollectionSchemaField; +use PhpTwinfield\Fields\Dimensions\Level2\Customer\EBillingField; +use PhpTwinfield\Fields\Dimensions\Level2\Customer\EBillMailField; +use PhpTwinfield\Fields\Dimensions\Level2\DueDaysField; +use PhpTwinfield\Fields\Dimensions\Level2\MeansOfPaymentField; +use PhpTwinfield\Fields\Dimensions\Level2\PayAvailableField; +use PhpTwinfield\Fields\Dimensions\Level2\PayCodeField; +use PhpTwinfield\Fields\Dimensions\Level2\PayCodeIDField; +use PhpTwinfield\Fields\Dimensions\LevelField; +use PhpTwinfield\Fields\Dimensions\MatchTypeField; +use PhpTwinfield\Fields\Dimensions\SubAnalyseField; +use PhpTwinfield\Fields\Dimensions\SubstitutionLevelField; +use PhpTwinfield\Fields\Dimensions\SubstituteWithField; +use PhpTwinfield\Fields\Dimensions\SubstituteWithIDField; +use PhpTwinfield\Fields\Dimensions\VatCodeFixedField; use PhpTwinfield\Fields\VatCodeField; /** diff --git a/src/CustomerLine.php b/src/CustomerLine.php index 8e97a127..ce802d19 100644 --- a/src/CustomerLine.php +++ b/src/CustomerLine.php @@ -3,13 +3,13 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\DescriptionField; -use PhpTwinfield\Fields\Level1234\Level2\Dimension1Field; -use PhpTwinfield\Fields\Level1234\Level2\Dimension1IDField; -use PhpTwinfield\Fields\Level1234\Level2\Dimension2Field; -use PhpTwinfield\Fields\Level1234\Level2\Dimension2IDField; -use PhpTwinfield\Fields\Level1234\Level2\Dimension3Field; -use PhpTwinfield\Fields\Level1234\Level2\Dimension3IDField; -use PhpTwinfield\Fields\Level1234\Level2\RatioField; +use PhpTwinfield\Fields\Dimensions\Level2\Dimension1Field; +use PhpTwinfield\Fields\Dimensions\Level2\Dimension1IDField; +use PhpTwinfield\Fields\Dimensions\Level2\Dimension2Field; +use PhpTwinfield\Fields\Dimensions\Level2\Dimension2IDField; +use PhpTwinfield\Fields\Dimensions\Level2\Dimension3Field; +use PhpTwinfield\Fields\Dimensions\Level2\Dimension3IDField; +use PhpTwinfield\Fields\Dimensions\Level2\RatioField; use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\VatCodeField; diff --git a/src/CustomerPostingRule.php b/src/CustomerPostingRule.php index dc9bc339..3b37b448 100644 --- a/src/CustomerPostingRule.php +++ b/src/CustomerPostingRule.php @@ -4,8 +4,8 @@ use PhpTwinfield\Fields\CurrencyField; use PhpTwinfield\Fields\DescriptionField; +use PhpTwinfield\Fields\Dimensions\AmountField; use PhpTwinfield\Fields\IDField; -use PhpTwinfield\Fields\Level1234\AmountField; use PhpTwinfield\Fields\StatusField; /** diff --git a/src/DimensionGroupDimension.php b/src/DimensionGroupDimension.php index a43ee168..eb43f5e7 100644 --- a/src/DimensionGroupDimension.php +++ b/src/DimensionGroupDimension.php @@ -2,8 +2,8 @@ namespace PhpTwinfield; -use PhpTwinfield\Fields\Level1234\DimensionGroup\CodeField; -use PhpTwinfield\Fields\Level1234\DimensionType\TypeField; +use PhpTwinfield\Fields\Dimensions\DimensionGroup\CodeField; +use PhpTwinfield\Fields\Dimensions\DimensionType\TypeField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionGroups diff --git a/src/DimensionType.php b/src/DimensionType.php index 7369f562..b29b2374 100644 --- a/src/DimensionType.php +++ b/src/DimensionType.php @@ -3,7 +3,7 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\CodeField; -use PhpTwinfield\Fields\Level1234\DimensionType\MaskField; +use PhpTwinfield\Fields\Dimensions\DimensionType\MaskField; use PhpTwinfield\Fields\NameField; use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\ShortNameField; diff --git a/src/DimensionTypeAddress.php b/src/DimensionTypeAddress.php index bae379f5..388bae31 100644 --- a/src/DimensionTypeAddress.php +++ b/src/DimensionTypeAddress.php @@ -2,12 +2,12 @@ namespace PhpTwinfield; -use PhpTwinfield\Fields\Level1234\DimensionType\Label1Field; -use PhpTwinfield\Fields\Level1234\DimensionType\Label2Field; -use PhpTwinfield\Fields\Level1234\DimensionType\Label3Field; -use PhpTwinfield\Fields\Level1234\DimensionType\Label4Field; -use PhpTwinfield\Fields\Level1234\DimensionType\Label5Field; -use PhpTwinfield\Fields\Level1234\DimensionType\Label6Field; +use PhpTwinfield\Fields\Dimensions\DimensionType\Label1Field; +use PhpTwinfield\Fields\Dimensions\DimensionType\Label2Field; +use PhpTwinfield\Fields\Dimensions\DimensionType\Label3Field; +use PhpTwinfield\Fields\Dimensions\DimensionType\Label4Field; +use PhpTwinfield\Fields\Dimensions\DimensionType\Label5Field; +use PhpTwinfield\Fields\Dimensions\DimensionType\Label6Field; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionTypes diff --git a/src/DimensionTypeLevels.php b/src/DimensionTypeLevels.php index c1a23b36..8766bbb1 100644 --- a/src/DimensionTypeLevels.php +++ b/src/DimensionTypeLevels.php @@ -2,8 +2,8 @@ namespace PhpTwinfield; -use PhpTwinfield\Fields\Level1234\DimensionType\FinancialsField; -use PhpTwinfield\Fields\Level1234\DimensionType\TimeField; +use PhpTwinfield\Fields\Dimensions\DimensionType\FinancialsField; +use PhpTwinfield\Fields\Dimensions\DimensionType\TimeField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionTypes diff --git a/src/Fields/Level1234/AccountTypeField.php b/src/Fields/Dimensions/AccountTypeField.php similarity index 91% rename from src/Fields/Level1234/AccountTypeField.php rename to src/Fields/Dimensions/AccountTypeField.php index 1a47a5f9..d2b58400 100644 --- a/src/Fields/Level1234/AccountTypeField.php +++ b/src/Fields/Dimensions/AccountTypeField.php @@ -1,41 +1,41 @@ -accountType; - } - - /** - * @param AccountType|null $accountType - * @return $this - */ - public function setAccountType(?AccountType $accountType): self - { - $this->accountType = $accountType; - return $this; - } - - /** - * @param string|null $accountTypeString - * @return $this - * @throws Exception - */ - public function setAccountTypeFromString(?string $accountTypeString) - { - return $this->setAccountType(new AccountType((string)$accountTypeString)); - } +accountType; + } + + /** + * @param AccountType|null $accountType + * @return $this + */ + public function setAccountType(?AccountType $accountType): self + { + $this->accountType = $accountType; + return $this; + } + + /** + * @param string|null $accountTypeString + * @return $this + * @throws Exception + */ + public function setAccountTypeFromString(?string $accountTypeString) + { + return $this->setAccountType(new AccountType((string)$accountTypeString)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/AmountField.php b/src/Fields/Dimensions/AmountField.php similarity index 91% rename from src/Fields/Level1234/AmountField.php rename to src/Fields/Dimensions/AmountField.php index 55066e71..a51baad4 100644 --- a/src/Fields/Level1234/AmountField.php +++ b/src/Fields/Dimensions/AmountField.php @@ -1,62 +1,62 @@ -amount; - } - - /** - * @return float|null - */ - public function getAmountToFloat(): ?float - { - if ($this->getAmount() != null) { - return Util::formatMoney($this->getAmount()); - } else { - return 0; - } - } - - /** - * @param Money|null $amount - * @return $this - */ - public function setAmount(?Money $amount) - { - $this->amount = $amount; - - return $this; - } - - /** - * @param float|null $amountFloat - * @return $this - * @throws Exception - */ - public function setAmountFromFloat(?float $amountFloat) - { - if ((float)$amountFloat) { - return $this->setAmount(Money::EUR(100 * $amountFloat)); - } else { - return $this->setAmount(Money::EUR(0)); - } - } +amount; + } + + /** + * @return float|null + */ + public function getAmountToFloat(): ?float + { + if ($this->getAmount() != null) { + return Util::formatMoney($this->getAmount()); + } else { + return 0; + } + } + + /** + * @param Money|null $amount + * @return $this + */ + public function setAmount(?Money $amount) + { + $this->amount = $amount; + + return $this; + } + + /** + * @param float|null $amountFloat + * @return $this + * @throws Exception + */ + public function setAmountFromFloat(?float $amountFloat) + { + if ((float)$amountFloat) { + return $this->setAmount(Money::EUR(100 * $amountFloat)); + } else { + return $this->setAmount(Money::EUR(0)); + } + } } \ No newline at end of file diff --git a/src/Fields/Level1234/BeginPeriodField.php b/src/Fields/Dimensions/BeginPeriodField.php similarity index 92% rename from src/Fields/Level1234/BeginPeriodField.php rename to src/Fields/Dimensions/BeginPeriodField.php index 72108980..ff1285e5 100644 --- a/src/Fields/Level1234/BeginPeriodField.php +++ b/src/Fields/Dimensions/BeginPeriodField.php @@ -1,6 +1,6 @@ beginYear; - } - - /** - * @param null|int $beginYear - * @return $this - */ - public function setBeginYear(?int $beginYear): self - { - $this->beginYear = $beginYear; - return $this; - } +beginYear; + } + + /** + * @param null|int $beginYear + * @return $this + */ + public function setBeginYear(?int $beginYear): self + { + $this->beginYear = $beginYear; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/DimensionGroup/CodeField.php b/src/Fields/Dimensions/DimensionGroup/CodeField.php similarity index 93% rename from src/Fields/Level1234/DimensionGroup/CodeField.php rename to src/Fields/Dimensions/DimensionGroup/CodeField.php index 3ddea308..4a91387f 100644 --- a/src/Fields/Level1234/DimensionGroup/CodeField.php +++ b/src/Fields/Dimensions/DimensionGroup/CodeField.php @@ -1,6 +1,6 @@ label1; - } - - /** - * @param null|string $label1 - * @return $this - */ - public function setLabel1(?string $label1): self - { - $this->label1 = $label1; - return $this; - } +label1; + } + + /** + * @param null|string $label1 + * @return $this + */ + public function setLabel1(?string $label1): self + { + $this->label1 = $label1; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/DimensionType/Label2Field.php b/src/Fields/Dimensions/DimensionType/Label2Field.php similarity index 84% rename from src/Fields/Level1234/DimensionType/Label2Field.php rename to src/Fields/Dimensions/DimensionType/Label2Field.php index 63ecd9a5..e31f8543 100644 --- a/src/Fields/Level1234/DimensionType/Label2Field.php +++ b/src/Fields/Dimensions/DimensionType/Label2Field.php @@ -1,32 +1,32 @@ -label2; - } - - /** - * @param null|string $label2 - * @return $this - */ - public function setLabel2(?string $label2): self - { - $this->label2 = $label2; - return $this; - } +label2; + } + + /** + * @param null|string $label2 + * @return $this + */ + public function setLabel2(?string $label2): self + { + $this->label2 = $label2; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/DimensionType/Label3Field.php b/src/Fields/Dimensions/DimensionType/Label3Field.php similarity index 84% rename from src/Fields/Level1234/DimensionType/Label3Field.php rename to src/Fields/Dimensions/DimensionType/Label3Field.php index 6dec4ebc..5a93cd4d 100644 --- a/src/Fields/Level1234/DimensionType/Label3Field.php +++ b/src/Fields/Dimensions/DimensionType/Label3Field.php @@ -1,32 +1,32 @@ -label3; - } - - /** - * @param null|string $label3 - * @return $this - */ - public function setLabel3(?string $label3): self - { - $this->label3 = $label3; - return $this; - } +label3; + } + + /** + * @param null|string $label3 + * @return $this + */ + public function setLabel3(?string $label3): self + { + $this->label3 = $label3; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/DimensionType/Label4Field.php b/src/Fields/Dimensions/DimensionType/Label4Field.php similarity index 84% rename from src/Fields/Level1234/DimensionType/Label4Field.php rename to src/Fields/Dimensions/DimensionType/Label4Field.php index ea220b50..438a42b3 100644 --- a/src/Fields/Level1234/DimensionType/Label4Field.php +++ b/src/Fields/Dimensions/DimensionType/Label4Field.php @@ -1,32 +1,32 @@ -label4; - } - - /** - * @param null|string $label4 - * @return $this - */ - public function setLabel4(?string $label4): self - { - $this->label4 = $label4; - return $this; - } +label4; + } + + /** + * @param null|string $label4 + * @return $this + */ + public function setLabel4(?string $label4): self + { + $this->label4 = $label4; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/DimensionType/Label5Field.php b/src/Fields/Dimensions/DimensionType/Label5Field.php similarity index 84% rename from src/Fields/Level1234/DimensionType/Label5Field.php rename to src/Fields/Dimensions/DimensionType/Label5Field.php index 60b4b9ac..27bcfdfa 100644 --- a/src/Fields/Level1234/DimensionType/Label5Field.php +++ b/src/Fields/Dimensions/DimensionType/Label5Field.php @@ -1,32 +1,32 @@ -label5; - } - - /** - * @param null|string $label5 - * @return $this - */ - public function setLabel5(?string $label5): self - { - $this->label5 = $label5; - return $this; - } +label5; + } + + /** + * @param null|string $label5 + * @return $this + */ + public function setLabel5(?string $label5): self + { + $this->label5 = $label5; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/DimensionType/Label6Field.php b/src/Fields/Dimensions/DimensionType/Label6Field.php similarity index 84% rename from src/Fields/Level1234/DimensionType/Label6Field.php rename to src/Fields/Dimensions/DimensionType/Label6Field.php index becfaf4c..c50d18b3 100644 --- a/src/Fields/Level1234/DimensionType/Label6Field.php +++ b/src/Fields/Dimensions/DimensionType/Label6Field.php @@ -1,32 +1,32 @@ -label6; - } - - /** - * @param null|string $label6 - * @return $this - */ - public function setLabel6(?string $label6): self - { - $this->label6 = $label6; - return $this; - } +label6; + } + + /** + * @param null|string $label6 + * @return $this + */ + public function setLabel6(?string $label6): self + { + $this->label6 = $label6; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/DimensionType/MaskField.php b/src/Fields/Dimensions/DimensionType/MaskField.php similarity index 83% rename from src/Fields/Level1234/DimensionType/MaskField.php rename to src/Fields/Dimensions/DimensionType/MaskField.php index e23f13c0..3872ac54 100644 --- a/src/Fields/Level1234/DimensionType/MaskField.php +++ b/src/Fields/Dimensions/DimensionType/MaskField.php @@ -1,32 +1,32 @@ -mask; - } - - /** - * @param null|string $mask - * @return $this - */ - public function setMask(?string $mask): self - { - $this->mask = $mask; - return $this; - } +mask; + } + + /** + * @param null|string $mask + * @return $this + */ + public function setMask(?string $mask): self + { + $this->mask = $mask; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/DimensionType/TimeField.php b/src/Fields/Dimensions/DimensionType/TimeField.php similarity index 88% rename from src/Fields/Level1234/DimensionType/TimeField.php rename to src/Fields/Dimensions/DimensionType/TimeField.php index aeae646e..77969d63 100644 --- a/src/Fields/Level1234/DimensionType/TimeField.php +++ b/src/Fields/Dimensions/DimensionType/TimeField.php @@ -1,6 +1,6 @@ endYear; - } - - /** - * @param null|int $endYear - * @return $this - */ - public function setEndYear(?int $endYear): self - { - $this->endYear = $endYear; - return $this; - } +endYear; + } + + /** + * @param null|int $endYear + * @return $this + */ + public function setEndYear(?int $endYear): self + { + $this->endYear = $endYear; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/AccountNumberField.php b/src/Fields/Dimensions/Level2/AccountNumberField.php similarity index 87% rename from src/Fields/Level1234/Level2/AccountNumberField.php rename to src/Fields/Dimensions/Level2/AccountNumberField.php index 06580e25..03f76603 100644 --- a/src/Fields/Level1234/Level2/AccountNumberField.php +++ b/src/Fields/Dimensions/Level2/AccountNumberField.php @@ -1,32 +1,32 @@ -accountNumber; - } - - /** - * @param null|string $accountNumber - * @return $this - */ - public function setAccountNumber(?string $accountNumber): self - { - $this->accountNumber = $accountNumber; - return $this; - } +accountNumber; + } + + /** + * @param null|string $accountNumber + * @return $this + */ + public function setAccountNumber(?string $accountNumber): self + { + $this->accountNumber = $accountNumber; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/AddressField2Field.php b/src/Fields/Dimensions/Level2/AddressField2Field.php similarity index 87% rename from src/Fields/Level1234/Level2/AddressField2Field.php rename to src/Fields/Dimensions/Level2/AddressField2Field.php index d32eae16..173d64c2 100644 --- a/src/Fields/Level1234/Level2/AddressField2Field.php +++ b/src/Fields/Dimensions/Level2/AddressField2Field.php @@ -1,32 +1,32 @@ -addressField2; - } - - /** - * @param null|string $addressField2 - * @return $this - */ - public function setAddressField2(?string $addressField2): self - { - $this->addressField2 = $addressField2; - return $this; - } +addressField2; + } + + /** + * @param null|string $addressField2 + * @return $this + */ + public function setAddressField2(?string $addressField2): self + { + $this->addressField2 = $addressField2; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/AddressField3Field.php b/src/Fields/Dimensions/Level2/AddressField3Field.php similarity index 87% rename from src/Fields/Level1234/Level2/AddressField3Field.php rename to src/Fields/Dimensions/Level2/AddressField3Field.php index 80b2b037..caf36f14 100644 --- a/src/Fields/Level1234/Level2/AddressField3Field.php +++ b/src/Fields/Dimensions/Level2/AddressField3Field.php @@ -1,32 +1,32 @@ -addressField3; - } - - /** - * @param null|string $addressField3 - * @return $this - */ - public function setAddressField3(?string $addressField3): self - { - $this->addressField3 = $addressField3; - return $this; - } +addressField3; + } + + /** + * @param null|string $addressField3 + * @return $this + */ + public function setAddressField3(?string $addressField3): self + { + $this->addressField3 = $addressField3; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/AscriptionField.php b/src/Fields/Dimensions/Level2/AscriptionField.php similarity index 86% rename from src/Fields/Level1234/Level2/AscriptionField.php rename to src/Fields/Dimensions/Level2/AscriptionField.php index b232e281..417992ac 100644 --- a/src/Fields/Level1234/Level2/AscriptionField.php +++ b/src/Fields/Dimensions/Level2/AscriptionField.php @@ -1,32 +1,32 @@ -ascription; - } - - /** - * @param null|string $ascription - * @return $this - */ - public function setAscription(?string $ascription): self - { - $this->ascription = $ascription; - return $this; - } +ascription; + } + + /** + * @param null|string $ascription + * @return $this + */ + public function setAscription(?string $ascription): self + { + $this->ascription = $ascription; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/BankBlockedField.php b/src/Fields/Dimensions/Level2/BankBlockedField.php similarity index 90% rename from src/Fields/Level1234/Level2/BankBlockedField.php rename to src/Fields/Dimensions/Level2/BankBlockedField.php index fee8ace0..e2b13728 100644 --- a/src/Fields/Level1234/Level2/BankBlockedField.php +++ b/src/Fields/Dimensions/Level2/BankBlockedField.php @@ -1,47 +1,47 @@ -blocked; - } - - public function getBlockedToString(): ?string - { - return ($this->getBlocked()) ? 'true' : 'false'; - } - - /** - * @param bool $blocked - * @return $this - */ - public function setBlocked(?bool $blocked): self - { - $this->blocked = $blocked; - return $this; - } - - /** - * @param string|null $blockedString - * @return $this - * @throws Exception - */ - public function setBlockedFromString(?string $blockedString) - { - return $this->setBlocked(filter_var($blockedString, FILTER_VALIDATE_BOOLEAN)); - } +blocked; + } + + public function getBlockedToString(): ?string + { + return ($this->getBlocked()) ? 'true' : 'false'; + } + + /** + * @param bool $blocked + * @return $this + */ + public function setBlocked(?bool $blocked): self + { + $this->blocked = $blocked; + return $this; + } + + /** + * @param string|null $blockedString + * @return $this + * @throws Exception + */ + public function setBlockedFromString(?string $blockedString) + { + return $this->setBlocked(filter_var($blockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/BankNameField.php b/src/Fields/Dimensions/Level2/BankNameField.php similarity index 86% rename from src/Fields/Level1234/Level2/BankNameField.php rename to src/Fields/Dimensions/Level2/BankNameField.php index 822be4c1..59c19779 100644 --- a/src/Fields/Level1234/Level2/BankNameField.php +++ b/src/Fields/Dimensions/Level2/BankNameField.php @@ -1,32 +1,32 @@ -bankName; - } - - /** - * @param null|string $bankName - * @return $this - */ - public function setBankName(?string $bankName): self - { - $this->bankName = $bankName; - return $this; - } +bankName; + } + + /** + * @param null|string $bankName + * @return $this + */ + public function setBankName(?string $bankName): self + { + $this->bankName = $bankName; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/BicCodeField.php b/src/Fields/Dimensions/Level2/BicCodeField.php similarity index 86% rename from src/Fields/Level1234/Level2/BicCodeField.php rename to src/Fields/Dimensions/Level2/BicCodeField.php index 875ba9ed..3f52d274 100644 --- a/src/Fields/Level1234/Level2/BicCodeField.php +++ b/src/Fields/Dimensions/Level2/BicCodeField.php @@ -1,32 +1,32 @@ -bicCode; - } - - /** - * @param null|string $bicCode - * @return $this - */ - public function setBicCode(?string $bicCode): self - { - $this->bicCode = $bicCode; - return $this; - } +bicCode; + } + + /** + * @param null|string $bicCode + * @return $this + */ + public function setBicCode(?string $bicCode): self + { + $this->bicCode = $bicCode; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/CityField.php b/src/Fields/Dimensions/Level2/CityField.php similarity index 86% rename from src/Fields/Level1234/Level2/CityField.php rename to src/Fields/Dimensions/Level2/CityField.php index 3f9cf912..3b4e83a3 100644 --- a/src/Fields/Level1234/Level2/CityField.php +++ b/src/Fields/Dimensions/Level2/CityField.php @@ -1,32 +1,32 @@ -city; - } - - /** - * @param null|string $city - * @return $this - */ - public function setCity(?string $city): self - { - $this->city = $city; - return $this; - } +city; + } + + /** + * @param null|string $city + * @return $this + */ + public function setCity(?string $city): self + { + $this->city = $city; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/CountryField.php b/src/Fields/Dimensions/Level2/CountryField.php similarity index 90% rename from src/Fields/Level1234/Level2/CountryField.php rename to src/Fields/Dimensions/Level2/CountryField.php index 36a110fa..0a3356c8 100644 --- a/src/Fields/Level1234/Level2/CountryField.php +++ b/src/Fields/Dimensions/Level2/CountryField.php @@ -1,54 +1,54 @@ -country; - } - - public function getCountryToString(): ?string - { - if ($this->getCountry() != null) { - return $this->country->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setCountry(?Country $country): self - { - $this->country = $country; - return $this; - } - - /** - * @param string|null $countryCode - * @return $this - * @throws Exception - */ - public function setCountryFromString(?string $countryCode) - { - $country = new Country(); - $country->setCode($countryCode); - return $this->setCountry($country); - } -} +country; + } + + public function getCountryToString(): ?string + { + if ($this->getCountry() != null) { + return $this->country->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setCountry(?Country $country): self + { + $this->country = $country; + return $this; + } + + /** + * @param string|null $countryCode + * @return $this + * @throws Exception + */ + public function setCountryFromString(?string $countryCode) + { + $country = new Country(); + $country->setCode($countryCode); + return $this->setCountry($country); + } +} diff --git a/src/Fields/Level1234/Level2/Customer/BaseCreditLimitField.php b/src/Fields/Dimensions/Level2/Customer/BaseCreditLimitField.php similarity index 91% rename from src/Fields/Level1234/Level2/Customer/BaseCreditLimitField.php rename to src/Fields/Dimensions/Level2/Customer/BaseCreditLimitField.php index 161e86be..57764742 100644 --- a/src/Fields/Level1234/Level2/Customer/BaseCreditLimitField.php +++ b/src/Fields/Dimensions/Level2/Customer/BaseCreditLimitField.php @@ -1,62 +1,62 @@ -baseCreditLimit; - } - - /** - * @return float|null - */ - public function getBaseCreditLimitToFloat(): ?float - { - if ($this->getBaseCreditLimit() != null) { - return Util::formatMoney($this->getBaseCreditLimit()); - } else { - return 0; - } - } - - /** - * @param Money|null $baseCreditLimit - * @return $this - */ - public function setBaseCreditLimit(?Money $baseCreditLimit) - { - $this->baseCreditLimit = $baseCreditLimit; - - return $this; - } - - /** - * @param float|null $baseCreditLimitFloat - * @return $this - * @throws Exception - */ - public function setBaseCreditLimitFromFloat(?float $baseCreditLimitFloat) - { - if ((float)$baseCreditLimitFloat) { - return $this->setBaseCreditLimit(Money::EUR(100 * $baseCreditLimitFloat)); - } else { - return $this->setBaseCreditLimit(Money::EUR(0)); - } - } +baseCreditLimit; + } + + /** + * @return float|null + */ + public function getBaseCreditLimitToFloat(): ?float + { + if ($this->getBaseCreditLimit() != null) { + return Util::formatMoney($this->getBaseCreditLimit()); + } else { + return 0; + } + } + + /** + * @param Money|null $baseCreditLimit + * @return $this + */ + public function setBaseCreditLimit(?Money $baseCreditLimit) + { + $this->baseCreditLimit = $baseCreditLimit; + + return $this; + } + + /** + * @param float|null $baseCreditLimitFloat + * @return $this + * @throws Exception + */ + public function setBaseCreditLimitFromFloat(?float $baseCreditLimitFloat) + { + if ((float)$baseCreditLimitFloat) { + return $this->setBaseCreditLimit(Money::EUR(100 * $baseCreditLimitFloat)); + } else { + return $this->setBaseCreditLimit(Money::EUR(0)); + } + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/BlockedField.php b/src/Fields/Dimensions/Level2/Customer/BlockedField.php similarity index 89% rename from src/Fields/Level1234/Level2/Customer/BlockedField.php rename to src/Fields/Dimensions/Level2/Customer/BlockedField.php index 127a078d..8b313f3f 100644 --- a/src/Fields/Level1234/Level2/Customer/BlockedField.php +++ b/src/Fields/Dimensions/Level2/Customer/BlockedField.php @@ -1,47 +1,47 @@ -blocked; - } - - public function getBlockedToString(): ?string - { - return ($this->getBlocked()) ? 'true' : 'false'; - } - - /** - * @param bool $blocked - * @return $this - */ - public function setBlocked(?bool $blocked): self - { - $this->blocked = $blocked; - return $this; - } - - /** - * @param string|null $blockedString - * @return $this - * @throws Exception - */ - public function setBlockedFromString(?string $blockedString) - { - return $this->setBlocked(filter_var($blockedString, FILTER_VALIDATE_BOOLEAN)); - } +blocked; + } + + public function getBlockedToString(): ?string + { + return ($this->getBlocked()) ? 'true' : 'false'; + } + + /** + * @param bool $blocked + * @return $this + */ + public function setBlocked(?bool $blocked): self + { + $this->blocked = $blocked; + return $this; + } + + /** + * @param string|null $blockedString + * @return $this + * @throws Exception + */ + public function setBlockedFromString(?string $blockedString) + { + return $this->setBlocked(filter_var($blockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/BlockedLockedField.php b/src/Fields/Dimensions/Level2/Customer/BlockedLockedField.php similarity index 90% rename from src/Fields/Level1234/Level2/Customer/BlockedLockedField.php rename to src/Fields/Dimensions/Level2/Customer/BlockedLockedField.php index b76f05bc..23aa08c5 100644 --- a/src/Fields/Level1234/Level2/Customer/BlockedLockedField.php +++ b/src/Fields/Dimensions/Level2/Customer/BlockedLockedField.php @@ -1,47 +1,47 @@ -blockedLocked; - } - - public function getBlockedLockedToString(): ?string - { - return ($this->getBlockedLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $blockedLocked - * @return $this - */ - public function setBlockedLocked(?bool $blockedLocked): self - { - $this->blockedLocked = $blockedLocked; - return $this; - } - - /** - * @param string|null $blockedLockedString - * @return $this - * @throws Exception - */ - public function setBlockedLockedFromString(?string $blockedLockedString) - { - return $this->setBlockedLocked(filter_var($blockedLockedString, FILTER_VALIDATE_BOOLEAN)); - } +blockedLocked; + } + + public function getBlockedLockedToString(): ?string + { + return ($this->getBlockedLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $blockedLocked + * @return $this + */ + public function setBlockedLocked(?bool $blockedLocked): self + { + $this->blockedLocked = $blockedLocked; + return $this; + } + + /** + * @param string|null $blockedLockedString + * @return $this + * @throws Exception + */ + public function setBlockedLockedFromString(?string $blockedLockedString) + { + return $this->setBlockedLocked(filter_var($blockedLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/BlockedModifiedField.php b/src/Fields/Dimensions/Level2/Customer/BlockedModifiedField.php similarity index 92% rename from src/Fields/Level1234/Level2/Customer/BlockedModifiedField.php rename to src/Fields/Dimensions/Level2/Customer/BlockedModifiedField.php index 51459bad..a99dabdf 100644 --- a/src/Fields/Level1234/Level2/Customer/BlockedModifiedField.php +++ b/src/Fields/Dimensions/Level2/Customer/BlockedModifiedField.php @@ -1,66 +1,66 @@ -blockedModified; - } - - /** - * @return string|null - */ - public function getBlockedModifiedToString(): ?string - { - if ($this->getBlockedModified() != null) { - return Util::formatDateTime($this->getBlockedModified()); - } else { - return null; - } - } - - /** - * @param \DateTimeInterface|null $blockedModified - * @return $this - */ - public function setBlockedModified(?\DateTimeInterface $blockedModified) - { - $this->blockedModified = $blockedModified; - return $this; - } - - /** - * @param string|null $blockedModifiedString - * @return $this - * @throws Exception - */ - public function setBlockedModifiedFromString(?string $blockedModifiedString) - { - if ((bool)strtotime($blockedModifiedString)) { - return $this->setBlockedModified(Util::parseDateTime($blockedModifiedString)); - } else { - return $this->setBlockedModified(null); - } - } +blockedModified; + } + + /** + * @return string|null + */ + public function getBlockedModifiedToString(): ?string + { + if ($this->getBlockedModified() != null) { + return Util::formatDateTime($this->getBlockedModified()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $blockedModified + * @return $this + */ + public function setBlockedModified(?\DateTimeInterface $blockedModified) + { + $this->blockedModified = $blockedModified; + return $this; + } + + /** + * @param string|null $blockedModifiedString + * @return $this + * @throws Exception + */ + public function setBlockedModifiedFromString(?string $blockedModifiedString) + { + if ((bool)strtotime($blockedModifiedString)) { + return $this->setBlockedModified(Util::parseDateTime($blockedModifiedString)); + } else { + return $this->setBlockedModified(null); + } + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/CollectionSchemaField.php b/src/Fields/Dimensions/Level2/Customer/CollectionSchemaField.php similarity index 90% rename from src/Fields/Level1234/Level2/Customer/CollectionSchemaField.php rename to src/Fields/Dimensions/Level2/Customer/CollectionSchemaField.php index 06807a14..b19012df 100644 --- a/src/Fields/Level1234/Level2/Customer/CollectionSchemaField.php +++ b/src/Fields/Dimensions/Level2/Customer/CollectionSchemaField.php @@ -1,41 +1,41 @@ -collectionSchema; - } - - /** - * @param CollectionSchema|null $collectionSchema - * @return $this - */ - public function setCollectionSchema(?CollectionSchema $collectionSchema): self - { - $this->collectionSchema = $collectionSchema; - return $this; - } - - /** - * @param string|null $collectionSchemaString - * @return $this - * @throws Exception - */ - public function setCollectionSchemaFromString(?string $collectionSchemaString) - { - return $this->setCollectionSchema(new CollectionSchema((string)$collectionSchemaString)); - } +collectionSchema; + } + + /** + * @param CollectionSchema|null $collectionSchema + * @return $this + */ + public function setCollectionSchema(?CollectionSchema $collectionSchema): self + { + $this->collectionSchema = $collectionSchema; + return $this; + } + + /** + * @param string|null $collectionSchemaString + * @return $this + * @throws Exception + */ + public function setCollectionSchemaFromString(?string $collectionSchemaString) + { + return $this->setCollectionSchema(new CollectionSchema((string)$collectionSchemaString)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/CommentField.php b/src/Fields/Dimensions/Level2/Customer/CommentField.php similarity index 84% rename from src/Fields/Level1234/Level2/Customer/CommentField.php rename to src/Fields/Dimensions/Level2/Customer/CommentField.php index 0132a1c2..0a936794 100644 --- a/src/Fields/Level1234/Level2/Customer/CommentField.php +++ b/src/Fields/Dimensions/Level2/Customer/CommentField.php @@ -1,32 +1,32 @@ -comment; - } - - /** - * @param null|string $comment - * @return $this - */ - public function setComment(?string $comment) - { - $this->comment = $comment; - return $this; - } +comment; + } + + /** + * @param null|string $comment + * @return $this + */ + public function setComment(?string $comment) + { + $this->comment = $comment; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/DiscountArticleField.php b/src/Fields/Dimensions/Level2/Customer/DiscountArticleField.php similarity index 90% rename from src/Fields/Level1234/Level2/Customer/DiscountArticleField.php rename to src/Fields/Dimensions/Level2/Customer/DiscountArticleField.php index 3516143d..58aeb06c 100644 --- a/src/Fields/Level1234/Level2/Customer/DiscountArticleField.php +++ b/src/Fields/Dimensions/Level2/Customer/DiscountArticleField.php @@ -1,54 +1,54 @@ -discountArticle; - } - - public function getDiscountArticleToString(): ?string - { - if ($this->getDiscountArticle() != null) { - return $this->discountArticle->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setDiscountArticle(?Article $discountArticle): self - { - $this->discountArticle = $discountArticle; - return $this; - } - - /** - * @param string|null $discountArticleCode - * @return $this - * @throws Exception - */ - public function setDiscountArticleFromString(?string $discountArticleCode) - { - $discountArticle = new Article(); - $discountArticle->setCode($discountArticleCode); - return $this->setDiscountArticle($discountArticle); - } -} +discountArticle; + } + + public function getDiscountArticleToString(): ?string + { + if ($this->getDiscountArticle() != null) { + return $this->discountArticle->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDiscountArticle(?Article $discountArticle): self + { + $this->discountArticle = $discountArticle; + return $this; + } + + /** + * @param string|null $discountArticleCode + * @return $this + * @throws Exception + */ + public function setDiscountArticleFromString(?string $discountArticleCode) + { + $discountArticle = new Article(); + $discountArticle->setCode($discountArticleCode); + return $this->setDiscountArticle($discountArticle); + } +} diff --git a/src/Fields/Level1234/Level2/Customer/DiscountArticleIDField.php b/src/Fields/Dimensions/Level2/Customer/DiscountArticleIDField.php similarity index 86% rename from src/Fields/Level1234/Level2/Customer/DiscountArticleIDField.php rename to src/Fields/Dimensions/Level2/Customer/DiscountArticleIDField.php index b99406eb..7aaf3bcb 100644 --- a/src/Fields/Level1234/Level2/Customer/DiscountArticleIDField.php +++ b/src/Fields/Dimensions/Level2/Customer/DiscountArticleIDField.php @@ -1,32 +1,32 @@ -discountArticleID; - } - - /** - * @param null|string $discountArticleID - * @return $this - */ - public function setDiscountArticleID(?string $discountArticleID): self - { - $this->discountArticleID = $discountArticleID; - return $this; - } +discountArticleID; + } + + /** + * @param null|string $discountArticleID + * @return $this + */ + public function setDiscountArticleID(?string $discountArticleID): self + { + $this->discountArticleID = $discountArticleID; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/EBillMailField.php b/src/Fields/Dimensions/Level2/Customer/EBillMailField.php similarity index 85% rename from src/Fields/Level1234/Level2/Customer/EBillMailField.php rename to src/Fields/Dimensions/Level2/Customer/EBillMailField.php index c4993380..7290e9f4 100644 --- a/src/Fields/Level1234/Level2/Customer/EBillMailField.php +++ b/src/Fields/Dimensions/Level2/Customer/EBillMailField.php @@ -1,32 +1,32 @@ -eBillMail; - } - - /** - * @param null|string $eBillMail - * @return $this - */ - public function setEBillMail(?string $eBillMail): self - { - $this->eBillMail = $eBillMail; - return $this; - } +eBillMail; + } + + /** + * @param null|string $eBillMail + * @return $this + */ + public function setEBillMail(?string $eBillMail): self + { + $this->eBillMail = $eBillMail; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/EBillingField.php b/src/Fields/Dimensions/Level2/Customer/EBillingField.php similarity index 89% rename from src/Fields/Level1234/Level2/Customer/EBillingField.php rename to src/Fields/Dimensions/Level2/Customer/EBillingField.php index 2844141e..26e4eb3d 100644 --- a/src/Fields/Level1234/Level2/Customer/EBillingField.php +++ b/src/Fields/Dimensions/Level2/Customer/EBillingField.php @@ -1,47 +1,47 @@ -eBilling; - } - - public function getEBillingToString(): ?string - { - return ($this->getEBilling()) ? 'true' : 'false'; - } - - /** - * @param bool $eBilling - * @return $this - */ - public function setEBilling(?bool $eBilling): self - { - $this->eBilling = $eBilling; - return $this; - } - - /** - * @param string|null $eBillingString - * @return $this - * @throws Exception - */ - public function setEBillingFromString(?string $eBillingString) - { - return $this->setEBilling(filter_var($eBillingString, FILTER_VALIDATE_BOOLEAN)); - } +eBilling; + } + + public function getEBillingToString(): ?string + { + return ($this->getEBilling()) ? 'true' : 'false'; + } + + /** + * @param bool $eBilling + * @return $this + */ + public function setEBilling(?bool $eBilling): self + { + $this->eBilling = $eBilling; + return $this; + } + + /** + * @param string|null $eBillingString + * @return $this + * @throws Exception + */ + public function setEBillingFromString(?string $eBillingString) + { + return $this->setEBilling(filter_var($eBillingString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/FirstRunDateField.php b/src/Fields/Dimensions/Level2/Customer/FirstRunDateField.php similarity index 92% rename from src/Fields/Level1234/Level2/Customer/FirstRunDateField.php rename to src/Fields/Dimensions/Level2/Customer/FirstRunDateField.php index 3ff0769e..c1ff1f75 100644 --- a/src/Fields/Level1234/Level2/Customer/FirstRunDateField.php +++ b/src/Fields/Dimensions/Level2/Customer/FirstRunDateField.php @@ -1,66 +1,66 @@ -firstRunDate; - } - - /** - * @return string|null - */ - public function getFirstRunDateToString(): ?string - { - if ($this->getFirstRunDate() != null) { - return Util::formatDate($this->getFirstRunDate()); - } else { - return null; - } - } - - /** - * @param \DateTimeInterface|null $firstRunDate - * @return $this - */ - public function setFirstRunDate(?\DateTimeInterface $firstRunDate) - { - $this->firstRunDate = $firstRunDate; - return $this; - } - - /** - * @param string|null $firstRunDateString - * @return $this - * @throws Exception - */ - public function setFirstRunDateFromString(?string $firstRunDateString) - { - if ((bool)strtotime($firstRunDateString)) { - return $this->setFirstRunDate(Util::parseDate($firstRunDateString)); - } else { - return $this->setFirstRunDate(null); - } - } +firstRunDate; + } + + /** + * @return string|null + */ + public function getFirstRunDateToString(): ?string + { + if ($this->getFirstRunDate() != null) { + return Util::formatDate($this->getFirstRunDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $firstRunDate + * @return $this + */ + public function setFirstRunDate(?\DateTimeInterface $firstRunDate) + { + $this->firstRunDate = $firstRunDate; + return $this; + } + + /** + * @param string|null $firstRunDateString + * @return $this + * @throws Exception + */ + public function setFirstRunDateFromString(?string $firstRunDateString) + { + if ((bool)strtotime($firstRunDateString)) { + return $this->setFirstRunDate(Util::parseDate($firstRunDateString)); + } else { + return $this->setFirstRunDate(null); + } + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/FreeText1Field.php b/src/Fields/Dimensions/Level2/Customer/FreeText1Field.php similarity index 93% rename from src/Fields/Level1234/Level2/Customer/FreeText1Field.php rename to src/Fields/Dimensions/Level2/Customer/FreeText1Field.php index 5788c0b1..4977d30b 100644 --- a/src/Fields/Level1234/Level2/Customer/FreeText1Field.php +++ b/src/Fields/Dimensions/Level2/Customer/FreeText1Field.php @@ -1,6 +1,6 @@ reminderEmail; - } - - /** - * @param null|string $reminderEmail - * @return $this - */ - public function setReminderEmail(?string $reminderEmail): self - { - $this->reminderEmail = $reminderEmail; - return $this; - } +reminderEmail; + } + + /** + * @param null|string $reminderEmail + * @return $this + */ + public function setReminderEmail(?string $reminderEmail): self + { + $this->reminderEmail = $reminderEmail; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/ResponsibleUserField.php b/src/Fields/Dimensions/Level2/Customer/ResponsibleUserField.php similarity index 90% rename from src/Fields/Level1234/Level2/Customer/ResponsibleUserField.php rename to src/Fields/Dimensions/Level2/Customer/ResponsibleUserField.php index 51bdeeec..a4925fdd 100644 --- a/src/Fields/Level1234/Level2/Customer/ResponsibleUserField.php +++ b/src/Fields/Dimensions/Level2/Customer/ResponsibleUserField.php @@ -1,55 +1,55 @@ -responsibleUser; - } - - public function getResponsibleUserToString(): ?string - { - if ($this->getResponsibleUser() != null) { - return $this->responsibleUser->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setResponsibleUser(?User $responsibleUser): self - { - $this->responsibleUser = $responsibleUser; - return $this; - } - - /** - * @param string|null $responsibleUserCode - * @return $this - * @throws Exception - */ - public function setResponsibleUserFromString(?string $responsibleUserCode) - { - $responsibleUser = new User(); - $responsibleUser->setCode($responsibleUserCode); - return $this->setResponsibleUser($responsibleUser); - } -} - +responsibleUser; + } + + public function getResponsibleUserToString(): ?string + { + if ($this->getResponsibleUser() != null) { + return $this->responsibleUser->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setResponsibleUser(?User $responsibleUser): self + { + $this->responsibleUser = $responsibleUser; + return $this; + } + + /** + * @param string|null $responsibleUserCode + * @return $this + * @throws Exception + */ + public function setResponsibleUserFromString(?string $responsibleUserCode) + { + $responsibleUser = new User(); + $responsibleUser->setCode($responsibleUserCode); + return $this->setResponsibleUser($responsibleUser); + } +} + diff --git a/src/Fields/Level1234/Level2/Customer/SendReminderField.php b/src/Fields/Dimensions/Level2/Customer/SendReminderField.php similarity index 89% rename from src/Fields/Level1234/Level2/Customer/SendReminderField.php rename to src/Fields/Dimensions/Level2/Customer/SendReminderField.php index 1d2efe33..20ed5b77 100644 --- a/src/Fields/Level1234/Level2/Customer/SendReminderField.php +++ b/src/Fields/Dimensions/Level2/Customer/SendReminderField.php @@ -1,41 +1,41 @@ -sendReminder; - } - - /** - * @param SendReminder|null $sendReminder - * @return $this - */ - public function setSendReminder(?SendReminder $sendReminder): self - { - $this->sendReminder = $sendReminder; - return $this; - } - - /** - * @param string|null $sendReminderString - * @return $this - * @throws Exception - */ - public function setSendReminderFromString(?string $sendReminderString) - { - return $this->setSendReminder(new SendReminder((string)$sendReminderString)); - } +sendReminder; + } + + /** + * @param SendReminder|null $sendReminder + * @return $this + */ + public function setSendReminder(?SendReminder $sendReminder): self + { + $this->sendReminder = $sendReminder; + return $this; + } + + /** + * @param string|null $sendReminderString + * @return $this + * @throws Exception + */ + public function setSendReminderFromString(?string $sendReminderString) + { + return $this->setSendReminder(new SendReminder((string)$sendReminderString)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Customer/SignatureDateField.php b/src/Fields/Dimensions/Level2/Customer/SignatureDateField.php similarity index 92% rename from src/Fields/Level1234/Level2/Customer/SignatureDateField.php rename to src/Fields/Dimensions/Level2/Customer/SignatureDateField.php index 4a965e25..0a4fe3f4 100644 --- a/src/Fields/Level1234/Level2/Customer/SignatureDateField.php +++ b/src/Fields/Dimensions/Level2/Customer/SignatureDateField.php @@ -1,66 +1,66 @@ -signatureDate; - } - - /** - * @return string|null - */ - public function getSignatureDateToString(): ?string - { - if ($this->getSignatureDate() != null) { - return Util::formatDate($this->getSignatureDate()); - } else { - return null; - } - } - - /** - * @param \DateTimeInterface|null $signatureDate - * @return $this - */ - public function setSignatureDate(?\DateTimeInterface $signatureDate) - { - $this->signatureDate = $signatureDate; - return $this; - } - - /** - * @param string|null $signatureDateString - * @return $this - * @throws Exception - */ - public function setSignatureDateFromString(?string $signatureDateString) - { - if ((bool)strtotime($signatureDateString)) { - return $this->setSignatureDate(Util::parseDate($signatureDateString)); - } else { - return $this->setSignatureDate(null); - } - } +signatureDate; + } + + /** + * @return string|null + */ + public function getSignatureDateToString(): ?string + { + if ($this->getSignatureDate() != null) { + return Util::formatDate($this->getSignatureDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $signatureDate + * @return $this + */ + public function setSignatureDate(?\DateTimeInterface $signatureDate) + { + $this->signatureDate = $signatureDate; + return $this; + } + + /** + * @param string|null $signatureDateString + * @return $this + * @throws Exception + */ + public function setSignatureDateFromString(?string $signatureDateString) + { + if ((bool)strtotime($signatureDateString)) { + return $this->setSignatureDate(Util::parseDate($signatureDateString)); + } else { + return $this->setSignatureDate(null); + } + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/DefaultField.php b/src/Fields/Dimensions/Level2/DefaultField.php similarity index 90% rename from src/Fields/Level1234/Level2/DefaultField.php rename to src/Fields/Dimensions/Level2/DefaultField.php index e93b4057..85dc56c7 100644 --- a/src/Fields/Level1234/Level2/DefaultField.php +++ b/src/Fields/Dimensions/Level2/DefaultField.php @@ -1,47 +1,47 @@ -default; - } - - public function getDefaultToString(): ?string - { - return ($this->getDefault()) ? 'true' : 'false'; - } - - /** - * @param bool $default - * @return $this - */ - public function setDefault(?bool $default): self - { - $this->default = $default; - return $this; - } - - /** - * @param string|null $defaultString - * @return $this - * @throws Exception - */ - public function setDefaultFromString(?string $defaultString) - { - return $this->setDefault(filter_var($defaultString, FILTER_VALIDATE_BOOLEAN)); - } +default; + } + + public function getDefaultToString(): ?string + { + return ($this->getDefault()) ? 'true' : 'false'; + } + + /** + * @param bool $default + * @return $this + */ + public function setDefault(?bool $default): self + { + $this->default = $default; + return $this; + } + + /** + * @param string|null $defaultString + * @return $this + * @throws Exception + */ + public function setDefaultFromString(?string $defaultString) + { + return $this->setDefault(filter_var($defaultString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Dimension1Field.php b/src/Fields/Dimensions/Level2/Dimension1Field.php similarity index 91% rename from src/Fields/Level1234/Level2/Dimension1Field.php rename to src/Fields/Dimensions/Level2/Dimension1Field.php index d1b60a56..1d5e508f 100644 --- a/src/Fields/Level1234/Level2/Dimension1Field.php +++ b/src/Fields/Dimensions/Level2/Dimension1Field.php @@ -1,54 +1,54 @@ -dimension1; - } - - public function getDimension1ToString(): ?string - { - if ($this->getDimension1() != null) { - return $this->dimension1->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setDimension1(?GeneralLedger $dimension1): self - { - $this->dimension1 = $dimension1; - return $this; - } - - /** - * @param string|null $dimension1Code - * @return $this - * @throws Exception - */ - public function setDimension1FromString(?string $dimension1Code) - { - $dimension1 = new GeneralLedger(); - $dimension1->setCode($dimension1Code); - return $this->setDimension1($dimension1); - } +dimension1; + } + + public function getDimension1ToString(): ?string + { + if ($this->getDimension1() != null) { + return $this->dimension1->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDimension1(?GeneralLedger $dimension1): self + { + $this->dimension1 = $dimension1; + return $this; + } + + /** + * @param string|null $dimension1Code + * @return $this + * @throws Exception + */ + public function setDimension1FromString(?string $dimension1Code) + { + $dimension1 = new GeneralLedger(); + $dimension1->setCode($dimension1Code); + return $this->setDimension1($dimension1); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Dimension1IDField.php b/src/Fields/Dimensions/Level2/Dimension1IDField.php similarity index 87% rename from src/Fields/Level1234/Level2/Dimension1IDField.php rename to src/Fields/Dimensions/Level2/Dimension1IDField.php index 3c4a0d72..c7b71bef 100644 --- a/src/Fields/Level1234/Level2/Dimension1IDField.php +++ b/src/Fields/Dimensions/Level2/Dimension1IDField.php @@ -1,32 +1,32 @@ -dimension1ID; - } - - /** - * @param null|string $dimension1ID - * @return $this - */ - public function setDimension1ID(?string $dimension1ID): self - { - $this->dimension1ID = $dimension1ID; - return $this; - } +dimension1ID; + } + + /** + * @param null|string $dimension1ID + * @return $this + */ + public function setDimension1ID(?string $dimension1ID): self + { + $this->dimension1ID = $dimension1ID; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Dimension2Field.php b/src/Fields/Dimensions/Level2/Dimension2Field.php similarity index 91% rename from src/Fields/Level1234/Level2/Dimension2Field.php rename to src/Fields/Dimensions/Level2/Dimension2Field.php index 810a2e75..1063575e 100644 --- a/src/Fields/Level1234/Level2/Dimension2Field.php +++ b/src/Fields/Dimensions/Level2/Dimension2Field.php @@ -1,54 +1,54 @@ -dimension2; - } - - public function getDimension2ToString(): ?string - { - if ($this->getDimension2() != null) { - return $this->dimension2->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setDimension2(?CostCenter $dimension2): self - { - $this->dimension2 = $dimension2; - return $this; - } - - /** - * @param string|null $dimension2Code - * @return $this - * @throws Exception - */ - public function setDimension2FromString(?string $dimension2Code) - { - $dimension2 = new CostCenter(); - $dimension2->setCode($dimension2Code); - return $this->setDimension2($dimension2); - } +dimension2; + } + + public function getDimension2ToString(): ?string + { + if ($this->getDimension2() != null) { + return $this->dimension2->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDimension2(?CostCenter $dimension2): self + { + $this->dimension2 = $dimension2; + return $this; + } + + /** + * @param string|null $dimension2Code + * @return $this + * @throws Exception + */ + public function setDimension2FromString(?string $dimension2Code) + { + $dimension2 = new CostCenter(); + $dimension2->setCode($dimension2Code); + return $this->setDimension2($dimension2); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Dimension2IDField.php b/src/Fields/Dimensions/Level2/Dimension2IDField.php similarity index 87% rename from src/Fields/Level1234/Level2/Dimension2IDField.php rename to src/Fields/Dimensions/Level2/Dimension2IDField.php index 3ff0c220..802c1ee2 100644 --- a/src/Fields/Level1234/Level2/Dimension2IDField.php +++ b/src/Fields/Dimensions/Level2/Dimension2IDField.php @@ -1,32 +1,32 @@ -dimension2ID; - } - - /** - * @param null|string $dimension2ID - * @return $this - */ - public function setDimension2ID(?string $dimension2ID): self - { - $this->dimension2ID = $dimension2ID; - return $this; - } +dimension2ID; + } + + /** + * @param null|string $dimension2ID + * @return $this + */ + public function setDimension2ID(?string $dimension2ID): self + { + $this->dimension2ID = $dimension2ID; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Dimension3Field.php b/src/Fields/Dimensions/Level2/Dimension3Field.php similarity index 90% rename from src/Fields/Level1234/Level2/Dimension3Field.php rename to src/Fields/Dimensions/Level2/Dimension3Field.php index 2afe81c6..388cecca 100644 --- a/src/Fields/Level1234/Level2/Dimension3Field.php +++ b/src/Fields/Dimensions/Level2/Dimension3Field.php @@ -1,54 +1,54 @@ -dimension3; - } - - public function getDimension3ToString(): ?string - { - if ($this->getDimension3() != null) { - return $this->dimension3->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setDimension3($dimension3): self - { - $this->dimension3 = $dimension3; - return $this; - } - - /** - * @param string|null $dimension3Code - * @return $this - * @throws Exception - */ - public function setDimension3FromString(?string $dimension3Code) - { - $dimension3 = new Dummy(); - $dimension3->setCode($dimension3Code); - return $this->setDimension3($dimension3); - } +dimension3; + } + + public function getDimension3ToString(): ?string + { + if ($this->getDimension3() != null) { + return $this->dimension3->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDimension3($dimension3): self + { + $this->dimension3 = $dimension3; + return $this; + } + + /** + * @param string|null $dimension3Code + * @return $this + * @throws Exception + */ + public function setDimension3FromString(?string $dimension3Code) + { + $dimension3 = new Dummy(); + $dimension3->setCode($dimension3Code); + return $this->setDimension3($dimension3); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Dimension3IDField.php b/src/Fields/Dimensions/Level2/Dimension3IDField.php similarity index 87% rename from src/Fields/Level1234/Level2/Dimension3IDField.php rename to src/Fields/Dimensions/Level2/Dimension3IDField.php index 5ef84657..3a98d687 100644 --- a/src/Fields/Level1234/Level2/Dimension3IDField.php +++ b/src/Fields/Dimensions/Level2/Dimension3IDField.php @@ -1,32 +1,32 @@ -dimension3ID; - } - - /** - * @param null|string $dimension3ID - * @return $this - */ - public function setDimension3ID(?string $dimension3ID): self - { - $this->dimension3ID = $dimension3ID; - return $this; - } +dimension3ID; + } + + /** + * @param null|string $dimension3ID + * @return $this + */ + public function setDimension3ID(?string $dimension3ID): self + { + $this->dimension3ID = $dimension3ID; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/DueDaysField.php b/src/Fields/Dimensions/Level2/DueDaysField.php similarity index 86% rename from src/Fields/Level1234/Level2/DueDaysField.php rename to src/Fields/Dimensions/Level2/DueDaysField.php index 9d5abb77..f964b89b 100644 --- a/src/Fields/Level1234/Level2/DueDaysField.php +++ b/src/Fields/Dimensions/Level2/DueDaysField.php @@ -1,32 +1,32 @@ -dueDays; - } - - /** - * @param null|int $dueDays - * @return $this - */ - public function setDueDays(?int $dueDays): self - { - $this->dueDays = $dueDays; - return $this; - } +dueDays; + } + + /** + * @param null|int $dueDays + * @return $this + */ + public function setDueDays(?int $dueDays): self + { + $this->dueDays = $dueDays; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/EmailField.php b/src/Fields/Dimensions/Level2/EmailField.php similarity index 85% rename from src/Fields/Level1234/Level2/EmailField.php rename to src/Fields/Dimensions/Level2/EmailField.php index 4271afd1..3ec6128c 100644 --- a/src/Fields/Level1234/Level2/EmailField.php +++ b/src/Fields/Dimensions/Level2/EmailField.php @@ -1,32 +1,32 @@ -email; - } - - /** - * @param null|string $email - * @return $this - */ - public function setEmail(?string $email): self - { - $this->email = $email; - return $this; - } +email; + } + + /** + * @param null|string $email + * @return $this + */ + public function setEmail(?string $email): self + { + $this->email = $email; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Field1Field.php b/src/Fields/Dimensions/Level2/Field1Field.php similarity index 86% rename from src/Fields/Level1234/Level2/Field1Field.php rename to src/Fields/Dimensions/Level2/Field1Field.php index bb3ef90b..54115f1d 100644 --- a/src/Fields/Level1234/Level2/Field1Field.php +++ b/src/Fields/Dimensions/Level2/Field1Field.php @@ -1,32 +1,32 @@ -field1; - } - - /** - * @param null|string $field1 - * @return $this - */ - public function setField1(?string $field1): self - { - $this->field1 = $field1; - return $this; - } +field1; + } + + /** + * @param null|string $field1 + * @return $this + */ + public function setField1(?string $field1): self + { + $this->field1 = $field1; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Field2Field.php b/src/Fields/Dimensions/Level2/Field2Field.php similarity index 86% rename from src/Fields/Level1234/Level2/Field2Field.php rename to src/Fields/Dimensions/Level2/Field2Field.php index c7a2a02d..dee47816 100644 --- a/src/Fields/Level1234/Level2/Field2Field.php +++ b/src/Fields/Dimensions/Level2/Field2Field.php @@ -1,32 +1,32 @@ -field2; - } - - /** - * @param null|string $field2 - * @return $this - */ - public function setField2(?string $field2): self - { - $this->field2 = $field2; - return $this; - } +field2; + } + + /** + * @param null|string $field2 + * @return $this + */ + public function setField2(?string $field2): self + { + $this->field2 = $field2; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Field3Field.php b/src/Fields/Dimensions/Level2/Field3Field.php similarity index 86% rename from src/Fields/Level1234/Level2/Field3Field.php rename to src/Fields/Dimensions/Level2/Field3Field.php index 9ada5734..7b7d761f 100644 --- a/src/Fields/Level1234/Level2/Field3Field.php +++ b/src/Fields/Dimensions/Level2/Field3Field.php @@ -1,32 +1,32 @@ -field3; - } - - /** - * @param null|string $field3 - * @return $this - */ - public function setField3(?string $field3): self - { - $this->field3 = $field3; - return $this; - } +field3; + } + + /** + * @param null|string $field3 + * @return $this + */ + public function setField3(?string $field3): self + { + $this->field3 = $field3; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Field4Field.php b/src/Fields/Dimensions/Level2/Field4Field.php similarity index 86% rename from src/Fields/Level1234/Level2/Field4Field.php rename to src/Fields/Dimensions/Level2/Field4Field.php index 718a5c2e..4c21a66c 100644 --- a/src/Fields/Level1234/Level2/Field4Field.php +++ b/src/Fields/Dimensions/Level2/Field4Field.php @@ -1,32 +1,32 @@ -field4; - } - - /** - * @param null|string $field4 - * @return $this - */ - public function setField4(?string $field4): self - { - $this->field4 = $field4; - return $this; - } +field4; + } + + /** + * @param null|string $field4 + * @return $this + */ + public function setField4(?string $field4): self + { + $this->field4 = $field4; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Field5Field.php b/src/Fields/Dimensions/Level2/Field5Field.php similarity index 86% rename from src/Fields/Level1234/Level2/Field5Field.php rename to src/Fields/Dimensions/Level2/Field5Field.php index 64fa8602..f87166b4 100644 --- a/src/Fields/Level1234/Level2/Field5Field.php +++ b/src/Fields/Dimensions/Level2/Field5Field.php @@ -1,32 +1,32 @@ -field5; - } - - /** - * @param null|string $field5 - * @return $this - */ - public function setField5(?string $field5): self - { - $this->field5 = $field5; - return $this; - } +field5; + } + + /** + * @param null|string $field5 + * @return $this + */ + public function setField5(?string $field5): self + { + $this->field5 = $field5; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Field6Field.php b/src/Fields/Dimensions/Level2/Field6Field.php similarity index 86% rename from src/Fields/Level1234/Level2/Field6Field.php rename to src/Fields/Dimensions/Level2/Field6Field.php index a5246952..eef92278 100644 --- a/src/Fields/Level1234/Level2/Field6Field.php +++ b/src/Fields/Dimensions/Level2/Field6Field.php @@ -1,32 +1,32 @@ -field6; - } - - /** - * @param null|string $field6 - * @return $this - */ - public function setField6(?string $field6): self - { - $this->field6 = $field6; - return $this; - } +field6; + } + + /** + * @param null|string $field6 + * @return $this + */ + public function setField6(?string $field6): self + { + $this->field6 = $field6; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/IbanField.php b/src/Fields/Dimensions/Level2/IbanField.php similarity index 85% rename from src/Fields/Level1234/Level2/IbanField.php rename to src/Fields/Dimensions/Level2/IbanField.php index 11d2c71a..59e38e55 100644 --- a/src/Fields/Level1234/Level2/IbanField.php +++ b/src/Fields/Dimensions/Level2/IbanField.php @@ -1,32 +1,32 @@ -iban; - } - - /** - * @param null|string $iban - * @return $this - */ - public function setIban(?string $iban): self - { - $this->iban = $iban; - return $this; - } +iban; + } + + /** + * @param null|string $iban + * @return $this + */ + public function setIban(?string $iban): self + { + $this->iban = $iban; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/MeansOfPaymentField.php b/src/Fields/Dimensions/Level2/MeansOfPaymentField.php similarity index 91% rename from src/Fields/Level1234/Level2/MeansOfPaymentField.php rename to src/Fields/Dimensions/Level2/MeansOfPaymentField.php index ee8b92df..5c72ccf8 100644 --- a/src/Fields/Level1234/Level2/MeansOfPaymentField.php +++ b/src/Fields/Dimensions/Level2/MeansOfPaymentField.php @@ -1,41 +1,41 @@ -meansOfPayment; - } - - /** - * @param MeansOfPayment|null $meansOfPayment - * @return $this - */ - public function setMeansOfPayment(?MeansOfPayment $meansOfPayment): self - { - $this->meansOfPayment = $meansOfPayment; - return $this; - } - - /** - * @param string|null $meansOfPaymentString - * @return $this - * @throws Exception - */ - public function setMeansOfPaymentFromString(?string $meansOfPaymentString) - { - return $this->setMeansOfPayment(new MeansOfPayment((string)$meansOfPaymentString)); - } +meansOfPayment; + } + + /** + * @param MeansOfPayment|null $meansOfPayment + * @return $this + */ + public function setMeansOfPayment(?MeansOfPayment $meansOfPayment): self + { + $this->meansOfPayment = $meansOfPayment; + return $this; + } + + /** + * @param string|null $meansOfPaymentString + * @return $this + * @throws Exception + */ + public function setMeansOfPaymentFromString(?string $meansOfPaymentString) + { + return $this->setMeansOfPayment(new MeansOfPayment((string)$meansOfPaymentString)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/NatBicCodeField.php b/src/Fields/Dimensions/Level2/NatBicCodeField.php similarity index 86% rename from src/Fields/Level1234/Level2/NatBicCodeField.php rename to src/Fields/Dimensions/Level2/NatBicCodeField.php index 7b90bd8e..13ff2e8f 100644 --- a/src/Fields/Level1234/Level2/NatBicCodeField.php +++ b/src/Fields/Dimensions/Level2/NatBicCodeField.php @@ -1,32 +1,32 @@ -natBicCode; - } - - /** - * @param null|string $natBicCode - * @return $this - */ - public function setNatBicCode(?string $natBicCode): self - { - $this->natBicCode = $natBicCode; - return $this; - } +natBicCode; + } + + /** + * @param null|string $natBicCode + * @return $this + */ + public function setNatBicCode(?string $natBicCode): self + { + $this->natBicCode = $natBicCode; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/PayAvailableField.php b/src/Fields/Dimensions/Level2/PayAvailableField.php similarity index 90% rename from src/Fields/Level1234/Level2/PayAvailableField.php rename to src/Fields/Dimensions/Level2/PayAvailableField.php index 904f2099..19d21afe 100644 --- a/src/Fields/Level1234/Level2/PayAvailableField.php +++ b/src/Fields/Dimensions/Level2/PayAvailableField.php @@ -1,47 +1,47 @@ -payAvailable; - } - - public function getPayAvailableToString(): ?string - { - return ($this->getPayAvailable()) ? 'true' : 'false'; - } - - /** - * @param bool $payAvailable - * @return $this - */ - public function setPayAvailable(?bool $payAvailable): self - { - $this->payAvailable = $payAvailable; - return $this; - } - - /** - * @param string|null $payAvailableString - * @return $this - * @throws Exception - */ - public function setPayAvailableFromString(?string $payAvailableString) - { - return $this->setPayAvailable(filter_var($payAvailableString, FILTER_VALIDATE_BOOLEAN)); - } +payAvailable; + } + + public function getPayAvailableToString(): ?string + { + return ($this->getPayAvailable()) ? 'true' : 'false'; + } + + /** + * @param bool $payAvailable + * @return $this + */ + public function setPayAvailable(?bool $payAvailable): self + { + $this->payAvailable = $payAvailable; + return $this; + } + + /** + * @param string|null $payAvailableString + * @return $this + * @throws Exception + */ + public function setPayAvailableFromString(?string $payAvailableString) + { + return $this->setPayAvailable(filter_var($payAvailableString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/PayCodeField.php b/src/Fields/Dimensions/Level2/PayCodeField.php similarity index 90% rename from src/Fields/Level1234/Level2/PayCodeField.php rename to src/Fields/Dimensions/Level2/PayCodeField.php index 34c7590e..da46e409 100644 --- a/src/Fields/Level1234/Level2/PayCodeField.php +++ b/src/Fields/Dimensions/Level2/PayCodeField.php @@ -1,54 +1,54 @@ -payCode; - } - - public function getPayCodeToString(): ?string - { - if ($this->getPayCode() != null) { - return $this->payCode->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setPayCode(?PayCode $payCode): self - { - $this->payCode = $payCode; - return $this; - } - - /** - * @param string|null $payCodeCode - * @return $this - * @throws Exception - */ - public function setPayCodeFromString(?string $payCodeCode) - { - $payCode = new PayCode(); - $payCode->setCode($payCodeCode); - return $this->setPayCode($payCode); - } -} +payCode; + } + + public function getPayCodeToString(): ?string + { + if ($this->getPayCode() != null) { + return $this->payCode->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setPayCode(?PayCode $payCode): self + { + $this->payCode = $payCode; + return $this; + } + + /** + * @param string|null $payCodeCode + * @return $this + * @throws Exception + */ + public function setPayCodeFromString(?string $payCodeCode) + { + $payCode = new PayCode(); + $payCode->setCode($payCodeCode); + return $this->setPayCode($payCode); + } +} diff --git a/src/Fields/Level1234/Level2/PayCodeIDField.php b/src/Fields/Dimensions/Level2/PayCodeIDField.php similarity index 86% rename from src/Fields/Level1234/Level2/PayCodeIDField.php rename to src/Fields/Dimensions/Level2/PayCodeIDField.php index c6a80501..10c146d7 100644 --- a/src/Fields/Level1234/Level2/PayCodeIDField.php +++ b/src/Fields/Dimensions/Level2/PayCodeIDField.php @@ -1,32 +1,32 @@ -payCodeID; - } - - /** - * @param null|string $payCodeID - * @return $this - */ - public function setPayCodeID(?string $payCodeID): self - { - $this->payCodeID = $payCodeID; - return $this; - } +payCodeID; + } + + /** + * @param null|string $payCodeID + * @return $this + */ + public function setPayCodeID(?string $payCodeID): self + { + $this->payCodeID = $payCodeID; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/PaymentConditionDiscountDaysField.php b/src/Fields/Dimensions/Level2/PaymentConditionDiscountDaysField.php similarity index 89% rename from src/Fields/Level1234/Level2/PaymentConditionDiscountDaysField.php rename to src/Fields/Dimensions/Level2/PaymentConditionDiscountDaysField.php index ce317c34..64f20727 100644 --- a/src/Fields/Level1234/Level2/PaymentConditionDiscountDaysField.php +++ b/src/Fields/Dimensions/Level2/PaymentConditionDiscountDaysField.php @@ -1,32 +1,32 @@ -paymentConditionDiscountDays; - } - - /** - * @param null|int $paymentConditionDiscountDays - * @return $this - */ - public function setPaymentConditionDiscountDays(?int $paymentConditionDiscountDays): self - { - $this->paymentConditionDiscountDays = $paymentConditionDiscountDays; - return $this; - } +paymentConditionDiscountDays; + } + + /** + * @param null|int $paymentConditionDiscountDays + * @return $this + */ + public function setPaymentConditionDiscountDays(?int $paymentConditionDiscountDays): self + { + $this->paymentConditionDiscountDays = $paymentConditionDiscountDays; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/PaymentConditionDiscountPercentageField.php b/src/Fields/Dimensions/Level2/PaymentConditionDiscountPercentageField.php similarity index 90% rename from src/Fields/Level1234/Level2/PaymentConditionDiscountPercentageField.php rename to src/Fields/Dimensions/Level2/PaymentConditionDiscountPercentageField.php index 3939e2f5..8a8beb82 100644 --- a/src/Fields/Level1234/Level2/PaymentConditionDiscountPercentageField.php +++ b/src/Fields/Dimensions/Level2/PaymentConditionDiscountPercentageField.php @@ -1,32 +1,32 @@ -paymentConditionDiscountPercentage; - } - - /** - * @param null|float $paymentConditionDiscountPercentage - * @return $this - */ - public function setPaymentConditionDiscountPercentage(?float $paymentConditionDiscountPercentage): self - { - $this->paymentConditionDiscountPercentage = $paymentConditionDiscountPercentage; - return $this; - } +paymentConditionDiscountPercentage; + } + + /** + * @param null|float $paymentConditionDiscountPercentage + * @return $this + */ + public function setPaymentConditionDiscountPercentage(?float $paymentConditionDiscountPercentage): self + { + $this->paymentConditionDiscountPercentage = $paymentConditionDiscountPercentage; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/PostcodeField.php b/src/Fields/Dimensions/Level2/PostcodeField.php similarity index 87% rename from src/Fields/Level1234/Level2/PostcodeField.php rename to src/Fields/Dimensions/Level2/PostcodeField.php index 8cdf7da1..7738943d 100644 --- a/src/Fields/Level1234/Level2/PostcodeField.php +++ b/src/Fields/Dimensions/Level2/PostcodeField.php @@ -1,32 +1,32 @@ -postcode; - } - - /** - * @param null|string $postcode - * @return $this - */ - public function setPostcode(?string $postcode): self - { - $this->postcode = $postcode; - return $this; - } +postcode; + } + + /** + * @param null|string $postcode + * @return $this + */ + public function setPostcode(?string $postcode): self + { + $this->postcode = $postcode; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/RatioField.php b/src/Fields/Dimensions/Level2/RatioField.php similarity index 85% rename from src/Fields/Level1234/Level2/RatioField.php rename to src/Fields/Dimensions/Level2/RatioField.php index 087c7141..bf6d6b19 100644 --- a/src/Fields/Level1234/Level2/RatioField.php +++ b/src/Fields/Dimensions/Level2/RatioField.php @@ -1,32 +1,32 @@ -ratio; - } - - /** - * @param null|float $ratio - * @return $this - */ - public function setRatio(?float $ratio): self - { - $this->ratio = $ratio; - return $this; - } +ratio; + } + + /** + * @param null|float $ratio + * @return $this + */ + public function setRatio(?float $ratio): self + { + $this->ratio = $ratio; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/RemittanceAdviceSendMailField.php b/src/Fields/Dimensions/Level2/RemittanceAdviceSendMailField.php similarity index 89% rename from src/Fields/Level1234/Level2/RemittanceAdviceSendMailField.php rename to src/Fields/Dimensions/Level2/RemittanceAdviceSendMailField.php index f1b46f79..2c2790dc 100644 --- a/src/Fields/Level1234/Level2/RemittanceAdviceSendMailField.php +++ b/src/Fields/Dimensions/Level2/RemittanceAdviceSendMailField.php @@ -1,32 +1,32 @@ -remittanceAdviceSendMail; - } - - /** - * @param null|string $remittanceAdviceSendMail - * @return $this - */ - public function setRemittanceAdviceSendMail(?string $remittanceAdviceSendMail): self - { - $this->remittanceAdviceSendMail = $remittanceAdviceSendMail; - return $this; - } +remittanceAdviceSendMail; + } + + /** + * @param null|string $remittanceAdviceSendMail + * @return $this + */ + public function setRemittanceAdviceSendMail(?string $remittanceAdviceSendMail): self + { + $this->remittanceAdviceSendMail = $remittanceAdviceSendMail; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/RemittanceAdviceSendTypeField.php b/src/Fields/Dimensions/Level2/RemittanceAdviceSendTypeField.php similarity index 92% rename from src/Fields/Level1234/Level2/RemittanceAdviceSendTypeField.php rename to src/Fields/Dimensions/Level2/RemittanceAdviceSendTypeField.php index b3367ea7..48fda613 100644 --- a/src/Fields/Level1234/Level2/RemittanceAdviceSendTypeField.php +++ b/src/Fields/Dimensions/Level2/RemittanceAdviceSendTypeField.php @@ -1,41 +1,41 @@ -remittanceAdviceSendType; - } - - /** - * @param RemittanceAdviceSendType|null $remittanceAdviceSendType - * @return $this - */ - public function setRemittanceAdviceSendType(?RemittanceAdviceSendType $remittanceAdviceSendType): self - { - $this->remittanceAdviceSendType = $remittanceAdviceSendType; - return $this; - } - - /** - * @param string|null $remittanceAdviceSendTypeString - * @return $this - * @throws Exception - */ - public function setRemittanceAdviceSendTypeFromString(?string $remittanceAdviceSendTypeString) - { - return $this->setRemittanceAdviceSendType(new RemittanceAdviceSendType((string)$remittanceAdviceSendTypeString)); - } +remittanceAdviceSendType; + } + + /** + * @param RemittanceAdviceSendType|null $remittanceAdviceSendType + * @return $this + */ + public function setRemittanceAdviceSendType(?RemittanceAdviceSendType $remittanceAdviceSendType): self + { + $this->remittanceAdviceSendType = $remittanceAdviceSendType; + return $this; + } + + /** + * @param string|null $remittanceAdviceSendTypeString + * @return $this + * @throws Exception + */ + public function setRemittanceAdviceSendTypeFromString(?string $remittanceAdviceSendTypeString) + { + return $this->setRemittanceAdviceSendType(new RemittanceAdviceSendType((string)$remittanceAdviceSendTypeString)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/StateField.php b/src/Fields/Dimensions/Level2/StateField.php similarity index 85% rename from src/Fields/Level1234/Level2/StateField.php rename to src/Fields/Dimensions/Level2/StateField.php index 870f04ef..ec393548 100644 --- a/src/Fields/Level1234/Level2/StateField.php +++ b/src/Fields/Dimensions/Level2/StateField.php @@ -1,32 +1,32 @@ -state; - } - - /** - * @param null|string $state - * @return $this - */ - public function setState(?string $state): self - { - $this->state = $state; - return $this; - } +state; + } + + /** + * @param null|string $state + * @return $this + */ + public function setState(?string $state): self + { + $this->state = $state; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Supplier/BlockedAccountPaymentConditionsIncludeVatField.php b/src/Fields/Dimensions/Level2/Supplier/BlockedAccountPaymentConditionsIncludeVatField.php similarity index 93% rename from src/Fields/Level1234/Level2/Supplier/BlockedAccountPaymentConditionsIncludeVatField.php rename to src/Fields/Dimensions/Level2/Supplier/BlockedAccountPaymentConditionsIncludeVatField.php index 6cb07828..f99bbbd3 100644 --- a/src/Fields/Level1234/Level2/Supplier/BlockedAccountPaymentConditionsIncludeVatField.php +++ b/src/Fields/Dimensions/Level2/Supplier/BlockedAccountPaymentConditionsIncludeVatField.php @@ -1,41 +1,41 @@ -blockedAccountPaymentConditionsIncludeVat; - } - - /** - * @param BlockedAccountPaymentConditionsIncludeVat|null $blockedAccountPaymentConditionsIncludeVat - * @return $this - */ - public function setBlockedAccountPaymentConditionsIncludeVat(?BlockedAccountPaymentConditionsIncludeVat $blockedAccountPaymentConditionsIncludeVat): self - { - $this->blockedAccountPaymentConditionsIncludeVat = $blockedAccountPaymentConditionsIncludeVat; - return $this; - } - - /** - * @param string|null $blockedAccountPaymentConditionsIncludeVatString - * @return $this - * @throws Exception - */ - public function setBlockedAccountPaymentConditionsIncludeVatFromString(?string $blockedAccountPaymentConditionsIncludeVatString) - { - return $this->setBlockedAccountPaymentConditionsIncludeVat(new BlockedAccountPaymentConditionsIncludeVat((string)$blockedAccountPaymentConditionsIncludeVatString)); - } +blockedAccountPaymentConditionsIncludeVat; + } + + /** + * @param BlockedAccountPaymentConditionsIncludeVat|null $blockedAccountPaymentConditionsIncludeVat + * @return $this + */ + public function setBlockedAccountPaymentConditionsIncludeVat(?BlockedAccountPaymentConditionsIncludeVat $blockedAccountPaymentConditionsIncludeVat): self + { + $this->blockedAccountPaymentConditionsIncludeVat = $blockedAccountPaymentConditionsIncludeVat; + return $this; + } + + /** + * @param string|null $blockedAccountPaymentConditionsIncludeVatString + * @return $this + * @throws Exception + */ + public function setBlockedAccountPaymentConditionsIncludeVatFromString(?string $blockedAccountPaymentConditionsIncludeVatString) + { + return $this->setBlockedAccountPaymentConditionsIncludeVat(new BlockedAccountPaymentConditionsIncludeVat((string)$blockedAccountPaymentConditionsIncludeVatString)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Supplier/BlockedAccountPaymentConditionsPercentageField.php b/src/Fields/Dimensions/Level2/Supplier/BlockedAccountPaymentConditionsPercentageField.php similarity index 90% rename from src/Fields/Level1234/Level2/Supplier/BlockedAccountPaymentConditionsPercentageField.php rename to src/Fields/Dimensions/Level2/Supplier/BlockedAccountPaymentConditionsPercentageField.php index 6d50a36a..ddcd9db9 100644 --- a/src/Fields/Level1234/Level2/Supplier/BlockedAccountPaymentConditionsPercentageField.php +++ b/src/Fields/Dimensions/Level2/Supplier/BlockedAccountPaymentConditionsPercentageField.php @@ -1,32 +1,32 @@ -blockedAccountPaymentConditionsPercentage; - } - - /** - * @param null|float $blockedAccountPaymentConditionsPercentage - * @return $this - */ - public function setBlockedAccountPaymentConditionsPercentage(?float $blockedAccountPaymentConditionsPercentage): self - { - $this->blockedAccountPaymentConditionsPercentage = $blockedAccountPaymentConditionsPercentage; - return $this; - } +blockedAccountPaymentConditionsPercentage; + } + + /** + * @param null|float $blockedAccountPaymentConditionsPercentage + * @return $this + */ + public function setBlockedAccountPaymentConditionsPercentage(?float $blockedAccountPaymentConditionsPercentage): self + { + $this->blockedAccountPaymentConditionsPercentage = $blockedAccountPaymentConditionsPercentage; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/Supplier/RelationsReferenceField.php b/src/Fields/Dimensions/Level2/Supplier/RelationsReferenceField.php similarity index 87% rename from src/Fields/Level1234/Level2/Supplier/RelationsReferenceField.php rename to src/Fields/Dimensions/Level2/Supplier/RelationsReferenceField.php index 10d475a5..43289ab7 100644 --- a/src/Fields/Level1234/Level2/Supplier/RelationsReferenceField.php +++ b/src/Fields/Dimensions/Level2/Supplier/RelationsReferenceField.php @@ -1,32 +1,32 @@ -relationsReference; - } - - /** - * @param null|string $relationsReference - * @return $this - */ - public function setRelationsReference(?string $relationsReference): self - { - $this->relationsReference = $relationsReference; - return $this; - } +relationsReference; + } + + /** + * @param null|string $relationsReference + * @return $this + */ + public function setRelationsReference(?string $relationsReference): self + { + $this->relationsReference = $relationsReference; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/TelefaxField.php b/src/Fields/Dimensions/Level2/TelefaxField.php similarity index 86% rename from src/Fields/Level1234/Level2/TelefaxField.php rename to src/Fields/Dimensions/Level2/TelefaxField.php index 1776b518..bec83d24 100644 --- a/src/Fields/Level1234/Level2/TelefaxField.php +++ b/src/Fields/Dimensions/Level2/TelefaxField.php @@ -1,32 +1,32 @@ -telefax; - } - - /** - * @param null|string $telefax - * @return $this - */ - public function setTelefax(?string $telefax): self - { - $this->telefax = $telefax; - return $this; - } +telefax; + } + + /** + * @param null|string $telefax + * @return $this + */ + public function setTelefax(?string $telefax): self + { + $this->telefax = $telefax; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/TelephoneField.php b/src/Fields/Dimensions/Level2/TelephoneField.php similarity index 86% rename from src/Fields/Level1234/Level2/TelephoneField.php rename to src/Fields/Dimensions/Level2/TelephoneField.php index 8c995787..ec50331c 100644 --- a/src/Fields/Level1234/Level2/TelephoneField.php +++ b/src/Fields/Dimensions/Level2/TelephoneField.php @@ -1,32 +1,32 @@ -telephone; - } - - /** - * @param null|string $telephone - * @return $this - */ - public function setTelephone(?string $telephone): self - { - $this->telephone = $telephone; - return $this; - } +telephone; + } + + /** + * @param null|string $telephone + * @return $this + */ + public function setTelephone(?string $telephone): self + { + $this->telephone = $telephone; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level2/TypeField.php b/src/Fields/Dimensions/Level2/TypeField.php similarity index 93% rename from src/Fields/Level1234/Level2/TypeField.php rename to src/Fields/Dimensions/Level2/TypeField.php index ff76023a..51c7ed1d 100644 --- a/src/Fields/Level1234/Level2/TypeField.php +++ b/src/Fields/Dimensions/Level2/TypeField.php @@ -1,6 +1,6 @@ website; - } - - /** - * @param null|string $website - * @return $this - */ - public function setWebsite(?string $website): self - { - $this->website = $website; - return $this; - } +website; + } + + /** + * @param null|string $website + * @return $this + */ + public function setWebsite(?string $website): self + { + $this->website = $website; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/AuthoriserField.php b/src/Fields/Dimensions/Level34/AuthoriserField.php similarity index 90% rename from src/Fields/Level1234/Level34/AuthoriserField.php rename to src/Fields/Dimensions/Level34/AuthoriserField.php index 8b7b667d..4d9f458e 100644 --- a/src/Fields/Level1234/Level34/AuthoriserField.php +++ b/src/Fields/Dimensions/Level34/AuthoriserField.php @@ -1,54 +1,54 @@ -authoriser; - } - - public function getAuthoriserToString(): ?string - { - if ($this->getAuthoriser() != null) { - return $this->authoriser->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setAuthoriser(?User $authoriser): self - { - $this->authoriser = $authoriser; - return $this; - } - - /** - * @param string|null $authoriserCode - * @return $this - * @throws Exception - */ - public function setAuthoriserFromString(?string $authoriserCode) - { - $authoriser = new User(); - $authoriser->setCode($authoriserCode); - return $this->setAuthoriser($authoriser); - } -} +authoriser; + } + + public function getAuthoriserToString(): ?string + { + if ($this->getAuthoriser() != null) { + return $this->authoriser->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setAuthoriser(?User $authoriser): self + { + $this->authoriser = $authoriser; + return $this; + } + + /** + * @param string|null $authoriserCode + * @return $this + * @throws Exception + */ + public function setAuthoriserFromString(?string $authoriserCode) + { + $authoriser = new User(); + $authoriser->setCode($authoriserCode); + return $this->setAuthoriser($authoriser); + } +} diff --git a/src/Fields/Level1234/Level34/AuthoriserInheritField.php b/src/Fields/Dimensions/Level34/AuthoriserInheritField.php similarity index 91% rename from src/Fields/Level1234/Level34/AuthoriserInheritField.php rename to src/Fields/Dimensions/Level34/AuthoriserInheritField.php index 2bcd3efe..4a985fd8 100644 --- a/src/Fields/Level1234/Level34/AuthoriserInheritField.php +++ b/src/Fields/Dimensions/Level34/AuthoriserInheritField.php @@ -1,47 +1,47 @@ -authoriserInherit; - } - - public function getAuthoriserInheritToString(): ?string - { - return ($this->getAuthoriserInherit()) ? 'true' : 'false'; - } - - /** - * @param bool $authoriserInherit - * @return $this - */ - public function setAuthoriserInherit(?bool $authoriserInherit): self - { - $this->authoriserInherit = $authoriserInherit; - return $this; - } - - /** - * @param string|null $authoriserInheritString - * @return $this - * @throws Exception - */ - public function setAuthoriserInheritFromString(?string $authoriserInheritString) - { - return $this->setAuthoriserInherit(filter_var($authoriserInheritString, FILTER_VALIDATE_BOOLEAN)); - } +authoriserInherit; + } + + public function getAuthoriserInheritToString(): ?string + { + return ($this->getAuthoriserInherit()) ? 'true' : 'false'; + } + + /** + * @param bool $authoriserInherit + * @return $this + */ + public function setAuthoriserInherit(?bool $authoriserInherit): self + { + $this->authoriserInherit = $authoriserInherit; + return $this; + } + + /** + * @param string|null $authoriserInheritString + * @return $this + * @throws Exception + */ + public function setAuthoriserInheritFromString(?string $authoriserInheritString) + { + return $this->setAuthoriserInherit(filter_var($authoriserInheritString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/AuthoriserLockedField.php b/src/Fields/Dimensions/Level34/AuthoriserLockedField.php similarity index 91% rename from src/Fields/Level1234/Level34/AuthoriserLockedField.php rename to src/Fields/Dimensions/Level34/AuthoriserLockedField.php index 200c5535..3c10b1cd 100644 --- a/src/Fields/Level1234/Level34/AuthoriserLockedField.php +++ b/src/Fields/Dimensions/Level34/AuthoriserLockedField.php @@ -1,47 +1,47 @@ -authoriserLocked; - } - - public function getAuthoriserLockedToString(): ?string - { - return ($this->getAuthoriserLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $authoriserLocked - * @return $this - */ - public function setAuthoriserLocked(?bool $authoriserLocked): self - { - $this->authoriserLocked = $authoriserLocked; - return $this; - } - - /** - * @param string|null $authoriserLockedString - * @return $this - * @throws Exception - */ - public function setAuthoriserLockedFromString(?string $authoriserLockedString) - { - return $this->setAuthoriserLocked(filter_var($authoriserLockedString, FILTER_VALIDATE_BOOLEAN)); - } +authoriserLocked; + } + + public function getAuthoriserLockedToString(): ?string + { + return ($this->getAuthoriserLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $authoriserLocked + * @return $this + */ + public function setAuthoriserLocked(?bool $authoriserLocked): self + { + $this->authoriserLocked = $authoriserLocked; + return $this; + } + + /** + * @param string|null $authoriserLockedString + * @return $this + * @throws Exception + */ + public function setAuthoriserLockedFromString(?string $authoriserLockedString) + { + return $this->setAuthoriserLocked(filter_var($authoriserLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/BillableField.php b/src/Fields/Dimensions/Level34/BillableField.php similarity index 90% rename from src/Fields/Level1234/Level34/BillableField.php rename to src/Fields/Dimensions/Level34/BillableField.php index f5baf53f..ed5d5b20 100644 --- a/src/Fields/Level1234/Level34/BillableField.php +++ b/src/Fields/Dimensions/Level34/BillableField.php @@ -1,47 +1,47 @@ -billable; - } - - public function getBillableToString(): ?string - { - return ($this->getBillable()) ? 'true' : 'false'; - } - - /** - * @param bool $billable - * @return $this - */ - public function setBillable(?bool $billable): self - { - $this->billable = $billable; - return $this; - } - - /** - * @param string|null $billableString - * @return $this - * @throws Exception - */ - public function setBillableFromString(?string $billableString) - { - return $this->setBillable(filter_var($billableString, FILTER_VALIDATE_BOOLEAN)); - } +billable; + } + + public function getBillableToString(): ?string + { + return ($this->getBillable()) ? 'true' : 'false'; + } + + /** + * @param bool $billable + * @return $this + */ + public function setBillable(?bool $billable): self + { + $this->billable = $billable; + return $this; + } + + /** + * @param string|null $billableString + * @return $this + * @throws Exception + */ + public function setBillableFromString(?string $billableString) + { + return $this->setBillable(filter_var($billableString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/BillableForRatioField.php b/src/Fields/Dimensions/Level34/BillableForRatioField.php similarity index 91% rename from src/Fields/Level1234/Level34/BillableForRatioField.php rename to src/Fields/Dimensions/Level34/BillableForRatioField.php index c7c7675f..600c9309 100644 --- a/src/Fields/Level1234/Level34/BillableForRatioField.php +++ b/src/Fields/Dimensions/Level34/BillableForRatioField.php @@ -1,47 +1,47 @@ -billableForRatio; - } - - public function getBillableForRatioToString(): ?string - { - return ($this->getBillableForRatio()) ? 'true' : 'false'; - } - - /** - * @param bool $billableForRatio - * @return $this - */ - public function setBillableForRatio(?bool $billableForRatio): self - { - $this->billableForRatio = $billableForRatio; - return $this; - } - - /** - * @param string|null $billableForRatioString - * @return $this - * @throws Exception - */ - public function setBillableForRatioFromString(?string $billableForRatioString) - { - return $this->setBillableForRatio(filter_var($billableForRatioString, FILTER_VALIDATE_BOOLEAN)); - } +billableForRatio; + } + + public function getBillableForRatioToString(): ?string + { + return ($this->getBillableForRatio()) ? 'true' : 'false'; + } + + /** + * @param bool $billableForRatio + * @return $this + */ + public function setBillableForRatio(?bool $billableForRatio): self + { + $this->billableForRatio = $billableForRatio; + return $this; + } + + /** + * @param string|null $billableForRatioString + * @return $this + * @throws Exception + */ + public function setBillableForRatioFromString(?string $billableForRatioString) + { + return $this->setBillableForRatio(filter_var($billableForRatioString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/BillableInheritField.php b/src/Fields/Dimensions/Level34/BillableInheritField.php similarity index 91% rename from src/Fields/Level1234/Level34/BillableInheritField.php rename to src/Fields/Dimensions/Level34/BillableInheritField.php index 01b2fcca..7a1c9daf 100644 --- a/src/Fields/Level1234/Level34/BillableInheritField.php +++ b/src/Fields/Dimensions/Level34/BillableInheritField.php @@ -1,47 +1,47 @@ -billableInherit; - } - - public function getBillableInheritToString(): ?string - { - return ($this->getBillableInherit()) ? 'true' : 'false'; - } - - /** - * @param bool $billableInherit - * @return $this - */ - public function setBillableInherit(?bool $billableInherit): self - { - $this->billableInherit = $billableInherit; - return $this; - } - - /** - * @param string|null $billableInheritString - * @return $this - * @throws Exception - */ - public function setBillableInheritFromString(?string $billableInheritString) - { - return $this->setBillableInherit(filter_var($billableInheritString, FILTER_VALIDATE_BOOLEAN)); - } +billableInherit; + } + + public function getBillableInheritToString(): ?string + { + return ($this->getBillableInherit()) ? 'true' : 'false'; + } + + /** + * @param bool $billableInherit + * @return $this + */ + public function setBillableInherit(?bool $billableInherit): self + { + $this->billableInherit = $billableInherit; + return $this; + } + + /** + * @param string|null $billableInheritString + * @return $this + * @throws Exception + */ + public function setBillableInheritFromString(?string $billableInheritString) + { + return $this->setBillableInherit(filter_var($billableInheritString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/BillableLockedField.php b/src/Fields/Dimensions/Level34/BillableLockedField.php similarity index 91% rename from src/Fields/Level1234/Level34/BillableLockedField.php rename to src/Fields/Dimensions/Level34/BillableLockedField.php index 80214279..80f313f8 100644 --- a/src/Fields/Level1234/Level34/BillableLockedField.php +++ b/src/Fields/Dimensions/Level34/BillableLockedField.php @@ -1,47 +1,47 @@ -billableLocked; - } - - public function getBillableLockedToString(): ?string - { - return ($this->getBillableLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $billableLocked - * @return $this - */ - public function setBillableLocked(?bool $billableLocked): self - { - $this->billableLocked = $billableLocked; - return $this; - } - - /** - * @param string|null $billableLockedString - * @return $this - * @throws Exception - */ - public function setBillableLockedFromString(?string $billableLockedString) - { - return $this->setBillableLocked(filter_var($billableLockedString, FILTER_VALIDATE_BOOLEAN)); - } +billableLocked; + } + + public function getBillableLockedToString(): ?string + { + return ($this->getBillableLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $billableLocked + * @return $this + */ + public function setBillableLocked(?bool $billableLocked): self + { + $this->billableLocked = $billableLocked; + return $this; + } + + /** + * @param string|null $billableLockedString + * @return $this + * @throws Exception + */ + public function setBillableLockedFromString(?string $billableLockedString) + { + return $this->setBillableLocked(filter_var($billableLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/CustomerInheritField.php b/src/Fields/Dimensions/Level34/CustomerInheritField.php similarity index 91% rename from src/Fields/Level1234/Level34/CustomerInheritField.php rename to src/Fields/Dimensions/Level34/CustomerInheritField.php index 9689efbe..b974b8b9 100644 --- a/src/Fields/Level1234/Level34/CustomerInheritField.php +++ b/src/Fields/Dimensions/Level34/CustomerInheritField.php @@ -1,47 +1,47 @@ -customerInherit; - } - - public function getCustomerInheritToString(): ?string - { - return ($this->getCustomerInherit()) ? 'true' : 'false'; - } - - /** - * @param bool $customerInherit - * @return $this - */ - public function setCustomerInherit(?bool $customerInherit): self - { - $this->customerInherit = $customerInherit; - return $this; - } - - /** - * @param string|null $customerInheritString - * @return $this - * @throws Exception - */ - public function setCustomerInheritFromString(?string $customerInheritString) - { - return $this->setCustomerInherit(filter_var($customerInheritString, FILTER_VALIDATE_BOOLEAN)); - } +customerInherit; + } + + public function getCustomerInheritToString(): ?string + { + return ($this->getCustomerInherit()) ? 'true' : 'false'; + } + + /** + * @param bool $customerInherit + * @return $this + */ + public function setCustomerInherit(?bool $customerInherit): self + { + $this->customerInherit = $customerInherit; + return $this; + } + + /** + * @param string|null $customerInheritString + * @return $this + * @throws Exception + */ + public function setCustomerInheritFromString(?string $customerInheritString) + { + return $this->setCustomerInherit(filter_var($customerInheritString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/CustomerLockedField.php b/src/Fields/Dimensions/Level34/CustomerLockedField.php similarity index 91% rename from src/Fields/Level1234/Level34/CustomerLockedField.php rename to src/Fields/Dimensions/Level34/CustomerLockedField.php index 7bd75018..f7940452 100644 --- a/src/Fields/Level1234/Level34/CustomerLockedField.php +++ b/src/Fields/Dimensions/Level34/CustomerLockedField.php @@ -1,47 +1,47 @@ -customerLocked; - } - - public function getCustomerLockedToString(): ?string - { - return ($this->getCustomerLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $customerLocked - * @return $this - */ - public function setCustomerLocked(?bool $customerLocked): self - { - $this->customerLocked = $customerLocked; - return $this; - } - - /** - * @param string|null $customerLockedString - * @return $this - * @throws Exception - */ - public function setCustomerLockedFromString(?string $customerLockedString) - { - return $this->setCustomerLocked(filter_var($customerLockedString, FILTER_VALIDATE_BOOLEAN)); - } +customerLocked; + } + + public function getCustomerLockedToString(): ?string + { + return ($this->getCustomerLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $customerLocked + * @return $this + */ + public function setCustomerLocked(?bool $customerLocked): self + { + $this->customerLocked = $customerLocked; + return $this; + } + + /** + * @param string|null $customerLockedString + * @return $this + * @throws Exception + */ + public function setCustomerLockedFromString(?string $customerLockedString) + { + return $this->setCustomerLocked(filter_var($customerLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/AmountLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/AmountLockedField.php similarity index 89% rename from src/Fields/Level1234/Level34/FixedAsset/AmountLockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/AmountLockedField.php index a5b56b51..470b92d7 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/AmountLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/AmountLockedField.php @@ -1,47 +1,47 @@ -amountLocked; - } - - public function getAmountLockedToString(): ?string - { - return ($this->getAmountLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $amountLocked - * @return $this - */ - public function setAmountLocked(?bool $amountLocked): self - { - $this->amountLocked = $amountLocked; - return $this; - } - - /** - * @param string|null $amountLockedString - * @return $this - * @throws Exception - */ - public function setAmountLockedFromString(?string $amountLockedString) - { - return $this->setAmountLocked(filter_var($amountLockedString, FILTER_VALIDATE_BOOLEAN)); - } +amountLocked; + } + + public function getAmountLockedToString(): ?string + { + return ($this->getAmountLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $amountLocked + * @return $this + */ + public function setAmountLocked(?bool $amountLocked): self + { + $this->amountLocked = $amountLocked; + return $this; + } + + /** + * @param string|null $amountLockedString + * @return $this + * @throws Exception + */ + public function setAmountLockedFromString(?string $amountLockedString) + { + return $this->setAmountLocked(filter_var($amountLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/BeginPeriodField.php b/src/Fields/Dimensions/Level34/FixedAsset/BeginPeriodField.php similarity index 87% rename from src/Fields/Level1234/Level34/FixedAsset/BeginPeriodField.php rename to src/Fields/Dimensions/Level34/FixedAsset/BeginPeriodField.php index 1fac240a..cbe18d03 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/BeginPeriodField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/BeginPeriodField.php @@ -1,37 +1,37 @@ -beginPeriod; - } - - /** - * @param string|null $beginPeriod - * @return $this - */ - public function setBeginPeriod(?string $beginPeriod): self - { - if (!preg_match("!\\d{4}/\\d{1,2}!", $beginPeriod)) { - $beginPeriod = ''; - } - - $this->beginPeriod = $beginPeriod; - - return $this; - } -} +beginPeriod; + } + + /** + * @param string|null $beginPeriod + * @return $this + */ + public function setBeginPeriod(?string $beginPeriod): self + { + if (!preg_match("!\\d{4}/\\d{1,2}!", $beginPeriod)) { + $beginPeriod = ''; + } + + $this->beginPeriod = $beginPeriod; + + return $this; + } +} diff --git a/src/Fields/Level1234/Level34/FixedAsset/BeginPeriodLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/BeginPeriodLockedField.php similarity index 90% rename from src/Fields/Level1234/Level34/FixedAsset/BeginPeriodLockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/BeginPeriodLockedField.php index 8fe2e0c0..d6e66eb3 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/BeginPeriodLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/BeginPeriodLockedField.php @@ -1,47 +1,47 @@ -beginPeriodLocked; - } - - public function getBeginPeriodLockedToString(): ?string - { - return ($this->getBeginPeriodLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $beginPeriodLocked - * @return $this - */ - public function setBeginPeriodLocked(?bool $beginPeriodLocked): self - { - $this->beginPeriodLocked = $beginPeriodLocked; - return $this; - } - - /** - * @param string|null $beginPeriodLockedString - * @return $this - * @throws Exception - */ - public function setBeginPeriodLockedFromString(?string $beginPeriodLockedString) - { - return $this->setBeginPeriodLocked(filter_var($beginPeriodLockedString, FILTER_VALIDATE_BOOLEAN)); - } +beginPeriodLocked; + } + + public function getBeginPeriodLockedToString(): ?string + { + return ($this->getBeginPeriodLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $beginPeriodLocked + * @return $this + */ + public function setBeginPeriodLocked(?bool $beginPeriodLocked): self + { + $this->beginPeriodLocked = $beginPeriodLocked; + return $this; + } + + /** + * @param string|null $beginPeriodLockedString + * @return $this + * @throws Exception + */ + public function setBeginPeriodLockedFromString(?string $beginPeriodLockedString) + { + return $this->setBeginPeriodLocked(filter_var($beginPeriodLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/CodeField.php b/src/Fields/Dimensions/Level34/FixedAsset/CodeField.php similarity index 90% rename from src/Fields/Level1234/Level34/FixedAsset/CodeField.php rename to src/Fields/Dimensions/Level34/FixedAsset/CodeField.php index 55151704..1959c885 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/CodeField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/CodeField.php @@ -1,6 +1,6 @@ dim1Locked; - } - - public function getDim1LockedToString(): ?string - { - return ($this->getDim1Locked()) ? 'true' : 'false'; - } - - /** - * @param bool $dim1Locked - * @return $this - */ - public function setDim1Locked(?bool $dim1Locked): self - { - $this->dim1Locked = $dim1Locked; - return $this; - } - - /** - * @param string|null $dim1LockedString - * @return $this - * @throws Exception - */ - public function setDim1LockedFromString(?string $dim1LockedString) - { - return $this->setDim1Locked(filter_var($dim1LockedString, FILTER_VALIDATE_BOOLEAN)); - } +dim1Locked; + } + + public function getDim1LockedToString(): ?string + { + return ($this->getDim1Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $dim1Locked + * @return $this + */ + public function setDim1Locked(?bool $dim1Locked): self + { + $this->dim1Locked = $dim1Locked; + return $this; + } + + /** + * @param string|null $dim1LockedString + * @return $this + * @throws Exception + */ + public function setDim1LockedFromString(?string $dim1LockedString) + { + return $this->setDim1Locked(filter_var($dim1LockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim2Field.php similarity index 88% rename from src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php rename to src/Fields/Dimensions/Level34/FixedAsset/Dim2Field.php index ae919497..a3f33477 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/Dim2Field.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim2Field.php @@ -1,54 +1,54 @@ -dim2; - } - - public function getDim2ToString(): ?string - { - if ($this->getDim2() != null) { - return $this->dim2->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setDim2($dim2): self - { - $this->dim2 = $dim2; - return $this; - } - - /** - * @param string|null $dim2Code - * @return $this - * @throws Exception - */ - public function setDim2FromString(?string $dim2Code) - { - $dim2 = new Dummy(); - $dim2->setCode($dim2Code); - return $this->setDim2($dim2); - } -} +dim2; + } + + public function getDim2ToString(): ?string + { + if ($this->getDim2() != null) { + return $this->dim2->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDim2($dim2): self + { + $this->dim2 = $dim2; + return $this; + } + + /** + * @param string|null $dim2Code + * @return $this + * @throws Exception + */ + public function setDim2FromString(?string $dim2Code) + { + $dim2 = new Dummy(); + $dim2->setCode($dim2Code); + return $this->setDim2($dim2); + } +} diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim2LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim2LockedField.php similarity index 89% rename from src/Fields/Level1234/Level34/FixedAsset/Dim2LockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/Dim2LockedField.php index ba1a8e90..b2712b10 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/Dim2LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim2LockedField.php @@ -1,47 +1,47 @@ -dim2Locked; - } - - public function getDim2LockedToString(): ?string - { - return ($this->getDim2Locked()) ? 'true' : 'false'; - } - - /** - * @param bool $dim2Locked - * @return $this - */ - public function setDim2Locked(?bool $dim2Locked): self - { - $this->dim2Locked = $dim2Locked; - return $this; - } - - /** - * @param string|null $dim2LockedString - * @return $this - * @throws Exception - */ - public function setDim2LockedFromString(?string $dim2LockedString) - { - return $this->setDim2Locked(filter_var($dim2LockedString, FILTER_VALIDATE_BOOLEAN)); - } +dim2Locked; + } + + public function getDim2LockedToString(): ?string + { + return ($this->getDim2Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $dim2Locked + * @return $this + */ + public function setDim2Locked(?bool $dim2Locked): self + { + $this->dim2Locked = $dim2Locked; + return $this; + } + + /** + * @param string|null $dim2LockedString + * @return $this + * @throws Exception + */ + public function setDim2LockedFromString(?string $dim2LockedString) + { + return $this->setDim2Locked(filter_var($dim2LockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim3Field.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim3Field.php similarity index 88% rename from src/Fields/Level1234/Level34/FixedAsset/Dim3Field.php rename to src/Fields/Dimensions/Level34/FixedAsset/Dim3Field.php index 71b36d14..9889f5c2 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/Dim3Field.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim3Field.php @@ -1,54 +1,54 @@ -dim3; - } - - public function getDim3ToString(): ?string - { - if ($this->getDim3() != null) { - return $this->dim3->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setDim3($dim3): self - { - $this->dim3 = $dim3; - return $this; - } - - /** - * @param string|null $dim3Code - * @return $this - * @throws Exception - */ - public function setDim3FromString(?string $dim3Code) - { - $dim3 = new Dummy(); - $dim3->setCode($dim3Code); - return $this->setDim3($dim3); - } -} +dim3; + } + + public function getDim3ToString(): ?string + { + if ($this->getDim3() != null) { + return $this->dim3->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDim3($dim3): self + { + $this->dim3 = $dim3; + return $this; + } + + /** + * @param string|null $dim3Code + * @return $this + * @throws Exception + */ + public function setDim3FromString(?string $dim3Code) + { + $dim3 = new Dummy(); + $dim3->setCode($dim3Code); + return $this->setDim3($dim3); + } +} diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim3LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim3LockedField.php similarity index 89% rename from src/Fields/Level1234/Level34/FixedAsset/Dim3LockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/Dim3LockedField.php index f8492a58..b11c51fc 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/Dim3LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim3LockedField.php @@ -1,47 +1,47 @@ -dim3Locked; - } - - public function getDim3LockedToString(): ?string - { - return ($this->getDim3Locked()) ? 'true' : 'false'; - } - - /** - * @param bool $dim3Locked - * @return $this - */ - public function setDim3Locked(?bool $dim3Locked): self - { - $this->dim3Locked = $dim3Locked; - return $this; - } - - /** - * @param string|null $dim3LockedString - * @return $this - * @throws Exception - */ - public function setDim3LockedFromString(?string $dim3LockedString) - { - return $this->setDim3Locked(filter_var($dim3LockedString, FILTER_VALIDATE_BOOLEAN)); - } +dim3Locked; + } + + public function getDim3LockedToString(): ?string + { + return ($this->getDim3Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $dim3Locked + * @return $this + */ + public function setDim3Locked(?bool $dim3Locked): self + { + $this->dim3Locked = $dim3Locked; + return $this; + } + + /** + * @param string|null $dim3LockedString + * @return $this + * @throws Exception + */ + public function setDim3LockedFromString(?string $dim3LockedString) + { + return $this->setDim3Locked(filter_var($dim3LockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim4Field.php similarity index 88% rename from src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php rename to src/Fields/Dimensions/Level34/FixedAsset/Dim4Field.php index 228faea0..6cbbdb66 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/Dim4Field.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim4Field.php @@ -1,54 +1,54 @@ -dim4; - } - - public function getDim4ToString(): ?string - { - if ($this->getDim4() != null) { - return $this->dim4->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setDim4($dim4): self - { - $this->dim4 = $dim4; - return $this; - } - - /** - * @param string|null $dim4Code - * @return $this - * @throws Exception - */ - public function setDim4FromString(?string $dim4Code) - { - $dim4 = new Dummy(); - $dim4->setCode($dim4Code); - return $this->setDim4($dim4); - } -} +dim4; + } + + public function getDim4ToString(): ?string + { + if ($this->getDim4() != null) { + return $this->dim4->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDim4($dim4): self + { + $this->dim4 = $dim4; + return $this; + } + + /** + * @param string|null $dim4Code + * @return $this + * @throws Exception + */ + public function setDim4FromString(?string $dim4Code) + { + $dim4 = new Dummy(); + $dim4->setCode($dim4Code); + return $this->setDim4($dim4); + } +} diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim4LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim4LockedField.php similarity index 89% rename from src/Fields/Level1234/Level34/FixedAsset/Dim4LockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/Dim4LockedField.php index ff899ab7..f384f956 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/Dim4LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim4LockedField.php @@ -1,47 +1,47 @@ -dim4Locked; - } - - public function getDim4LockedToString(): ?string - { - return ($this->getDim4Locked()) ? 'true' : 'false'; - } - - /** - * @param bool $dim4Locked - * @return $this - */ - public function setDim4Locked(?bool $dim4Locked): self - { - $this->dim4Locked = $dim4Locked; - return $this; - } - - /** - * @param string|null $dim4LockedString - * @return $this - * @throws Exception - */ - public function setDim4LockedFromString(?string $dim4LockedString) - { - return $this->setDim4Locked(filter_var($dim4LockedString, FILTER_VALIDATE_BOOLEAN)); - } +dim4Locked; + } + + public function getDim4LockedToString(): ?string + { + return ($this->getDim4Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $dim4Locked + * @return $this + */ + public function setDim4Locked(?bool $dim4Locked): self + { + $this->dim4Locked = $dim4Locked; + return $this; + } + + /** + * @param string|null $dim4LockedString + * @return $this + * @throws Exception + */ + public function setDim4LockedFromString(?string $dim4LockedString) + { + return $this->setDim4Locked(filter_var($dim4LockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim5Field.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim5Field.php similarity index 88% rename from src/Fields/Level1234/Level34/FixedAsset/Dim5Field.php rename to src/Fields/Dimensions/Level34/FixedAsset/Dim5Field.php index c66489e7..3629ff38 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/Dim5Field.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim5Field.php @@ -1,54 +1,54 @@ -dim5; - } - - public function getDim5ToString(): ?string - { - if ($this->getDim5() != null) { - return $this->dim5->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setDim5($dim5): self - { - $this->dim5 = $dim5; - return $this; - } - - /** - * @param string|null $dim5Code - * @return $this - * @throws Exception - */ - public function setDim5FromString(?string $dim5Code) - { - $dim5 = new Dummy(); - $dim5->setCode($dim5Code); - return $this->setDim5($dim5); - } -} +dim5; + } + + public function getDim5ToString(): ?string + { + if ($this->getDim5() != null) { + return $this->dim5->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDim5($dim5): self + { + $this->dim5 = $dim5; + return $this; + } + + /** + * @param string|null $dim5Code + * @return $this + * @throws Exception + */ + public function setDim5FromString(?string $dim5Code) + { + $dim5 = new Dummy(); + $dim5->setCode($dim5Code); + return $this->setDim5($dim5); + } +} diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim5LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim5LockedField.php similarity index 89% rename from src/Fields/Level1234/Level34/FixedAsset/Dim5LockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/Dim5LockedField.php index 97d86b10..fce648f0 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/Dim5LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim5LockedField.php @@ -1,47 +1,47 @@ -dim5Locked; - } - - public function getDim5LockedToString(): ?string - { - return ($this->getDim5Locked()) ? 'true' : 'false'; - } - - /** - * @param bool $dim5Locked - * @return $this - */ - public function setDim5Locked(?bool $dim5Locked): self - { - $this->dim5Locked = $dim5Locked; - return $this; - } - - /** - * @param string|null $dim5LockedString - * @return $this - * @throws Exception - */ - public function setDim5LockedFromString(?string $dim5LockedString) - { - return $this->setDim5Locked(filter_var($dim5LockedString, FILTER_VALIDATE_BOOLEAN)); - } +dim5Locked; + } + + public function getDim5LockedToString(): ?string + { + return ($this->getDim5Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $dim5Locked + * @return $this + */ + public function setDim5Locked(?bool $dim5Locked): self + { + $this->dim5Locked = $dim5Locked; + return $this; + } + + /** + * @param string|null $dim5LockedString + * @return $this + * @throws Exception + */ + public function setDim5LockedFromString(?string $dim5LockedString) + { + return $this->setDim5Locked(filter_var($dim5LockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim6Field.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim6Field.php similarity index 88% rename from src/Fields/Level1234/Level34/FixedAsset/Dim6Field.php rename to src/Fields/Dimensions/Level34/FixedAsset/Dim6Field.php index cbe05420..128488f3 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/Dim6Field.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim6Field.php @@ -1,54 +1,54 @@ -dim6; - } - - public function getDim6ToString(): ?string - { - if ($this->getDim6() != null) { - return $this->dim6->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setDim6($dim6): self - { - $this->dim6 = $dim6; - return $this; - } - - /** - * @param string|null $dim6Code - * @return $this - * @throws Exception - */ - public function setDim6FromString(?string $dim6Code) - { - $dim6 = new Dummy(); - $dim6->setCode($dim6Code); - return $this->setDim6($dim6); - } -} +dim6; + } + + public function getDim6ToString(): ?string + { + if ($this->getDim6() != null) { + return $this->dim6->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDim6($dim6): self + { + $this->dim6 = $dim6; + return $this; + } + + /** + * @param string|null $dim6Code + * @return $this + * @throws Exception + */ + public function setDim6FromString(?string $dim6Code) + { + $dim6 = new Dummy(); + $dim6->setCode($dim6Code); + return $this->setDim6($dim6); + } +} diff --git a/src/Fields/Level1234/Level34/FixedAsset/Dim6LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim6LockedField.php similarity index 89% rename from src/Fields/Level1234/Level34/FixedAsset/Dim6LockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/Dim6LockedField.php index 45021937..d6b9408c 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/Dim6LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim6LockedField.php @@ -1,47 +1,47 @@ -dim6Locked; - } - - public function getDim6LockedToString(): ?string - { - return ($this->getDim6Locked()) ? 'true' : 'false'; - } - - /** - * @param bool $dim6Locked - * @return $this - */ - public function setDim6Locked(?bool $dim6Locked): self - { - $this->dim6Locked = $dim6Locked; - return $this; - } - - /** - * @param string|null $dim6LockedString - * @return $this - * @throws Exception - */ - public function setDim6LockedFromString(?string $dim6LockedString) - { - return $this->setDim6Locked(filter_var($dim6LockedString, FILTER_VALIDATE_BOOLEAN)); - } +dim6Locked; + } + + public function getDim6LockedToString(): ?string + { + return ($this->getDim6Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $dim6Locked + * @return $this + */ + public function setDim6Locked(?bool $dim6Locked): self + { + $this->dim6Locked = $dim6Locked; + return $this; + } + + /** + * @param string|null $dim6LockedString + * @return $this + * @throws Exception + */ + public function setDim6LockedFromString(?string $dim6LockedString) + { + return $this->setDim6Locked(filter_var($dim6LockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/FreeText1LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText1LockedField.php similarity index 90% rename from src/Fields/Level1234/Level34/FixedAsset/FreeText1LockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/FreeText1LockedField.php index f6e3f31b..670505ee 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/FreeText1LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText1LockedField.php @@ -1,47 +1,47 @@ -freeText1Locked; - } - - public function getFreeText1LockedToString(): ?string - { - return ($this->getFreeText1Locked()) ? 'true' : 'false'; - } - - /** - * @param bool $freeText1Locked - * @return $this - */ - public function setFreeText1Locked(?bool $freeText1Locked): self - { - $this->freeText1Locked = $freeText1Locked; - return $this; - } - - /** - * @param string|null $freeText1LockedString - * @return $this - * @throws Exception - */ - public function setFreeText1LockedFromString(?string $freeText1LockedString) - { - return $this->setFreeText1Locked(filter_var($freeText1LockedString, FILTER_VALIDATE_BOOLEAN)); - } +freeText1Locked; + } + + public function getFreeText1LockedToString(): ?string + { + return ($this->getFreeText1Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $freeText1Locked + * @return $this + */ + public function setFreeText1Locked(?bool $freeText1Locked): self + { + $this->freeText1Locked = $freeText1Locked; + return $this; + } + + /** + * @param string|null $freeText1LockedString + * @return $this + * @throws Exception + */ + public function setFreeText1LockedFromString(?string $freeText1LockedString) + { + return $this->setFreeText1Locked(filter_var($freeText1LockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/FreeText2LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText2LockedField.php similarity index 90% rename from src/Fields/Level1234/Level34/FixedAsset/FreeText2LockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/FreeText2LockedField.php index 7d7b1f1e..80ad63c9 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/FreeText2LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText2LockedField.php @@ -1,47 +1,47 @@ -freeText2Locked; - } - - public function getFreeText2LockedToString(): ?string - { - return ($this->getFreeText2Locked()) ? 'true' : 'false'; - } - - /** - * @param bool $freeText2Locked - * @return $this - */ - public function setFreeText2Locked(?bool $freeText2Locked): self - { - $this->freeText2Locked = $freeText2Locked; - return $this; - } - - /** - * @param string|null $freeText2LockedString - * @return $this - * @throws Exception - */ - public function setFreeText2LockedFromString(?string $freeText2LockedString) - { - return $this->setFreeText2Locked(filter_var($freeText2LockedString, FILTER_VALIDATE_BOOLEAN)); - } +freeText2Locked; + } + + public function getFreeText2LockedToString(): ?string + { + return ($this->getFreeText2Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $freeText2Locked + * @return $this + */ + public function setFreeText2Locked(?bool $freeText2Locked): self + { + $this->freeText2Locked = $freeText2Locked; + return $this; + } + + /** + * @param string|null $freeText2LockedString + * @return $this + * @throws Exception + */ + public function setFreeText2LockedFromString(?string $freeText2LockedString) + { + return $this->setFreeText2Locked(filter_var($freeText2LockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/FreeText3LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText3LockedField.php similarity index 90% rename from src/Fields/Level1234/Level34/FixedAsset/FreeText3LockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/FreeText3LockedField.php index a03e4759..b4f4ae36 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/FreeText3LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText3LockedField.php @@ -1,47 +1,47 @@ -freeText3Locked; - } - - public function getFreeText3LockedToString(): ?string - { - return ($this->getFreeText3Locked()) ? 'true' : 'false'; - } - - /** - * @param bool $freeText3Locked - * @return $this - */ - public function setFreeText3Locked(?bool $freeText3Locked): self - { - $this->freeText3Locked = $freeText3Locked; - return $this; - } - - /** - * @param string|null $freeText3LockedString - * @return $this - * @throws Exception - */ - public function setFreeText3LockedFromString(?string $freeText3LockedString) - { - return $this->setFreeText3Locked(filter_var($freeText3LockedString, FILTER_VALIDATE_BOOLEAN)); - } +freeText3Locked; + } + + public function getFreeText3LockedToString(): ?string + { + return ($this->getFreeText3Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $freeText3Locked + * @return $this + */ + public function setFreeText3Locked(?bool $freeText3Locked): self + { + $this->freeText3Locked = $freeText3Locked; + return $this; + } + + /** + * @param string|null $freeText3LockedString + * @return $this + * @throws Exception + */ + public function setFreeText3LockedFromString(?string $freeText3LockedString) + { + return $this->setFreeText3Locked(filter_var($freeText3LockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/FreeText4Field.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText4Field.php similarity index 84% rename from src/Fields/Level1234/Level34/FixedAsset/FreeText4Field.php rename to src/Fields/Dimensions/Level34/FixedAsset/FreeText4Field.php index be86dee2..955e86b1 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/FreeText4Field.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText4Field.php @@ -1,32 +1,32 @@ -freeText4; - } - - /** - * @param null|string $freeText4 - * @return $this - */ - public function setFreetext4(?string $freeText4): self - { - $this->freeText4 = $freeText4; - return $this; - } +freeText4; + } + + /** + * @param null|string $freeText4 + * @return $this + */ + public function setFreetext4(?string $freeText4): self + { + $this->freeText4 = $freeText4; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/FreeText4LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText4LockedField.php similarity index 90% rename from src/Fields/Level1234/Level34/FixedAsset/FreeText4LockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/FreeText4LockedField.php index 47cca078..1294c5fc 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/FreeText4LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText4LockedField.php @@ -1,47 +1,47 @@ -freeText4Locked; - } - - public function getFreeText4LockedToString(): ?string - { - return ($this->getFreeText4Locked()) ? 'true' : 'false'; - } - - /** - * @param bool $freeText4Locked - * @return $this - */ - public function setFreeText4Locked(?bool $freeText4Locked): self - { - $this->freeText4Locked = $freeText4Locked; - return $this; - } - - /** - * @param string|null $freeText4LockedString - * @return $this - * @throws Exception - */ - public function setFreeText4LockedFromString(?string $freeText4LockedString) - { - return $this->setFreeText4Locked(filter_var($freeText4LockedString, FILTER_VALIDATE_BOOLEAN)); - } +freeText4Locked; + } + + public function getFreeText4LockedToString(): ?string + { + return ($this->getFreeText4Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $freeText4Locked + * @return $this + */ + public function setFreeText4Locked(?bool $freeText4Locked): self + { + $this->freeText4Locked = $freeText4Locked; + return $this; + } + + /** + * @param string|null $freeText4LockedString + * @return $this + * @throws Exception + */ + public function setFreeText4LockedFromString(?string $freeText4LockedString) + { + return $this->setFreeText4Locked(filter_var($freeText4LockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/FreeText5Field.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText5Field.php similarity index 84% rename from src/Fields/Level1234/Level34/FixedAsset/FreeText5Field.php rename to src/Fields/Dimensions/Level34/FixedAsset/FreeText5Field.php index d3cb284c..5701b455 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/FreeText5Field.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText5Field.php @@ -1,32 +1,32 @@ -freeText5; - } - - /** - * @param null|string $freeText5 - * @return $this - */ - public function setFreetext5(?string $freeText5): self - { - $this->freeText5 = $freeText5; - return $this; - } +freeText5; + } + + /** + * @param null|string $freeText5 + * @return $this + */ + public function setFreetext5(?string $freeText5): self + { + $this->freeText5 = $freeText5; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/FreeText5LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText5LockedField.php similarity index 90% rename from src/Fields/Level1234/Level34/FixedAsset/FreeText5LockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/FreeText5LockedField.php index 3466b770..88e2345f 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/FreeText5LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText5LockedField.php @@ -1,47 +1,47 @@ -freeText5Locked; - } - - public function getFreeText5LockedToString(): ?string - { - return ($this->getFreeText5Locked()) ? 'true' : 'false'; - } - - /** - * @param bool $freeText5Locked - * @return $this - */ - public function setFreeText5Locked(?bool $freeText5Locked): self - { - $this->freeText5Locked = $freeText5Locked; - return $this; - } - - /** - * @param string|null $freeText5LockedString - * @return $this - * @throws Exception - */ - public function setFreeText5LockedFromString(?string $freeText5LockedString) - { - return $this->setFreeText5Locked(filter_var($freeText5LockedString, FILTER_VALIDATE_BOOLEAN)); - } +freeText5Locked; + } + + public function getFreeText5LockedToString(): ?string + { + return ($this->getFreeText5Locked()) ? 'true' : 'false'; + } + + /** + * @param bool $freeText5Locked + * @return $this + */ + public function setFreeText5Locked(?bool $freeText5Locked): self + { + $this->freeText5Locked = $freeText5Locked; + return $this; + } + + /** + * @param string|null $freeText5LockedString + * @return $this + * @throws Exception + */ + public function setFreeText5LockedFromString(?string $freeText5LockedString) + { + return $this->setFreeText5Locked(filter_var($freeText5LockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/LastDepreciationField.php b/src/Fields/Dimensions/Level34/FixedAsset/LastDepreciationField.php similarity index 88% rename from src/Fields/Level1234/Level34/FixedAsset/LastDepreciationField.php rename to src/Fields/Dimensions/Level34/FixedAsset/LastDepreciationField.php index 448dc222..bb4fe5f6 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/LastDepreciationField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/LastDepreciationField.php @@ -1,37 +1,37 @@ -lastDepreciation; - } - - /** - * @param string|null $lastDepreciation - * @return $this - */ - public function setLastDepreciation(?string $lastDepreciation): self - { - if (!preg_match("!\\d{4}/\\d{1,2}!", $lastDepreciation)) { - $lastDepreciation = ''; - } - - $this->lastDepreciation = $lastDepreciation; - - return $this; - } -} +lastDepreciation; + } + + /** + * @param string|null $lastDepreciation + * @return $this + */ + public function setLastDepreciation(?string $lastDepreciation): self + { + if (!preg_match("!\\d{4}/\\d{1,2}!", $lastDepreciation)) { + $lastDepreciation = ''; + } + + $this->lastDepreciation = $lastDepreciation; + + return $this; + } +} diff --git a/src/Fields/Level1234/Level34/FixedAsset/LastDepreciationLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/LastDepreciationLockedField.php similarity index 91% rename from src/Fields/Level1234/Level34/FixedAsset/LastDepreciationLockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/LastDepreciationLockedField.php index 9fdbd22b..af28d925 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/LastDepreciationLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/LastDepreciationLockedField.php @@ -1,47 +1,47 @@ -lastDepreciationLocked; - } - - public function getLastDepreciationLockedToString(): ?string - { - return ($this->getLastDepreciationLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $lastDepreciationLocked - * @return $this - */ - public function setLastDepreciationLocked(?bool $lastDepreciationLocked): self - { - $this->lastDepreciationLocked = $lastDepreciationLocked; - return $this; - } - - /** - * @param string|null $lastDepreciationLockedString - * @return $this - * @throws Exception - */ - public function setLastDepreciationLockedFromString(?string $lastDepreciationLockedString) - { - return $this->setLastDepreciationLocked(filter_var($lastDepreciationLockedString, FILTER_VALIDATE_BOOLEAN)); - } +lastDepreciationLocked; + } + + public function getLastDepreciationLockedToString(): ?string + { + return ($this->getLastDepreciationLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $lastDepreciationLocked + * @return $this + */ + public function setLastDepreciationLocked(?bool $lastDepreciationLocked): self + { + $this->lastDepreciationLocked = $lastDepreciationLocked; + return $this; + } + + /** + * @param string|null $lastDepreciationLockedString + * @return $this + * @throws Exception + */ + public function setLastDepreciationLockedFromString(?string $lastDepreciationLockedString) + { + return $this->setLastDepreciationLocked(filter_var($lastDepreciationLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/LineField.php b/src/Fields/Dimensions/Level34/FixedAsset/LineField.php similarity index 82% rename from src/Fields/Level1234/Level34/FixedAsset/LineField.php rename to src/Fields/Dimensions/Level34/FixedAsset/LineField.php index a6fa8d10..2d6a756f 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/LineField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/LineField.php @@ -1,32 +1,32 @@ -line; - } - - /** - * @param null|int $line - * @return $this - */ - public function setLine(?int $line): self - { - $this->line = $line; - return $this; - } +line; + } + + /** + * @param null|int $line + * @return $this + */ + public function setLine(?int $line): self + { + $this->line = $line; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/LineLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/LineLockedField.php similarity index 89% rename from src/Fields/Level1234/Level34/FixedAsset/LineLockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/LineLockedField.php index 2968291c..0e0ee9d2 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/LineLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/LineLockedField.php @@ -1,47 +1,47 @@ -lineLocked; - } - - public function getLineLockedToString(): ?string - { - return ($this->getLineLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $lineLocked - * @return $this - */ - public function setLineLocked(?bool $lineLocked): self - { - $this->lineLocked = $lineLocked; - return $this; - } - - /** - * @param string|null $lineLockedString - * @return $this - * @throws Exception - */ - public function setLineLockedFromString(?string $lineLockedString) - { - return $this->setLineLocked(filter_var($lineLockedString, FILTER_VALIDATE_BOOLEAN)); - } +lineLocked; + } + + public function getLineLockedToString(): ?string + { + return ($this->getLineLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $lineLocked + * @return $this + */ + public function setLineLocked(?bool $lineLocked): self + { + $this->lineLocked = $lineLocked; + return $this; + } + + /** + * @param string|null $lineLockedString + * @return $this + * @throws Exception + */ + public function setLineLockedFromString(?string $lineLockedString) + { + return $this->setLineLocked(filter_var($lineLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/MethodField.php b/src/Fields/Dimensions/Level34/FixedAsset/MethodField.php similarity index 94% rename from src/Fields/Level1234/Level34/FixedAsset/MethodField.php rename to src/Fields/Dimensions/Level34/FixedAsset/MethodField.php index 7da4a172..bd1de558 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/MethodField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/MethodField.php @@ -1,6 +1,6 @@ nrOfPeriodsInherited; - } - - public function getNrOfPeriodsInheritedToString(): ?string - { - return ($this->getNrOfPeriodsInherited()) ? 'true' : 'false'; - } - - /** - * @param bool $nrOfPeriodsInherited - * @return $this - */ - public function setNrOfPeriodsInherited(?bool $nrOfPeriodsInherited): self - { - $this->nrOfPeriodsInherited = $nrOfPeriodsInherited; - return $this; - } - - /** - * @param string|null $nrOfPeriodsInheritedString - * @return $this - * @throws Exception - */ - public function setNrOfPeriodsInheritedFromString(?string $nrOfPeriodsInheritedString) - { - return $this->setNrOfPeriodsInherited(filter_var($nrOfPeriodsInheritedString, FILTER_VALIDATE_BOOLEAN)); - } +nrOfPeriodsInherited; + } + + public function getNrOfPeriodsInheritedToString(): ?string + { + return ($this->getNrOfPeriodsInherited()) ? 'true' : 'false'; + } + + /** + * @param bool $nrOfPeriodsInherited + * @return $this + */ + public function setNrOfPeriodsInherited(?bool $nrOfPeriodsInherited): self + { + $this->nrOfPeriodsInherited = $nrOfPeriodsInherited; + return $this; + } + + /** + * @param string|null $nrOfPeriodsInheritedString + * @return $this + * @throws Exception + */ + public function setNrOfPeriodsInheritedFromString(?string $nrOfPeriodsInheritedString) + { + return $this->setNrOfPeriodsInherited(filter_var($nrOfPeriodsInheritedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/NrOfPeriodsLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/NrOfPeriodsLockedField.php similarity index 90% rename from src/Fields/Level1234/Level34/FixedAsset/NrOfPeriodsLockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/NrOfPeriodsLockedField.php index 009b064f..c55b251a 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/NrOfPeriodsLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/NrOfPeriodsLockedField.php @@ -1,47 +1,47 @@ -nrOfPeriodsLocked; - } - - public function getNrOfPeriodsLockedToString(): ?string - { - return ($this->getNrOfPeriodsLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $nrOfPeriodsLocked - * @return $this - */ - public function setNrOfPeriodsLocked(?bool $nrOfPeriodsLocked): self - { - $this->nrOfPeriodsLocked = $nrOfPeriodsLocked; - return $this; - } - - /** - * @param string|null $nrOfPeriodsLockedString - * @return $this - * @throws Exception - */ - public function setNrOfPeriodsLockedFromString(?string $nrOfPeriodsLockedString) - { - return $this->setNrOfPeriodsLocked(filter_var($nrOfPeriodsLockedString, FILTER_VALIDATE_BOOLEAN)); - } +nrOfPeriodsLocked; + } + + public function getNrOfPeriodsLockedToString(): ?string + { + return ($this->getNrOfPeriodsLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $nrOfPeriodsLocked + * @return $this + */ + public function setNrOfPeriodsLocked(?bool $nrOfPeriodsLocked): self + { + $this->nrOfPeriodsLocked = $nrOfPeriodsLocked; + return $this; + } + + /** + * @param string|null $nrOfPeriodsLockedString + * @return $this + * @throws Exception + */ + public function setNrOfPeriodsLockedFromString(?string $nrOfPeriodsLockedString) + { + return $this->setNrOfPeriodsLocked(filter_var($nrOfPeriodsLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/NumberField.php b/src/Fields/Dimensions/Level34/FixedAsset/NumberField.php similarity index 83% rename from src/Fields/Level1234/Level34/FixedAsset/NumberField.php rename to src/Fields/Dimensions/Level34/FixedAsset/NumberField.php index 38b67d0c..195b2df1 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/NumberField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/NumberField.php @@ -1,32 +1,32 @@ -number; - } - - /** - * @param null|int $number - * @return $this - */ - public function setNumber(?int $number): self - { - $this->number = $number; - return $this; - } +number; + } + + /** + * @param null|int $number + * @return $this + */ + public function setNumber(?int $number): self + { + $this->number = $number; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/NumberLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/NumberLockedField.php similarity index 89% rename from src/Fields/Level1234/Level34/FixedAsset/NumberLockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/NumberLockedField.php index e8ba56e4..7283a73e 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/NumberLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/NumberLockedField.php @@ -1,47 +1,47 @@ -numberLocked; - } - - public function getNumberLockedToString(): ?string - { - return ($this->getNumberLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $numberLocked - * @return $this - */ - public function setNumberLocked(?bool $numberLocked): self - { - $this->numberLocked = $numberLocked; - return $this; - } - - /** - * @param string|null $numberLockedString - * @return $this - * @throws Exception - */ - public function setNumberLockedFromString(?string $numberLockedString) - { - return $this->setNumberLocked(filter_var($numberLockedString, FILTER_VALIDATE_BOOLEAN)); - } +numberLocked; + } + + public function getNumberLockedToString(): ?string + { + return ($this->getNumberLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $numberLocked + * @return $this + */ + public function setNumberLocked(?bool $numberLocked): self + { + $this->numberLocked = $numberLocked; + return $this; + } + + /** + * @param string|null $numberLockedString + * @return $this + * @throws Exception + */ + public function setNumberLockedFromString(?string $numberLockedString) + { + return $this->setNumberLocked(filter_var($numberLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/PercentageLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/PercentageLockedField.php similarity index 90% rename from src/Fields/Level1234/Level34/FixedAsset/PercentageLockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/PercentageLockedField.php index 1a14a825..aeae43a8 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/PercentageLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/PercentageLockedField.php @@ -1,47 +1,47 @@ -percentageLocked; - } - - public function getPercentageLockedToString(): ?string - { - return ($this->getPercentageLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $percentageLocked - * @return $this - */ - public function setPercentageLocked(?bool $percentageLocked): self - { - $this->percentageLocked = $percentageLocked; - return $this; - } - - /** - * @param string|null $percentageLockedString - * @return $this - * @throws Exception - */ - public function setPercentageLockedFromString(?string $percentageLockedString) - { - return $this->setPercentageLocked(filter_var($percentageLockedString, FILTER_VALIDATE_BOOLEAN)); - } +percentageLocked; + } + + public function getPercentageLockedToString(): ?string + { + return ($this->getPercentageLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $percentageLocked + * @return $this + */ + public function setPercentageLocked(?bool $percentageLocked): self + { + $this->percentageLocked = $percentageLocked; + return $this; + } + + /** + * @param string|null $percentageLockedString + * @return $this + * @throws Exception + */ + public function setPercentageLockedFromString(?string $percentageLockedString) + { + return $this->setPercentageLocked(filter_var($percentageLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/PeriodLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/PeriodLockedField.php similarity index 89% rename from src/Fields/Level1234/Level34/FixedAsset/PeriodLockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/PeriodLockedField.php index 635bf011..8ddfbead 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/PeriodLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/PeriodLockedField.php @@ -1,47 +1,47 @@ -periodLocked; - } - - public function getPeriodLockedToString(): ?string - { - return ($this->getPeriodLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $periodLocked - * @return $this - */ - public function setPeriodLocked(?bool $periodLocked): self - { - $this->periodLocked = $periodLocked; - return $this; - } - - /** - * @param string|null $periodLockedString - * @return $this - * @throws Exception - */ - public function setPeriodLockedFromString(?string $periodLockedString) - { - return $this->setPeriodLocked(filter_var($periodLockedString, FILTER_VALIDATE_BOOLEAN)); - } +periodLocked; + } + + public function getPeriodLockedToString(): ?string + { + return ($this->getPeriodLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $periodLocked + * @return $this + */ + public function setPeriodLocked(?bool $periodLocked): self + { + $this->periodLocked = $periodLocked; + return $this; + } + + /** + * @param string|null $periodLockedString + * @return $this + * @throws Exception + */ + public function setPeriodLockedFromString(?string $periodLockedString) + { + return $this->setPeriodLocked(filter_var($periodLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/PurchaseDateField.php b/src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateField.php similarity index 91% rename from src/Fields/Level1234/Level34/FixedAsset/PurchaseDateField.php rename to src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateField.php index d2a42a45..f5582ab6 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/PurchaseDateField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateField.php @@ -1,66 +1,66 @@ -purchaseDate; - } - - /** - * @return string|null - */ - public function getPurchaseDateToString(): ?string - { - if ($this->getPurchaseDate() != null) { - return Util::formatDate($this->getPurchaseDate()); - } else { - return null; - } - } - - /** - * @param \DateTimeInterface|null $purchaseDate - * @return $this - */ - public function setPurchaseDate(?\DateTimeInterface $purchaseDate) - { - $this->purchaseDate = $purchaseDate; - return $this; - } - - /** - * @param string|null $purchaseDateString - * @return $this - * @throws Exception - */ - public function setPurchaseDateFromString(?string $purchaseDateString) - { - if ((bool)strtotime($purchaseDateString)) { - return $this->setPurchaseDate(Util::parseDate($purchaseDateString)); - } else { - return $this->setPurchaseDate(null); - } - } +purchaseDate; + } + + /** + * @return string|null + */ + public function getPurchaseDateToString(): ?string + { + if ($this->getPurchaseDate() != null) { + return Util::formatDate($this->getPurchaseDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $purchaseDate + * @return $this + */ + public function setPurchaseDate(?\DateTimeInterface $purchaseDate) + { + $this->purchaseDate = $purchaseDate; + return $this; + } + + /** + * @param string|null $purchaseDateString + * @return $this + * @throws Exception + */ + public function setPurchaseDateFromString(?string $purchaseDateString) + { + if ((bool)strtotime($purchaseDateString)) { + return $this->setPurchaseDate(Util::parseDate($purchaseDateString)); + } else { + return $this->setPurchaseDate(null); + } + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/PurchaseDateLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateLockedField.php similarity index 90% rename from src/Fields/Level1234/Level34/FixedAsset/PurchaseDateLockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateLockedField.php index 6ba046c2..9e674ae0 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/PurchaseDateLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateLockedField.php @@ -1,47 +1,47 @@ -purchaseDateLocked; - } - - public function getPurchaseDateLockedToString(): ?string - { - return ($this->getPurchaseDateLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $purchaseDateLocked - * @return $this - */ - public function setPurchaseDateLocked(?bool $purchaseDateLocked): self - { - $this->purchaseDateLocked = $purchaseDateLocked; - return $this; - } - - /** - * @param string|null $purchaseDateLockedString - * @return $this - * @throws Exception - */ - public function setPurchaseDateLockedFromString(?string $purchaseDateLockedString) - { - return $this->setPurchaseDateLocked(filter_var($purchaseDateLockedString, FILTER_VALIDATE_BOOLEAN)); - } +purchaseDateLocked; + } + + public function getPurchaseDateLockedToString(): ?string + { + return ($this->getPurchaseDateLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $purchaseDateLocked + * @return $this + */ + public function setPurchaseDateLocked(?bool $purchaseDateLocked): self + { + $this->purchaseDateLocked = $purchaseDateLocked; + return $this; + } + + /** + * @param string|null $purchaseDateLockedString + * @return $this + * @throws Exception + */ + public function setPurchaseDateLockedFromString(?string $purchaseDateLockedString) + { + return $this->setPurchaseDateLocked(filter_var($purchaseDateLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/ResidualValueField.php b/src/Fields/Dimensions/Level34/FixedAsset/ResidualValueField.php similarity index 91% rename from src/Fields/Level1234/Level34/FixedAsset/ResidualValueField.php rename to src/Fields/Dimensions/Level34/FixedAsset/ResidualValueField.php index aa54ee8a..ff935bb2 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/ResidualValueField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/ResidualValueField.php @@ -1,62 +1,62 @@ -residualValue; - } - - /** - * @return float|null - */ - public function getResidualValueToFloat(): ?float - { - if ($this->getResidualValue() != null) { - return Util::formatMoney($this->getResidualValue()); - } else { - return 0; - } - } - - /** - * @param Money|null $residualValue - * @return $this - */ - public function setResidualValue(?Money $residualValue) - { - $this->residualValue = $residualValue; - - return $this; - } - - /** - * @param float|null $residualValueFloat - * @return $this - * @throws Exception - */ - public function setResidualValueFromFloat(?float $residualValueFloat) - { - if ((float)$residualValueFloat) { - return $this->setResidualValue(Money::EUR(100 * $residualValueFloat)); - } else { - return $this->setResidualValue(Money::EUR(0)); - } - } +residualValue; + } + + /** + * @return float|null + */ + public function getResidualValueToFloat(): ?float + { + if ($this->getResidualValue() != null) { + return Util::formatMoney($this->getResidualValue()); + } else { + return 0; + } + } + + /** + * @param Money|null $residualValue + * @return $this + */ + public function setResidualValue(?Money $residualValue) + { + $this->residualValue = $residualValue; + + return $this; + } + + /** + * @param float|null $residualValueFloat + * @return $this + * @throws Exception + */ + public function setResidualValueFromFloat(?float $residualValueFloat) + { + if ((float)$residualValueFloat) { + return $this->setResidualValue(Money::EUR(100 * $residualValueFloat)); + } else { + return $this->setResidualValue(Money::EUR(0)); + } + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/ResidualValueLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/ResidualValueLockedField.php similarity index 90% rename from src/Fields/Level1234/Level34/FixedAsset/ResidualValueLockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/ResidualValueLockedField.php index 58010b76..2bc7719f 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/ResidualValueLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/ResidualValueLockedField.php @@ -1,47 +1,47 @@ -residualValueLocked; - } - - public function getResidualValueLockedToString(): ?string - { - return ($this->getResidualValueLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $residualValueLocked - * @return $this - */ - public function setResidualValueLocked(?bool $residualValueLocked): self - { - $this->residualValueLocked = $residualValueLocked; - return $this; - } - - /** - * @param string|null $residualValueLockedString - * @return $this - * @throws Exception - */ - public function setResidualValueLockedFromString(?string $residualValueLockedString) - { - return $this->setResidualValueLocked(filter_var($residualValueLockedString, FILTER_VALIDATE_BOOLEAN)); - } +residualValueLocked; + } + + public function getResidualValueLockedToString(): ?string + { + return ($this->getResidualValueLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $residualValueLocked + * @return $this + */ + public function setResidualValueLocked(?bool $residualValueLocked): self + { + $this->residualValueLocked = $residualValueLocked; + return $this; + } + + /** + * @param string|null $residualValueLockedString + * @return $this + * @throws Exception + */ + public function setResidualValueLockedFromString(?string $residualValueLockedString) + { + return $this->setResidualValueLocked(filter_var($residualValueLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/SellDateField.php b/src/Fields/Dimensions/Level34/FixedAsset/SellDateField.php similarity index 91% rename from src/Fields/Level1234/Level34/FixedAsset/SellDateField.php rename to src/Fields/Dimensions/Level34/FixedAsset/SellDateField.php index 3d121338..3de24d08 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/SellDateField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/SellDateField.php @@ -1,66 +1,66 @@ -sellDate; - } - - /** - * @return string|null - */ - public function getSellDateToString(): ?string - { - if ($this->getSellDate() != null) { - return Util::formatDate($this->getSellDate()); - } else { - return null; - } - } - - /** - * @param \DateTimeInterface|null $sellDate - * @return $this - */ - public function setSellDate(?\DateTimeInterface $sellDate) - { - $this->sellDate = $sellDate; - return $this; - } - - /** - * @param string|null $sellDateString - * @return $this - * @throws Exception - */ - public function setSellDateFromString(?string $sellDateString) - { - if ((bool)strtotime($sellDateString)) { - return $this->setSellDate(Util::parseDate($sellDateString)); - } else { - return $this->setSellDate(null); - } - } +sellDate; + } + + /** + * @return string|null + */ + public function getSellDateToString(): ?string + { + if ($this->getSellDate() != null) { + return Util::formatDate($this->getSellDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $sellDate + * @return $this + */ + public function setSellDate(?\DateTimeInterface $sellDate) + { + $this->sellDate = $sellDate; + return $this; + } + + /** + * @param string|null $sellDateString + * @return $this + * @throws Exception + */ + public function setSellDateFromString(?string $sellDateString) + { + if ((bool)strtotime($sellDateString)) { + return $this->setSellDate(Util::parseDate($sellDateString)); + } else { + return $this->setSellDate(null); + } + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/SellDateLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/SellDateLockedField.php similarity index 90% rename from src/Fields/Level1234/Level34/FixedAsset/SellDateLockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/SellDateLockedField.php index 25bf1697..eaf131da 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/SellDateLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/SellDateLockedField.php @@ -1,47 +1,47 @@ -sellDateLocked; - } - - public function getSellDateLockedToString(): ?string - { - return ($this->getSellDateLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $sellDateLocked - * @return $this - */ - public function setSellDateLocked(?bool $sellDateLocked): self - { - $this->sellDateLocked = $sellDateLocked; - return $this; - } - - /** - * @param string|null $sellDateLockedString - * @return $this - * @throws Exception - */ - public function setSellDateLockedFromString(?string $sellDateLockedString) - { - return $this->setSellDateLocked(filter_var($sellDateLockedString, FILTER_VALIDATE_BOOLEAN)); - } +sellDateLocked; + } + + public function getSellDateLockedToString(): ?string + { + return ($this->getSellDateLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $sellDateLocked + * @return $this + */ + public function setSellDateLocked(?bool $sellDateLocked): self + { + $this->sellDateLocked = $sellDateLocked; + return $this; + } + + /** + * @param string|null $sellDateLockedString + * @return $this + * @throws Exception + */ + public function setSellDateLockedFromString(?string $sellDateLockedString) + { + return $this->setSellDateLocked(filter_var($sellDateLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/StatusField.php b/src/Fields/Dimensions/Level34/FixedAsset/StatusField.php similarity index 92% rename from src/Fields/Level1234/Level34/FixedAsset/StatusField.php rename to src/Fields/Dimensions/Level34/FixedAsset/StatusField.php index f260cbb6..1f649405 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/StatusField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/StatusField.php @@ -1,6 +1,6 @@ stopValue; - } - - /** - * @return float|null - */ - public function getStopValueToFloat(): ?float - { - if ($this->getStopValue() != null) { - return Util::formatMoney($this->getStopValue()); - } else { - return 0; - } - } - - /** - * @param Money|null $stopValue - * @return $this - */ - public function setStopValue(?Money $stopValue) - { - $this->stopValue = $stopValue; - - return $this; - } - - /** - * @param float|null $stopValueFloat - * @return $this - * @throws Exception - */ - public function setStopValueFromFloat(?float $stopValueFloat) - { - if ((float)$stopValueFloat) { - return $this->setStopValue(Money::EUR(100 * $stopValueFloat)); - } else { - return $this->setStopValue(Money::EUR(0)); - } - } +stopValue; + } + + /** + * @return float|null + */ + public function getStopValueToFloat(): ?float + { + if ($this->getStopValue() != null) { + return Util::formatMoney($this->getStopValue()); + } else { + return 0; + } + } + + /** + * @param Money|null $stopValue + * @return $this + */ + public function setStopValue(?Money $stopValue) + { + $this->stopValue = $stopValue; + + return $this; + } + + /** + * @param float|null $stopValueFloat + * @return $this + * @throws Exception + */ + public function setStopValueFromFloat(?float $stopValueFloat) + { + if ((float)$stopValueFloat) { + return $this->setStopValue(Money::EUR(100 * $stopValueFloat)); + } else { + return $this->setStopValue(Money::EUR(0)); + } + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/StopValueLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/StopValueLockedField.php similarity index 90% rename from src/Fields/Level1234/Level34/FixedAsset/StopValueLockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/StopValueLockedField.php index 9a07ed83..30972e2e 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/StopValueLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/StopValueLockedField.php @@ -1,47 +1,47 @@ -stopValueLocked; - } - - public function getStopValueLockedToString(): ?string - { - return ($this->getStopValueLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $stopValueLocked - * @return $this - */ - public function setStopValueLocked(?bool $stopValueLocked): self - { - $this->stopValueLocked = $stopValueLocked; - return $this; - } - - /** - * @param string|null $stopValueLockedString - * @return $this - * @throws Exception - */ - public function setStopValueLockedFromString(?string $stopValueLockedString) - { - return $this->setStopValueLocked(filter_var($stopValueLockedString, FILTER_VALIDATE_BOOLEAN)); - } +stopValueLocked; + } + + public function getStopValueLockedToString(): ?string + { + return ($this->getStopValueLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $stopValueLocked + * @return $this + */ + public function setStopValueLocked(?bool $stopValueLocked): self + { + $this->stopValueLocked = $stopValueLocked; + return $this; + } + + /** + * @param string|null $stopValueLockedString + * @return $this + * @throws Exception + */ + public function setStopValueLockedFromString(?string $stopValueLockedString) + { + return $this->setStopValueLocked(filter_var($stopValueLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/FixedAsset/TransactionLinesLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/TransactionLinesLockedField.php similarity index 91% rename from src/Fields/Level1234/Level34/FixedAsset/TransactionLinesLockedField.php rename to src/Fields/Dimensions/Level34/FixedAsset/TransactionLinesLockedField.php index 6dbf4783..cee0d7f0 100644 --- a/src/Fields/Level1234/Level34/FixedAsset/TransactionLinesLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/TransactionLinesLockedField.php @@ -1,47 +1,47 @@ -transactionLinesLocked; - } - - public function getTransactionLinesLockedToString(): ?string - { - return ($this->getTransactionLinesLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $transactionLinesLocked - * @return $this - */ - public function setTransactionLinesLocked(?bool $transactionLinesLocked): self - { - $this->transactionLinesLocked = $transactionLinesLocked; - return $this; - } - - /** - * @param string|null $transactionLinesLockedString - * @return $this - * @throws Exception - */ - public function setTransactionLinesLockedFromString(?string $transactionLinesLockedString) - { - return $this->setTransactionLinesLocked(filter_var($transactionLinesLockedString, FILTER_VALIDATE_BOOLEAN)); - } +transactionLinesLocked; + } + + public function getTransactionLinesLockedToString(): ?string + { + return ($this->getTransactionLinesLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $transactionLinesLocked + * @return $this + */ + public function setTransactionLinesLocked(?bool $transactionLinesLocked): self + { + $this->transactionLinesLocked = $transactionLinesLocked; + return $this; + } + + /** + * @param string|null $transactionLinesLockedString + * @return $this + * @throws Exception + */ + public function setTransactionLinesLockedFromString(?string $transactionLinesLockedString) + { + return $this->setTransactionLinesLocked(filter_var($transactionLinesLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/InvoiceDescriptionField.php b/src/Fields/Dimensions/Level34/InvoiceDescriptionField.php similarity index 88% rename from src/Fields/Level1234/Level34/InvoiceDescriptionField.php rename to src/Fields/Dimensions/Level34/InvoiceDescriptionField.php index dc24d480..8e5e9a2f 100644 --- a/src/Fields/Level1234/Level34/InvoiceDescriptionField.php +++ b/src/Fields/Dimensions/Level34/InvoiceDescriptionField.php @@ -1,32 +1,32 @@ -invoiceDescription; - } - - /** - * @param null|string $invoiceDescription - * @return $this - */ - public function setInvoiceDescription(?string $invoiceDescription): self - { - $this->invoiceDescription = $invoiceDescription; - return $this; - } +invoiceDescription; + } + + /** + * @param null|string $invoiceDescription + * @return $this + */ + public function setInvoiceDescription(?string $invoiceDescription): self + { + $this->invoiceDescription = $invoiceDescription; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/LabelField.php b/src/Fields/Dimensions/Level34/LabelField.php similarity index 85% rename from src/Fields/Level1234/Level34/LabelField.php rename to src/Fields/Dimensions/Level34/LabelField.php index 6eb6c6cc..49c8325a 100644 --- a/src/Fields/Level1234/Level34/LabelField.php +++ b/src/Fields/Dimensions/Level34/LabelField.php @@ -1,32 +1,32 @@ -label; - } - - /** - * @param null|string $label - * @return $this - */ - public function setLabel(?string $label): self - { - $this->label = $label; - return $this; - } +label; + } + + /** + * @param null|string $label + * @return $this + */ + public function setLabel(?string $label): self + { + $this->label = $label; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/MandatoryField.php b/src/Fields/Dimensions/Level34/MandatoryField.php similarity index 90% rename from src/Fields/Level1234/Level34/MandatoryField.php rename to src/Fields/Dimensions/Level34/MandatoryField.php index 82c39558..42c13032 100644 --- a/src/Fields/Level1234/Level34/MandatoryField.php +++ b/src/Fields/Dimensions/Level34/MandatoryField.php @@ -1,47 +1,47 @@ -mandatory; - } - - public function getMandatoryToString(): ?string - { - return ($this->getMandatory()) ? 'true' : 'false'; - } - - /** - * @param bool $mandatory - * @return $this - */ - public function setMandatory(?bool $mandatory): self - { - $this->mandatory = $mandatory; - return $this; - } - - /** - * @param string|null $mandatoryString - * @return $this - * @throws Exception - */ - public function setMandatoryFromString(?string $mandatoryString) - { - return $this->setMandatory(filter_var($mandatoryString, FILTER_VALIDATE_BOOLEAN)); - } +mandatory; + } + + public function getMandatoryToString(): ?string + { + return ($this->getMandatory()) ? 'true' : 'false'; + } + + /** + * @param bool $mandatory + * @return $this + */ + public function setMandatory(?bool $mandatory): self + { + $this->mandatory = $mandatory; + return $this; + } + + /** + * @param string|null $mandatoryString + * @return $this + * @throws Exception + */ + public function setMandatoryFromString(?string $mandatoryString) + { + return $this->setMandatory(filter_var($mandatoryString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/RateInheritField.php b/src/Fields/Dimensions/Level34/RateInheritField.php similarity index 90% rename from src/Fields/Level1234/Level34/RateInheritField.php rename to src/Fields/Dimensions/Level34/RateInheritField.php index 374a11d8..8cd538c2 100644 --- a/src/Fields/Level1234/Level34/RateInheritField.php +++ b/src/Fields/Dimensions/Level34/RateInheritField.php @@ -1,47 +1,47 @@ -rateInherit; - } - - public function getRateInheritToString(): ?string - { - return ($this->getRateInherit()) ? 'true' : 'false'; - } - - /** - * @param bool $rateInherit - * @return $this - */ - public function setRateInherit(?bool $rateInherit): self - { - $this->rateInherit = $rateInherit; - return $this; - } - - /** - * @param string|null $rateInheritString - * @return $this - * @throws Exception - */ - public function setRateInheritFromString(?string $rateInheritString) - { - return $this->setRateInherit(filter_var($rateInheritString, FILTER_VALIDATE_BOOLEAN)); - } +rateInherit; + } + + public function getRateInheritToString(): ?string + { + return ($this->getRateInherit()) ? 'true' : 'false'; + } + + /** + * @param bool $rateInherit + * @return $this + */ + public function setRateInherit(?bool $rateInherit): self + { + $this->rateInherit = $rateInherit; + return $this; + } + + /** + * @param string|null $rateInheritString + * @return $this + * @throws Exception + */ + public function setRateInheritFromString(?string $rateInheritString) + { + return $this->setRateInherit(filter_var($rateInheritString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/RateLockedField.php b/src/Fields/Dimensions/Level34/RateLockedField.php similarity index 90% rename from src/Fields/Level1234/Level34/RateLockedField.php rename to src/Fields/Dimensions/Level34/RateLockedField.php index 65cb1a4f..5926ccfa 100644 --- a/src/Fields/Level1234/Level34/RateLockedField.php +++ b/src/Fields/Dimensions/Level34/RateLockedField.php @@ -1,47 +1,47 @@ -rateLocked; - } - - public function getRateLockedToString(): ?string - { - return ($this->getRateLocked()) ? 'true' : 'false'; - } - - /** - * @param bool $rateLocked - * @return $this - */ - public function setRateLocked(?bool $rateLocked): self - { - $this->rateLocked = $rateLocked; - return $this; - } - - /** - * @param string|null $rateLockedString - * @return $this - * @throws Exception - */ - public function setRateLockedFromString(?string $rateLockedString) - { - return $this->setRateLocked(filter_var($rateLockedString, FILTER_VALIDATE_BOOLEAN)); - } +rateLocked; + } + + public function getRateLockedToString(): ?string + { + return ($this->getRateLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $rateLocked + * @return $this + */ + public function setRateLocked(?bool $rateLocked): self + { + $this->rateLocked = $rateLocked; + return $this; + } + + /** + * @param string|null $rateLockedString + * @return $this + * @throws Exception + */ + public function setRateLockedFromString(?string $rateLockedString) + { + return $this->setRateLocked(filter_var($rateLockedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/ValidFromField.php b/src/Fields/Dimensions/Level34/ValidFromField.php similarity index 92% rename from src/Fields/Level1234/Level34/ValidFromField.php rename to src/Fields/Dimensions/Level34/ValidFromField.php index 1cfb3f64..c143d7fc 100644 --- a/src/Fields/Level1234/Level34/ValidFromField.php +++ b/src/Fields/Dimensions/Level34/ValidFromField.php @@ -1,66 +1,66 @@ -validFrom; - } - - /** - * @return string|null - */ - public function getValidFromToString(): ?string - { - if ($this->getValidFrom() != null) { - return Util::formatDate($this->getValidFrom()); - } else { - return null; - } - } - - /** - * @param \DateTimeInterface|null $validFrom - * @return $this - */ - public function setValidFrom(?\DateTimeInterface $validFrom) - { - $this->validFrom = $validFrom; - return $this; - } - - /** - * @param string|null $validFromString - * @return $this - * @throws Exception - */ - public function setValidFromFromString(?string $validFromString) - { - if ((bool)strtotime($validFromString)) { - return $this->setValidFrom(Util::parseDate($validFromString)); - } else { - return $this->setValidFrom(null); - } - } +validFrom; + } + + /** + * @return string|null + */ + public function getValidFromToString(): ?string + { + if ($this->getValidFrom() != null) { + return Util::formatDate($this->getValidFrom()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $validFrom + * @return $this + */ + public function setValidFrom(?\DateTimeInterface $validFrom) + { + $this->validFrom = $validFrom; + return $this; + } + + /** + * @param string|null $validFromString + * @return $this + * @throws Exception + */ + public function setValidFromFromString(?string $validFromString) + { + if ((bool)strtotime($validFromString)) { + return $this->setValidFrom(Util::parseDate($validFromString)); + } else { + return $this->setValidFrom(null); + } + } } \ No newline at end of file diff --git a/src/Fields/Level1234/Level34/ValidTillField.php b/src/Fields/Dimensions/Level34/ValidTillField.php similarity index 92% rename from src/Fields/Level1234/Level34/ValidTillField.php rename to src/Fields/Dimensions/Level34/ValidTillField.php index 70fbb0d8..f2114aa9 100644 --- a/src/Fields/Level1234/Level34/ValidTillField.php +++ b/src/Fields/Dimensions/Level34/ValidTillField.php @@ -1,66 +1,66 @@ -validTill; - } - - /** - * @return string|null - */ - public function getValidTillToString(): ?string - { - if ($this->getValidTill() != null) { - return Util::formatDate($this->getValidTill()); - } else { - return null; - } - } - - /** - * @param \DateTimeInterface|null $validTill - * @return $this - */ - public function setValidTill(?\DateTimeInterface $validTill) - { - $this->validTill = $validTill; - return $this; - } - - /** - * @param string|null $validTillString - * @return $this - * @throws Exception - */ - public function setValidTillFromString(?string $validTillString) - { - if ((bool)strtotime($validTillString)) { - return $this->setValidTill(Util::parseDate($validTillString)); - } else { - return $this->setValidTill(null); - } - } +validTill; + } + + /** + * @return string|null + */ + public function getValidTillToString(): ?string + { + if ($this->getValidTill() != null) { + return Util::formatDate($this->getValidTill()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $validTill + * @return $this + */ + public function setValidTill(?\DateTimeInterface $validTill) + { + $this->validTill = $validTill; + return $this; + } + + /** + * @param string|null $validTillString + * @return $this + * @throws Exception + */ + public function setValidTillFromString(?string $validTillString) + { + if ((bool)strtotime($validTillString)) { + return $this->setValidTill(Util::parseDate($validTillString)); + } else { + return $this->setValidTill(null); + } + } } \ No newline at end of file diff --git a/src/Fields/Level1234/LevelField.php b/src/Fields/Dimensions/LevelField.php similarity index 89% rename from src/Fields/Level1234/LevelField.php rename to src/Fields/Dimensions/LevelField.php index f9d2ed54..2765fc31 100644 --- a/src/Fields/Level1234/LevelField.php +++ b/src/Fields/Dimensions/LevelField.php @@ -1,32 +1,32 @@ -level; - } - - /** - * @param null|int $level - * @return $this - */ - public function setLevel(?int $level): self - { - $this->level = $level; - return $this; - } +level; + } + + /** + * @param null|int $level + * @return $this + */ + public function setLevel(?int $level): self + { + $this->level = $level; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/MatchTypeField.php b/src/Fields/Dimensions/MatchTypeField.php similarity index 91% rename from src/Fields/Level1234/MatchTypeField.php rename to src/Fields/Dimensions/MatchTypeField.php index bed20d43..1c2c91c4 100644 --- a/src/Fields/Level1234/MatchTypeField.php +++ b/src/Fields/Dimensions/MatchTypeField.php @@ -1,41 +1,41 @@ -matchType; - } - - /** - * @param MatchType|null $matchType - * @return $this - */ - public function setMatchType(?MatchType $matchType): self - { - $this->matchType = $matchType; - return $this; - } - - /** - * @param string|null $matchTypeString - * @return $this - * @throws Exception - */ - public function setMatchTypeFromString(?string $matchTypeString) - { - return $this->setMatchType(new MatchType((string)$matchTypeString)); - } +matchType; + } + + /** + * @param MatchType|null $matchType + * @return $this + */ + public function setMatchType(?MatchType $matchType): self + { + $this->matchType = $matchType; + return $this; + } + + /** + * @param string|null $matchTypeString + * @return $this + * @throws Exception + */ + public function setMatchTypeFromString(?string $matchTypeString) + { + return $this->setMatchType(new MatchType((string)$matchTypeString)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/SubAnalyseField.php b/src/Fields/Dimensions/SubAnalyseField.php similarity index 91% rename from src/Fields/Level1234/SubAnalyseField.php rename to src/Fields/Dimensions/SubAnalyseField.php index 0d152787..213203e6 100644 --- a/src/Fields/Level1234/SubAnalyseField.php +++ b/src/Fields/Dimensions/SubAnalyseField.php @@ -1,41 +1,41 @@ -subAnalyse; - } - - /** - * @param SubAnalyse|null $subAnalyse - * @return $this - */ - public function setSubAnalyse(?SubAnalyse $subAnalyse): self - { - $this->subAnalyse = $subAnalyse; - return $this; - } - - /** - * @param string|null $subAnalyseString - * @return $this - * @throws Exception - */ - public function setSubAnalyseFromString(?string $subAnalyseString) - { - return $this->setSubAnalyse(new SubAnalyse((string)$subAnalyseString)); - } +subAnalyse; + } + + /** + * @param SubAnalyse|null $subAnalyse + * @return $this + */ + public function setSubAnalyse(?SubAnalyse $subAnalyse): self + { + $this->subAnalyse = $subAnalyse; + return $this; + } + + /** + * @param string|null $subAnalyseString + * @return $this + * @throws Exception + */ + public function setSubAnalyseFromString(?string $subAnalyseString) + { + return $this->setSubAnalyse(new SubAnalyse((string)$subAnalyseString)); + } } \ No newline at end of file diff --git a/src/Fields/Level1234/SubstituteWithField.php b/src/Fields/Dimensions/SubstituteWithField.php similarity index 92% rename from src/Fields/Level1234/SubstituteWithField.php rename to src/Fields/Dimensions/SubstituteWithField.php index 3c2c95b8..7ff9b3b7 100644 --- a/src/Fields/Level1234/SubstituteWithField.php +++ b/src/Fields/Dimensions/SubstituteWithField.php @@ -1,54 +1,54 @@ -substituteWith; - } - - public function getSubstituteWithToString(): ?string - { - if ($this->getSubstituteWith() != null) { - return $this->substituteWith->getCode(); - } else { - return null; - } - } - - /** - * @return $this - */ - public function setSubstituteWith($substituteWith): self - { - $this->substituteWith = $substituteWith; - return $this; - } - - /** - * @param string|null $substituteWithCode - * @return $this - * @throws Exception - */ - public function setSubstituteWithFromString(?string $substituteWithCode) - { - $substituteWith = new Dummy(); - $substituteWith->setCode($substituteWithCode); - return $this->setSubstituteWith($substituteWith); - } -} +substituteWith; + } + + public function getSubstituteWithToString(): ?string + { + if ($this->getSubstituteWith() != null) { + return $this->substituteWith->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setSubstituteWith($substituteWith): self + { + $this->substituteWith = $substituteWith; + return $this; + } + + /** + * @param string|null $substituteWithCode + * @return $this + * @throws Exception + */ + public function setSubstituteWithFromString(?string $substituteWithCode) + { + $substituteWith = new Dummy(); + $substituteWith->setCode($substituteWithCode); + return $this->setSubstituteWith($substituteWith); + } +} diff --git a/src/Fields/Level1234/SubstituteWithIDField.php b/src/Fields/Dimensions/SubstituteWithIDField.php similarity index 89% rename from src/Fields/Level1234/SubstituteWithIDField.php rename to src/Fields/Dimensions/SubstituteWithIDField.php index 013eb897..3fc8ac19 100644 --- a/src/Fields/Level1234/SubstituteWithIDField.php +++ b/src/Fields/Dimensions/SubstituteWithIDField.php @@ -1,32 +1,32 @@ -substituteWithID; - } - - /** - * @param null|string $substituteWithID - * @return $this - */ - public function setSubstituteWithID(?string $substituteWithID): self - { - $this->substituteWithID = $substituteWithID; - return $this; - } +substituteWithID; + } + + /** + * @param null|string $substituteWithID + * @return $this + */ + public function setSubstituteWithID(?string $substituteWithID): self + { + $this->substituteWithID = $substituteWithID; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/SubstitutionLevelField.php b/src/Fields/Dimensions/SubstitutionLevelField.php similarity index 89% rename from src/Fields/Level1234/SubstitutionLevelField.php rename to src/Fields/Dimensions/SubstitutionLevelField.php index 12a9d637..493ee162 100644 --- a/src/Fields/Level1234/SubstitutionLevelField.php +++ b/src/Fields/Dimensions/SubstitutionLevelField.php @@ -1,32 +1,32 @@ -substitutionLevel; - } - - /** - * @param null|int $substitutionLevel - * @return $this - */ - public function setSubstitutionLevel(?int $substitutionLevel): self - { - $this->substitutionLevel = $substitutionLevel; - return $this; - } +substitutionLevel; + } + + /** + * @param null|int $substitutionLevel + * @return $this + */ + public function setSubstitutionLevel(?int $substitutionLevel): self + { + $this->substitutionLevel = $substitutionLevel; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Level1234/TypeField.php b/src/Fields/Dimensions/TypeField.php similarity index 95% rename from src/Fields/Level1234/TypeField.php rename to src/Fields/Dimensions/TypeField.php index b6a9f523..2bf3e5d7 100644 --- a/src/Fields/Level1234/TypeField.php +++ b/src/Fields/Dimensions/TypeField.php @@ -1,6 +1,6 @@ vatCodeFixed; - } - - public function getVatCodeFixedToString(): ?string - { - return ($this->getVatCodeFixed()) ? 'true' : 'false'; - } - - /** - * @param bool $vatCodeFixed - * @return $this - */ - public function setVatCodeFixed(?bool $vatCodeFixed): self - { - $this->vatCodeFixed = $vatCodeFixed; - return $this; - } - - /** - * @param string|null $vatCodeFixedString - * @return $this - * @throws Exception - */ - public function setVatCodeFixedFromString(?string $vatCodeFixedString) - { - return $this->setVatCodeFixed(filter_var($vatCodeFixedString, FILTER_VALIDATE_BOOLEAN)); - } +vatCodeFixed; + } + + public function getVatCodeFixedToString(): ?string + { + return ($this->getVatCodeFixed()) ? 'true' : 'false'; + } + + /** + * @param bool $vatCodeFixed + * @return $this + */ + public function setVatCodeFixed(?bool $vatCodeFixed): self + { + $this->vatCodeFixed = $vatCodeFixed; + return $this; + } + + /** + * @param string|null $vatCodeFixedString + * @return $this + * @throws Exception + */ + public function setVatCodeFixedFromString(?string $vatCodeFixedString) + { + return $this->setVatCodeFixed(filter_var($vatCodeFixedString, FILTER_VALIDATE_BOOLEAN)); + } } \ No newline at end of file diff --git a/src/Fields/Rate/RateTypeField.php b/src/Fields/Rate/TypeField.php similarity index 89% rename from src/Fields/Rate/RateTypeField.php rename to src/Fields/Rate/TypeField.php index 8cb95007..74b0c23e 100644 --- a/src/Fields/Rate/RateTypeField.php +++ b/src/Fields/Rate/TypeField.php @@ -1,41 +1,41 @@ -type; - } - - /** - * @param RateType|null $type - * @return $this - */ - public function setType(?RateType $type): self - { - $this->type = $type; - return $this; - } - - /** - * @param string|null $typeString - * @return $this - * @throws Exception - */ - public function setTypeFromString(?string $typeString) - { - return $this->setType(new RateType((string)$typeString)); - } +type; + } + + /** + * @param RateType|null $type + * @return $this + */ + public function setType(?RateType $type): self + { + $this->type = $type; + return $this; + } + + /** + * @param string|null $typeString + * @return $this + * @throws Exception + */ + public function setTypeFromString(?string $typeString) + { + return $this->setType(new RateType((string)$typeString)); + } } \ No newline at end of file diff --git a/src/Fields/User/UserLevelField.php b/src/Fields/User/LevelField.php similarity index 85% rename from src/Fields/User/UserLevelField.php rename to src/Fields/User/LevelField.php index 7157b36e..94805fda 100644 --- a/src/Fields/User/UserLevelField.php +++ b/src/Fields/User/LevelField.php @@ -1,32 +1,32 @@ -level; - } - - /** - * @param null|string $level - * @return $this - */ - public function setLevel(?string $level): self - { - $this->level = $level; - return $this; - } +level; + } + + /** + * @param null|string $level + * @return $this + */ + public function setLevel(?string $level): self + { + $this->level = $level; + return $this; + } } \ No newline at end of file diff --git a/src/FixedAsset.php b/src/FixedAsset.php index 19cbc5b5..c2618fc8 100644 --- a/src/FixedAsset.php +++ b/src/FixedAsset.php @@ -4,9 +4,9 @@ use PhpTwinfield\Fields\BehaviourField; use PhpTwinfield\Fields\CodeField; +use PhpTwinfield\Fields\Dimensions\DimensionGroup\GroupField; +use PhpTwinfield\Fields\Dimensions\DimensionType\TypeField; use PhpTwinfield\Fields\InUseField; -use PhpTwinfield\Fields\Level1234\DimensionGroup\GroupField; -use PhpTwinfield\Fields\Level1234\DimensionType\TypeField; use PhpTwinfield\Fields\NameField; use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\ShortNameField; diff --git a/src/FixedAssetFinancials.php b/src/FixedAssetFinancials.php index c2bd644c..211f52f3 100644 --- a/src/FixedAssetFinancials.php +++ b/src/FixedAssetFinancials.php @@ -2,14 +2,14 @@ namespace PhpTwinfield; -use PhpTwinfield\Fields\Level1234\AccountTypeField; -use PhpTwinfield\Fields\Level1234\LevelField; -use PhpTwinfield\Fields\Level1234\MatchTypeField; -use PhpTwinfield\Fields\Level1234\SubAnalyseField; -use PhpTwinfield\Fields\Level1234\SubstitutionLevelField; -use PhpTwinfield\Fields\Level1234\SubstituteWithField; -use PhpTwinfield\Fields\Level1234\SubstituteWithIDField; -use PhpTwinfield\Fields\Level1234\VatCodeFixedField; +use PhpTwinfield\Fields\Dimensions\AccountTypeField; +use PhpTwinfield\Fields\Dimensions\LevelField; +use PhpTwinfield\Fields\Dimensions\MatchTypeField; +use PhpTwinfield\Fields\Dimensions\SubAnalyseField; +use PhpTwinfield\Fields\Dimensions\SubstitutionLevelField; +use PhpTwinfield\Fields\Dimensions\SubstituteWithField; +use PhpTwinfield\Fields\Dimensions\SubstituteWithIDField; +use PhpTwinfield\Fields\Dimensions\VatCodeFixedField; use PhpTwinfield\Fields\VatCodeField; /** diff --git a/src/FixedAssetFixedAssets.php b/src/FixedAssetFixedAssets.php index 5427e477..7d9a7ff1 100644 --- a/src/FixedAssetFixedAssets.php +++ b/src/FixedAssetFixedAssets.php @@ -2,36 +2,36 @@ namespace PhpTwinfield; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\BeginPeriodField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\BeginPeriodLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\FreeText1LockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\FreeText2LockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\FreeText3LockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\FreeText4Field; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\FreeText4LockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\FreeText5Field; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\FreeText5LockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\LastDepreciationField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\LastDepreciationLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\MethodField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\MethodLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\NrOfPeriodsInheritedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\NrOfPeriodsLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\PercentageLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\PurchaseDateField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\PurchaseDateLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\ResidualValueField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\ResidualValueLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\SellDateField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\SellDateLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\StatusField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\StatusLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\StopValueField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\StopValueLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\TransactionLinesLockedField; use PhpTwinfield\Fields\FreeText1Field; use PhpTwinfield\Fields\FreeText2Field; use PhpTwinfield\Fields\FreeText3Field; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\BeginPeriodField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\BeginPeriodLockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\FreeText1LockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\FreeText2LockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\FreeText3LockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\FreeText4Field; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\FreeText4LockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\FreeText5Field; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\FreeText5LockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\LastDepreciationField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\LastDepreciationLockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\MethodField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\MethodLockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\NrOfPeriodsInheritedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\NrOfPeriodsLockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\PercentageLockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\PurchaseDateField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\PurchaseDateLockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\ResidualValueField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\ResidualValueLockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\SellDateField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\SellDateLockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\StatusField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\StatusLockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\StopValueField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\StopValueLockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\TransactionLinesLockedField; use PhpTwinfield\Fields\NrOfPeriodsField; use PhpTwinfield\Fields\PercentageField; diff --git a/src/FixedAssetTransactionLine.php b/src/FixedAssetTransactionLine.php index ead21e7c..855623a2 100644 --- a/src/FixedAssetTransactionLine.php +++ b/src/FixedAssetTransactionLine.php @@ -3,26 +3,26 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\Dim1Field; -use PhpTwinfield\Fields\Level1234\AmountField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\AmountLockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\CodeField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\CodeLockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\Dim1LockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\Dim2Field; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\Dim2LockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\Dim3Field; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\Dim3LockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\Dim4Field; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\Dim4LockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\Dim5Field; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\Dim5LockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\Dim6Field; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\Dim6LockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\LineField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\LineLockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\NumberField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\NumberLockedField; -use PhpTwinfield\Fields\Level1234\Level34\FixedAsset\PeriodLockedField; +use PhpTwinfield\Fields\Dimensions\AmountField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\AmountLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\CodeField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\CodeLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\Dim1LockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\Dim2Field; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\Dim2LockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\Dim3Field; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\Dim3LockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\Dim4Field; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\Dim4LockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\Dim5Field; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\Dim5LockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\Dim6Field; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\Dim6LockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\LineField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\LineLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\NumberField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\NumberLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\PeriodLockedField; use PhpTwinfield\Fields\PeriodField; /** diff --git a/src/GeneralLedger.php b/src/GeneralLedger.php index 76973c4e..05f3e48d 100644 --- a/src/GeneralLedger.php +++ b/src/GeneralLedger.php @@ -4,13 +4,13 @@ use PhpTwinfield\Fields\BehaviourField; use PhpTwinfield\Fields\CodeField; +use PhpTwinfield\Fields\Dimensions\BeginPeriodField; +use PhpTwinfield\Fields\Dimensions\BeginYearField; +use PhpTwinfield\Fields\Dimensions\DimensionGroup\GroupField; +use PhpTwinfield\Fields\Dimensions\DimensionType\TypeField; +use PhpTwinfield\Fields\Dimensions\EndPeriodField; +use PhpTwinfield\Fields\Dimensions\EndYearField; use PhpTwinfield\Fields\InUseField; -use PhpTwinfield\Fields\Level1234\BeginPeriodField; -use PhpTwinfield\Fields\Level1234\BeginYearField; -use PhpTwinfield\Fields\Level1234\DimensionGroup\GroupField; -use PhpTwinfield\Fields\Level1234\DimensionType\TypeField; -use PhpTwinfield\Fields\Level1234\EndPeriodField; -use PhpTwinfield\Fields\Level1234\EndYearField; use PhpTwinfield\Fields\NameField; use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\ShortNameField; diff --git a/src/GeneralLedgerChildValidation.php b/src/GeneralLedgerChildValidation.php index 8becf6a4..80535bc4 100644 --- a/src/GeneralLedgerChildValidation.php +++ b/src/GeneralLedgerChildValidation.php @@ -2,9 +2,9 @@ namespace PhpTwinfield; +use PhpTwinfield\Fields\Dimensions\LevelField; +use PhpTwinfield\Fields\Dimensions\TypeField; use PhpTwinfield\Fields\ElementValueField; -use PhpTwinfield\Fields\Level1234\LevelField; -use PhpTwinfield\Fields\Level1234\TypeField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/BalanceSheets diff --git a/src/GeneralLedgerFinancials.php b/src/GeneralLedgerFinancials.php index 5ccfed7a..ca6e3e2e 100644 --- a/src/GeneralLedgerFinancials.php +++ b/src/GeneralLedgerFinancials.php @@ -2,11 +2,11 @@ namespace PhpTwinfield; -use PhpTwinfield\Fields\Level1234\AccountTypeField; -use PhpTwinfield\Fields\Level1234\LevelField; -use PhpTwinfield\Fields\Level1234\MatchTypeField; -use PhpTwinfield\Fields\Level1234\SubAnalyseField; -use PhpTwinfield\Fields\Level1234\VatCodeFixedField; +use PhpTwinfield\Fields\Dimensions\AccountTypeField; +use PhpTwinfield\Fields\Dimensions\LevelField; +use PhpTwinfield\Fields\Dimensions\MatchTypeField; +use PhpTwinfield\Fields\Dimensions\SubAnalyseField; +use PhpTwinfield\Fields\Dimensions\VatCodeFixedField; use PhpTwinfield\Fields\VatCodeField; /** diff --git a/src/Project.php b/src/Project.php index a55b0495..c0dca89f 100644 --- a/src/Project.php +++ b/src/Project.php @@ -4,8 +4,8 @@ use PhpTwinfield\Fields\BehaviourField; use PhpTwinfield\Fields\CodeField; +use PhpTwinfield\Fields\Dimensions\DimensionType\TypeField; use PhpTwinfield\Fields\InUseField; -use PhpTwinfield\Fields\Level1234\DimensionType\TypeField; use PhpTwinfield\Fields\NameField; use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\ShortNameField; diff --git a/src/ProjectProjects.php b/src/ProjectProjects.php index 82caf045..a6887a75 100644 --- a/src/ProjectProjects.php +++ b/src/ProjectProjects.php @@ -3,20 +3,20 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\CustomerField; -use PhpTwinfield\Fields\Level1234\Level34\AuthoriserField; -use PhpTwinfield\Fields\Level1234\Level34\AuthoriserInheritField; -use PhpTwinfield\Fields\Level1234\Level34\AuthoriserLockedField; -use PhpTwinfield\Fields\Level1234\Level34\BillableField; -use PhpTwinfield\Fields\Level1234\Level34\BillableForRatioField; -use PhpTwinfield\Fields\Level1234\Level34\BillableInheritField; -use PhpTwinfield\Fields\Level1234\Level34\BillableLockedField; -use PhpTwinfield\Fields\Level1234\Level34\CustomerInheritField; -use PhpTwinfield\Fields\Level1234\Level34\CustomerLockedField; -use PhpTwinfield\Fields\Level1234\Level34\InvoiceDescriptionField; -use PhpTwinfield\Fields\Level1234\Level34\RateInheritField; -use PhpTwinfield\Fields\Level1234\Level34\RateLockedField; -use PhpTwinfield\Fields\Level1234\Level34\ValidFromField; -use PhpTwinfield\Fields\Level1234\Level34\ValidTillField; +use PhpTwinfield\Fields\Dimensions\Level34\AuthoriserField; +use PhpTwinfield\Fields\Dimensions\Level34\AuthoriserInheritField; +use PhpTwinfield\Fields\Dimensions\Level34\AuthoriserLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\BillableField; +use PhpTwinfield\Fields\Dimensions\Level34\BillableForRatioField; +use PhpTwinfield\Fields\Dimensions\Level34\BillableInheritField; +use PhpTwinfield\Fields\Dimensions\Level34\BillableLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\CustomerInheritField; +use PhpTwinfield\Fields\Dimensions\Level34\CustomerLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\InvoiceDescriptionField; +use PhpTwinfield\Fields\Dimensions\Level34\RateInheritField; +use PhpTwinfield\Fields\Dimensions\Level34\RateLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\ValidFromField; +use PhpTwinfield\Fields\Dimensions\Level34\ValidTillField; use PhpTwinfield\Fields\RateField; /** diff --git a/src/ProjectQuantity.php b/src/ProjectQuantity.php index ee7172ea..15e0d183 100644 --- a/src/ProjectQuantity.php +++ b/src/ProjectQuantity.php @@ -2,10 +2,10 @@ namespace PhpTwinfield; -use PhpTwinfield\Fields\Level1234\Level34\BillableField; -use PhpTwinfield\Fields\Level1234\Level34\BillableLockedField; -use PhpTwinfield\Fields\Level1234\Level34\LabelField; -use PhpTwinfield\Fields\Level1234\Level34\MandatoryField; +use PhpTwinfield\Fields\Dimensions\Level34\BillableField; +use PhpTwinfield\Fields\Dimensions\Level34\BillableLockedField; +use PhpTwinfield\Fields\Dimensions\Level34\LabelField; +use PhpTwinfield\Fields\Dimensions\Level34\MandatoryField; use PhpTwinfield\Fields\RateField; /** diff --git a/src/Rate.php b/src/Rate.php index 72112fb3..a4a95e71 100644 --- a/src/Rate.php +++ b/src/Rate.php @@ -8,7 +8,7 @@ use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\ShortNameField; use PhpTwinfield\Fields\StatusField; -use PhpTwinfield\Fields\Rate\RateTypeField; +use PhpTwinfield\Fields\Rate\TypeField; use PhpTwinfield\Fields\Rate\UnitField; use PhpTwinfield\Fields\UserField; @@ -25,7 +25,7 @@ class Rate extends BaseObject use OfficeField; use ShortNameField; use StatusField; - use RateTypeField; + use TypeField; use UnitField; use UserField; diff --git a/src/Supplier.php b/src/Supplier.php index 51d8fdb8..bed03cf4 100644 --- a/src/Supplier.php +++ b/src/Supplier.php @@ -4,20 +4,20 @@ use PhpTwinfield\Fields\BehaviourField; use PhpTwinfield\Fields\CodeField; +use PhpTwinfield\Fields\Dimensions\BeginPeriodField; +use PhpTwinfield\Fields\Dimensions\BeginYearField; +use PhpTwinfield\Fields\Dimensions\DimensionGroup\GroupField; +use PhpTwinfield\Fields\Dimensions\DimensionType\TypeField; +use PhpTwinfield\Fields\Dimensions\EndPeriodField; +use PhpTwinfield\Fields\Dimensions\EndYearField; +use PhpTwinfield\Fields\Dimensions\Level2\PaymentConditionDiscountDaysField; +use PhpTwinfield\Fields\Dimensions\Level2\PaymentConditionDiscountPercentageField; +use PhpTwinfield\Fields\Dimensions\Level2\RemittanceAdviceSendMailField; +use PhpTwinfield\Fields\Dimensions\Level2\RemittanceAdviceSendTypeField; +use PhpTwinfield\Fields\Dimensions\Level2\Supplier\BlockedAccountPaymentConditionsIncludeVatField; +use PhpTwinfield\Fields\Dimensions\Level2\Supplier\BlockedAccountPaymentConditionsPercentageField; +use PhpTwinfield\Fields\Dimensions\Level2\WebsiteField; use PhpTwinfield\Fields\InUseField; -use PhpTwinfield\Fields\Level1234\BeginPeriodField; -use PhpTwinfield\Fields\Level1234\BeginYearField; -use PhpTwinfield\Fields\Level1234\DimensionGroup\GroupField; -use PhpTwinfield\Fields\Level1234\DimensionType\TypeField; -use PhpTwinfield\Fields\Level1234\EndPeriodField; -use PhpTwinfield\Fields\Level1234\EndYearField; -use PhpTwinfield\Fields\Level1234\Level2\PaymentConditionDiscountDaysField; -use PhpTwinfield\Fields\Level1234\Level2\PaymentConditionDiscountPercentageField; -use PhpTwinfield\Fields\Level1234\Level2\RemittanceAdviceSendMailField; -use PhpTwinfield\Fields\Level1234\Level2\RemittanceAdviceSendTypeField; -use PhpTwinfield\Fields\Level1234\Level2\Supplier\BlockedAccountPaymentConditionsIncludeVatField; -use PhpTwinfield\Fields\Level1234\Level2\Supplier\BlockedAccountPaymentConditionsPercentageField; -use PhpTwinfield\Fields\Level1234\Level2\WebsiteField; use PhpTwinfield\Fields\NameField; use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\ShortNameField; diff --git a/src/SupplierAddress.php b/src/SupplierAddress.php index 6bc0b9e4..aa462f25 100644 --- a/src/SupplierAddress.php +++ b/src/SupplierAddress.php @@ -2,21 +2,21 @@ namespace PhpTwinfield; +use PhpTwinfield\Fields\Dimensions\Level2\CityField; +use PhpTwinfield\Fields\Dimensions\Level2\CountryField; +use PhpTwinfield\Fields\Dimensions\Level2\DefaultField; +use PhpTwinfield\Fields\Dimensions\Level2\EmailField; +use PhpTwinfield\Fields\Dimensions\Level2\Field1Field; +use PhpTwinfield\Fields\Dimensions\Level2\Field2Field; +use PhpTwinfield\Fields\Dimensions\Level2\Field3Field; +use PhpTwinfield\Fields\Dimensions\Level2\Field4Field; +use PhpTwinfield\Fields\Dimensions\Level2\Field5Field; +use PhpTwinfield\Fields\Dimensions\Level2\Field6Field; +use PhpTwinfield\Fields\Dimensions\Level2\PostcodeField; +use PhpTwinfield\Fields\Dimensions\Level2\TelefaxField; +use PhpTwinfield\Fields\Dimensions\Level2\TelephoneField; +use PhpTwinfield\Fields\Dimensions\Level2\TypeField; use PhpTwinfield\Fields\IDField; -use PhpTwinfield\Fields\Level1234\Level2\CityField; -use PhpTwinfield\Fields\Level1234\Level2\CountryField; -use PhpTwinfield\Fields\Level1234\Level2\DefaultField; -use PhpTwinfield\Fields\Level1234\Level2\EmailField; -use PhpTwinfield\Fields\Level1234\Level2\Field1Field; -use PhpTwinfield\Fields\Level1234\Level2\Field2Field; -use PhpTwinfield\Fields\Level1234\Level2\Field3Field; -use PhpTwinfield\Fields\Level1234\Level2\Field4Field; -use PhpTwinfield\Fields\Level1234\Level2\Field5Field; -use PhpTwinfield\Fields\Level1234\Level2\Field6Field; -use PhpTwinfield\Fields\Level1234\Level2\PostcodeField; -use PhpTwinfield\Fields\Level1234\Level2\TelefaxField; -use PhpTwinfield\Fields\Level1234\Level2\TelephoneField; -use PhpTwinfield\Fields\Level1234\Level2\TypeField; use PhpTwinfield\Fields\NameField; /** diff --git a/src/SupplierBank.php b/src/SupplierBank.php index f6164f73..50780881 100644 --- a/src/SupplierBank.php +++ b/src/SupplierBank.php @@ -2,21 +2,21 @@ namespace PhpTwinfield; +use PhpTwinfield\Fields\Dimensions\Level2\AccountNumberField; +use PhpTwinfield\Fields\Dimensions\Level2\AddressField2Field; +use PhpTwinfield\Fields\Dimensions\Level2\AddressField3Field; +use PhpTwinfield\Fields\Dimensions\Level2\AscriptionField; +use PhpTwinfield\Fields\Dimensions\Level2\BankBlockedField; +use PhpTwinfield\Fields\Dimensions\Level2\BankNameField; +use PhpTwinfield\Fields\Dimensions\Level2\BicCodeField; +use PhpTwinfield\Fields\Dimensions\Level2\CityField; +use PhpTwinfield\Fields\Dimensions\Level2\CountryField; +use PhpTwinfield\Fields\Dimensions\Level2\DefaultField; +use PhpTwinfield\Fields\Dimensions\Level2\IbanField; +use PhpTwinfield\Fields\Dimensions\Level2\NatBicCodeField; +use PhpTwinfield\Fields\Dimensions\Level2\PostcodeField; +use PhpTwinfield\Fields\Dimensions\Level2\StateField; use PhpTwinfield\Fields\IDField; -use PhpTwinfield\Fields\Level1234\Level2\AccountNumberField; -use PhpTwinfield\Fields\Level1234\Level2\AddressField2Field; -use PhpTwinfield\Fields\Level1234\Level2\AddressField3Field; -use PhpTwinfield\Fields\Level1234\Level2\AscriptionField; -use PhpTwinfield\Fields\Level1234\Level2\BankBlockedField; -use PhpTwinfield\Fields\Level1234\Level2\BankNameField; -use PhpTwinfield\Fields\Level1234\Level2\BicCodeField; -use PhpTwinfield\Fields\Level1234\Level2\CityField; -use PhpTwinfield\Fields\Level1234\Level2\CountryField; -use PhpTwinfield\Fields\Level1234\Level2\DefaultField; -use PhpTwinfield\Fields\Level1234\Level2\IbanField; -use PhpTwinfield\Fields\Level1234\Level2\NatBicCodeField; -use PhpTwinfield\Fields\Level1234\Level2\PostcodeField; -use PhpTwinfield\Fields\Level1234\Level2\StateField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers diff --git a/src/SupplierChildValidation.php b/src/SupplierChildValidation.php index 65fd0b83..2f03775e 100644 --- a/src/SupplierChildValidation.php +++ b/src/SupplierChildValidation.php @@ -2,9 +2,9 @@ namespace PhpTwinfield; +use PhpTwinfield\Fields\Dimensions\LevelField; +use PhpTwinfield\Fields\Dimensions\TypeField; use PhpTwinfield\Fields\ElementValueField; -use PhpTwinfield\Fields\Level1234\LevelField; -use PhpTwinfield\Fields\Level1234\TypeField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers diff --git a/src/SupplierFinancials.php b/src/SupplierFinancials.php index 539e176d..3f248dec 100644 --- a/src/SupplierFinancials.php +++ b/src/SupplierFinancials.php @@ -2,20 +2,20 @@ namespace PhpTwinfield; -use PhpTwinfield\Fields\Level1234\AccountTypeField; -use PhpTwinfield\Fields\Level1234\Level2\DueDaysField; -use PhpTwinfield\Fields\Level1234\Level2\Supplier\RelationsReferenceField; -use PhpTwinfield\Fields\Level1234\Level2\MeansOfPaymentField; -use PhpTwinfield\Fields\Level1234\Level2\PayAvailableField; -use PhpTwinfield\Fields\Level1234\Level2\PayCodeField; -use PhpTwinfield\Fields\Level1234\Level2\PayCodeIDField; -use PhpTwinfield\Fields\Level1234\LevelField; -use PhpTwinfield\Fields\Level1234\MatchTypeField; -use PhpTwinfield\Fields\Level1234\SubAnalyseField; -use PhpTwinfield\Fields\Level1234\SubstitutionLevelField; -use PhpTwinfield\Fields\Level1234\SubstituteWithField; -use PhpTwinfield\Fields\Level1234\SubstituteWithIDField; -use PhpTwinfield\Fields\Level1234\VatCodeFixedField; +use PhpTwinfield\Fields\Dimensions\AccountTypeField; +use PhpTwinfield\Fields\Dimensions\Level2\DueDaysField; +use PhpTwinfield\Fields\Dimensions\Level2\Supplier\RelationsReferenceField; +use PhpTwinfield\Fields\Dimensions\Level2\MeansOfPaymentField; +use PhpTwinfield\Fields\Dimensions\Level2\PayAvailableField; +use PhpTwinfield\Fields\Dimensions\Level2\PayCodeField; +use PhpTwinfield\Fields\Dimensions\Level2\PayCodeIDField; +use PhpTwinfield\Fields\Dimensions\LevelField; +use PhpTwinfield\Fields\Dimensions\MatchTypeField; +use PhpTwinfield\Fields\Dimensions\SubAnalyseField; +use PhpTwinfield\Fields\Dimensions\SubstitutionLevelField; +use PhpTwinfield\Fields\Dimensions\SubstituteWithField; +use PhpTwinfield\Fields\Dimensions\SubstituteWithIDField; +use PhpTwinfield\Fields\Dimensions\VatCodeFixedField; use PhpTwinfield\Fields\VatCodeField; /** diff --git a/src/SupplierLine.php b/src/SupplierLine.php index 8c2d6ac0..63e46cef 100644 --- a/src/SupplierLine.php +++ b/src/SupplierLine.php @@ -3,13 +3,13 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\DescriptionField; -use PhpTwinfield\Fields\Level1234\Level2\Dimension1Field; -use PhpTwinfield\Fields\Level1234\Level2\Dimension1IDField; -use PhpTwinfield\Fields\Level1234\Level2\Dimension2Field; -use PhpTwinfield\Fields\Level1234\Level2\Dimension2IDField; -use PhpTwinfield\Fields\Level1234\Level2\Dimension3Field; -use PhpTwinfield\Fields\Level1234\Level2\Dimension3IDField; -use PhpTwinfield\Fields\Level1234\Level2\RatioField; +use PhpTwinfield\Fields\Dimensions\Level2\Dimension1Field; +use PhpTwinfield\Fields\Dimensions\Level2\Dimension1IDField; +use PhpTwinfield\Fields\Dimensions\Level2\Dimension2Field; +use PhpTwinfield\Fields\Dimensions\Level2\Dimension2IDField; +use PhpTwinfield\Fields\Dimensions\Level2\Dimension3Field; +use PhpTwinfield\Fields\Dimensions\Level2\Dimension3IDField; +use PhpTwinfield\Fields\Dimensions\Level2\RatioField; use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\VatCodeField; diff --git a/src/SupplierPostingRule.php b/src/SupplierPostingRule.php index d080956a..da0a9f4e 100644 --- a/src/SupplierPostingRule.php +++ b/src/SupplierPostingRule.php @@ -4,8 +4,8 @@ use PhpTwinfield\Fields\CurrencyField; use PhpTwinfield\Fields\DescriptionField; +use PhpTwinfield\Fields\Dimensions\AmountField; use PhpTwinfield\Fields\IDField; -use PhpTwinfield\Fields\Level1234\AmountField; use PhpTwinfield\Fields\StatusField; /** diff --git a/src/User.php b/src/User.php index ac96d698..ac49c8a6 100644 --- a/src/User.php +++ b/src/User.php @@ -10,17 +10,17 @@ use PhpTwinfield\Fields\StatusField; use PhpTwinfield\Fields\TouchedField; use PhpTwinfield\Fields\User\IsCurrentUserField; -use PhpTwinfield\Fields\User\UserLevelField; +use PhpTwinfield\Fields\User\LevelField; class User extends BaseObject { use CodeField; use CreatedField; use IsCurrentUserField; + use LevelField; use ModifiedField; use NameField; use ShortNameField; use StatusField; - use TouchedField; - use UserLevelField; + use TouchedField; } From 13225d26e74af880f8d52f6242f4fd769cf7f9e6 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 12 May 2019 10:39:52 +0200 Subject: [PATCH 203/388] Upload --- src/Enums/AccountType.php | 8 +++++--- src/Enums/AddressType.php | 8 +++++--- src/Enums/ArticleType.php | 2 ++ src/Enums/Behaviour.php | 8 +++++--- .../BlockedAccountPaymentConditionsIncludeVat.php | 8 ++++---- src/Enums/BrowseColumnOperator.php | 8 +++++--- src/Enums/CalcMethod.php | 10 ++++++---- src/Enums/ChildValidationType.php | 8 +++++--- src/Enums/CollectionSchema.php | 6 ++++-- src/Enums/DebitCredit.php | 4 ++-- src/Enums/DepreciateReconciliation.php | 6 ++++-- src/Enums/Destiny.php | 6 ++++-- src/Enums/FixedAssetsStatus.php | 10 ++++++---- src/Enums/FreeTextType.php | 6 ++++-- src/Enums/InvoiceDebitCredit.php | 6 ++++-- src/Enums/InvoiceStatus.php | 8 +++++--- src/Enums/LineType.php | 2 ++ src/Enums/MatchType.php | 7 +++++-- src/Enums/MeansOfPayment.php | 8 +++++--- src/Enums/Order.php | 4 ++-- src/Enums/PaymentMethod.php | 12 +++++++----- src/Enums/PerformanceType.php | 8 ++++---- src/Enums/RateType.php | 2 ++ src/Enums/RemittanceAdviceSendType.php | 6 ++++-- src/Enums/SendReminder.php | 2 ++ src/Enums/Services.php | 4 ++-- src/Enums/Status.php | 8 +++++--- src/Enums/SubAnalyse.php | 8 +++++--- src/Enums/VatType.php | 4 ++-- src/Enums/WriteOffType.php | 2 ++ src/Mappers/InvoiceMapper.php | 2 +- 31 files changed, 120 insertions(+), 71 deletions(-) diff --git a/src/Enums/AccountType.php b/src/Enums/AccountType.php index 3b0dd081..7379b703 100644 --- a/src/Enums/AccountType.php +++ b/src/Enums/AccountType.php @@ -6,12 +6,14 @@ /** * @method static AccountType BALANCE() + * @method static AccountType EMPTY() * @method static AccountType INHERIT() * @method static AccountType PROFITANDLOSS() */ class AccountType extends Enum { - protected const BALANCE = 'balance'; - protected const INHERIT = 'inherit'; - protected const PROFITANDLOSS = 'profitandloss'; + public const BALANCE = 'balance'; + public const EMPTY = ''; + public const INHERIT = 'inherit'; + public const PROFITANDLOSS = 'profitandloss'; } \ No newline at end of file diff --git a/src/Enums/AddressType.php b/src/Enums/AddressType.php index 8308b0e4..d0743156 100644 --- a/src/Enums/AddressType.php +++ b/src/Enums/AddressType.php @@ -6,12 +6,14 @@ /** * @method static AddressType CONTACT() + * @method static AddressType EMPTY() * @method static AddressType INVOICE() * @method static AddressType POSTAL() */ class AddressType extends Enum { - protected const CONTACT = 'contact'; - protected const INVOICE = 'invoice'; - protected const POSTAL = 'postal'; + public const CONTACT = 'contact'; + public const EMPTY = ''; + public const INVOICE = 'invoice'; + public const POSTAL = 'postal'; } \ No newline at end of file diff --git a/src/Enums/ArticleType.php b/src/Enums/ArticleType.php index 434b4577..528f1033 100644 --- a/src/Enums/ArticleType.php +++ b/src/Enums/ArticleType.php @@ -6,12 +6,14 @@ /** * @method static ArticleType DISCOUNT() + * @method static ArticleType EMPTY() * @method static ArticleType NORMAL() * @method static ArticleType PREMIUM() */ class ArticleType extends Enum { public const DISCOUNT = "discount"; + public const EMPTY = ""; public const NORMAL = "normal"; public const PREMIUM = "premium"; } \ No newline at end of file diff --git a/src/Enums/Behaviour.php b/src/Enums/Behaviour.php index 9e7d92eb..4d13e18b 100644 --- a/src/Enums/Behaviour.php +++ b/src/Enums/Behaviour.php @@ -5,13 +5,15 @@ use MyCLabs\Enum\Enum; /** + * @method static Behaviour EMPTY() * @method static Behaviour NORMAL() * @method static Behaviour SYSTEM() * @method static Behaviour TEMPLATE() */ class Behaviour extends Enum { - protected const NORMAL = 'normal'; - protected const SYSTEM = 'system'; - protected const TEMPLATE = 'template'; + public const EMPTY = ''; + public const NORMAL = 'normal'; + public const SYSTEM = 'system'; + public const TEMPLATE = 'template'; } \ No newline at end of file diff --git a/src/Enums/BlockedAccountPaymentConditionsIncludeVat.php b/src/Enums/BlockedAccountPaymentConditionsIncludeVat.php index 1a9b5f20..9fdb40c3 100644 --- a/src/Enums/BlockedAccountPaymentConditionsIncludeVat.php +++ b/src/Enums/BlockedAccountPaymentConditionsIncludeVat.php @@ -5,13 +5,13 @@ use MyCLabs\Enum\Enum; /** + * @method static BlockedAccountPaymentConditionsIncludeVat EMPTY() * @method static BlockedAccountPaymentConditionsIncludeVat FALSE() - * @method static BlockedAccountPaymentConditionsIncludeVat NONE() * @method static BlockedAccountPaymentConditionsIncludeVat TRUE() */ class BlockedAccountPaymentConditionsIncludeVat extends Enum { - protected const FALSE = 'false'; - protected const NONE = ''; - protected const TRUE = 'true'; + public const EMPTY = ''; + public const FALSE = 'false'; + public const TRUE = 'true'; } \ No newline at end of file diff --git a/src/Enums/BrowseColumnOperator.php b/src/Enums/BrowseColumnOperator.php index 50eb1d11..d3c23433 100644 --- a/src/Enums/BrowseColumnOperator.php +++ b/src/Enums/BrowseColumnOperator.php @@ -6,12 +6,14 @@ /** * @method static BrowseColumnOperator BETWEEN() + * @method static BrowseColumnOperator EMPTY() * @method static BrowseColumnOperator EQUAL() * @method static BrowseColumnOperator NONE() */ class BrowseColumnOperator extends Enum { - protected const BETWEEN = 'between'; - protected const EQUAL = 'equal'; - protected const NONE = 'none'; + public const BETWEEN = 'between'; + public const EMPTY = ''; + public const EQUAL = 'equal'; + public const NONE = 'none'; } \ No newline at end of file diff --git a/src/Enums/CalcMethod.php b/src/Enums/CalcMethod.php index 07009e61..17916f72 100644 --- a/src/Enums/CalcMethod.php +++ b/src/Enums/CalcMethod.php @@ -5,6 +5,7 @@ use MyCLabs\Enum\Enum; /** + * @method static CalcMethod EMPTY() * @method static CalcMethod LINEAR() * @method static CalcMethod LINEARPERCENTAGE() * @method static CalcMethod NONE() @@ -12,8 +13,9 @@ */ class CalcMethod extends Enum { - protected const LINEAR = "linear"; - protected const LINEARPERCENTAGE = "linearpercentage"; - protected const NONE = "none"; - protected const REDUCEBALANCE = "reducebalance"; + public const EMPTY = ""; + public const LINEAR = "linear"; + public const LINEARPERCENTAGE = "linearpercentage"; + public const NONE = "none"; + public const REDUCEBALANCE = "reducebalance"; } \ No newline at end of file diff --git a/src/Enums/ChildValidationType.php b/src/Enums/ChildValidationType.php index e8aa812d..a8afb00a 100644 --- a/src/Enums/ChildValidationType.php +++ b/src/Enums/ChildValidationType.php @@ -6,12 +6,14 @@ /** * @method static ChildValidationType CODE() + * @method static ChildValidationType EMPTY() * @method static ChildValidationType GROUP() * @method static ChildValidationType TYPE() */ class ChildValidationType extends Enum { - protected const CODE = "code"; - protected const GROUP = "group"; - protected const TYPE = "type"; + public const CODE = "code"; + public const EMPTY = ""; + public const GROUP = "group"; + public const TYPE = "type"; } \ No newline at end of file diff --git a/src/Enums/CollectionSchema.php b/src/Enums/CollectionSchema.php index 8fb988e5..98f88624 100644 --- a/src/Enums/CollectionSchema.php +++ b/src/Enums/CollectionSchema.php @@ -7,9 +7,11 @@ /** * @method static CollectionSchema B2B() * @method static CollectionSchema CORE() + * @method static CollectionSchema EMPTY() */ class CollectionSchema extends Enum { - protected const B2B = "b2b"; - protected const CORE = "core"; + public const B2B = "b2b"; + public const CORE = "core"; + public const EMPTY = ""; } \ No newline at end of file diff --git a/src/Enums/DebitCredit.php b/src/Enums/DebitCredit.php index e2bd721e..7b5102cf 100644 --- a/src/Enums/DebitCredit.php +++ b/src/Enums/DebitCredit.php @@ -10,8 +10,8 @@ */ class DebitCredit extends Enum { - protected const CREDIT = "credit"; - protected const DEBIT = "debit"; + public const CREDIT = "credit"; + public const DEBIT = "debit"; final public function invert(): self { diff --git a/src/Enums/DepreciateReconciliation.php b/src/Enums/DepreciateReconciliation.php index e2435fb6..7b6794d9 100644 --- a/src/Enums/DepreciateReconciliation.php +++ b/src/Enums/DepreciateReconciliation.php @@ -5,11 +5,13 @@ use MyCLabs\Enum\Enum; /** + * @method static DepreciateReconciliation EMPTY() * @method static DepreciateReconciliation FROMPURCHASEDATE() * @method static DepreciateReconciliation FROMRECONCILIATION() */ class DepreciateReconciliation extends Enum { - protected const FROMPURCHASEDATE = "from_purchase_date"; - protected const FROMRECONCILIATION = "from_reconciliation"; + public const EMPTY = ""; + public const FROMPURCHASEDATE = "from_purchase_date"; + public const FROMRECONCILIATION = "from_reconciliation"; } \ No newline at end of file diff --git a/src/Enums/Destiny.php b/src/Enums/Destiny.php index 4c3c7555..397a2dcd 100644 --- a/src/Enums/Destiny.php +++ b/src/Enums/Destiny.php @@ -5,11 +5,13 @@ use MyCLabs\Enum\Enum; /** + * @method static Destiny EMPTY() * @method static Destiny TEMPORARY() * @method static Destiny FINAL() */ class Destiny extends Enum { - protected const TEMPORARY = 'temporary'; // Also called 'provisional' - protected const FINAL = 'final'; + public const EMPTY = ''; + public const FINAL = 'final'; + public const TEMPORARY = 'temporary'; // Also called 'provisional' } \ No newline at end of file diff --git a/src/Enums/FixedAssetsStatus.php b/src/Enums/FixedAssetsStatus.php index 3c989173..2059b1dc 100644 --- a/src/Enums/FixedAssetsStatus.php +++ b/src/Enums/FixedAssetsStatus.php @@ -6,14 +6,16 @@ /** * @method static FixedAssetsStatus ACTIVE() + * @method static FixedAssetsStatus EMPTY() * @method static FixedAssetsStatus INACTIVE() * @method static FixedAssetsStatus SOLD() * @method static FixedAssetsStatus TOBEACTIVATED() */ class FixedAssetsStatus extends Enum { - protected const ACTIVE = "active"; - protected const INACTIVE = "inactive"; - protected const SOLD = "sold"; - protected const TOBEACTIVATED = "tobeactivated"; + public const ACTIVE = "active"; + public const EMPTY = ""; + public const INACTIVE = "inactive"; + public const SOLD = "sold"; + public const TOBEACTIVATED = "tobeactivated"; } \ No newline at end of file diff --git a/src/Enums/FreeTextType.php b/src/Enums/FreeTextType.php index a51d3360..6be1e5a3 100644 --- a/src/Enums/FreeTextType.php +++ b/src/Enums/FreeTextType.php @@ -6,10 +6,12 @@ /** * @method static FreeTextType AMOUNT() + * @method static FreeTextType EMPTY() * @method static FreeTextType TEXT() */ class FreeTextType extends Enum { - protected const AMOUNT = 'amount'; - protected const TEXT = 'text'; + public const AMOUNT = 'amount'; + public const EMPTY = ''; + public const TEXT = 'text'; } \ No newline at end of file diff --git a/src/Enums/InvoiceDebitCredit.php b/src/Enums/InvoiceDebitCredit.php index 09c01eca..603aa86c 100644 --- a/src/Enums/InvoiceDebitCredit.php +++ b/src/Enums/InvoiceDebitCredit.php @@ -7,9 +7,11 @@ /** * @method static InvoiceDebitCredit CREDIT() * @method static InvoiceDebitCredit DEBIT() + * @method static InvoiceDebitCredit EMPTY() */ class InvoiceDebitCredit extends Enum { - protected const CREDIT = "C"; - protected const DEBIT = "D"; + public const CREDIT = "C"; + public const DEBIT = "D"; + public const EMPTY = ""; } \ No newline at end of file diff --git a/src/Enums/InvoiceStatus.php b/src/Enums/InvoiceStatus.php index 4e6e200c..21a58aeb 100644 --- a/src/Enums/InvoiceStatus.php +++ b/src/Enums/InvoiceStatus.php @@ -7,11 +7,13 @@ /** * @method static InvoiceStatus CONCEPT() * @method static InvoiceStatus DEFAULT() + * @method static InvoiceStatus EMPTY() * @method static InvoiceStatus FINAL() */ class InvoiceStatus extends Enum { - protected const CONCEPT = "concept"; // Also called 'provisional' - protected const DEFAULT = "default"; - protected const FINAL = "final"; + public const CONCEPT = "concept"; // Also called 'provisional' + public const DEFAULT = "default"; + public const EMPTY = ""; + public const FINAL = "final"; } \ No newline at end of file diff --git a/src/Enums/LineType.php b/src/Enums/LineType.php index eb59d043..70c4036b 100644 --- a/src/Enums/LineType.php +++ b/src/Enums/LineType.php @@ -6,12 +6,14 @@ /** * @method static LineType DETAIL() + * @method static LineType EMPTY() * @method static LineType TOTAL() * @method static LineType VAT() */ class LineType extends Enum { public const DETAIL = "detail"; + public const EMPTY = ""; public const TOTAL = "total"; public const VAT = "vat"; } \ No newline at end of file diff --git a/src/Enums/MatchType.php b/src/Enums/MatchType.php index 8d47d449..0ac1a0d1 100644 --- a/src/Enums/MatchType.php +++ b/src/Enums/MatchType.php @@ -6,12 +6,15 @@ /** * @method static MatchType CUSTOMERSUPPLIER() - * @method static MatchType NOTMATCHABLE() + * @method static MatchType EMPTY() * @method static MatchType MATCHABLE() + * @method static MatchType NOTMATCHABLE() */ class MatchType extends Enum { public const CUSTOMERSUPPLIER = "customersupplier"; - public const NOTMATCHABLE = "notmatchable"; + public const EMPTY = ""; public const MATCHABLE = "matchable"; + public const NOTMATCHABLE = "notmatchable"; + } \ No newline at end of file diff --git a/src/Enums/MeansOfPayment.php b/src/Enums/MeansOfPayment.php index cd2dcb6f..d4bb5193 100644 --- a/src/Enums/MeansOfPayment.php +++ b/src/Enums/MeansOfPayment.php @@ -6,12 +6,14 @@ /** * @method static MeansOfPayment CHEQUES() + * @method static MeansOfPayment EMPTY() * @method static MeansOfPayment NONE() * @method static MeansOfPayment PAYMENTFILE() */ class MeansOfPayment extends Enum { - protected const CHEQUES = 'cheques'; - protected const NONE = 'none'; - protected const PAYMENTFILE = 'paymentfile'; + public const CHEQUES = 'cheques'; + public const EMPTY = ''; + public const NONE = 'none'; + public const PAYMENTFILE = 'paymentfile'; } \ No newline at end of file diff --git a/src/Enums/Order.php b/src/Enums/Order.php index 58fbeca1..b9cf06f8 100644 --- a/src/Enums/Order.php +++ b/src/Enums/Order.php @@ -10,6 +10,6 @@ */ class Order extends Enum { - protected const ASCENDING = 'ascending'; - protected const DESCENDING = 'descending'; + public const ASCENDING = 'ascending'; + public const DESCENDING = 'descending'; } \ No newline at end of file diff --git a/src/Enums/PaymentMethod.php b/src/Enums/PaymentMethod.php index a06ea63c..47e2ef53 100644 --- a/src/Enums/PaymentMethod.php +++ b/src/Enums/PaymentMethod.php @@ -10,12 +10,14 @@ * @method static PaymentMethod CASHONDELIVERY() * @method static PaymentMethod CHEQUE() * @method static PaymentMethod DA() + * @method static PaymentMethod EMPTY() */ class PaymentMethod extends Enum { - protected const BANK = 'bank'; - protected const CASH = 'cash'; - protected const CASHONDELIVERY = 'cashondelivery'; - protected const CHEQUE = 'cheque'; - protected const DA = 'da'; + public const BANK = 'bank'; + public const CASH = 'cash'; + public const CASHONDELIVERY = 'cashondelivery'; + public const CHEQUE = 'cheque'; + public const DA = 'da'; + public const EMPTY = ''; } \ No newline at end of file diff --git a/src/Enums/PerformanceType.php b/src/Enums/PerformanceType.php index b7029bd3..62238c14 100644 --- a/src/Enums/PerformanceType.php +++ b/src/Enums/PerformanceType.php @@ -5,13 +5,13 @@ use MyCLabs\Enum\Enum; /** + * @method static PerformanceType EMPTY() * @method static PerformanceType GOODS() - * @method static PerformanceType NONE() * @method static PerformanceType SERVICES() */ class PerformanceType extends Enum { - protected const GOODS = "goods"; - protected const NONE = ""; - protected const SERVICES = "services"; + public const EMPTY = ""; + public const GOODS = "goods"; + public const SERVICES = "services"; } \ No newline at end of file diff --git a/src/Enums/RateType.php b/src/Enums/RateType.php index 92dfcdbd..bc7086c6 100644 --- a/src/Enums/RateType.php +++ b/src/Enums/RateType.php @@ -5,11 +5,13 @@ use MyCLabs\Enum\Enum; /** + * @method static RateType EMPTY() * @method static RateType QUANTITY() * @method static RateType TIME() */ class RateType extends Enum { + public const EMPTY = ""; public const QUANTITY = "quantity"; public const TIME = "time"; } \ No newline at end of file diff --git a/src/Enums/RemittanceAdviceSendType.php b/src/Enums/RemittanceAdviceSendType.php index b7cd3622..f7b0fdc0 100644 --- a/src/Enums/RemittanceAdviceSendType.php +++ b/src/Enums/RemittanceAdviceSendType.php @@ -6,10 +6,12 @@ /** * @method static RemittanceAdviceSendType BYEMAIL() + * @method static RemittanceAdviceSendType EMPTY() * @method static RemittanceAdviceSendType TOFILEMANAGER() */ class RemittanceAdviceSendType extends Enum { - protected const BYEMAIL = 'ByEmail'; - protected const TOFILEMANAGER = 'ToFileManager'; + public const BYEMAIL = 'ByEmail'; + public const EMPTY = ''; + public const TOFILEMANAGER = 'ToFileManager'; } \ No newline at end of file diff --git a/src/Enums/SendReminder.php b/src/Enums/SendReminder.php index 2fe3a752..e95ed053 100644 --- a/src/Enums/SendReminder.php +++ b/src/Enums/SendReminder.php @@ -6,12 +6,14 @@ /** * @method static SendReminder EMAIL() + * @method static SendReminder EMPTY() * @method static SendReminder FALSE() * @method static SendReminder TRUE() */ class SendReminder extends Enum { public const EMAIL = "email"; + public const EMPTY = ""; public const FALSE = "false"; public const TRUE = "true"; } \ No newline at end of file diff --git a/src/Enums/Services.php b/src/Enums/Services.php index 5f6a9a64..8f30bd9b 100644 --- a/src/Enums/Services.php +++ b/src/Enums/Services.php @@ -22,10 +22,10 @@ class Services extends \MyCLabs\Enum\Enum /** * Twinfield Finder web service methods. */ - protected const FINDER = FinderService::class; + public const FINDER = FinderService::class; /** * Twinfield Process XML web service methods. See below for an overview of the supported XML messages. */ - protected const PROCESSXML = ProcessXmlService::class; + public const PROCESSXML = ProcessXmlService::class; } \ No newline at end of file diff --git a/src/Enums/Status.php b/src/Enums/Status.php index 92cf915e..afa049c3 100644 --- a/src/Enums/Status.php +++ b/src/Enums/Status.php @@ -7,11 +7,13 @@ /** * @method static Status ACTIVE() * @method static Status DELETED() + * @method static Status EMPTY() * @method static Status HIDDEN() */ class Status extends Enum { - protected const ACTIVE = 'active'; - protected const DELETED = 'deleted'; - protected const HIDDEN = 'hide'; + public const ACTIVE = 'active'; + public const DELETED = 'deleted'; + public const EMPTY = ''; + public const HIDDEN = 'hide'; } \ No newline at end of file diff --git a/src/Enums/SubAnalyse.php b/src/Enums/SubAnalyse.php index 7c500f85..c3bb5462 100644 --- a/src/Enums/SubAnalyse.php +++ b/src/Enums/SubAnalyse.php @@ -5,13 +5,15 @@ use MyCLabs\Enum\Enum; /** + * @method static SubAnalyse EMPTY() * @method static SubAnalyse FALSE() * @method static SubAnalyse MAYBE() * @method static SubAnalyse TRUE() */ class SubAnalyse extends Enum { - protected const FALSE = 'false'; - protected const MAYBE = 'maybe'; - protected const TRUE = 'true'; + public const EMPTY = ''; + public const FALSE = 'false'; + public const MAYBE = 'maybe'; + public const TRUE = 'true'; } \ No newline at end of file diff --git a/src/Enums/VatType.php b/src/Enums/VatType.php index d60dffe5..f07a1bc3 100644 --- a/src/Enums/VatType.php +++ b/src/Enums/VatType.php @@ -5,13 +5,13 @@ use MyCLabs\Enum\Enum; /** - * @method static VatType NONE() + * @method static VatType EMPTY() * @method static VatType PURCHASE() * @method static VatType SALES() */ class VatType extends Enum { - public const NONE = ""; + public const EMPTY = ""; public const PURCHASE = "purchase"; public const SALES = "sales"; } \ No newline at end of file diff --git a/src/Enums/WriteOffType.php b/src/Enums/WriteOffType.php index cfa28b59..48979bb1 100644 --- a/src/Enums/WriteOffType.php +++ b/src/Enums/WriteOffType.php @@ -11,6 +11,7 @@ * * @method static self CURRENCY() * @method static self DISCOUNT() + * @method static self EMPTY() * @method static self WRITEOFF() * * @link https://c3.twinfield.com/webservices/documentation/#/ApiReference/Miscellaneous/Matching @@ -19,5 +20,6 @@ final class WriteOffType extends Enum { private const CURRENCY = "currency"; private const DISCOUNT = "discount"; + private const EMPTY = ""; private const WRITEOFF = "writeoff"; } \ No newline at end of file diff --git a/src/Mappers/InvoiceMapper.php b/src/Mappers/InvoiceMapper.php index 6cb896e7..820784dd 100644 --- a/src/Mappers/InvoiceMapper.php +++ b/src/Mappers/InvoiceMapper.php @@ -100,7 +100,7 @@ public static function map(Response $response) ->setPerformanceDate(self::parseDateAttribute(self::getField($invoiceLine, $lineElement, 'performancedate'))) ->setPerformanceType(self::parseEnumAttribute('PerformanceType', self::getField($invoiceLine, $lineElement, 'performancetype'))) ->setQuantity(self::getField($invoiceLine, $lineElement, 'quantity')) - ->setSubArticleFromString(self::getField($invoiceLine, $lineElement, 'subarticle')) + ->setSubArticle(self::parseObjectAttribute('ArticleLine', $invoiceLine, $lineElement, 'subarticle')) ->setUnits(self::getField($invoiceLine, $lineElement, 'units')) ->setUnitsPriceExcl(self::parseMoneyAttribute(self::getField($invoiceLine, $lineElement, 'unitspriceexcl'))) ->setUnitsPriceInc(self::parseMoneyAttribute(self::getField($invoiceLine, $lineElement, 'unitspriceinc'))) From d9869e1f171e27c6f8df380cafa928b098d06f85 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 12 May 2019 11:45:51 +0200 Subject: [PATCH 204/388] Upload --- composer.json | 8 +- readme.md | 88 +++++++++---------- src/ApiConnectors/ActivityApiConnector.php | 30 ++++++- src/ApiConnectors/ArticleApiConnector.php | 30 ++++++- src/ApiConnectors/AssetMethodApiConnector.php | 30 ++++++- src/ApiConnectors/CostCenterApiConnector.php | 30 ++++++- src/ApiConnectors/CurrencyApiConnector.php | 2 +- src/ApiConnectors/CustomerApiConnector.php | 30 ++++++- .../DimensionGroupApiConnector.php | 34 ++++++- .../DimensionTypeApiConnector.php | 2 +- src/ApiConnectors/FixedAssetApiConnector.php | 30 ++++++- .../GeneralLedgerApiConnector.php | 30 ++++++- src/ApiConnectors/OfficeApiConnector.php | 2 +- src/ApiConnectors/ProjectApiConnector.php | 30 ++++++- src/ApiConnectors/RateApiConnector.php | 30 ++++++- src/ApiConnectors/SupplierApiConnector.php | 30 ++++++- src/ApiConnectors/UserApiConnector.php | 2 +- src/ApiConnectors/VatCodeApiConnector.php | 30 ++++++- src/DomDocuments/AssetMethodsDocument.php | 6 ++ src/DomDocuments/InvoicesDocument.php | 8 +- 20 files changed, 414 insertions(+), 68 deletions(-) diff --git a/composer.json b/composer.json index 052f5938..ba25c2bd 100644 --- a/composer.json +++ b/composer.json @@ -31,15 +31,13 @@ "ext-dom": "*", "ext-json": "*", "ext-soap": "*", + "league/oauth2-client": "^2.2", "moneyphp/money": "^3.0", "myclabs/php-enum": "^1.5", "psr/http-message": "^1.0", "psr/log": "^1.0", "webmozart/assert": "^1.2" }, - "suggest": { - "league/oauth2-client": "If you want to use OAuth to login" - }, "autoload": { "psr-4": { "PhpTwinfield\\": "src/" @@ -54,8 +52,8 @@ "eloquent/liberator": "^2.0", "league/oauth2-client": "^2.2", "mediact/dependency-guard": "^1.0", + "mockery/mockery": "dev-master", "phpstan/phpstan": "^0.10.1", - "phpunit/phpunit": "^7.3", - "mockery/mockery": "dev-master" + "phpunit/phpunit": "^7.3" } } diff --git a/readme.md b/readme.md index 176603e3..900dc646 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@ A PHP library for Twinfield Integration. Use the Twinfield SOAP Services to have your PHP application communicate directly with your Twinfield account. -**:warning: Note that this libary is *not* created or mainained by Twinfield. You can only get support on the code in this library here. For any questions related to your Twinfield administration or how to do certain things with the Twinfield API, contact your Twinfield account manager.** +**:warning: Note that this libary is *not* created or mainained by Twinfield. You can only get support on the code in this library here. For any questions related to your Twinfield administration or how to do certain things with the Twinfield API, contact your Twinfield account manager.** ## Installation @@ -16,10 +16,10 @@ composer require 'php-twinfield/twinfield:^2.0' ## Usage ### Authentication -You need to set up a `\PhpTwinfield\Secure\AuthenticatedConnection` class with your credentials. +You need to set up a `\PhpTwinfield\Secure\AuthenticatedConnection` class with your credentials. #### Session Login -**:warning: Note that Twinfield has stated that session login is deprecated and will be removed. End of life date will be announced later. See https://c3.twinfield.com/webservices/documentation/#/ApiReference/Authentication/WebServices** +**:warning: Note that Twinfield has stated that session login is deprecated and will be removed. End of life date will be announced later. See https://c3.twinfield.com/webservices/documentation/#/ApiReference/Authentication/WebServices** When using basic username and password authentication, the `\PhpTwinfield\Secure\WebservicesAuthentication` class should be used, as follows: @@ -58,7 +58,7 @@ if (!isset($_GET['code'])) { $options = [ 'scope' => ['twf.user','twf.organisation','twf.organisationUser','offline_access','openid'] ]; - + $authorizationUrl = $provider->getAuthorizationUrl($options); // Get the state generated for you and store it to the session. @@ -73,7 +73,7 @@ if (!isset($_GET['code'])) { if (isset($_SESSION['oauth2state'])) { unset($_SESSION['oauth2state']); } - + exit('Invalid state'); } else { try { @@ -82,28 +82,28 @@ if (!isset($_GET['code'])) { 'code' => $_GET['code'] ]); - //Twinfield's Refresh Token is valid for 550 days. + //Twinfield's Refresh Token is valid for 550 days. //Remember to put in place functionality to request the user to renew their authorization. //This can be done by requesting the user to reload this page and logging into Twinfield //before the refresh token is invalidated after 550 days. - $refresh_expiry = strtotime(date('Ymd') . " +550 days"); - + $refresh_expiry = strtotime(date('Ymd') . " +550 days"); + //Save Refresh Token and Refresh Token Expiry Time to storage $refreshTokenStorage = array(); $refreshTokenStorage['refresh_token'] = $accessToken->getRefreshToken(); $refreshTokenStorage['refresh_expiry'] = $refresh_expiry; - + SaveRefreshTokenToStore($refreshTokenStorage); - + //OPTIONAL: Save Access Token, Access Token Expiry Time and Cluster to storage $validationUrl = "https://login.twinfield.com/auth/authentication/connect/accesstokenvalidation?token="; $validationResult = @file_get_contents($validationUrl . urlencode($accessToken->getToken())); if ($validationResult !== false) { - $resultDecoded = \json_decode($validationResult, true); + $resultDecoded = \json_decode($validationResult, true); $accessTokenStorage = array(); $accessTokenStorage['access_token'] = $accessToken->getToken(); - $accessTokenStorage['access_expiry'] = $accessToken->getExpires(); + $accessTokenStorage['access_expiry'] = $accessToken->getExpires(); $accessTokenStorage['access_cluster'] = $resultDecoded["twf.clusterUrl"]; SaveAccessTokenToStore($accessTokenStorage); } @@ -115,7 +115,7 @@ if (!isset($_GET['code'])) { ``` ##### Optionally: Store a valid access token and cluster through a sceduled task/cron job running in the background -Running the following code every 60 minutes (or a bit less as Access Tokens are valid for exactly 60 minutes) will reduce connection time when working with the Api (by about 2 seconds). It will also reduce connection load on Twinfield when making more than 20-30 connections/day. +Running the following code every 60 minutes (or a bit less as Access Tokens are valid for exactly 60 minutes) will reduce connection time when working with the Api (by about 2 seconds). It will also reduce connection load on Twinfield when making more than 20-30 connections/day. ```php $refreshTokenStorage = retrieveRefreshTokenFromStore(); @@ -174,7 +174,7 @@ if ($accessTokenStorage['access_expiry'] > time()) { In order to communicate with the Twinfield API, you need to create an `ApiConnector` instance for the corresponding resource and use the `get()` or `list()` method. -The `ApiConnector` takes a `Secure\AuthenticatedConnection` object: +The `ApiConnector` takes a `Secure\AuthenticatedConnection` object: An example: @@ -221,7 +221,7 @@ $customer->addAddress($customer_address); $customer_factory->send($customer); ``` -You can also send multiple objects in one batch, chunking is handled automatically. +You can also send multiple objects in one batch, chunking is handled automatically. ### Browse data In order to get financial data out of Twinfield like general ledger transactions, sales invoices, and so on, you can use the the browse data functionality. @@ -230,7 +230,7 @@ More information about the browse data functionality in Twinfield can be found i #### Browse definition You can retrieve the browse definition of a browse code as follows. -You don't need to retrieve the browse definition for getting the browse data. It's only for viewing the browse definition of a browse code to know exactly which columns are available. +You don't need to retrieve the browse definition for getting the browse data. It's only for viewing the browse definition of a browse code to know exactly which columns are available. ```php $connector = new BrowseDataApiConnector($connection); @@ -314,35 +314,35 @@ $browseData = $connector->getBrowseData('000', $columns, $sortFields); Not all resources from the Twinfield API are currently implemented. Feel free to create a pull request when you need support for another resource. -| Component | get() | listAll() | send() | delete() | Mapper | -| --------------------------------------------------------------------------------------------------------------- | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | -| [Activities](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Activities) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| [Articles](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Articles) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| [Asset Methods](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/AssetMethods) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| [Browse Data](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Request/BrowseData) | :white_check_mark: | | | | :white_check_mark: | -| Cash and Bank books | | :white_check_mark: | | | :white_check_mark: | -| [Cost Centers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/CostCenters) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| Countries | | :white_check_mark: | | | :white_check_mark: | -| [Currencies](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Currencies) | | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| [Customers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| [Dimension Groups](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionGroups) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| [Dimension Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionTypes) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| [Electronic Bank Statements](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankStatements)| | | :white_check_mark: | | | -| [Fixed Assets](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/FixedAssets) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| [General Ledger Accounts](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/BalanceSheets) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| [Matching](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Miscellaneous/Matching) | | | :white_check_mark: | | :white_check_mark: | | -| [Offices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Offices) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | -| Paycodes | | :white_check_mark: | | | :white_check_mark: | -| [Projects](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Projects) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| [Rates](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Rates) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| [Sales Invoices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| [Sales Invoice Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | | :white_check_mark: | | | :white_check_mark: | -| [Suppliers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| Component | get() | listAll() | send() | delete() | Mapper | +| --------------------------------------------------------------------------------------------------------------- | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | +| [Activities](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Activities) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| [Articles](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Articles) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| [Asset Methods](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/AssetMethods) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| [Browse Data](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Request/BrowseData) | :white_check_mark: | | | | :white_check_mark: | +| Cash and Bank books | | :white_check_mark: | | | :white_check_mark: | +| [Cost Centers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/CostCenters) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| Countries | | :white_check_mark: | | | :white_check_mark: | +| [Currencies](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Currencies) | | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| [Customers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| [Dimension Groups](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionGroups) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| [Dimension Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionTypes) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| [Electronic Bank Statements](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankStatements)| | | :white_check_mark: | | | | +| [Fixed Assets](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/FixedAssets) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| [General Ledger Accounts](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/BalanceSheets) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| [Matching](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Miscellaneous/Matching) | | | :white_check_mark: | | :white_check_mark: | +| [Offices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Offices) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | +| Paycodes | | :white_check_mark: | | | :white_check_mark: | +| [Projects](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Projects) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| [Rates](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Rates) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| [Sales Invoices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| [Sales Invoice Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | | :white_check_mark: | | | :white_check_mark: | +| [Suppliers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | Transactions:
[Purchase](https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions), [Sale](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions), [Journal](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/JournalTransactions), [Cash](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/CashTransactions), [Bank](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| [Users](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Users) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | -| User Roles | | :white_check_mark: | | | :white_check_mark: | -| [VAT](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/VAT) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| VAT Groups | | :white_check_mark: | | | :white_check_mark: | +| [Users](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Users) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | +| User Roles | | :white_check_mark: | | | :white_check_mark: | +| [VAT](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/VAT) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| VAT Groups | | :white_check_mark: | | | :white_check_mark: | ## Links diff --git a/src/ApiConnectors/ActivityApiConnector.php b/src/ApiConnectors/ActivityApiConnector.php index 393165e7..9cf89062 100644 --- a/src/ApiConnectors/ActivityApiConnector.php +++ b/src/ApiConnectors/ActivityApiConnector.php @@ -30,7 +30,7 @@ class ActivityApiConnector extends BaseApiConnector * @param string $code * @param Office $office If no office has been passed it will instead take the default office from the * passed in config class. - * @return Activity|bool The requested activity or false if it can't be found. + * @return Activity The requested Activity or Activity object with error message if it can't be found. * @throws Exception */ public function get(string $code, Office $office): Activity @@ -123,4 +123,32 @@ public function listAll( return $this->mapListAll("Activity", $response->data, $activityArrayListAllTags); } + + /** + * Deletes a specific Activity based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return Activity The deleted Activity or Activity object with error message if it can't be found. + * @throws Exception + */ + public function delete(string $code, Office $office): Activity + { + $activity = self::get($code, $office); + + if ($activity->getResult() == 1) { + $activity->setStatusFromString("deleted"); + + try { + $activityDeleted = self::send($activity); + } catch (ResponseException $e) { + $activityDeleted = $e->getReturnedObject(); + } + + return $activityDeleted; + } else { + return $activity; + } + } } \ No newline at end of file diff --git a/src/ApiConnectors/ArticleApiConnector.php b/src/ApiConnectors/ArticleApiConnector.php index 62bbbe0d..0b2dc3d6 100644 --- a/src/ApiConnectors/ArticleApiConnector.php +++ b/src/ApiConnectors/ArticleApiConnector.php @@ -30,7 +30,7 @@ class ArticleApiConnector extends BaseApiConnector * @param string $code * @param Office $office If no office has been passed it will instead take the default office from the * passed in config class. - * @return Article|bool The requested article or false if it can't be found. + * @return Article The requested Article or Article object with error message if it can't be found. * @throws Exception */ public function get(string $code, Office $office): Article @@ -121,4 +121,32 @@ public function listAll( return $this->mapListAll("Article", $response->data, $articleArrayListAllTags); } + + /** + * Deletes a specific Article based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return Article The deleted Article or Article object with error message if it can't be found. + * @throws Exception + */ + public function delete(string $code, Office $office): Article + { + $article = self::get($code, $office); + + if ($article->getResult() == 1) { + $article->setStatusFromString("deleted"); + + try { + $articleDeleted = self::send($article); + } catch (ResponseException $e) { + $articleDeleted = $e->getReturnedObject(); + } + + return $articleDeleted; + } else { + return $article; + } + } } \ No newline at end of file diff --git a/src/ApiConnectors/AssetMethodApiConnector.php b/src/ApiConnectors/AssetMethodApiConnector.php index ead16b6d..5497e099 100644 --- a/src/ApiConnectors/AssetMethodApiConnector.php +++ b/src/ApiConnectors/AssetMethodApiConnector.php @@ -30,7 +30,7 @@ class AssetMethodApiConnector extends BaseApiConnector * @param string $code * @param Office $office If no office has been passed it will instead take the default office from the * passed in config class. - * @return AssetMethod|bool The requested asset method or false if it can't be found. + * @return AssetMethod The requested AssetMethod or AssetMethod object with error message if it can't be found. * @throws Exception */ public function get(string $code, Office $office): AssetMethod @@ -122,4 +122,32 @@ public function listAll( return $this->mapListAll("AssetMethod", $response->data, $assetMethodArrayListAllTags); } + + /** + * Deletes a specific AssetMethod based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return AssetMethod The deleted AssetMethod or AssetMethod object with error message if it can't be found. + * @throws Exception + */ + public function delete(string $code, Office $office): AssetMethod + { + $assetMethod = self::get($code, $office); + + if ($assetMethod->getResult() == 1) { + $assetMethod->setStatusFromString("deleted"); + + try { + $assetMethodDeleted = self::send($assetMethod); + } catch (ResponseException $e) { + $assetMethodDeleted = $e->getReturnedObject(); + } + + return $assetMethodDeleted; + } else { + return $assetMethod; + } + } } \ No newline at end of file diff --git a/src/ApiConnectors/CostCenterApiConnector.php b/src/ApiConnectors/CostCenterApiConnector.php index 9ca4f271..f8245c6b 100644 --- a/src/ApiConnectors/CostCenterApiConnector.php +++ b/src/ApiConnectors/CostCenterApiConnector.php @@ -30,7 +30,7 @@ class CostCenterApiConnector extends BaseApiConnector * @param string $code * @param Office $office If no office has been passed it will instead take the default office from the * passed in config class. - * @return CostCenter|bool The requested cost center or false if it can't be found. + * @return CostCenter The requested CostCenter or CostCenter object with error message if it can't be found. * @throws Exception */ public function get(string $code, Office $office): CostCenter @@ -123,4 +123,32 @@ public function listAll( return $this->mapListAll("CostCenter", $response->data, $costCenterArrayListAllTags); } + + /** + * Deletes a specific CostCenter based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return CostCenter The deleted CostCenter or CostCenter object with error message if it can't be found. + * @throws Exception + */ + public function delete(string $code, Office $office): CostCenter + { + $costCenter = self::get($code, $office); + + if ($costCenter->getResult() == 1) { + $costCenter->setStatusFromString("deleted"); + + try { + $costCenterDeleted = self::send($costCenter); + } catch (ResponseException $e) { + $costCenterDeleted = $e->getReturnedObject(); + } + + return $costCenterDeleted; + } else { + return $costCenter; + } + } } \ No newline at end of file diff --git a/src/ApiConnectors/CurrencyApiConnector.php b/src/ApiConnectors/CurrencyApiConnector.php index acaace00..00577201 100644 --- a/src/ApiConnectors/CurrencyApiConnector.php +++ b/src/ApiConnectors/CurrencyApiConnector.php @@ -31,7 +31,7 @@ class CurrencyApiConnector extends BaseApiConnector * @param string $code * @param Office $office If no office has been passed it will instead take the default office from the * passed in config class. - * @return Currency|bool The requested currency or false if it can't be found. + * @return Currency The requested Currency or Currency object with error message if it can't be found. * @throws Exception */ diff --git a/src/ApiConnectors/CustomerApiConnector.php b/src/ApiConnectors/CustomerApiConnector.php index 47bfe7fa..e91f8955 100644 --- a/src/ApiConnectors/CustomerApiConnector.php +++ b/src/ApiConnectors/CustomerApiConnector.php @@ -31,7 +31,7 @@ class CustomerApiConnector extends BaseApiConnector * @param string $code * @param Office $office If no office has been passed it will instead take the default office from the * passed in config class. - * @return Customer|bool The requested customer or false if it can't be found. + * @return Customer The requested Customer or Customer object with error message if it can't be found. * @throws Exception */ public function get(string $code, Office $office): Customer @@ -123,4 +123,32 @@ public function listAll( return $this->mapListAll("Customer", $response->data, $customerListAllTags); } + + /** + * Deletes a specific Customer based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return Customer The deleted Customer or Customer object with error message if it can't be found. + * @throws Exception + */ + public function delete(string $code, Office $office): Customer + { + $customer = self::get($code, $office); + + if ($customer->getResult() == 1) { + $customer->setStatusFromString("deleted"); + + try { + $customerDeleted = self::send($customer); + } catch (ResponseException $e) { + $customerDeleted = $e->getReturnedObject(); + } + + return $customerDeleted; + } else { + return $customer; + } + } } \ No newline at end of file diff --git a/src/ApiConnectors/DimensionGroupApiConnector.php b/src/ApiConnectors/DimensionGroupApiConnector.php index 9f5d339a..dca0ddd7 100644 --- a/src/ApiConnectors/DimensionGroupApiConnector.php +++ b/src/ApiConnectors/DimensionGroupApiConnector.php @@ -28,9 +28,9 @@ class DimensionGroupApiConnector extends BaseApiConnector * Requests a specific DimensionGroup based off the passed in code and optionally the office. * * @param string $code - * @param Office $office If no office has been passed it will instead take the default office from the - * passed in config class. - * @return DimensionGroup|bool The requested dimension group or false if it can't be found. + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return DimensionGroup The requested DimensionGroup or DimensionGroup object with error message if it can't be found. * @throws Exception */ public function get(string $code, Office $office): DimensionGroup @@ -122,4 +122,32 @@ public function listAll( return $this->mapListAll("DimensionGroup", $response->data, $dimensionGroupListAllTags); } + + /** + * Deletes a specific DimensionGroup based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return DimensionGroup The deleted DimensionGroup or DimensionGroup object with error message if it can't be found. + * @throws Exception + */ + public function delete(string $code, Office $office): DimensionGroup + { + $dimensionGroup = self::get($code, $office); + + if ($dimensionGroup->getResult() == 1) { + $dimensionGroup->setStatusFromString("deleted"); + + try { + $dimensionGroupDeleted = self::send($dimensionGroup); + } catch (ResponseException $e) { + $dimensionGroupDeleted = $e->getReturnedObject(); + } + + return $dimensionGroupDeleted; + } else { + return $dimensionGroup; + } + } } \ No newline at end of file diff --git a/src/ApiConnectors/DimensionTypeApiConnector.php b/src/ApiConnectors/DimensionTypeApiConnector.php index 879a8a46..a32eaf77 100644 --- a/src/ApiConnectors/DimensionTypeApiConnector.php +++ b/src/ApiConnectors/DimensionTypeApiConnector.php @@ -30,7 +30,7 @@ class DimensionTypeApiConnector extends BaseApiConnector * @param string $code * @param Office $office If no office has been passed it will instead take the default office from the * passed in config class. - * @return DimensionType|bool The requested dimension type or false if it can't be found. + * @return DimensionType The requested DimensionType or DimensionType object with error message if it can't be found. * @throws Exception */ public function get(string $code, Office $office): DimensionType diff --git a/src/ApiConnectors/FixedAssetApiConnector.php b/src/ApiConnectors/FixedAssetApiConnector.php index b4b14d0b..70022a4e 100644 --- a/src/ApiConnectors/FixedAssetApiConnector.php +++ b/src/ApiConnectors/FixedAssetApiConnector.php @@ -30,7 +30,7 @@ class FixedAssetApiConnector extends BaseApiConnector * @param string $code * @param Office $office If no office has been passed it will instead take the default office from the * passed in config class. - * @return FixedAsset|bool The requested fixed asset or false if it can't be found. + * @return FixedAsset The requested FixedAsset or FixedAsset object with error message if it can't be found. * @throws Exception */ public function get(string $code, Office $office): FixedAsset @@ -122,4 +122,32 @@ public function listAll( return $this->mapListAll("FixedAsset", $response->data, $fixedAssetListAllTags); } + + /** + * Deletes a specific FixedAsset based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return FixedAsset The deleted FixedAsset or FixedAsset object with error message if it can't be found. + * @throws Exception + */ + public function delete(string $code, Office $office): FixedAsset + { + $fixedAsset = self::get($code, $office); + + if ($fixedAsset->getResult() == 1) { + $fixedAsset->setStatusFromString("deleted"); + + try { + $fixedAssetDeleted = self::send($fixedAsset); + } catch (ResponseException $e) { + $fixedAssetDeleted = $e->getReturnedObject(); + } + + return $fixedAssetDeleted; + } else { + return $fixedAsset; + } + } } \ No newline at end of file diff --git a/src/ApiConnectors/GeneralLedgerApiConnector.php b/src/ApiConnectors/GeneralLedgerApiConnector.php index 46d7cb6f..c46c22a1 100644 --- a/src/ApiConnectors/GeneralLedgerApiConnector.php +++ b/src/ApiConnectors/GeneralLedgerApiConnector.php @@ -30,7 +30,7 @@ class GeneralLedgerApiConnector extends BaseApiConnector * @param string $code * @param Office $office If no office has been passed it will instead take the default office from the * passed in config class. - * @return GeneralLedger|bool The requested general ledger or false if it can't be found. + * @return GeneralLedger The requested GeneralLedger or GeneralLedger object with error message if it can't be found. * @throws Exception */ public function get(string $code, string $dimType, Office $office): GeneralLedger @@ -123,4 +123,32 @@ public function listAll( return $this->mapListAll("GeneralLedger", $response->data, $generalLedgerListAllTags); } + + /** + * Deletes a specific GeneralLedger based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return GeneralLedger The deleted GeneralLedger or GeneralLedger object with error message if it can't be found. + * @throws Exception + */ + public function delete(string $code, Office $office): GeneralLedger + { + $generalLedger = self::get($code, $office); + + if ($generalLedger->getResult() == 1) { + $generalLedger->setStatusFromString("deleted"); + + try { + $generalLedgerDeleted = self::send($generalLedger); + } catch (ResponseException $e) { + $generalLedgerDeleted = $e->getReturnedObject(); + } + + return $generalLedgerDeleted; + } else { + return $generalLedger; + } + } } \ No newline at end of file diff --git a/src/ApiConnectors/OfficeApiConnector.php b/src/ApiConnectors/OfficeApiConnector.php index 534dfdd3..7c7798db 100644 --- a/src/ApiConnectors/OfficeApiConnector.php +++ b/src/ApiConnectors/OfficeApiConnector.php @@ -24,7 +24,7 @@ class OfficeApiConnector extends BaseApiConnector * Requests a specific Office based off the passed in code. * * @param string $code - * @return Office|bool The requested office or false if it can't be found. + * @return Office The requested Office or Office object with error message if it can't be found. * @throws Exception */ public function get(string $code): Office diff --git a/src/ApiConnectors/ProjectApiConnector.php b/src/ApiConnectors/ProjectApiConnector.php index 8e9b00c9..1c66f453 100644 --- a/src/ApiConnectors/ProjectApiConnector.php +++ b/src/ApiConnectors/ProjectApiConnector.php @@ -30,7 +30,7 @@ class ProjectApiConnector extends BaseApiConnector * @param string $code * @param Office $office If no office has been passed it will instead take the default office from the * passed in config class. - * @return Project|bool The requested project or false if it can't be found. + * @return Project The requested Project or Project object with error message if it can't be found. * @throws Exception */ public function get(string $code, Office $office): Project @@ -123,4 +123,32 @@ public function listAll( return $this->mapListAll("Project", $response->data, $projectListAllTags); } + + /** + * Deletes a specific Project based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return Project The deleted Project or Project object with error message if it can't be found. + * @throws Exception + */ + public function delete(string $code, Office $office): Project + { + $project = self::get($code, $office); + + if ($project->getResult() == 1) { + $project->setStatusFromString("deleted"); + + try { + $projectDeleted = self::send($project); + } catch (ResponseException $e) { + $projectDeleted = $e->getReturnedObject(); + } + + return $projectDeleted; + } else { + return $project; + } + } } \ No newline at end of file diff --git a/src/ApiConnectors/RateApiConnector.php b/src/ApiConnectors/RateApiConnector.php index ef902c87..c64415c4 100644 --- a/src/ApiConnectors/RateApiConnector.php +++ b/src/ApiConnectors/RateApiConnector.php @@ -30,7 +30,7 @@ class RateApiConnector extends BaseApiConnector * @param string $code * @param Office $office If no office has been passed it will instead take the default office from the * passed in config class. - * @return Rate|bool The requested rate or false if it can't be found. + * @return Rate The requested Rate or Rate object with error message if it can't be found. * @throws Exception */ public function get(string $code, Office $office): Rate @@ -122,4 +122,32 @@ public function listAll( return $this->mapListAll("Rate", $response->data, $rateListAllTags); } + + /** + * Deletes a specific Rate based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return Rate The deleted Rate or Rate object with error message if it can't be found. + * @throws Exception + */ + public function delete(string $code, Office $office): Rate + { + $rate = self::get($code, $office); + + if ($rate->getResult() == 1) { + $rate->setStatusFromString("deleted"); + + try { + $rateDeleted = self::send($rate); + } catch (ResponseException $e) { + $rateDeleted = $e->getReturnedObject(); + } + + return $rateDeleted; + } else { + return $rate; + } + } } \ No newline at end of file diff --git a/src/ApiConnectors/SupplierApiConnector.php b/src/ApiConnectors/SupplierApiConnector.php index adb2fab7..8332206f 100644 --- a/src/ApiConnectors/SupplierApiConnector.php +++ b/src/ApiConnectors/SupplierApiConnector.php @@ -31,7 +31,7 @@ class SupplierApiConnector extends BaseApiConnector * @param string $code * @param Office $office If no office has been passed it will instead take the default office from the * passed in config class. - * @return Supplier|bool The requested supplier or false if it can't be found. + * @return Supplier The requested Supplier or Supplier object with error message if it can't be found. * @throws Exception */ public function get(string $code, Office $office): Supplier @@ -123,4 +123,32 @@ public function listAll( return $this->mapListAll("Supplier", $response->data, $supplierListAllTags); } + + /** + * Deletes a specific Supplier based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return Supplier The deleted Supplier or Supplier object with error message if it can't be found. + * @throws Exception + */ + public function delete(string $code, Office $office): Supplier + { + $supplier = self::get($code, $office); + + if ($supplier->getResult() == 1) { + $supplier->setStatusFromString("deleted"); + + try { + $supplierDeleted = self::send($supplier); + } catch (ResponseException $e) { + $supplierDeleted = $e->getReturnedObject(); + } + + return $supplierDeleted; + } else { + return $supplier; + } + } } \ No newline at end of file diff --git a/src/ApiConnectors/UserApiConnector.php b/src/ApiConnectors/UserApiConnector.php index 19a6d42b..30bd271f 100644 --- a/src/ApiConnectors/UserApiConnector.php +++ b/src/ApiConnectors/UserApiConnector.php @@ -36,7 +36,7 @@ class UserApiConnector extends BaseApiConnector * @param string $code * @param Office $office If no office has been passed it will instead take the default office from the * passed in config class. - * @return User|bool The requested User or false if it can't be found. + * @return User The requested User or User object with error message if it can't be found. * @throws Exception */ public function get(string $code, Office $office): User diff --git a/src/ApiConnectors/VatCodeApiConnector.php b/src/ApiConnectors/VatCodeApiConnector.php index 9872dee2..f5bc23ff 100644 --- a/src/ApiConnectors/VatCodeApiConnector.php +++ b/src/ApiConnectors/VatCodeApiConnector.php @@ -30,7 +30,7 @@ class VatCodeApiConnector extends BaseApiConnector * @param string $code * @param Office $office If no office has been passed it will instead take the default office from the * passed in config class. - * @return VatCode|bool The requested VAT code or false if it can't be found. + * @return VatCode The requested VatCode or VatCode object with error message if it can't be found. * @throws Exception */ public function get(string $code, Office $office): VatCode @@ -122,4 +122,32 @@ public function listAll( return $this->mapListAll("VatCode", $response->data, $vatCodeListAllTags); } + + /** + * Deletes a specific VatCode based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return VatCode The deleted VatCode or VatCode object with error message if it can't be found. + * @throws Exception + */ + public function delete(string $code, Office $office): VatCode + { + $vatCode = self::get($code, $office); + + if ($vatCode->getResult() == 1) { + $vatCode->setStatusFromString("deleted"); + + try { + $vatCodeDeleted = self::send($vatCode); + } catch (ResponseException $e) { + $vatCodeDeleted = $e->getReturnedObject(); + } + + return $vatCodeDeleted; + } else { + return $vatCode; + } + } } \ No newline at end of file diff --git a/src/DomDocuments/AssetMethodsDocument.php b/src/DomDocuments/AssetMethodsDocument.php index 7459b797..b0f3dff5 100644 --- a/src/DomDocuments/AssetMethodsDocument.php +++ b/src/DomDocuments/AssetMethodsDocument.php @@ -36,6 +36,12 @@ public function addAssetMethod(AssetMethod $assetMethod) $assetMethodElement = $this->createElement('assetmethod'); $this->rootElement->appendChild($assetMethodElement); + $status = $assetMethod->getStatus(); + + if (!empty($status)) { + $assetMethodElement->setAttribute('status', $status); + } + $assetMethodElement->appendChild($this->createNodeWithTextContent('calcmethod', $assetMethod->getCalcMethod())); $assetMethodElement->appendChild($this->createNodeWithTextContent('code', $assetMethod->getCode())); $assetMethodElement->appendChild($this->createNodeWithTextContent('depreciatereconciliation', $assetMethod->getDepreciateReconciliation())); diff --git a/src/DomDocuments/InvoicesDocument.php b/src/DomDocuments/InvoicesDocument.php index 144a2e0d..9c3b03a7 100644 --- a/src/DomDocuments/InvoicesDocument.php +++ b/src/DomDocuments/InvoicesDocument.php @@ -2,6 +2,7 @@ namespace PhpTwinfield\DomDocuments; +use PhpTwinfield\Article; use PhpTwinfield\Invoice; use PhpTwinfield\Secure\AuthenticatedConnection; @@ -113,7 +114,12 @@ public function addInvoice(Invoice $invoice, $connection) $lineElement->appendChild($this->createNodeWithTextContent('unitspriceexcl', $line->getUnitsPriceExclToFloat())); } - $article = $articleApiConnector->get($line->getArticleToString(), $invoice->getOffice()); + if ($line->getArticleToString() != '0') { + $article = $articleApiConnector->get($line->getArticleToString(), $invoice->getOffice()); + } else { + $article = new Article; + $article->setAllowChangeVatCode(true); + } if ($article->getAllowChangeVatCode() == true) { $lineElement->appendChild($this->createNodeWithTextContent('vatcode', $line->getVatCodeToString())); From dab2d1f61671c25d88214129d9eeb6879ba6c5a1 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 12 May 2019 11:51:03 +0200 Subject: [PATCH 205/388] Update InvoiceMapper.php --- src/Mappers/InvoiceMapper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mappers/InvoiceMapper.php b/src/Mappers/InvoiceMapper.php index 820784dd..6cb896e7 100644 --- a/src/Mappers/InvoiceMapper.php +++ b/src/Mappers/InvoiceMapper.php @@ -100,7 +100,7 @@ public static function map(Response $response) ->setPerformanceDate(self::parseDateAttribute(self::getField($invoiceLine, $lineElement, 'performancedate'))) ->setPerformanceType(self::parseEnumAttribute('PerformanceType', self::getField($invoiceLine, $lineElement, 'performancetype'))) ->setQuantity(self::getField($invoiceLine, $lineElement, 'quantity')) - ->setSubArticle(self::parseObjectAttribute('ArticleLine', $invoiceLine, $lineElement, 'subarticle')) + ->setSubArticleFromString(self::getField($invoiceLine, $lineElement, 'subarticle')) ->setUnits(self::getField($invoiceLine, $lineElement, 'units')) ->setUnitsPriceExcl(self::parseMoneyAttribute(self::getField($invoiceLine, $lineElement, 'unitspriceexcl'))) ->setUnitsPriceInc(self::parseMoneyAttribute(self::getField($invoiceLine, $lineElement, 'unitspriceinc'))) From d1e9dfb61cda9022b0f4b9284524d2f74f590dff Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 12 May 2019 11:56:04 +0200 Subject: [PATCH 206/388] Upload --- composer.json | 1 - src/ApiConnectors/ActivityApiConnector.php | 1 + src/ApiConnectors/ArticleApiConnector.php | 1 + src/ApiConnectors/AssetMethodApiConnector.php | 1 + src/ApiConnectors/CostCenterApiConnector.php | 1 + src/ApiConnectors/CustomerApiConnector.php | 1 + src/ApiConnectors/DimensionGroupApiConnector.php | 1 + src/ApiConnectors/FixedAssetApiConnector.php | 1 + src/ApiConnectors/GeneralLedgerApiConnector.php | 1 + src/ApiConnectors/ProjectApiConnector.php | 1 + src/ApiConnectors/RateApiConnector.php | 1 + src/ApiConnectors/SupplierApiConnector.php | 1 + src/ApiConnectors/VatCodeApiConnector.php | 1 + 13 files changed, 12 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ba25c2bd..f2161d43 100644 --- a/composer.json +++ b/composer.json @@ -50,7 +50,6 @@ }, "require-dev": { "eloquent/liberator": "^2.0", - "league/oauth2-client": "^2.2", "mediact/dependency-guard": "^1.0", "mockery/mockery": "dev-master", "phpstan/phpstan": "^0.10.1", diff --git a/src/ApiConnectors/ActivityApiConnector.php b/src/ApiConnectors/ActivityApiConnector.php index 9cf89062..da1bde47 100644 --- a/src/ApiConnectors/ActivityApiConnector.php +++ b/src/ApiConnectors/ActivityApiConnector.php @@ -10,6 +10,7 @@ use PhpTwinfield\Request as Request; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; +use PhpTwinfield\Response\ResponseException; use PhpTwinfield\Services\FinderService; use Webmozart\Assert\Assert; diff --git a/src/ApiConnectors/ArticleApiConnector.php b/src/ApiConnectors/ArticleApiConnector.php index 0b2dc3d6..5c19cd23 100644 --- a/src/ApiConnectors/ArticleApiConnector.php +++ b/src/ApiConnectors/ArticleApiConnector.php @@ -10,6 +10,7 @@ use PhpTwinfield\Request as Request; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; +use PhpTwinfield\Response\ResponseException; use PhpTwinfield\Services\FinderService; use Webmozart\Assert\Assert; diff --git a/src/ApiConnectors/AssetMethodApiConnector.php b/src/ApiConnectors/AssetMethodApiConnector.php index 5497e099..7e3603d7 100644 --- a/src/ApiConnectors/AssetMethodApiConnector.php +++ b/src/ApiConnectors/AssetMethodApiConnector.php @@ -10,6 +10,7 @@ use PhpTwinfield\Request as Request; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; +use PhpTwinfield\Response\ResponseException; use PhpTwinfield\Services\FinderService; use Webmozart\Assert\Assert; diff --git a/src/ApiConnectors/CostCenterApiConnector.php b/src/ApiConnectors/CostCenterApiConnector.php index f8245c6b..3ed5a290 100644 --- a/src/ApiConnectors/CostCenterApiConnector.php +++ b/src/ApiConnectors/CostCenterApiConnector.php @@ -10,6 +10,7 @@ use PhpTwinfield\Request as Request; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; +use PhpTwinfield\Response\ResponseException; use PhpTwinfield\Services\FinderService; use Webmozart\Assert\Assert; diff --git a/src/ApiConnectors/CustomerApiConnector.php b/src/ApiConnectors/CustomerApiConnector.php index e91f8955..e4688635 100644 --- a/src/ApiConnectors/CustomerApiConnector.php +++ b/src/ApiConnectors/CustomerApiConnector.php @@ -10,6 +10,7 @@ use PhpTwinfield\Request as Request; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; +use PhpTwinfield\Response\ResponseException; use PhpTwinfield\Services\FinderService; use Webmozart\Assert\Assert; diff --git a/src/ApiConnectors/DimensionGroupApiConnector.php b/src/ApiConnectors/DimensionGroupApiConnector.php index dca0ddd7..a87299dc 100644 --- a/src/ApiConnectors/DimensionGroupApiConnector.php +++ b/src/ApiConnectors/DimensionGroupApiConnector.php @@ -10,6 +10,7 @@ use PhpTwinfield\Request as Request; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; +use PhpTwinfield\Response\ResponseException; use PhpTwinfield\Services\FinderService; use Webmozart\Assert\Assert; diff --git a/src/ApiConnectors/FixedAssetApiConnector.php b/src/ApiConnectors/FixedAssetApiConnector.php index 70022a4e..0196b0ea 100644 --- a/src/ApiConnectors/FixedAssetApiConnector.php +++ b/src/ApiConnectors/FixedAssetApiConnector.php @@ -10,6 +10,7 @@ use PhpTwinfield\Request as Request; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; +use PhpTwinfield\Response\ResponseException; use PhpTwinfield\Services\FinderService; use Webmozart\Assert\Assert; diff --git a/src/ApiConnectors/GeneralLedgerApiConnector.php b/src/ApiConnectors/GeneralLedgerApiConnector.php index c46c22a1..609ac533 100644 --- a/src/ApiConnectors/GeneralLedgerApiConnector.php +++ b/src/ApiConnectors/GeneralLedgerApiConnector.php @@ -10,6 +10,7 @@ use PhpTwinfield\Request as Request; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; +use PhpTwinfield\Response\ResponseException; use PhpTwinfield\Services\FinderService; use Webmozart\Assert\Assert; diff --git a/src/ApiConnectors/ProjectApiConnector.php b/src/ApiConnectors/ProjectApiConnector.php index 1c66f453..455a1a5d 100644 --- a/src/ApiConnectors/ProjectApiConnector.php +++ b/src/ApiConnectors/ProjectApiConnector.php @@ -10,6 +10,7 @@ use PhpTwinfield\Request as Request; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; +use PhpTwinfield\Response\ResponseException; use PhpTwinfield\Services\FinderService; use Webmozart\Assert\Assert; diff --git a/src/ApiConnectors/RateApiConnector.php b/src/ApiConnectors/RateApiConnector.php index c64415c4..18301fa8 100644 --- a/src/ApiConnectors/RateApiConnector.php +++ b/src/ApiConnectors/RateApiConnector.php @@ -10,6 +10,7 @@ use PhpTwinfield\Request as Request; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; +use PhpTwinfield\Response\ResponseException; use PhpTwinfield\Services\FinderService; use Webmozart\Assert\Assert; diff --git a/src/ApiConnectors/SupplierApiConnector.php b/src/ApiConnectors/SupplierApiConnector.php index 8332206f..b5596ed3 100644 --- a/src/ApiConnectors/SupplierApiConnector.php +++ b/src/ApiConnectors/SupplierApiConnector.php @@ -9,6 +9,7 @@ use PhpTwinfield\Request as Request; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; +use PhpTwinfield\Response\ResponseException; use PhpTwinfield\Services\FinderService; use PhpTwinfield\Supplier; use Webmozart\Assert\Assert; diff --git a/src/ApiConnectors/VatCodeApiConnector.php b/src/ApiConnectors/VatCodeApiConnector.php index f5bc23ff..1776d721 100644 --- a/src/ApiConnectors/VatCodeApiConnector.php +++ b/src/ApiConnectors/VatCodeApiConnector.php @@ -9,6 +9,7 @@ use PhpTwinfield\Request as Request; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; +use PhpTwinfield\Response\ResponseException; use PhpTwinfield\Services\FinderService; use PhpTwinfield\VatCode; use Webmozart\Assert\Assert; From 727156ac7cee44fb88b82b737cbd520a819eeaee Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 12 May 2019 12:05:12 +0200 Subject: [PATCH 207/388] Upload --- composer.json | 5 ++++- src/ApiConnectors/GeneralLedgerApiConnector.php | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index f2161d43..3b7386d7 100644 --- a/composer.json +++ b/composer.json @@ -31,13 +31,15 @@ "ext-dom": "*", "ext-json": "*", "ext-soap": "*", - "league/oauth2-client": "^2.2", "moneyphp/money": "^3.0", "myclabs/php-enum": "^1.5", "psr/http-message": "^1.0", "psr/log": "^1.0", "webmozart/assert": "^1.2" }, + "suggest": { + "league/oauth2-client": "If you want to use OAuth to login" + }, "autoload": { "psr-4": { "PhpTwinfield\\": "src/" @@ -50,6 +52,7 @@ }, "require-dev": { "eloquent/liberator": "^2.0", + "league/oauth2-client": "^2.2", "mediact/dependency-guard": "^1.0", "mockery/mockery": "dev-master", "phpstan/phpstan": "^0.10.1", diff --git a/src/ApiConnectors/GeneralLedgerApiConnector.php b/src/ApiConnectors/GeneralLedgerApiConnector.php index 609ac533..33941cc4 100644 --- a/src/ApiConnectors/GeneralLedgerApiConnector.php +++ b/src/ApiConnectors/GeneralLedgerApiConnector.php @@ -26,9 +26,10 @@ class GeneralLedgerApiConnector extends BaseApiConnector { /** - * Requests a specific GeneralLedger based off the passed in code and optionally the office. + * Requests a specific GeneralLedger based off the passed in code, dimension type and optionally the office. * * @param string $code + * @param string $dimType * @param Office $office If no office has been passed it will instead take the default office from the * passed in config class. * @return GeneralLedger The requested GeneralLedger or GeneralLedger object with error message if it can't be found. @@ -129,14 +130,15 @@ public function listAll( * Deletes a specific GeneralLedger based off the passed in code and optionally the office. * * @param string $code + * @param string $dimType * @param Office $office If no office has been passed it will instead take the default office from the * passed in config class. * @return GeneralLedger The deleted GeneralLedger or GeneralLedger object with error message if it can't be found. * @throws Exception */ - public function delete(string $code, Office $office): GeneralLedger + public function delete(string $code, string $dimType, Office $office): GeneralLedger { - $generalLedger = self::get($code, $office); + $generalLedger = self::get($code, $dimType, $office); if ($generalLedger->getResult() == 1) { $generalLedger->setStatusFromString("deleted"); From ac63f2e598a40c91641402769227ed07a1fb66ae Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 13 May 2019 12:30:01 +0200 Subject: [PATCH 208/388] Update readme.md --- readme.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index 900dc646..0c0cb916 100644 --- a/readme.md +++ b/readme.md @@ -39,9 +39,9 @@ Go to the [Twinfield web site](https://www.twinfield.nl/openid-connect-request/) * Post logout URL: Your choice, can be left blank * Add more post logout URL's?: Your choice -##### Grant Authorisation and retrieve intitial Access Token +##### Grant Authorization and retrieve initial Access Token On loading a page containing the following code the user will be redirected to the Twinfield Login page. -After succesfull login and optionally consent (see above) the user will be redirected back to the page at which point the Access Token and Refresh Token can be retrieved. +After succesful login and optionally consent (see above) the user will be redirected back to the page at which point the Access Token and Refresh Token can be retrieved. For more information, please refer to: https://github.com/thephpleague/oauth2-client#usage @@ -114,7 +114,7 @@ if (!isset($_GET['code'])) { } ``` -##### Optionally: Store a valid access token and cluster through a sceduled task/cron job running in the background +##### Optionally: Store a valid access token and cluster through a scheduled task/cron job running in the background Running the following code every 60 minutes (or a bit less as Access Tokens are valid for exactly 60 minutes) will reduce connection time when working with the Api (by about 2 seconds). It will also reduce connection load on Twinfield when making more than 20-30 connections/day. ```php @@ -166,7 +166,7 @@ $office = \PhpTwinfield\Office::fromCode("someOfficeCode"); if ($accessTokenStorage['access_expiry'] > time()) { $connection = new \PhpTwinfield\Secure\OpenIdConnectAuthentication($provider, $refreshTokenStorage['refresh_token'], $office, $accessTokenStorage['access_token'], $accessTokenStorage['access_cluster']); } else { - $connection = new \PhpTwinfield\Secure\OpenIdConnectAuthentication($provider, $refreshTokenStorage['refresh_token'], $office) + $connection = new \PhpTwinfield\Secure\OpenIdConnectAuthentication($provider, $refreshTokenStorage['refresh_token'], $office); } ``` From ba254d2ef144dc1755eeed583dfcf31c2c8cb95e Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 14 May 2019 12:03:14 +0200 Subject: [PATCH 209/388] Upload --- examples/Authorization.php | 110 +++++++ examples/CashBankBook.php | 85 +++++ examples/Connection.php | 66 ++++ examples/CostCenter.php | 176 +++++++++++ examples/Country.php | 79 +++++ examples/PayCode.php | 85 +++++ examples/RenewAccessToken.php | 91 ++++++ examples/RenewAuthorization.php | 51 +++ examples/VatGroup.php | 79 +++++ examples/VatGroupCountry.php | 84 +++++ readme.md | 296 +----------------- .../VatGroupCountryApiConnector.php | 53 ++++ src/CashBankBook.php | 2 +- src/Country.php | 2 +- src/Dummy.php | 2 +- src/Fields/VatCode/GroupCountryField.php | 12 +- src/InvoiceType.php | 2 +- src/Mappers/VatGroupCountryMapper.php | 45 +++ src/PayCode.php | 2 +- src/UserRole.php | 2 +- src/VatGroup.php | 2 +- src/VatGroupCountry.php | 19 ++ usage.md | 296 ++++++++++++++++++ 23 files changed, 1334 insertions(+), 307 deletions(-) create mode 100644 examples/Authorization.php create mode 100644 examples/CashBankBook.php create mode 100644 examples/Connection.php create mode 100644 examples/CostCenter.php create mode 100644 examples/Country.php create mode 100644 examples/PayCode.php create mode 100644 examples/RenewAccessToken.php create mode 100644 examples/RenewAuthorization.php create mode 100644 examples/VatGroup.php create mode 100644 examples/VatGroupCountry.php create mode 100644 src/ApiConnectors/VatGroupCountryApiConnector.php create mode 100644 src/Mappers/VatGroupCountryMapper.php create mode 100644 src/VatGroupCountry.php create mode 100644 usage.md diff --git a/examples/Authorization.php b/examples/Authorization.php new file mode 100644 index 00000000..fd43eb87 --- /dev/null +++ b/examples/Authorization.php @@ -0,0 +1,110 @@ + $twin_client_id, + 'clientSecret' => $twin_client_secret, + 'redirectUri' => $twin_redirect_uri, +]); + +// If we don't have an authorization code then get one. +if (!isset($_GET['code'])) { + //Optionally limit your scope if you don't require all. + $options = [ + 'scope' => ['twf.user','twf.organisation','twf.organisationUser','offline_access','openid'] + ]; + + $authorizationUrl = $provider->getAuthorizationUrl($options); + + // Get the state generated for you and store it to the session. + $_SESSION['oauth2state'] = $provider->getState(); + + // Redirect the user to the authorization URL. + header('Location: ' . $authorizationUrl); + exit; + +// Check given state against previously stored one to mitigate CSRF attack. +} elseif (empty($_GET['state']) || (isset($_SESSION['oauth2state']) && $_GET['state'] !== $_SESSION['oauth2state'])) { + if (isset($_SESSION['oauth2state'])) { + unset($_SESSION['oauth2state']); + } + + exit('Invalid state'); +} else { + try { + // Try to get an access token using the authorization code grant. + $accessToken = $provider->getAccessToken('authorization_code', [ + 'code' => $_GET['code'] + ]); + + /* Twinfield's refresh token is valid for 550 days. + * Renewing the refresh token can be done by requesting the user to reload this page and logging into Twinfield before the refresh token is invalidated after 550 days. + * NOTE: Remember to put in place functionality to request the user to renew their authorization, see RenewAuthorization.php for an example. + */ + + $refresh_expiry = strtotime(date('Ymd') . " +550 days"); + + // Save refresh token and refresh token expiry time to storage. + $refreshTokenStorage = array(); + $refreshTokenStorage['refresh_token'] = $accessToken->getRefreshToken(); + $refreshTokenStorage['refresh_expiry'] = $refresh_expiry; + + SaveRefreshTokenToStore($refreshTokenStorage); + + /* Optionally save access token, access token expiry time and access cluster to storage. + * If you choose to use an always valid access token to login to speed up your requests you need to put in place functionality to automatically renew the access token using the save refresh token. + * As the access token is valid for 60 minutes you need to create a task scheduler/cron that runs at least once every hour, see RenewAccessToken.php for an example. + */ + + $validationUrl = "https://login.twinfield.com/auth/authentication/connect/accesstokenvalidation?token="; + $validationResult = @file_get_contents($validationUrl . urlencode($accessToken->getToken())); + + if ($validationResult !== false) { + $resultDecoded = \json_decode($validationResult, true); + $accessTokenStorage = array(); + $accessTokenStorage['access_token'] = $accessToken->getToken(); + $accessTokenStorage['access_expiry'] = $accessToken->getExpires(); + $accessTokenStorage['access_cluster'] = $resultDecoded["twf.clusterUrl"]; + + SaveAccessTokenToStore($accessTokenStorage); + } + } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) { + // Failed to get the access token or user details. + exit($e->getMessage()); + } +} \ No newline at end of file diff --git a/examples/CashBankBook.php b/examples/CashBankBook.php new file mode 100644 index 00000000..5022d12d --- /dev/null +++ b/examples/CashBankBook.php @@ -0,0 +1,85 @@ + banktype = 0 +$options = array('banktype' => 0); + +try { + $cashBankBooks = $cashBankBookApiConnector->listAll('BNK', 0, 1, 10, $options); +} catch (ResponseException $e) { + $cashBankBooks = $e->getReturnedObject(); +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +try { + $cashBankBooks = $cashBankBookApiConnector->listAll(); +} catch (ResponseException $e) { + $cashBankBooks = $e->getReturnedObject(); +} + +echo "
";
+print_r($cashBankBooks);
+echo "
"; + +/* CashBankBook + * \PhpTwinfield\CashBankBook + * Available getters: getCode, getName, getShortName + * Available setters: setCode, setName, setShortName + */ + +foreach ($cashBankBooks as $key => $cashBankBook) { + echo "CashBankBook {$key}
"; + echo "Code: {$cashBankBook->getCode()}
"; + echo "Name: {$cashBankBook->getName()}

"; +} + +// NOTE: Because the CashBankBookApiConnector only supports the listAll method at the moment it is not particularly useful to create a new CashBankBook + +$cashBankBook = new \PhpTwinfield\CashBankBook; +$cashBankBook->setCode("BNK"); +$cashBankBook->setName("Standaard bank"); +$cashBankBook->setShortName("StdBank"); + +echo "
";
+print_r($cashBankBook);
+echo "
"; \ No newline at end of file diff --git a/examples/Connection.php b/examples/Connection.php new file mode 100644 index 00000000..caf47d6c --- /dev/null +++ b/examples/Connection.php @@ -0,0 +1,66 @@ + $twin_client_id, + 'clientSecret' => $twin_client_secret, + 'redirectUri' => $twin_redirect_uri, +]); + +// Retrieve a stored refresh token from storage. +$refreshTokenStorage = RetrieveRefreshTokenFromStore(); + +// Optionally retrieve access token, access token expiry time and cluster from storage. +$accessTokenStorage = RetrieveAccessTokenFromStore(); + +// Create a new Office object from the $officeCode +$office = \PhpTwinfield\Office::fromCode($officeCode); + +// Create a new connection using either the refresh token, access token and access cluster (approximately 2 seconds faster) or only the refresh token. +if ($accessTokenStorage['access_expiry'] > time()) { + $connection = new \PhpTwinfield\Secure\OpenIdConnectAuthentication($provider, $refreshTokenStorage['refresh_token'], $office, $accessTokenStorage['access_token'], $accessTokenStorage['access_cluster']); +} else { + $connection = new \PhpTwinfield\Secure\OpenIdConnectAuthentication($provider, $refreshTokenStorage['refresh_token'], $office); +} \ No newline at end of file diff --git a/examples/CostCenter.php b/examples/CostCenter.php new file mode 100644 index 00000000..4930d027 --- /dev/null +++ b/examples/CostCenter.php @@ -0,0 +1,176 @@ + modifiedsince = '20190101100000', group = 'DimensionGroup' +$options = array('modifiedsince' => '20190101100000', 'group' => 'DimensionGroup'); + +try { + $costCenters = $costCenterApiConnector->listAll("Apeldoorn", 0, 5, 10, $options); +} catch (ResponseException $e) { + $costCenters = $e->getReturnedObject(); +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +try { + $costCenters = $costCenterApiConnector->listAll(); +} catch (ResponseException $e) { + $costCenters = $e->getReturnedObject(); +} + +echo "
";
+print_r($costCenters);
+echo "
"; + +/* CostCenter + * \PhpTwinfield\CostCenter + * Available getters: getBehaviour, getCode, getInUse, getInUseToString, getMessages, getName, getOffice, getOfficeToString, getResult, getShortName, getStatus, getTouched, getType, getTypeToString, getUID, hasMessages + * Available setters: setBehaviour, setBehaviourFromString, setCode, setName, setOffice, setOfficeFromString, setShortName, setStatus, setStatusFromString, setType, setTypeFromString + */ + +foreach ($costCenters as $key => $costCenter) { + echo "CostCenter {$key}
"; + echo "Code: {$costCenter->getCode()}
"; + echo "Name: {$costCenter->getName()}

"; +} + +// Read a CostCenter based off the passed in code and optionally the office. +$costCenter = $costCenterApiConnector->get("00000", $office); + +echo "
";
+print_r($costCenter);
+echo "
"; + +echo "CostCenter {$key}
"; +echo "Behaviour: {$costCenter->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. +echo "Code: {$costCenter->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the KPL Dimension type. +echo "InUse (bool): {$costCenter->getInUse()}
"; // bool|null Indicates whether the cost center is used in a financial transaction or not. Read-only attribute. +echo "InUse (string): {$costCenter->getInUseToString()}
"; // string|null +echo "Messages: {$costCenter->getMessages()}
"; // Array|null (Error) messages +echo "Name: {$costCenter->getName()}
"; // string|null Name of the dimension. +echo "Office (\\PhpTwinfield\\Office):
" . print_r($costCenter->getOffice(), true) . "

"; // Office|null Office. +echo "Office (string): {$costCenter->getOfficeToString()}
"; // string|null +echo "Result: {$costCenter->getResult()}
"; // int|null Result (0 = error, 1 = success). +echo "ShortName: {$costCenter->getShortName()}
"; // string|null Not in use. +echo "Status: {$costCenter->getStatus()}
"; // Status|null Status of the CostCenter +echo "Touched: {$costCenter->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. +echo "Type: {$costCenter->getType()}
"; // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is KPL. +echo "Type: {$costCenter->getTypeToString()}
"; // string|null +echo "UID: {$costCenter->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. +echo "Has Messages: {$costCenter->hasMessages()}
"; // bool Result has (error) messages + +// Copy an existing CostCenter to a new entity +$costCenter = $costCenterApiConnector->get("00000", $office); +$costCenter->setCode(null); + +try { + $costCenterCopy = $costCenterApiConnector->send($costCenter); +} catch (ResponseException $e) { + $costCenterCopy = $e->getReturnedObject(); +} + +echo "
";
+print_r($costCenterCopy);
+echo "
"; + +echo "Code of copied CostCenter: {$costCenterCopy->getCode()}
"; + +// Create a new CostCenter from scratch, alternatively read an existing CostCenter as shown above and than modify the values in the same way as shown below +$costCenter = new \PhpTwinfield\CostCenter; + +// Required values for creating a new CostCenter +$costCenter->setName("CostCenterName"); // string|null Name of the dimension. +$costCenter->setOffice($office); // Office|null Office. +$costCenter->setOfficefromCode($officeCode); // string|null + +// Optional values for creating a new CostCenter +$costCenter->setCode(null); // string|null Dimension code, must be compliant with the mask of the KPL Dimension type. +//$costCenter->setCode('00020'); // string|null +$costCenter->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. +//$costCenter->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null For deleting deleted should be used. In case a dimension that is used in a transaction is deleted, + // its status has been changed into hide. Hidden dimensions can be activated by using active. +$costCenter->setStatusFromString('active'); // string|null +//$costCenter->setStatusFromString('deleted'); // string|null + // +$dimensionType = new \PhpTwinfield\DimensionType; +$dimensionType->setCode('KPL'); +$costCenter->setType($dimensionType); // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is KPL. +$costCenter->setTypeFromString('KPL'); // string|null + +try { + $costCenterNew = $costCenterApiConnector->send($costCenter); +} catch (ResponseException $e) { + $costCenterNew = $e->getReturnedObject(); +} + +echo "
";
+print_r($costCenterNew);
+echo "
"; + +echo "Code of new CostCenter: {$costCenterNew->getCode()}
"; + +// Delete a CostCenter based off the passed in code and optionally the office. + +try { + $costCenterDeleted = $costCenterApiConnector->delete("SomeCostCenterCode", $office); +} catch (ResponseException $e) { + $costCenterDeleted = $e->getReturnedObject(); +} + +echo "
";
+print_r($costCenterDeleted);
+echo "
"; \ No newline at end of file diff --git a/examples/Country.php b/examples/Country.php new file mode 100644 index 00000000..2f05da88 --- /dev/null +++ b/examples/Country.php @@ -0,0 +1,79 @@ +listAll('NL', 0, 1, 10); +} catch (ResponseException $e) { + $countries = $e->getReturnedObject(); +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +try { + $countries = $countryApiConnector->listAll(); +} catch (ResponseException $e) { + $countries = $e->getReturnedObject(); +} + +echo "
";
+print_r($countries);
+echo "
"; + +/* Country + * \PhpTwinfield\Country + * Available getters: getCode, getName, getShortName + * Available setters: setCode, setName, setShortName + */ + +foreach ($countries as $key => $country) { + echo "Country {$key}
"; + echo "Code: {$country->getCode()}
"; + echo "Name: {$country->getName()}

"; +} + +// NOTE: Because the CountryApiConnector only supports the listAll method at the moment it is not particularly useful to create a new Country + +$country = new \PhpTwinfield\Country; +$country->setCode("NL"); +$country->setName("Nederland"); +$country->setShortName("Nederland"); + +echo "
";
+print_r($country);
+echo "
"; \ No newline at end of file diff --git a/examples/PayCode.php b/examples/PayCode.php new file mode 100644 index 00000000..798fcb6b --- /dev/null +++ b/examples/PayCode.php @@ -0,0 +1,85 @@ + paytype = pay +$options = array('paytype' => 'pay'); + +try { + $payCodes = $payCodeApiConnector->listAll("SEPA*", 0, 5, 10, $options); +} catch (ResponseException $e) { + $payCodes = $e->getReturnedObject(); +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +try { + $payCodes = $payCodeApiConnector->listAll(); +} catch (ResponseException $e) { + $payCodes = $e->getReturnedObject(); +} + +echo "
";
+print_r($payCodes);
+echo "
"; + +/* PayCode + * \PhpTwinfield\PayCode + * Available getters: getCode, getName, getShortName + * Available setters: setCode, setName, setShortName + */ + +foreach ($payCodes as $key => $payCode) { + echo "PayCode {$key}
"; + echo "Code: {$payCode->getCode()}
"; + echo "Name: {$payCode->getName()}

"; +} + +// NOTE: Because the PayCodeApiConnector only supports the listAll method at the moment it is not particularly useful to create a new PayCode + +$payCode = new \PhpTwinfield\PayCode; +$payCode->setCode("SEPATEST"); +$payCode->setName("SEPA Test pay code"); +$payCode->setShortName("SEPATestPayCode"); + +echo "
";
+print_r($payCode);
+echo "
"; \ No newline at end of file diff --git a/examples/RenewAccessToken.php b/examples/RenewAccessToken.php new file mode 100644 index 00000000..87a9f707 --- /dev/null +++ b/examples/RenewAccessToken.php @@ -0,0 +1,91 @@ + (time() - 60 * 45)) { + return true; + } + + return false; +} + +// Only allow the script to run from the command line interface e.g. Cron +if (php_sapi_name() !='cli') exit; + +// Only allow the script to run if last successful run time is more than 45 minutes ago +if (!LastRunThreeQuartersAgo()) exit; + +require_once('vendor/autoload.php'); + +// The client ID assigned to you by Twinfield. +$twin_client_id = 'SomeClientId'; + +// The client secret assigned to you by Twinfield. +$twin_client_secret = 'SomeClientSecret'; + +// The FQDN URI of the script used for initial authorization, must be filled out on the form (Redirect URL) when requesting the client ID/Secret from Twinfield. +$twin_redirect_uri = 'https://example.org/twinfield/Authorization.php'; + +// Retrieve a stored Refresh token from storage. +$refreshTokenStorage = retrieveRefreshTokenFromStore(); + +$provider = new \PhpTwinfield\Secure\Provider\OAuthProvider([ + 'clientId' => $twin_client_id, + 'clientSecret' => $twin_client_secret, + 'redirectUri' => $twin_redirect_uri, +]); + +// Get a new access token using the stored refresh token +$accessToken = $provider->getAccessToken('refresh_token', [ + 'refresh_token' => $refreshTokenStorage['refresh_token'] +]); + +// Validate the access token and retrieve the access cluster +$validationUrl = "https://login.twinfield.com/auth/authentication/connect/accesstokenvalidation?token="; +$validationResult = @file_get_contents($validationUrl . urlencode($accessToken->getToken())); + +if ($validationResult !== false) { + $resultDecoded = \json_decode($validationResult, true); + + $tokenStorage = array(); + $tokenStorage['access_token'] = $accessToken->getToken(); + $tokenStorage['access_expiry'] = $accessToken->getExpires(); + $tokenStorage['access_cluster'] = $resultDecoded["twf.clusterUrl"]; + + // Save the new access token, expiry time and cluster to storage + SaveAccessTokenToStore($tokenStorage); + + // Update the last renewal successful run time to right now + touch('renewaccesstoken.timestamp'); +} \ No newline at end of file diff --git a/examples/RenewAuthorization.php b/examples/RenewAuthorization.php new file mode 100644 index 00000000..c449d0dc --- /dev/null +++ b/examples/RenewAuthorization.php @@ -0,0 +1,51 @@ +
+ +The Twinfield authorization for domain/application is about to expire.
+Please renew the authorization as soon as possible.
+Renew the authorization by clicking here and logging in with Twinfield.

+ +You will receive this email once a week until the authorization is renewed."; + +// The FQDN URI of the script used for initial authorization, must be filled out on the form (Redirect URL) when requesting the client ID/Secret from Twinfield. +$twin_redirect_uri = 'https://example.org/twinfield/Authorization.php'; + +if ($refreshTokenStorage['refresh_expiry'] < (time() + ($daysLeftAfterWhichRequestRenewal * 60 * 60 * 24))) { + SendEmail($accountingAdminEmail, $fromEmail, $subject, $body); +} +?> \ No newline at end of file diff --git a/examples/VatGroup.php b/examples/VatGroup.php new file mode 100644 index 00000000..367dc3cc --- /dev/null +++ b/examples/VatGroup.php @@ -0,0 +1,79 @@ +listAll("1*", 0, 5, 10); +} catch (ResponseException $e) { + $vatGroups = $e->getReturnedObject(); +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +try { + $vatGroups = $vatGroupApiConnector->listAll(); +} catch (ResponseException $e) { + $vatGroups = $e->getReturnedObject(); +} + +echo "
";
+print_r($vatGroups);
+echo "
"; + +/* VatGroup + * \PhpTwinfield\VatGroup + * Available getters: getCode, getName, getShortName + * Available setters: setCode, setName, setShortName + */ + +foreach ($vatGroups as $key => $vatGroup) { + echo "VatGroup {$key}
"; + echo "Code: {$vatGroup->getCode()}
"; + echo "Name: {$vatGroup->getName()}

"; +} + +// NOTE: Because the VatGroupApiConnector only supports the listAll method at the moment it is not particularly useful to create a new VatGroup + +$vatGroup = new \PhpTwinfield\VatGroup; +$vatGroup->setCode("1A"); +$vatGroup->setName("High (1a)"); +$vatGroup->setShortName("High1A"); + +echo "
";
+print_r($vatGroup);
+echo "
"; \ No newline at end of file diff --git a/examples/VatGroupCountry.php b/examples/VatGroupCountry.php new file mode 100644 index 00000000..76719411 --- /dev/null +++ b/examples/VatGroupCountry.php @@ -0,0 +1,84 @@ + country = NL +$options = array('country' => 'NL'); + +try { + $vatGroupCountries = $vatGroupCountryApiConnector->listAll('*', 0, 1, 10, $options); +} catch (ResponseException $e) { + $vatGroupCountries = $e->getReturnedObject(); +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +try { + $vatGroupCountries = $vatGroupCountryApiConnector->listAll(); +} catch (ResponseException $e) { + $vatGroupCountries = $e->getReturnedObject(); +} + +echo "
";
+print_r($vatGroupCountries);
+echo "
"; + +/* VatGroupCountry + * \PhpTwinfield\VatGroupCountry + * Available getters: getCode, getName, getShortName + * Available setters: setCode, setName, setShortName + */ + +foreach ($vatGroupCountries as $key => $vatGroupCountry) { + echo "VatGroupCountry {$key}
"; + echo "Code: {$vatGroupCountry->getCode()}
"; + echo "Name: {$vatGroupCountry->getName()}

"; +} + +// NOTE: Because the VatGroupCountryApiConnector only supports the listAll method at the moment it is not particularly useful to create a new VatGroupCountry + +$vatGroupCountry = new \PhpTwinfield\VatGroupCountry; +$vatGroupCountry->setCode("NL"); +$vatGroupCountry->setName("NL1A"); +$vatGroupCountry->setShortName("NL1A"); + +echo "
";
+print_r($vatGroupCountry);
+echo "
"; \ No newline at end of file diff --git a/readme.md b/readme.md index 0c0cb916..b3acb91e 100644 --- a/readme.md +++ b/readme.md @@ -15,300 +15,7 @@ composer require 'php-twinfield/twinfield:^2.0' ## Usage -### Authentication -You need to set up a `\PhpTwinfield\Secure\AuthenticatedConnection` class with your credentials. - -#### Session Login -**:warning: Note that Twinfield has stated that session login is deprecated and will be removed. End of life date will be announced later. See https://c3.twinfield.com/webservices/documentation/#/ApiReference/Authentication/WebServices** - -When using basic username and password authentication, the `\PhpTwinfield\Secure\WebservicesAuthentication` class should be used, as follows: - -```php -$connection = new Secure\WebservicesAuthentication("username", "password", "organization"); -``` - -#### OAuth2 -In order to use OAuth2 to authenticate with Twinfield, one should use the `\PhpTwinfield\Secure\Provider\OAuthProvider` to retrieve an `\League\OAuth2\Client\Token\AccessToken` object, and extract the refresh token from this object. Furthermore, it is required to set up a default `\PhpTwinfield\Office`, that will be used during requests to Twinfield. **Please note:** when a different office is specified when sending a request through one of the `ApiConnectors`, this Office will override the default. - -##### Request a client ID/Secret from Twinfield -Go to the [Twinfield web site](https://www.twinfield.nl/openid-connect-request/) in order to register your OpenID Connect / OAuth 2.0 client and get your Client ID and Secret. Fill in your personal information en pick the following: -* Flow: Authorization Code -* Consent: Your choice -* Redirect URL: The full URI where the following code is available on your domain/server -* Add more redirect URL's?: Your choice -* Post logout URL: Your choice, can be left blank -* Add more post logout URL's?: Your choice - -##### Grant Authorization and retrieve initial Access Token -On loading a page containing the following code the user will be redirected to the Twinfield Login page. -After succesful login and optionally consent (see above) the user will be redirected back to the page at which point the Access Token and Refresh Token can be retrieved. - -For more information, please refer to: https://github.com/thephpleague/oauth2-client#usage - -```php -$provider = new \PhpTwinfield\Secure\Provider\OAuthProvider([ - 'clientId' => 'someClientId', // The Client ID assigned to you by Twinfield - 'clientSecret' => 'someClientSecret', // The Client Secret assigned to you by Twinfield - 'redirectUri' => 'https://example.org/', // The full URL your filled in at Redirect URL when you requested your client ID -]); - -// If we don't have an authorization code then get one -if (!isset($_GET['code'])) { - //Optionally limit your scope if you don't require all. - $options = [ - 'scope' => ['twf.user','twf.organisation','twf.organisationUser','offline_access','openid'] - ]; - - $authorizationUrl = $provider->getAuthorizationUrl($options); - - // Get the state generated for you and store it to the session. - $_SESSION['oauth2state'] = $provider->getState(); - - // Redirect the user to the authorization URL. - header('Location: ' . $authorizationUrl); - exit; - -// Check given state against previously stored one to mitigate CSRF attack -} elseif (empty($_GET['state']) || (isset($_SESSION['oauth2state']) && $_GET['state'] !== $_SESSION['oauth2state'])) { - if (isset($_SESSION['oauth2state'])) { - unset($_SESSION['oauth2state']); - } - - exit('Invalid state'); -} else { - try { - // Try to get an access token using the authorization code grant. - $accessToken = $provider->getAccessToken('authorization_code', [ - 'code' => $_GET['code'] - ]); - - //Twinfield's Refresh Token is valid for 550 days. - //Remember to put in place functionality to request the user to renew their authorization. - //This can be done by requesting the user to reload this page and logging into Twinfield - //before the refresh token is invalidated after 550 days. - $refresh_expiry = strtotime(date('Ymd') . " +550 days"); - - //Save Refresh Token and Refresh Token Expiry Time to storage - $refreshTokenStorage = array(); - $refreshTokenStorage['refresh_token'] = $accessToken->getRefreshToken(); - $refreshTokenStorage['refresh_expiry'] = $refresh_expiry; - - SaveRefreshTokenToStore($refreshTokenStorage); - - //OPTIONAL: Save Access Token, Access Token Expiry Time and Cluster to storage - $validationUrl = "https://login.twinfield.com/auth/authentication/connect/accesstokenvalidation?token="; - $validationResult = @file_get_contents($validationUrl . urlencode($accessToken->getToken())); - - if ($validationResult !== false) { - $resultDecoded = \json_decode($validationResult, true); - $accessTokenStorage = array(); - $accessTokenStorage['access_token'] = $accessToken->getToken(); - $accessTokenStorage['access_expiry'] = $accessToken->getExpires(); - $accessTokenStorage['access_cluster'] = $resultDecoded["twf.clusterUrl"]; - SaveAccessTokenToStore($accessTokenStorage); - } - } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) { - // Failed to get the access token or user details. - exit($e->getMessage()); - } -} -``` - -##### Optionally: Store a valid access token and cluster through a scheduled task/cron job running in the background -Running the following code every 60 minutes (or a bit less as Access Tokens are valid for exactly 60 minutes) will reduce connection time when working with the Api (by about 2 seconds). It will also reduce connection load on Twinfield when making more than 20-30 connections/day. - -```php -$refreshTokenStorage = retrieveRefreshTokenFromStore(); - -$provider = new OAuthProvider([ - 'clientId' => 'someClientId', - 'clientSecret' => 'someClientSecret', - 'redirectUri' => 'https://example.org/' -]); - -$accessToken = $provider->getAccessToken('refresh_token', [ - 'refresh_token' => $refreshTokenStorage['refresh_token'] -]); - -$validationUrl = "https://login.twinfield.com/auth/authentication/connect/accesstokenvalidation?token="; -$validationResult = @file_get_contents($validationUrl . urlencode($accessToken->getToken())); - -if ($validationResult !== false) { - $resultDecoded = \json_decode($validationResult, true); - - $tokenStorage = array(); - $tokenStorage['access_token'] = $accessToken->getToken(); - $tokenStorage['access_expiry'] = $accessToken->getExpires(); - $tokenStorage['access_cluster'] = $resultDecoded["twf.clusterUrl"]; - - SaveAccessTokenToStore($tokenStorage); -} -``` - -##### Connection -Using the stored Refresh Token and optionally Access Token/Cluster, we can create an instance of the `\PhpTwinfield\Secure\OpenIdConnectAuthentication` class, as follows: - -```php -$provider = new OAuthProvider([ - 'clientId' => 'someClientId', - 'clientSecret' => 'someClientSecret', - 'redirectUri' => 'https://example.org/' -]); - -//Retrieve Refresh Token and Refresh Token Expiry Time from storage -$refreshTokenStorage = retrieveRefreshTokenFromStore(); - -//OPTIONAL: Retrieve Access Token, Access Token Expiry Time and Cluster from storage -$accessTokenStorage = retrieveAccessTokenFromStore(); - -$office = \PhpTwinfield\Office::fromCode("someOfficeCode"); - -if ($accessTokenStorage['access_expiry'] > time()) { - $connection = new \PhpTwinfield\Secure\OpenIdConnectAuthentication($provider, $refreshTokenStorage['refresh_token'], $office, $accessTokenStorage['access_token'], $accessTokenStorage['access_cluster']); -} else { - $connection = new \PhpTwinfield\Secure\OpenIdConnectAuthentication($provider, $refreshTokenStorage['refresh_token'], $office); -} -``` - -### Getting data from the API -In order to communicate with the Twinfield API, you need to create an `ApiConnector` instance for the corresponding -resource and use the `get()` or `list()` method. - -The `ApiConnector` takes a `Secure\AuthenticatedConnection` object: - -An example: - -```php - -$connection = new Secure\WebservicesAuthentication("username", "password", "organization"); -$customerApiConnector = new ApiConnectors\CustomerApiConnector($connection); - -// Get one customer. -$office = Office::fromCode('office code'); -$customer = $customerApiConnector->get('1001', $office); - -// Get a list of all customers. -$customer = $customerApiConnector->listAll($office); -``` - -### Creating or updating objects -If you want to create or update a customer or any other object, it's just as easy: - -```php -$customer_factory = new ApiConnectors\CustomerApiConnector($connection); - -// First, create the objects you want to send. -$customer = new Customer(); -$customer - ->setCode('1001') - ->setName('John Doe') - ->setOffice($office) - ->setEBilling(false); - -$customer_address = new CustomerAddress(); -$customer_address - ->setType('invoice') - ->setDefault(false) - ->setPostcode('1212 AB') - ->setCity('TestCity') - ->setCountry('NL') - ->setTelephone('010-12345') - ->setFax('010-1234') - ->setEmail('johndoe@example.com'); -$customer->addAddress($customer_address); - -// And secondly, send it to Twinfield. -$customer_factory->send($customer); -``` - -You can also send multiple objects in one batch, chunking is handled automatically. - -### Browse data -In order to get financial data out of Twinfield like general ledger transactions, sales invoices, and so on, you can use the the browse data functionality. -More information about the browse data functionality in Twinfield can be found in the [documentation](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Request/BrowseData). - -#### Browse definition - -You can retrieve the browse definition of a browse code as follows. -You don't need to retrieve the browse definition for getting the browse data. It's only for viewing the browse definition of a browse code to know exactly which columns are available. - -```php -$connector = new BrowseDataApiConnector($connection); -$browseDefinition = $connector->getBrowseDefinition('000'); -``` - -#### Browse fields - -You can retrieve the browse fields as follows. -You don't need to retrieve the browse fields for getting the browse data. It's only for viewing the definitions of all browse fields so you now what you can expect when retrieving browse data. - -```php -$connector = new BrowseDataApiConnector($connection); -$browseFields = $connector->getBrowseFields(); -``` - -#### Browse data - -You can retrieve browse data of a browse code as follows. - -```php -$connector = new BrowseDataApiConnector($connection); - -// First, create the columns that you want to retrieve (see the browse definition for which columns are available) -$columns[] = (new BrowseColumn()) - ->setField('fin.trs.head.yearperiod') - ->setLabel('Period') - ->setVisible(true) - ->setAsk(true) - ->setOperator(Enums\BrowseColumnOperator::BETWEEN()) - ->setFrom('2013/01') - ->setTo('2013/12'); - -$columns[] = (new BrowseColumn()) - ->setField('fin.trs.head.code') - ->setLabel('Transaction type') - ->setVisible(true); - -$columns[] = (new BrowseColumn()) - ->setField('fin.trs.head.shortname') - ->setLabel('Name') - ->setVisible(true); - -$columns[] = (new BrowseColumn()) - ->setField('fin.trs.head.number') - ->setLabel('Trans. no.') - ->setVisible(true); - -$columns[] = (new BrowseColumn()) - ->setField('fin.trs.line.dim1') - ->setLabel('General ledger') - ->setVisible(true) - ->setAsk(true) - ->setOperator(Enums\BrowseColumnOperator::BETWEEN()) - ->setFrom('1300') - ->setTo('1300'); - -$columns[] = (new BrowseColumn()) - ->setField('fin.trs.head.curcode') - ->setLabel('Currency') - ->setVisible(true); - -$columns[] = (new BrowseColumn()) - ->setField('fin.trs.line.valuesigned') - ->setLabel('Value') - ->setVisible(true); - -$columns[] = (new BrowseColumn()) - ->setField('fin.trs.line.description') - ->setLabel('Description') - ->setVisible(true); - -// Second, create sort fields -$sortFields[] = new BrowseSortField('fin.trs.head.code'); - -// Get the browse data -$browseData = $connector->getBrowseData('000', $columns, $sortFields); -``` +See [Usage] (usage.md) ### Supported resources Not all resources from the Twinfield API are currently implemented. Feel free to create a pull request when you need @@ -343,6 +50,7 @@ support for another resource. | User Roles | | :white_check_mark: | | | :white_check_mark: | | [VAT](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/VAT) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | VAT Groups | | :white_check_mark: | | | :white_check_mark: | +| VAT Groups Countries | | :white_check_mark: | | | :white_check_mark: | ## Links diff --git a/src/ApiConnectors/VatGroupCountryApiConnector.php b/src/ApiConnectors/VatGroupCountryApiConnector.php new file mode 100644 index 00000000..99d4a703 --- /dev/null +++ b/src/ApiConnectors/VatGroupCountryApiConnector.php @@ -0,0 +1,53 @@ + + */ +class VatGroupCountryApiConnector extends BaseApiConnector +{ + /** + * List all VAT group countries. + * + * @param string $pattern The search pattern. May contain wildcards * and ? + * @param int $field The search field determines which field or fields will be searched. The available fields + * depends on the finder type. Passing a value outside the specified values will cause an + * error. + * @param int $firstRow First row to return, useful for paging + * @param int $maxRows Maximum number of rows to return, useful for paging + * @param array $options The Finder options. Passing an unsupported name or value causes an error. It's possible + * to add multiple options. An option name may be used once, specifying an option multiple + * times will cause an error. + * + * @return VatGroupCountry[] The VAT group countries found. + */ + public function listAll( + string $pattern = '*', + int $field = 0, + int $firstRow = 1, + int $maxRows = 100, + array $options = [] + ): array { + $optionsArrayOfString = $this->convertOptionsToArrayOfString($options); + + $response = $this->getFinderService()->searchFinder(FinderService::TYPE_VAT_GROUPS_COUNTRIES, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); + + $vatGroupCountryListAllTags = array( + 0 => 'setCode', + 1 => 'setName', + ); + + return $this->mapListAll("VatGroupCountry", $response->data, $vatGroupCountryListAllTags); + } +} \ No newline at end of file diff --git a/src/CashBankBook.php b/src/CashBankBook.php index 8b76f767..f49b9ea2 100644 --- a/src/CashBankBook.php +++ b/src/CashBankBook.php @@ -11,7 +11,7 @@ * * @author Yannick Aerssens */ -class CashBankBook extends BaseObject +class CashBankBook { use CodeField; use NameField; diff --git a/src/Country.php b/src/Country.php index e0137081..d53b923f 100644 --- a/src/Country.php +++ b/src/Country.php @@ -11,7 +11,7 @@ * * @author Yannick Aerssens */ -class Country extends BaseObject +class Country { use CodeField; use NameField; diff --git a/src/Dummy.php b/src/Dummy.php index 1e76a8dc..26ce361b 100644 --- a/src/Dummy.php +++ b/src/Dummy.php @@ -12,7 +12,7 @@ * * @author Yannick Aerssens */ -class Dummy extends BaseObject +class Dummy { use CodeField; use NameField; diff --git a/src/Fields/VatCode/GroupCountryField.php b/src/Fields/VatCode/GroupCountryField.php index 8489e9b6..513a6784 100644 --- a/src/Fields/VatCode/GroupCountryField.php +++ b/src/Fields/VatCode/GroupCountryField.php @@ -2,10 +2,10 @@ namespace PhpTwinfield\Fields\VatCode; -use PhpTwinfield\Country; +use PhpTwinfield\VatGroupCountry; /** - * The country + * The VAT group country * Used by: VatCodeAccount * * @package PhpTwinfield\Traits @@ -13,11 +13,11 @@ trait GroupCountryField { /** - * @var Country|null + * @var VatGroupCountry|null */ private $groupCountry; - public function getGroupCountry(): ?Country + public function getGroupCountry(): ?VatGroupCountry { return $this->groupCountry; } @@ -34,7 +34,7 @@ public function getGroupCountryToString(): ?string /** * @return $this */ - public function setGroupCountry(?Country $groupCountry): self + public function setGroupCountry(?VatGroupCountry $groupCountry): self { $this->groupCountry = $groupCountry; return $this; @@ -47,7 +47,7 @@ public function setGroupCountry(?Country $groupCountry): self */ public function setGroupCountryFromString(?string $groupCountryCode) { - $groupCountry = new Country(); + $groupCountry = new VatGroupCountry(); $groupCountry->setCode($groupCountryCode); return $this->setGroupCountry($groupCountry); } diff --git a/src/InvoiceType.php b/src/InvoiceType.php index c32ccfb6..f6408de3 100644 --- a/src/InvoiceType.php +++ b/src/InvoiceType.php @@ -11,7 +11,7 @@ * * @author Yannick Aerssens */ -class InvoiceType extends BaseObject +class InvoiceType { use CodeField; use NameField; diff --git a/src/Mappers/VatGroupCountryMapper.php b/src/Mappers/VatGroupCountryMapper.php new file mode 100644 index 00000000..1145d0a4 --- /dev/null +++ b/src/Mappers/VatGroupCountryMapper.php @@ -0,0 +1,45 @@ + + */ +class VatGroupCountryMapper extends BaseMapper +{ + /** + * Maps a Response object to a clean VatGroupCountry entity. + * + * @access public + * + * @param \PhpTwinfield\Response\Response $response + * + * @return VatGroupCountry + * @throws \PhpTwinfield\Exception + */ + public static function map(Response $response) + { + // Generate new VatGroupCountry object + $vatGroupCountry = new VatGroupCountry(); + + // Gets the raw DOMDocument response. + $responseDOM = $response->getResponseDocument(); + + // Get the root/vat group country element + $vatGroupElement = $responseDOM->documentElement; + + // Set the vat group country elements from the vat group country element + $vatGroupCountry->setCode(self::getField($vatGroupCountry, $vatGroupElement, 'code')) + ->setName(self::getField($vatGroupCountry, $vatGroupElement, 'name')) + ->setShortName(self::getField($vatGroupCountry, $vatGroupElement, 'shortname')); + + // Return the complete object + return $vatGroupCountry; + } +} \ No newline at end of file diff --git a/src/PayCode.php b/src/PayCode.php index a32edafd..3c9ad9ec 100644 --- a/src/PayCode.php +++ b/src/PayCode.php @@ -11,7 +11,7 @@ * * @author Yannick Aerssens */ -class PayCode extends BaseObject +class PayCode { use CodeField; use NameField; diff --git a/src/UserRole.php b/src/UserRole.php index 170ab88b..2abb2868 100644 --- a/src/UserRole.php +++ b/src/UserRole.php @@ -11,7 +11,7 @@ * * @author Yannick Aerssens */ -class UserRole extends BaseObject +class UserRole { use CodeField; use NameField; diff --git a/src/VatGroup.php b/src/VatGroup.php index d6374333..5f3aa1c3 100644 --- a/src/VatGroup.php +++ b/src/VatGroup.php @@ -11,7 +11,7 @@ * * @author Yannick Aerssens */ -class VatGroup extends BaseObject +class VatGroup { use CodeField; use NameField; diff --git a/src/VatGroupCountry.php b/src/VatGroupCountry.php new file mode 100644 index 00000000..f5856f53 --- /dev/null +++ b/src/VatGroupCountry.php @@ -0,0 +1,19 @@ + + */ +class VatGroupCountry +{ + use CodeField; + use NameField; + use ShortNameField; +} \ No newline at end of file diff --git a/usage.md b/usage.md new file mode 100644 index 00000000..3a59da9c --- /dev/null +++ b/usage.md @@ -0,0 +1,296 @@ +## Usage + +### Authentication +You need to set up a `\PhpTwinfield\Secure\AuthenticatedConnection` class with your credentials. + +#### Session Login +**:warning: Note that Twinfield has stated that session login is deprecated and will be removed. End of life date will be announced later. See https://c3.twinfield.com/webservices/documentation/#/ApiReference/Authentication/WebServices** + +When using basic username and password authentication, the `\PhpTwinfield\Secure\WebservicesAuthentication` class should be used, as follows: + +```php +$connection = new Secure\WebservicesAuthentication("username", "password", "organization"); +``` + +#### OAuth2 +In order to use OAuth2 to authenticate with Twinfield, one should use the `\PhpTwinfield\Secure\Provider\OAuthProvider` to retrieve an `\League\OAuth2\Client\Token\AccessToken` object, and extract the refresh token from this object. Furthermore, it is required to set up a default `\PhpTwinfield\Office`, that will be used during requests to Twinfield. **Please note:** when a different office is specified when sending a request through one of the `ApiConnectors`, this Office will override the default. + +##### Request a client ID/Secret from Twinfield +Go to the [Twinfield web site](https://www.twinfield.nl/openid-connect-request/) in order to register your OpenID Connect / OAuth 2.0 client and get your Client ID and Secret. Fill in your personal information en pick the following: +* Flow: Authorization Code +* Consent: Your choice +* Redirect URL: The full URI where the following code is available on your domain/server +* Add more redirect URL's?: Your choice +* Post logout URL: Your choice, can be left blank +* Add more post logout URL's?: Your choice + +##### Grant Authorization and retrieve initial Access Token +On loading a page containing the following code the user will be redirected to the Twinfield Login page. +After successful login and optionally consent (see above) the user will be redirected back to the page at which point the Access Token and Refresh Token can be retrieved. + +For more information, please refer to: https://github.com/thephpleague/oauth2-client#usage + +```php +$provider = new \PhpTwinfield\Secure\Provider\OAuthProvider([ + 'clientId' => 'someClientId', // The Client ID assigned to you by Twinfield + 'clientSecret' => 'someClientSecret', // The Client Secret assigned to you by Twinfield + 'redirectUri' => 'https://example.org/', // The full URL your filled in at Redirect URL when you requested your client ID +]); + +// If we don't have an authorization code then get one +if (!isset($_GET['code'])) { + //Optionally limit your scope if you don't require all. + $options = [ + 'scope' => ['twf.user','twf.organisation','twf.organisationUser','offline_access','openid'] + ]; + + $authorizationUrl = $provider->getAuthorizationUrl($options); + + // Get the state generated for you and store it to the session. + $_SESSION['oauth2state'] = $provider->getState(); + + // Redirect the user to the authorization URL. + header('Location: ' . $authorizationUrl); + exit; + +// Check given state against previously stored one to mitigate CSRF attack +} elseif (empty($_GET['state']) || (isset($_SESSION['oauth2state']) && $_GET['state'] !== $_SESSION['oauth2state'])) { + if (isset($_SESSION['oauth2state'])) { + unset($_SESSION['oauth2state']); + } + + exit('Invalid state'); +} else { + try { + // Try to get an access token using the authorization code grant. + $accessToken = $provider->getAccessToken('authorization_code', [ + 'code' => $_GET['code'] + ]); + + //Twinfield's Refresh Token is valid for 550 days. + //Remember to put in place functionality to request the user to renew their authorization. + //This can be done by requesting the user to reload this page and logging into Twinfield + //before the refresh token is invalidated after 550 days. + $refresh_expiry = strtotime(date('Ymd') . " +550 days"); + + //Save Refresh Token and Refresh Token Expiry Time to storage + $refreshTokenStorage = array(); + $refreshTokenStorage['refresh_token'] = $accessToken->getRefreshToken(); + $refreshTokenStorage['refresh_expiry'] = $refresh_expiry; + + SaveRefreshTokenToStore($refreshTokenStorage); + + //OPTIONAL: Save Access Token, Access Token Expiry Time and Cluster to storage + $validationUrl = "https://login.twinfield.com/auth/authentication/connect/accesstokenvalidation?token="; + $validationResult = @file_get_contents($validationUrl . urlencode($accessToken->getToken())); + + if ($validationResult !== false) { + $resultDecoded = \json_decode($validationResult, true); + $accessTokenStorage = array(); + $accessTokenStorage['access_token'] = $accessToken->getToken(); + $accessTokenStorage['access_expiry'] = $accessToken->getExpires(); + $accessTokenStorage['access_cluster'] = $resultDecoded["twf.clusterUrl"]; + SaveAccessTokenToStore($accessTokenStorage); + } + } catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) { + // Failed to get the access token or user details. + exit($e->getMessage()); + } +} +``` + +##### Optionally: Store a valid access token and cluster through a scheduled task/cron job running in the background +Running the following code every 60 minutes (or a bit less as Access Tokens are valid for exactly 60 minutes) will reduce connection time when working with the Api (by about 2 seconds). It will also reduce connection load on Twinfield when making more than 20-30 connections/day. + +```php +$refreshTokenStorage = retrieveRefreshTokenFromStore(); + +$provider = new OAuthProvider([ + 'clientId' => 'someClientId', + 'clientSecret' => 'someClientSecret', + 'redirectUri' => 'https://example.org/' +]); + +$accessToken = $provider->getAccessToken('refresh_token', [ + 'refresh_token' => $refreshTokenStorage['refresh_token'] +]); + +$validationUrl = "https://login.twinfield.com/auth/authentication/connect/accesstokenvalidation?token="; +$validationResult = @file_get_contents($validationUrl . urlencode($accessToken->getToken())); + +if ($validationResult !== false) { + $resultDecoded = \json_decode($validationResult, true); + + $tokenStorage = array(); + $tokenStorage['access_token'] = $accessToken->getToken(); + $tokenStorage['access_expiry'] = $accessToken->getExpires(); + $tokenStorage['access_cluster'] = $resultDecoded["twf.clusterUrl"]; + + SaveAccessTokenToStore($tokenStorage); +} +``` + +##### Connection +Using the stored Refresh Token and optionally Access Token/Cluster, we can create an instance of the `\PhpTwinfield\Secure\OpenIdConnectAuthentication` class, as follows: + +```php +$provider = new OAuthProvider([ + 'clientId' => 'someClientId', + 'clientSecret' => 'someClientSecret', + 'redirectUri' => 'https://example.org/' +]); + +//Retrieve Refresh Token and Refresh Token Expiry Time from storage +$refreshTokenStorage = retrieveRefreshTokenFromStore(); + +//OPTIONAL: Retrieve Access Token, Access Token Expiry Time and Cluster from storage +$accessTokenStorage = retrieveAccessTokenFromStore(); + +$office = \PhpTwinfield\Office::fromCode("someOfficeCode"); + +if ($accessTokenStorage['access_expiry'] > time()) { + $connection = new \PhpTwinfield\Secure\OpenIdConnectAuthentication($provider, $refreshTokenStorage['refresh_token'], $office, $accessTokenStorage['access_token'], $accessTokenStorage['access_cluster']); +} else { + $connection = new \PhpTwinfield\Secure\OpenIdConnectAuthentication($provider, $refreshTokenStorage['refresh_token'], $office); +} +``` + +### Getting data from the API +In order to communicate with the Twinfield API, you need to create an `ApiConnector` instance for the corresponding +resource and use the `get()` or `list()` method. + +The `ApiConnector` takes a `Secure\AuthenticatedConnection` object: + +An example: + +```php + +$connection = new Secure\WebservicesAuthentication("username", "password", "organization"); +$customerApiConnector = new ApiConnectors\CustomerApiConnector($connection); + +// Get one customer. +$office = Office::fromCode('office code'); +$customer = $customerApiConnector->get('1001', $office); + +// Get a list of all customers. +$customer = $customerApiConnector->listAll($office); +``` + +### Creating or updating objects +If you want to create or update a customer or any other object, it's just as easy: + +```php +$customer_factory = new ApiConnectors\CustomerApiConnector($connection); + +// First, create the objects you want to send. +$customer = new Customer(); +$customer + ->setCode('1001') + ->setName('John Doe') + ->setOffice($office) + ->setEBilling(false); + +$customer_address = new CustomerAddress(); +$customer_address + ->setType('invoice') + ->setDefault(false) + ->setPostcode('1212 AB') + ->setCity('TestCity') + ->setCountry('NL') + ->setTelephone('010-12345') + ->setFax('010-1234') + ->setEmail('johndoe@example.com'); +$customer->addAddress($customer_address); + +// And secondly, send it to Twinfield. +$customer_factory->send($customer); +``` + +You can also send multiple objects in one batch, chunking is handled automatically. + +### Browse data +In order to get financial data out of Twinfield like general ledger transactions, sales invoices, and so on, you can use the the browse data functionality. +More information about the browse data functionality in Twinfield can be found in the [documentation](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Request/BrowseData). + +#### Browse definition + +You can retrieve the browse definition of a browse code as follows. +You don't need to retrieve the browse definition for getting the browse data. It's only for viewing the browse definition of a browse code to know exactly which columns are available. + +```php +$connector = new BrowseDataApiConnector($connection); +$browseDefinition = $connector->getBrowseDefinition('000'); +``` + +#### Browse fields + +You can retrieve the browse fields as follows. +You don't need to retrieve the browse fields for getting the browse data. It's only for viewing the definitions of all browse fields so you now what you can expect when retrieving browse data. + +```php +$connector = new BrowseDataApiConnector($connection); +$browseFields = $connector->getBrowseFields(); +``` + +#### Browse data + +You can retrieve browse data of a browse code as follows. + +```php +$connector = new BrowseDataApiConnector($connection); + +// First, create the columns that you want to retrieve (see the browse definition for which columns are available) +$columns[] = (new BrowseColumn()) + ->setField('fin.trs.head.yearperiod') + ->setLabel('Period') + ->setVisible(true) + ->setAsk(true) + ->setOperator(Enums\BrowseColumnOperator::BETWEEN()) + ->setFrom('2013/01') + ->setTo('2013/12'); + +$columns[] = (new BrowseColumn()) + ->setField('fin.trs.head.code') + ->setLabel('Transaction type') + ->setVisible(true); + +$columns[] = (new BrowseColumn()) + ->setField('fin.trs.head.shortname') + ->setLabel('Name') + ->setVisible(true); + +$columns[] = (new BrowseColumn()) + ->setField('fin.trs.head.number') + ->setLabel('Trans. no.') + ->setVisible(true); + +$columns[] = (new BrowseColumn()) + ->setField('fin.trs.line.dim1') + ->setLabel('General ledger') + ->setVisible(true) + ->setAsk(true) + ->setOperator(Enums\BrowseColumnOperator::BETWEEN()) + ->setFrom('1300') + ->setTo('1300'); + +$columns[] = (new BrowseColumn()) + ->setField('fin.trs.head.curcode') + ->setLabel('Currency') + ->setVisible(true); + +$columns[] = (new BrowseColumn()) + ->setField('fin.trs.line.valuesigned') + ->setLabel('Value') + ->setVisible(true); + +$columns[] = (new BrowseColumn()) + ->setField('fin.trs.line.description') + ->setLabel('Description') + ->setVisible(true); + +// Second, create sort fields +$sortFields[] = new BrowseSortField('fin.trs.head.code'); + +// Get the browse data +$browseData = $connector->getBrowseData('000', $columns, $sortFields); +``` \ No newline at end of file From 8ff10168cada1fa49476aa9533ca85bbc79e6c66 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 14 May 2019 12:05:04 +0200 Subject: [PATCH 210/388] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index b3acb91e..123d005d 100644 --- a/readme.md +++ b/readme.md @@ -15,7 +15,7 @@ composer require 'php-twinfield/twinfield:^2.0' ## Usage -See [Usage] (usage.md) +See [Usage](usage.md) ### Supported resources Not all resources from the Twinfield API are currently implemented. Feel free to create a pull request when you need From f25dadefcb50095a690c0cc83de36f26ca5bb228 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 14 May 2019 12:09:34 +0200 Subject: [PATCH 211/388] Update RenewAuthorization.php --- examples/RenewAuthorization.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/RenewAuthorization.php b/examples/RenewAuthorization.php index c449d0dc..8650572b 100644 --- a/examples/RenewAuthorization.php +++ b/examples/RenewAuthorization.php @@ -21,6 +21,9 @@ function SendEmail(string $toEmail, string $fromEmail, string $subject, string $ // Only allow the script to run from the command line interface e.g. Cron if (php_sapi_name() !='cli') exit; +// The FQDN URI of the script used for initial authorization, must be filled out on the form (Redirect URL) when requesting the client ID/Secret from Twinfield. +$twin_redirect_uri = 'https://example.org/twinfield/Authorization.php'; + // Amount of days before the refresh token expires after 550 days to start asking the user for renewal $daysLeftAfterWhichRequestRenewal = 60; @@ -42,9 +45,6 @@ function SendEmail(string $toEmail, string $fromEmail, string $subject, string $ You will receive this email once a week until the authorization is renewed."; -// The FQDN URI of the script used for initial authorization, must be filled out on the form (Redirect URL) when requesting the client ID/Secret from Twinfield. -$twin_redirect_uri = 'https://example.org/twinfield/Authorization.php'; - if ($refreshTokenStorage['refresh_expiry'] < (time() + ($daysLeftAfterWhichRequestRenewal * 60 * 60 * 24))) { SendEmail($accountingAdminEmail, $fromEmail, $subject, $body); } From c910487ed4c85b96fce7cc91088ef19bb4047f38 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 15 May 2019 09:15:43 +0200 Subject: [PATCH 212/388] Upload --- examples/CashBankBook.php | 70 +++--- examples/CostCenter.php | 218 +++++++++-------- examples/Country.php | 66 ++++-- examples/Currency.php | 222 ++++++++++++++++++ examples/PayCode.php | 72 +++--- examples/VatGroup.php | 66 ++++-- examples/VatGroupCountry.php | 70 +++--- readme.md | 65 ++--- src/ApiConnectors/CurrencyApiConnector.php | 55 ++++- src/Currency.php | 2 +- src/CustomerAddress.php | 2 +- src/CustomerChildValidation.php | 2 +- src/CustomerFinancials.php | 2 +- src/Enums/Culture.php | 27 +++ src/Enums/UserType.php | 19 ++ .../{Dimensions/Level2 => }/EmailField.php | 4 +- src/Fields/{Dimensions => }/LevelField.php | 4 +- src/Fields/User/AcceptExtraCostField.php | 47 ++++ src/Fields/User/CultureField.php | 40 ++++ src/Fields/User/CultureNameField.php | 31 +++ src/Fields/User/CultureNativeNameField.php | 31 +++ src/Fields/User/DemoField.php | 47 ++++ src/Fields/User/DemoLockedField.php | 47 ++++ src/Fields/User/ExchangeQuotaField.php | 32 +++ src/Fields/User/ExchangeQuotaLockedField.php | 47 ++++ src/Fields/User/FileManagerQuotaField.php | 32 +++ .../User/FileManagerQuotaLockedField.php | 47 ++++ src/Fields/User/PasswordField.php | 31 +++ src/Fields/User/TypeField.php | 40 ++++ src/Fields/User/TypeLockedField.php | 47 ++++ src/FixedAssetFinancials.php | 2 +- src/GeneralLedgerChildValidation.php | 2 +- src/GeneralLedgerFinancials.php | 2 +- src/Mappers/InvoiceTypeMapper.php | 2 +- src/Mappers/PayCodeMapper.php | 4 +- src/SupplierAddress.php | 2 +- src/SupplierChildValidation.php | 2 +- src/SupplierFinancials.php | 2 +- src/User.php | 28 +++ src/UserRole.php | 1 + 40 files changed, 1247 insertions(+), 285 deletions(-) create mode 100644 examples/Currency.php create mode 100644 src/Enums/Culture.php create mode 100644 src/Enums/UserType.php rename src/Fields/{Dimensions/Level2 => }/EmailField.php (81%) rename src/Fields/{Dimensions => }/LevelField.php (84%) create mode 100644 src/Fields/User/AcceptExtraCostField.php create mode 100644 src/Fields/User/CultureField.php create mode 100644 src/Fields/User/CultureNameField.php create mode 100644 src/Fields/User/CultureNativeNameField.php create mode 100644 src/Fields/User/DemoField.php create mode 100644 src/Fields/User/DemoLockedField.php create mode 100644 src/Fields/User/ExchangeQuotaField.php create mode 100644 src/Fields/User/ExchangeQuotaLockedField.php create mode 100644 src/Fields/User/FileManagerQuotaField.php create mode 100644 src/Fields/User/FileManagerQuotaLockedField.php create mode 100644 src/Fields/User/PasswordField.php create mode 100644 src/Fields/User/TypeField.php create mode 100644 src/Fields/User/TypeLockedField.php diff --git a/examples/CashBankBook.php b/examples/CashBankBook.php index 5022d12d..12314fcc 100644 --- a/examples/CashBankBook.php +++ b/examples/CashBankBook.php @@ -17,6 +17,11 @@ * \PhpTwinfield\ApiConnectors\CashBankBookApiConnector * Available methods: listAll */ + +// Run all or only some of the following examples +$executeListAllWithFilter = false; +$executeListAllWithoutFilter = true; +$executeNew = false; $cashBankBookApiConnector = new \PhpTwinfield\ApiConnectors\CashBankBookApiConnector($connection); @@ -42,44 +47,55 @@ */ //List all with pattern "BNK", field 0 (= search code or number), firstRow 1, maxRows 10, options -> banktype = 0 -$options = array('banktype' => 0); - -try { - $cashBankBooks = $cashBankBookApiConnector->listAll('BNK', 0, 1, 10, $options); -} catch (ResponseException $e) { - $cashBankBooks = $e->getReturnedObject(); +if ($executeListAllWithFilter) { + $options = array('banktype' => 0); + + try { + $cashBankBooks = $cashBankBookApiConnector->listAll('BNK', 0, 1, 10, $options); + } catch (ResponseException $e) { + $cashBankBooks = $e->getReturnedObject(); + } + + echo "
";
+    print_r($cashBankBooks);
+    echo "
"; } //List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) -try { - $cashBankBooks = $cashBankBookApiConnector->listAll(); -} catch (ResponseException $e) { - $cashBankBooks = $e->getReturnedObject(); +if ($executeListAllWithoutFilter) { + try { + $cashBankBooks = $cashBankBookApiConnector->listAll(); + } catch (ResponseException $e) { + $cashBankBooks = $e->getReturnedObject(); + } + + echo "
";
+    print_r($cashBankBooks);
+    echo "
"; } -echo "
";
-print_r($cashBankBooks);
-echo "
"; - /* CashBankBook * \PhpTwinfield\CashBankBook * Available getters: getCode, getName, getShortName * Available setters: setCode, setName, setShortName */ -foreach ($cashBankBooks as $key => $cashBankBook) { - echo "CashBankBook {$key}
"; - echo "Code: {$cashBankBook->getCode()}
"; - echo "Name: {$cashBankBook->getName()}

"; +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($cashBankBooks as $key => $cashBankBook) { + echo "CashBankBook {$key}
"; + echo "Code: {$cashBankBook->getCode()}
"; + echo "Name: {$cashBankBook->getName()}

"; + } } // NOTE: Because the CashBankBookApiConnector only supports the listAll method at the moment it is not particularly useful to create a new CashBankBook - -$cashBankBook = new \PhpTwinfield\CashBankBook; -$cashBankBook->setCode("BNK"); -$cashBankBook->setName("Standaard bank"); -$cashBankBook->setShortName("StdBank"); - -echo "
";
-print_r($cashBankBook);
-echo "
"; \ No newline at end of file +if ($executeNew) { + $cashBankBook = new \PhpTwinfield\CashBankBook; + $cashBankBook->setCode("BNK"); + $cashBankBook->setName("Standaard bank"); + $cashBankBook->setShortName("StdBank"); + + echo "
";
+    print_r($cashBankBook);
+    echo "
"; +} \ No newline at end of file diff --git a/examples/CostCenter.php b/examples/CostCenter.php index 4930d027..9acbade5 100644 --- a/examples/CostCenter.php +++ b/examples/CostCenter.php @@ -1,7 +1,8 @@ modifiedsince = '20190101100000', group = 'DimensionGroup' -$options = array('modifiedsince' => '20190101100000', 'group' => 'DimensionGroup'); - -try { - $costCenters = $costCenterApiConnector->listAll("Apeldoorn", 0, 5, 10, $options); -} catch (ResponseException $e) { - $costCenters = $e->getReturnedObject(); +if ($executeListAllWithFilter) { + $options = array('modifiedsince' => '20190101100000', 'group' => 'DimensionGroup'); + + try { + $costCenters = $costCenterApiConnector->listAll("Apeldoorn", 0, 5, 10, $options); + } catch (ResponseException $e) { + $costCenters = $e->getReturnedObject(); + } + + echo "
";
+    print_r($costCenters);
+    echo "
"; } + //List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) -try { - $costCenters = $costCenterApiConnector->listAll(); -} catch (ResponseException $e) { - $costCenters = $e->getReturnedObject(); +if ($executeListAllWithoutFilter) { + try { + $costCenters = $costCenterApiConnector->listAll(); + } catch (ResponseException $e) { + $costCenters = $e->getReturnedObject(); + } + + echo "
";
+    print_r($costCenters);
+    echo "
"; } -echo "
";
-print_r($costCenters);
-echo "
"; - /* CostCenter * \PhpTwinfield\CostCenter * Available getters: getBehaviour, getCode, getInUse, getInUseToString, getMessages, getName, getOffice, getOfficeToString, getResult, getShortName, getStatus, getTouched, getType, getTypeToString, getUID, hasMessages * Available setters: setBehaviour, setBehaviourFromString, setCode, setName, setOffice, setOfficeFromString, setShortName, setStatus, setStatusFromString, setType, setTypeFromString */ -foreach ($costCenters as $key => $costCenter) { - echo "CostCenter {$key}
"; - echo "Code: {$costCenter->getCode()}
"; - echo "Name: {$costCenter->getName()}

"; +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($costCenters as $key => $costCenter) { + echo "CostCenter {$key}
"; + echo "Code: {$costCenter->getCode()}
"; + echo "Name: {$costCenter->getName()}

"; + } } // Read a CostCenter based off the passed in code and optionally the office. -$costCenter = $costCenterApiConnector->get("00000", $office); - -echo "
";
-print_r($costCenter);
-echo "
"; - -echo "CostCenter {$key}
"; -echo "Behaviour: {$costCenter->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. -echo "Code: {$costCenter->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the KPL Dimension type. -echo "InUse (bool): {$costCenter->getInUse()}
"; // bool|null Indicates whether the cost center is used in a financial transaction or not. Read-only attribute. -echo "InUse (string): {$costCenter->getInUseToString()}
"; // string|null -echo "Messages: {$costCenter->getMessages()}
"; // Array|null (Error) messages -echo "Name: {$costCenter->getName()}
"; // string|null Name of the dimension. -echo "Office (\\PhpTwinfield\\Office):
" . print_r($costCenter->getOffice(), true) . "

"; // Office|null Office. -echo "Office (string): {$costCenter->getOfficeToString()}
"; // string|null -echo "Result: {$costCenter->getResult()}
"; // int|null Result (0 = error, 1 = success). -echo "ShortName: {$costCenter->getShortName()}
"; // string|null Not in use. -echo "Status: {$costCenter->getStatus()}
"; // Status|null Status of the CostCenter -echo "Touched: {$costCenter->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. -echo "Type: {$costCenter->getType()}
"; // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is KPL. -echo "Type: {$costCenter->getTypeToString()}
"; // string|null -echo "UID: {$costCenter->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. -echo "Has Messages: {$costCenter->hasMessages()}
"; // bool Result has (error) messages +if ($executeRead) { + $costCenter = $costCenterApiConnector->get("00000", $office); + + echo "
";
+    print_r($costCenter);
+    echo "
"; + + echo "CostCenter
"; + echo "Behaviour: {$costCenter->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. + echo "Code: {$costCenter->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the KPL Dimension type. + echo "InUse (bool): {$costCenter->getInUse()}
"; // bool|null Indicates whether the cost center is used in a financial transaction or not. Read-only attribute. + echo "InUse (string): {$costCenter->getInUseToString()}
"; // string|null + + if ($costCenter->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($costCenter->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Name: {$costCenter->getName()}
"; // string|null Name of the dimension. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($costCenter->getOffice(), true) . "

"; // Office|null Office. + echo "Office (string): {$costCenter->getOfficeToString()}
"; // string|null + echo "Result: {$costCenter->getResult()}
"; // int|null Result (0 = error, 1 = success). + echo "ShortName: {$costCenter->getShortName()}
"; // string|null Not in use. + echo "Status: {$costCenter->getStatus()}
"; // Status|null Status of the cost center. + echo "Touched: {$costCenter->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. + echo "Type: {$costCenter->getType()}
"; // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is KPL. + echo "Type: {$costCenter->getTypeToString()}
"; // string|null + echo "UID: {$costCenter->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. +} // Copy an existing CostCenter to a new entity -$costCenter = $costCenterApiConnector->get("00000", $office); -$costCenter->setCode(null); +if ($executeCopy) { + $costCenter = $costCenterApiConnector->get("00000", $office); + $costCenter->setCode(null); -try { - $costCenterCopy = $costCenterApiConnector->send($costCenter); -} catch (ResponseException $e) { - $costCenterCopy = $e->getReturnedObject(); -} + try { + $costCenterCopy = $costCenterApiConnector->send($costCenter); + } catch (ResponseException $e) { + $costCenterCopy = $e->getReturnedObject(); + } -echo "
";
-print_r($costCenterCopy);
-echo "
"; + echo "
";
+    print_r($costCenterCopy);
+    echo "
"; -echo "Code of copied CostCenter: {$costCenterCopy->getCode()}
"; + echo "Code of copied CostCenter: {$costCenterCopy->getCode()}
"; +} // Create a new CostCenter from scratch, alternatively read an existing CostCenter as shown above and than modify the values in the same way as shown below -$costCenter = new \PhpTwinfield\CostCenter; - -// Required values for creating a new CostCenter -$costCenter->setName("CostCenterName"); // string|null Name of the dimension. -$costCenter->setOffice($office); // Office|null Office. -$costCenter->setOfficefromCode($officeCode); // string|null - -// Optional values for creating a new CostCenter -$costCenter->setCode(null); // string|null Dimension code, must be compliant with the mask of the KPL Dimension type. -//$costCenter->setCode('00020'); // string|null -$costCenter->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. -//$costCenter->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null For deleting deleted should be used. In case a dimension that is used in a transaction is deleted, - // its status has been changed into hide. Hidden dimensions can be activated by using active. -$costCenter->setStatusFromString('active'); // string|null -//$costCenter->setStatusFromString('deleted'); // string|null - // -$dimensionType = new \PhpTwinfield\DimensionType; -$dimensionType->setCode('KPL'); -$costCenter->setType($dimensionType); // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is KPL. -$costCenter->setTypeFromString('KPL'); // string|null - -try { - $costCenterNew = $costCenterApiConnector->send($costCenter); -} catch (ResponseException $e) { - $costCenterNew = $e->getReturnedObject(); +if ($executeNew) { + $costCenter = new \PhpTwinfield\CostCenter; + + // Required values for creating a new CostCenter + $costCenter->setName("CostCenterName"); // string|null Name of the dimension. + $costCenter->setOffice($office); // Office|null Office. + $costCenter->setOfficefromCode($officeCode); // string|null + + // Optional values for creating a new CostCenter + $costCenter->setCode(null); // string|null Dimension code, must be compliant with the mask of the KPL Dimension type. + //$costCenter->setCode('00020'); // string|null + $costCenter->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. + //$costCenter->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null For deleting deleted should be used. In case a dimension that is used in a transaction is deleted, + // its status has been changed into hide. Hidden dimensions can be activated by using active. + $costCenter->setStatusFromString('active'); // string|null + //$costCenter->setStatusFromString('deleted'); // string|null + // + $dimensionType = new \PhpTwinfield\DimensionType; + $dimensionType->setCode('KPL'); + $costCenter->setType($dimensionType); // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is KPL. + $costCenter->setTypeFromString('KPL'); // string|null + + try { + $costCenterNew = $costCenterApiConnector->send($costCenter); + } catch (ResponseException $e) { + $costCenterNew = $e->getReturnedObject(); + } + + echo "
";
+    print_r($costCenterNew);
+    echo "
"; + + echo "Code of new CostCenter: {$costCenterNew->getCode()}
"; } -echo "
";
-print_r($costCenterNew);
-echo "
"; - -echo "Code of new CostCenter: {$costCenterNew->getCode()}
"; - // Delete a CostCenter based off the passed in code and optionally the office. - -try { - $costCenterDeleted = $costCenterApiConnector->delete("SomeCostCenterCode", $office); -} catch (ResponseException $e) { - $costCenterDeleted = $e->getReturnedObject(); -} - -echo "
";
-print_r($costCenterDeleted);
-echo "
"; \ No newline at end of file +if ($executeDelete) { + try { + $costCenterDeleted = $costCenterApiConnector->delete("SomeCostCenterCode", $office); + } catch (ResponseException $e) { + $costCenterDeleted = $e->getReturnedObject(); + } + + echo "
";
+    print_r($costCenterDeleted);
+    echo "
"; +} \ No newline at end of file diff --git a/examples/Country.php b/examples/Country.php index 2f05da88..cff517e3 100644 --- a/examples/Country.php +++ b/examples/Country.php @@ -18,6 +18,11 @@ * Available methods: listAll */ +// Run all or only some of the following examples +$executeListAllWithFilter = false; +$executeListAllWithoutFilter = true; +$executeNew = false; + $countryApiConnector = new \PhpTwinfield\ApiConnectors\CountryApiConnector($connection); /* List all countries @@ -38,42 +43,53 @@ */ //List all with pattern "NL", field 0 (= search code or number), firstRow 1, maxRows 10 -try { - $countries = $countryApiConnector->listAll('NL', 0, 1, 10); -} catch (ResponseException $e) { - $countries = $e->getReturnedObject(); +if ($executeListAllWithFilter) { + try { + $countries = $countryApiConnector->listAll('NL', 0, 1, 10); + } catch (ResponseException $e) { + $countries = $e->getReturnedObject(); + } + + echo "
";
+    print_r($countries);
+    echo "
"; } //List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) -try { - $countries = $countryApiConnector->listAll(); -} catch (ResponseException $e) { - $countries = $e->getReturnedObject(); +if ($executeListAllWithoutFilter) { + try { + $countries = $countryApiConnector->listAll(); + } catch (ResponseException $e) { + $countries = $e->getReturnedObject(); + } + + echo "
";
+    print_r($countries);
+    echo "
"; } -echo "
";
-print_r($countries);
-echo "
"; - /* Country * \PhpTwinfield\Country * Available getters: getCode, getName, getShortName * Available setters: setCode, setName, setShortName */ -foreach ($countries as $key => $country) { - echo "Country {$key}
"; - echo "Code: {$country->getCode()}
"; - echo "Name: {$country->getName()}

"; +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($countries as $key => $country) { + echo "Country {$key}
"; + echo "Code: {$country->getCode()}
"; + echo "Name: {$country->getName()}

"; + } } // NOTE: Because the CountryApiConnector only supports the listAll method at the moment it is not particularly useful to create a new Country - -$country = new \PhpTwinfield\Country; -$country->setCode("NL"); -$country->setName("Nederland"); -$country->setShortName("Nederland"); - -echo "
";
-print_r($country);
-echo "
"; \ No newline at end of file +if ($executeNew) { + $country = new \PhpTwinfield\Country; + $country->setCode("NL"); + $country->setName("Nederland"); + $country->setShortName("Nederland"); + + echo "
";
+    print_r($country);
+    echo "
"; +} \ No newline at end of file diff --git a/examples/Currency.php b/examples/Currency.php new file mode 100644 index 00000000..5677425d --- /dev/null +++ b/examples/Currency.php @@ -0,0 +1,222 @@ +listAll("EUR", 0, 5, 10); + } catch (ResponseException $e) { + $currencies = $e->getReturnedObject(); + } + + echo "
";
+    print_r($currencies);
+    echo "
"; +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +if ($executeListAllWithoutFilter) { + try { + $currencies = $currencyApiConnector->listAll(); + } catch (ResponseException $e) { + $currencies = $e->getReturnedObject(); + } + + echo "
";
+    print_r($currencies);
+    echo "
"; +} + +/* Currency + * \PhpTwinfield\Currency + * Available getters: getCode, getMessages, getName, getOffice, getOfficeToString, getResult, getShortName, getStatus, hasMessages, getRates + * Available setters: setCode, setName, setOffice, setOfficeFromString, setShortName, setStatus, setStatusFromString, addRate, removeRate + */ + +/* CurrencyRate + * \PhpTwinfield\CurrencyRate + * Available getters: getMessages, getRate, getResult, getStartDate, getStartDateToString, getStatus, hasMessages + * Available setters: setRate ,setStartDate, setStartDateFromString, setStatus, setStatusFromString + */ + +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($currencies as $key => $currency) { + echo "Currency {$key}
"; + echo "Code: {$currency->getCode()}
"; + echo "Name: {$currency->getName()}

"; + } +} + +// Read a Currency based off the passed in code and optionally the office. +if ($executeRead) { + $currency = $currencyApiConnector->get("EUR", $office); + + echo "
";
+    print_r($currency);
+    echo "
"; + + echo "Currency
"; + echo "Code: {$currency->getCode()}
"; // string|null The code of the currency. + + if ($currency->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($currency->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Name: {$currency->getName()}
"; // string|null Name of the currency. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($currency->getOffice(), true) . "

"; // Office|null Office of the currency. + echo "Office (string): {$currency->getOfficeToString()}
"; // string|null + echo "Result: {$currency->getResult()}
"; // int|null Result (0 = error, 1 = success). + echo "ShortName: {$currency->getShortName()}
"; // string|null Short name of the currency. + echo "Status: {$currency->getStatus()}
"; // Status|null Status of the currency. + + $currencyRates = $currency->getRates(); // Array|null Array of CurrencyRate objects. + + foreach ($currencyRates as $key => $currencyRate) { + echo "CurrencyRate {$key}
"; + + if ($currencyRate->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($currencyRate->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Rate: {$currencyRate->getRate()}
"; // float|null Conversion rate to be used as of the start date. + echo "Result: {$currencyRate->getResult()}
"; // int|null Result (0 = error, 1 = success). + echo "StartDate (\\DateTimeInterface):
" . print_r($currencyRate->getStartDate(), true) . "

"; // \DateTimeInterface|null Starting date of the rate. + echo "StartDate (string): {$currencyRate->getStartDateToString()}
"; // string|null + echo "Status: {$currencyRate->getStatus()}
"; // Status|null Status of the currency rate. + } +} + +// Copy an existing Currency to a new entity +if ($executeCopy) { + $currency = $currencyApiConnector->get("EUR", $office); + $currency->setCode("EUR2"); + + try { + $currencyCopy = $currencyApiConnector->send($currency); + } catch (ResponseException $e) { + $currencyCopy = $e->getReturnedObject(); + } + + echo "
";
+    print_r($currencyCopy);
+    echo "
"; + + echo "Result of copy process: {$currencyCopy->getResult()}
"; + echo "Code of copied Currency: {$currencyCopy->getCode()}
"; +} + +// Create a new Currency from scratch, alternatively read an existing Currency as shown above and than modify the values in the same way as shown below +if ($executeNew) { + $currency = new \PhpTwinfield\Currency; + + // Required values for creating a new Currency + $currency->setCode('JPY'); // string|null The code of the currency. + $currency->setName("Japanese yen"); // string|null Name of the currency. + $currency->setOffice($office); // Office|null Office code of the currency. + $currency->setOfficefromCode($officeCode); // string|null + + // Optional values for creating a new Currency + $currency->setShortName("Yen"); // string|null Short name of the currency. + //$currency->setShortName("¥"); // string|null + $currency->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. + //$currency->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null For deleting deleted should be used. In case a dimension that is used in a transaction is deleted, + // its status has been changed into hide. Hidden dimensions can be activated by using active. + $currency->setStatusFromString('active'); // string|null + //$currency->setStatusFromString('deleted'); // string|null + + // The minimum amount of CurrencyRates linked to a Currency object is 0 + $currencyRate = new \PhpTwinfield\CurrencyRate; + $currencyRate->setRate(122.87); // float|null Conversion rate to be used as of the start date. + $startDate = DateTime::createFromFormat('d-m-Y', '01-01-2019'); + $currencyRate->setStartDate($startDate); // \DateTimeInterface|null Starting date of the rate. + $currencyRate->setStartDateFromString('20190101'); // string|null + $currencyRate->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. + //$currencyRate->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null For deleting deleted should be used. In case a dimension that is used in a transaction is deleted, + // its status has been changed into hide. Hidden dimensions can be activated by using active. + $currencyRate->setStatusFromString('active'); // string|null + //$currencyRate->setStatusFromString('deleted'); // string|null + + $currency->addRate($currencyRate); // CurrencyRate Add a CurrencyRate object to the Currency object + //$currency->removeRate(0); // int Remove a rate based on the index of the rate within the array + + try { + $currencyNew = $currencyApiConnector->send($currency); + } catch (ResponseException $e) { + $currencyNew = $e->getReturnedObject(); + } + + echo "
";
+    print_r($currencyNew);
+    echo "
"; + + echo "Result of creation process: {$currencyNew->getResult()}
"; + echo "Code of new Currency: {$currencyNew->getCode()}
"; +} + +// Delete a Currency based off the passed in code and optionally the office. +if ($executeDelete) { + try { + $currencyDeleted = $currencyApiConnector->delete("SomeCurrencyCode", $office); + } catch (ResponseException $e) { + $currencyDeleted = $e->getReturnedObject(); + } + + echo "
";
+    print_r($currencyDeleted);
+    echo "
"; + + echo "Result of deletion process: {$currencyDeleted->getResult()}
"; +} \ No newline at end of file diff --git a/examples/PayCode.php b/examples/PayCode.php index 798fcb6b..eef08c7d 100644 --- a/examples/PayCode.php +++ b/examples/PayCode.php @@ -17,6 +17,11 @@ * \PhpTwinfield\ApiConnectors\PayCodeApiConnector * Available methods: listAll */ + +// Run all or only some of the following examples +$executeListAllWithFilter = false; +$executeListAllWithoutFilter = true; +$executeNew = false; $payCodeApiConnector = new \PhpTwinfield\ApiConnectors\PayCodeApiConnector($connection); @@ -42,44 +47,55 @@ */ //List all with pattern "SEPA*", field 0 (= search code or number), firstRow 5, maxRows 10, options -> paytype = pay -$options = array('paytype' => 'pay'); - -try { - $payCodes = $payCodeApiConnector->listAll("SEPA*", 0, 5, 10, $options); -} catch (ResponseException $e) { - $payCodes = $e->getReturnedObject(); +if ($executeListAllWithFilter) { + $options = array('paytype' => 'pay'); + + try { + $payCodes = $payCodeApiConnector->listAll("SEPA*", 0, 5, 10, $options); + } catch (ResponseException $e) { + $payCodes = $e->getReturnedObject(); + } + + echo "
";
+    print_r($payCodes);
+    echo "
"; } //List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) -try { - $payCodes = $payCodeApiConnector->listAll(); -} catch (ResponseException $e) { - $payCodes = $e->getReturnedObject(); +if ($executeListAllWithoutFilter) { + try { + $payCodes = $payCodeApiConnector->listAll(); + } catch (ResponseException $e) { + $payCodes = $e->getReturnedObject(); + } + + echo "
";
+    print_r($payCodes);
+    echo "
"; } -echo "
";
-print_r($payCodes);
-echo "
"; - /* PayCode * \PhpTwinfield\PayCode * Available getters: getCode, getName, getShortName * Available setters: setCode, setName, setShortName */ - -foreach ($payCodes as $key => $payCode) { - echo "PayCode {$key}
"; - echo "Code: {$payCode->getCode()}
"; - echo "Name: {$payCode->getName()}

"; + +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($payCodes as $key => $payCode) { + echo "PayCode {$key}
"; + echo "Code: {$payCode->getCode()}
"; + echo "Name: {$payCode->getName()}

"; + } } // NOTE: Because the PayCodeApiConnector only supports the listAll method at the moment it is not particularly useful to create a new PayCode - -$payCode = new \PhpTwinfield\PayCode; -$payCode->setCode("SEPATEST"); -$payCode->setName("SEPA Test pay code"); -$payCode->setShortName("SEPATestPayCode"); - -echo "
";
-print_r($payCode);
-echo "
"; \ No newline at end of file +if ($executeNew) { + $payCode = new \PhpTwinfield\PayCode; + $payCode->setCode("SEPATEST"); + $payCode->setName("SEPA Test pay code"); + $payCode->setShortName("SEPATestPayCode"); + + echo "
";
+    print_r($payCode);
+    echo "
"; +} \ No newline at end of file diff --git a/examples/VatGroup.php b/examples/VatGroup.php index 367dc3cc..cc621d42 100644 --- a/examples/VatGroup.php +++ b/examples/VatGroup.php @@ -17,6 +17,11 @@ * \PhpTwinfield\ApiConnectors\VatGroupApiConnector * Available methods: listAll */ + +// Run all or only some of the following examples +$executeListAllWithFilter = false; +$executeListAllWithoutFilter = true; +$executeNew = false; $vatGroupApiConnector = new \PhpTwinfield\ApiConnectors\VatGroupApiConnector($connection); @@ -38,42 +43,53 @@ */ //List all with pattern "1*", field 0 (= search code or number), firstRow 5, maxRows 10 -try { - $vatGroups = $vatGroupApiConnector->listAll("1*", 0, 5, 10); -} catch (ResponseException $e) { - $vatGroups = $e->getReturnedObject(); +if ($executeListAllWithFilter) { + try { + $vatGroups = $vatGroupApiConnector->listAll("1*", 0, 5, 10); + } catch (ResponseException $e) { + $vatGroups = $e->getReturnedObject(); + } + + echo "
";
+    print_r($vatGroups);
+    echo "
"; } //List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) -try { - $vatGroups = $vatGroupApiConnector->listAll(); -} catch (ResponseException $e) { - $vatGroups = $e->getReturnedObject(); +if ($executeListAllWithoutFilter) { + try { + $vatGroups = $vatGroupApiConnector->listAll(); + } catch (ResponseException $e) { + $vatGroups = $e->getReturnedObject(); + } + + echo "
";
+    print_r($vatGroups);
+    echo "
"; } -echo "
";
-print_r($vatGroups);
-echo "
"; - /* VatGroup * \PhpTwinfield\VatGroup * Available getters: getCode, getName, getShortName * Available setters: setCode, setName, setShortName */ -foreach ($vatGroups as $key => $vatGroup) { - echo "VatGroup {$key}
"; - echo "Code: {$vatGroup->getCode()}
"; - echo "Name: {$vatGroup->getName()}

"; +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($vatGroups as $key => $vatGroup) { + echo "VatGroup {$key}
"; + echo "Code: {$vatGroup->getCode()}
"; + echo "Name: {$vatGroup->getName()}

"; + } } // NOTE: Because the VatGroupApiConnector only supports the listAll method at the moment it is not particularly useful to create a new VatGroup - -$vatGroup = new \PhpTwinfield\VatGroup; -$vatGroup->setCode("1A"); -$vatGroup->setName("High (1a)"); -$vatGroup->setShortName("High1A"); - -echo "
";
-print_r($vatGroup);
-echo "
"; \ No newline at end of file +if ($executeNew) { + $vatGroup = new \PhpTwinfield\VatGroup; + $vatGroup->setCode("1A"); + $vatGroup->setName("High (1a)"); + $vatGroup->setShortName("High1A"); + + echo "
";
+    print_r($vatGroup);
+    echo "
"; +} \ No newline at end of file diff --git a/examples/VatGroupCountry.php b/examples/VatGroupCountry.php index 76719411..21d2c961 100644 --- a/examples/VatGroupCountry.php +++ b/examples/VatGroupCountry.php @@ -17,6 +17,11 @@ * \PhpTwinfield\ApiConnectors\VatGroupCountryApiConnector * Available methods: listAll */ + +// Run all or only some of the following examples +$executeListAllWithFilter = false; +$executeListAllWithoutFilter = true; +$executeNew = false; $vatGroupCountryApiConnector = new \PhpTwinfield\ApiConnectors\VatGroupCountryApiConnector($connection); @@ -41,44 +46,55 @@ */ //List all with pattern "*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> country = NL -$options = array('country' => 'NL'); - -try { - $vatGroupCountries = $vatGroupCountryApiConnector->listAll('*', 0, 1, 10, $options); -} catch (ResponseException $e) { - $vatGroupCountries = $e->getReturnedObject(); +if ($executeListAllWithFilter) { + $options = array('country' => 'NL'); + + try { + $vatGroupCountries = $vatGroupCountryApiConnector->listAll('*', 0, 1, 10, $options); + } catch (ResponseException $e) { + $vatGroupCountries = $e->getReturnedObject(); + } + + echo "
";
+    print_r($vatGroupCountries);
+    echo "
"; } //List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) -try { - $vatGroupCountries = $vatGroupCountryApiConnector->listAll(); -} catch (ResponseException $e) { - $vatGroupCountries = $e->getReturnedObject(); +if ($executeListAllWithoutFilter) { + try { + $vatGroupCountries = $vatGroupCountryApiConnector->listAll(); + } catch (ResponseException $e) { + $vatGroupCountries = $e->getReturnedObject(); + } + + echo "
";
+    print_r($vatGroupCountries);
+    echo "
"; } -echo "
";
-print_r($vatGroupCountries);
-echo "
"; - /* VatGroupCountry * \PhpTwinfield\VatGroupCountry * Available getters: getCode, getName, getShortName * Available setters: setCode, setName, setShortName */ -foreach ($vatGroupCountries as $key => $vatGroupCountry) { - echo "VatGroupCountry {$key}
"; - echo "Code: {$vatGroupCountry->getCode()}
"; - echo "Name: {$vatGroupCountry->getName()}

"; +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($vatGroupCountries as $key => $vatGroupCountry) { + echo "VatGroupCountry {$key}
"; + echo "Code: {$vatGroupCountry->getCode()}
"; + echo "Name: {$vatGroupCountry->getName()}

"; + } } // NOTE: Because the VatGroupCountryApiConnector only supports the listAll method at the moment it is not particularly useful to create a new VatGroupCountry - -$vatGroupCountry = new \PhpTwinfield\VatGroupCountry; -$vatGroupCountry->setCode("NL"); -$vatGroupCountry->setName("NL1A"); -$vatGroupCountry->setShortName("NL1A"); - -echo "
";
-print_r($vatGroupCountry);
-echo "
"; \ No newline at end of file +if ($executeNew) { + $vatGroupCountry = new \PhpTwinfield\VatGroupCountry; + $vatGroupCountry->setCode("NL"); + $vatGroupCountry->setName("NL1A"); + $vatGroupCountry->setShortName("NL1A"); + + echo "
";
+    print_r($vatGroupCountry);
+    echo "
"; +} \ No newline at end of file diff --git a/readme.md b/readme.md index 123d005d..cbbac42a 100644 --- a/readme.md +++ b/readme.md @@ -21,36 +21,41 @@ See [Usage](usage.md) Not all resources from the Twinfield API are currently implemented. Feel free to create a pull request when you need support for another resource. -| Component | get() | listAll() | send() | delete() | Mapper | -| --------------------------------------------------------------------------------------------------------------- | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | -| [Activities](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Activities) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| [Articles](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Articles) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| [Asset Methods](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/AssetMethods) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| [Browse Data](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Request/BrowseData) | :white_check_mark: | | | | :white_check_mark: | -| Cash and Bank books | | :white_check_mark: | | | :white_check_mark: | -| [Cost Centers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/CostCenters) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| Countries | | :white_check_mark: | | | :white_check_mark: | -| [Currencies](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Currencies) | | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| [Customers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| [Dimension Groups](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionGroups) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| [Dimension Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionTypes) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| [Electronic Bank Statements](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankStatements)| | | :white_check_mark: | | | | -| [Fixed Assets](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/FixedAssets) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| [General Ledger Accounts](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/BalanceSheets) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| [Matching](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Miscellaneous/Matching) | | | :white_check_mark: | | :white_check_mark: | -| [Offices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Offices) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | -| Paycodes | | :white_check_mark: | | | :white_check_mark: | -| [Projects](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Projects) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| [Rates](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Rates) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| [Sales Invoices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| [Sales Invoice Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | | :white_check_mark: | | | :white_check_mark: | -| [Suppliers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| Transactions:
[Purchase](https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions), [Sale](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions), [Journal](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/JournalTransactions), [Cash](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/CashTransactions), [Bank](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| [Users](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Users) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | -| User Roles | | :white_check_mark: | | | :white_check_mark: | -| [VAT](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/VAT) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| VAT Groups | | :white_check_mark: | | | :white_check_mark: | -| VAT Groups Countries | | :white_check_mark: | | | :white_check_mark: | +| Component | get() | listAll() | send() | delete() | Mapper | Example | +| --------------------------------------------------------------------------------------------------------------- | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | +| [Activities](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Activities) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Activity](examples/Activity.php) | +| [Articles](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Articles) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Articles](examples/Activity.php) | +| [Asset Methods](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/AssetMethods) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Asset Methods](examples/Activity.php) | +| [Browse Data](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Request/BrowseData) | :white_check_mark: | | | | :white_check_mark: | [Browse Data](examples/Activity.php) | +| Cash and Bank books | | :white_check_mark: | | | :white_check_mark: | [Cash and Bank books](examples/Activity.php) | +| [Cost Centers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/CostCenters) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Cost Centers](examples/Activity.php) | +| Countries | | :white_check_mark: | | | :white_check_mark: | [Countries](examples/Activity.php) | +| [Currencies](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Currencies) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Currencies](examples/Activity.php) | +| [Customers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Customers](examples/Activity.php) | +| [Dimension Groups](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionGroups) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Dimension Groups](examples/Activity.php) | +| [Dimension Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionTypes) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | [Dimension Types](examples/Activity.php) | +| [Electronic Bank Statements](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankStatements)| | | :white_check_mark: | | | | | +| [Fixed Assets](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/FixedAssets) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Fixed Assets](examples/Activity.php) | +| [General Ledger Accounts](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/BalanceSheets) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [General Ledger Accounts](examples/Activity.php) | +| [Matching](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Miscellaneous/Matching) | | | :white_check_mark: | | :white_check_mark: | | +| [Offices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Offices) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | [Offices](examples/Office.php) | +| Paycodes | | :white_check_mark: | | | :white_check_mark: | [Paycodes](examples/PayCode.php) | +| [Projects](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Projects) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Projects](examples/Project.php) | +| [Rates](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Rates) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Rates](examples/Rate.php) | +| [Sales Invoices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | [Sales Invoices](examples/Invoice.php) | +| [Sales Invoice Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | | :white_check_mark: | | | :white_check_mark: | [Sales Invoice Types](examples/InvoiceType.php) | +| [Suppliers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Suppliers](examples/Activity.php) | +| Transactions:
+[Bank](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankTransactions), +[Cash](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/CashTransactions), +[Journal](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/JournalTransactions), +[Purchase](https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions), +[Sale](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Transactions](examples/Transactions.php) | +| [Users](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Users) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | [Users](examples/Users.php) | +| User Roles | | :white_check_mark: | | | :white_check_mark: | [User Roles](examples/Activity.php) | +| [VAT](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/VAT) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [VAT](examples/VatCode.php) | +| VAT Groups | | :white_check_mark: | | | :white_check_mark: | [VAT Groups](examples/VatGroup.php) | +| VAT Group Countries | | :white_check_mark: | | | :white_check_mark: | [VAT Group Countries](examples/VatGroupCountry.php) | ## Links diff --git a/src/ApiConnectors/CurrencyApiConnector.php b/src/ApiConnectors/CurrencyApiConnector.php index 00577201..0da66233 100644 --- a/src/ApiConnectors/CurrencyApiConnector.php +++ b/src/ApiConnectors/CurrencyApiConnector.php @@ -10,6 +10,7 @@ use PhpTwinfield\Request as Request; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; +use PhpTwinfield\Response\ResponseException; use PhpTwinfield\Services\FinderService; use Webmozart\Assert\Assert; @@ -26,7 +27,8 @@ class CurrencyApiConnector extends BaseApiConnector { /** * Requests a specific Currency based off the passed in code and optionally the office. - * NOTE: The Twinfield API does not currently support reading currencies + * NOTE: The Twinfield API does not currently officially support reading currencies + * This function uses the fact that the API will return a complete object when sending an existing code with an explicit error (no name) * * @param string $code * @param Office $office If no office has been passed it will instead take the default office from the @@ -35,21 +37,22 @@ class CurrencyApiConnector extends BaseApiConnector * @throws Exception */ - /* public function get(string $code, Office $office): Currency { - // Make a request to read a single Currency. Set the required values - $request_currency = new Request\Read\Currency(); - $request_currency - ->setOffice($office->getCode()) - ->setCode($code); - - // Send the Request document and set the response to this instance. - $response = $this->sendXmlDocument($request_currency); + $currency = new Currency; + $currency->setCode($code); + $currency->setOffice($office); + + try { + $currencyResponse = $this->send($currency); + } catch (ResponseException $e) { + $currencyResponse = $e->getReturnedObject(); + $currencyResponse->setMessages(null); + $currencyResponse->setResult(1); + } - return CurrencyMapper::map($response); + return $currencyResponse; } - */ /** * Sends a Currency instance to Twinfield to update or add. @@ -126,4 +129,32 @@ public function listAll( return $this->mapListAll("Currency", $response->data, $currencyArrayListAllTags); } + + /** + * Deletes a specific Currency based off the passed in code and optionally the office. + * + * @param string $code + * @param Office $office If no office has been passed it will instead take the default office from the + * passed in config class. + * @return Currency The deleted Currency or Currency object with error message if it can't be found. + * @throws Exception + */ + public function delete(string $code, Office $office): Currency + { + $currency = self::get($code, $office); + + if ($currency->getResult() == 1) { + $currency->setStatusFromString("deleted"); + + try { + $currencyDeleted = self::send($currency); + } catch (ResponseException $e) { + $currencyDeleted = $e->getReturnedObject(); + } + + return $currencyDeleted; + } else { + return $currency; + } + } } \ No newline at end of file diff --git a/src/Currency.php b/src/Currency.php index ba76d763..682c2459 100644 --- a/src/Currency.php +++ b/src/Currency.php @@ -15,10 +15,10 @@ class Currency extends BaseObject { use CodeField; - use StatusField; use NameField; use OfficeField; use ShortNameField; + use StatusField; private $rates = []; diff --git a/src/CustomerAddress.php b/src/CustomerAddress.php index d5c5ba6c..316cbbe3 100644 --- a/src/CustomerAddress.php +++ b/src/CustomerAddress.php @@ -5,7 +5,6 @@ use PhpTwinfield\Fields\Dimensions\Level2\CityField; use PhpTwinfield\Fields\Dimensions\Level2\CountryField; use PhpTwinfield\Fields\Dimensions\Level2\DefaultField; -use PhpTwinfield\Fields\Dimensions\Level2\EmailField; use PhpTwinfield\Fields\Dimensions\Level2\Field1Field; use PhpTwinfield\Fields\Dimensions\Level2\Field2Field; use PhpTwinfield\Fields\Dimensions\Level2\Field3Field; @@ -16,6 +15,7 @@ use PhpTwinfield\Fields\Dimensions\Level2\TelefaxField; use PhpTwinfield\Fields\Dimensions\Level2\TelephoneField; use PhpTwinfield\Fields\Dimensions\Level2\TypeField; +use PhpTwinfield\Fields\EmailField; use PhpTwinfield\Fields\IDField; use PhpTwinfield\Fields\NameField; diff --git a/src/CustomerChildValidation.php b/src/CustomerChildValidation.php index b590192b..f74f303c 100644 --- a/src/CustomerChildValidation.php +++ b/src/CustomerChildValidation.php @@ -2,9 +2,9 @@ namespace PhpTwinfield; -use PhpTwinfield\Fields\Dimensions\LevelField; use PhpTwinfield\Fields\Dimensions\TypeField; use PhpTwinfield\Fields\ElementValueField; +use PhpTwinfield\Fields\LevelField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers diff --git a/src/CustomerFinancials.php b/src/CustomerFinancials.php index 154adb05..ddc45b53 100644 --- a/src/CustomerFinancials.php +++ b/src/CustomerFinancials.php @@ -11,13 +11,13 @@ use PhpTwinfield\Fields\Dimensions\Level2\PayAvailableField; use PhpTwinfield\Fields\Dimensions\Level2\PayCodeField; use PhpTwinfield\Fields\Dimensions\Level2\PayCodeIDField; -use PhpTwinfield\Fields\Dimensions\LevelField; use PhpTwinfield\Fields\Dimensions\MatchTypeField; use PhpTwinfield\Fields\Dimensions\SubAnalyseField; use PhpTwinfield\Fields\Dimensions\SubstitutionLevelField; use PhpTwinfield\Fields\Dimensions\SubstituteWithField; use PhpTwinfield\Fields\Dimensions\SubstituteWithIDField; use PhpTwinfield\Fields\Dimensions\VatCodeFixedField; +use PhpTwinfield\Fields\LevelField; use PhpTwinfield\Fields\VatCodeField; /** diff --git a/src/Enums/Culture.php b/src/Enums/Culture.php new file mode 100644 index 00000000..4e09253c --- /dev/null +++ b/src/Enums/Culture.php @@ -0,0 +1,27 @@ +acceptExtraCost; + } + + public function getAcceptExtraCostToString(): ?string + { + return ($this->getAcceptExtraCost()) ? 'true' : 'false'; + } + + /** + * @param bool $acceptExtraCost + * @return $this + */ + public function setAcceptExtraCost(?bool $acceptExtraCost): self + { + $this->acceptExtraCost = $acceptExtraCost; + return $this; + } + + /** + * @param string|null $acceptExtraCostString + * @return $this + * @throws Exception + */ + public function setAcceptExtraCostFromString(?string $acceptExtraCostString) + { + return $this->setAcceptExtraCost(filter_var($acceptExtraCostString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/User/CultureField.php b/src/Fields/User/CultureField.php new file mode 100644 index 00000000..e9665f3d --- /dev/null +++ b/src/Fields/User/CultureField.php @@ -0,0 +1,40 @@ +culture; + } + + /** + * @param Culture|null $culture + * @return $this + */ + public function setCulture(?Culture $culture): self + { + $this->culture = $culture; + return $this; + } + + /** + * @param string|null $cultureString + * @return $this + * @throws Exception + */ + public function setCultureFromString(?string $cultureString) + { + return $this->setCulture(new Culture((string)$cultureString)); + } +} \ No newline at end of file diff --git a/src/Fields/User/CultureNameField.php b/src/Fields/User/CultureNameField.php new file mode 100644 index 00000000..acf2e011 --- /dev/null +++ b/src/Fields/User/CultureNameField.php @@ -0,0 +1,31 @@ +cultureName; + } + + /** + * @param null|string $cultureName + * @return $this + */ + public function setCultureName(?string $cultureName): self + { + $this->cultureName = $cultureName; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/User/CultureNativeNameField.php b/src/Fields/User/CultureNativeNameField.php new file mode 100644 index 00000000..aa72820b --- /dev/null +++ b/src/Fields/User/CultureNativeNameField.php @@ -0,0 +1,31 @@ +cultureNativeName; + } + + /** + * @param null|string $cultureNativeName + * @return $this + */ + public function setCultureNativeName(?string $cultureNativeName): self + { + $this->cultureNativeName = $cultureNativeName; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/User/DemoField.php b/src/Fields/User/DemoField.php new file mode 100644 index 00000000..cd83d4ad --- /dev/null +++ b/src/Fields/User/DemoField.php @@ -0,0 +1,47 @@ +demo; + } + + public function getDemoToString(): ?string + { + return ($this->getDemo()) ? 'true' : 'false'; + } + + /** + * @param bool $demo + * @return $this + */ + public function setDemo(?bool $demo): self + { + $this->demo = $demo; + return $this; + } + + /** + * @param string|null $demoString + * @return $this + * @throws Exception + */ + public function setDemoFromString(?string $demoString) + { + return $this->setDemo(filter_var($demoString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/User/DemoLockedField.php b/src/Fields/User/DemoLockedField.php new file mode 100644 index 00000000..dc93f51c --- /dev/null +++ b/src/Fields/User/DemoLockedField.php @@ -0,0 +1,47 @@ +demoLocked; + } + + public function getDemoLockedToString(): ?string + { + return ($this->getDemoLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $demoLocked + * @return $this + */ + public function setDemoLocked(?bool $demoLocked): self + { + $this->demoLocked = $demoLocked; + return $this; + } + + /** + * @param string|null $demoLockedString + * @return $this + * @throws Exception + */ + public function setDemoLockedFromString(?string $demoLockedString) + { + return $this->setDemoLocked(filter_var($demoLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/User/ExchangeQuotaField.php b/src/Fields/User/ExchangeQuotaField.php new file mode 100644 index 00000000..b69eeb61 --- /dev/null +++ b/src/Fields/User/ExchangeQuotaField.php @@ -0,0 +1,32 @@ +exchangeQuota; + } + + /** + * @param null|int $exchangeQuota + * @return $this + */ + public function setExchangeQuota(?int $exchangeQuota): self + { + $this->exchangeQuota = $exchangeQuota; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/User/ExchangeQuotaLockedField.php b/src/Fields/User/ExchangeQuotaLockedField.php new file mode 100644 index 00000000..555e2c9a --- /dev/null +++ b/src/Fields/User/ExchangeQuotaLockedField.php @@ -0,0 +1,47 @@ +exchangeQuotaLocked; + } + + public function getExchangeQuotaLockedToString(): ?string + { + return ($this->getExchangeQuotaLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $exchangeQuotaLocked + * @return $this + */ + public function setExchangeQuotaLocked(?bool $exchangeQuotaLocked): self + { + $this->exchangeQuotaLocked = $exchangeQuotaLocked; + return $this; + } + + /** + * @param string|null $exchangeQuotaLockedString + * @return $this + * @throws Exception + */ + public function setExchangeQuotaLockedFromString(?string $exchangeQuotaLockedString) + { + return $this->setExchangeQuotaLocked(filter_var($exchangeQuotaLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/User/FileManagerQuotaField.php b/src/Fields/User/FileManagerQuotaField.php new file mode 100644 index 00000000..84dd2e07 --- /dev/null +++ b/src/Fields/User/FileManagerQuotaField.php @@ -0,0 +1,32 @@ +fileManagerQuota; + } + + /** + * @param null|int $fileManagerQuota + * @return $this + */ + public function setFileManagerQuota(?int $fileManagerQuota): self + { + $this->fileManagerQuota = $fileManagerQuota; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/User/FileManagerQuotaLockedField.php b/src/Fields/User/FileManagerQuotaLockedField.php new file mode 100644 index 00000000..9415787e --- /dev/null +++ b/src/Fields/User/FileManagerQuotaLockedField.php @@ -0,0 +1,47 @@ +fileManagerQuotaLocked; + } + + public function getFileManagerQuotaLockedToString(): ?string + { + return ($this->getFileManagerQuotaLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $fileManagerQuotaLocked + * @return $this + */ + public function setFileManagerQuotaLocked(?bool $fileManagerQuotaLocked): self + { + $this->fileManagerQuotaLocked = $fileManagerQuotaLocked; + return $this; + } + + /** + * @param string|null $fileManagerQuotaLockedString + * @return $this + * @throws Exception + */ + public function setFileManagerQuotaLockedFromString(?string $fileManagerQuotaLockedString) + { + return $this->setFileManagerQuotaLocked(filter_var($fileManagerQuotaLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/User/PasswordField.php b/src/Fields/User/PasswordField.php new file mode 100644 index 00000000..19af96a8 --- /dev/null +++ b/src/Fields/User/PasswordField.php @@ -0,0 +1,31 @@ +password; + } + + /** + * @param null|string $password + * @return $this + */ + public function setPassword(?string $password): self + { + $this->password = $password; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/User/TypeField.php b/src/Fields/User/TypeField.php new file mode 100644 index 00000000..46663929 --- /dev/null +++ b/src/Fields/User/TypeField.php @@ -0,0 +1,40 @@ +type; + } + + /** + * @param UserType|null $type + * @return $this + */ + public function setType(?UserType $type): self + { + $this->type = $type; + return $this; + } + + /** + * @param string|null $typeString + * @return $this + * @throws Exception + */ + public function setTypeFromString(?string $typeString) + { + return $this->setType(new UserType((string)$typeString)); + } +} \ No newline at end of file diff --git a/src/Fields/User/TypeLockedField.php b/src/Fields/User/TypeLockedField.php new file mode 100644 index 00000000..0ed2829c --- /dev/null +++ b/src/Fields/User/TypeLockedField.php @@ -0,0 +1,47 @@ +typeLocked; + } + + public function getTypeLockedToString(): ?string + { + return ($this->getTypeLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $typeLocked + * @return $this + */ + public function setTypeLocked(?bool $typeLocked): self + { + $this->typeLocked = $typeLocked; + return $this; + } + + /** + * @param string|null $typeLockedString + * @return $this + * @throws Exception + */ + public function setTypeLockedFromString(?string $typeLockedString) + { + return $this->setTypeLocked(filter_var($typeLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/FixedAssetFinancials.php b/src/FixedAssetFinancials.php index 211f52f3..d6131d4a 100644 --- a/src/FixedAssetFinancials.php +++ b/src/FixedAssetFinancials.php @@ -3,13 +3,13 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\Dimensions\AccountTypeField; -use PhpTwinfield\Fields\Dimensions\LevelField; use PhpTwinfield\Fields\Dimensions\MatchTypeField; use PhpTwinfield\Fields\Dimensions\SubAnalyseField; use PhpTwinfield\Fields\Dimensions\SubstitutionLevelField; use PhpTwinfield\Fields\Dimensions\SubstituteWithField; use PhpTwinfield\Fields\Dimensions\SubstituteWithIDField; use PhpTwinfield\Fields\Dimensions\VatCodeFixedField; +use PhpTwinfield\Fields\LevelField; use PhpTwinfield\Fields\VatCodeField; /** diff --git a/src/GeneralLedgerChildValidation.php b/src/GeneralLedgerChildValidation.php index 80535bc4..cab9ba4c 100644 --- a/src/GeneralLedgerChildValidation.php +++ b/src/GeneralLedgerChildValidation.php @@ -2,9 +2,9 @@ namespace PhpTwinfield; -use PhpTwinfield\Fields\Dimensions\LevelField; use PhpTwinfield\Fields\Dimensions\TypeField; use PhpTwinfield\Fields\ElementValueField; +use PhpTwinfield\Fields\LevelField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/BalanceSheets diff --git a/src/GeneralLedgerFinancials.php b/src/GeneralLedgerFinancials.php index ca6e3e2e..23837e70 100644 --- a/src/GeneralLedgerFinancials.php +++ b/src/GeneralLedgerFinancials.php @@ -3,10 +3,10 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\Dimensions\AccountTypeField; -use PhpTwinfield\Fields\Dimensions\LevelField; use PhpTwinfield\Fields\Dimensions\MatchTypeField; use PhpTwinfield\Fields\Dimensions\SubAnalyseField; use PhpTwinfield\Fields\Dimensions\VatCodeFixedField; +use PhpTwinfield\Fields\LevelField; use PhpTwinfield\Fields\VatCodeField; /** diff --git a/src/Mappers/InvoiceTypeMapper.php b/src/Mappers/InvoiceTypeMapper.php index 51706339..648bcd8e 100644 --- a/src/Mappers/InvoiceTypeMapper.php +++ b/src/Mappers/InvoiceTypeMapper.php @@ -34,7 +34,7 @@ public static function map(Response $response) // Get the root/invoice type element $invoiceTypeElement = $responseDOM->documentElement; - // Set the vat group elements from the vat group element + // Set the invoice type elements from the invoice type element $invoiceType->setCode(self::getField($invoiceType, $invoiceTypeElement, 'code')) ->setName(self::getField($invoiceType, $invoiceTypeElement, 'name')) ->setShortName(self::getField($invoiceType, $invoiceTypeElement, 'shortname')); diff --git a/src/Mappers/PayCodeMapper.php b/src/Mappers/PayCodeMapper.php index 041e2e13..f56f9124 100644 --- a/src/Mappers/PayCodeMapper.php +++ b/src/Mappers/PayCodeMapper.php @@ -31,10 +31,10 @@ public static function map(Response $response) // Gets the raw DOMDocument response. $responseDOM = $response->getResponseDocument(); - // Get the root/vat group element + // Get the root/paycode element $payCodeElement = $responseDOM->documentElement; - // Set the vat group elements from the vat group element + // Set the paycode elements from the paycode element $payCode->setCode(self::getField($payCode, $payCodeElement, 'code')) ->setName(self::getField($payCode, $payCodeElement, 'name')) ->setShortName(self::getField($payCode, $payCodeElement, 'shortname')); diff --git a/src/SupplierAddress.php b/src/SupplierAddress.php index aa462f25..8202089f 100644 --- a/src/SupplierAddress.php +++ b/src/SupplierAddress.php @@ -5,7 +5,6 @@ use PhpTwinfield\Fields\Dimensions\Level2\CityField; use PhpTwinfield\Fields\Dimensions\Level2\CountryField; use PhpTwinfield\Fields\Dimensions\Level2\DefaultField; -use PhpTwinfield\Fields\Dimensions\Level2\EmailField; use PhpTwinfield\Fields\Dimensions\Level2\Field1Field; use PhpTwinfield\Fields\Dimensions\Level2\Field2Field; use PhpTwinfield\Fields\Dimensions\Level2\Field3Field; @@ -16,6 +15,7 @@ use PhpTwinfield\Fields\Dimensions\Level2\TelefaxField; use PhpTwinfield\Fields\Dimensions\Level2\TelephoneField; use PhpTwinfield\Fields\Dimensions\Level2\TypeField; +use PhpTwinfield\Fields\EmailField; use PhpTwinfield\Fields\IDField; use PhpTwinfield\Fields\NameField; diff --git a/src/SupplierChildValidation.php b/src/SupplierChildValidation.php index 2f03775e..69dd5377 100644 --- a/src/SupplierChildValidation.php +++ b/src/SupplierChildValidation.php @@ -2,9 +2,9 @@ namespace PhpTwinfield; -use PhpTwinfield\Fields\Dimensions\LevelField; use PhpTwinfield\Fields\Dimensions\TypeField; use PhpTwinfield\Fields\ElementValueField; +use PhpTwinfield\Fields\LevelField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers diff --git a/src/SupplierFinancials.php b/src/SupplierFinancials.php index 3f248dec..d583a00b 100644 --- a/src/SupplierFinancials.php +++ b/src/SupplierFinancials.php @@ -9,13 +9,13 @@ use PhpTwinfield\Fields\Dimensions\Level2\PayAvailableField; use PhpTwinfield\Fields\Dimensions\Level2\PayCodeField; use PhpTwinfield\Fields\Dimensions\Level2\PayCodeIDField; -use PhpTwinfield\Fields\Dimensions\LevelField; use PhpTwinfield\Fields\Dimensions\MatchTypeField; use PhpTwinfield\Fields\Dimensions\SubAnalyseField; use PhpTwinfield\Fields\Dimensions\SubstitutionLevelField; use PhpTwinfield\Fields\Dimensions\SubstituteWithField; use PhpTwinfield\Fields\Dimensions\SubstituteWithIDField; use PhpTwinfield\Fields\Dimensions\VatCodeFixedField; +use PhpTwinfield\Fields\LevelField; use PhpTwinfield\Fields\VatCodeField; /** diff --git a/src/User.php b/src/User.php index ac49c8a6..7564261e 100644 --- a/src/User.php +++ b/src/User.php @@ -4,23 +4,51 @@ use PhpTwinfield\Fields\CodeField; use PhpTwinfield\Fields\CreatedField; +use PhpTwinfield\Fields\EmailField; use PhpTwinfield\Fields\ModifiedField; use PhpTwinfield\Fields\NameField; use PhpTwinfield\Fields\ShortNameField; use PhpTwinfield\Fields\StatusField; use PhpTwinfield\Fields\TouchedField; +use PhpTwinfield\Fields\User\AcceptExtraCostField; +use PhpTwinfield\Fields\User\CultureField; +use PhpTwinfield\Fields\User\CultureNameField; +use PhpTwinfield\Fields\User\CultureNativeNameField; +use PhpTwinfield\Fields\User\DemoField; +use PhpTwinfield\Fields\User\DemoLockedField; +use PhpTwinfield\Fields\User\ExchangeQuotaField; +use PhpTwinfield\Fields\User\ExchangeQuotaLockedField; +use PhpTwinfield\Fields\User\FileManagerQuotaField; +use PhpTwinfield\Fields\User\FileManagerQuotaLockedField; use PhpTwinfield\Fields\User\IsCurrentUserField; use PhpTwinfield\Fields\User\LevelField; +use PhpTwinfield\Fields\User\PasswordField; +use PhpTwinfield\Fields\User\TypeField; +use PhpTwinfield\Fields\User\TypeLockedField; class User extends BaseObject { + use AcceptExtraCostField; use CodeField; use CreatedField; + use CultureField; + use CultureNameField; + use CultureNativeNameField; + use DemoField; + use DemoLockedField; + use EmailField; + use ExchangeQuotaField; + use ExchangeQuotaLockedField; + use FileManagerQuotaField; + use FileManagerQuotaLockedField; use IsCurrentUserField; use LevelField; use ModifiedField; use NameField; + use PasswordField; use ShortNameField; use StatusField; use TouchedField; + use TypeField; + use TypeLockedField; } diff --git a/src/UserRole.php b/src/UserRole.php index 2abb2868..d755c53b 100644 --- a/src/UserRole.php +++ b/src/UserRole.php @@ -3,6 +3,7 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\CodeField; +use PhpTwinfield\Fields\LevelField; use PhpTwinfield\Fields\NameField; use PhpTwinfield\Fields\ShortNameField; From ab8485a0199a13243eca38d14606469556b7366c Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 15 May 2019 10:22:46 +0200 Subject: [PATCH 213/388] Upload --- readme.md | 70 +++++++++++++------------- src/ApiConnectors/UserApiConnector.php | 43 ---------------- src/DomDocuments/UsersDocument.php | 49 ------------------ src/Fields/CreatedField.php | 2 +- src/Fields/ModifiedField.php | 2 +- src/Fields/TouchedField.php | 2 +- src/Fields/User/RoleField.php | 55 ++++++++++++++++++++ src/Fields/User/RoleLockedField.php | 47 +++++++++++++++++ src/Fields/UserField.php | 2 +- src/Mappers/OfficeMapper.php | 7 ++- src/Mappers/UserMapper.php | 21 +++++++- src/Office.php | 8 +++ src/User.php | 4 ++ 13 files changed, 178 insertions(+), 134 deletions(-) delete mode 100644 src/DomDocuments/UsersDocument.php create mode 100644 src/Fields/User/RoleField.php create mode 100644 src/Fields/User/RoleLockedField.php diff --git a/readme.md b/readme.md index cbbac42a..88acd033 100644 --- a/readme.md +++ b/readme.md @@ -21,41 +21,41 @@ See [Usage](usage.md) Not all resources from the Twinfield API are currently implemented. Feel free to create a pull request when you need support for another resource. -| Component | get() | listAll() | send() | delete() | Mapper | Example | -| --------------------------------------------------------------------------------------------------------------- | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | -| [Activities](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Activities) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Activity](examples/Activity.php) | -| [Articles](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Articles) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Articles](examples/Activity.php) | -| [Asset Methods](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/AssetMethods) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Asset Methods](examples/Activity.php) | -| [Browse Data](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Request/BrowseData) | :white_check_mark: | | | | :white_check_mark: | [Browse Data](examples/Activity.php) | -| Cash and Bank books | | :white_check_mark: | | | :white_check_mark: | [Cash and Bank books](examples/Activity.php) | -| [Cost Centers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/CostCenters) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Cost Centers](examples/Activity.php) | -| Countries | | :white_check_mark: | | | :white_check_mark: | [Countries](examples/Activity.php) | -| [Currencies](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Currencies) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Currencies](examples/Activity.php) | -| [Customers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Customers](examples/Activity.php) | -| [Dimension Groups](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionGroups) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Dimension Groups](examples/Activity.php) | -| [Dimension Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionTypes) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | [Dimension Types](examples/Activity.php) | -| [Electronic Bank Statements](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankStatements)| | | :white_check_mark: | | | | | -| [Fixed Assets](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/FixedAssets) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Fixed Assets](examples/Activity.php) | -| [General Ledger Accounts](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/BalanceSheets) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [General Ledger Accounts](examples/Activity.php) | -| [Matching](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Miscellaneous/Matching) | | | :white_check_mark: | | :white_check_mark: | | -| [Offices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Offices) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | [Offices](examples/Office.php) | -| Paycodes | | :white_check_mark: | | | :white_check_mark: | [Paycodes](examples/PayCode.php) | -| [Projects](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Projects) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Projects](examples/Project.php) | -| [Rates](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Rates) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Rates](examples/Rate.php) | -| [Sales Invoices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | [Sales Invoices](examples/Invoice.php) | -| [Sales Invoice Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | | :white_check_mark: | | | :white_check_mark: | [Sales Invoice Types](examples/InvoiceType.php) | -| [Suppliers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Suppliers](examples/Activity.php) | -| Transactions:
-[Bank](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankTransactions), -[Cash](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/CashTransactions), -[Journal](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/JournalTransactions), -[Purchase](https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions), -[Sale](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Transactions](examples/Transactions.php) | -| [Users](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Users) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | [Users](examples/Users.php) | -| User Roles | | :white_check_mark: | | | :white_check_mark: | [User Roles](examples/Activity.php) | -| [VAT](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/VAT) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [VAT](examples/VatCode.php) | -| VAT Groups | | :white_check_mark: | | | :white_check_mark: | [VAT Groups](examples/VatGroup.php) | -| VAT Group Countries | | :white_check_mark: | | | :white_check_mark: | [VAT Group Countries](examples/VatGroupCountry.php) | +| Component | get() | listAll() | send() | delete() | Mapper | Example | +| --------------------------------------------------------------------------------------------------------------- | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | +| [Activities](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Activities) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Activity](examples/Activity.php) | +| [Articles](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Articles) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Article](examples/Article.php) | +| [Asset Methods](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/AssetMethods) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Asset Method](examples/AssetMethod.php) | +| [Browse Data](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Request/BrowseData) | :white_check_mark: | | | | :white_check_mark: | [Browse Data](examples/BrowseData.php) | +| Cash and Bank Books | | :white_check_mark: | | | :white_check_mark: | [Cash and Bank Book](examples/CashBankBook.php) | +| [Cost Centers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/CostCenters) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Cost Center](examples/CostCenter.php) | +| Countries | | :white_check_mark: | | | :white_check_mark: | [Country](examples/Country.php) | +| [Currencies](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Currencies) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Currency](examples/Currency.php) | +| [Customers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Customer](examples/Customer.php) | +| [Dimension Groups](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionGroups) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Dimension Group](examples/DimensionGroup.php) | +| [Dimension Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionTypes) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | [Dimension Type](examples/DimensionType.php) | +| [Electronic Bank Statements](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankStatements)| | | :white_check_mark: | | | | | +| [Fixed Assets](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/FixedAssets) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Fixed Asset](examples/FixedAsset.php) | +| [General Ledger Accounts](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/BalanceSheets) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [General Ledger Account](examples/GeneralLedger.php) | +| [Matching](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Miscellaneous/Matching) | | | :white_check_mark: | | :white_check_mark: | | +| [Offices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Offices) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | [Office](examples/Office.php) | +| Paycodes | | :white_check_mark: | | | :white_check_mark: | [Paycode](examples/PayCode.php) | +| [Projects](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Projects) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Project](examples/Project.php) | +| [Rates](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Rates) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Rate](examples/Rate.php) | +| [Sales Invoices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | [Sales Invoice](examples/Invoice.php) | +| [Sales Invoice Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | | :white_check_mark: | | | :white_check_mark: | [Sales Invoice Type](examples/InvoiceType.php) | +| [Suppliers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Supplier](examples/Supplier.php) | +| Transactions: +[Bank](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Bank Transaction](examples/BankTransaction.php) | +[Cash](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/CashTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Cash Transaction](examples/CashTransaction.php) | +[Journal](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/JournalTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Journal Transaction](examples/JournalTransaction.php) | +[Purchase](https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Purchase Transaction](examples/PurchaseTransaction.php) | +[Sale](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Sale Transaction](examples/SaleTransaction.php) | +| [Users](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Users) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | [User](examples/User.php) | +| User Roles | | :white_check_mark: | | | :white_check_mark: | [User Role](examples/UserRole.php) | +| [VAT](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/VAT) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [VAT](examples/VatCode.php) | +| VAT Groups | | :white_check_mark: | | | :white_check_mark: | [VAT Group](examples/VatGroup.php) | +| VAT Group Countries | | :white_check_mark: | | | :white_check_mark: | [VAT Group Country](examples/VatGroupCountry.php) | ## Links diff --git a/src/ApiConnectors/UserApiConnector.php b/src/ApiConnectors/UserApiConnector.php index 30bd271f..71cd2dc3 100644 --- a/src/ApiConnectors/UserApiConnector.php +++ b/src/ApiConnectors/UserApiConnector.php @@ -2,7 +2,6 @@ namespace PhpTwinfield\ApiConnectors; -use PhpTwinfield\DomDocuments\UsersDocument; use PhpTwinfield\Exception; use PhpTwinfield\Mappers\UserMapper; use PhpTwinfield\Office; @@ -53,48 +52,6 @@ public function get(string $code, Office $office): User return UserMapper::map($response); } - /** - * Sends a User instance to Twinfield to update or add. - * - * @param User $user - * @return User - * @throws Exception - */ - public function send(User $user): User - { - foreach($this->sendAll([$user]) as $each) { - return $each->unwrap(); - } - } - - /** - * @param User[] $users - * @return MappedResponseCollection - * @throws Exception - */ - public function sendAll(array $users): MappedResponseCollection - { - Assert::allIsInstanceOf($users, User::class); - - /** @var Response[] $responses */ - $responses = []; - - foreach ($this->getProcessXmlService()->chunk($users) as $chunk) { - - $usersDocument = new UsersDocument(); - - foreach ($chunk as $user) { - $usersDocument->addUser($user); - } - - $responses[] = $this->sendXmlDocument($usersDocument); - } - - return $this->getProcessXmlService()->mapAll($responses, "user", function(Response $response): User { - return UserMapper::map($response); - }); - } - /** * List all users. * diff --git a/src/DomDocuments/UsersDocument.php b/src/DomDocuments/UsersDocument.php deleted file mode 100644 index 99c6ff97..00000000 --- a/src/DomDocuments/UsersDocument.php +++ /dev/null @@ -1,49 +0,0 @@ - - */ -class UsersDocument extends BaseDocument -{ - final protected function getRootTagName(): string - { - return "users"; - } - - /** - * Turns a passed User class into the required markup for interacting - * with Twinfield. - * - * This method doesn't return anything, instead just adds the User to - * this DOMDOcument instance for submission usage. - * - * @access public - * @param User $user - * @return void | [Adds to this instance] - */ - public function addUser(User $user) - { - $userElement = $this->createElement('user'); - $this->rootElement->appendChild($userElement); - - $status = $user->getStatus(); - - if (!empty($status)) { - $userElement->setAttribute('status', $status); - } - - $userElement->appendChild($this->createNodeWithTextContent('code', $user->getCode())); - $userElement->appendChild($this->createNodeWithTextContent('name', $user->getName())); - $userElement->appendChild($this->createNodeWithTextContent('shortname', $user->getShortName())); - } -} diff --git a/src/Fields/CreatedField.php b/src/Fields/CreatedField.php index ee7fe59c..71ce8d97 100644 --- a/src/Fields/CreatedField.php +++ b/src/Fields/CreatedField.php @@ -7,7 +7,7 @@ /** * Created field - * Used by: AssetMethod, User, VatCode, VatCodePercentage + * Used by: AssetMethod, Office, User, VatCode, VatCodePercentage * * @package PhpTwinfield\Traits * @see Util::formatDateTime() diff --git a/src/Fields/ModifiedField.php b/src/Fields/ModifiedField.php index e52ab189..cc4761b4 100644 --- a/src/Fields/ModifiedField.php +++ b/src/Fields/ModifiedField.php @@ -7,7 +7,7 @@ /** * Modified field - * Used by: AssetMethod, User, VatCode + * Used by: AssetMethod, Office, User, VatCode * * @package PhpTwinfield\Traits * @see Util::formatDateTime() diff --git a/src/Fields/TouchedField.php b/src/Fields/TouchedField.php index 25baa093..c7109adb 100644 --- a/src/Fields/TouchedField.php +++ b/src/Fields/TouchedField.php @@ -6,7 +6,7 @@ trait TouchedField { /** * Touched field - * Used by: Activity, AssetMethod, CostCenter, Customer, FixedAsset, GeneralLedger, Project, Supplier, User, VatCode + * Used by: Activity, AssetMethod, CostCenter, Customer, FixedAsset, GeneralLedger, Office, Project, Supplier, User, VatCode * * @var int|null */ diff --git a/src/Fields/User/RoleField.php b/src/Fields/User/RoleField.php new file mode 100644 index 00000000..8f665a88 --- /dev/null +++ b/src/Fields/User/RoleField.php @@ -0,0 +1,55 @@ +role; + } + + public function getRoleToString(): ?string + { + if ($this->getRole() != null) { + return $this->role->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setRole(?UserRole $role): self + { + $this->role = $role; + return $this; + } + + /** + * @param string|null $roleCode + * @return $this + * @throws Exception + */ + public function setRoleFromString(?string $roleCode) + { + $role = new UserRole(); + $role->setCode($roleCode); + return $this->setRole($role); + } +} + diff --git a/src/Fields/User/RoleLockedField.php b/src/Fields/User/RoleLockedField.php new file mode 100644 index 00000000..5d28e0bb --- /dev/null +++ b/src/Fields/User/RoleLockedField.php @@ -0,0 +1,47 @@ +roleLocked; + } + + public function getRoleLockedToString(): ?string + { + return ($this->getRoleLocked()) ? 'true' : 'false'; + } + + /** + * @param bool $roleLocked + * @return $this + */ + public function setRoleLocked(?bool $roleLocked): self + { + $this->roleLocked = $roleLocked; + return $this; + } + + /** + * @param string|null $roleLockedString + * @return $this + * @throws Exception + */ + public function setRoleLockedFromString(?string $roleLockedString) + { + return $this->setRoleLocked(filter_var($roleLockedString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/UserField.php b/src/Fields/UserField.php index e0fddfc8..95d13cbd 100644 --- a/src/Fields/UserField.php +++ b/src/Fields/UserField.php @@ -6,7 +6,7 @@ /** * The user - * Used by: AssetMethod, Rate, VatCode, VatCodePercentage + * Used by: AssetMethod, Office, Rate, VatCode, VatCodePercentage * * @package PhpTwinfield\Traits */ diff --git a/src/Mappers/OfficeMapper.php b/src/Mappers/OfficeMapper.php index c9d40c01..aff5b756 100644 --- a/src/Mappers/OfficeMapper.php +++ b/src/Mappers/OfficeMapper.php @@ -40,7 +40,12 @@ public static function map(Response $response) // Set the office elements from the office element $office->setCode(self::getField($office, $officeElement, 'code')) - ->setName(self::getField($office, $officeElement, 'name')); + ->setCreated(self::parseDateTimeAttribute(self::getField($office, $officeElement, 'created'))) + ->setModified(self::parseDateTimeAttribute(self::getField($office, $officeElement, 'modified'))) + ->setName(self::getField($office, $officeElement, 'name')) + ->setShortName(self::getField($office, $officeElement, 'shortname')) + ->setTouched(self::getField($office, $officeElement, 'touched')) + ->setUser(self::parseObjectAttribute('User', $office, $officeElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); // Return the complete object return $office; diff --git a/src/Mappers/UserMapper.php b/src/Mappers/UserMapper.php index ee9f316e..2095f76f 100644 --- a/src/Mappers/UserMapper.php +++ b/src/Mappers/UserMapper.php @@ -43,12 +43,29 @@ public static function map(Response $response) $user->setStatus(self::parseEnumAttribute('Status', $userElement->getAttribute('status'))); // Set the user elements from the user element - $user->setCode(self::getField($user, $userElement, 'code')) + $user->setAcceptExtraCostField(self::parseBooleanAttribute(self::getField($user, $userElement, 'acceptextracost'))) + ->setCulture(self::getField($user, $userElement, 'culture')) + ->setCode(self::getField($user, $userElement, 'code')) ->setCreated(self::parseDateTimeAttribute(self::getField($user, $userElement, 'created'))) + ->setDemo(self::parseBooleanAttribute(self::getField($user, $userElement, 'demo'))) + ->setEmail(self::getField($user, $userElement, 'email')) + ->setExchangeQuota(self::getField($user, $userElement, 'exchangequota')) + ->setFileManagerQuota(self::getField($user, $userElement, 'filemanagerquota')) ->setModified(self::parseDateTimeAttribute(self::getField($user, $userElement, 'modified'))) ->setName(self::getField($user, $userElement, 'name')) + ->setRole(self::parseObjectAttribute('UserRole', $user, $userElement, 'method', array('level' => 'setLevel', 'name' => 'setName', 'shortname' => 'setShortName'))) ->setShortName(self::getField($user, $userElement, 'shortname')) - ->setTouched(self::getField($user, $userElement, 'touched')); + ->setTouched(self::getField($user, $userElement, 'touched')) + ->setType(self::parseEnumAttribute('UserType', self::getField($user, $userElement, 'type'))); + + // Set the user elements from the user element attributes + $user->setCultureName(self::getAttribute($userElement, 'culture', 'name')) + ->setCultureNativeName(self::getAttribute($userElement, 'culture', 'nativename')) + ->setDemoLocked(self::getAttribute($userElement, 'demo', 'locked')) + ->setExchangeQuotaLocked(self::getAttribute($userElement, 'exchangequota', 'locked')) + ->setFileManagerQuotaLocked(self::getAttribute($userElement, 'filemanagerquota', 'locked')) + ->setRoleLocked(self::getAttribute($userElement, 'role', 'locked')) + ->setTypeLocked(self::getAttribute($userElement, 'type', 'locked')); // Return the complete object return $user; diff --git a/src/Office.php b/src/Office.php index a0c7d8b0..c8839810 100644 --- a/src/Office.php +++ b/src/Office.php @@ -3,20 +3,28 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\CodeField; +use PhpTwinfield\Fields\CreatedField; +use PhpTwinfield\Fields\ModifiedField; use PhpTwinfield\Fields\NameField; use PhpTwinfield\Fields\Office\CountryCodeField; use PhpTwinfield\Fields\Office\VatFirstQuarterStartsInField; use PhpTwinfield\Fields\Office\VatPeriodField; use PhpTwinfield\Fields\ShortNameField; use PhpTwinfield\Fields\StatusField; +use PhpTwinfield\Fields\TouchedField; +use PhpTwinfield\Fields\UserField; class Office extends BaseObject { use CodeField; use CountryCodeField; + use CreatedField; + use ModifiedField; use NameField; use ShortNameField; use StatusField; + use TouchedField; + use UserField; use VatFirstQuarterStartsInField; use VatPeriodField; diff --git a/src/User.php b/src/User.php index 7564261e..5b1597ea 100644 --- a/src/User.php +++ b/src/User.php @@ -23,6 +23,8 @@ use PhpTwinfield\Fields\User\IsCurrentUserField; use PhpTwinfield\Fields\User\LevelField; use PhpTwinfield\Fields\User\PasswordField; +use PhpTwinfield\Fields\User\RoleField; +use PhpTwinfield\Fields\User\RoleLockedField; use PhpTwinfield\Fields\User\TypeField; use PhpTwinfield\Fields\User\TypeLockedField; @@ -46,6 +48,8 @@ class User extends BaseObject use ModifiedField; use NameField; use PasswordField; + use RoleField; + use RoleLockedField; use ShortNameField; use StatusField; use TouchedField; From f6360722f1d8ecd0eb5730597201a69f92c8ba72 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 15 May 2019 10:32:00 +0200 Subject: [PATCH 214/388] Update readme.md --- readme.md | 79 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 36 deletions(-) diff --git a/readme.md b/readme.md index 88acd033..fc33f553 100644 --- a/readme.md +++ b/readme.md @@ -2,7 +2,7 @@ A PHP library for Twinfield Integration. Use the Twinfield SOAP Services to have your PHP application communicate directly with your Twinfield account. -**:warning: Note that this libary is *not* created or mainained by Twinfield. You can only get support on the code in this library here. For any questions related to your Twinfield administration or how to do certain things with the Twinfield API, contact your Twinfield account manager.** +**:warning: Note that this libary is *not* created or maintained by Twinfield. You can only get support on the code in this library here. For any questions related to your Twinfield administration or how to do certain things with the Twinfield API, contact your Twinfield account manager.** ## Installation @@ -12,6 +12,11 @@ Install this Twinfield PHP library with Composer: composer require 'php-twinfield/twinfield:^2.0' ``` +Considering session login is deprecated and OAuth 2 is the preferred login method you should also install PHP League's OAuth 2.0 Client + +```bash +composer require 'league/oauth2-client' +``` ## Usage @@ -21,41 +26,43 @@ See [Usage](usage.md) Not all resources from the Twinfield API are currently implemented. Feel free to create a pull request when you need support for another resource. -| Component | get() | listAll() | send() | delete() | Mapper | Example | -| --------------------------------------------------------------------------------------------------------------- | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | -| [Activities](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Activities) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Activity](examples/Activity.php) | -| [Articles](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Articles) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Article](examples/Article.php) | -| [Asset Methods](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/AssetMethods) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Asset Method](examples/AssetMethod.php) | -| [Browse Data](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Request/BrowseData) | :white_check_mark: | | | | :white_check_mark: | [Browse Data](examples/BrowseData.php) | -| Cash and Bank Books | | :white_check_mark: | | | :white_check_mark: | [Cash and Bank Book](examples/CashBankBook.php) | -| [Cost Centers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/CostCenters) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Cost Center](examples/CostCenter.php) | -| Countries | | :white_check_mark: | | | :white_check_mark: | [Country](examples/Country.php) | -| [Currencies](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Currencies) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Currency](examples/Currency.php) | -| [Customers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Customer](examples/Customer.php) | -| [Dimension Groups](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionGroups) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Dimension Group](examples/DimensionGroup.php) | -| [Dimension Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionTypes) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | [Dimension Type](examples/DimensionType.php) | -| [Electronic Bank Statements](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankStatements)| | | :white_check_mark: | | | | | -| [Fixed Assets](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/FixedAssets) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Fixed Asset](examples/FixedAsset.php) | -| [General Ledger Accounts](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/BalanceSheets) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [General Ledger Account](examples/GeneralLedger.php) | -| [Matching](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Miscellaneous/Matching) | | | :white_check_mark: | | :white_check_mark: | | -| [Offices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Offices) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | [Office](examples/Office.php) | -| Paycodes | | :white_check_mark: | | | :white_check_mark: | [Paycode](examples/PayCode.php) | -| [Projects](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Projects) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Project](examples/Project.php) | -| [Rates](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Rates) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Rate](examples/Rate.php) | -| [Sales Invoices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | [Sales Invoice](examples/Invoice.php) | -| [Sales Invoice Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | | :white_check_mark: | | | :white_check_mark: | [Sales Invoice Type](examples/InvoiceType.php) | -| [Suppliers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Supplier](examples/Supplier.php) | -| Transactions: -[Bank](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Bank Transaction](examples/BankTransaction.php) | -[Cash](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/CashTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Cash Transaction](examples/CashTransaction.php) | -[Journal](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/JournalTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Journal Transaction](examples/JournalTransaction.php) | -[Purchase](https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Purchase Transaction](examples/PurchaseTransaction.php) | -[Sale](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Sale Transaction](examples/SaleTransaction.php) | -| [Users](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Users) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | [User](examples/User.php) | -| User Roles | | :white_check_mark: | | | :white_check_mark: | [User Role](examples/UserRole.php) | -| [VAT](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/VAT) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [VAT](examples/VatCode.php) | -| VAT Groups | | :white_check_mark: | | | :white_check_mark: | [VAT Group](examples/VatGroup.php) | -| VAT Group Countries | | :white_check_mark: | | | :white_check_mark: | [VAT Group Country](examples/VatGroupCountry.php) | +| Component | get() | listAll() | send() | delete() | Mapper | Example | +| ----------------------------------------------------------------------------------------------------------------------------------| :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | :----------------: | +| [Activities](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Activities) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Activity](examples/Activity.php) | +| [Articles](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Articles) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Article](examples/Article.php) | +| [Asset Methods](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/AssetMethods) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Asset Method](examples/AssetMethod.php) | +| [Browse Data](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Request/BrowseData) | :white_check_mark: | | | | :white_check_mark: | [Browse Data](examples/BrowseData.php) | +| Cash and Bank Books | | :white_check_mark: | | | :white_check_mark: | [Cash and Bank Book](examples/CashBankBook.php) | +| [Cost Centers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/CostCenters) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Cost Center](examples/CostCenter.php) | +| Countries | | :white_check_mark: | | | :white_check_mark: | [Country](examples/Country.php) | +| [Currencies](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Currencies) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Currency](examples/Currency.php) | +| [Customers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Customer](examples/Customer.php) | +| [Dimension Groups](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionGroups) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Dimension Group](examples/DimensionGroup.php) | +| [Dimension Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionTypes) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | [Dimension Type](examples/DimensionType.php) | +| [Electronic Bank Statements](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankStatements) | | :white_check_mark: | | | | | +| [Fixed Assets](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/FixedAssets) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Fixed Asset](examples/FixedAsset.php) | +| [General Ledger Accounts](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/BalanceSheets) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [General Ledger Account](examples/GeneralLedger.php) | +| [Matching](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Miscellaneous/Matching) | | | :white_check_mark: | | :white_check_mark: | | +| [Offices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Offices) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | [Office](examples/Office.php) | +| Paycodes | | :white_check_mark: | | | :white_check_mark: | [Paycode](examples/PayCode.php) | +| [Projects](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Projects) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Project](examples/Project.php) | +| [Rates](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Rates) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Rate](examples/Rate.php) | +| [Sales Invoices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | [Sales Invoice](examples/Invoice.php) | +| [Sales Invoice Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | | :white_check_mark: | | | :white_check_mark: | [Sales Invoice Type](examples/InvoiceType.php) | +| [Suppliers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Supplier](examples/Supplier.php) | +| | | | | | | | +| Transactions | | | | | | | +[Bank Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Bank Transaction](examples/BankTransaction.php) | +[Cash Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/CashTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Cash Transaction](examples/CashTransaction.php) | +[Journal Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/JournalTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Journal Transaction](examples/JournalTransaction.php) | +[Purchase Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Purchase Transaction](examples/PurchaseTransaction.php) | +[Sale Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Sale Transaction](examples/SaleTransaction.php) | +| | | | | | | | +| [Users](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Users) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | [User](examples/User.php) | +| User Roles | | :white_check_mark: | | | :white_check_mark: | [User Role](examples/UserRole.php) | +| [VAT](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/VAT) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [VAT](examples/VatCode.php) | +| VAT Groups | | :white_check_mark: | | | :white_check_mark: | [VAT Group](examples/VatGroup.php) | +| VAT Group Countries | | :white_check_mark: | | | :white_check_mark: | [VAT Group Country](examples/VatGroupCountry.php) | ## Links From e1ae0ef4c3135cc04eafbdd8e18221f2ef931661 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 15 May 2019 12:45:51 +0200 Subject: [PATCH 215/388] Upload --- examples/BrowseData.php | 263 +++++++++++++++++++++ examples/CashBankBook.php | 15 +- examples/CostCenter.php | 21 +- examples/Country.php | 13 - examples/Currency.php | 25 +- examples/PayCode.php | 21 +- examples/UserRole.php | 82 +++++++ examples/VatGroup.php | 19 +- examples/VatGroupCountry.php | 15 +- readme.md | 10 +- src/ApiConnectors/CurrencyApiConnector.php | 23 +- usage.md | 13 + 12 files changed, 418 insertions(+), 102 deletions(-) create mode 100644 examples/BrowseData.php create mode 100644 examples/UserRole.php diff --git a/examples/BrowseData.php b/examples/BrowseData.php new file mode 100644 index 00000000..8c8424b1 --- /dev/null +++ b/examples/BrowseData.php @@ -0,0 +1,263 @@ +getBrowseDefinition('000'); + } catch (ResponseException $e) { + $browseDefinition = $e->getReturnedObject(); + } + + echo "
";
+    print_r($browseDefinition);
+    echo "
"; +} + +/* BrowseField + * \PhpTwinfield\BrowseField + * Available getters: getCode, getDataType, getFinder, getOptions, isCanOrder + * Available setters: setCanOrder, setCode, setDataType, setFinder, addOption + */ + +/* BrowseFieldOption + * \PhpTwinfield\BrowseFieldOption + * Available getters: getCode, getName + * Available setters: setCode, setName + */ + +if ($executeListBrowseFields) { + try { + $browseFields = $browseDataApiConnector->getBrowseFields(); + } catch (ResponseException $e) { + $browseFields = $e->getReturnedObject(); + } + + echo "
";
+    print_r($browseFields);
+    echo "
"; +} + +/* BrowseSortField + * \PhpTwinfield\BrowseSortField + * Available getters: getCode, getOrder + * Available setters: setCode, setOrder + */ + +/* BrowseData + * \PhpTwinfield\BrowseData + * Available getters: getFirst, getHeaders, getLast, getRows, getTotal + * Available setters: setFirst, setLast, setTotal, addHeader, addRow + */ + + /* BrowseDataHeader + * \PhpTwinfield\BrowseDataHeader + * Available getters: getCode, getLabel, getType, isHideForUser + * Available setters: setCode, setHideForUser, setLabel, setType + */ + +/* BrowseDataRow + * \PhpTwinfield\BrowseDataRow + * Available getters: getCells, getCode, getLine, getNumber, getOffice + * Available setters: setCode, setLine, setNumber, setOffice, addCell + */ + +/* BrowseDataCell + * \PhpTwinfield\BrowseDataCell + * Available getters: getField, getType, getValue, isHideForUser + * Available setters: setField, setHideForUser, setType, setValue + */ + +if ($executeGetBrowseData) { + // First, create the columns that you want to retrieve (see the browse definition for which columns are available) + $columns[] = (new \PhpTwinfield\BrowseColumn()) + ->setField('fin.trs.head.yearperiod') + ->setLabel('Period') + ->setVisible(true) + ->setAsk(true) + ->setOperator(\PhpTwinfield\Enums\BrowseColumnOperator::BETWEEN()) + ->setFrom('2018/01') + ->setTo('2050/12'); + + $columns[] = (new \PhpTwinfield\BrowseColumn()) + ->setField('fin.trs.head.code') + ->setLabel('Transaction type') + ->setVisible(true); + + $columns[] = (new \PhpTwinfield\BrowseColumn()) + ->setField('fin.trs.head.shortname') + ->setLabel('Name') + ->setVisible(true); + + $columns[] = (new \PhpTwinfield\BrowseColumn()) + ->setField('fin.trs.head.number') + ->setLabel('Trans. no.') + ->setVisible(true); + + $columns[] = (new \PhpTwinfield\BrowseColumn()) + ->setField('fin.trs.line.dim1') + ->setLabel('General ledger') + ->setVisible(true) + ->setAsk(true) + ->setOperator(\PhpTwinfield\Enums\BrowseColumnOperator::BETWEEN()) + ->setFrom('1300') + ->setTo('1300'); + + $columns[] = (new \PhpTwinfield\BrowseColumn()) + ->setField('fin.trs.head.curcode') + ->setLabel('Currency') + ->setVisible(true); + + $columns[] = (new \PhpTwinfield\BrowseColumn()) + ->setField('fin.trs.line.valuesigned') + ->setLabel('Value') + ->setVisible(true); + + $columns[] = (new \PhpTwinfield\BrowseColumn()) + ->setField('fin.trs.line.description') + ->setLabel('Description') + ->setVisible(true); + + // Second, create sort fields + $sortFields[] = new \PhpTwinfield\BrowseSortField('fin.trs.head.code'); + + try { + // Get the browse data + $browseData = $browseDataApiConnector->getBrowseData('000', $columns, $sortFields); + } catch (ResponseException $e) { + $browseData = $e->getReturnedObject(); + } + + echo "
";
+    print_r($browseData);
+    echo "
"; + + echo "Browse Data
"; + echo "First: {$browseData->getFirst()}
"; + echo "Last: {$browseData->getLast()}
"; + echo "Total: {$browseData->getTotal()}

"; + + $browseDataHeaders = $browseData->getHeaders(); + $tableHeader = array("Result #", "Office", "Code", "Number", "Line"); + + foreach ($browseDataHeaders as $browseDataHeader) { + $tableHeader[] = $browseDataHeader->getLabel(); + } + + $browseDataRows = $browseData->getRows(); + + foreach ($browseDataRows as $key => $browseDataRow) { + $tableRows[$key][] = $key; + $tableRows[$key][] = $browseDataRow->getOffice(); + $tableRows[$key][] = $browseDataRow->getCode(); + $tableRows[$key][] = $browseDataRow->getNumber(); + $tableRows[$key][] = $browseDataRow->getLine(); + + $browseDataCells = $browseDataRow->getCells(); + + foreach ($browseDataCells as $browseDataCell) { + $tableRows[$key][] = $browseDataCell->getValue(); + } + } + + ?> + + + {$tableHeaderColumn}"; } ?> + + "; foreach ($tableRow as $tableColumn) { echo ""; } echo ""; } ?> +
{$tableColumn}
+ + getCode()}
"; echo "Name: {$cashBankBook->getName()}

"; } -} - -// NOTE: Because the CashBankBookApiConnector only supports the listAll method at the moment it is not particularly useful to create a new CashBankBook -if ($executeNew) { - $cashBankBook = new \PhpTwinfield\CashBankBook; - $cashBankBook->setCode("BNK"); - $cashBankBook->setName("Standaard bank"); - $cashBankBook->setShortName("StdBank"); - - echo "
";
-    print_r($cashBankBook);
-    echo "
"; } \ No newline at end of file diff --git a/examples/CostCenter.php b/examples/CostCenter.php index 9acbade5..fac8dd10 100644 --- a/examples/CostCenter.php +++ b/examples/CostCenter.php @@ -65,12 +65,12 @@ * Usage: $options['group'] = 'DimensionGroup'; */ -//List all with pattern "Apeldoorn", field 0 (= search code or number), firstRow 5, maxRows 10, options -> modifiedsince = '20190101100000', group = 'DimensionGroup' +//List all with pattern "Apeldoorn", field 0 (= search code or number), firstRow 1, maxRows 10, options -> modifiedsince = '20190101100000', group = 'DimensionGroup' if ($executeListAllWithFilter) { $options = array('modifiedsince' => '20190101100000', 'group' => 'DimensionGroup'); try { - $costCenters = $costCenterApiConnector->listAll("Apeldoorn", 0, 5, 10, $options); + $costCenters = $costCenterApiConnector->listAll("Apeldoorn", 0, 1, 10, $options); } catch (ResponseException $e) { $costCenters = $e->getReturnedObject(); } @@ -133,7 +133,7 @@ echo "ShortName: {$costCenter->getShortName()}
"; // string|null Not in use. echo "Status: {$costCenter->getStatus()}
"; // Status|null Status of the cost center. echo "Touched: {$costCenter->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. - echo "Type: {$costCenter->getType()}
"; // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is KPL. + echo "Type:
" . print_r($costCenter->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is KPL. echo "Type: {$costCenter->getTypeToString()}
"; // string|null echo "UID: {$costCenter->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. } @@ -141,7 +141,7 @@ // Copy an existing CostCenter to a new entity if ($executeCopy) { $costCenter = $costCenterApiConnector->get("00000", $office); - $costCenter->setCode(null); + $costCenter->setCode("00010"); // string|null Dimension code, must be compliant with the mask of the KPL Dimension type. try { $costCenterCopy = $costCenterApiConnector->send($costCenter); @@ -153,6 +153,7 @@ print_r($costCenterCopy); echo ""; + echo "Result of copy process: {$costCenterCopy->getResult()}
"; echo "Code of copied CostCenter: {$costCenterCopy->getCode()}
"; } @@ -162,18 +163,17 @@ // Required values for creating a new CostCenter $costCenter->setName("CostCenterName"); // string|null Name of the dimension. + $costCenter->setCode('00020'); // string|null Dimension code, must be compliant with the mask of the KPL Dimension type. $costCenter->setOffice($office); // Office|null Office. - $costCenter->setOfficefromCode($officeCode); // string|null + $costCenter->setOfficeFromString($officeCode); // string|null // Optional values for creating a new CostCenter - $costCenter->setCode(null); // string|null Dimension code, must be compliant with the mask of the KPL Dimension type. - //$costCenter->setCode('00020'); // string|null $costCenter->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. //$costCenter->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null For deleting deleted should be used. In case a dimension that is used in a transaction is deleted, // its status has been changed into hide. Hidden dimensions can be activated by using active. $costCenter->setStatusFromString('active'); // string|null //$costCenter->setStatusFromString('deleted'); // string|null - // + $dimensionType = new \PhpTwinfield\DimensionType; $dimensionType->setCode('KPL'); $costCenter->setType($dimensionType); // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is KPL. @@ -189,13 +189,14 @@ print_r($costCenterNew); echo ""; + echo "Result of creation process: {$costCenterNew->getResult()}
"; echo "Code of new CostCenter: {$costCenterNew->getCode()}
"; } // Delete a CostCenter based off the passed in code and optionally the office. if ($executeDelete) { try { - $costCenterDeleted = $costCenterApiConnector->delete("SomeCostCenterCode", $office); + $costCenterDeleted = $costCenterApiConnector->delete("00020", $office); } catch (ResponseException $e) { $costCenterDeleted = $e->getReturnedObject(); } @@ -203,4 +204,6 @@ echo "
";
     print_r($costCenterDeleted);
     echo "
"; + + echo "Result of deletion process: {$costCenterDeleted->getResult()}
"; } \ No newline at end of file diff --git a/examples/Country.php b/examples/Country.php index cff517e3..ed048ab0 100644 --- a/examples/Country.php +++ b/examples/Country.php @@ -21,7 +21,6 @@ // Run all or only some of the following examples $executeListAllWithFilter = false; $executeListAllWithoutFilter = true; -$executeNew = false; $countryApiConnector = new \PhpTwinfield\ApiConnectors\CountryApiConnector($connection); @@ -80,16 +79,4 @@ echo "Code: {$country->getCode()}
"; echo "Name: {$country->getName()}

"; } -} - -// NOTE: Because the CountryApiConnector only supports the listAll method at the moment it is not particularly useful to create a new Country -if ($executeNew) { - $country = new \PhpTwinfield\Country; - $country->setCode("NL"); - $country->setName("Nederland"); - $country->setShortName("Nederland"); - - echo "
";
-    print_r($country);
-    echo "
"; } \ No newline at end of file diff --git a/examples/Currency.php b/examples/Currency.php index 5677425d..42bc46e4 100644 --- a/examples/Currency.php +++ b/examples/Currency.php @@ -54,10 +54,10 @@ * Usage: $options['office'] = 'SomeOfficeCode'; */ -//List all with pattern "EUR", field 0 (= search code or number), firstRow 5, maxRows 10, options [] +//List all with pattern "EUR", field 0 (= search code or number), firstRow 1, maxRows 10, options [] if ($executeListAllWithFilter) { try { - $currencies = $currencyApiConnector->listAll("EUR", 0, 5, 10); + $currencies = $currencyApiConnector->listAll("EUR", 0, 1, 10); } catch (ResponseException $e) { $currencies = $e->getReturnedObject(); } @@ -102,7 +102,7 @@ // Read a Currency based off the passed in code and optionally the office. if ($executeRead) { - $currency = $currencyApiConnector->get("EUR", $office); + $currency = $currencyApiConnector->get("USD", $office); echo "
";
     print_r($currency);
@@ -119,7 +119,7 @@
     echo "Office (\\PhpTwinfield\\Office): 
" . print_r($currency->getOffice(), true) . "

"; // Office|null Office of the currency. echo "Office (string): {$currency->getOfficeToString()}
"; // string|null echo "Result: {$currency->getResult()}
"; // int|null Result (0 = error, 1 = success). - echo "ShortName: {$currency->getShortName()}
"; // string|null Short name of the currency. + echo "ShortName: {$currency->getShortName()}
"; // string|null Short name of the currency. NOTE: Because of the "hackish" way a currency is read (because Twinfield does not officially support reading currencies) the get() method will not return the current Short Name echo "Status: {$currency->getStatus()}
"; // Status|null Status of the currency. $currencyRates = $currency->getRates(); // Array|null Array of CurrencyRate objects. @@ -141,8 +141,8 @@ // Copy an existing Currency to a new entity if ($executeCopy) { - $currency = $currencyApiConnector->get("EUR", $office); - $currency->setCode("EUR2"); + $currency = $currencyApiConnector->get("USD", $office); + $currency->setCode("USD2"); try { $currencyCopy = $currencyApiConnector->send($currency); @@ -166,7 +166,7 @@ $currency->setCode('JPY'); // string|null The code of the currency. $currency->setName("Japanese yen"); // string|null Name of the currency. $currency->setOffice($office); // Office|null Office code of the currency. - $currency->setOfficefromCode($officeCode); // string|null + $currency->setOfficeFromString($officeCode); // string|null // Optional values for creating a new Currency $currency->setShortName("Yen"); // string|null Short name of the currency. @@ -180,14 +180,13 @@ // The minimum amount of CurrencyRates linked to a Currency object is 0 $currencyRate = new \PhpTwinfield\CurrencyRate; $currencyRate->setRate(122.87); // float|null Conversion rate to be used as of the start date. - $startDate = DateTime::createFromFormat('d-m-Y', '01-01-2019'); + $startDate = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); $currencyRate->setStartDate($startDate); // \DateTimeInterface|null Starting date of the rate. $currencyRate->setStartDateFromString('20190101'); // string|null - $currencyRate->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. - //$currencyRate->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null For deleting deleted should be used. In case a dimension that is used in a transaction is deleted, + //$currencyRate->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null For creating and updating status may be left empty. NOTE: Do not use $currencyRate->setStatusFromString(\PhpTwinfield\Enums\Status::ACTIVE()); + // For deleting deleted should be used. In case a dimension that is used in a transaction is deleted, // its status has been changed into hide. Hidden dimensions can be activated by using active. - $currencyRate->setStatusFromString('active'); // string|null - //$currencyRate->setStatusFromString('deleted'); // string|null + //$currencyRate->setStatusFromString('deleted'); // string|null NOTE: Do not use $currencyRate->setStatusFromString('active'); $currency->addRate($currencyRate); // CurrencyRate Add a CurrencyRate object to the Currency object //$currency->removeRate(0); // int Remove a rate based on the index of the rate within the array @@ -209,7 +208,7 @@ // Delete a Currency based off the passed in code and optionally the office. if ($executeDelete) { try { - $currencyDeleted = $currencyApiConnector->delete("SomeCurrencyCode", $office); + $currencyDeleted = $currencyApiConnector->delete("JPY", $office); } catch (ResponseException $e) { $currencyDeleted = $e->getReturnedObject(); } diff --git a/examples/PayCode.php b/examples/PayCode.php index eef08c7d..4456fd1f 100644 --- a/examples/PayCode.php +++ b/examples/PayCode.php @@ -17,11 +17,10 @@ * \PhpTwinfield\ApiConnectors\PayCodeApiConnector * Available methods: listAll */ - + // Run all or only some of the following examples $executeListAllWithFilter = false; $executeListAllWithoutFilter = true; -$executeNew = false; $payCodeApiConnector = new \PhpTwinfield\ApiConnectors\PayCodeApiConnector($connection); @@ -46,12 +45,12 @@ * Usage: $options['paytype'] = 'pay'; */ -//List all with pattern "SEPA*", field 0 (= search code or number), firstRow 5, maxRows 10, options -> paytype = pay +//List all with pattern "SEPA*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> paytype = pay if ($executeListAllWithFilter) { $options = array('paytype' => 'pay'); try { - $payCodes = $payCodeApiConnector->listAll("SEPA*", 0, 5, 10, $options); + $payCodes = $payCodeApiConnector->listAll("SEPA*", 0, 1, 10, $options); } catch (ResponseException $e) { $payCodes = $e->getReturnedObject(); } @@ -79,23 +78,11 @@ * Available getters: getCode, getName, getShortName * Available setters: setCode, setName, setShortName */ - + if ($executeListAllWithFilter || $executeListAllWithoutFilter) { foreach ($payCodes as $key => $payCode) { echo "PayCode {$key}
"; echo "Code: {$payCode->getCode()}
"; echo "Name: {$payCode->getName()}

"; } -} - -// NOTE: Because the PayCodeApiConnector only supports the listAll method at the moment it is not particularly useful to create a new PayCode -if ($executeNew) { - $payCode = new \PhpTwinfield\PayCode; - $payCode->setCode("SEPATEST"); - $payCode->setName("SEPA Test pay code"); - $payCode->setShortName("SEPATestPayCode"); - - echo "
";
-    print_r($payCode);
-    echo "
"; } \ No newline at end of file diff --git a/examples/UserRole.php b/examples/UserRole.php new file mode 100644 index 00000000..dfb6f90c --- /dev/null +++ b/examples/UserRole.php @@ -0,0 +1,82 @@ +listAll("LVL1*", 0, 1, 10); + } catch (ResponseException $e) { + $userRoles = $e->getReturnedObject(); + } + + echo "
";
+    print_r($userRoles);
+    echo "
"; +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +if ($executeListAllWithoutFilter) { + try { + $userRoles = $userRoleApiConnector->listAll(); + } catch (ResponseException $e) { + $userRoles = $e->getReturnedObject(); + } + + echo "
";
+    print_r($userRoles);
+    echo "
"; +} + +/* UserRole + * \PhpTwinfield\UserRole + * Available getters: getCode, getName, getShortName + * Available setters: setCode, setName, setShortName + */ + +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($userRoles as $key => $userRole) { + echo "UserRole {$key}
"; + echo "Code: {$userRole->getCode()}
"; + echo "Name: {$userRole->getName()}

"; + } +} \ No newline at end of file diff --git a/examples/VatGroup.php b/examples/VatGroup.php index cc621d42..8e3f705a 100644 --- a/examples/VatGroup.php +++ b/examples/VatGroup.php @@ -17,11 +17,10 @@ * \PhpTwinfield\ApiConnectors\VatGroupApiConnector * Available methods: listAll */ - + // Run all or only some of the following examples $executeListAllWithFilter = false; $executeListAllWithoutFilter = true; -$executeNew = false; $vatGroupApiConnector = new \PhpTwinfield\ApiConnectors\VatGroupApiConnector($connection); @@ -42,10 +41,10 @@ * Usage: $options['office'] = 'SomeOfficeCode'; */ -//List all with pattern "1*", field 0 (= search code or number), firstRow 5, maxRows 10 +//List all with pattern "1*", field 0 (= search code or number), firstRow 1, maxRows 10 if ($executeListAllWithFilter) { try { - $vatGroups = $vatGroupApiConnector->listAll("1*", 0, 5, 10); + $vatGroups = $vatGroupApiConnector->listAll("1*", 0, 1, 10); } catch (ResponseException $e) { $vatGroups = $e->getReturnedObject(); } @@ -80,16 +79,4 @@ echo "Code: {$vatGroup->getCode()}
"; echo "Name: {$vatGroup->getName()}

"; } -} - -// NOTE: Because the VatGroupApiConnector only supports the listAll method at the moment it is not particularly useful to create a new VatGroup -if ($executeNew) { - $vatGroup = new \PhpTwinfield\VatGroup; - $vatGroup->setCode("1A"); - $vatGroup->setName("High (1a)"); - $vatGroup->setShortName("High1A"); - - echo "
";
-    print_r($vatGroup);
-    echo "
"; } \ No newline at end of file diff --git a/examples/VatGroupCountry.php b/examples/VatGroupCountry.php index 21d2c961..c5f51535 100644 --- a/examples/VatGroupCountry.php +++ b/examples/VatGroupCountry.php @@ -17,11 +17,10 @@ * \PhpTwinfield\ApiConnectors\VatGroupCountryApiConnector * Available methods: listAll */ - + // Run all or only some of the following examples $executeListAllWithFilter = false; $executeListAllWithoutFilter = true; -$executeNew = false; $vatGroupCountryApiConnector = new \PhpTwinfield\ApiConnectors\VatGroupCountryApiConnector($connection); @@ -85,16 +84,4 @@ echo "Code: {$vatGroupCountry->getCode()}
"; echo "Name: {$vatGroupCountry->getName()}

"; } -} - -// NOTE: Because the VatGroupCountryApiConnector only supports the listAll method at the moment it is not particularly useful to create a new VatGroupCountry -if ($executeNew) { - $vatGroupCountry = new \PhpTwinfield\VatGroupCountry; - $vatGroupCountry->setCode("NL"); - $vatGroupCountry->setName("NL1A"); - $vatGroupCountry->setShortName("NL1A"); - - echo "
";
-    print_r($vatGroupCountry);
-    echo "
"; } \ No newline at end of file diff --git a/readme.md b/readme.md index fc33f553..4cea9ba1 100644 --- a/readme.md +++ b/readme.md @@ -52,11 +52,11 @@ support for another resource. | [Suppliers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Supplier](examples/Supplier.php) | | | | | | | | | | Transactions | | | | | | | -[Bank Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Bank Transaction](examples/BankTransaction.php) | -[Cash Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/CashTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Cash Transaction](examples/CashTransaction.php) | -[Journal Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/JournalTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Journal Transaction](examples/JournalTransaction.php) | -[Purchase Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Purchase Transaction](examples/PurchaseTransaction.php) | -[Sale Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Sale Transaction](examples/SaleTransaction.php) | +[Bank Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | | +[Cash Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/CashTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | | +[Journal Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/JournalTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | | +[Purchase Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | | +[Sale Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | | | | | | | | | | | [Users](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Users) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | [User](examples/User.php) | | User Roles | | :white_check_mark: | | | :white_check_mark: | [User Role](examples/UserRole.php) | diff --git a/src/ApiConnectors/CurrencyApiConnector.php b/src/ApiConnectors/CurrencyApiConnector.php index 0da66233..1ebdc64e 100644 --- a/src/ApiConnectors/CurrencyApiConnector.php +++ b/src/ApiConnectors/CurrencyApiConnector.php @@ -28,7 +28,7 @@ class CurrencyApiConnector extends BaseApiConnector /** * Requests a specific Currency based off the passed in code and optionally the office. * NOTE: The Twinfield API does not currently officially support reading currencies - * This function uses the fact that the API will return a complete object when sending an existing code with an explicit error (no name) + * This function uses the fact that the API will return part of an existing object when sending a known code with an explicit error (no name) * * @param string $code * @param Office $office If no office has been passed it will instead take the default office from the @@ -42,12 +42,33 @@ public function get(string $code, Office $office): Currency $currency = new Currency; $currency->setCode($code); $currency->setOffice($office); + $currencyName = ''; + + $currencies = self::listAll($code, 1, 1, 100, array('office' => $office->getCode())); + + if (count($currencies) == 0) { + $currency->setResult(0); + return $currency; + } + + foreach ($currencies as $currencyListing) { + if ($currencyListing->getCode() == $code) { + $currencyName = $currencyListing->getName(); + break; + } + } + + if (empty($currencyName)) { + $currency->setResult(0); + return $currency; + } try { $currencyResponse = $this->send($currency); } catch (ResponseException $e) { $currencyResponse = $e->getReturnedObject(); $currencyResponse->setMessages(null); + $currencyResponse->setName($currencyName); $currencyResponse->setResult(1); } diff --git a/usage.md b/usage.md index 3a59da9c..848e1c2d 100644 --- a/usage.md +++ b/usage.md @@ -25,6 +25,9 @@ Go to the [Twinfield web site](https://www.twinfield.nl/openid-connect-request/) * Add more post logout URL's?: Your choice ##### Grant Authorization and retrieve initial Access Token +See [Authorization Example](examples/Authorization.php) for a complete example +Also see [RenewAuthorization Example](examples/RenewAuthorization.php) for a complete example on how/when to request users to renew their authorization + On loading a page containing the following code the user will be redirected to the Twinfield Login page. After successful login and optionally consent (see above) the user will be redirected back to the page at which point the Access Token and Refresh Token can be retrieved. @@ -100,6 +103,8 @@ if (!isset($_GET['code'])) { ``` ##### Optionally: Store a valid access token and cluster through a scheduled task/cron job running in the background +See [RenewAccessToken Example](examples/RenewAccessToken.php) for a complete example + Running the following code every 60 minutes (or a bit less as Access Tokens are valid for exactly 60 minutes) will reduce connection time when working with the Api (by about 2 seconds). It will also reduce connection load on Twinfield when making more than 20-30 connections/day. ```php @@ -131,6 +136,8 @@ if ($validationResult !== false) { ``` ##### Connection +See [Connection Example](examples/Connection.php) for a complete example + Using the stored Refresh Token and optionally Access Token/Cluster, we can create an instance of the `\PhpTwinfield\Secure\OpenIdConnectAuthentication` class, as follows: ```php @@ -156,6 +163,8 @@ if ($accessTokenStorage['access_expiry'] > time()) { ``` ### Getting data from the API +See [Customer Example](examples/Customer.php) among others for a complete example + In order to communicate with the Twinfield API, you need to create an `ApiConnector` instance for the corresponding resource and use the `get()` or `list()` method. @@ -177,6 +186,8 @@ $customer = $customerApiConnector->listAll($office); ``` ### Creating or updating objects +See [Customer Example](examples/Customer.php) among others for a complete example + If you want to create or update a customer or any other object, it's just as easy: ```php @@ -209,6 +220,8 @@ $customer_factory->send($customer); You can also send multiple objects in one batch, chunking is handled automatically. ### Browse data +See [BrowseData Example](examples/BrowseData.php) for a complete example + In order to get financial data out of Twinfield like general ledger transactions, sales invoices, and so on, you can use the the browse data functionality. More information about the browse data functionality in Twinfield can be found in the [documentation](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Request/BrowseData). From 8fb6a1800d905012580d1836a41fa189d8c7de4e Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 20 May 2019 10:34:25 +0200 Subject: [PATCH 216/388] Upload --- breaking262.md | 85 ++++ readme.md | 3 +- src/ApiConnectors/ActivityApiConnector.php | 6 +- src/ApiConnectors/AssetMethodApiConnector.php | 6 +- src/ApiConnectors/CostCenterApiConnector.php | 6 +- src/ApiConnectors/CustomerApiConnector.php | 4 +- .../ElectronicBankStatementApiConnector.php | 3 +- src/ApiConnectors/MatchesApiConnector.php | 7 +- src/ApiConnectors/ProjectApiConnector.php | 6 +- src/ApiConnectors/RateApiConnector.php | 6 +- src/ApiConnectors/SupplierApiConnector.php | 6 +- src/ApiConnectors/TransactionApiConnector.php | 22 +- src/ApiConnectors/VatCodeApiConnector.php | 6 +- src/Article.php | 8 +- src/AssetMethod.php | 7 +- src/BankTransaction.php | 47 +- src/BankTransactionLine.php | 264 ++++++----- src/BaseTransaction.php | 109 ++--- src/BaseTransactionLine.php | 444 ++++++------------ src/BrowseDataHeader.php | 23 +- src/BrowseDataRow.php | 46 +- src/BrowseDefinition.php | 79 +--- src/BrowseField.php | 23 +- src/BrowseFieldOption.php | 46 +- src/BrowseSortField.php | 20 +- src/CashTransaction.php | 47 +- src/CashTransactionLine.php | 263 ++++++----- src/Customer.php | 19 +- src/CustomerBank.php | 2 +- src/CustomerCreditManagement.php | 2 +- src/CustomerFinancials.php | 1 + src/DomDocuments/BaseDocument.php | 126 +---- .../BookingReferenceDeletionDocument.php | 2 +- .../ElectronicBankStatementDocument.php | 25 +- src/DomDocuments/InvoicesDocument.php | 6 +- src/DomDocuments/MatchDocument.php | 10 +- src/DomDocuments/TransactionsDocument.php | 139 +++--- src/ElectronicBankStatement.php | 76 +-- src/ElectronicBankStatementTransaction.php | 82 ++-- src/Enums/MatchStatus.php | 21 + src/Enums/Regime.php | 21 + .../Level2/Customer => }/CommentField.php | 4 +- src/Fields/CurrencyField.php | 2 +- src/Fields/{VatCode => }/DateField.php | 130 ++--- src/Fields/DescriptionField.php | 2 +- .../Level34/FixedAsset => }/Dim2Field.php | 4 +- .../Level34/FixedAsset => }/Dim3Field.php | 4 +- .../Level34/FixedAsset => }/Dim4Field.php | 4 +- src/Fields/{Invoice => }/DueDateField.php | 130 ++--- src/Fields/FreeText1Field.php | 2 +- src/Fields/FreeText2Field.php | 2 +- src/Fields/FreeText3Field.php | 2 +- src/Fields/IDField.php | 2 +- src/Fields/Invoice/InvoiceNumberField.php | 10 +- src/Fields/{VatCode => }/LineTypeField.php | 80 ++-- .../{Invoice => }/PerformanceDateField.php | 130 ++--- .../{Invoice => }/PerformanceTypeField.php | 80 ++-- src/Fields/PeriodField.php | 2 +- .../Transaction/AutoBalanceVatField.php | 47 ++ src/Fields/Transaction/CloseValueField.php | 62 +++ .../Transaction/DateRaiseWarningField.php | 47 ++ src/Fields/Transaction/DestinyField.php | 41 ++ src/Fields/Transaction/InputDateField.php | 66 +++ src/Fields/Transaction/InvoiceNumberField.php | 32 ++ .../InvoiceNumberRaiseWarningField.php | 47 ++ .../Transaction}/LinesField.php | 19 +- .../Transaction/ModificationDateField.php | 66 +++ src/Fields/Transaction/NumberField.php | 32 ++ src/Fields/Transaction/OriginField.php | 32 ++ .../Transaction/OriginReferenceField.php | 32 ++ .../Transaction}/PaymentReferenceField.php | 14 +- src/Fields/Transaction/RaiseWarningField.php | 47 ++ src/Fields/Transaction/RegimeField.php | 41 ++ src/Fields/Transaction/StartValueField.php | 62 +++ .../Transaction/StatementNumberField.php | 32 ++ .../TransactionLine/BaseValueField.php | 62 +++ .../TransactionLine/BaseValueOpenField.php | 62 +++ .../TransactionLine/BaselineField.php | 32 ++ .../TransactionLine/CurrencyDateField.php | 66 +++ .../TransactionLine/DestOfficeField.php | 53 +++ .../Transaction/TransactionLine/Dim1Field.php | 54 +++ .../TransactionLine}/FreeCharField.php | 4 +- .../TransactionLine/MatchDateField.php | 66 +++ .../TransactionLine/MatchLevelField.php | 32 ++ .../TransactionLine/MatchStatusField.php | 40 ++ .../PerformanceCountryField.php | 54 +++ .../PerformanceVatNumberField.php | 32 ++ .../Transaction/TransactionLine/RateField.php | 32 ++ .../TransactionLine/RelationField.php | 32 ++ .../TransactionLine/RepRateField.php | 32 ++ .../TransactionLine/RepValueField.php | 62 +++ .../TransactionLine/RepValueOpenField.php | 62 +++ .../TransactionLine}/ValueFields.php | 28 +- .../TransactionLine/ValueOpenField.php | 62 +++ .../TransactionLine/VatBaseTotalField.php | 62 +++ .../TransactionLine/VatBaseTurnoverField.php | 62 +++ .../TransactionLine/VatBaseValueField.php | 62 +++ .../TransactionLine/VatRepTotalField.php | 62 +++ .../TransactionLine/VatRepTurnoverField.php | 62 +++ .../TransactionLine/VatRepValueField.php | 62 +++ .../TransactionLine/VatTotalField.php | 62 +++ .../TransactionLine/VatTurnoverField.php | 62 +++ src/Fields/UserField.php | 2 +- src/Fields/VatCodeField.php | 2 +- src/Fields/{Invoice => }/VatValueField.php | 122 ++--- src/FixedAssetTransactionLine.php | 6 +- src/Invoice.php | 39 +- src/InvoiceLine.php | 6 +- src/InvoiceVatLine.php | 8 +- src/JournalTransaction.php | 37 +- src/JournalTransactionLine.php | 239 +++++++--- src/Mappers/BaseMapper.php | 68 +-- src/Mappers/MatchSetMapper.php | 13 +- src/Mappers/ProjectMapper.php | 2 +- src/Mappers/TransactionMapper.php | 195 ++++---- src/Mappers/UserRoleMapper.php | 2 +- src/MatchLine.php | 46 +- src/MatchReference.php | 5 +- src/MatchSet.php | 2 +- src/PurchaseTransaction.php | 12 +- src/PurchaseTransactionLine.php | 283 ++++++++--- src/Rate.php | 14 +- src/Request/Read/Activity.php | 8 +- src/Request/Read/Currency.php | 6 +- src/Request/Read/User.php | 2 +- src/Request/Read/VatCode.php | 2 +- src/SalesTransaction.php | 53 +-- src/SalesTransactionLine.php | 278 ++++++----- src/Secure/WebservicesAuthentication.php | 16 +- src/Services/BaseService.php | 5 + src/Supplier.php | 19 +- src/SupplierBank.php | 2 +- src/SupplierFinancials.php | 4 +- src/Transactions/Transaction.php | 7 - .../TransactionFields/AutoBalanceVatField.php | 32 -- .../CodeNumberOfficeFields.php | 82 ---- .../TransactionFields/DestinyField.php | 31 -- .../TransactionFields/DueDateField.php | 47 -- .../TransactionFields/FreeTextFields.php | 85 ---- .../TransactionFields/InvoiceNumberField.php | 30 -- .../TransactionFields/OfficeField.php | 33 -- .../TransactionFields/RaiseWarningField.php | 30 -- .../StartAndCloseValueFields.php | 67 --- .../StatementNumberField.php | 30 -- src/Transactions/TransactionLine.php | 53 --- .../TransactionLineFields/CommentField.php | 29 -- .../TransactionLineFields/DateField.php | 47 -- .../TransactionLineFields/FourDimFields.php | 28 -- .../PerformanceFields.php | 144 ------ .../TransactionLineFields/PeriodField.php | 37 -- .../TransactionLineFields/ThreeDimFields.php | 66 --- .../TransactionLineFields/ValueOpenField.php | 43 -- .../TransactionLineFields/VatCodeField.php | 33 -- .../TransactionLineFields/VatTotalFields.php | 76 --- .../VatTurnoverFields.php | 81 ---- src/UserRole.php | 1 + src/VatCodeAccount.php | 6 +- src/VatCodePercentage.php | 8 +- .../BankTransactionIntegrationTest.php | 28 +- .../BrowseDataApiConnectorTest.php | 4 +- .../CashTransactionIntegrationTest.php | 26 +- .../JournalTransactionIntegrationTest.php | 22 +- .../PurchaseTransactionIntegrationTest.php | 30 +- .../SalesTransactionIntegrationTest.php | 30 +- .../ApiConnectors/MatchesApiConnectorTest.php | 24 +- .../TransactionApiConnectorTest.php | 2 +- .../UnitTests/BankTransactionLineUnitTest.php | 7 +- tests/UnitTests/BankTransactionUnitTest.php | 27 +- .../UnitTests/CashTransactionLineUnitTest.php | 7 +- tests/UnitTests/CashTransactionUnitTest.php | 29 +- ...lectronicBankStatementDocumentUnitTest.php | 12 +- .../ElectronicBankStatementUnitTest.php | 7 +- .../ValueFieldsUnitTest.php | 2 +- usage.md | 66 ++- 174 files changed, 4274 insertions(+), 3469 deletions(-) create mode 100644 breaking262.md create mode 100644 src/Enums/MatchStatus.php create mode 100644 src/Enums/Regime.php rename src/Fields/{Dimensions/Level2/Customer => }/CommentField.php (81%) rename src/Fields/{VatCode => }/DateField.php (90%) rename src/Fields/{Dimensions/Level34/FixedAsset => }/Dim2Field.php (89%) rename src/Fields/{Dimensions/Level34/FixedAsset => }/Dim3Field.php (89%) rename src/Fields/{Dimensions/Level34/FixedAsset => }/Dim4Field.php (89%) rename src/Fields/{Invoice => }/DueDateField.php (91%) rename src/Fields/{VatCode => }/LineTypeField.php (86%) rename src/Fields/{Invoice => }/PerformanceDateField.php (89%) rename src/Fields/{Invoice => }/PerformanceTypeField.php (82%) create mode 100644 src/Fields/Transaction/AutoBalanceVatField.php create mode 100644 src/Fields/Transaction/CloseValueField.php create mode 100644 src/Fields/Transaction/DateRaiseWarningField.php create mode 100644 src/Fields/Transaction/DestinyField.php create mode 100644 src/Fields/Transaction/InputDateField.php create mode 100644 src/Fields/Transaction/InvoiceNumberField.php create mode 100644 src/Fields/Transaction/InvoiceNumberRaiseWarningField.php rename src/{Transactions/TransactionFields => Fields/Transaction}/LinesField.php (84%) create mode 100644 src/Fields/Transaction/ModificationDateField.php create mode 100644 src/Fields/Transaction/NumberField.php create mode 100644 src/Fields/Transaction/OriginField.php create mode 100644 src/Fields/Transaction/OriginReferenceField.php rename src/{Transactions/TransactionFields => Fields/Transaction}/PaymentReferenceField.php (63%) create mode 100644 src/Fields/Transaction/RaiseWarningField.php create mode 100644 src/Fields/Transaction/RegimeField.php create mode 100644 src/Fields/Transaction/StartValueField.php create mode 100644 src/Fields/Transaction/StatementNumberField.php create mode 100644 src/Fields/Transaction/TransactionLine/BaseValueField.php create mode 100644 src/Fields/Transaction/TransactionLine/BaseValueOpenField.php create mode 100644 src/Fields/Transaction/TransactionLine/BaselineField.php create mode 100644 src/Fields/Transaction/TransactionLine/CurrencyDateField.php create mode 100644 src/Fields/Transaction/TransactionLine/DestOfficeField.php create mode 100644 src/Fields/Transaction/TransactionLine/Dim1Field.php rename src/{Transactions/TransactionLineFields => Fields/Transaction/TransactionLine}/FreeCharField.php (84%) create mode 100644 src/Fields/Transaction/TransactionLine/MatchDateField.php create mode 100644 src/Fields/Transaction/TransactionLine/MatchLevelField.php create mode 100644 src/Fields/Transaction/TransactionLine/MatchStatusField.php create mode 100644 src/Fields/Transaction/TransactionLine/PerformanceCountryField.php create mode 100644 src/Fields/Transaction/TransactionLine/PerformanceVatNumberField.php create mode 100644 src/Fields/Transaction/TransactionLine/RateField.php create mode 100644 src/Fields/Transaction/TransactionLine/RelationField.php create mode 100644 src/Fields/Transaction/TransactionLine/RepRateField.php create mode 100644 src/Fields/Transaction/TransactionLine/RepValueField.php create mode 100644 src/Fields/Transaction/TransactionLine/RepValueOpenField.php rename src/{Transactions/TransactionLineFields => Fields/Transaction/TransactionLine}/ValueFields.php (81%) create mode 100644 src/Fields/Transaction/TransactionLine/ValueOpenField.php create mode 100644 src/Fields/Transaction/TransactionLine/VatBaseTotalField.php create mode 100644 src/Fields/Transaction/TransactionLine/VatBaseTurnoverField.php create mode 100644 src/Fields/Transaction/TransactionLine/VatBaseValueField.php create mode 100644 src/Fields/Transaction/TransactionLine/VatRepTotalField.php create mode 100644 src/Fields/Transaction/TransactionLine/VatRepTurnoverField.php create mode 100644 src/Fields/Transaction/TransactionLine/VatRepValueField.php create mode 100644 src/Fields/Transaction/TransactionLine/VatTotalField.php create mode 100644 src/Fields/Transaction/TransactionLine/VatTurnoverField.php rename src/Fields/{Invoice => }/VatValueField.php (88%) delete mode 100644 src/Transactions/Transaction.php delete mode 100644 src/Transactions/TransactionFields/AutoBalanceVatField.php delete mode 100644 src/Transactions/TransactionFields/CodeNumberOfficeFields.php delete mode 100644 src/Transactions/TransactionFields/DestinyField.php delete mode 100644 src/Transactions/TransactionFields/DueDateField.php delete mode 100644 src/Transactions/TransactionFields/FreeTextFields.php delete mode 100644 src/Transactions/TransactionFields/InvoiceNumberField.php delete mode 100644 src/Transactions/TransactionFields/OfficeField.php delete mode 100644 src/Transactions/TransactionFields/RaiseWarningField.php delete mode 100644 src/Transactions/TransactionFields/StartAndCloseValueFields.php delete mode 100644 src/Transactions/TransactionFields/StatementNumberField.php delete mode 100644 src/Transactions/TransactionLine.php delete mode 100644 src/Transactions/TransactionLineFields/CommentField.php delete mode 100644 src/Transactions/TransactionLineFields/DateField.php delete mode 100644 src/Transactions/TransactionLineFields/FourDimFields.php delete mode 100644 src/Transactions/TransactionLineFields/PerformanceFields.php delete mode 100644 src/Transactions/TransactionLineFields/PeriodField.php delete mode 100644 src/Transactions/TransactionLineFields/ThreeDimFields.php delete mode 100644 src/Transactions/TransactionLineFields/ValueOpenField.php delete mode 100644 src/Transactions/TransactionLineFields/VatCodeField.php delete mode 100644 src/Transactions/TransactionLineFields/VatTotalFields.php delete mode 100644 src/Transactions/TransactionLineFields/VatTurnoverFields.php diff --git a/breaking262.md b/breaking262.md new file mode 100644 index 00000000..e488cb91 --- /dev/null +++ b/breaking262.md @@ -0,0 +1,85 @@ +# Breaking changes since 2.6.2 +Release 3.0 added multiple new resources, but also broke several existing ones. + +Breaking changes are present in: +- Bank Transactions (Separate API connector completely removed and functionality moved to general Transactions API Connector) +- Articles +- Customers +- Sales Invoices +- Suppliers +- Vat Codes + +Except for Bank Transactions, the breaking changes are primarily due to the fact that most fields and methods are now properly type cast. + +This means (among others) that all booleans are now type cast as bool, all monetary values are now Money\Money instances and several fields now use Enums instead of strings. + +Another big change is that retrieved fields that are instances of another entity in Twinfield and this library are now retrieved and set in the same way as was already done with Office or Customer codes. +So for example a VAT code retrieved from or set to a PhpTwinfield\Article will now become an instance of PhpTwinfield\VatCode with its $code set to "VH" instead of begin just a string with the value "VH". + +Most of these changed methods have gained ToString/FromString or ToFloat/FromFloat methods that will ease the transition. + +See the tables per class below for breaking changes and suggestions for fixes/replacement methods. + +## Bank Transactions + +| Class/Method | Change | Replaced by | Old Usage | New Usage | +| -------------------------------------------------------------------------- | :-----------------------------------: | :-----------------------------------: | :-----------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------: | +| ApiConnectors\BankTransactionApiConnector | Class removed | ApiConnectors\TransactionApiConnector | $bankTransactionApiConnector = ApiConnectors\BankTransactionApiConnector; | $bankTransactionApiConnector = ApiConnectors\BankTransactionApiConnector; | +| Transactions\BankTransactionLine\Base | Class removed | BankTransactionLine | N.A. | N.A. | +| Transactions\BankTransactionLine\Detail | Class removed | BankTransactionLine | $bankTransactionLineDetail = New Transactions\BankTransactionLine\Detail; | $bankTransactionLineDetail = New BankTransactionLine; $bankTransactionLine->setType(LineType::DETAIL()) | +| Transactions\BankTransactionLine\Total | Class removed | BankTransactionLine | $bankTransactionLineTotal = New Transactions\BankTransactionLine\Total; | $bankTransactionLineTotal = New BankTransactionLine; $bankTransactionLine->setType(LineType::TOTAL()) | +| Transactions\BankTransactionLine\Vat | Class removed | BankTransactionLine | $bankTransactionLineVat = New Transactions\BankTransactionLine\Vat; | $bankTransactionLineVat = New BankTransactionLine; $bankTransactionLine->setType(LineType::VAT()) | +| Transactions\BankTransactionLine\Detail::setAccount | Method removed | BankTransactionLine::setDim1 | $bankTransactionLineDetail->setAccount('4010'); | $bankTransactionLineDetail->setDim1FromString('4010'); | +| Transactions\BankTransactionLine\Detail::setCustomerOrSupplierOrCostCenter | Method removed | BankTransactionLine::setDim2 | $bankTransactionLineDetail->setCustomerOrSupplierOrCostCenter('2010'); | $bankTransactionLineDetail->setDim2FromString('2010'); | +| Transactions\BankTransactionLine\Detail::setProjectOrAsset | Method removed | BankTransactionLine::setDim3 | $bankTransactionLineDetail->setProjectOrAsset('2010'); | $bankTransactionLineDetail->setDim3FromString('P000'); | +| Transactions\BankTransactionLine\Total::setBankBalanceAccount | Method removed | BankTransactionLine::setDim1 | $bankTransactionLineTotal->setBankBalanceAccount('5010'); | $bankTransactionLineTotal->setDim1FromString('5010'); | +| Transactions\BankTransactionLine\Vat::setVatBalanceAccount | Method removed | BankTransactionLine::setDim1 | $bankTransactionLineVat->setVatBalanceAccount('5050'); | $bankTransactionLineVat->setDim1FromString('5050'); | + +## Articles + +| Class/Method | Change | Replaced by | Old Usage | New Usage | +| ---------------------------------- | :--------------------------------------------------------------------: | :-----------------------------------: | :----------------------------------------: | :--------------------------------------------------------------------------------------------------------------------: | +| Article::setStatus | setStatus now expects Enums\Status instead of string | Article::setStatusFromString | $article->setStatus('active'); | $article->setStatusFromString('active'); OR $article->setStatus(Enums\Status::ACTIVE()) | +| Article::setType | setType now expects Enums\ArticleType instead of string | Article::setTypeFromString | $article->setType('normal'); | $article->setTypeFromString('normal'); OR $article->setType(Enums\ArticleType::NORMAL()) | +| Article::setPerformanceType | setPerformanceType now expects Enums\PerformanceType instead of string | Article::setPerformanceTypeFromString | $article->setPerformanceType('services'); | $article->setPerformanceTypeFromString('services'); OR $article->setPerformanceType(Enums\PerformanceType::SERVICES()) | +| Article::getAllowDiscountorPremium | Properly camelCased | Article::getAllowDiscountOrPremium | $article->getAllowDiscountorPremium(true); | $article->getAllowDiscountOrPremium(true); | +| Article::setAllowDiscountorPremium | Properly camelCased | Article::setAllowDiscountOrPremium | $article->setAllowDiscountorPremium(true); | $article->setAllowDiscountOrPremium(true); | + +### Article Lines + +| Class/Method | Change | Replaced by | Old Usage | New Usage | +| ------------------------------ | :---------------------------------------------------------: | :-------------------------------------: | :--------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------: | +| ArticleLine::setStatus | setStatus now expects Enums\Status instead of string | ArticleLine::setStatusFromString | $articleLine->setStatus('active'); | $articleLine->setStatusFromString('active'); OR $articleLine->setStatus(Enums\Status::ACTIVE()) | +| ArticleLine::getUnitsPriceInc | getUnitsPriceInc now returns Money instead of string/float | ArticleLine::getUnitsPriceIncToFloat | $unitsPriceInc = $articleLine->getUnitsPriceInc(); | $unitsPriceInc = $articleLine->getUnitsPriceIncToFloat(); OR $unitsPriceInc = \Money\Formatter\DecimalMoneyFormatter::format($articleLine->getUnitsPriceInc()); | +| ArticleLine::setUnitsPriceInc | setUnitsPriceInc now expects Money instead of string/float | ArticleLine::setUnitsPriceIncFromFloat | $articleLine->setUnitsPriceInc(100.50); | $articleLine->setUnitsPriceIncFromFloat(100.50); OR $articleLine->setUnitsPriceInc(New \Money\Money(10050), new \Money\Currency('EUR')); | +| ArticleLine::getUnitsPriceExcl | getUnitsPriceExcl now returns Money instead of string/float | ArticleLine::getUnitsPriceExclToFloat | $unitsPriceExcl = $articleLine->getUnitsPriceExcl(); | $unitsPriceExcl = $articleLine->getUnitsPriceExclToFloat(); OR $unitsPriceExcl = \Money\Formatter\DecimalMoneyFormatter::format($articleLine->getUnitsPriceExcl()); | +| ArticleLine::setUnitsPriceExcl | setUnitsPriceExcl now expects Money instead of string/float | ArticleLine::setUnitsPriceExclFromFloat | $articleLine->setUnitsPriceExcl(80.75); | $articleLine->setUnitsPriceExclFromFloat(80.75); OR $articleLine->setUnitsPriceExcl(New \Money\Money(8075), new \Money\Currency('EUR')); | +| ArticleLine::getFreeText1 | getFreeText1 now returns GeneralLedger instead of string | ArticleLine::getFreeText1ToString | $dim1 = $articleLine->getFreeText1(); | $dim1 = $articleLine->getFreeText1ToString(); OR $dim1 = $articleLine->getFreeText1()->getCode(); | +| ArticleLine::setFreeText1 | setFreeText1 now expects GeneralLedger instead of string | ArticleLine::setFreeText1FromString | $articleLine->setFreeText1('4050'); | $articleLine->setFreeText1FromString('4050'); OR $dim1 = new GeneralLedger; $dim1->setCode('4050'); $articleLine->setFreeText1($dim1); | + +## Customers + +## Sales Invoices + +## Suppliers + +## Cash/Journal/Purchase/Sale Transactions + +BaseTransaction getCurrency now returns PhpTwinfield\Currency instead of Money\Currency +BaseTransaction setCurrency now expects PhpTwinfield\Currency instead of Money\Currency + +BaseTransactionLine setId -> setID + +BankTransaction getCloseValue Properly camelCased +BankTransaction setCloseValue Properly camelCased + +BankTransaction getStartValue Properly camelCased +BankTransaction setStartValue Properly camelCased + +CashTransaction getCloseValue Properly camelCased +CashTransaction setCloseValue Properly camelCased + +CashTransaction getStartValue Properly camelCased +CashTransaction setStartValue Properly camelCased + +## VAT diff --git a/readme.md b/readme.md index 4cea9ba1..a2920084 100644 --- a/readme.md +++ b/readme.md @@ -20,7 +20,8 @@ composer require 'league/oauth2-client' ## Usage -See [Usage](usage.md) +See [Usage](usage.md). +For breaking changes since 2.6.2 see [Breaking Changes since 2.6.2](breaking262.md). ### Supported resources Not all resources from the Twinfield API are currently implemented. Feel free to create a pull request when you need diff --git a/src/ApiConnectors/ActivityApiConnector.php b/src/ApiConnectors/ActivityApiConnector.php index da1bde47..5bf1cc77 100644 --- a/src/ApiConnectors/ActivityApiConnector.php +++ b/src/ApiConnectors/ActivityApiConnector.php @@ -124,7 +124,7 @@ public function listAll( return $this->mapListAll("Activity", $response->data, $activityArrayListAllTags); } - + /** * Deletes a specific Activity based off the passed in code and optionally the office. * @@ -137,8 +137,8 @@ public function listAll( public function delete(string $code, Office $office): Activity { $activity = self::get($code, $office); - - if ($activity->getResult() == 1) { + + if ($activity->getResult() == 1) { $activity->setStatusFromString("deleted"); try { diff --git a/src/ApiConnectors/AssetMethodApiConnector.php b/src/ApiConnectors/AssetMethodApiConnector.php index 7e3603d7..cdf6372d 100644 --- a/src/ApiConnectors/AssetMethodApiConnector.php +++ b/src/ApiConnectors/AssetMethodApiConnector.php @@ -123,7 +123,7 @@ public function listAll( return $this->mapListAll("AssetMethod", $response->data, $assetMethodArrayListAllTags); } - + /** * Deletes a specific AssetMethod based off the passed in code and optionally the office. * @@ -136,8 +136,8 @@ public function listAll( public function delete(string $code, Office $office): AssetMethod { $assetMethod = self::get($code, $office); - - if ($assetMethod->getResult() == 1) { + + if ($assetMethod->getResult() == 1) { $assetMethod->setStatusFromString("deleted"); try { diff --git a/src/ApiConnectors/CostCenterApiConnector.php b/src/ApiConnectors/CostCenterApiConnector.php index 3ed5a290..cf46c073 100644 --- a/src/ApiConnectors/CostCenterApiConnector.php +++ b/src/ApiConnectors/CostCenterApiConnector.php @@ -124,7 +124,7 @@ public function listAll( return $this->mapListAll("CostCenter", $response->data, $costCenterArrayListAllTags); } - + /** * Deletes a specific CostCenter based off the passed in code and optionally the office. * @@ -137,8 +137,8 @@ public function listAll( public function delete(string $code, Office $office): CostCenter { $costCenter = self::get($code, $office); - - if ($costCenter->getResult() == 1) { + + if ($costCenter->getResult() == 1) { $costCenter->setStatusFromString("deleted"); try { diff --git a/src/ApiConnectors/CustomerApiConnector.php b/src/ApiConnectors/CustomerApiConnector.php index e4688635..9b459383 100644 --- a/src/ApiConnectors/CustomerApiConnector.php +++ b/src/ApiConnectors/CustomerApiConnector.php @@ -137,8 +137,8 @@ public function listAll( public function delete(string $code, Office $office): Customer { $customer = self::get($code, $office); - - if ($customer->getResult() == 1) { + + if ($customer->getResult() == 1) { $customer->setStatusFromString("deleted"); try { diff --git a/src/ApiConnectors/ElectronicBankStatementApiConnector.php b/src/ApiConnectors/ElectronicBankStatementApiConnector.php index 7f9a1c5e..2fe46275 100644 --- a/src/ApiConnectors/ElectronicBankStatementApiConnector.php +++ b/src/ApiConnectors/ElectronicBankStatementApiConnector.php @@ -35,7 +35,6 @@ public function sendAll(array $statements): void $responses = []; foreach ($this->getProcessXmlService()->chunk($statements) as $chunk) { - $document = new ElectronicBankStatementDocument(); foreach ($chunk as $statement) { @@ -49,4 +48,4 @@ public function sendAll(array $statements): void $response->assertSuccessful(); } } -} +} \ No newline at end of file diff --git a/src/ApiConnectors/MatchesApiConnector.php b/src/ApiConnectors/MatchesApiConnector.php index c0f87984..ddc74fa4 100644 --- a/src/ApiConnectors/MatchesApiConnector.php +++ b/src/ApiConnectors/MatchesApiConnector.php @@ -22,7 +22,9 @@ class MatchesApiConnector extends BaseApiConnector */ public function send(MatchSet $matchSet): MatchSet { - return $this->sendAll([$matchSet])[0]->unwrap(); + foreach($this->sendAll([$matchSet]) as $each) { + return $each->unwrap(); + } } /** @@ -38,7 +40,6 @@ public function sendAll(array $matchSets): MappedResponseCollection $responses = []; foreach ($this->getProcessXmlService()->chunk($matchSets) as $chunk) { - $document = new MatchDocument(); foreach ($chunk as $matchSet) { @@ -52,4 +53,4 @@ public function sendAll(array $matchSets): MappedResponseCollection return MatchSetMapper::map($subResponse->getResponseDocument()); }); } -} +} \ No newline at end of file diff --git a/src/ApiConnectors/ProjectApiConnector.php b/src/ApiConnectors/ProjectApiConnector.php index 455a1a5d..8d62dc81 100644 --- a/src/ApiConnectors/ProjectApiConnector.php +++ b/src/ApiConnectors/ProjectApiConnector.php @@ -124,7 +124,7 @@ public function listAll( return $this->mapListAll("Project", $response->data, $projectListAllTags); } - + /** * Deletes a specific Project based off the passed in code and optionally the office. * @@ -137,8 +137,8 @@ public function listAll( public function delete(string $code, Office $office): Project { $project = self::get($code, $office); - - if ($project->getResult() == 1) { + + if ($project->getResult() == 1) { $project->setStatusFromString("deleted"); try { diff --git a/src/ApiConnectors/RateApiConnector.php b/src/ApiConnectors/RateApiConnector.php index 18301fa8..8859ace7 100644 --- a/src/ApiConnectors/RateApiConnector.php +++ b/src/ApiConnectors/RateApiConnector.php @@ -123,7 +123,7 @@ public function listAll( return $this->mapListAll("Rate", $response->data, $rateListAllTags); } - + /** * Deletes a specific Rate based off the passed in code and optionally the office. * @@ -136,8 +136,8 @@ public function listAll( public function delete(string $code, Office $office): Rate { $rate = self::get($code, $office); - - if ($rate->getResult() == 1) { + + if ($rate->getResult() == 1) { $rate->setStatusFromString("deleted"); try { diff --git a/src/ApiConnectors/SupplierApiConnector.php b/src/ApiConnectors/SupplierApiConnector.php index b5596ed3..6a0b18b1 100644 --- a/src/ApiConnectors/SupplierApiConnector.php +++ b/src/ApiConnectors/SupplierApiConnector.php @@ -124,7 +124,7 @@ public function listAll( return $this->mapListAll("Supplier", $response->data, $supplierListAllTags); } - + /** * Deletes a specific Supplier based off the passed in code and optionally the office. * @@ -137,8 +137,8 @@ public function listAll( public function delete(string $code, Office $office): Supplier { $supplier = self::get($code, $office); - - if ($supplier->getResult() == 1) { + + if ($supplier->getResult() == 1) { $supplier->setStatusFromString("deleted"); try { diff --git a/src/ApiConnectors/TransactionApiConnector.php b/src/ApiConnectors/TransactionApiConnector.php index 6e409caa..b953363f 100644 --- a/src/ApiConnectors/TransactionApiConnector.php +++ b/src/ApiConnectors/TransactionApiConnector.php @@ -32,12 +32,8 @@ class TransactionApiConnector extends BaseApiConnector * @throws Exception * @return BaseTransaction */ - public function get( - string $transactionClassName, - string $code, - string $transactionNumber, - Office $office - ): BaseTransaction { + public function get(string $transactionClassName, string $code, string $transactionNumber, Office $office): BaseTransaction + { // Make a request to read a single transaction $request_transaction = new Request\Read\Transaction(); $request_transaction @@ -76,14 +72,10 @@ public function sendAll(array $transactions): MappedResponseCollection $classname = get_class(reset($transactions)); - /* - * We can have multiple documents sent, so we need to collect all documents. - */ /** @var Response[] $responses */ $responses = []; foreach ($this->getProcessXmlService()->chunk($transactions) as $chunk) { - $transactionsDocument = new TransactionsDocument(); foreach ($chunk as $transaction) { @@ -93,12 +85,8 @@ public function sendAll(array $transactions): MappedResponseCollection $responses[] = $this->sendXmlDocument($transactionsDocument); } - return $this->getProcessXmlService()->mapAll( - $responses, - "transaction", - function (Response $subresponse) use ($classname): BaseTransaction { - return TransactionMapper::map($classname, $subresponse); - } - ); + return $this->getProcessXmlService()->mapAll($responses, "transaction", function (Response $subresponse) use ($classname): BaseTransaction { + return TransactionMapper::map($classname, $subresponse); + }); } } \ No newline at end of file diff --git a/src/ApiConnectors/VatCodeApiConnector.php b/src/ApiConnectors/VatCodeApiConnector.php index 1776d721..56403556 100644 --- a/src/ApiConnectors/VatCodeApiConnector.php +++ b/src/ApiConnectors/VatCodeApiConnector.php @@ -123,7 +123,7 @@ public function listAll( return $this->mapListAll("VatCode", $response->data, $vatCodeListAllTags); } - + /** * Deletes a specific VatCode based off the passed in code and optionally the office. * @@ -136,8 +136,8 @@ public function listAll( public function delete(string $code, Office $office): VatCode { $vatCode = self::get($code, $office); - - if ($vatCode->getResult() == 1) { + + if ($vatCode->getResult() == 1) { $vatCode->setStatusFromString("deleted"); try { diff --git a/src/Article.php b/src/Article.php index ce600a12..783a5822 100644 --- a/src/Article.php +++ b/src/Article.php @@ -12,9 +12,9 @@ use PhpTwinfield\Fields\Invoice\Article\TypeField; use PhpTwinfield\Fields\Invoice\Article\UnitNamePluralField; use PhpTwinfield\Fields\Invoice\Article\UnitNameSingularField; -use PhpTwinfield\Fields\Invoice\PerformanceTypeField; use PhpTwinfield\Fields\NameField; use PhpTwinfield\Fields\OfficeField; +use PhpTwinfield\Fields\PerformanceTypeField; use PhpTwinfield\Fields\ShortNameField; use PhpTwinfield\Fields\StatusField; use PhpTwinfield\Fields\VatCodeField; @@ -64,10 +64,10 @@ public function addLine(ArticleLine $line) return $this; } - public function removeLine($index) + public function removeLine($id) { - if (array_key_exists($index, $this->lines)) { - unset($this->lines[$index]); + if (array_key_exists($id, $this->lines)) { + unset($this->lines[$id]); return true; } else { return false; diff --git a/src/AssetMethod.php b/src/AssetMethod.php index b69c2ef1..820b1923 100644 --- a/src/AssetMethod.php +++ b/src/AssetMethod.php @@ -40,6 +40,7 @@ class AssetMethod extends BaseObject private $balanceAccounts; private $profitLossAccounts; + private $freeTexts = []; public function __construct() @@ -81,10 +82,10 @@ public function addFreeText(AssetMethodFreeText $freeText) return $this; } - public function removeFreeText($index) + public function removeFreeText($id) { - if (array_key_exists($index, $this->freeTexts)) { - unset($this->freeTexts[$index]); + if (array_key_exists($id, $this->freeTexts)) { + unset($this->freeTexts[$id]); return true; } else { return false; diff --git a/src/BankTransaction.php b/src/BankTransaction.php index ff2085d3..f84a731f 100644 --- a/src/BankTransaction.php +++ b/src/BankTransaction.php @@ -2,30 +2,29 @@ namespace PhpTwinfield; -use Money\Currency; -use Money\Money; +use PhpTwinfield\BankTransactionLine; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\LineType; -use PhpTwinfield\Transactions\TransactionFields\StartAndCloseValueFields; -use PhpTwinfield\Transactions\TransactionFields\StatementNumberField; -use PhpTwinfield\Transactions\TransactionLine; +use PhpTwinfield\Fields\Transaction\CloseValueField; +use PhpTwinfield\Fields\Transaction\StartValueField; +use PhpTwinfield\Fields\Transaction\StatementNumberField; -/** +/* * @link https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankTransactions */ class BankTransaction extends BaseTransaction { + use CloseValueField; + use StartValueField; use StatementNumberField; - use StartAndCloseValueFields { - setCurrency as protected traitSetCurrency; - } public function __construct() { - $this->startvalue = new Money(0, new Currency('EUR')); + $this->closeValue = new \Money\Money(0, new \Money\Currency('EUR')); + $this->startValue = new \Money\Money(0, new \Money\Currency('EUR')); } - /** + /* * @return string */ public function getLineClassName(): string @@ -33,35 +32,23 @@ public function getLineClassName(): string return BankTransactionLine::class; } - /** - * Set the currency. Can only be done when the start value is still 0. - * - * @param Currency $currency - * @return $this - */ - public function setCurrency(?Currency $currency): BaseTransaction - { - $this->traitSetCurrency($currency); - return $this; - } - - /** - * @param TransactionLine $line + /* + * @param BankTransactionLine $line * @return $this */ - public function addLine(TransactionLine $line) + public function addLine(BankTransactionLine $line) { parent::addLine($line); - /** @var BankTransactionLine $line */ + /* @var BankTransactionLine $line */ if (!$line->getLineType()->equals(LineType::TOTAL())) { /* - * Don't add total lines to the closevalue, they are summaries of the details and vat lines. + * Don't add total lines to the close value, they are summaries of the details and vat lines. */ if ($line->getDebitCredit()->equals(DebitCredit::CREDIT())) { - $this->closevalue = $this->getClosevalue()->add($line->getValue()); + $this->closeValue = $this->getCloseValue()->add($line->getValue()); } else { - $this->closevalue = $this->getClosevalue()->subtract($line->getValue()); + $this->closeValue = $this->getCloseValue()->subtract($line->getValue()); } } diff --git a/src/BankTransactionLine.php b/src/BankTransactionLine.php index 24aa0c91..4de4abe7 100644 --- a/src/BankTransactionLine.php +++ b/src/BankTransactionLine.php @@ -3,27 +3,36 @@ namespace PhpTwinfield; use Money\Money; -use PhpTwinfield\Enums\DebitCredit; +use PhpTwinfield\Dummy; use PhpTwinfield\Enums\LineType; -use PhpTwinfield\Transactions\TransactionFields\InvoiceNumberField; -use PhpTwinfield\Transactions\TransactionLineFields\PerformanceFields; -use PhpTwinfield\Transactions\TransactionLineFields\VatTotalFields; +use PhpTwinfield\Enums\PerformanceType; +use PhpTwinfield\Fields\PerformanceDateField; +use PhpTwinfield\Fields\PerformanceTypeField; +use PhpTwinfield\Fields\Transaction\TransactionLine\CurrencyDateField; +use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceCountryField; +use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceVatNumberField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatBaseTotalField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatRepTotalField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatTotalField; use Webmozart\Assert\Assert; class BankTransactionLine extends BaseTransactionLine { - use VatTotalFields; - use PerformanceFields; - use InvoiceNumberField { - setInvoiceNumber as traitSetInvoiceNumber; - } + use CurrencyDateField; + use PerformanceCountryField; + use PerformanceDateField; + use PerformanceTypeField; + use PerformanceVatNumberField; + use VatBaseTotalField; + use VatRepTotalField; + use VatTotalField; - /** + /* * @var BankTransaction */ private $transaction; - /** + /* * @param BankTransaction $object */ public function setTransaction($object): void @@ -33,7 +42,7 @@ public function setTransaction($object): void $this->transaction = $object; } - /** + /* * References the transaction this line belongs too. * * @return BankTransaction @@ -43,222 +52,249 @@ public function getTransaction(): BankTransaction return $this->transaction; } - /** - * If line type = total the bank balance account. - * - * If line type = detail the customer or supplier balance account or profit and loss account. + /* + * Only if line type is detail. The amount still owed in base currency. Read-only attribute. * - * If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account - * will be taken as entered at the VAT code in Twinfield. + * @param Money|null $baseValueOpen + * @return $this + * @throws Exception + */ + public function setBaseValueOpen(?Money $baseValueOpen): parent + { + if ($baseValueOpen !== null && !$this->getLineType()->equals(LineType::DETAIL())) { + throw Exception::invalidFieldForLineType('baseValueOpen', $this); + } + + return parent::setBaseValueOpen($baseValueOpen); + } + + /* + * Only if line type is detail. The line date. Only allowed if the line date in the bank book is set to Allowed or Mandatory. * - * @param string|null $dim1 + * @param \DateTimeInterface|null $currencyDate * @return $this + * @throws Exception */ - public function setDim1(?string $dim1): BaseTransactionLine + public function setCurrencyDate(?\DateTimeInterface $currencyDate): self { - return parent::setDim1($dim1); + if ($currencyDate !== null && !$this->getLineType()->equals(LineType::DETAIL())) { + throw Exception::invalidFieldForLineType('currencyDate', $this); + } + + return parent::setCurrencyDate($currencyDate); } - /** + /* * If line type = total empty. * * If line type = detail the customer or supplier or the cost center or empty. * * If line type = vat empty. * - * @param string|null $dim2 + * @param Dummy|null $dim2 * @return $this * @throws Exception */ - public function setDim2(?string $dim2): BaseTransactionLine + public function setDim2(?Dummy $dim2): parent { - if ($dim2 !== null && - ($this->getLineType()->equals(LineType::VAT()) || $this->getLineType()->equals(LineType::TOTAL()))) { + if ($dim2 !== null && ($this->getLineType()->equals(LineType::VAT()) || $this->getLineType()->equals(LineType::TOTAL()))) { throw Exception::invalidDimensionForLineType(2, $this); } return parent::setDim2($dim2); } - /** + /* * If line type = total empty. * * If line type = detail the project or asset or empty. * * If line type = vat empty. * - * @param string|null $dim3 + * @param Dummy|null $dim3 * @return $this * @throws Exception */ - public function setDim3(?string $dim3): BaseTransactionLine + public function setDim3(?Dummy $dim3): parent { - if ($dim3 !== null && - ($this->getLineType()->equals(LineType::VAT()) || $this->getLineType()->equals(LineType::TOTAL()))) { + if ($dim3 !== null && ($this->getLineType()->equals(LineType::VAT()) || $this->getLineType()->equals(LineType::TOTAL()))) { throw Exception::invalidDimensionForLineType(3, $this); } return parent::setDim3($dim3); } - /** - * If line type = total, based on the sum of the individual bank transaction lines. - * - In case of a bank addition debit. - * - In case of a bank withdrawal credit. + /* + * Returns true if a positive amount in the TOTAL line means the amount is 'debit'. Examples of incoming transaction + * types are Sales Transactions, Electronic Bank Statements and Bank Transactions. * - * If line type = detail - * - In case money is received credit. - * - In case money is paid debit. + * Returns false if a positive amount in the TOTAL line means the amount is 'credit'. An example of an outgoing + * transaction type is a Purchase Transaction. * - * If line type = vat, based on the sum of the vat amounts of the individual bank transaction lines. - * - In case of a bank addition credit. - * - In case of a bank withdrawal debit. + * @return bool + */ + protected function isIncomingTransactionType(): bool + { + return true; + } + + /* + * Only if line type is detail. The level of the matchable dimension. Read-only attribute. * - * @param DebitCredit::DEBIT() $debitCredit + * @param int|null $matchLevel * @return $this + * @throws Exception */ - public function setDebitCredit(DebitCredit $debitCredit): BaseTransactionLine + public function setMatchLevel(?int $matchLevel): parent { - return parent::setDebitCredit($debitCredit); + if ($matchLevel !== null && !$this->getLineType()->equals(LineType::DETAIL())) { + throw Exception::invalidFieldForLineType('matchLevel', $this); + } + + return parent::setMatchLevel($matchLevel); } - /** - * If line type = total amount including VAT. - * - * If line type = detail amount without VAT. - * - * If line type = vat VAT amount. + /* + * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The performance type. * - * @param Money $value + * @param PerformanceType|null $performanceType * @return $this + * @throws Exception */ - public function setValue(Money $value): BaseTransactionLine + public function setPerformanceType(?PerformanceType $performanceType): self { - return parent::setValue($value); + if ($performanceType !== null && $this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('performanceType', $this); + } + + return parent::setPerformanceType($performanceType); } - /** - * Payment status of the bank transaction. If line type total or vat always notmatchable. Read-only attribute. + /* + * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The ISO country codes are used. If not added to the request, by default the country code of the customer will be taken. * - * @param string|null $matchStatus + * @param Country|null $performanceCountry * @return $this * @throws Exception */ - public function setMatchStatus(?string $matchStatus): BaseTransactionLine + public function setPerformanceCountry(?Country $performanceCountry): self { - if ( - $matchStatus !== null && - in_array($this->getLineType(), [LineType::TOTAL(), LineType::VAT()]) && - $matchStatus != self::MATCHSTATUS_NOTMATCHABLE - ) { - throw Exception::invalidMatchStatusForLineType($matchStatus, $this); + if ($performanceCountry !== null && $this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('performanceCountry', $this); } - return parent::setMatchStatus($matchStatus); + return parent::setPerformanceCountry($performanceCountry); } - /** - * Only if line type is detail. The level of the matchable dimension. Read-only attribute. + /* + * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. If not added to the request, by default the VAT number of the customer will be taken. * - * @param int|null $matchLevel + * @param string|null $performanceVatNumber * @return $this * @throws Exception */ - public function setMatchLevel(?int $matchLevel): BaseTransactionLine + public function setPerformanceVatNumber(?string $performanceVatNumber): self { - if ($matchLevel !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('matchLevel', $this); + if ($performanceVatNumber !== null && $this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('performanceVatNumber', $this); } - return parent::setMatchLevel($matchLevel); + return parent::setPerformanceVatNumber($performanceVatNumber); } - /** - * Only if line type is detail. The amount still owed in base currency. Read-only attribute. + /* + * Only if line type is detail or vat. Mandatory in case of an ICT VAT code but only if performancetype is services. * - * @param Money|null $baseValueOpen + * @param \DateTimeInterface|null $performanceDate * @return $this * @throws Exception */ - public function setBaseValueOpen(?Money $baseValueOpen): BaseTransactionLine + public function setPerformanceDate(?\DateTimeInterface $performanceDate): self { - if ($baseValueOpen !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('baseValueOpen', $this); + if ($performanceDate !== null && (!$this->getPerformanceType()->equals(PerformanceType::SERVICES()) || $this->getLineType()->equals(LineType::TOTAL()))) { + throw Exception::invalidFieldForLineType('performanceDate', $this); } - return parent::setBaseValueOpen($baseValueOpen); + return parent::setPerformanceDate($performanceDate); } - /** - * Only if line type is vat. Amount on which VAT was calculated in the currency of the sales transaction. + /* + * Relation of the transaction. Only if line type is detail. Read-only attribute. * - * @param Money|null $vatTurnover + * @param string|null $relation * @return $this * @throws Exception */ - public function setVatTurnover(?Money $vatTurnover): BaseTransactionLine + public function setRelation(?string $relation): parent { - if (!$this->getLineType()->equals(LineType::VAT())) { - throw Exception::invalidFieldForLineType('vatturnover', $this); + if ($relation !== null && !$this->getLineType()->equals(LineType::DETAIL())) { + throw Exception::invalidRelationForLineType($relation, $this); } - return parent::setVatTurnOver($vatTurnover); + + return $this; } - /** - * Only if line type is vat. Amount on which VAT was calculated in base currency. + /* + * Only if line type is detail. The amount still owed in reporting currency. Read-only attribute. * - * @param Money|null $vatBaseTurnover + * @param Money|null $repValueOpen * @return $this * @throws Exception */ - public function setVatBaseTurnover(?Money $vatBaseTurnover): BaseTransactionLine + public function setRepValueOpen(?Money $repValueOpen): parent { - if (!$this->getLineType()->equals(LineType::VAT())) { - throw Exception::invalidFieldForLineType('vatbaseturnover', $this); + if ($repValueOpen !== null && !$this->getLineType()->equals(LineType::DETAIL())) { + throw Exception::invalidFieldForLineType('repValueOpen', $this); } - return parent::setVatBaseTurnover($vatBaseTurnover); + + return parent::setRepValueOpen($repValueOpen); } - /** - * Only if line type is vat. Amount on which VAT was calculated in reporting currency. + /* + * Only if line type is total. The total VAT amount in the currency of the bank transaction * - * @param Money|null $vatRepTurnover + * @param Money|null $vatValueOpen * @return $this * @throws Exception */ - public function setVatRepTurnover(?Money $vatRepTurnover): BaseTransactionLine + public function setVatValueOpen(?Money $vatValueOpen): parent { - if (!$this->getLineType()->equals(LineType::VAT())) { - throw Exception::invalidFieldForLineType('vatrepturnover', $this); + if ($vatValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatValueOpen', $this); } - return parent::setVatRepTurnover($vatRepTurnover); + + return parent::setVatValueOpen($vatValueOpen); } - /** - * @param string|null $invoiceNumber + /* + * Only if line type is total. The total VAT amount in base currency. + * + * @param Money|null $vatBaseValueOpen * @return $this * @throws Exception */ - public function setInvoiceNumber(?string $invoiceNumber) + public function setVatBaseValueOpen(?Money $vatBaseValueOpen): parent { - if (!$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('invoicenumber', $this); + if ($vatBaseValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatBaseValueOpen', $this); } - return $this->traitSetInvoiceNumber($invoiceNumber); + return parent::setVatBaseValueOpen($vatBaseValueOpen); } - /** - * Returns true if a positive amount in the TOTAL line means the amount is 'debit'. Examples of incoming transaction - * types are Sales Transactions, Electronic Bank Statements and Bank Transactions. + /* + * Only if line type is total. The total VAT amount in reporting currency. * - * Returns false if a positive amount in the TOTAL line means the amount is 'credit'. An example of an outgoing - * transaction type is a Purchase Transaction. - * - * @return bool + * @param Money|null $vatRepValueOpen + * @return $this + * @throws Exception */ - protected function isIncomingTransactionType(): bool + public function setVatRepValueOpen(?Money $vatRepValueOpen): parent { - return true; + if ($vatRepValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatRepValueOpen', $this); + } + + return parent::setVatRepValueOpen($vatRepValueOpen); } } diff --git a/src/BaseTransaction.php b/src/BaseTransaction.php index 00db0a78..31f840f5 100644 --- a/src/BaseTransaction.php +++ b/src/BaseTransaction.php @@ -2,78 +2,53 @@ namespace PhpTwinfield; -use Money\Currency; -use PhpTwinfield\Transactions\Transaction; -use PhpTwinfield\Transactions\TransactionFields\AutoBalanceVatField; -use PhpTwinfield\Transactions\TransactionFields\CodeNumberOfficeFields; -use PhpTwinfield\Transactions\TransactionFields\DestinyField; -use PhpTwinfield\Transactions\TransactionFields\FreeTextFields; -use PhpTwinfield\Transactions\TransactionFields\LinesField; -use PhpTwinfield\Transactions\TransactionFields\RaiseWarningField; -use PhpTwinfield\Transactions\TransactionLineFields\DateField; -use PhpTwinfield\Transactions\TransactionLineFields\PeriodField; - -/** - * @todo $modificationDate The date/time on which the transaction was modified the last time. Read-only attribute. - * @todo $user The user who created the transaction. Read-only attribute. - * @todo $inputDate The date/time on which the transaction was created. Read-only attribute. - */ -abstract class BaseTransaction extends BaseObject implements Transaction +use PhpTwinfield\BookingReference; +use PhpTwinfield\Fields\CodeField; +use PhpTwinfield\Fields\CurrencyField; +use PhpTwinfield\Fields\DateField; +use PhpTwinfield\Fields\FreeText1Field; +use PhpTwinfield\Fields\FreeText2Field; +use PhpTwinfield\Fields\FreeText3Field; +use PhpTwinfield\Fields\OfficeField; +use PhpTwinfield\Fields\PeriodField; +use PhpTwinfield\Fields\Transaction\AutoBalanceVatField; +use PhpTwinfield\Fields\Transaction\DateRaiseWarningField; +use PhpTwinfield\Fields\Transaction\DestinyField; +use PhpTwinfield\Fields\Transaction\InputDateField; +use PhpTwinfield\Fields\Transaction\LinesField; +use PhpTwinfield\Fields\Transaction\ModificationDateField; +use PhpTwinfield\Fields\Transaction\NumberField; +use PhpTwinfield\Fields\Transaction\OriginField; +use PhpTwinfield\Fields\Transaction\RaiseWarningField; +use PhpTwinfield\Fields\UserField; +use PhpTwinfield\MatchReferenceInterface; + +abstract class BaseTransaction extends BaseObject { use AutoBalanceVatField; - use CodeNumberOfficeFields; + use CodeField; + use CurrencyField; + use DateField; + use DateRaiseWarningField; use DestinyField; - use FreeTextFields; + use FreeText1Field; + use FreeText2Field; + use FreeText3Field; + use InputDateField; use LinesField; - use RaiseWarningField; - use DateField; + use ModificationDateField; + use NumberField; + use OfficeField; + use OriginField; use PeriodField; + use RaiseWarningField; - /** - * @var Currency|null The currency. - */ - private $currency; - - /** - * @var string|null The sales transaction origin. Read-only attribute. - */ - private $origin; - - /** - * @return Currency|null - */ - public function getCurrency(): ?Currency - { - return $this->currency; - } - - /** - * @param Currency|null $currency - * @return $this - */ - public function setCurrency(?Currency $currency): BaseTransaction - { - $this->currency = $currency; - - return $this; - } - - /** - * @return string|null - */ - public function getOrigin(): ?string - { - return $this->origin; - } - - /** - * @param string|null $origin - * @return $this - */ - public function setOrigin(?string $origin): BaseTransaction + public function getBookingReference(): BookingReference { - $this->origin = $origin; - - return $this; + return new BookingReference( + $this->office, + $this->code, + $this->number + ); } -} +} \ No newline at end of file diff --git a/src/BaseTransactionLine.php b/src/BaseTransactionLine.php index 85c6092a..f35ed65a 100644 --- a/src/BaseTransactionLine.php +++ b/src/BaseTransactionLine.php @@ -4,338 +4,197 @@ use Money\Money; use PhpTwinfield\Enums\LineType; -use PhpTwinfield\Transactions\TransactionLine; -use PhpTwinfield\Transactions\TransactionLineFields\CommentField; -use PhpTwinfield\Transactions\TransactionLineFields\FreeCharField; -use PhpTwinfield\Transactions\TransactionLineFields\ThreeDimFields; -use PhpTwinfield\Transactions\TransactionLineFields\ValueFields; -use PhpTwinfield\Transactions\TransactionLineFields\VatTurnoverFields; - -/** - * @todo $relation Only if line type is total (or detail for Journal and Cash transactions). Read-only attribute. - * @todo $repValueOpen Meaning differs per transaction type. Read-only attribute. - * @todo $vatBaseValue Only if line type is detail. VAT amount in base currency. - * @todo $vatRepValue Only if line type is detail. VAT amount in reporting currency. - * @todo $destOffice Office code. Used for inter company transactions. - * @todo $comment Comment set on the transaction line. - * @todo $matches Contains matching information. Read-only attribute. - * - * @link https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankTransactions - */ -abstract class BaseTransactionLine implements TransactionLine +use PhpTwinfield\Enums\MatchStatus; +use PhpTwinfield\Fields\CommentField; +use PhpTwinfield\Fields\DescriptionField; +use PhpTwinfield\Fields\Dim2Field; +use PhpTwinfield\Fields\Dim3Field; +use PhpTwinfield\Fields\IDField; +use PhpTwinfield\Fields\LineTypeField; +use PhpTwinfield\Fields\Transaction\TransactionLine\BaseValueField; +use PhpTwinfield\Fields\Transaction\TransactionLine\BaseValueOpenField; +use PhpTwinfield\Fields\Transaction\TransactionLine\DestOfficeField; +use PhpTwinfield\Fields\Transaction\TransactionLine\Dim1Field; +use PhpTwinfield\Fields\Transaction\TransactionLine\FreeCharField; +use PhpTwinfield\Fields\Transaction\TransactionLine\MatchLevelField; +use PhpTwinfield\Fields\Transaction\TransactionLine\MatchStatusField; +use PhpTwinfield\Fields\Transaction\TransactionLine\RateField; +use PhpTwinfield\Fields\Transaction\TransactionLine\RelationField; +use PhpTwinfield\Fields\Transaction\TransactionLine\RepRateField; +use PhpTwinfield\Fields\Transaction\TransactionLine\RepValueField; +use PhpTwinfield\Fields\Transaction\TransactionLine\RepValueOpenField; +use PhpTwinfield\Fields\Transaction\TransactionLine\ValueFields; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatBaseTurnoverField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatBaseValueField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatRepTurnoverField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatRepValueField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatTurnoverField; +use PhpTwinfield\Fields\VatCodeField; +use PhpTwinfield\Fields\VatValueField; + +abstract class BaseTransactionLine { - use ValueFields; - use ThreeDimFields; - use VatTurnoverFields; + use BaseValueField; + use BaseValueOpenField; use CommentField; + use DescriptionField; + use DestOfficeField; + use Dim1Field; + use Dim2Field; + use Dim3Field; use FreeCharField; - - public const MATCHSTATUS_AVAILABLE = 'available'; - public const MATCHSTATUS_MATCHED = 'matched'; - public const MATCHSTATUS_PROPOSED = 'proposed'; - public const MATCHSTATUS_NOTMATCHABLE = 'notmatchable'; - - // Used in PerformanceFields trait. - const PERFORMANCETYPE_SERVICES = 'services'; - const PERFORMANCETYPE_GOODS = 'goods'; - - /** - * @var LineType - */ - protected $lineType; - - /** - * @var int|null The line ID. - */ - protected $id; - - /** - * @var Money|null Amount in the base currency. - * @todo This field is currently read-only in this library. - */ - protected $baseValue; - - /** - * @var int|null - */ - private $baseline; - - /** - * @var float|null The exchange rate used for the calculation of the base amount. - * @todo This field is currently read-only in this library. - */ - protected $rate; - - /** - * @var Money|null Amount in the reporting currency. - * @todo This field is currently read-only in this library. - */ - protected $repValue; - - /** - * @var float|null The exchange rate used for the calculation of the reporting amount. - * @todo This field is currently read-only in this library. - */ - protected $repRate; - - /** - * @var string|null Description of the transaction line. Max length is 40 characters. - */ - protected $description; - - /** - * @var string|null Payment status of the transaction. One of the self::MATCHSTATUS_* constants. Read-only - * attribute. There are some restrictions for possible values depending on the sub class. See - * explanation in the sub classes. - */ - protected $matchStatus; - - /** - * @var int|null The level of the matchable dimension. Read-only attribute. Only available for some line types, - * depending on the sub class. See the explanation in sub classes. - */ - protected $matchLevel; - - /** - * @var Money|null Meaning differs per transaction type. Read-only attribute. See explanatio in the sub classes. - */ - protected $baseValueOpen; - - /** - * @var string|null Only if line type is detail or vat. VAT code. - */ - protected $vatCode; - - /** - * @var Money|null Only if line type is detail. VAT amount in the currency of the transaction. - */ - protected $vatValue; - - public function getLineType(): LineType - { - return $this->lineType; - } - - /** - * @param LineType $lineType - * @return $this - */ - public function setLineType(LineType $lineType): BaseTransactionLine - { - $this->lineType = $lineType; - - return $this; - } - - /** - * @return int|null - */ - public function getId(): ?int - { - return $this->id; - } - - /** - * @param int|null $id - * @return $this + use IDField; + use LineTypeField; + use MatchLevelField; + use MatchStatusField; + use RateField; + use RelationField; + use RepRateField; + use RepValueField; + use RepValueOpenField; + use ValueFields; + use VatBaseTurnoverField; + use VatBaseValueField; + use VatCodeField; + use VatRepTurnoverField; + use VatRepValueField; + use VatTurnoverField; + use VatValueField; + + /* + * This will get you a unique reference to the object in Twinfield. + * + * With this reference, you can perform matching. + * + * @return MatchReferenceInterface */ - public function setId(?int $id): BaseTransactionLine + public function getReference(): MatchReferenceInterface { - $this->id = $id; - - return $this; - } + /* @var BankTransaction|CashTransaction|JournalTransaction|PurchaseTransaction|SalesTransaction $transaction */ + $transaction = $this->getTransaction(); - /** - * @return Money|null - */ - public function getBaseValue(): ?Money - { - return $this->baseValue; + return new MatchReference( + $transaction->getOffice(), + $transaction->getCode(), + $transaction->getNumber(), + $this->getId() + ); } - /** - * @param Money|null $baseValue + /* + * Payment status of the transaction. If line type total or vat always notmatchable. Read-only attribute. + * + * @param MatchStatus|null $matchStatus * @return $this + * @throws Exception */ - public function setBaseValue(?Money $baseValue): BaseTransactionLine + public function setMatchStatus(?MatchStatus $matchStatus): self { - $this->baseValue = $baseValue; + if ($matchStatus !== null && in_array($this->getLineType(), [LineType::TOTAL(), LineType::VAT()]) && $matchStatus != MatchStatus::NOTMATCHABLE()) { + throw Exception::invalidMatchStatusForLineType($matchStatus, $this); + } return $this; } - /** - * @return float|null - */ - public function getRate(): ?float - { - return $this->rate; - } - - /** - * @param float|null $rate + /* + * Only if line type is vat. Amount on which VAT was calculated in base currency. + * + * @param Money|null $vatBaseTurnover * @return $this + * @throws Exception */ - public function setRate(?float $rate): BaseTransactionLine - { - $this->rate = $rate; - - return $this; - } - - /** - * @return Money|null - */ - public function getRepValue(): ?Money + public function setVatBaseTurnover(?Money $vatBaseTurnover): self { - return $this->repValue; + if (!$this->getLineType()->equals(LineType::VAT())) { + throw Exception::invalidFieldForLineType('vatbaseturnover', $this); + } + return parent::setVatBaseTurnover($vatBaseTurnover); } - /** - * @param Money|null $repValue + /* + * @param Money|null $vatBaseValue * @return $this + * @throws Exception */ - public function setRepValue(?Money $repValue): BaseTransactionLine - { - $this->repValue = $repValue; - - return $this; - } - - /** - * @return float|null - */ - public function getRepRate(): ?float + public function setVatBaseValue(?Money $vatBaseValue): self { - return $this->repRate; - } + if ($vatBaseValue !== null && !$this->getLineType()->equals(LineType::DETAIL())) { + throw Exception::invalidFieldForLineType('vatBaseValue', $this); + } - /** - * @param float|null $repRate - * @return $this - */ - public function setRepRate(?float $repRate): BaseTransactionLine - { - $this->repRate = $repRate; + $this->vatBaseValue = $vatBaseValue; return $this; } - /** - * @return string|null - */ - public function getDescription(): ?string - { - return $this->description; - } - - /** - * @param string|null $description + /* + * @param VatCode|null $vatCode * @return $this + * @throws Exception */ - public function setDescription(?string $description): BaseTransactionLine + public function setVatCode(?VatCode $vatCode): self { - $this->description = $description; + if ($vatCode !== null && !in_array($this->getLineType(), [LineType::DETAIL(), LineType::VAT()])) { + throw Exception::invalidFieldForLineType('vatCode', $this); + } + $this->vatCode = $vatCode; return $this; } - /** - * @return string|null - */ - public function getMatchStatus(): ?string - { - return $this->matchStatus; - } - - /** - * @param string|null $matchStatus + /* + * Only if line type is vat. Amount on which VAT was calculated in reporting currency. + * + * @param Money|null $vatRepTurnover * @return $this + * @throws Exception */ - public function setMatchStatus(?string $matchStatus): BaseTransactionLine - { - $this->matchStatus = $matchStatus; - - return $this; - } - - /** - * @return int|null - */ - public function getMatchLevel(): ?int + public function setVatRepTurnover(?Money $vatRepTurnover): self { - return $this->matchLevel; + if (!$this->getLineType()->equals(LineType::VAT())) { + throw Exception::invalidFieldForLineType('vatrepturnover', $this); + } + return parent::setVatRepTurnover($vatRepTurnover); } - /** - * @param int|null $matchLevel + /* + * @param Money|null $vatRepValue * @return $this + * @throws Exception */ - public function setMatchLevel(?int $matchLevel): BaseTransactionLine - { - $this->matchLevel = $matchLevel; - - return $this; - } - - /** - * @return Money|null - */ - public function getBaseValueOpen(): ?Money + public function setVatRepValue(?Money $vatRepValue): self { - return $this->baseValueOpen; - } + if ($vatRepValue !== null && !$this->getLineType()->equals(LineType::DETAIL())) { + throw Exception::invalidFieldForLineType('vatRepValue', $this); + } - /** - * @param Money|null $baseValueOpen - * @return $this - */ - public function setBaseValueOpen(?Money $baseValueOpen): BaseTransactionLine - { - $this->baseValueOpen = $baseValueOpen; + $this->vatRepValue = $vatRepValue; return $this; } - /** - * @return string|null - */ - public function getVatCode(): ?string - { - return $this->vatCode; - } - - /** - * @param string|null $vatCode + /* + * Only if line type is vat. Amount on which VAT was calculated in the currency of the sales transaction. + * + * @param Money|null $vatTurnover * @return $this * @throws Exception */ - public function setVatCode(?string $vatCode): BaseTransactionLine + public function setVatTurnover(?Money $vatTurnover): self { - if ($vatCode !== null && !in_array($this->getLineType(), [LineType::DETAIL(), LineType::VAT()])) { - throw Exception::invalidFieldForLineType('vatCode', $this); + if (!$this->getLineType()->equals(LineType::VAT())) { + throw Exception::invalidFieldForLineType('vatturnover', $this); } - - $this->vatCode = $vatCode; - - return $this; + return parent::setVatTurnover($vatTurnover); } - /** - * @return Money|null - */ - public function getVatValue(): ?Money - { - return !empty($this->vatValue) ? $this->vatValue->absolute() : null; - } - - /** + /* * @param Money|null $vatValue * @return $this * @throws Exception */ - public function setVatValue(?Money $vatValue): BaseTransactionLine + public function setVatValue(?Money $vatValue): self { if ($vatValue !== null && !$this->getLineType()->equals(LineType::DETAIL())) { throw Exception::invalidFieldForLineType('vatValue', $this); @@ -345,43 +204,4 @@ public function setVatValue(?Money $vatValue): BaseTransactionLine return $this; } - - /** - * @return int|null - */ - public function getBaseline(): ?int - { - return $this->baseline; - } - - /** - * @param int|null $baseline - * @return $this - */ - public function setBaseline(?int $baseline) - { - $this->baseline = $baseline; - - return $this; - } - - /** - * This will get you a unique reference to the object in Twinfield. - * - * With this reference, you can perform matching. - * - * @return MatchReferenceInterface - */ - public function getReference(): MatchReferenceInterface - { - /** @var JournalTransaction|PurchaseTransaction|SalesTransaction $transaction */ - $transaction = $this->getTransaction(); - - return new MatchReference( - $transaction->getOffice(), - $transaction->getCode(), - $transaction->getNumber(), - $this->getId() - ); - } } diff --git a/src/BrowseDataHeader.php b/src/BrowseDataHeader.php index 48472db4..7838f9ad 100644 --- a/src/BrowseDataHeader.php +++ b/src/BrowseDataHeader.php @@ -2,10 +2,11 @@ namespace PhpTwinfield; +use PhpTwinfield\Fields\CodeField; + class BrowseDataHeader { - /** @var string */ - private $code; + use CodeField; /** @var string */ private $label; @@ -16,24 +17,6 @@ class BrowseDataHeader /** @var string */ private $type; - /** - * @return string - */ - public function getCode(): string - { - return $this->code; - } - - /** - * @param string $code - * @return BrowseDataHeader - */ - public function setCode(string $code): BrowseDataHeader - { - $this->code = $code; - return $this; - } - /** * @return string */ diff --git a/src/BrowseDataRow.php b/src/BrowseDataRow.php index 4ae7f1b8..bb831a76 100644 --- a/src/BrowseDataRow.php +++ b/src/BrowseDataRow.php @@ -2,13 +2,13 @@ namespace PhpTwinfield; +use PhpTwinfield\Fields\CodeField; +use PhpTwinfield\Fields\OfficeField; + class BrowseDataRow { - /** @var Office */ - private $office; - - /** @var string */ - private $code; + use CodeField; + use OfficeField; /** @var int */ private $number; @@ -27,42 +27,6 @@ public function __construct() $this->cells = []; } - /** - * @return Office - */ - public function getOffice(): Office - { - return $this->office; - } - - /** - * @param Office $office - * @return BrowseDataRow - */ - public function setOffice(Office $office): BrowseDataRow - { - $this->office = $office; - return $this; - } - - /** - * @return string - */ - public function getCode(): string - { - return $this->code; - } - - /** - * @param string $code - * @return BrowseDataRow - */ - public function setCode(string $code): BrowseDataRow - { - $this->code = $code; - return $this; - } - /** * @return int */ diff --git a/src/BrowseDefinition.php b/src/BrowseDefinition.php index e63d3fcc..3ba4ecea 100644 --- a/src/BrowseDefinition.php +++ b/src/BrowseDefinition.php @@ -2,20 +2,17 @@ namespace PhpTwinfield; -use PhpTwinfield\Transactions\TransactionFields\OfficeField; +use PhpTwinfield\Fields\CodeField; +use PhpTwinfield\Fields\NameField; +use PhpTwinfield\Fields\OfficeField; +use PhpTwinfield\Fields\ShortNameField; class BrowseDefinition { + use CodeField; + use NameField; use OfficeField; - - /** @var string */ - private $code; - - /** @var string */ - private $name; - - /** @var string */ - private $shortName; + use ShortNameField; /** @var bool */ private $visible; @@ -31,60 +28,6 @@ public function __construct() $this->columns = []; } - /** - * @return string - */ - public function getCode(): string - { - return $this->code; - } - - /** - * @param string $code - * @return BrowseDefinition - */ - public function setCode(string $code): BrowseDefinition - { - $this->code = $code; - return $this; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @param string $name - * @return BrowseDefinition - */ - public function setName(string $name): BrowseDefinition - { - $this->name = $name; - return $this; - } - - /** - * @return string - */ - public function getShortName(): string - { - return $this->shortName; - } - - /** - * @param string $shortName - * @return BrowseDefinition - */ - public function setShortName(string $shortName): BrowseDefinition - { - $this->shortName = $shortName; - return $this; - } - /** * @return bool */ @@ -122,13 +65,13 @@ public function addColumn(BrowseColumn $column) } /** - * @param $index + * @param $id * @return bool */ - public function removeColumn($index) + public function removeColumn($id) { - if (array_key_exists($index, $this->columns)) { - unset($this->columns[$index]); + if (array_key_exists($id, $this->columns)) { + unset($this->columns[$id]); return true; } else { return false; diff --git a/src/BrowseField.php b/src/BrowseField.php index 28322ce0..81b54e5a 100644 --- a/src/BrowseField.php +++ b/src/BrowseField.php @@ -2,10 +2,11 @@ namespace PhpTwinfield; +use PhpTwinfield\Fields\CodeField; + class BrowseField { - /** @var string */ - private $code; + use CodeField; /** @var string */ private $dataType; @@ -27,24 +28,6 @@ public function __construct() $this->options = []; } - /** - * @return string - */ - public function getCode(): string - { - return $this->code; - } - - /** - * @param string $code - * @return BrowseField - */ - public function setCode(string $code): BrowseField - { - $this->code = $code; - return $this; - } - /** * @return string */ diff --git a/src/BrowseFieldOption.php b/src/BrowseFieldOption.php index fee48fc4..0adf734c 100644 --- a/src/BrowseFieldOption.php +++ b/src/BrowseFieldOption.php @@ -2,47 +2,11 @@ namespace PhpTwinfield; +use PhpTwinfield\Fields\CodeField; +use PhpTwinfield\Fields\NameField; + class BrowseFieldOption { - /** @var string */ - private $code; - - /** @var string|null */ - private $name; - - /** - * @return string - */ - public function getCode(): string - { - return $this->code; - } - - /** - * @param string $code - * @return BrowseFieldOption - */ - public function setCode(string $code): BrowseFieldOption - { - $this->code = $code; - return $this; - } - - /** - * @return string - */ - public function getName(): ?string - { - return $this->name; - } - - /** - * @param string $name - * @return BrowseFieldOption - */ - public function setName(string $name): BrowseFieldOption - { - $this->name = $name; - return $this; - } + use CodeField; + use NameField; } diff --git a/src/BrowseSortField.php b/src/BrowseSortField.php index 0f2c6d73..09cdcded 100644 --- a/src/BrowseSortField.php +++ b/src/BrowseSortField.php @@ -3,11 +3,11 @@ namespace PhpTwinfield; use PhpTwinfield\Enums\Order; +use PhpTwinfield\Fields\CodeField; class BrowseSortField { - /** @var string */ - private $code; + use CodeField; /** @var Order|null */ private $order; @@ -24,22 +24,6 @@ public function __construct(string $code, ?Order $order = null) $this->order = $order; } - /** - * @return string - */ - public function getCode(): string - { - return $this->code; - } - - /** - * @param string $code - */ - public function setCode(string $code): void - { - $this->code = $code; - } - /** * @return null|Order */ diff --git a/src/CashTransaction.php b/src/CashTransaction.php index 3ca394a7..ba4f459f 100644 --- a/src/CashTransaction.php +++ b/src/CashTransaction.php @@ -2,30 +2,29 @@ namespace PhpTwinfield; -use Money\Currency; -use Money\Money; +use PhpTwinfield\CashTransactionLine; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\LineType; -use PhpTwinfield\Transactions\TransactionFields\StartAndCloseValueFields; -use PhpTwinfield\Transactions\TransactionFields\StatementNumberField; -use PhpTwinfield\Transactions\TransactionLine; +use PhpTwinfield\Fields\Transaction\CloseValueField; +use PhpTwinfield\Fields\Transaction\StartValueField; +use PhpTwinfield\Fields\Transaction\StatementNumberField; -/** +/* * @link https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/CashTransactions */ class CashTransaction extends BaseTransaction { + use CloseValueField; + use StartValueField; use StatementNumberField; - use StartAndCloseValueFields { - setCurrency as protected traitSetCurrency; - } public function __construct() { - $this->startvalue = new Money(0, new Currency('EUR')); + $this->closeValue = new \Money\Money(0, new \Money\Currency('EUR')); + $this->startValue = new \Money\Money(0, new \Money\Currency('EUR')); } - /** + /* * @return string */ public function getLineClassName(): string @@ -33,35 +32,23 @@ public function getLineClassName(): string return CashTransactionLine::class; } - /** - * Set the currency. Can only be done when the start value is still 0. - * - * @param Currency $currency - * @return $this - */ - public function setCurrency(?Currency $currency): BaseTransaction - { - $this->traitSetCurrency($currency); - return $this; - } - - /** - * @param TransactionLine $line + /* + * @param CashTransactionLine $line * @return $this */ - public function addLine(TransactionLine $line) + public function addLine(CashTransactionLine $line) { parent::addLine($line); - /** @var CashTransactionLine $line */ + /* @var CashTransactionLine $line */ if (!$line->getLineType()->equals(LineType::TOTAL())) { /* - * Don't add total lines to the closevalue, they are summaries of the details and vat lines. + * Don't add total lines to the close value, they are summaries of the details and vat lines. */ if ($line->getDebitCredit()->equals(DebitCredit::CREDIT())) { - $this->closevalue = $this->getClosevalue()->add($line->getValue()); + $this->closeValue = $this->getCloseValue()->add($line->getValue()); } else { - $this->closevalue = $this->getClosevalue()->subtract($line->getValue()); + $this->closeValue = $this->getCloseValue()->subtract($line->getValue()); } } diff --git a/src/CashTransactionLine.php b/src/CashTransactionLine.php index c6c69ce0..43ecfa28 100644 --- a/src/CashTransactionLine.php +++ b/src/CashTransactionLine.php @@ -3,27 +3,35 @@ namespace PhpTwinfield; use Money\Money; -use PhpTwinfield\Enums\DebitCredit; +use PhpTwinfield\Dummy; use PhpTwinfield\Enums\LineType; -use PhpTwinfield\Transactions\TransactionFields\InvoiceNumberField; -use PhpTwinfield\Transactions\TransactionLineFields\PerformanceFields; -use PhpTwinfield\Transactions\TransactionLineFields\VatTotalFields; +use PhpTwinfield\Fields\PerformanceDateField; +use PhpTwinfield\Fields\PerformanceTypeField; +use PhpTwinfield\Fields\Transaction\TransactionLine\CurrencyDateField; +use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceCountryField; +use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceVatNumberField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatBaseTotalField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatRepTotalField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatTotalField; use Webmozart\Assert\Assert; class CashTransactionLine extends BaseTransactionLine { - use VatTotalFields; - use PerformanceFields; - use InvoiceNumberField { - setInvoiceNumber as traitSetInvoiceNumber; - } + use CurrencyDateField; + use PerformanceCountryField; + use PerformanceDateField; + use PerformanceTypeField; + use PerformanceVatNumberField; + use VatBaseTotalField; + use VatRepTotalField; + use VatTotalField; - /** + /* * @var CashTransaction */ private $transaction; - /** + /* * @param CashTransaction $object */ public function setTransaction($object): void @@ -33,7 +41,7 @@ public function setTransaction($object): void $this->transaction = $object; } - /** + /* * References the transaction this line belongs too. * * @return CashTransaction @@ -43,222 +51,249 @@ public function getTransaction(): CashTransaction return $this->transaction; } - /** - * If line type = total the cash balance account. - * - * If line type = detail the customer or supplier balance account or profit and loss account. + /* + * Only if line type is detail. The amount still owed in base currency. Read-only attribute. * - * If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account - * will be taken as entered at the VAT code in Twinfield. + * @param Money|null $baseValueOpen + * @return $this + * @throws Exception + */ + public function setBaseValueOpen(?Money $baseValueOpen): parent + { + if ($baseValueOpen !== null && !$this->getLineType()->equals(LineType::DETAIL())) { + throw Exception::invalidFieldForLineType('baseValueOpen', $this); + } + + return parent::setBaseValueOpen($baseValueOpen); + } + + /* + * Only if line type is detail. The line date. Only allowed if the line date in the bank book is set to Allowed or Mandatory. * - * @param string|null $dim1 + * @param \DateTimeInterface|null $currencyDate * @return $this + * @throws Exception */ - public function setDim1(?string $dim1): BaseTransactionLine + public function setCurrencyDate(?\DateTimeInterface $currencyDate): self { - return parent::setDim1($dim1); + if ($currencyDate !== null && !$this->getLineType()->equals(LineType::DETAIL())) { + throw Exception::invalidFieldForLineType('currencyDate', $this); + } + + return parent::setCurrencyDate($currencyDate); } - /** + /* * If line type = total empty. * * If line type = detail the customer or supplier or the cost center or empty. * * If line type = vat empty. * - * @param string|null $dim2 + * @param Dummy|null $dim2 * @return $this * @throws Exception */ - public function setDim2(?string $dim2): BaseTransactionLine + public function setDim2(?Dummy $dim2): parent { - if ($dim2 !== null && - ($this->getLineType()->equals(LineType::VAT()) || $this->getLineType()->equals(LineType::TOTAL()))) { + if ($dim2 !== null && ($this->getLineType()->equals(LineType::VAT()) || $this->getLineType()->equals(LineType::TOTAL()))) { throw Exception::invalidDimensionForLineType(2, $this); } return parent::setDim2($dim2); } - /** + /* * If line type = total empty. * * If line type = detail the project or asset or empty. * * If line type = vat empty. * - * @param string|null $dim3 + * @param Dummy|null $dim3 * @return $this * @throws Exception */ - public function setDim3(?string $dim3): BaseTransactionLine + public function setDim3(?Dummy $dim3): parent { - if ($dim3 !== null && - ($this->getLineType()->equals(LineType::VAT()) || $this->getLineType()->equals(LineType::TOTAL()))) { + if ($dim3 !== null && ($this->getLineType()->equals(LineType::VAT()) || $this->getLineType()->equals(LineType::TOTAL()))) { throw Exception::invalidDimensionForLineType(3, $this); } return parent::setDim3($dim3); } - /** - * If line type = total, based on the sum of the individual cash transaction lines. - * - In case of a cash addition debit. - * - In case of a cash withdrawal credit. + /* + * Returns true if a positive amount in the TOTAL line means the amount is 'debit'. Examples of incoming transaction + * types are Sales Transactions, Electronic Bank Statements and Bank Transactions. * - * If line type = detail - * - In case money is received credit. - * - In case money is paid debit. + * Returns false if a positive amount in the TOTAL line means the amount is 'credit'. An example of an outgoing + * transaction type is a Purchase Transaction. * - * If line type = vat, based on the sum of the vat amounts of the individual cash transaction lines. - * - In case of a cash addition credit. - * - In case of a cash withdrawal debit. + * @return bool + */ + protected function isIncomingTransactionType(): bool + { + return true; + } + + /* + * Only if line type is detail. The level of the matchable dimension. Read-only attribute. * - * @param DebitCredit::DEBIT() $debitCredit + * @param int|null $matchLevel * @return $this + * @throws Exception */ - public function setDebitCredit(DebitCredit $debitCredit): BaseTransactionLine + public function setMatchLevel(?int $matchLevel): parent { - return parent::setDebitCredit($debitCredit); + if ($matchLevel !== null && !$this->getLineType()->equals(LineType::DETAIL())) { + throw Exception::invalidFieldForLineType('matchLevel', $this); + } + + return parent::setMatchLevel($matchLevel); } - /** - * If line type = total amount including VAT. - * - * If line type = detail amount without VAT. - * - * If line type = vat VAT amount. + /* + * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The performance type. * - * @param Money $value + * @param PerformanceType|null $performanceType * @return $this + * @throws Exception */ - public function setValue(Money $value): BaseTransactionLine + public function setPerformanceType(?PerformanceType $performanceType): self { - return parent::setValue($value); + if ($performanceType !== null && $this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('performanceType', $this); + } + + return parent::setPerformanceType($performanceType); } - /** - * Payment status of the cash transaction. If line type total or vat always notmatchable. Read-only attribute. + /* + * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The ISO country codes are used. If not added to the request, by default the country code of the customer will be taken. * - * @param string|null $matchStatus + * @param Country|null $performanceCountry * @return $this * @throws Exception */ - public function setMatchStatus(?string $matchStatus): BaseTransactionLine + public function setPerformanceCountry(?Country $performanceCountry): self { - if ( - $matchStatus !== null && - in_array($this->getLineType(), [LineType::TOTAL(), LineType::VAT()]) && - $matchStatus != self::MATCHSTATUS_NOTMATCHABLE - ) { - throw Exception::invalidMatchStatusForLineType($matchStatus, $this); + if ($performanceCountry !== null && $this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('performanceCountry', $this); } - return parent::setMatchStatus($matchStatus); + return parent::setPerformanceCountry($performanceCountry); } - /** - * Only if line type is detail. The level of the matchable dimension. Read-only attribute. + /* + * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. If not added to the request, by default the VAT number of the customer will be taken. * - * @param int|null $matchLevel + * @param string|null $performanceVatNumber * @return $this * @throws Exception */ - public function setMatchLevel(?int $matchLevel): BaseTransactionLine + public function setPerformanceVatNumber(?string $performanceVatNumber): self { - if ($matchLevel !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('matchLevel', $this); + if ($performanceVatNumber !== null && $this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('performanceVatNumber', $this); } - return parent::setMatchLevel($matchLevel); + return parent::setPerformanceVatNumber($performanceVatNumber); } - /** - * Only if line type is detail. The amount still owed in base currency. Read-only attribute. + /* + * Only if line type is detail or vat. Mandatory in case of an ICT VAT code but only if performancetype is services. * - * @param Money|null $baseValueOpen + * @param \DateTimeInterface|null $performanceDate * @return $this * @throws Exception */ - public function setBaseValueOpen(?Money $baseValueOpen): BaseTransactionLine + public function setPerformanceDate(?\DateTimeInterface $performanceDate): self { - if ($baseValueOpen !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('baseValueOpen', $this); + if ($performanceDate !== null && (!$this->getPerformanceType()->equals(PerformanceType::SERVICES()) || $this->getLineType()->equals(LineType::TOTAL()))) { + throw Exception::invalidFieldForLineType('performanceDate', $this); } - return parent::setBaseValueOpen($baseValueOpen); + return parent::setPerformanceDate($performanceDate); } - /** - * Only if line type is vat. Amount on which VAT was calculated in the currency of the sales transaction. + /* + * Relation of the transaction. Only if line type is detail. Read-only attribute. * - * @param Money|null $vatTurnover + * @param string|null $relation * @return $this * @throws Exception */ - public function setVatTurnover(?Money $vatTurnover): BaseTransactionLine + public function setRelation(?string $relation): parent { - if (!$this->getLineType()->equals(LineType::VAT())) { - throw Exception::invalidFieldForLineType('vatturnover', $this); + if ($relation !== null && !$this->getLineType()->equals(LineType::DETAIL())) { + throw Exception::invalidRelationForLineType($relation, $this); } - return parent::setVatTurnOver($vatTurnover); + + return $this; } - /** - * Only if line type is vat. Amount on which VAT was calculated in base currency. + /* + * Only if line type is detail. The amount still owed in reporting currency. Read-only attribute. * - * @param Money|null $vatBaseTurnover + * @param Money|null $repValueOpen * @return $this * @throws Exception */ - public function setVatBaseTurnover(?Money $vatBaseTurnover): BaseTransactionLine + public function setRepValueOpen(?Money $repValueOpen): parent { - if (!$this->getLineType()->equals(LineType::VAT())) { - throw Exception::invalidFieldForLineType('vatbaseturnover', $this); + if ($repValueOpen !== null && !$this->getLineType()->equals(LineType::DETAIL())) { + throw Exception::invalidFieldForLineType('repValueOpen', $this); } - return parent::setVatBaseTurnover($vatBaseTurnover); + + return parent::setRepValueOpen($repValueOpen); } - /** - * Only if line type is vat. Amount on which VAT was calculated in reporting currency. + /* + * Only if line type is total. The total VAT amount in the currency of the cash transaction * - * @param Money|null $vatRepTurnover + * @param Money|null $vatValueOpen * @return $this * @throws Exception */ - public function setVatRepTurnover(?Money $vatRepTurnover): BaseTransactionLine + public function setVatValueOpen(?Money $vatValueOpen): parent { - if (!$this->getLineType()->equals(LineType::VAT())) { - throw Exception::invalidFieldForLineType('vatrepturnover', $this); + if ($vatValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatValueOpen', $this); } - return parent::setVatRepTurnover($vatRepTurnover); + + return parent::setVatValueOpen($vatValueOpen); } - /** - * @param string|null $invoiceNumber + /* + * Only if line type is total. The total VAT amount in base currency. + * + * @param Money|null $vatBaseValueOpen * @return $this * @throws Exception */ - public function setInvoiceNumber(?string $invoiceNumber) + public function setVatBaseValueOpen(?Money $vatBaseValueOpen): parent { - if (!$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('invoicenumber', $this); + if ($vatBaseValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatBaseValueOpen', $this); } - return $this->traitSetInvoiceNumber($invoiceNumber); + return parent::setVatBaseValueOpen($vatBaseValueOpen); } - /** - * Returns true if a positive amount in the TOTAL line means the amount is 'debit'. Examples of incoming transaction - * types are Sales Transactions, Electronic Bank Statements and Bank Transactions. + /* + * Only if line type is total. The total VAT amount in reporting currency. * - * Returns false if a positive amount in the TOTAL line means the amount is 'credit'. An example of an outgoing - * transaction type is a Purchase Transaction. - * - * @return bool + * @param Money|null $vatRepValueOpen + * @return $this + * @throws Exception */ - protected function isIncomingTransactionType(): bool + public function setVatRepValueOpen(?Money $vatRepValueOpen): parent { - return true; + if ($vatRepValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatRepValueOpen', $this); + } + + return parent::setVatRepValueOpen($vatRepValueOpen); } } diff --git a/src/Customer.php b/src/Customer.php index a65f5834..8f34ec8a 100644 --- a/src/Customer.php +++ b/src/Customer.php @@ -56,6 +56,7 @@ class Customer extends BaseObject private $creditManagement; private $financials; + private $addresses = []; private $banks = []; private $postingRules = []; @@ -105,10 +106,10 @@ public function addAddress(CustomerAddress $address) return $this; } - public function removeAddress($index) + public function removeAddress($id) { - if (array_key_exists($index, $this->addresses)) { - unset($this->addresses[$index]); + if (array_key_exists($id, $this->addresses)) { + unset($this->addresses[$id]); return true; } else { return false; @@ -126,10 +127,10 @@ public function addBank(CustomerBank $bank) return $this; } - public function removeBank($index) + public function removeBank($id) { - if (array_key_exists($index, $this->banks)) { - unset($this->banks[$index]); + if (array_key_exists($id, $this->banks)) { + unset($this->banks[$id]); return true; } else { return false; @@ -147,10 +148,10 @@ public function addPostingRule(CustomerPostingRule $postingRule) return $this; } - public function removePostingRule($index) + public function removePostingRule($id) { - if (array_key_exists($index, $this->postingRules)) { - unset($this->postingRules[$index]); + if (array_key_exists($id, $this->postingRules)) { + unset($this->postingRules[$id]); return true; } else { return false; diff --git a/src/CustomerBank.php b/src/CustomerBank.php index 02258406..bf91599a 100644 --- a/src/CustomerBank.php +++ b/src/CustomerBank.php @@ -28,8 +28,8 @@ class CustomerBank extends BaseObject use AddressField2Field; use AddressField3Field; use AscriptionField; - use BankNameField; use BankBlockedField; + use BankNameField; use BicCodeField; use CityField; use CountryField; diff --git a/src/CustomerCreditManagement.php b/src/CustomerCreditManagement.php index a5f4d367..5299df62 100644 --- a/src/CustomerCreditManagement.php +++ b/src/CustomerCreditManagement.php @@ -2,11 +2,11 @@ namespace PhpTwinfield; +use PhpTwinfield\Fields\CommentField; use PhpTwinfield\Fields\Dimensions\Level2\Customer\BaseCreditLimitField; use PhpTwinfield\Fields\Dimensions\Level2\Customer\BlockedField; use PhpTwinfield\Fields\Dimensions\Level2\Customer\BlockedLockedField; use PhpTwinfield\Fields\Dimensions\Level2\Customer\BlockedModifiedField; -use PhpTwinfield\Fields\Dimensions\Level2\Customer\CommentField; use PhpTwinfield\Fields\Dimensions\Level2\Customer\FreeText1Field; use PhpTwinfield\Fields\Dimensions\Level2\Customer\ReminderEmailField; use PhpTwinfield\Fields\Dimensions\Level2\Customer\ResponsibleUserField; diff --git a/src/CustomerFinancials.php b/src/CustomerFinancials.php index ddc45b53..aebd3dfc 100644 --- a/src/CustomerFinancials.php +++ b/src/CustomerFinancials.php @@ -45,6 +45,7 @@ class CustomerFinancials extends BaseObject use VatCodeFixedField; private $collectMandate; + private $childValidations = []; public function __construct() diff --git a/src/DomDocuments/BaseDocument.php b/src/DomDocuments/BaseDocument.php index 161436c3..461c5258 100644 --- a/src/DomDocuments/BaseDocument.php +++ b/src/DomDocuments/BaseDocument.php @@ -2,15 +2,6 @@ namespace PhpTwinfield\DomDocuments; -use PhpTwinfield\Enums\PerformanceType; -use PhpTwinfield\Office; -use PhpTwinfield\Transactions\TransactionFields\FreeTextFields; -use PhpTwinfield\Transactions\TransactionFields\StartAndCloseValueFields; -use PhpTwinfield\Transactions\TransactionLineFields\PerformanceFields; -use PhpTwinfield\Transactions\TransactionLineFields\ValueFields; -use PhpTwinfield\Util; -use Webmozart\Assert\Assert; - /** * You should add a public function add($instance): void method which will add an instance to the rootElement, so * that you can send multiple elements in one go. @@ -37,119 +28,6 @@ public function __construct($version = "1.0", $encoding = "UTF-8") $this->appendChild($this->rootElement); } - protected function createBooleanAttribute(string $name, bool $value): \DOMAttr - { - $attr = $this->createAttribute($name); - $attr->value = Util::formatBoolean($value); - - return $attr; - } - - protected function appendDateElement(\DOMElement $element, string $name, \DateTimeInterface $date): void - { - $element->appendChild( - $this->createNodeWithTextContent($name, Util::formatDate($date)) - ); - } - - protected function appendOfficeField(\DOMElement $element, Office $office): void - { - $element->appendChild( - $this->createNodeWithTextContent("office", $office->getCode()) - ); - } - - /** - * Utility method to get a formatted value using a callable. - * - * @param callable $callback - * @return null|string - */ - protected function getValueFromCallback(callable $callback): ?string - { - $value = call_user_func($callback); - - if ($value instanceof \DateTimeInterface) { - $value = Util::formatDate($value); - } - - if (is_bool($value)) { - $value = Util::formatBoolean($value); - } - - return $value; - } - - /** - * Adds currency, startvalue and closevalue to $element. - * - * @param \DOMElement $element - * @param $object - */ - protected function appendStartCloseValues(\DOMElement $element, $object): void - { - Assert::true(Util::objectUses(StartAndCloseValueFields::class, $object)); - - /** @var StartAndCloseValueFields $object */ - $element->appendChild($this->createNodeWithTextContent("currency", $object->getCurrency())); - $element->appendChild($this->createNodeWithTextContent("startvalue", Util::formatMoney($object->getStartvalue()))); - $element->appendChild($this->createNodeWithTextContent("closevalue", Util::formatMoney($object->getClosevalue()))); - } - - /** - * Adds freetext[1-3] to the $element, unless they are null. - * - * @param \DOMElement $element - * @param $object - */ - protected function appendFreeTextFields(\DOMElement $element, $object): void - { - Assert::true(Util::objectUses(FreeTextFields::class, $object)); - - /** @var FreeTextFields $object */ - if ($object->getFreetext1() !== null) { - $element->appendChild($this->createNodeWithTextContent("freetext1", $object->getFreetext1())); - } - if ($object->getFreetext2() !== null) { - $element->appendChild($this->createNodeWithTextContent("freetext2", $object->getFreetext2())); - } - if ($object->getFreetext3() !== null) { - $element->appendChild($this->createNodeWithTextContent("freetext3", $object->getFreetext3())); - } - } - - protected function appendValueValues(\DOMElement $element, $object): void - { - Assert::true(Util::objectUses(ValueFields::class, $object)); - - /** @var ValueFields $object */ - $element->appendChild($this->createNodeWithTextContent("debitcredit", $object->getDebitCredit())); - $element->appendChild($this->createNodeWithTextContent("value", Util::formatMoney($object->getValue()))); - } - - protected function appendPerformanceTypeFields(\DOMElement $element, $object): void - { - /** @var PerformanceFields $object */ - - Assert::true(Util::objectUses(PerformanceFields::class, $object)); - - if ($object->getPerformanceType() !== null) { - $element->appendChild($this->createNodeWithTextContent("performancetype", $object->getPerformanceType())); - } - - if ($object->getPerformanceCountry() !== null) { - $element->appendChild($this->createNodeWithTextContent("performancecountry", $object->getPerformanceCountry())); - } - - if ($object->getPerformanceVatNumber() !== null) { - $element->appendChild($this->createNodeWithTextContent("performancevatnumber", $object->getPerformanceVatNumber())); - } - - if ($object->getPerformanceDate() != null && $object->getPerformanceType()->equals(PerformanceType::SERVICES())) { - $this->appendDateElement($element, "performancedate", $object->getPerformanceDate()); - } - } - /** * Create an element and set some value as its innerText. * @@ -164,11 +42,11 @@ protected function appendPerformanceTypeFields(\DOMElement $element, $object): v final protected function createNodeWithTextContent(string $tag, ?string $textContent, object $object = null, array $attributes = null): \DOMElement { $element = $this->createElement($tag); - + if ($textContent != null) { $element->textContent = $textContent; } - + if (isset($object) && isset($attributes)) { foreach ($attributes as $attributeName => $method) { $element->setAttribute($attributeName, $object->$method()); diff --git a/src/DomDocuments/BookingReferenceDeletionDocument.php b/src/DomDocuments/BookingReferenceDeletionDocument.php index 243ae432..4282ddb4 100644 --- a/src/DomDocuments/BookingReferenceDeletionDocument.php +++ b/src/DomDocuments/BookingReferenceDeletionDocument.php @@ -18,7 +18,7 @@ public function __construct(BookingReference $bookingReference, string $reason) $this->rootElement->setAttribute("action", "delete"); $this->rootElement->setAttribute("reason", $reason); - $this->appendOfficeField($this->rootElement, $bookingReference->getOffice()); + $this->rootElement->appendChild($this->createNodeWithTextContent('office', $bookingReference->getOfficeToString())); $this->rootElement->appendChild( $this->createNodeWithTextContent("code", $bookingReference->getCode()) diff --git a/src/DomDocuments/ElectronicBankStatementDocument.php b/src/DomDocuments/ElectronicBankStatementDocument.php index 284e0f90..6a16f9b7 100644 --- a/src/DomDocuments/ElectronicBankStatementDocument.php +++ b/src/DomDocuments/ElectronicBankStatementDocument.php @@ -4,8 +4,6 @@ use PhpTwinfield\ElectronicBankStatement; -/** - */ class ElectronicBankStatementDocument extends BaseDocument { final protected function getRootTagName(): string @@ -30,14 +28,14 @@ public function addStatement(ElectronicBankStatement $electronicBankStatement) $statement->appendChild($this->createNodeWithTextContent("code", $electronicBankStatement->getCode())); } - $statement->appendChild($this->createNodeWithTextContent("date", $electronicBankStatement->getDate()->format("Ymd"))); - - $this->appendStartCloseValues($statement, $electronicBankStatement); - + $statement->appendChild($this->createNodeWithTextContent("date", $electronicBankStatement->getDateToString())); + $statement->appendChild($this->createNodeWithTextContent("currency", $electronicBankStatement->getCurrencyToString())); + $statement->appendChild($this->createNodeWithTextContent("startvalue", $electronicBankStatement->getStartValueToFloat())); + $statement->appendChild($this->createNodeWithTextContent("closevalue", $electronicBankStatement->getCloseValueToFloat())); $statement->appendChild($this->createNodeWithTextContent("statementnumber", $electronicBankStatement->getStatementnumber())); if ($electronicBankStatement->getOffice()) { - $statement->appendChild($this->createNodeWithTextContent("office", $electronicBankStatement->getOffice()->getCode())); + $statement->appendChild($this->createNodeWithTextContent("office", $electronicBankStatement->getOfficeToString())); } $transactions = $this->createElement("transactions"); @@ -46,10 +44,10 @@ public function addStatement(ElectronicBankStatement $electronicBankStatement) $node = $this->createElement("transaction"); - if ($transaction->getContraaccount()) { - $node->appendChild($this->createNodeWithTextContent("contraaccount", $transaction->getContraaccount())); - } elseif ($transaction->getContraiban()) { - $node->appendChild($this->createNodeWithTextContent("contraiban", $transaction->getContraiban())); + if ($transaction->getContraAccount()) { + $node->appendChild($this->createNodeWithTextContent("contraaccount", $transaction->getContraAccount())); + } elseif ($transaction->getContraIban()) { + $node->appendChild($this->createNodeWithTextContent("contraiban", $transaction->getContraIban())); } $node->appendChild($this->createNodeWithTextContent("type", $transaction->getType())); @@ -58,15 +56,14 @@ public function addStatement(ElectronicBankStatement $electronicBankStatement) $node->appendChild($this->createNodeWithTextContent("reference", $transaction->getReference())); } - $this->appendValueValues($node, $transaction); - + $node->appendChild($this->createNodeWithTextContent('debitcredit', $transaction->getDebitCredit())); + $node->appendChild($this->createNodeWithTextContent('value', $transaction->getValueToFloat())); $node->appendChild($this->createNodeWithTextContent("description", $transaction->getDescription())); $transactions->appendChild($node); } $statement->appendChild($transactions); - $this->rootElement->appendChild($statement); } } \ No newline at end of file diff --git a/src/DomDocuments/InvoicesDocument.php b/src/DomDocuments/InvoicesDocument.php index 9c3b03a7..fbe1fd72 100644 --- a/src/DomDocuments/InvoicesDocument.php +++ b/src/DomDocuments/InvoicesDocument.php @@ -2,6 +2,8 @@ namespace PhpTwinfield\DomDocuments; +use PhpTwinfield\ApiConnectors\ArticleApiConnector; +use PhpTwinfield\ApiConnectors\InvoiceTypeApiConnector; use PhpTwinfield\Article; use PhpTwinfield\Invoice; use PhpTwinfield\Secure\AuthenticatedConnection; @@ -71,10 +73,10 @@ public function addInvoice(Invoice $invoice, $connection) $headerElement->appendChild($this->createNodeWithTextContent('period', $invoice->getPeriod())); $headerElement->appendChild($this->createNodeWithTextContent('status', $invoice->getStatus())); - $invoiceTypeApiConnector = new \PhpTwinfield\ApiConnectors\InvoiceTypeApiConnector($connection); + $invoiceTypeApiConnector = new InvoiceTypeApiConnector($connection); $invoiceVatType = $invoiceTypeApiConnector->getInvoiceTypeVatType($invoice->getInvoiceTypeToString()); - $articleApiConnector = new \PhpTwinfield\ApiConnectors\ArticleApiConnector($connection); + $articleApiConnector = new ArticleApiConnector($connection); $lines = $invoice->getLines(); diff --git a/src/DomDocuments/MatchDocument.php b/src/DomDocuments/MatchDocument.php index 3171c7e6..42eb7b02 100644 --- a/src/DomDocuments/MatchDocument.php +++ b/src/DomDocuments/MatchDocument.php @@ -12,11 +12,11 @@ public function addMatchSet(MatchSet $matchSet) { $set = $this->createElement("set"); - $this->appendOfficeField($set, $matchSet->getOffice()); + $set->appendChild($this->createNodeWithTextContent('office', $transaction->getOfficeToString())); $set->appendChild($this->createNodeWithTextContent("matchcode", $matchSet->getMatchCode()->getValue())); - $this->appendDateElement($set, "matchdate", $matchSet->getMatchDate()); + $set->appendChild($this->createNodeWithTextContent("matchdate", $matchSet->getMatchDateToString())); $lines = $this->createElement("lines"); @@ -33,9 +33,9 @@ private function createLineElement(MatchLine $line): \DOMElement { $element = $this->createElement("line"); - $element->appendChild($this->createNodeWithTextContent("transcode", $line->getTranscode())); - $element->appendChild($this->createNodeWithTextContent("transnumber", $line->getTransnumber())); - $element->appendChild($this->createNodeWithTextContent("transline", $line->getTransline())); + $element->appendChild($this->createNodeWithTextContent("transcode", $line->getTransCode())); + $element->appendChild($this->createNodeWithTextContent("transnumber", $line->getTransNumber())); + $element->appendChild($this->createNodeWithTextContent("transline", $line->getTransLine())); if ($line->getMatchValue() !== null) { $element->appendChild($this->createNodeWithTextContent("matchvalue", Util::formatMoney($line->getMatchValue()))); diff --git a/src/DomDocuments/TransactionsDocument.php b/src/DomDocuments/TransactionsDocument.php index e7f019ea..1379a949 100644 --- a/src/DomDocuments/TransactionsDocument.php +++ b/src/DomDocuments/TransactionsDocument.php @@ -7,15 +7,19 @@ use PhpTwinfield\BaseTransactionLine; use PhpTwinfield\CashTransaction; use PhpTwinfield\Enums\LineType; -use PhpTwinfield\JournalTransactionLine; -use PhpTwinfield\Transactions\TransactionFields\DueDateField; -use PhpTwinfield\Transactions\TransactionFields\FreeTextFields; -use PhpTwinfield\Transactions\TransactionFields\InvoiceNumberField; -use PhpTwinfield\Transactions\TransactionFields\PaymentReferenceField; -use PhpTwinfield\Transactions\TransactionFields\StatementNumberField; -use PhpTwinfield\Transactions\TransactionLineFields\FreeCharField; -use PhpTwinfield\Transactions\TransactionLineFields\PerformanceFields; -use PhpTwinfield\Transactions\TransactionLineFields\VatTotalFields; +use PhpTwinfield\Fields\DueDateField; +use PhpTwinfield\Fields\FreeText1Field; +use PhpTwinfield\Fields\PerformanceDateField; +use PhpTwinfield\Fields\PerformanceTypeField; +use PhpTwinfield\Fields\Transaction\InvoiceNumberField; +use PhpTwinfield\Fields\Transaction\PaymentReferenceField; +use PhpTwinfield\Fields\Transaction\StatementNumberField; +use PhpTwinfield\Fields\Transaction\TransactionLine\FreeCharField; +use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceCountryField; +use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceVatNumberField; +use PhpTwinfield\Fields\Transaction\TransactionLine\ValueFields; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatBaseTotalField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatTotalField; use PhpTwinfield\Util; /** @@ -44,11 +48,12 @@ public function addTransaction(BaseTransaction $transaction) // Transaction $transactionElement = $this->createElement('transaction'); $transactionElement->setAttribute('destiny', $transaction->getDestiny()); + if ($transaction->getRaiseWarning() !== null) { - $transactionElement->appendChild($this->createBooleanAttribute('raisewarning', $transaction->getRaiseWarning())); + $transactionElement->appendChild($this->createNodeWithTextContent('raisewarning', $transaction->getRaiseWarningToString())); } if ($transaction->isAutoBalanceVat() !== null) { - $transactionElement->appendChild($this->createBooleanAttribute('autobalancevat', $transaction->isAutoBalanceVat())); + $transactionElement->appendChild($this->createNodeWithTextContent('autobalancevat', $transaction->isAutoBalanceVatToString())); } $this->rootElement->appendChild($transactionElement); @@ -66,53 +71,56 @@ public function addTransaction(BaseTransaction $transaction) } if ($transaction->getCurrency() !== null) { - $currencyElement = $this->createNodeWithTextContent('currency', $transaction->getCurrency()); + $currencyElement = $this->createNodeWithTextContent('currency', $transaction->getCurrencyToString()); $headerElement->appendChild($currencyElement); } - $this->appendDateElement($headerElement, "date", $transaction->getDate()); + $dateElement = $this->createNodeWithTextContent("date", $transaction->getDateToString()); + $headerElement->appendChild($dateElement); if ($transaction->getPeriod() !== null) { $periodElement = $this->createNodeWithTextContent('period', $transaction->getPeriod()); $headerElement->appendChild($periodElement); } - if ( - in_array(InvoiceNumberField::class, class_uses($transaction)) && - $transaction->getInvoiceNumber() !== null - ) { + if (in_array(InvoiceNumberField::class, class_uses($transaction)) && $transaction->getInvoiceNumber() !== null) { $invoiceNumberElement = $this->createNodeWithTextContent('invoicenumber', $transaction->getInvoiceNumber()); $headerElement->appendChild($invoiceNumberElement); } - if ( - in_array(PaymentReferenceField::class, class_uses($transaction)) && - $transaction->getPaymentReference() !== null - ) { + if (in_array(PaymentReferenceField::class, class_uses($transaction)) && $transaction->getPaymentReference() !== null) { $paymentReferenceElement = $this->createNodeWithTextContent('paymentreference', $transaction->getPaymentReference()); $headerElement->appendChild($paymentReferenceElement); } - $officeElement = $this->createNodeWithTextContent('office', $transaction->getOffice()); + $officeElement = $this->createNodeWithTextContent('office', $transaction->getOfficeToString()); $headerElement->appendChild($officeElement); - if (Util::objectUses(DueDateField::class, $transaction) && - $transaction->getDueDate() !== null - ) { - $this->appendDateElement($headerElement, "duedate", $transaction->getDueDate()); + if (Util::objectUses(DueDateField::class, $transaction) && $transaction->getDueDate() !== null) { + $dueDateElement = $this->createNodeWithTextContent("duedate", $transaction->getDueDateToString()); + $headerElement->appendChild($dueDateElement); } - if (Util::objectUses(StatementNumberField::class, $transaction) && - $transaction->getStatementnumber() !== null) { + if (Util::objectUses(StatementNumberField::class, $transaction) && $transaction->getStatementnumber() !== null) { $headerElement->appendChild($this->createNodeWithTextContent('statementnumber', $transaction->getStatementnumber())); } if ($transaction instanceof BankTransaction || $transaction instanceof CashTransaction) { - $headerElement->appendChild($this->createNodeWithTextContent('startvalue', Util::formatMoney($transaction->getStartvalue()))); - $headerElement->appendChild($this->createNodeWithTextContent('closevalue', Util::formatMoney($transaction->getClosevalue()))); + $headerElement->appendChild($this->createNodeWithTextContent('startvalue', $transaction->getStartValueToFloat())); + $headerElement->appendChild($this->createNodeWithTextContent('closevalue', $transaction->getCloseValueToFloat())); + } + + if (Util::objectUses(FreeText1Field::class, $transaction)) { + $headerElement->appendChild($this->createNodeWithTextContent("freetext1", $transaction->getFreetext1())); } - $this->appendFreeTextFields($headerElement, $transaction); + if (Util::objectUses(FreeText2Field::class, $transaction) && $transaction->getFreetext2() !== null) { + $headerElement->appendChild($this->createNodeWithTextContent("freetext2", $transaction->getFreetext2())); + } + + if (Util::objectUses(FreeText3Field::class, $transaction)) { + $headerElement->appendChild($this->createNodeWithTextContent("freetext3", $transaction->getFreetext3())); + } $linesElement = $this->createElement('lines'); $transactionElement->appendChild($linesElement); @@ -125,115 +133,140 @@ public function addTransaction(BaseTransaction $transaction) $lineElement->setAttribute('id', $transactionLine->getId()); $linesElement->appendChild($lineElement); - $dim1Element = $this->createNodeWithTextContent('dim1', $transactionLine->getDim1()); + $dim1Element = $this->createNodeWithTextContent('dim1', $transactionLine->getDim1ToString()); $lineElement->appendChild($dim1Element); - $dim2 = $transactionLine->getDim2(); + $dim2 = $transactionLine->getDim2ToString(); + if (!empty($dim2)) { $dim2Element = $this->createNodeWithTextContent('dim2', $dim2); $lineElement->appendChild($dim2Element); } - $this->appendValueValues($lineElement, $transactionLine); + if (in_array(ValueOpenField::class, class_uses($transactionLine))) { + $debitCreditElement = $this->createNodeWithTextContent('debitcredit', $transactionLine->getDebitCredit()); + $lineElement->appendChild($debitCreditElement); - if (Util::objectUses(PerformanceFields::class, $transactionLine)) { - /** @var PerformanceFields $transactionLine */ + $valueElement = $this->createNodeWithTextContent('value', $transactionLine->getValueToFloat()); + $lineElement->appendChild($valueElement); + } + + if (Util::objectUses(PerformanceTypeField::class, $transactionLine)) { $performanceType = $transactionLine->getPerformanceType(); + if (!empty($performanceType)) { $perfElement = $this->createNodeWithTextContent('performancetype', $performanceType); $lineElement->appendChild($perfElement); } + } + + if (Util::objectUses(PerformanceCountryField::class, $transactionLine)) { + $performanceCountry = $transactionLine->getPerformanceCountryToString(); - $performanceCountry = $transactionLine->getPerformanceCountry(); if (!empty($performanceCountry)) { $perfCountryElement = $this->createNodeWithTextContent('performancecountry', $performanceCountry); $lineElement->appendChild($perfCountryElement); } + } + if (Util::objectUses(PerformanceVatNumberField::class, $transactionLine)) { $performanceVatNumber = $transactionLine->getPerformanceVatNumber(); + if (!empty($performanceVatNumber)) { $perfVatNumberElement = $this->createNodeWithTextContent('performancevatnumber', $performanceVatNumber); $lineElement->appendChild($perfVatNumberElement); } + } + + if (Util::objectUses(PerformanceDateField::class, $transactionLine)) { + $performanceDate = $transactionLine->getPerformanceDateToString(); - $performanceDate = $transactionLine->getPerformanceDate(); if (!empty($performanceDate)) { - $this->appendDateElement($lineElement, "performancedate", $transactionLine->getPerformanceDate()); + $dueDateElement = $this->createNodeWithTextContent("performancedate", $performanceDate); + $lineElement->appendChild($dueDateElement); } } if (Util::objectUses(FreeCharField::class, $transactionLine)) { - /** @var FreeCharField $transactionLine */ $freeChar = $transactionLine->getFreeChar(); + if (!empty($freeChar)) { $freeCharElement = $this->createNodeWithTextContent('freechar', $freeChar); $lineElement->appendChild($freeCharElement); } } - if (Util::objectUses(FreeTextFields::class, $transactionLine)) { + if (Util::objectUses(FreeText1Field::class, $transactionLine)) { $freetext1 = $transactionLine->getFreetext1(); + if (!empty($freetext1)) { $freetext1Element = $this->createNodeWithTextContent('freetext1', $freetext1); $lineElement->appendChild($freetext1Element); } + } + if (Util::objectUses(FreeText2Field::class, $transactionLine)) { $freetext2 = $transactionLine->getFreetext2(); + if (!empty($freetext2)) { $freetext2Element = $this->createNodeWithTextContent('freetext2', $freetext2); $lineElement->appendChild($freetext2Element); } + } + if (Util::objectUses(FreeText3Field::class, $transactionLine)) { $freetext3 = $transactionLine->getFreetext3(); + if (!empty($freetext3)) { $freetext3Element = $this->createNodeWithTextContent('freetext3', $freetext3); $lineElement->appendChild($freetext3Element); } } - if (Util::objectUses(VatTotalFields::class, $transactionLine)) { - /** @var VatTotalFields $transactionLine */ + if (Util::objectUses(VatTotalField::class, $transactionLine)) { $vatTotal = $transactionLine->getVatTotal(); + if (!empty($vatTotal)) { - $vatTotalElement = $this->createNodeWithTextContent('vattotal', Util::formatMoney($vatTotal)); + $vatTotalElement = $this->createNodeWithTextContent('vattotal', $transactionLine->getVatTotalToFloat()); $lineElement->appendChild($vatTotalElement); } + } + if (Util::objectUses(VatBaseTotalField::class, $transactionLine)) { $vatBaseTotal= $transactionLine->getVatBaseTotal(); + if (!empty($vatBaseTotal)) { - $vatBaseTotalElement = $this->createNodeWithTextContent('vatbasetotal', Util::formatMoney($vatBaseTotal)); + $vatBaseTotalElement = $this->createNodeWithTextContent('vatbasetotal', $transactionLine->getVatBaseTotalToFloat()); $lineElement->appendChild($vatBaseTotalElement); } } - if (Util::objectUses(InvoiceNumberField::class, $transactionLine) && - $transactionLine->getInvoiceNumber() !== null - ) { + if (Util::objectUses(InvoiceNumberField::class, $transactionLine) && $transactionLine->getInvoiceNumber() !== null) { $invoiceNumberElement = $this->createNodeWithTextContent('invoicenumber', $transactionLine->getInvoiceNumber()); $lineElement->appendChild($invoiceNumberElement); } $vatValue = $transactionLine->getVatValue(); + if (!empty($vatValue)) { - $vatElement = $this->createNodeWithTextContent('vatvalue', Util::formatMoney($vatValue)); + $vatElement = $this->createNodeWithTextContent('vatvalue', $transactionLine->getVatValueToFloat()); $lineElement->appendChild($vatElement); } $baseline = $transactionLine->getBaseline(); + if (!empty($baseline)) { $baselineElement = $this->createNodeWithTextContent('baseline', $baseline); $lineElement->appendChild($baselineElement); } if ($transactionLine->getDescription() !== null) { - $descriptionNode = $this->createTextNode($transactionLine->getDescription()); - $descriptionElement = $this->createElement('description'); - $descriptionElement->appendChild($descriptionNode); + $descriptionElement = $this->createNodeWithTextContent('description', $transactionLine->getDescription()); $lineElement->appendChild($descriptionElement); } if (!LineType::TOTAL()->equals($transactionLine->getLineType()) && $transactionLine->getVatCode() !== null) { - $vatCodeElement = $this->createNodeWithTextContent('vatcode', $transactionLine->getVatCode()); + $vatCodeElement = $this->createNodeWithTextContent('vatcode', $transactionLine->getVatCodeToSring()); $lineElement->appendChild($vatCodeElement); } } diff --git a/src/ElectronicBankStatement.php b/src/ElectronicBankStatement.php index a6b2e77a..40b0d716 100644 --- a/src/ElectronicBankStatement.php +++ b/src/ElectronicBankStatement.php @@ -5,10 +5,11 @@ use Money\Currency; use Money\Money; use PhpTwinfield\Enums\DebitCredit; -use PhpTwinfield\Transactions\TransactionFields\OfficeField; -use PhpTwinfield\Transactions\TransactionFields\StartAndCloseValueFields; -use PhpTwinfield\Transactions\TransactionFields\StatementNumberField; -use PhpTwinfield\Transactions\TransactionLineFields\DateField; +use PhpTwinfield\Fields\DateField; +use PhpTwinfield\Fields\OfficeField; +use PhpTwinfield\Fields\Transaction\CloseValueField; +use PhpTwinfield\Fields\Transaction\StartValueField; +use PhpTwinfield\Fields\Transaction\StatementNumberField; use Webmozart\Assert\Assert; /** @@ -16,50 +17,51 @@ */ class ElectronicBankStatement { - use StartAndCloseValueFields; + use CloseValueField; use DateField; use OfficeField; + use StartValueField; use StatementNumberField; - /** - * Optional attribute to indicate whether duplicates may be imported or not. - * - * @var bool - */ - private $importDuplicate = false; - - /** - * Contains the bank statement transactions. + /* + * Account number. Either account or iban or code should be set. * - * @var array + * @var ?string */ - private $transactions = []; + private $account; - /** - * Account number. Either account or iban or code should be set. + /* + * Code of the corresponding bank book. Either account or iban or code should be set. * * @var ?string */ - private $account; + private $code; - /** + /* * IBAN account number. Either account or iban or code should be set. * * @var ?string */ private $iban; - /** - * Code of the corresponding bank book. Either account or iban or code should be set. + /* + * Optional attribute to indicate whether duplicates may be imported or not. * - * @var ?string + * @var bool */ - private $code; + private $importDuplicate = false; + + /* + * Contains the bank statement transactions. + * + * @var array + */ + private $transactions = []; public function __construct() { $this->currency = new Currency("EUR"); - $this->startvalue = new Money(0, $this->getCurrency()); + $this->startValue = new Money(0, $this->getCurrency()); } public function getAccount(): ?string @@ -74,18 +76,6 @@ public function setAccount(string $account): void $this->code = null; } - public function getIban(): ?string - { - return $this->iban; - } - - public function setIban(string $iban): void - { - $this->iban = $iban; - $this->account = null; - $this->code = null; - } - public function getCode(): ?string { return $this->code; @@ -101,6 +91,18 @@ public function setCode($code): void $this->iban = null; } + public function getIban(): ?string + { + return $this->iban; + } + + public function setIban(string $iban): void + { + $this->iban = $iban; + $this->account = null; + $this->code = null; + } + /** * @return bool */ diff --git a/src/ElectronicBankStatementTransaction.php b/src/ElectronicBankStatementTransaction.php index 967bd4d6..26332ef5 100644 --- a/src/ElectronicBankStatementTransaction.php +++ b/src/ElectronicBankStatementTransaction.php @@ -3,32 +3,38 @@ namespace PhpTwinfield; use PhpTwinfield\Enums\LineType; -use PhpTwinfield\Transactions\TransactionLineFields\FourDimFields; -use PhpTwinfield\Transactions\TransactionLineFields\ValueFields; +use PhpTwinfield\Fields\Dim1Field; +use PhpTwinfield\Fields\Dim2Field; +use PhpTwinfield\Fields\Dim3Field; +use PhpTwinfield\Fields\Dim4Field; +use PhpTwinfield\Fields\Transaction\TransactionLine\ValueFields; class ElectronicBankStatementTransaction { + use Dim1Field; + use Dim2Field; + use Dim3Field; + use Dim4Field; use ValueFields; - use FourDimFields; /** - * Contra account number in BBAN format. Either use contraaccount or contraiban or leave empty. + * Contra account number in BBAN format. Either use contraAccount or contraIban or leave empty. * * @var string */ - private $contraaccount; + private $contraAccount; + /** - * Contra account number in IBAN format. Either use contraaccount or contraiban or leave empty. + * Contra account number in IBAN format. Either use contraAccount or contraIban or leave empty. * * @var string */ - private $contraiban; + private $contraIban; + /** - * Transaction type code. - * * @var string */ - private $type; + private $description; /** * Reference for own use. @@ -38,40 +44,50 @@ class ElectronicBankStatementTransaction private $reference; /** + * Transaction type code. + * * @var string */ - private $description; + private $type; - public function getContraaccount(): ?string + public function getContraAccount(): ?string { - return $this->contraaccount; + return $this->contraAccount; } - public function setContraaccount(string $contraaccount): void + public function setContraAccount(string $contraAccount): void { - $this->contraaccount = $contraaccount; - $this->contraiban = null; + $this->contraAccount = $contraAccount; + $this->contraIban = null; } - public function getContraiban(): ?string + public function getContraIban(): ?string { - return $this->contraiban; + return $this->contraIban; } - public function setContraiban(string $contraiban): void + public function setContraIban(string $contraIban): void { - $this->contraiban = $contraiban; - $this->contraaccount = null; + $this->contraIban = $contraIban; + $this->contraAccount = null; } - public function getType(): string + public function getDescription(): string { - return $this->type; + return $this->description; } - public function setType(string $type): void + public function setDescription(string $description): void { - $this->type = $type; + $this->description = $description; + } + + public function getLineType(): ?LineType + { + /* + * Electronic bank statement transactions don't have line types. + */ + return null; } public function getReference(): ?string @@ -84,22 +100,14 @@ public function setReference(string $reference): void $this->reference = $reference; } - public function getDescription(): string - { - return $this->description; - } - - public function setDescription(string $description): void + public function getType(): string { - $this->description = $description; + return $this->type; } - public function getLineType(): ?LineType + public function setType(string $type): void { - /* - * Electronic bank statement transactions don't have line types. - */ - return null; + $this->type = $type; } /** diff --git a/src/Enums/MatchStatus.php b/src/Enums/MatchStatus.php new file mode 100644 index 00000000..1867dc5a --- /dev/null +++ b/src/Enums/MatchStatus.php @@ -0,0 +1,21 @@ +date; - } - - /** - * @return string|null - */ - public function getDateToString(): ?string - { - if ($this->getDate() != null) { - return Util::formatDate($this->getDate()); - } else { - return null; - } - } - - /** - * @param \DateTimeInterface|null $date - * @return $this - */ - public function setDate(?\DateTimeInterface $date) - { - $this->date = $date; - return $this; - } - - /** - * @param string|null $dateString - * @return $this - * @throws Exception - */ - public function setDateFromString(?string $dateString) - { - if ((bool)strtotime($dateString)) { - return $this->setDate(Util::parseDate($dateString)); - } else { - return $this->setDate(null); - } - } +date; + } + + /** + * @return string|null + */ + public function getDateToString(): ?string + { + if ($this->getDate() != null) { + return Util::formatDate($this->getDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $date + * @return $this + */ + public function setDate(?\DateTimeInterface $date) + { + $this->date = $date; + return $this; + } + + /** + * @param string|null $dateString + * @return $this + * @throws Exception + */ + public function setDateFromString(?string $dateString) + { + if ((bool)strtotime($dateString)) { + return $this->setDate(Util::parseDate($dateString)); + } else { + return $this->setDate(null); + } + } } \ No newline at end of file diff --git a/src/Fields/DescriptionField.php b/src/Fields/DescriptionField.php index 6df17751..ba659eb6 100644 --- a/src/Fields/DescriptionField.php +++ b/src/Fields/DescriptionField.php @@ -6,7 +6,7 @@ trait DescriptionField { /** * Description field - * Used by: CustomerLine, CustomerPostingRule, InvoiceLine, SupplierLine, SupplierPostingRule + * Used by: BaseTransactionLine, CustomerLine, CustomerPostingRule, InvoiceLine, SupplierLine, SupplierPostingRule * * @var string|null */ diff --git a/src/Fields/Dimensions/Level34/FixedAsset/Dim2Field.php b/src/Fields/Dim2Field.php similarity index 89% rename from src/Fields/Dimensions/Level34/FixedAsset/Dim2Field.php rename to src/Fields/Dim2Field.php index a3f33477..e64667c0 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/Dim2Field.php +++ b/src/Fields/Dim2Field.php @@ -1,12 +1,12 @@ dueDate; - } - - /** - * @return string|null - */ - public function getDueDateToString(): ?string - { - if ($this->getDueDate() != null) { - return Util::formatDate($this->getDueDate()); - } else { - return null; - } - } - - /** - * @param \DateTimeInterface|null $dueDate - * @return $this - */ - public function setDueDate(?\DateTimeInterface $dueDate) - { - $this->dueDate = $dueDate; - return $this; - } - - /** - * @param string|null $dueDateString - * @return $this - * @throws Exception - */ - public function setDueDateFromString(?string $dueDateString) - { - if ((bool)strtotime($dueDateString)) { - return $this->setDueDate(Util::parseDate($dueDateString)); - } else { - return $this->setDueDate(null); - } - } +dueDate; + } + + /** + * @return string|null + */ + public function getDueDateToString(): ?string + { + if ($this->getDueDate() != null) { + return Util::formatDate($this->getDueDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $dueDate + * @return $this + */ + public function setDueDate(?\DateTimeInterface $dueDate) + { + $this->dueDate = $dueDate; + return $this; + } + + /** + * @param string|null $dueDateString + * @return $this + * @throws Exception + */ + public function setDueDateFromString(?string $dueDateString) + { + if ((bool)strtotime($dueDateString)) { + return $this->setDueDate(Util::parseDate($dueDateString)); + } else { + return $this->setDueDate(null); + } + } } \ No newline at end of file diff --git a/src/Fields/FreeText1Field.php b/src/Fields/FreeText1Field.php index 9f60251e..32d2b7d1 100644 --- a/src/Fields/FreeText1Field.php +++ b/src/Fields/FreeText1Field.php @@ -6,7 +6,7 @@ trait FreeText1Field { /** * Free text 1 field - * Used by: FixedAssetFixedAssets, InvoiceLine + * Used by: BaseTransaction, FixedAssetFixedAssets, InvoiceLine * * @var string|null */ diff --git a/src/Fields/FreeText2Field.php b/src/Fields/FreeText2Field.php index ddc25e64..4ae0b79c 100644 --- a/src/Fields/FreeText2Field.php +++ b/src/Fields/FreeText2Field.php @@ -6,7 +6,7 @@ trait FreeText2Field { /** * Free text 2 field - * Used by: CustomerCreditManagement, FixedAssetFixedAssets, InvoiceLine + * Used by: BaseTransaction, CustomerCreditManagement, FixedAssetFixedAssets, InvoiceLine * * @var string|null */ diff --git a/src/Fields/FreeText3Field.php b/src/Fields/FreeText3Field.php index 714440f6..385794b6 100644 --- a/src/Fields/FreeText3Field.php +++ b/src/Fields/FreeText3Field.php @@ -6,7 +6,7 @@ trait FreeText3Field { /** * Free text 3 field - * Used by: CustomerCreditManagement, FixedAssetFixedAssets, InvoiceLine + * Used by: BaseTransaction, CustomerCreditManagement, FixedAssetFixedAssets, InvoiceLine * * @var string|null */ diff --git a/src/Fields/IDField.php b/src/Fields/IDField.php index 6b3c94ff..28b4df21 100644 --- a/src/Fields/IDField.php +++ b/src/Fields/IDField.php @@ -6,7 +6,7 @@ trait IDField { /** * ID field - * Used by: ArticleLine, AssetMethodFreeText, CustomerAddress, CustomerBank, CustomerPostingRule, InvoiceLine, RateRateChange, SupplierAddress, SupplierBank, SupplierPostingRule, VatCodeAccount + * Used by: ArticleLine, AssetMethodFreeText, BaseTransactionLine, CustomerAddress, CustomerBank, CustomerPostingRule, InvoiceLine, RateRateChange, SupplierAddress, SupplierBank, SupplierPostingRule, VatCodeAccount * * @var int|null */ diff --git a/src/Fields/Invoice/InvoiceNumberField.php b/src/Fields/Invoice/InvoiceNumberField.php index 36251c0c..5327a8c4 100644 --- a/src/Fields/Invoice/InvoiceNumberField.php +++ b/src/Fields/Invoice/InvoiceNumberField.php @@ -8,23 +8,23 @@ trait InvoiceNumberField * Invoice number field * Used by: Invoice * - * @var int|null + * @var string|null */ private $invoiceNumber; /** - * @return null|int + * @return null|string */ - public function getInvoiceNumber(): ?int + public function getInvoiceNumber(): ?string { return $this->invoiceNumber; } /** - * @param null|int $invoiceNumber + * @param null|string $invoiceNumber * @return $this */ - public function setInvoiceNumber(?int $invoiceNumber): self + public function setInvoiceNumber(?string $invoiceNumber): self { $this->invoiceNumber = $invoiceNumber; return $this; diff --git a/src/Fields/VatCode/LineTypeField.php b/src/Fields/LineTypeField.php similarity index 86% rename from src/Fields/VatCode/LineTypeField.php rename to src/Fields/LineTypeField.php index d291c235..d2244307 100644 --- a/src/Fields/VatCode/LineTypeField.php +++ b/src/Fields/LineTypeField.php @@ -1,41 +1,41 @@ -lineType; - } - - /** - * @param LineType|null $linetype - * @return $this - */ - public function setLineType(?LineType $lineType): self - { - $this->lineType = $lineType; - return $this; - } - - /** - * @param string|null $lineTypeString - * @return $this - * @throws Exception - */ - public function setLineTypeFromString(?string $lineTypeString) - { - return $this->setLineType(new LineType((string)$lineTypeString)); - } +lineType; + } + + /** + * @param LineType|null $linetype + * @return $this + */ + public function setLineType(?LineType $lineType): self + { + $this->lineType = $lineType; + return $this; + } + + /** + * @param string|null $lineTypeString + * @return $this + * @throws Exception + */ + public function setLineTypeFromString(?string $lineTypeString) + { + return $this->setLineType(new LineType((string)$lineTypeString)); + } } \ No newline at end of file diff --git a/src/Fields/Invoice/PerformanceDateField.php b/src/Fields/PerformanceDateField.php similarity index 89% rename from src/Fields/Invoice/PerformanceDateField.php rename to src/Fields/PerformanceDateField.php index b08efba4..b6836f2f 100644 --- a/src/Fields/Invoice/PerformanceDateField.php +++ b/src/Fields/PerformanceDateField.php @@ -1,66 +1,66 @@ -performanceDate; - } - - /** - * @return string|null - */ - public function getPerformanceDateToString(): ?string - { - if ($this->getPerformanceDate() != null) { - return Util::formatDate($this->getPerformanceDate()); - } else { - return null; - } - } - - /** - * @param \DateTimeInterface|null $performanceDate - * @return $this - */ - public function setPerformanceDate(?\DateTimeInterface $performanceDate) - { - $this->performanceDate = $performanceDate; - return $this; - } - - /** - * @param string|null $performanceDateString - * @return $this - * @throws Exception - */ - public function setPerformanceDateFromString(?string $performanceDateString) - { - if ((bool)strtotime($performanceDateString)) { - return $this->setPerformanceDate(Util::parseDate($performanceDateString)); - } else { - return $this->setPerformanceDate(null); - } - } +performanceDate; + } + + /** + * @return string|null + */ + public function getPerformanceDateToString(): ?string + { + if ($this->getPerformanceDate() != null) { + return Util::formatDate($this->getPerformanceDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $performanceDate + * @return $this + */ + public function setPerformanceDate(?\DateTimeInterface $performanceDate) + { + $this->performanceDate = $performanceDate; + return $this; + } + + /** + * @param string|null $performanceDateString + * @return $this + * @throws Exception + */ + public function setPerformanceDateFromString(?string $performanceDateString) + { + if ((bool)strtotime($performanceDateString)) { + return $this->setPerformanceDate(Util::parseDate($performanceDateString)); + } else { + return $this->setPerformanceDate(null); + } + } } \ No newline at end of file diff --git a/src/Fields/Invoice/PerformanceTypeField.php b/src/Fields/PerformanceTypeField.php similarity index 82% rename from src/Fields/Invoice/PerformanceTypeField.php rename to src/Fields/PerformanceTypeField.php index 1d33a61e..b9c4a8c0 100644 --- a/src/Fields/Invoice/PerformanceTypeField.php +++ b/src/Fields/PerformanceTypeField.php @@ -1,41 +1,41 @@ -performanceType; - } - - /** - * @param PerformanceType|null $performanceType - * @return $this - */ - public function setPerformanceType(?PerformanceType $performanceType): self - { - $this->performanceType = $performanceType; - return $this; - } - - /** - * @param string|null $performanceTypeString - * @return $this - * @throws Exception - */ - public function setPerformanceTypeFromString(?string $performanceTypeString) - { - return $this->setPerformanceType(new PerformanceType((string)$performanceTypeString)); - } +performanceType; + } + + /** + * @param PerformanceType|null $performanceType + * @return $this + */ + public function setPerformanceType(?PerformanceType $performanceType): self + { + $this->performanceType = $performanceType; + return $this; + } + + /** + * @param string|null $performanceTypeString + * @return $this + * @throws Exception + */ + public function setPerformanceTypeFromString(?string $performanceTypeString) + { + return $this->setPerformanceType(new PerformanceType((string)$performanceTypeString)); + } } \ No newline at end of file diff --git a/src/Fields/PeriodField.php b/src/Fields/PeriodField.php index 30cbce06..4cac81e5 100644 --- a/src/Fields/PeriodField.php +++ b/src/Fields/PeriodField.php @@ -6,7 +6,7 @@ trait PeriodField { /** * Period in 'YYYY/PP' format (e.g. '2013/05') - * Used by: FixedAssetTransactionLine, Invoice + * Used by: BaseTransaction, FixedAssetTransactionLine, Invoice * * @var string */ diff --git a/src/Fields/Transaction/AutoBalanceVatField.php b/src/Fields/Transaction/AutoBalanceVatField.php new file mode 100644 index 00000000..7cf20206 --- /dev/null +++ b/src/Fields/Transaction/AutoBalanceVatField.php @@ -0,0 +1,47 @@ +autoBalanceVat; + } + + public function getAutoBalanceVatToString(): ?string + { + return ($this->getAutoBalanceVat()) ? 'true' : 'false'; + } + + /** + * @param bool $autoBalanceVat + * @return $this + */ + public function setAutoBalanceVat(?bool $autoBalanceVat): self + { + $this->autoBalanceVat = $autoBalanceVat; + return $this; + } + + /** + * @param string|null $autoBalanceVatString + * @return $this + * @throws Exception + */ + public function setAutoBalanceVatFromString(?string $autoBalanceVatString) + { + return $this->setAutoBalanceVat(filter_var($autoBalanceVatString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/CloseValueField.php b/src/Fields/Transaction/CloseValueField.php new file mode 100644 index 00000000..827a4be1 --- /dev/null +++ b/src/Fields/Transaction/CloseValueField.php @@ -0,0 +1,62 @@ +closeValue; + } + + /** + * @return float|null + */ + public function getCloseValueToFloat(): ?float + { + if ($this->getCloseValue() != null) { + return Util::formatMoney($this->getCloseValue()); + } else { + return 0; + } + } + + /** + * @param Money|null $closeValue + * @return $this + */ + public function setCloseValue(?Money $closeValue) + { + $this->closeValue = $closeValue; + + return $this; + } + + /** + * @param float|null $closeValueFloat + * @return $this + * @throws Exception + */ + public function setCloseValueFromFloat(?float $closeValueFloat) + { + if ((float)$closeValueFloat) { + return $this->setCloseValue(Money::EUR(100 * $closeValueFloat)); + } else { + return $this->setCloseValue(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/DateRaiseWarningField.php b/src/Fields/Transaction/DateRaiseWarningField.php new file mode 100644 index 00000000..35ab04ad --- /dev/null +++ b/src/Fields/Transaction/DateRaiseWarningField.php @@ -0,0 +1,47 @@ +dateRaiseWarning; + } + + public function getDateRaiseWarningToString(): ?string + { + return ($this->getDateRaiseWarning()) ? 'true' : 'false'; + } + + /** + * @param bool $dateRaiseWarning + * @return $this + */ + public function setDateRaiseWarning(?bool $dateRaiseWarning): self + { + $this->dateRaiseWarning = $dateRaiseWarning; + return $this; + } + + /** + * @param string|null $dateRaiseWarningString + * @return $this + * @throws Exception + */ + public function setDateRaiseWarningFromString(?string $dateRaiseWarningString) + { + return $this->setDateRaiseWarning(filter_var($dateRaiseWarningString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/DestinyField.php b/src/Fields/Transaction/DestinyField.php new file mode 100644 index 00000000..2683d3ae --- /dev/null +++ b/src/Fields/Transaction/DestinyField.php @@ -0,0 +1,41 @@ +destiny; + } + + /** + * @param Destiny|null $destiny + * @return $this + */ + public function setDestiny(?Destiny $destiny): self + { + $this->destiny = $destiny; + return $this; + } + + /** + * @param string|null $destinyString + * @return $this + * @throws Exception + */ + public function setDestinyFromString(?string $destinyString) + { + return $this->setDestiny(new Destiny((string)$destinyString)); + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/InputDateField.php b/src/Fields/Transaction/InputDateField.php new file mode 100644 index 00000000..d03b3a9f --- /dev/null +++ b/src/Fields/Transaction/InputDateField.php @@ -0,0 +1,66 @@ +inputDate; + } + + /** + * @return string|null + */ + public function getInputDateToString(): ?string + { + if ($this->getInputDate() != null) { + return Util::formatDateTime($this->getInputDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $inputDate + * @return $this + */ + public function setInputDate(?\DateTimeInterface $inputDate) + { + $this->inputDate = $inputDate; + return $this; + } + + /** + * @param string|null $inputDateString + * @return $this + * @throws Exception + */ + public function setInputDateFromString(?string $inputDateString) + { + if ((bool)strtotime($inputDateString)) { + return $this->setInputDate(Util::parseDateTime($inputDateString)); + } else { + return $this->setInputDate(null); + } + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/InvoiceNumberField.php b/src/Fields/Transaction/InvoiceNumberField.php new file mode 100644 index 00000000..e341d426 --- /dev/null +++ b/src/Fields/Transaction/InvoiceNumberField.php @@ -0,0 +1,32 @@ +invoiceNumber; + } + + /** + * @param null|string $invoiceNumber + * @return $this + */ + public function setInvoiceNumber(?string $invoiceNumber): self + { + $this->invoiceNumber = $invoiceNumber; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/InvoiceNumberRaiseWarningField.php b/src/Fields/Transaction/InvoiceNumberRaiseWarningField.php new file mode 100644 index 00000000..2f4c10d2 --- /dev/null +++ b/src/Fields/Transaction/InvoiceNumberRaiseWarningField.php @@ -0,0 +1,47 @@ +invoiceNumberRaiseWarning; + } + + public function getInvoiceNumberRaiseWarningToString(): ?string + { + return ($this->getInvoiceNumberRaiseWarning()) ? 'true' : 'false'; + } + + /** + * @param bool $invoiceNumberRaiseWarning + * @return $this + */ + public function setInvoiceNumberRaiseWarning(?bool $invoiceNumberRaiseWarning): self + { + $this->invoiceNumberRaiseWarning = $invoiceNumberRaiseWarning; + return $this; + } + + /** + * @param string|null $invoiceNumberRaiseWarningString + * @return $this + * @throws Exception + */ + public function setInvoiceNumberRaiseWarningFromString(?string $invoiceNumberRaiseWarningString) + { + return $this->setInvoiceNumberRaiseWarning(filter_var($invoiceNumberRaiseWarningString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Transactions/TransactionFields/LinesField.php b/src/Fields/Transaction/LinesField.php similarity index 84% rename from src/Transactions/TransactionFields/LinesField.php rename to src/Fields/Transaction/LinesField.php index 8b2a7d6f..e4ca3fc0 100644 --- a/src/Transactions/TransactionFields/LinesField.php +++ b/src/Fields/Transaction/LinesField.php @@ -1,18 +1,18 @@ [], @@ -21,8 +21,7 @@ trait LinesField ]; /** - * @return string The class name for transaction lines supported by this transaction. Must be an implementation of - * TransactionLine. + * @return string The class name for transaction lines supported by this transaction. Must be an implementation of BaseTransactionLine. */ abstract public function getLineClassName(): string; @@ -39,7 +38,7 @@ private function getLineCountForType(LineType $line_type): int } /** - * @return TransactionLine[] + * @return array[] */ public function getLines(): array { @@ -71,10 +70,10 @@ private function getVatLines(): array } /** - * @param TransactionLine $line + * @param $line * @return $this */ - public function addLine(TransactionLine $line) + public function addLine($line) { Assert::isInstanceOf($line, $this->getLineClassName()); @@ -89,7 +88,7 @@ public function addLine(TransactionLine $line) } /** - * @param TransactionLine[] $lines + * @param array $lines */ public function setLines(array $lines): void { diff --git a/src/Fields/Transaction/ModificationDateField.php b/src/Fields/Transaction/ModificationDateField.php new file mode 100644 index 00000000..f978db7f --- /dev/null +++ b/src/Fields/Transaction/ModificationDateField.php @@ -0,0 +1,66 @@ +modificationDate; + } + + /** + * @return string|null + */ + public function getModificationDateToString(): ?string + { + if ($this->getModificationDate() != null) { + return Util::formatDateTime($this->getModificationDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $modificationDate + * @return $this + */ + public function setModificationDate(?\DateTimeInterface $modificationDate) + { + $this->modificationDate = $modificationDate; + return $this; + } + + /** + * @param string|null $modificationDateString + * @return $this + * @throws Exception + */ + public function setModificationDateFromString(?string $modificationDateString) + { + if ((bool)strtotime($modificationDateString)) { + return $this->setModificationDate(Util::parseDateTime($modificationDateString)); + } else { + return $this->setModificationDate(null); + } + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/NumberField.php b/src/Fields/Transaction/NumberField.php new file mode 100644 index 00000000..67247915 --- /dev/null +++ b/src/Fields/Transaction/NumberField.php @@ -0,0 +1,32 @@ +number; + } + + /** + * @param null|int $number + * @return $this + */ + public function setNumber(?int $number): self + { + $this->number = $number; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/OriginField.php b/src/Fields/Transaction/OriginField.php new file mode 100644 index 00000000..f64111f7 --- /dev/null +++ b/src/Fields/Transaction/OriginField.php @@ -0,0 +1,32 @@ +origin; + } + + /** + * @param null|string $origin + * @return $this + */ + public function setOrigin(?string $origin): self + { + $this->origin = $origin; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/OriginReferenceField.php b/src/Fields/Transaction/OriginReferenceField.php new file mode 100644 index 00000000..6e9c2557 --- /dev/null +++ b/src/Fields/Transaction/OriginReferenceField.php @@ -0,0 +1,32 @@ +originReference; + } + + /** + * @param null|string $originReference + * @return $this + */ + public function setOriginReference(?string $originReference): self + { + $this->originReference = $originReference; + return $this; + } +} \ No newline at end of file diff --git a/src/Transactions/TransactionFields/PaymentReferenceField.php b/src/Fields/Transaction/PaymentReferenceField.php similarity index 63% rename from src/Transactions/TransactionFields/PaymentReferenceField.php rename to src/Fields/Transaction/PaymentReferenceField.php index 143452a4..fcca6770 100644 --- a/src/Transactions/TransactionFields/PaymentReferenceField.php +++ b/src/Fields/Transaction/PaymentReferenceField.php @@ -1,16 +1,19 @@ paymentReference = $paymentReference; - return $this; } -} +} \ No newline at end of file diff --git a/src/Fields/Transaction/RaiseWarningField.php b/src/Fields/Transaction/RaiseWarningField.php new file mode 100644 index 00000000..2419b50e --- /dev/null +++ b/src/Fields/Transaction/RaiseWarningField.php @@ -0,0 +1,47 @@ +raiseWarning; + } + + public function getRaiseWarningToString(): ?string + { + return ($this->getRaiseWarning()) ? 'true' : 'false'; + } + + /** + * @param bool $raiseWarning + * @return $this + */ + public function setRaiseWarning(?bool $raiseWarning): self + { + $this->raiseWarning = $raiseWarning; + return $this; + } + + /** + * @param string|null $raiseWarningString + * @return $this + * @throws Exception + */ + public function setRaiseWarningFromString(?string $raiseWarningString) + { + return $this->setRaiseWarning(filter_var($raiseWarningString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/RegimeField.php b/src/Fields/Transaction/RegimeField.php new file mode 100644 index 00000000..0d575b7c --- /dev/null +++ b/src/Fields/Transaction/RegimeField.php @@ -0,0 +1,41 @@ +regime; + } + + /** + * @param Regime|null $regime + * @return $this + */ + public function setRegime(?Regime $regime): self + { + $this->regime = $regime; + return $this; + } + + /** + * @param string|null $regimeString + * @return $this + * @throws Exception + */ + public function setRegimeFromString(?string $regimeString) + { + return $this->setRegime(new Regime((string)$regimeString)); + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/StartValueField.php b/src/Fields/Transaction/StartValueField.php new file mode 100644 index 00000000..65a98ad9 --- /dev/null +++ b/src/Fields/Transaction/StartValueField.php @@ -0,0 +1,62 @@ +startValue; + } + + /** + * @return float|null + */ + public function getStartValueToFloat(): ?float + { + if ($this->getStartValue() != null) { + return Util::formatMoney($this->getStartValue()); + } else { + return 0; + } + } + + /** + * @param Money|null $startValue + * @return $this + */ + public function setStartValue(?Money $startValue) + { + $this->startValue = $startValue; + + return $this; + } + + /** + * @param float|null $startValueFloat + * @return $this + * @throws Exception + */ + public function setStartValueFromFloat(?float $startValueFloat) + { + if ((float)$startValueFloat) { + return $this->setStartValue(Money::EUR(100 * $startValueFloat)); + } else { + return $this->setStartValue(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/StatementNumberField.php b/src/Fields/Transaction/StatementNumberField.php new file mode 100644 index 00000000..ba3f23eb --- /dev/null +++ b/src/Fields/Transaction/StatementNumberField.php @@ -0,0 +1,32 @@ +statementNumber; + } + + /** + * @param null|int $statementNumber + * @return $this + */ + public function setStatementNumber(?int $statementNumber): self + { + $this->statementNumber = $statementNumber; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/BaseValueField.php b/src/Fields/Transaction/TransactionLine/BaseValueField.php new file mode 100644 index 00000000..ee5d4b8a --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/BaseValueField.php @@ -0,0 +1,62 @@ +baseValue; + } + + /** + * @return float|null + */ + public function getBaseValueToFloat(): ?float + { + if ($this->getBaseValue() != null) { + return Util::formatMoney($this->getBaseValue()); + } else { + return 0; + } + } + + /** + * @param Money|null $baseValue + * @return $this + */ + public function setBaseValue(?Money $baseValue) + { + $this->baseValue = $baseValue; + + return $this; + } + + /** + * @param float|null $baseValueFloat + * @return $this + * @throws Exception + */ + public function setBaseValueFromFloat(?float $baseValueFloat) + { + if ((float)$baseValueFloat) { + return $this->setBaseValue(Money::EUR(100 * $baseValueFloat)); + } else { + return $this->setBaseValue(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/BaseValueOpenField.php b/src/Fields/Transaction/TransactionLine/BaseValueOpenField.php new file mode 100644 index 00000000..6bba766c --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/BaseValueOpenField.php @@ -0,0 +1,62 @@ +baseValueOpen; + } + + /** + * @return float|null + */ + public function getBaseValueOpenToFloat(): ?float + { + if ($this->getBaseValueOpen() != null) { + return Util::formatMoney($this->getBaseValueOpen()); + } else { + return 0; + } + } + + /** + * @param Money|null $baseValueOpen + * @return $this + */ + public function setBaseValueOpen(?Money $baseValueOpen) + { + $this->baseValueOpen = $baseValueOpen; + + return $this; + } + + /** + * @param float|null $baseValueOpenFloat + * @return $this + * @throws Exception + */ + public function setBaseValueOpenFromFloat(?float $baseValueOpenFloat) + { + if ((float)$baseValueOpenFloat) { + return $this->setBaseValueOpen(Money::EUR(100 * $baseValueOpenFloat)); + } else { + return $this->setBaseValueOpen(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/BaselineField.php b/src/Fields/Transaction/TransactionLine/BaselineField.php new file mode 100644 index 00000000..ec0f0c88 --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/BaselineField.php @@ -0,0 +1,32 @@ +baseline; + } + + /** + * @param null|int $baseline + * @return $this + */ + public function setBaseline(?int $baseline): self + { + $this->baseline = $baseline; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/CurrencyDateField.php b/src/Fields/Transaction/TransactionLine/CurrencyDateField.php new file mode 100644 index 00000000..0494a312 --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/CurrencyDateField.php @@ -0,0 +1,66 @@ +currencyDate; + } + + /** + * @return string|null + */ + public function getCurrencyDateToString(): ?string + { + if ($this->getCurrencyDate() != null) { + return Util::formatDateTime($this->getCurrencyDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $currencyDate + * @return $this + */ + public function setCurrencyDate(?\DateTimeInterface $currencyDate) + { + $this->currencyDate = $currencyDate; + return $this; + } + + /** + * @param string|null $currencyDateString + * @return $this + * @throws Exception + */ + public function setCurrencyDateFromString(?string $currencyDateString) + { + if ((bool)strtotime($currencyDateString)) { + return $this->setCurrencyDate(Util::parseDateTime($currencyDateString)); + } else { + return $this->setCurrencyDate(null); + } + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/DestOfficeField.php b/src/Fields/Transaction/TransactionLine/DestOfficeField.php new file mode 100644 index 00000000..0e2e2e1c --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/DestOfficeField.php @@ -0,0 +1,53 @@ +destOffice; + } + + public function getDestOfficeToString(): ?string + { + if ($this->getDestOffice() != null) { + return $this->destOffice->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDestOffice(?Office $destOffice): self + { + $this->destOffice = $destOffice; + return $this; + } + + /** + * @param string|null $officeCode + * @return $this + * @throws Exception + */ + public function setDestOfficeFromString(?string $officeCode) + { + $destOffice = new Office(); + $destOffice->setCode($officeCode); + return $this->setDestOffice($destOffice); + } +} diff --git a/src/Fields/Transaction/TransactionLine/Dim1Field.php b/src/Fields/Transaction/TransactionLine/Dim1Field.php new file mode 100644 index 00000000..123a97de --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/Dim1Field.php @@ -0,0 +1,54 @@ +dim1; + } + + public function getDim1ToString(): ?string + { + if ($this->getDim1() != null) { + return $this->dim1->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setDim1($dim1): self + { + $this->dim1 = $dim1; + return $this; + } + + /** + * @param string|null $dim1Code + * @return $this + * @throws Exception + */ + public function setDim1FromString(?string $dim1Code) + { + $dim1 = new Dummy(); + $dim1->setCode($dim1Code); + return $this->setDim1($dim1); + } +} diff --git a/src/Transactions/TransactionLineFields/FreeCharField.php b/src/Fields/Transaction/TransactionLine/FreeCharField.php similarity index 84% rename from src/Transactions/TransactionLineFields/FreeCharField.php rename to src/Fields/Transaction/TransactionLine/FreeCharField.php index 0096da8e..1cb155a7 100644 --- a/src/Transactions/TransactionLineFields/FreeCharField.php +++ b/src/Fields/Transaction/TransactionLine/FreeCharField.php @@ -1,13 +1,15 @@ matchDate; + } + + /** + * @return string|null + */ + public function getMatchDateToString(): ?string + { + if ($this->getMatchDate() != null) { + return Util::formatDateTime($this->getMatchDate()); + } else { + return null; + } + } + + /** + * @param \DateTimeInterface|null $matchDate + * @return $this + */ + public function setMatchDate(?\DateTimeInterface $matchDate) + { + $this->matchDate = $matchDate; + return $this; + } + + /** + * @param string|null $matchDateString + * @return $this + * @throws Exception + */ + public function setMatchDateFromString(?string $matchDateString) + { + if ((bool)strtotime($matchDateString)) { + return $this->setMatchDate(Util::parseDateTime($matchDateString)); + } else { + return $this->setMatchDate(null); + } + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/MatchLevelField.php b/src/Fields/Transaction/TransactionLine/MatchLevelField.php new file mode 100644 index 00000000..ed3019fb --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/MatchLevelField.php @@ -0,0 +1,32 @@ +matchLevel; + } + + /** + * @param null|int $matchLevel + * @return $this + */ + public function setMatchLevel(?int $matchLevel): self + { + $this->matchLevel = $matchLevel; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/MatchStatusField.php b/src/Fields/Transaction/TransactionLine/MatchStatusField.php new file mode 100644 index 00000000..b7686f74 --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/MatchStatusField.php @@ -0,0 +1,40 @@ +matchStatus; + } + + /** + * @param MatchStatus|null $matchStatus + * @return $this + */ + public function setMatchStatus(?MatchStatus $matchStatus): self + { + $this->matchStatus = $matchStatus; + return $this; + } + + /** + * @param string|null $matchStatusString + * @return $this + * @throws Exception + */ + public function setMatchStatusFromString(?string $matchStatusString) + { + return $this->setMatchStatus(new MatchStatus((string)$matchStatusString)); + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/PerformanceCountryField.php b/src/Fields/Transaction/TransactionLine/PerformanceCountryField.php new file mode 100644 index 00000000..38c9daf2 --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/PerformanceCountryField.php @@ -0,0 +1,54 @@ +performanceCountry; + } + + public function getPerformanceCountryToString(): ?string + { + if ($this->getPerformanceCountry() != null) { + return $this->performanceCountry->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setPerformanceCountry(?Country $performanceCountry): self + { + $this->performanceCountry = $performanceCountry; + return $this; + } + + /** + * @param string|null $performanceCountry + * @return $this + * @throws Exception + */ + public function setPerformanceCountryFromString(?string $performanceCountry) + { + $performanceCountry = new Country(); + $performanceCountry->setCode($performanceCountry); + return $this->setPerformanceCountry($performanceCountry); + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/PerformanceVatNumberField.php b/src/Fields/Transaction/TransactionLine/PerformanceVatNumberField.php new file mode 100644 index 00000000..fee4c6db --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/PerformanceVatNumberField.php @@ -0,0 +1,32 @@ +performanceVatNumber; + } + + /** + * @param null|string $performanceVatNumber + * @return $this + */ + public function setPerformanceVatNumber(?string $performanceVatNumber): self + { + $this->performanceVatNumber = $performanceVatNumber; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/RateField.php b/src/Fields/Transaction/TransactionLine/RateField.php new file mode 100644 index 00000000..68dca839 --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/RateField.php @@ -0,0 +1,32 @@ +rate; + } + + /** + * @param null|float $rate + * @return $this + */ + public function setRate(?float $rate): self + { + $this->rate = $rate; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/RelationField.php b/src/Fields/Transaction/TransactionLine/RelationField.php new file mode 100644 index 00000000..98cb533a --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/RelationField.php @@ -0,0 +1,32 @@ +relation; + } + + /** + * @param null|int $relation + * @return $this + */ + public function setRelation(?int $relation): self + { + $this->relation = $relation; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/RepRateField.php b/src/Fields/Transaction/TransactionLine/RepRateField.php new file mode 100644 index 00000000..99038ffb --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/RepRateField.php @@ -0,0 +1,32 @@ +repRate; + } + + /** + * @param null|float $repRate + * @return $this + */ + public function setRepRate(?float $repRate): self + { + $this->repRate = $repRate; + return $this; + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/RepValueField.php b/src/Fields/Transaction/TransactionLine/RepValueField.php new file mode 100644 index 00000000..0b5002a4 --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/RepValueField.php @@ -0,0 +1,62 @@ +repValue; + } + + /** + * @return float|null + */ + public function getRepValueToFloat(): ?float + { + if ($this->getRepValue() != null) { + return Util::formatMoney($this->getRepValue()); + } else { + return 0; + } + } + + /** + * @param Money|null $repValue + * @return $this + */ + public function setRepValue(?Money $repValue) + { + $this->repValue = $repValue; + + return $this; + } + + /** + * @param float|null $repValueFloat + * @return $this + * @throws Exception + */ + public function setRepValueFromFloat(?float $repValueFloat) + { + if ((float)$repValueFloat) { + return $this->setRepValue(Money::EUR(100 * $repValueFloat)); + } else { + return $this->setRepValue(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/RepValueOpenField.php b/src/Fields/Transaction/TransactionLine/RepValueOpenField.php new file mode 100644 index 00000000..b3d05ee9 --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/RepValueOpenField.php @@ -0,0 +1,62 @@ +repValueOpen; + } + + /** + * @return float|null + */ + public function getRepValueOpenToFloat(): ?float + { + if ($this->getRepValueOpen() != null) { + return Util::formatMoney($this->getRepValueOpen()); + } else { + return 0; + } + } + + /** + * @param Money|null $repValueOpen + * @return $this + */ + public function setRepValueOpen(?Money $repValueOpen) + { + $this->repValueOpen = $repValueOpen; + + return $this; + } + + /** + * @param float|null $repValueOpenFloat + * @return $this + * @throws Exception + */ + public function setRepValueOpenFromFloat(?float $repValueOpenFloat) + { + if ((float)$repValueOpenFloat) { + return $this->setRepValueOpen(Money::EUR(100 * $repValueOpenFloat)); + } else { + return $this->setRepValueOpen(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Transactions/TransactionLineFields/ValueFields.php b/src/Fields/Transaction/TransactionLine/ValueFields.php similarity index 81% rename from src/Transactions/TransactionLineFields/ValueFields.php rename to src/Fields/Transaction/TransactionLine/ValueFields.php index 54286673..fde35e95 100644 --- a/src/Transactions/TransactionLineFields/ValueFields.php +++ b/src/Fields/Transaction/TransactionLine/ValueFields.php @@ -1,6 +1,6 @@ value->absolute(); } + /** + * @return float|null + */ + public function getValueToFloat(): ?float + { + if ($this->getValue() != null) { + return Util::formatMoney($this->getValue()); + } else { + return 0; + } + } + public function getSignedValue(): Money { return $this->value; @@ -112,4 +124,18 @@ public function setValue(Money $value) $this->value = $value; return $this; } + + /** + * @param float|null $valueFloat + * @return $this + * @throws Exception + */ + public function setValueFromFloat(?float $valueFloat) + { + if ((float)$valueFloat) { + return $this->setValue(Money::EUR(100 * $valueFloat)); + } else { + return $this->setValue(Money::EUR(0)); + } + } } \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/ValueOpenField.php b/src/Fields/Transaction/TransactionLine/ValueOpenField.php new file mode 100644 index 00000000..33668dd7 --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/ValueOpenField.php @@ -0,0 +1,62 @@ +valueOpen; + } + + /** + * @return float|null + */ + public function getValueOpenToFloat(): ?float + { + if ($this->getValueOpen() != null) { + return Util::formatMoney($this->getValueOpen()); + } else { + return 0; + } + } + + /** + * @param Money|null $valueOpen + * @return $this + */ + public function setValueOpen(?Money $valueOpen) + { + $this->valueOpen = $valueOpen; + + return $this; + } + + /** + * @param float|null $valueOpenFloat + * @return $this + * @throws Exception + */ + public function setValueOpenFromFloat(?float $valueOpenFloat) + { + if ((float)$valueOpenFloat) { + return $this->setValueOpen(Money::EUR(100 * $valueOpenFloat)); + } else { + return $this->setValueOpen(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/VatBaseTotalField.php b/src/Fields/Transaction/TransactionLine/VatBaseTotalField.php new file mode 100644 index 00000000..aea42f7c --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/VatBaseTotalField.php @@ -0,0 +1,62 @@ +vatBaseTotal; + } + + /** + * @return float|null + */ + public function getVatBaseTotalToFloat(): ?float + { + if ($this->getVatBaseTotal() != null) { + return Util::formatMoney($this->getVatBaseTotal()); + } else { + return 0; + } + } + + /** + * @param Money|null $vatBaseTotal + * @return $this + */ + public function setVatBaseTotal(?Money $vatBaseTotal) + { + $this->vatBaseTotal = $vatBaseTotal; + + return $this; + } + + /** + * @param float|null $vatBaseTotalFloat + * @return $this + * @throws Exception + */ + public function setVatBaseTotalFromFloat(?float $vatBaseTotalFloat) + { + if ((float)$vatBaseTotalFloat) { + return $this->setVatBaseTotal(Money::EUR(100 * $vatBaseTotalFloat)); + } else { + return $this->setVatBaseTotal(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/VatBaseTurnoverField.php b/src/Fields/Transaction/TransactionLine/VatBaseTurnoverField.php new file mode 100644 index 00000000..9db8b86b --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/VatBaseTurnoverField.php @@ -0,0 +1,62 @@ +vatBaseTurnover; + } + + /** + * @return float|null + */ + public function getVatBaseTurnoverToFloat(): ?float + { + if ($this->getVatBaseTurnover() != null) { + return Util::formatMoney($this->getVatBaseTurnover()); + } else { + return 0; + } + } + + /** + * @param Money|null $vatBaseTurnover + * @return $this + */ + public function setVatBaseTurnover(?Money $vatBaseTurnover) + { + $this->vatBaseTurnover = $vatBaseTurnover; + + return $this; + } + + /** + * @param float|null $vatBaseTurnoverFloat + * @return $this + * @throws Exception + */ + public function setVatBaseTurnoverFromFloat(?float $vatBaseTurnoverFloat) + { + if ((float)$vatBaseTurnoverFloat) { + return $this->setVatBaseTurnover(Money::EUR(100 * $vatBaseTurnoverFloat)); + } else { + return $this->setVatBaseTurnover(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/VatBaseValueField.php b/src/Fields/Transaction/TransactionLine/VatBaseValueField.php new file mode 100644 index 00000000..f38cd19f --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/VatBaseValueField.php @@ -0,0 +1,62 @@ +vatBaseValue; + } + + /** + * @return float|null + */ + public function getVatBaseValueToFloat(): ?float + { + if ($this->getVatBaseValue() != null) { + return Util::formatMoney($this->getVatBaseValue()); + } else { + return 0; + } + } + + /** + * @param Money|null $vatBaseValue + * @return $this + */ + public function setVatBaseValue(?Money $vatBaseValue) + { + $this->vatBaseValue = $vatBaseValue; + + return $this; + } + + /** + * @param float|null $vatBaseValueFloat + * @return $this + * @throws Exception + */ + public function setVatBaseValueFromFloat(?float $vatBaseValueFloat) + { + if ((float)$vatBaseValueFloat) { + return $this->setVatBaseValue(Money::EUR(100 * $vatBaseValueFloat)); + } else { + return $this->setVatBaseValue(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/VatRepTotalField.php b/src/Fields/Transaction/TransactionLine/VatRepTotalField.php new file mode 100644 index 00000000..a77676e4 --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/VatRepTotalField.php @@ -0,0 +1,62 @@ +vatRepTotal; + } + + /** + * @return float|null + */ + public function getVatRepTotalToFloat(): ?float + { + if ($this->getVatRepTotal() != null) { + return Util::formatMoney($this->getVatRepTotal()); + } else { + return 0; + } + } + + /** + * @param Money|null $vatRepTotal + * @return $this + */ + public function setVatRepTotal(?Money $vatRepTotal) + { + $this->vatRepTotal = $vatRepTotal; + + return $this; + } + + /** + * @param float|null $vatRepTotalFloat + * @return $this + * @throws Exception + */ + public function setVatRepTotalFromFloat(?float $vatRepTotalFloat) + { + if ((float)$vatRepTotalFloat) { + return $this->setVatRepTotal(Money::EUR(100 * $vatRepTotalFloat)); + } else { + return $this->setVatRepTotal(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/VatRepTurnoverField.php b/src/Fields/Transaction/TransactionLine/VatRepTurnoverField.php new file mode 100644 index 00000000..92490ddd --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/VatRepTurnoverField.php @@ -0,0 +1,62 @@ +vatRepTurnover; + } + + /** + * @return float|null + */ + public function getVatRepTurnoverToFloat(): ?float + { + if ($this->getVatRepTurnover() != null) { + return Util::formatMoney($this->getVatRepTurnover()); + } else { + return 0; + } + } + + /** + * @param Money|null $vatRepTurnover + * @return $this + */ + public function setVatRepTurnover(?Money $vatRepTurnover) + { + $this->vatRepTurnover = $vatRepTurnover; + + return $this; + } + + /** + * @param float|null $vatRepTurnoverFloat + * @return $this + * @throws Exception + */ + public function setVatRepTurnoverFromFloat(?float $vatRepTurnoverFloat) + { + if ((float)$vatRepTurnoverFloat) { + return $this->setVatRepTurnover(Money::EUR(100 * $vatRepTurnoverFloat)); + } else { + return $this->setVatRepTurnover(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/VatRepValueField.php b/src/Fields/Transaction/TransactionLine/VatRepValueField.php new file mode 100644 index 00000000..e4199f5d --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/VatRepValueField.php @@ -0,0 +1,62 @@ +vatRepValue; + } + + /** + * @return float|null + */ + public function getVatRepValueToFloat(): ?float + { + if ($this->getVatRepValue() != null) { + return Util::formatMoney($this->getVatRepValue()); + } else { + return 0; + } + } + + /** + * @param Money|null $vatRepValue + * @return $this + */ + public function setVatRepValue(?Money $vatRepValue) + { + $this->vatRepValue = $vatRepValue; + + return $this; + } + + /** + * @param float|null $vatRepValueFloat + * @return $this + * @throws Exception + */ + public function setVatRepValueFromFloat(?float $vatRepValueFloat) + { + if ((float)$vatRepValueFloat) { + return $this->setVatRepValue(Money::EUR(100 * $vatRepValueFloat)); + } else { + return $this->setVatRepValue(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/VatTotalField.php b/src/Fields/Transaction/TransactionLine/VatTotalField.php new file mode 100644 index 00000000..4e3f74ed --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/VatTotalField.php @@ -0,0 +1,62 @@ +vatTotal; + } + + /** + * @return float|null + */ + public function getVatTotalToFloat(): ?float + { + if ($this->getVatTotal() != null) { + return Util::formatMoney($this->getVatTotal()); + } else { + return 0; + } + } + + /** + * @param Money|null $vatTotal + * @return $this + */ + public function setVatTotal(?Money $vatTotal) + { + $this->vatTotal = $vatTotal; + + return $this; + } + + /** + * @param float|null $vatTotalFloat + * @return $this + * @throws Exception + */ + public function setVatTotalFromFloat(?float $vatTotalFloat) + { + if ((float)$vatTotalFloat) { + return $this->setVatTotal(Money::EUR(100 * $vatTotalFloat)); + } else { + return $this->setVatTotal(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/VatTurnoverField.php b/src/Fields/Transaction/TransactionLine/VatTurnoverField.php new file mode 100644 index 00000000..bd35adac --- /dev/null +++ b/src/Fields/Transaction/TransactionLine/VatTurnoverField.php @@ -0,0 +1,62 @@ +vatTurnover; + } + + /** + * @return float|null + */ + public function getVatTurnoverToFloat(): ?float + { + if ($this->getVatTurnover() != null) { + return Util::formatMoney($this->getVatTurnover()); + } else { + return 0; + } + } + + /** + * @param Money|null $vatTurnover + * @return $this + */ + public function setVatTurnover(?Money $vatTurnover) + { + $this->vatTurnover = $vatTurnover; + + return $this; + } + + /** + * @param float|null $vatTurnoverFloat + * @return $this + * @throws Exception + */ + public function setVatTurnoverFromFloat(?float $vatTurnoverFloat) + { + if ((float)$vatTurnoverFloat) { + return $this->setVatTurnover(Money::EUR(100 * $vatTurnoverFloat)); + } else { + return $this->setVatTurnover(Money::EUR(0)); + } + } +} \ No newline at end of file diff --git a/src/Fields/UserField.php b/src/Fields/UserField.php index 95d13cbd..882482d7 100644 --- a/src/Fields/UserField.php +++ b/src/Fields/UserField.php @@ -6,7 +6,7 @@ /** * The user - * Used by: AssetMethod, Office, Rate, VatCode, VatCodePercentage + * Used by: AssetMethod, BaseTransaction, Office, Rate, VatCode, VatCodePercentage * * @package PhpTwinfield\Traits */ diff --git a/src/Fields/VatCodeField.php b/src/Fields/VatCodeField.php index a5d1a5da..3b61a21b 100644 --- a/src/Fields/VatCodeField.php +++ b/src/Fields/VatCodeField.php @@ -6,7 +6,7 @@ /** * The VAT code - * Used by: Activity, Article, CustomerFinancials, CustomerLine, FixedAssetFinancials, GeneralLedgerFinancials, InvoiceLine, InvoiceVatLine, Project, SupplierFinancials, SupplierLine + * Used by: Activity, Article, BaseTransactionLine, CustomerFinancials, CustomerLine, FixedAssetFinancials, GeneralLedgerFinancials, InvoiceLine, InvoiceVatLine, Project, SupplierFinancials, SupplierLine * * @package PhpTwinfield\Traits */ diff --git a/src/Fields/Invoice/VatValueField.php b/src/Fields/VatValueField.php similarity index 88% rename from src/Fields/Invoice/VatValueField.php rename to src/Fields/VatValueField.php index c1cb1161..27247b83 100644 --- a/src/Fields/Invoice/VatValueField.php +++ b/src/Fields/VatValueField.php @@ -1,62 +1,62 @@ -vatValue; - } - - /** - * @return float|null - */ - public function getVatValueToFloat(): ?float - { - if ($this->getVatValue() != null) { - return Util::formatMoney($this->getVatValue()); - } else { - return 0; - } - } - - /** - * @param Money|null $vatValue - * @return $this - */ - public function setVatValue(?Money $vatValue) - { - $this->vatValue = $vatValue; - - return $this; - } - - /** - * @param float|null $vatValueFloat - * @return $this - * @throws Exception - */ - public function setVatValueFromFloat(?float $vatValueFloat) - { - if ((float)$vatValueFloat) { - return $this->setVatValue(Money::EUR(100 * $vatValueFloat)); - } else { - return $this->setVatValue(Money::EUR(0)); - } - } +vatValue; + } + + /** + * @return float|null + */ + public function getVatValueToFloat(): ?float + { + if ($this->getVatValue() != null) { + return Util::formatMoney($this->getVatValue()); + } else { + return 0; + } + } + + /** + * @param Money|null $vatValue + * @return $this + */ + public function setVatValue(?Money $vatValue) + { + $this->vatValue = $vatValue; + + return $this; + } + + /** + * @param float|null $vatValueFloat + * @return $this + * @throws Exception + */ + public function setVatValueFromFloat(?float $vatValueFloat) + { + if ((float)$vatValueFloat) { + return $this->setVatValue(Money::EUR(100 * $vatValueFloat)); + } else { + return $this->setVatValue(Money::EUR(0)); + } + } } \ No newline at end of file diff --git a/src/FixedAssetTransactionLine.php b/src/FixedAssetTransactionLine.php index 855623a2..1c44b3f9 100644 --- a/src/FixedAssetTransactionLine.php +++ b/src/FixedAssetTransactionLine.php @@ -3,16 +3,16 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\Dim1Field; +use PhpTwinfield\Fields\Dim2Field; +use PhpTwinfield\Fields\Dim3Field; +use PhpTwinfield\Fields\Dim4Field; use PhpTwinfield\Fields\Dimensions\AmountField; use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\AmountLockedField; use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\CodeField; use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\CodeLockedField; use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\Dim1LockedField; -use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\Dim2Field; use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\Dim2LockedField; -use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\Dim3Field; use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\Dim3LockedField; -use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\Dim4Field; use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\Dim4LockedField; use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\Dim5Field; use PhpTwinfield\Fields\Dimensions\Level34\FixedAsset\Dim5LockedField; diff --git a/src/Invoice.php b/src/Invoice.php index 55b8968b..bbae0fc6 100644 --- a/src/Invoice.php +++ b/src/Invoice.php @@ -3,12 +3,12 @@ use PhpTwinfield\Fields\CurrencyField; use PhpTwinfield\Fields\CustomerField; +use PhpTwinfield\Fields\DueDateField; use PhpTwinfield\Fields\Invoice\BankField; use PhpTwinfield\Fields\Invoice\CalculateOnlyField; use PhpTwinfield\Fields\Invoice\CustomerNameField; use PhpTwinfield\Fields\Invoice\DebitCreditField; use PhpTwinfield\Fields\Invoice\DeliverAddressNumberField; -use PhpTwinfield\Fields\Invoice\DueDateField; use PhpTwinfield\Fields\Invoice\FinancialCodeField; use PhpTwinfield\Fields\Invoice\FinancialNumberField; use PhpTwinfield\Fields\Invoice\FooterTextField; @@ -19,10 +19,10 @@ use PhpTwinfield\Fields\Invoice\InvoiceNumberField; use PhpTwinfield\Fields\Invoice\InvoiceTypeField; use PhpTwinfield\Fields\Invoice\PaymentMethodField; -use PhpTwinfield\Fields\Invoice\PerformanceDateField; use PhpTwinfield\Fields\Invoice\RaiseWarningField; use PhpTwinfield\Fields\Invoice\StatusField; use PhpTwinfield\Fields\OfficeField; +use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PeriodField; /** @@ -72,18 +72,19 @@ class Invoice extends BaseObject use StatusField; private $totals; + private $lines = []; - private $vatlines = []; + private $vatLines = []; - public function setTotals(InvoiceTotals $totals) + public function getTotals(): InvoiceTotals { - $this->totals = $totals; - return $this; + return $this->totals; } - public function getTotals(): InvoiceTotals + public function setTotals(InvoiceTotals $totals) { - return $this->totals; + $this->totals = $totals; + return $this; } /** @@ -100,10 +101,10 @@ public function addLine(InvoiceLine $line) return $this; } - public function removeLine($index) + public function removeLine($id) { - if (array_key_exists($index, $this->lines)) { - unset($this->lines[$index]); + if (array_key_exists($id, $this->lines)) { + unset($this->lines[$id]); return true; } else { return false; @@ -115,15 +116,25 @@ public function removeLine($index) */ public function getVatLines(): array { - return $this->vatlines; + return $this->vatLines; } - public function addVatLine(InvoiceVatLine $vatline) + public function addVatLine(InvoiceVatLine $vatLine) { - $this->vatlines[] = $vatline; + $this->vatLines[] = $vatLine; return $this; } + public function removeVatLine($index) + { + if (array_key_exists($index, $this->vatLines)) { + unset($this->vatLines[$index]); + return true; + } else { + return false; + } + } + public function getMatchReference(): MatchReferenceInterface { return new MatchReference($this->getOffice(), $this->getFinancialCode(), $this->getFinancialNumber(), 1); diff --git a/src/InvoiceLine.php b/src/InvoiceLine.php index cebcd97f..44ebc6f4 100644 --- a/src/InvoiceLine.php +++ b/src/InvoiceLine.php @@ -9,8 +9,6 @@ use PhpTwinfield\Fields\IDField; use PhpTwinfield\Fields\Invoice\AllowDiscountOrPremiumField; use PhpTwinfield\Fields\Invoice\ArticleField; -use PhpTwinfield\Fields\Invoice\PerformanceDateField; -use PhpTwinfield\Fields\Invoice\PerformanceTypeField; use PhpTwinfield\Fields\Invoice\QuantityField; use PhpTwinfield\Fields\Invoice\SubArticleField; use PhpTwinfield\Fields\Invoice\UnitsField; @@ -18,8 +16,10 @@ use PhpTwinfield\Fields\Invoice\UnitsPriceIncField; use PhpTwinfield\Fields\Invoice\ValueExclField; use PhpTwinfield\Fields\Invoice\ValueIncField; -use PhpTwinfield\Fields\Invoice\VatValueField; +use PhpTwinfield\Fields\PerformanceDateField; +use PhpTwinfield\Fields\PerformanceTypeField; use PhpTwinfield\Fields\VatCodeField; +use PhpTwinfield\Fields\VatValueField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices diff --git a/src/InvoiceVatLine.php b/src/InvoiceVatLine.php index 38ec0e4c..5f25667e 100644 --- a/src/InvoiceVatLine.php +++ b/src/InvoiceVatLine.php @@ -1,10 +1,10 @@ regime; - } - - /** - * @param string|null $regime - * @return $this - */ - public function setRegime(?string $regime): JournalTransaction - { - $this->regime = $regime; - - return $this; - } } diff --git a/src/JournalTransactionLine.php b/src/JournalTransactionLine.php index aa477a60..b72f5d95 100644 --- a/src/JournalTransactionLine.php +++ b/src/JournalTransactionLine.php @@ -3,27 +3,33 @@ namespace PhpTwinfield; use Money\Money; +use PhpTwinfield\Dummy; use PhpTwinfield\Enums\LineType; -use PhpTwinfield\Transactions\TransactionFields\InvoiceNumberField; -use PhpTwinfield\Transactions\TransactionLineFields\PerformanceFields; +use PhpTwinfield\Fields\PerformanceDateField; +use PhpTwinfield\Fields\PerformanceTypeField; +use PhpTwinfield\Fields\Transaction\InvoiceNumberField; +use PhpTwinfield\Fields\Transaction\TransactionLine\BaselineField; +use PhpTwinfield\Fields\Transaction\TransactionLine\CurrencyDateField; +use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceCountryField; +use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceVatNumberField; use Webmozart\Assert\Assert; -/** - * @todo $currencyDate Only if line type is detail. The line date. - */ class JournalTransactionLine extends BaseTransactionLine { - use PerformanceFields; - use InvoiceNumberField { - setInvoiceNumber as traitSetInvoiceNumber; - } + use BaselineField; + use CurrencyDateField; + use InvoiceNumberField; + use PerformanceCountryField; + use PerformanceDateField; + use PerformanceTypeField; + use PerformanceVatNumberField; - /** + /* * @var JournalTransaction */ private $transaction; - /** + /* * @param JournalTransaction $object */ public function setTransaction($object): void @@ -33,7 +39,7 @@ public function setTransaction($object): void $this->transaction = $object; } - /** + /* * References the transaction this line belongs too. * * @return JournalTransaction @@ -43,45 +49,63 @@ public function getTransaction(): JournalTransaction return $this->transaction; } - /** - * @param LineType $lineType + /* + * Only if line type is vat. The value of the baseline tag is a reference to the line ID of the VAT rate. + * + * @param int|null $baseline * @return $this * @throws Exception */ - public function setLineType(LineType $lineType): BaseTransactionLine + public function setBaseline(?int $baseline): self { - // Only 'detail' and 'vat' are supported. - if ($lineType->equals(LineType::TOTAL())) { - throw Exception::invalidLineTypeForTransaction($lineType, $this); + if (!$this->getLineType()->equals(LineType::VAT())) { + throw Exception::invalidFieldForLineType("baseline", $this); } - - return parent::setLineType($lineType); + return parent::setBaseline($baseline); } - /** - * If line type = detail the journal balance account or profit and loss account. + /* + * Only if line type is detail. The amount still owed in base currency. Read-only attribute. * - * If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account - * will be taken as entered at the VAT code in Twinfield. + * @param Money|null $baseValueOpen + * @return $this + * @throws Exception + */ + public function setBaseValueOpen(?Money $baseValueOpen): parent + { + if ($baseValueOpen !== null && !$this->getLineType()->equals(LineType::DETAIL())) { + throw Exception::invalidFieldForLineType('baseValueOpen', $this); + } + + return parent::setBaseValueOpen($baseValueOpen); + } + + /* + * Only if line type is detail. The line date. Only allowed if the line date in the journal book is set to Allowed or Mandatory. * - * @param string|null $dim1 + * @param \DateTimeInterface|null $currencyDate * @return $this + * @throws Exception */ - public function setDim1(?string $dim1): BaseTransactionLine + public function setCurrencyDate(?\DateTimeInterface $currencyDate): self { - return parent::setDim1($dim1); + if ($currencyDate !== null && !$this->getLineType()->equals(LineType::DETAIL())) { + throw Exception::invalidFieldForLineType('currencyDate', $this); + } + + return parent::setCurrencyDate($currencyDate); } - /** + /* * If line type = detail the customer or supplier or the cost center or empty. * * If line type = vat empty. * - * @param string|null $dim2 + * @param Dummy|null $dim2 * @return $this * @throws Exception */ - public function setDim2(?string $dim2): BaseTransactionLine + public function setDim2(?Dummy $dim2): parent { if ($dim2 !== null && $this->getLineType()->equals(LineType::VAT())) { throw Exception::invalidDimensionForLineType(2, $this); @@ -90,62 +114,75 @@ public function setDim2(?string $dim2): BaseTransactionLine return parent::setDim2($dim2); } - /** - * If line type = detail amount without VAT. + /* + * If line type = detail the project or asset or empty. * - * If line type = vat VAT amount. + * If line type = vat empty. * - * @param Money $value + * @param Dummy|null $dim3 * @return $this + * @throws Exception */ - public function setValue(Money $value): BaseTransactionLine + public function setDim3(?Dummy $dim3): parent { - parent::setValue($value); - return $this; + if ($dim3 !== null && $this->getLineType()->equals(LineType::VAT())) { + throw Exception::invalidDimensionForLineType(3, $this); + } + + return parent::setDim3($dim3); } - /** + /* * @param string|null $invoiceNumber * @return $this * @throws Exception */ - public function setInvoiceNumber(?string $invoiceNumber): BaseTransactionLine + public function setInvoiceNumber(?string $invoiceNumber): self { if ($invoiceNumber !== null && !$this->getLineType()->equals(LineType::DETAIL())) { throw Exception::invalidFieldForLineType('invoiceNumber', $this); } - return $this->traitSetInvoiceNumber($invoiceNumber); + return parent::setInvoiceNumber($invoiceNumber); } - /** - * Payment status of the journal transaction. If line type vat always notmatchable. Read-only attribute. + /* + * Returns true if a positive amount in the TOTAL line means the amount is 'debit'. Examples of incoming transaction + * types are Sales Transactions, Electronic Bank Statements and Bank Transactions. * - * @param string|null $matchStatus + * Returns false if a positive amount in the TOTAL line means the amount is 'credit'. An example of an outgoing + * transaction type is a Purchase Transaction. + * + * @return bool + */ + protected function isIncomingTransactionType(): bool + { + return true; + } + + /* + * @param LineType $lineType * @return $this * @throws Exception */ - public function setMatchStatus(?string $matchStatus): BaseTransactionLine + public function setLineType(LineType $lineType): parent { - if ( - $matchStatus !== null && - $this->getLineType()->equals(LineType::VAT()) && - $matchStatus != self::MATCHSTATUS_NOTMATCHABLE - ) { - throw Exception::invalidMatchStatusForLineType($matchStatus, $this); + // Only 'detail' and 'vat' are supported. + if ($lineType->equals(LineType::TOTAL())) { + throw Exception::invalidLineTypeForTransaction($lineType, $this); } - return parent::setMatchStatus($matchStatus); + return parent::setLineType($lineType); } - /** + /* * Only if line type is detail. The level of the matchable dimension. Read-only attribute. * * @param int|null $matchLevel * @return $this * @throws Exception */ - public function setMatchLevel(?int $matchLevel): BaseTransactionLine + public function setMatchLevel(?int $matchLevel): parent { if ($matchLevel !== null && !$this->getLineType()->equals(LineType::DETAIL())) { throw Exception::invalidFieldForLineType('matchLevel', $this); @@ -153,34 +190,100 @@ public function setMatchLevel(?int $matchLevel): BaseTransactionLine return parent::setMatchLevel($matchLevel); } + + /* + * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The performance type. + * + * @param PerformanceType|null $performanceType + * @return $this + * @throws Exception + */ + public function setPerformanceType(?PerformanceType $performanceType): self + { + if ($performanceType !== null && $this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('performanceType', $this); + } - /** - * Only if line type is detail. The amount still owed in base currency. Read-only attribute. + return parent::setPerformanceType($performanceType); + } + + /* + * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The ISO country codes are used. If not added to the request, by default the country code of the customer will be taken. * - * @param Money|null $baseValueOpen + * @param Country|null $performanceCountry * @return $this * @throws Exception */ - public function setBaseValueOpen(?Money $baseValueOpen): BaseTransactionLine + public function setPerformanceCountry(?Country $performanceCountry): self { - if ($baseValueOpen !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('baseValueOpen', $this); + if ($performanceCountry !== null && $this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('performanceCountry', $this); } - return parent::setBaseValueOpen($baseValueOpen); + return parent::setPerformanceCountry($performanceCountry); } - /** - * Returns true if a positive amount in the TOTAL line means the amount is 'debit'. Examples of incoming transaction - * types are Sales Transactions, Electronic Bank Statements and Bank Transactions. + /* + * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. If not added to the request, by default the VAT number of the customer will be taken. * - * Returns false if a positive amount in the TOTAL line means the amount is 'credit'. An example of an outgoing - * transaction type is a Purchase Transaction. + * @param string|null $performanceVatNumber + * @return $this + * @throws Exception + */ + public function setPerformanceVatNumber(?string $performanceVatNumber): self + { + if ($performanceVatNumber !== null && $this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('performanceVatNumber', $this); + } + + return parent::setPerformanceVatNumber($performanceVatNumber); + } + + /* + * Only if line type is detail or vat. Mandatory in case of an ICT VAT code but only if performancetype is services. * - * @return bool + * @param \DateTimeInterface|null $performanceDate + * @return $this + * @throws Exception */ - protected function isIncomingTransactionType(): bool + public function setPerformanceDate(?\DateTimeInterface $performanceDate): self { - return true; + if ($performanceDate !== null && (!$this->getPerformanceType()->equals(PerformanceType::SERVICES()) || $this->getLineType()->equals(LineType::TOTAL()))) { + throw Exception::invalidFieldForLineType('performanceDate', $this); + } + + return parent::setPerformanceDate($performanceDate); + } + + /* + * Relation of the transaction. Only if line type is detail. Read-only attribute. + * + * @param string|null $relation + * @return $this + * @throws Exception + */ + public function setRelation(?string $relation): parent + { + if ($relation !== null && !$this->getLineType()->equals(LineType::DETAIL())) { + throw Exception::invalidRelationForLineType($relation, $this); + } + + return $this; + } + + /* + * Only if line type is detail. The amount still owed in reporting currency. Read-only attribute. + * + * @param Money|null $repValueOpen + * @return $this + * @throws Exception + */ + public function setRepValueOpen(?Money $repValueOpen): parent + { + if ($repValueOpen !== null && !$this->getLineType()->equals(LineType::DETAIL())) { + throw Exception::invalidFieldForLineType('repValueOpen', $this); + } + + return parent::setRepValueOpen($repValueOpen); } } diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index 823ae2ba..9f42075a 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -5,63 +5,21 @@ use Money\Currency; use Money\Money; use PhpTwinfield\Message\Message; -use PhpTwinfield\Office; use PhpTwinfield\Util; use Webmozart\Assert\Assert; abstract class BaseMapper { - /** - * @throws \PhpTwinfield\Exception - */ - protected static function setFromTagValue(\DOMDocument $document, string $tag, callable $setter): void - { - $value = self::getValueFromTag($document, $tag); - - if ($value === null) { - return; - } - - if ($tag === "office") { - \call_user_func($setter, Office::fromCode($value)); - return; - } - - if ($tag === "date") { - \call_user_func($setter, Util::parseDate($value)); - return; - } - - if ($tag === "startvalue") { - $currency = new Currency(self::getValueFromTag($document, "currency")); - - \call_user_func($setter, Util::parseMoney($value, $currency)); - - return; - } - - \call_user_func($setter, $value); - } - - protected static function getValueFromTag(\DOMDocument $document, string $tag): ?string + private static function checkForMessage($object, \DOMElement $element): void { - /** @var \DOMNodeList $nodelist */ - $nodelist = $document->getElementsByTagName($tag); - - if ($nodelist->length === 0) { - return null; - } - - Assert::greaterThanEq($nodelist->length, 1); - - /** @var \DOMElement $element */ - $element = $nodelist[0]; + if ($element->hasAttribute('msg')) { + $message = new Message(); + $message->setType($element->getAttribute('msgtype')); + $message->setMessage($element->getAttribute('msg')); + $message->setField($element->nodeName); - if ("" === $element->textContent) { - return null; + $object->addMessage($message); } - - return $element->textContent; } protected static function getAttribute(\DOMElement $element, string $fieldTagName, string $attributeName): ?string @@ -98,18 +56,6 @@ protected static function getField($object, \DOMElement $element, string $fieldT return $fieldElement->textContent; } - private static function checkForMessage($object, \DOMElement $element): void - { - if ($element->hasAttribute('msg')) { - $message = new Message(); - $message->setType($element->getAttribute('msgtype')); - $message->setMessage($element->getAttribute('msg')); - $message->setField($element->nodeName); - - $object->addMessage($message); - } - } - protected static function parseBooleanAttribute(?string $value): ?bool { return filter_var($value, FILTER_VALIDATE_BOOLEAN); diff --git a/src/Mappers/MatchSetMapper.php b/src/Mappers/MatchSetMapper.php index 9caf2d47..be34f406 100644 --- a/src/Mappers/MatchSetMapper.php +++ b/src/Mappers/MatchSetMapper.php @@ -31,11 +31,9 @@ private static function createMatchSetFrom(\DOMDocument $document): MatchSet { $matchSet = new MatchSet(); - $matchSet->setOffice(Office::fromCode(self::getValueFromTag($document, "office"))); - $matchSet->setMatchCode(new MatchCode(self::getValueFromTag($document, "matchcode"))); - $matchSet->setMatchDate( - \DateTimeImmutable::createFromFormat("Ymd", self::getValueFromTag($document, "matchdate")) - ); + $matchSet->setOffice(Office::fromCode(self::getField(null, $document, "office"))); + $matchSet->setMatchCode(new MatchCode(self::getField(null, $document, "matchcode"))); + $matchSet->setMatchDate(\DateTimeImmutable::createFromFormat("Ymd", self::getField(null, $document, "matchdate"))); return $matchSet; } @@ -54,10 +52,7 @@ private static function addLines(\DOMDocument $document, MatchSet $matchSet): vo } } - private static function getMatchReferenceFrom( - \DOMElement $lineElement, - Office $office - ): MatchReferenceInterface { + private static function getMatchReferenceFrom(\DOMElement $lineElement, Office $office): MatchReferenceInterface { return new MatchReference( $office, self::getField(null, $lineElement, 'transcode'), diff --git a/src/Mappers/ProjectMapper.php b/src/Mappers/ProjectMapper.php index 4190152e..0dad3c87 100644 --- a/src/Mappers/ProjectMapper.php +++ b/src/Mappers/ProjectMapper.php @@ -32,7 +32,7 @@ public static function map(Response $response) // Gets the raw DOMDocument response. $responseDOM = $response->getResponseDocument(); - + // Get the root/project element $projectElement = $responseDOM->documentElement; diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 214688ef..28749a1b 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -2,33 +2,32 @@ namespace PhpTwinfield\Mappers; -use Money\Currency; -use Money\Money; use PhpTwinfield\BankTransaction; use PhpTwinfield\BaseTransaction; -use PhpTwinfield\BaseTransactionLine; use PhpTwinfield\CashTransaction; -use PhpTwinfield\Enums\DebitCredit; -use PhpTwinfield\Enums\Destiny; use PhpTwinfield\Enums\LineType; -use PhpTwinfield\Enums\PerformanceType; use PhpTwinfield\Exception; +use PhpTwinfield\Fields\DueDateField; +use PhpTwinfield\Fields\FreeText1Field; +use PhpTwinfield\Fields\FreeText2Field; +use PhpTwinfield\Fields\FreeText3Field; +use PhpTwinfield\Fields\PerformanceDateField; +use PhpTwinfield\Fields\PerformanceTypeField; +use PhpTwinfield\Fields\Transaction\InvoiceNumberField; +use PhpTwinfield\Fields\Transaction\PaymentReferenceField; +use PhpTwinfield\Fields\Transaction\StatementNumberField; +use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceCountryField; +use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceVatNumberField; +use PhpTwinfield\Fields\Transaction\TransactionLine\ValueOpenField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatBaseTotalField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatTotalField; use PhpTwinfield\JournalTransaction; use PhpTwinfield\Message\Message; -use PhpTwinfield\Office; use PhpTwinfield\Response\Response; use PhpTwinfield\SalesTransaction; -use PhpTwinfield\Transactions\TransactionFields\DueDateField; -use PhpTwinfield\Transactions\TransactionFields\FreeTextFields; -use PhpTwinfield\Transactions\TransactionFields\InvoiceNumberField; -use PhpTwinfield\Transactions\TransactionFields\PaymentReferenceField; -use PhpTwinfield\Transactions\TransactionFields\StatementNumberField; -use PhpTwinfield\Transactions\TransactionLineFields\PerformanceFields; -use PhpTwinfield\Transactions\TransactionLineFields\ValueOpenField; -use PhpTwinfield\Transactions\TransactionLineFields\VatTotalFields; use PhpTwinfield\Util; -class TransactionMapper +class TransactionMapper extends BaseMapper { /** * @param string $transactionClassName @@ -53,66 +52,65 @@ public static function map(string $transactionClassName, Response $response): Ba $document = $response->getResponseDocument(); $transactionElement = $document->documentElement; - /** @var BaseTransaction $transaction */ $transaction = new $transactionClassName(); $transaction->setResult($transactionElement->getAttribute('result')); + $autoBalanceVat = $transactionElement->getAttribute('autobalancevat'); + + if (!empty($autoBalanceVat)) { + $transaction->setAutoBalanceVat(self::parseBooleanAttribute($autoBalanceVat)); + } + $destiny = $transactionElement->getAttribute('location'); + if (empty($destiny)) { - /* - * This field should be sent to Twinfield as 'destiny' attribute and Twinfield should return it as - * 'location' attribute. But in case of an error elsewhere in this object, Twinfield returns this field as - * 'destiny' attibute. - */ $destiny = $transactionElement->getAttribute('destiny'); } - if (!empty($destiny)) { - $transaction->setDestiny(new Destiny($destiny)); - } - $autoBalanceVat = $transactionElement->getAttribute('autobalancevat'); - if (!empty($autoBalanceVat)) { - $transaction->setAutoBalanceVat($autoBalanceVat == 'true'); + if (!empty($destiny)) { + $transaction->setDestiny(self::parseEnumAttribute('Destiny', $destiny)); } $raiseWarning = $transactionElement->getAttribute('raisewarning'); + if (!empty($raiseWarning)) { - $transaction->setRaiseWarning(Util::parseBoolean($raiseWarning)); + $transaction->setRaiseWarning(self::parseBooleanAttribute($raiseWarning)); } - $office = new Office(); - $office->setCode(self::getField($transaction, $transactionElement, 'office')); - - $transaction - ->setOffice($office) - ->setCode(self::getField($transaction, $transactionElement, 'code')) - ->setPeriod(self::getField($transaction, $transactionElement, 'period')) + $transaction->setCode(self::getField($transaction, $transactionElement, 'code')) ->setDateFromString(self::getField($transaction, $transactionElement, 'date')) - ->setOrigin(self::getField($transaction, $transactionElement, 'origin')) ->setFreetext1(self::getField($transaction, $transactionElement, 'freetext1')) ->setFreetext2(self::getField($transaction, $transactionElement, 'freetext2')) - ->setFreetext3(self::getField($transaction, $transactionElement, 'freetext3')); + ->setFreetext3(self::getField($transaction, $transactionElement, 'freetext3')) + ->setOfficeFromString(self::getField($transaction, $transactionElement, 'office')) + ->setOrigin(self::getField($transaction, $transactionElement, 'origin')) + ->setPeriod(self::getField($transaction, $transactionElement, 'period')); $currency = self::getField($transaction, $transactionElement, 'currency'); + if (!empty($currency)) { - $transaction->setCurrency(new Currency($currency)); + $transaction->setCurrencyFromString($currency); } $number = self::getField($transaction, $transactionElement, 'number'); + if (!empty($number)) { $transaction->setNumber($number); } + if (Util::objectUses(DueDateField::class, $transaction)) { $transaction->setDueDateFromString(self::getField($transaction, $transactionElement, 'duedate')); } + if (Util::objectUses(InvoiceNumberField::class, $transaction)) { $transaction->setInvoiceNumber(self::getField($transaction, $transactionElement, 'invoicenumber')); } + if (Util::objectUses(PaymentReferenceField::class, $transaction)) { - $transaction - ->setPaymentReference(self::getField($transaction, $transactionElement, 'paymentreference')); + $transaction->setPaymentReference(self::getField($transaction, $transactionElement, 'paymentreference')); } + if (Util::objectUses(StatementNumberField::class, $transaction)) { $transaction->setStatementnumber(self::getField($transaction, $transactionElement, 'statementnumber')); } @@ -120,16 +118,14 @@ public static function map(string $transactionClassName, Response $response): Ba if ($transaction instanceof SalesTransaction) { $transaction->setOriginReference(self::getField($transaction, $transactionElement, 'originreference')); } + if ($transaction instanceof JournalTransaction) { $transaction->setRegime(self::getField($transaction, $transactionElement, 'regime')); } + if ($transaction instanceof BankTransaction || $transaction instanceof CashTransaction) { - $transaction->setStartvalue( - Util::parseMoney( - self::getField($transaction, $transactionElement, 'startvalue'), - $transaction->getCurrency() - ) - ); + $transaction->setCloseValueFromFloat(self::getField($transaction, $transactionElement, 'closevalue')); + $transaction->setStartValueFromFloat(self::getField($transaction, $transactionElement, 'startvalue')); } // Parse the transaction lines @@ -147,97 +143,107 @@ public static function map(string $transactionClassName, Response $response): Ba self::checkForMessage($transaction, $lineElement); - /** @var BaseTransactionLine $transactionLine */ $transactionLine = new $transactionLineClassName(); $lineType = $lineElement->getAttribute('type'); $transactionLine ->setLineType(new LineType($lineType)) ->setId($lineElement->getAttribute('id')) - ->setDim1(self::getField($transaction, $lineElement, 'dim1')) - ->setDim2(self::getField($transaction, $lineElement, 'dim2')) - ->setValue(Money::EUR(100 * self::getField($transaction, $lineElement, 'value'))) - ->setDebitCredit(new DebitCredit(self::getField($transaction, $lineElement, 'debitcredit'))) - ->setBaseValue(Money::EUR(100 * self::getField($transaction, $lineElement, 'basevalue'))) + ->setDim1FromString(self::getField($transaction, $lineElement, 'dim1')) + ->setDim2FromString(self::getField($transaction, $lineElement, 'dim2')) + ->setValueFromFloat(self::getField($transaction, $lineElement, 'value')) + ->setDebitCredit(self::parseEnumAttribute('DebitCredit', self::getField($transaction, $lineElement, 'debitcredit'))) + ->setBaseValueFromFloat(self::getField($transaction, $lineElement, 'basevalue')) ->setRate(self::getField($transaction, $lineElement, 'rate')) - ->setRepValue(Money::EUR(100 * self::getField($transaction, $lineElement, 'repvalue'))) + ->setRepValueFromFloat(self::getField($transaction, $lineElement, 'repvalue')) ->setRepRate(self::getField($transaction, $lineElement, 'reprate')) ->setDescription(self::getField($transaction, $lineElement, 'description')) - ->setMatchStatus(self::getField($transaction, $lineElement, 'matchstatus')) + ->setMatchStatusFromString(self::getField($transaction, $lineElement, 'matchstatus')) ->setMatchLevel(self::getField($transaction, $lineElement, 'matchlevel')) - ->setVatCode(self::getField($transaction, $lineElement, 'vatcode')); + ->setVatCodeFromString(self::getField($transaction, $lineElement, 'vatcode')); - // TODO - according to the docs, the field is called , but the examples use . $baseValueOpen = self::getField($transaction, $lineElement, 'basevalueopen') ?: self::getField($transaction, $lineElement, 'openbasevalue'); + if ($baseValueOpen) { - $transactionLine->setBaseValueOpen(Money::EUR(100 * $baseValueOpen)); + $transactionLine->setBaseValueOpenFromFloat($baseValueOpen); } $vatValue = self::getField($transaction, $lineElement, 'vatvalue'); + if ($lineType == LineType::DETAIL() && $vatValue) { - $transactionLine->setVatValue(Money::EUR(100 * $vatValue)); + $transactionLine->setVatValueFromFloat($vatValue); } $baseline = self::getField($transaction, $lineElement, 'baseline'); + if ($baseline) { $transactionLine->setBaseline($baseline); } - if (Util::objectUses(FreeTextFields::class, $transactionLine)) { + if (Util::objectUses(FreeText1Field::class, $transactionLine)) { $freetext1 = self::getField($transaction, $lineElement, 'freetext1'); + if ($freetext1) { $transactionLine->setFreetext1($freetext1); } + } + if (Util::objectUses(FreeText2Field::class, $transactionLine)) { $freetext2 = self::getField($transaction, $lineElement, 'freetext2'); if ($freetext2) { $transactionLine->setFreetext2($freetext2); } + } + if (Util::objectUses(FreeText3Field::class, $transactionLine)) { $freetext3 = self::getField($transaction, $lineElement, 'freetext3'); if ($freetext3) { $transactionLine->setFreetext3($freetext3); } } - if (Util::objectUses(PerformanceFields::class, $transactionLine)) { - /** @var BaseTransactionLine|PerformanceFields $transactionLine */ - $performanceType = self::getField($transaction, $lineElement, 'performancetype'); - $transactionLine - ->setPerformanceType($performanceType ? new PerformanceType($performanceType) : null) - ->setPerformanceCountry(self::getField($transaction, $lineElement, 'performancecountry')) - ->setPerformanceVatNumber(self::getField($transaction, $lineElement, 'performancevatnumber')); + if (Util::objectUses(PerformanceTypeField::class, $transactionLine)) { + $transactionLine->setPerformanceTypeFromString(self::getField($transaction, $lineElement, 'performancetype')); + } - $performanceDate = self::getField($transaction, $lineElement, 'performancedate'); + if (Util::objectUses(PerformanceCountryField::class, $transactionLine)) { + $transactionLine->setPerformanceCountryFromString(self::getField($transaction, $lineElement, 'performancecountry')); + } - if ($performanceDate) { - $transactionLine->setPerformanceDate(Util::parseDate($performanceDate)); - } + if (Util::objectUses(PerformanceVatNumberField::class, $transactionLine)) { + $transactionLine->setPerformanceVatNumber(self::getField($transaction, $lineElement, 'performancevatnumber')); } + + if (Util::objectUses(PerformanceDateField::class, $transactionLine)) { + $transactionLine->setPerformanceDateFromString(self::getField($transaction, $lineElement, 'performancedate')); + } + if (in_array(ValueOpenField::class, class_uses($transactionLine))) { - // TODO - according to the docs, the field is called , but the examples use . $valueOpen = self::getField($transaction, $lineElement, 'valueopen') ?: self::getField($transaction, $lineElement, 'openvalue'); + if ($valueOpen) { - $transactionLine->setValueOpen(Money::EUR(100 * $valueOpen)); + $transactionLine->setValueOpenFromFloat($valueOpen); } } - if (in_array(VatTotalFields::class, class_uses($transactionLine))) { + + if (Util::objectUses(VatTotalField::class, $transactionLine)) { $vatTotal = self::getField($transaction, $lineElement, 'vattotal'); + if ($vatTotal) { - $transactionLine->setVatTotal(Money::EUR(100 * $vatTotal)); + $transactionLine->setVatTotalFromFloat($vatTotal); } + } + if (Util::objectUses(VatBaseTotalField::class, $transactionLine)) { $vatBaseTotal = self::getField($transaction, $lineElement, 'vatbasetotal'); + if ($vatBaseTotal) { - $transactionLine->setVatBaseTotal(Money::EUR(100 * $vatBaseTotal)); + $transactionLine->setVatBaseTotalFromFloat($vatBaseTotal); } } + if (Util::objectUses(InvoiceNumberField::class, $transactionLine)) { - /** @var InvoiceNumberField $transactionLine */ - $invoiceNumber = self::getField($transaction, $lineElement, 'invoicenumber'); - if ($invoiceNumber) { - $transactionLine->setInvoiceNumber(self::getField($transaction, $lineElement, 'invoicenumber')); - } + $transactionLine->setInvoiceNumber(self::getField($transaction, $lineElement, 'invoicenumber')); } $transaction->addLine($transactionLine); @@ -246,29 +252,4 @@ public static function map(string $transactionClassName, Response $response): Ba return $transaction; } - - private static function getField(BaseTransaction $transaction, \DOMElement $element, string $fieldTagName): ?string - { - $fieldElement = $element->getElementsByTagName($fieldTagName)->item(0); - - if (!isset($fieldElement)) { - return null; - } - - self::checkForMessage($transaction, $fieldElement); - - return $fieldElement->textContent; - } - - private static function checkForMessage(BaseTransaction $transaction, \DOMElement $element): void - { - if ($element->hasAttribute('msg')) { - $message = new Message(); - $message->setType($element->getAttribute('msgtype')); - $message->setMessage($element->getAttribute('msg')); - $message->setField($element->nodeName); - - $transaction->addMessage($message); - } - } -} +} \ No newline at end of file diff --git a/src/Mappers/UserRoleMapper.php b/src/Mappers/UserRoleMapper.php index 89e548fb..810b5f41 100644 --- a/src/Mappers/UserRoleMapper.php +++ b/src/Mappers/UserRoleMapper.php @@ -38,7 +38,7 @@ public static function map(Response $response) $userRole->setCode(self::getField($userRole, $userRoleElement, 'code')) ->setName(self::getField($userRole, $userRoleElement, 'name')) ->setShortName(self::getField($userRole, $userRoleElement, 'shortname')); - + // Return the complete object return $userRole; } diff --git a/src/MatchLine.php b/src/MatchLine.php index 78b5ac33..d215e1cc 100644 --- a/src/MatchLine.php +++ b/src/MatchLine.php @@ -12,36 +12,36 @@ class MatchLine * * @var string */ - private $transcode; + private $transCode; /** * Transaction number. * * @var int */ - private $transnumber; + private $transNumber; /** * Transaction line number. * * @var int */ - private $transline; + private $transLine; /** * @var Money|null */ - private $matchvalue; + private $matchValue; /** * @var Money|null */ - private $writeoff; + private $writeOff; /** * @var Enums\WriteOffType|null */ - private $writeofftype; + private $writeOffType; /** * Create a new matchline based on a MatchReferenceInterface. @@ -54,10 +54,10 @@ public static function addToMatchSet(MatchSet $set, MatchReferenceInterface $ref Assert::eq($set->getOffice(), $reference->getOffice()); $instance = new self; - $instance->transcode = $reference->getCode(); - $instance->transnumber = $reference->getNumber(); - $instance->transline = $reference->getLineId(); - $instance->setMatchvalue($value); + $instance->transCode = $reference->getCode(); + $instance->transNumber = $reference->getNumber(); + $instance->transLine = $reference->getLineId(); + $instance->setMatchValue($value); $set->addLine($instance); @@ -73,39 +73,39 @@ private function __construct() {} /** * @return string */ - public function getTranscode(): string + public function getTransCode(): string { - return $this->transcode; + return $this->transCode; } - public function getTransnumber(): int + public function getTransNumber(): int { - return $this->transnumber; + return $this->transNumber; } - public function getTransline(): int + public function getTransLine(): int { - return $this->transline; + return $this->transLine; } public function getMatchValue(): ?Money { - return $this->matchvalue; + return $this->matchValue; } /** * Optional; only for partial payments. Include an "-" on credit lines. */ - public function setMatchvalue(?Money $matchvalue): self + public function setMatchValue(?Money $matchValue): self { - $this->matchvalue = $matchvalue; + $this->matchValue = $matchValue; return $this; } public function getWriteOff(): ?Money { - return $this->writeoff; + return $this->writeOff; } /** @@ -113,8 +113,8 @@ public function getWriteOff(): ?Money */ public function setWriteOff(Money $amount, Enums\WriteOffType $type): self { - $this->writeoff = $amount; - $this->writeofftype = $type; + $this->writeOff = $amount; + $this->writeOffType = $type; return $this; } @@ -124,6 +124,6 @@ public function setWriteOff(Money $amount, Enums\WriteOffType $type): self */ public function getWriteOffType(): ?Enums\WriteOffType { - return $this->writeofftype; + return $this->writeOffType; } } \ No newline at end of file diff --git a/src/MatchReference.php b/src/MatchReference.php index e7b57d37..4e5fd9b1 100644 --- a/src/MatchReference.php +++ b/src/MatchReference.php @@ -14,10 +14,7 @@ final class MatchReference implements MatchReferenceInterface */ private $lineId; - public static function fromBookingReference( - BookingReferenceInterface $bookingReference, - int $lineId - ): MatchReferenceInterface { + public static function fromBookingReference(BookingReferenceInterface $bookingReference, int $lineId): MatchReferenceInterface { return new self( $bookingReference->getOffice(), $bookingReference->getCode(), diff --git a/src/MatchSet.php b/src/MatchSet.php index 36527ab5..2adaa722 100644 --- a/src/MatchSet.php +++ b/src/MatchSet.php @@ -2,7 +2,7 @@ namespace PhpTwinfield; -use PhpTwinfield\Transactions\TransactionFields\OfficeField; +use PhpTwinfield\Fields\OfficeField; use Webmozart\Assert\Assert; class MatchSet diff --git a/src/PurchaseTransaction.php b/src/PurchaseTransaction.php index 7ec95979..05f6d7fc 100644 --- a/src/PurchaseTransaction.php +++ b/src/PurchaseTransaction.php @@ -2,20 +2,22 @@ namespace PhpTwinfield; -use PhpTwinfield\Transactions\TransactionFields\DueDateField; -use PhpTwinfield\Transactions\TransactionFields\InvoiceNumberField; -use PhpTwinfield\Transactions\TransactionFields\PaymentReferenceField; +use PhpTwinfield\Fields\DueDateField; +use PhpTwinfield\Fields\Transaction\InvoiceNumberField; +use PhpTwinfield\Fields\Transaction\InvoiceNumberRaiseWarningField; +use PhpTwinfield\Fields\Transaction\PaymentReferenceField; -/** +/* * @link https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions */ class PurchaseTransaction extends BaseTransaction { use DueDateField; use InvoiceNumberField; + use InvoiceNumberRaiseWarningField; use PaymentReferenceField; - /** + /* * @return string */ public function getLineClassName(): string diff --git a/src/PurchaseTransactionLine.php b/src/PurchaseTransactionLine.php index 47451583..97e22fc1 100644 --- a/src/PurchaseTransactionLine.php +++ b/src/PurchaseTransactionLine.php @@ -3,26 +3,32 @@ namespace PhpTwinfield; use Money\Money; +use PhpTwinfield\Dummy; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\LineType; -use PhpTwinfield\Transactions\TransactionLineFields\ValueOpenField; -use PhpTwinfield\Transactions\TransactionLineFields\VatTotalFields; +use PhpTwinfield\Fields\Transaction\TransactionLine\BaselineField; +use PhpTwinfield\Fields\Transaction\TransactionLine\MatchDateField; +use PhpTwinfield\Fields\Transaction\TransactionLine\ValueOpenField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatBaseTotalField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatRepTotalField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatTotalField; use Webmozart\Assert\Assert; -/** - * @todo $matchDate Only if line type is total. The date on which the purchase invoice is matched. Read-only attribute. - */ class PurchaseTransactionLine extends BaseTransactionLine { - use VatTotalFields; + use BaselineField; + use MatchDateField; use ValueOpenField; + use VatBaseTotalField; + use VatRepTotalField; + use VatTotalField; - /** + /* * @var PurchaseTransaction */ private $transaction; - /** + /* * @param PurchaseTransaction $object */ public function setTransaction($object): void @@ -32,7 +38,7 @@ public function setTransaction($object): void $this->transaction = $object; } - /** + /* * References the transaction this line belongs too. * * @return PurchaseTransaction @@ -42,133 +48,260 @@ public function getTransaction(): PurchaseTransaction return $this->transaction; } - /** - * If line type = total the accounts payable balance account. When dim1 is omitted, by default the general ledger - * account will be taken as entered at the supplier in Twinfield. + /* + * Only if line type is vat. The value of the baseline tag is a reference to the line ID of the VAT rate. * - * If line type = detail the profit and loss account. + * @param int|null $baseline + * @return $this + * @throws Exception + */ + public function setBaseline(?int $baseline): self + { + if (!$this->getLineType()->equals(LineType::VAT())) { + throw Exception::invalidFieldForLineType("baseline", $this); + } + return parent::setBaseline($baseline); + } + + /* + * Only if line type is total. The amount still to be paid in base currency. Read-only attribute. + * + * @param Money|null $baseValueOpen + * @return $this + * @throws Exception + */ + public function setBaseValueOpen(?Money $baseValueOpen): parent + { + if ($baseValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('baseValueOpen', $this); + } + + return parent::setBaseValueOpen($baseValueOpen); + } + + /* + * If line type = total empty. * - * If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account - * will be taken as entered at the VAT code in Twinfield. + * If line type = detail the project or asset or empty. * - * @param string|null $dim1 + * If line type = vat the project or asset or empty. + * + * @param Dummy|null $dim3 * @return $this + * @throws Exception */ - public function setDim1(?string $dim1): BaseTransactionLine + public function setDim3(?Dummy $dim3): parent { - return parent::setDim1($dim1); + if ($dim3 !== null && $this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidDimensionForLineType(3, $this); + } + + return parent::setDim3($dim3); } - /** - * If line type = total the account payable. + /* + * Returns true if a positive amount in the TOTAL line means the amount is 'debit'. Examples of incoming transaction + * types are Sales Transactions, Electronic Bank Statements and Bank Transactions. + * + * Returns false if a positive amount in the TOTAL line means the amount is 'credit'. An example of an outgoing + * transaction type is a Purchase Transaction. * - * If line type = detail the cost center or empty. + * @return bool + */ + protected function isIncomingTransactionType(): bool + { + return false; + } + + /* + * Only if line type is total. The date on which the purchase invoice is matched. Read-only attribute. * - * If line type = vat the cost center or empty. + * @param \DateTimeInterface|null $matchDate + * @return $this + * @throws Exception + */ + public function setMatchDate(?\DateTimeInterface $matchDate): self + { + if ($matchDate !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('matchDate', $this); + } + + return parent::setMatchDate($matchDate); + } + + /* + * Only if line type is total. The level of the matchable dimension. Read-only attribute. * - * @param string|null $dim2 + * @param int|null $matchLevel * @return $this + * @throws Exception */ - public function setDim2(?string $dim2): BaseTransactionLine + public function setMatchLevel(?int $matchLevel): parent { - return parent::setDim2($dim2); + if ($matchLevel !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('matchLevel', $this); + } + + return parent::setMatchLevel($matchLevel); } - /** - * If line type = total - * - In case of a 'normal' purchase transaction credit. - * - In case of a credit purchase transaction debit. + /* + * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The performance type. * - * If line type = detail or vat - * - In case of a 'normal' purchase transaction debit. - * - In case of a credit purchase transaction credit. + * @param PerformanceType|null $performanceType + * @return $this + * @throws Exception + */ + public function setPerformanceType(?PerformanceType $performanceType): parent + { + if ($performanceType !== null && $this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('performanceType', $this); + } + + return parent::setPerformanceType($performanceType); + } + + /* + * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The ISO country codes are used. If not added to the request, by default the country code of the customer will be taken. * - * @param DebitCredit $debitCredit + * @param Country|null $performanceCountry * @return $this + * @throws Exception */ - public function setDebitCredit(DebitCredit $debitCredit): BaseTransactionLine + public function setPerformanceCountry(?Country $performanceCountry): parent { - return parent::setDebitCredit($debitCredit); + if ($performanceCountry !== null && $this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('performanceCountry', $this); + } + + return parent::setPerformanceCountry($performanceCountry); } - /** - * If line type = total amount including VAT. + /* + * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. If not added to the request, by default the VAT number of the customer will be taken. * - * If line type = detail amount without VAT. + * @param string|null $performanceVatNumber + * @return $this + * @throws Exception + */ + public function setPerformanceVatNumber(?string $performanceVatNumber): parent + { + if ($performanceVatNumber !== null && $this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('performanceVatNumber', $this); + } + + return parent::setPerformanceVatNumber($performanceVatNumber); + } + + /* + * Only if line type is detail or vat. Mandatory in case of an ICT VAT code but only if performancetype is services. * - * If line type = vat VAT amount. + * @param \DateTimeInterface|null $performanceDate + * @return $this + * @throws Exception + */ + public function setPerformanceDate(?\DateTimeInterface $performanceDate): parent + { + if ($performanceDate !== null && (!$this->getPerformanceType()->equals(PerformanceType::SERVICES()) || $this->getLineType()->equals(LineType::TOTAL()))) { + throw Exception::invalidFieldForLineType('performanceDate', $this); + } + + return parent::setPerformanceDate($performanceDate); + } + + /* + * Relation of the transaction. Only if line type is total. Read-only attribute. * - * @param Money $value + * @param string|null $relation * @return $this + * @throws Exception */ - public function setValue(Money $value): BaseTransactionLine + public function setRelation(?string $relation): parent { - return parent::setValue($value); + if ($relation !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidRelationForLineType($relation, $this); + } + + return $this; } - /** - * Payment status of the purchase transaction. If line type detail or vat always notmatchable. Read-only attribute. + /* + * Only if line type is total. The amount still owed in reporting currency. Read-only attribute. * - * @param string|null $matchStatus + * @param Money|null $repValueOpen * @return $this * @throws Exception */ - public function setMatchStatus(?string $matchStatus): BaseTransactionLine + public function setRepValueOpen(?Money $repValueOpen): parent { - if ( - $matchStatus !== null && - in_array($this->getLineType(), [LineType::DETAIL(), LineType::VAT()]) && - $matchStatus != self::MATCHSTATUS_NOTMATCHABLE - ) { - throw Exception::invalidMatchStatusForLineType($matchStatus, $this); + if ($repValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('repValueOpen', $this); } - return parent::setMatchStatus($matchStatus); + return parent::setRepValueOpen($repValueOpen); } - /** - * Only if line type is total. The level of the matchable dimension. Read-only attribute. + /* + * Only if line type is total. The amount still to be paid in the currency of the purchase transaction. Read-only attribute. * - * @param int|null $matchLevel + * @param Money|null $valueOpen * @return $this * @throws Exception */ - public function setMatchLevel(?int $matchLevel): BaseTransactionLine + public function setValueOpen(?Money $valueOpen): self { - if ($matchLevel !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('matchLevel', $this); + if ($valueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('valueOpen', $this); } - return parent::setMatchLevel($matchLevel); + return parent::setValueOpen($valueOpen); } - /** - * Only if line type is total. The amount still to be paid in base currency. Read-only attribute. + /* + * Only if line type is total. The total VAT amount in the currency of the purchase transaction * - * @param Money|null $baseValueOpen + * @param Money|null $vatValueOpen * @return $this * @throws Exception */ - public function setBaseValueOpen(?Money $baseValueOpen): BaseTransactionLine + public function setVatValueOpen(?Money $vatValueOpen): parent { - if ($baseValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('baseValueOpen', $this); + if ($vatValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatValueOpen', $this); } - return parent::setBaseValueOpen($baseValueOpen); + return parent::setVatValueOpen($vatValueOpen); } - /** - * Returns true if a positive amount in the TOTAL line means the amount is 'debit'. Examples of incoming transaction - * types are Sales Transactions, Electronic Bank Statements and Bank Transactions. + /* + * Only if line type is total. The total VAT amount in base currency. * - * Returns false if a positive amount in the TOTAL line means the amount is 'credit'. An example of an outgoing - * transaction type is a Purchase Transaction. + * @param Money|null $vatBaseValueOpen + * @return $this + * @throws Exception + */ + public function setVatBaseValueOpen(?Money $vatBaseValueOpen): parent + { + if ($vatBaseValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatBaseValueOpen', $this); + } + + return parent::setVatBaseValueOpen($vatBaseValueOpen); + } + + /* + * Only if line type is total. The total VAT amount in reporting currency. * - * @return bool + * @param Money|null $vatRepValueOpen + * @return $this + * @throws Exception */ - protected function isIncomingTransactionType(): bool + public function setVatRepValueOpen(?Money $vatRepValueOpen): parent { - return false; + if ($vatRepValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatRepValueOpen', $this); + } + + return parent::setVatRepValueOpen($vatRepValueOpen); } } diff --git a/src/Rate.php b/src/Rate.php index a4a95e71..e575ee1c 100644 --- a/src/Rate.php +++ b/src/Rate.php @@ -29,23 +29,23 @@ class Rate extends BaseObject use UnitField; use UserField; - private $ratechanges = []; + private $rateChanges = []; public function getRateChanges() { - return $this->ratechanges; + return $this->rateChanges; } - public function addRateChange(RateRateChange $ratechange) + public function addRateChange(RateRateChange $rateChange) { - $this->ratechanges[$ratechange->getID()] = $ratechange; + $this->rateChanges[$rateChange->getID()] = $rateChange; return $this; } - public function removeRateChange($index) + public function removeRateChange($id) { - if (array_key_exists($index, $this->ratechanges)) { - unset($this->ratechanges[$index]); + if (array_key_exists($id, $this->rateChanges)) { + unset($this->rateChanges[$id]); return true; } else { return false; diff --git a/src/Request/Read/Activity.php b/src/Request/Read/Activity.php index cfde02c9..b8ba8532 100644 --- a/src/Request/Read/Activity.php +++ b/src/Request/Read/Activity.php @@ -3,7 +3,7 @@ /** * Used to request a specific Activity from a certain office and code. - * + * * @package PhpTwinfield * @subpackage Request\Read * @author Yannick Aerssens @@ -13,17 +13,17 @@ class Activity extends Read { /** * Sets office and code if they are present. - * + * * @access public */ - + public function __construct($office = null, $code = null) { parent::__construct(); $this->add('type', 'dimensions'); $this->add('dimtype', 'ACT'); - + if (null !== $office) { $this->setOffice($office); } diff --git a/src/Request/Read/Currency.php b/src/Request/Read/Currency.php index b0558ecb..daab4820 100644 --- a/src/Request/Read/Currency.php +++ b/src/Request/Read/Currency.php @@ -3,7 +3,7 @@ /** * Used to request a specific Currency from a certain office and code. - * + * * @package PhpTwinfield * @subpackage Request\Read * @author Yannick Aerssens @@ -13,7 +13,7 @@ class Currency extends Read { /** * Sets office and code if they are present. - * + * * @access public */ public function __construct($office = null, $code = null) @@ -21,7 +21,7 @@ public function __construct($office = null, $code = null) parent::__construct(); $this->add('type', 'currency'); - + if (null !== $office) { $this->setOffice($office); } diff --git a/src/Request/Read/User.php b/src/Request/Read/User.php index 54ee431d..2c20c688 100644 --- a/src/Request/Read/User.php +++ b/src/Request/Read/User.php @@ -19,7 +19,7 @@ class User extends Read public function __construct($office = null, $code = null) { parent::__construct(); - + $this->add('type', 'user'); if (null !== $office) { diff --git a/src/Request/Read/VatCode.php b/src/Request/Read/VatCode.php index 42efcf47..c4f81554 100644 --- a/src/Request/Read/VatCode.php +++ b/src/Request/Read/VatCode.php @@ -19,7 +19,7 @@ class VatCode extends Read public function __construct($office = null, $code = null) { parent::__construct(); - + $this->add('type', 'vat'); if (null !== $office) { diff --git a/src/SalesTransaction.php b/src/SalesTransaction.php index 1bc0d746..b1a547b4 100644 --- a/src/SalesTransaction.php +++ b/src/SalesTransaction.php @@ -2,63 +2,28 @@ namespace PhpTwinfield; -use PhpTwinfield\Transactions\TransactionFields\DueDateField; -use PhpTwinfield\Transactions\TransactionFields\InvoiceNumberField; -use PhpTwinfield\Transactions\TransactionFields\PaymentReferenceField; -use PhpTwinfield\Transactions\TransactionLineFields\ThreeDimFields; +use PhpTwinfield\Fields\DueDateField; +use PhpTwinfield\Fields\Transaction\InvoiceNumberField; +use PhpTwinfield\Fields\Transaction\InvoiceNumberRaiseWarningField; +use PhpTwinfield\Fields\Transaction\OriginReferenceField; +use PhpTwinfield\Fields\Transaction\PaymentReferenceField; -/** +/* * @link https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions */ class SalesTransaction extends BaseTransaction { use DueDateField; use InvoiceNumberField; + use InvoiceNumberRaiseWarningField; + use OriginReferenceField; use PaymentReferenceField; - use ThreeDimFields; - /** - * @var string|null The sales transaction origin reference (id). Provided in form of Guid. Read-only attribute. - * Sample: "f386393c-e4ba-439a-add4-3b366535d7bf". - */ - private $originReference; - - /** + /* * @return string */ public function getLineClassName(): string { return SalesTransactionLine::class; } - - /** - * @return string|null - */ - public function getOriginReference(): ?string - { - return $this->originReference; - } - - /** - * @param string|null $originReference - * @return $this - */ - public function setOriginReference(?string $originReference): SalesTransaction - { - $this->originReference = $originReference; - - return $this; - } - - /** - * When creating a new sales transaction, don't include this tag as the transaction number is determined by the - * system. When updating a sales transaction, the related transaction number should be provided. - * - * @param int|null $number - * @return $this - */ - public function setNumber(?int $number): BaseTransaction - { - return parent::setNumber($number); - } } diff --git a/src/SalesTransactionLine.php b/src/SalesTransactionLine.php index f33175be..3fc534a9 100644 --- a/src/SalesTransactionLine.php +++ b/src/SalesTransactionLine.php @@ -3,27 +3,37 @@ namespace PhpTwinfield; use Money\Money; -use PhpTwinfield\Enums\DebitCredit; +use PhpTwinfield\Dummy; use PhpTwinfield\Enums\LineType; -use PhpTwinfield\Transactions\TransactionFields\FreeTextFields; -use PhpTwinfield\Transactions\TransactionLineFields\PerformanceFields; -use PhpTwinfield\Transactions\TransactionLineFields\ValueOpenField; -use PhpTwinfield\Transactions\TransactionLineFields\VatTotalFields; +use PhpTwinfield\Fields\PerformanceDateField; +use PhpTwinfield\Fields\PerformanceTypeField; +use PhpTwinfield\Fields\Transaction\TransactionLine\BaselineField; +use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceCountryField; +use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceVatNumberField; +use PhpTwinfield\Fields\Transaction\TransactionLine\ValueOpenField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatBaseTotalField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatRepTotalField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatTotalField; use Webmozart\Assert\Assert; class SalesTransactionLine extends BaseTransactionLine { - use VatTotalFields; + use BaselineField; + use PerformanceCountryField; + use PerformanceDateField; + use PerformanceTypeField; + use PerformanceVatNumberField; use ValueOpenField; - use PerformanceFields; - use FreeTextFields; + use VatBaseTotalField; + use VatRepTotalField; + use VatTotalField; - /** + /* * @var SalesTransaction */ private $transaction; - /** + /* * @param SalesTransaction $object */ public function setTransaction($object): void @@ -33,7 +43,7 @@ public function setTransaction($object): void $this->transaction = $object; } - /** + /* * References the transaction this line belongs too. * * @return SalesTransaction @@ -43,35 +53,49 @@ public function getTransaction(): SalesTransaction return $this->transaction; } - /** - * If line type = total the accounts receivable balance account. When dim1 is omitted, by default the general ledger - * account will be taken as entered at the customer in Twinfield. - * - * If line type = detail the profit and loss account. + /* + * Only if line type is vat. The value of the baseline tag is a reference to the line ID of the VAT rate. * - * If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account - * will be taken as entered at the VAT code in Twinfield. + * @param int|null $baseline + * @return $this + * @throws Exception + */ + public function setBaseline(?int $baseline): self + { + if (!$this->getLineType()->equals(LineType::VAT())) { + throw Exception::invalidFieldForLineType("baseline", $this); + } + return parent::setBaseline($baseline); + } + + /* + * Only if line type is total. The amount still owed in base currency. Read-only attribute. * - * @param string|null $dim1 + * @param Money|null $baseValueOpen * @return $this + * @throws Exception */ - public function setDim1(?string $dim1): BaseTransactionLine + public function setBaseValueOpen(?Money $baseValueOpen): parent { - return parent::setDim1($dim1); + if ($baseValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('baseValueOpen', $this); + } + + return parent::setBaseValueOpen($baseValueOpen); } - /** + /* * If line type = total the account receivable. * * If line type = detail the cost center or empty. * * If line type = vat empty. * - * @param string|null $dim2 + * @param Dummy|null $dim2 * @return $this * @throws Exception */ - public function setDim2(?string $dim2): BaseTransactionLine + public function setDim2(?Dummy $dim2): parent { if ($dim2 !== null && $this->getLineType()->equals(LineType::VAT())) { throw Exception::invalidDimensionForLineType(2, $this); @@ -80,177 +104,213 @@ public function setDim2(?string $dim2): BaseTransactionLine return parent::setDim2($dim2); } - /** - * If line type = total - * - In case of a 'normal' sales transaction debit. - * - In case of a credit sales transaction credit. + /* + * If line type = total empty. + * + * If line type = detail the project or asset or empty. * - * If line type = detail or vat - * - In case of a 'normal' sales transaction credit. - * - In case of a credit sales transaction debit. + * If line type = empty. * - * @param DebitCredit $debitCredit + * @param Dummy|null $dim3 * @return $this + * @throws Exception */ - public function setDebitCredit(DebitCredit $debitCredit): BaseTransactionLine + public function setDim3(?Dummy $dim3): parent { - return parent::setDebitCredit($debitCredit); + if ($dim3 !== null && ($this->getLineType()->equals(LineType::TOTAL()) || $this->getLineType()->equals(LineType::VAT())) { + throw Exception::invalidDimensionForLineType(3, $this); + } + + return parent::setDim3($dim3); } - /** - * If line type = total amount including VAT. + /* + * Returns true if a positive amount in the TOTAL line means the amount is 'debit'. Examples of incoming transaction + * types are Sales Transactions, Electronic Bank Statements and Bank Transactions. * - * If line type = detail amount without VAT. + * Returns false if a positive amount in the TOTAL line means the amount is 'credit'. An example of an outgoing + * transaction type is a Purchase Transaction. * - * If line type = vat VAT amount. + * @return bool + */ + protected function isIncomingTransactionType(): bool + { + return true; + } + + /* + * Only if line type is total. The level of the matchable dimension. Read-only attribute. * - * @param Money $value + * @param int|null $matchLevel * @return $this + * @throws Exception */ - public function setValue(Money $value): BaseTransactionLine + public function setMatchLevel(?int $matchLevel): parent { - return parent::setValue($value); + if ($matchLevel !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('matchLevel', $this); + } + + return parent::setMatchLevel($matchLevel); } - /** - * Payment status of the sales transaction. If line type detail or vat always notmatchable. Read-only attribute. + /* + * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The performance type. * - * @param string|null $matchStatus + * @param PerformanceType|null $performanceType * @return $this * @throws Exception */ - public function setMatchStatus(?string $matchStatus): BaseTransactionLine + public function setPerformanceType(?PerformanceType $performanceType): self { - if ( - $matchStatus !== null && - in_array($this->getLineType(), [LineType::DETAIL(), LineType::VAT()]) && - $matchStatus != self::MATCHSTATUS_NOTMATCHABLE - ) { - throw Exception::invalidMatchStatusForLineType($matchStatus, $this); + if ($performanceType !== null && $this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('performanceType', $this); } - return parent::setMatchStatus($matchStatus); + return parent::setPerformanceType($performanceType); } - /** - * Only if line type is total. The level of the matchable dimension. Read-only attribute. + /* + * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The ISO country codes are used. If not added to the request, by default the country code of the customer will be taken. * - * @param int|null $matchLevel + * @param Country|null $performanceCountry * @return $this * @throws Exception */ - public function setMatchLevel(?int $matchLevel): BaseTransactionLine + public function setPerformanceCountry(?Country $performanceCountry): self { - if ($matchLevel !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('matchLevel', $this); + if ($performanceCountry !== null && $this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('performanceCountry', $this); } - return parent::setMatchLevel($matchLevel); + return parent::setPerformanceCountry($performanceCountry); } - /** - * Only if line type is total. The amount still owed in base currency. Read-only attribute. + /* + * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. If not added to the request, by default the VAT number of the customer will be taken. * - * @param Money|null $baseValueOpen + * @param string|null $performanceVatNumber * @return $this * @throws Exception */ - public function setBaseValueOpen(?Money $baseValueOpen): BaseTransactionLine + public function setPerformanceVatNumber(?string $performanceVatNumber): self { - if ($baseValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('baseValueOpen', $this); + if ($performanceVatNumber !== null && $this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('performanceVatNumber', $this); } - return parent::setBaseValueOpen($baseValueOpen); + return parent::setPerformanceVatNumber($performanceVatNumber); } - /** - * If line type = detail the project or asset or empty. + /* + * Only if line type is detail or vat. Mandatory in case of an ICT VAT code but only if performancetype is services. * - * @param string $dim3 + * @param \DateTimeInterface|null $performanceDate * @return $this * @throws Exception */ - public function setProjectAsset(string $dim3) + public function setPerformanceDate(?\DateTimeInterface $performanceDate): self { - if (!$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidDimensionForLineType(3, $this); + if ($performanceDate !== null && (!$this->getPerformanceType()->equals(PerformanceType::SERVICES()) || $this->getLineType()->equals(LineType::TOTAL()))) { + throw Exception::invalidFieldForLineType('performanceDate', $this); } - return $this->setDim3($dim3); + return parent::setPerformanceDate($performanceDate); } - /** - * Only if line type is vat. Amount on which VAT was calculated in the currency of the sales transaction. + /* + * Relation of the transaction. Only if line type is total. Read-only attribute. * - * @param Money|null $vatTurnover + * @param string|null $relation * @return $this * @throws Exception */ - public function setVatTurnover(?Money $vatTurnover) + public function setRelation(?string $relation): parent { - if (!$this->getLineType()->equals(LineType::VAT())) { - throw Exception::invalidFieldForLineType("vatturnover", $this); + if ($relation !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidRelationForLineType($relation, $this); } - return parent::setVatTurnOver($vatTurnover); + + return $this; } - /** - * Only if line type is vat. Amount on which VAT was calculated in base currency. + /* + * Only if line type is total. The amount still owed in reporting currency. Read-only attribute. * - * @param Money|null $vatBaseTurnover + * @param Money|null $reValueOpen * @return $this * @throws Exception */ - public function setVatBaseTurnover(?Money $vatBaseTurnover) + public function setRepValueOpen(?Money $reValueOpen): parent { - if (!$this->getLineType()->equals(LineType::VAT())) { - throw Exception::invalidFieldForLineType("vatbaseturnover", $this); + if ($reValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('reValueOpen', $this); } - return parent::setVatBaseTurnover($vatBaseTurnover); + + return parent::setRepValueOpen($reValueOpen); } - /** - * Only if line type is vat. Amount on which VAT was calculated in reporting currency. + /* + * Only if line type is total. The amount still to be paid in the currency of the sales transaction. Read-only attribute. * - * @param Money|null $vatRepTurnover + * @param Money|null $valueOpen * @return $this * @throws Exception */ - public function setVatRepTurnover(?Money $vatRepTurnover) + public function setValueOpen(?Money $valueOpen): self { - if (!$this->getLineType()->equals(LineType::VAT())) { - throw Exception::invalidFieldForLineType("vatrepturnover", $this); + if ($valueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('valueOpen', $this); } - return parent::setVatRepTurnover($vatRepTurnover); + + return parent::setValueOpen($valueOpen); } - /** - * Only if line type is vat. The value of the baseline tag is a reference to the line ID of the VAT rate. + /* + * Only if line type is total. The total VAT amount in the currency of the sales transaction * - * @param int|null $baseline + * @param Money|null $vatValueOpen * @return $this * @throws Exception */ - public function setBaseline(?int $baseline) + public function setVatValueOpen(?Money $vatValueOpen): parent { - if (!$this->getLineType()->equals(LineType::VAT())) { - throw Exception::invalidFieldForLineType("baseline", $this); + if ($vatValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatValueOpen', $this); } - return parent::setBaseline($baseline); + + return parent::setVatValueOpen($vatValueOpen); } - /** - * Returns true if a positive amount in the TOTAL line means the amount is 'debit'. Examples of incoming transaction - * types are Sales Transactions, Electronic Bank Statements and Bank Transactions. + /* + * Only if line type is total. The total VAT amount in base currency. * - * Returns false if a positive amount in the TOTAL line means the amount is 'credit'. An example of an outgoing - * transaction type is a Purchase Transaction. + * @param Money|null $vatBaseValueOpen + * @return $this + * @throws Exception + */ + public function setVatBaseValueOpen(?Money $vatBaseValueOpen): parent + { + if ($vatBaseValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatBaseValueOpen', $this); + } + + return parent::setVatBaseValueOpen($vatBaseValueOpen); + } + + /* + * Only if line type is total. The total VAT amount in reporting currency. * - * @return bool + * @param Money|null $vatRepValueOpen + * @return $this + * @throws Exception */ - protected function isIncomingTransactionType(): bool + public function setVatRepValueOpen(?Money $vatRepValueOpen): parent { - return true; + if ($vatRepValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatRepValueOpen', $this); + } + + return parent::setVatRepValueOpen($vatRepValueOpen); } } diff --git a/src/Secure/WebservicesAuthentication.php b/src/Secure/WebservicesAuthentication.php index eca9085c..40343880 100644 --- a/src/Secure/WebservicesAuthentication.php +++ b/src/Secure/WebservicesAuthentication.php @@ -10,7 +10,7 @@ class WebservicesAuthentication extends AuthenticatedConnection /** * @var string */ - private $username; + private $userName; /** * @var string */ @@ -37,15 +37,15 @@ class WebservicesAuthentication extends AuthenticatedConnection */ private $cluster = 'https://c3.twinfield.com'; - public function __construct(string $username, string $password, string $organization) + public function __construct(string $userName, string $password, string $organization) { - $this->username = $username; + $this->userName = $userName; $this->password = $password; $this->organization = $organization; } /** - * Login using username / password / organization combo. + * Login using userName / password / organization combo. * * @throws Exception */ @@ -60,16 +60,16 @@ protected function login(): void private const LOGIN_OK = "Ok"; /** - * @param string $username + * @param string $userName * @param string $password * @param string $organization * @return string[] * @throws Exception */ - public function getSessionIdAndCluster(string $username, string $password, string $organization): array + public function getSessionIdAndCluster(string $userName, string $password, string $organization): array { $response = $this->Logon([ - "user" => $username, + "user" => $userName, "password" => $password, "organisation" => $organization, ]); @@ -105,7 +105,7 @@ final protected function WSDL(): string } }; - [$this->sessionID, $this->cluster] = $loginService->getSessionIdAndCluster($this->username, $this->password, $this->organization); + [$this->sessionID, $this->cluster] = $loginService->getSessionIdAndCluster($this->userName, $this->password, $this->organization); } protected function getSoapHeaders() diff --git a/src/Services/BaseService.php b/src/Services/BaseService.php index 8c424909..9391637d 100644 --- a/src/Services/BaseService.php +++ b/src/Services/BaseService.php @@ -41,4 +41,9 @@ public function __construct(string $wsdl = null, array $options = []) parent::__construct($wsdl, $options); } + + public function __call($func, $args) + { + return $this->__soapCall($func, $args); + } } diff --git a/src/Supplier.php b/src/Supplier.php index bed03cf4..c605763b 100644 --- a/src/Supplier.php +++ b/src/Supplier.php @@ -55,6 +55,7 @@ class Supplier extends BaseObject use WebsiteField; private $financials; + private $addresses = []; private $banks = []; private $postingRules = []; @@ -92,10 +93,10 @@ public function addAddress(SupplierAddress $address) return $this; } - public function removeAddress($index) + public function removeAddress($id) { - if (array_key_exists($index, $this->addresses)) { - unset($this->addresses[$index]); + if (array_key_exists($id, $this->addresses)) { + unset($this->addresses[$id]); return true; } else { return false; @@ -113,10 +114,10 @@ public function addBank(SupplierBank $bank) return $this; } - public function removeBank($index) + public function removeBank($id) { - if (array_key_exists($index, $this->banks)) { - unset($this->banks[$index]); + if (array_key_exists($id, $this->banks)) { + unset($this->banks[$id]); return true; } else { return false; @@ -134,10 +135,10 @@ public function addPostingRule(SupplierPostingRule $postingRule) return $this; } - public function removePostingRule($index) + public function removePostingRule($id) { - if (array_key_exists($index, $this->postingRules)) { - unset($this->postingRules[$index]); + if (array_key_exists($id, $this->postingRules)) { + unset($this->postingRules[$id]); return true; } else { return false; diff --git a/src/SupplierBank.php b/src/SupplierBank.php index 50780881..5c245186 100644 --- a/src/SupplierBank.php +++ b/src/SupplierBank.php @@ -28,8 +28,8 @@ class SupplierBank extends BaseObject use AddressField2Field; use AddressField3Field; use AscriptionField; - use BankNameField; use BankBlockedField; + use BankNameField; use BicCodeField; use CityField; use CountryField; diff --git a/src/SupplierFinancials.php b/src/SupplierFinancials.php index d583a00b..aeaf355a 100644 --- a/src/SupplierFinancials.php +++ b/src/SupplierFinancials.php @@ -11,9 +11,9 @@ use PhpTwinfield\Fields\Dimensions\Level2\PayCodeIDField; use PhpTwinfield\Fields\Dimensions\MatchTypeField; use PhpTwinfield\Fields\Dimensions\SubAnalyseField; -use PhpTwinfield\Fields\Dimensions\SubstitutionLevelField; use PhpTwinfield\Fields\Dimensions\SubstituteWithField; use PhpTwinfield\Fields\Dimensions\SubstituteWithIDField; +use PhpTwinfield\Fields\Dimensions\SubstitutionLevelField; use PhpTwinfield\Fields\Dimensions\VatCodeFixedField; use PhpTwinfield\Fields\LevelField; use PhpTwinfield\Fields\VatCodeField; @@ -34,9 +34,9 @@ class SupplierFinancials extends BaseObject use PayCodeIDField; use RelationsReferenceField; use SubAnalyseField; - use SubstitutionLevelField; use SubstituteWithField; use SubstituteWithIDField; + use SubstitutionLevelField; use VatCodeField; use VatCodeFixedField; diff --git a/src/Transactions/Transaction.php b/src/Transactions/Transaction.php deleted file mode 100644 index 2fc1dafb..00000000 --- a/src/Transactions/Transaction.php +++ /dev/null @@ -1,7 +0,0 @@ -autoBalanceVat; - } - - /** - * @param bool $autoBalanceVat - * @return $this - */ - public function setAutoBalanceVat(bool $autoBalanceVat): self - { - $this->autoBalanceVat = $autoBalanceVat; - - return $this; - } -} \ No newline at end of file diff --git a/src/Transactions/TransactionFields/CodeNumberOfficeFields.php b/src/Transactions/TransactionFields/CodeNumberOfficeFields.php deleted file mode 100644 index b0311751..00000000 --- a/src/Transactions/TransactionFields/CodeNumberOfficeFields.php +++ /dev/null @@ -1,82 +0,0 @@ -code = $code; - return $this; - } - - /** - * @return string|int|null - */ - public function getCode() - { - return $this->code; - } - - /** - * @param int $number - * @return $this - */ - public function setNumber(int $number) - { - $this->number = $number; - return $this; - } - - /** - * When creating a new transaction, don't include this tag as the transaction number is determined by the - * system. When updating a transaction, the related transaction number should be provided. - * - * @return int - */ - public function getNumber(): ?int - { - return $this->number; - } - - /** - * Get the booking reference. The booking reference uniquely identifies a booking. - * - * @return BookingReference - */ - public function getBookingReference(): BookingReference - { - return new BookingReference( - $this->office, - $this->code, - $this->number - ); - } -} \ No newline at end of file diff --git a/src/Transactions/TransactionFields/DestinyField.php b/src/Transactions/TransactionFields/DestinyField.php deleted file mode 100644 index 35c224b1..00000000 --- a/src/Transactions/TransactionFields/DestinyField.php +++ /dev/null @@ -1,31 +0,0 @@ -destiny; - } - - /** - * @param Destiny $destiny - * @return $this - */ - public function setDestiny(Destiny $destiny): self - { - $this->destiny = $destiny; - - return $this; - } -} \ No newline at end of file diff --git a/src/Transactions/TransactionFields/DueDateField.php b/src/Transactions/TransactionFields/DueDateField.php deleted file mode 100644 index 6b287647..00000000 --- a/src/Transactions/TransactionFields/DueDateField.php +++ /dev/null @@ -1,47 +0,0 @@ -dueDate; - } - - /** - * @param \DateTimeInterface $date - * @return $this - */ - public function setDueDate(\DateTimeInterface $date) - { - $this->dueDate = $date; - return $this; - } - - /** - * @param string $dateString - * @return $this - * @throws Exception - */ - public function setDueDateFromString(string $dateString) - { - return $this->setDueDate(Util::parseDate($dateString)); - } -} diff --git a/src/Transactions/TransactionFields/FreeTextFields.php b/src/Transactions/TransactionFields/FreeTextFields.php deleted file mode 100644 index d7b2968c..00000000 --- a/src/Transactions/TransactionFields/FreeTextFields.php +++ /dev/null @@ -1,85 +0,0 @@ -freetext1; - } - - /** - * @param null|string $freetext1 - * @return $this - */ - public function setFreetext1(?string $freetext1): self - { - $this->freetext1 = $freetext1; - - return $this; - } - - /** - * @return null|string - */ - public function getFreetext2(): ?string - { - return $this->freetext2; - } - - /** - * @param null|string $freetext2 - * @return $this - */ - public function setFreetext2(?string $freetext2): self - { - $this->freetext2 = $freetext2; - - return $this; - } - - /** - * @return null|string - */ - public function getFreetext3(): ?string - { - return $this->freetext3; - } - - /** - * @param null|string $freetext3 - * @return $this - */ - public function setFreetext3(?string $freetext3): self - { - $this->freetext3 = $freetext3; - - return $this; - } - -} \ No newline at end of file diff --git a/src/Transactions/TransactionFields/InvoiceNumberField.php b/src/Transactions/TransactionFields/InvoiceNumberField.php deleted file mode 100644 index 5683aecf..00000000 --- a/src/Transactions/TransactionFields/InvoiceNumberField.php +++ /dev/null @@ -1,30 +0,0 @@ -invoiceNumber; - } - - /** - * @param string|null $invoiceNumber - * @return $this - */ - public function setInvoiceNumber(?string $invoiceNumber) - { - $this->invoiceNumber = $invoiceNumber; - - return $this; - } -} diff --git a/src/Transactions/TransactionFields/OfficeField.php b/src/Transactions/TransactionFields/OfficeField.php deleted file mode 100644 index ef0d964a..00000000 --- a/src/Transactions/TransactionFields/OfficeField.php +++ /dev/null @@ -1,33 +0,0 @@ -office; - } - - /** - * @return $this - */ - public function setOffice(Office $office): self - { - $this->office = $office; - - return $this; - } -} diff --git a/src/Transactions/TransactionFields/RaiseWarningField.php b/src/Transactions/TransactionFields/RaiseWarningField.php deleted file mode 100644 index 6a70bbd5..00000000 --- a/src/Transactions/TransactionFields/RaiseWarningField.php +++ /dev/null @@ -1,30 +0,0 @@ -raiseWarning; - } - - /** - * @param bool|null $raiseWarning - * @return $this - */ - public function setRaiseWarning(?bool $raiseWarning) - { - $this->raiseWarning = $raiseWarning; - - return $this; - } -} \ No newline at end of file diff --git a/src/Transactions/TransactionFields/StartAndCloseValueFields.php b/src/Transactions/TransactionFields/StartAndCloseValueFields.php deleted file mode 100644 index 34ee10c4..00000000 --- a/src/Transactions/TransactionFields/StartAndCloseValueFields.php +++ /dev/null @@ -1,67 +0,0 @@ -currency; - } - - /** - * Set the currency. Can only be done when the start value is still 0. - * - * @param Currency $currency - * @return $this - */ - public function setCurrency(Currency $currency) - { - Assert::true($this->startvalue->isZero()); - $this->setStartvalue(new Money(0, $currency)); - - return $this; - } - - public function getStartvalue(): Money - { - return $this->startvalue; - } - - public function setStartvalue(Money $startvalue): void - { - $this->currency = $startvalue->getCurrency(); - $this->startvalue = $startvalue; - $this->closevalue = $startvalue; - } - - public function getClosevalue(): Money - { - return $this->closevalue ?? new Money(0, $this->getCurrency()); - } -} \ No newline at end of file diff --git a/src/Transactions/TransactionFields/StatementNumberField.php b/src/Transactions/TransactionFields/StatementNumberField.php deleted file mode 100644 index 5d7ffb63..00000000 --- a/src/Transactions/TransactionFields/StatementNumberField.php +++ /dev/null @@ -1,30 +0,0 @@ -statementnumber; - } - - /** - * @param int $statementnumber - * @return $this - */ - public function setStatementnumber(int $statementnumber) - { - $this->statementnumber = $statementnumber; - return $this; - } -} \ No newline at end of file diff --git a/src/Transactions/TransactionLine.php b/src/Transactions/TransactionLine.php deleted file mode 100644 index c2e8ff1a..00000000 --- a/src/Transactions/TransactionLine.php +++ /dev/null @@ -1,53 +0,0 @@ -comment; - } - - /** - * @param null|string $comment - * @return $this - */ - public function setComment(?string $comment) - { - $this->comment = $comment; - return $this; - } -} \ No newline at end of file diff --git a/src/Transactions/TransactionLineFields/DateField.php b/src/Transactions/TransactionLineFields/DateField.php deleted file mode 100644 index 2ea4c03a..00000000 --- a/src/Transactions/TransactionLineFields/DateField.php +++ /dev/null @@ -1,47 +0,0 @@ -date; - } - - /** - * @param \DateTimeInterface $date - * @return $this - */ - public function setDate(\DateTimeInterface $date) - { - $this->date = $date; - return $this; - } - - /** - * @param string $dateString - * @return $this - * @throws Exception - */ - public function setDateFromString(string $dateString) - { - return $this->setDate(Util::parseDate($dateString)); - } -} \ No newline at end of file diff --git a/src/Transactions/TransactionLineFields/FourDimFields.php b/src/Transactions/TransactionLineFields/FourDimFields.php deleted file mode 100644 index b148fbee..00000000 --- a/src/Transactions/TransactionLineFields/FourDimFields.php +++ /dev/null @@ -1,28 +0,0 @@ -dim4; - } - - /** - * @param string $dim4 - * @return $this - */ - public function setDim4(string $dim4) - { - $this->dim4 = $dim4; - return $this; - } -} \ No newline at end of file diff --git a/src/Transactions/TransactionLineFields/PerformanceFields.php b/src/Transactions/TransactionLineFields/PerformanceFields.php deleted file mode 100644 index edca4f0f..00000000 --- a/src/Transactions/TransactionLineFields/PerformanceFields.php +++ /dev/null @@ -1,144 +0,0 @@ -performanceType; - } - - /** - * @param PerformanceType|null $performanceType - * @return $this - * @throws Exception - */ - public function setPerformanceType(?PerformanceType $performanceType): self - { - if ( - $performanceType !== null && - !in_array($this->getLineType(), [LineType::DETAIL(), LineType::VAT()]) - ) { - throw Exception::invalidFieldForLineType('performanceType', $this); - } - - $this->performanceType = $performanceType; - - return $this; - } - - /** - * @return string|null - */ - public function getPerformanceCountry(): ?string - { - return $this->performanceCountry; - } - - /** - * @param string|null $performanceCountry - * @return $this - * @throws Exception - */ - public function setPerformanceCountry(?string $performanceCountry): self - { - if ( - $performanceCountry !== null && - !in_array($this->getLineType(), [LineType::DETAIL(), LineType::VAT()]) - ) { - throw Exception::invalidFieldForLineType('performanceCountry', $this); - } - - $this->performanceCountry = $performanceCountry; - - return $this; - } - - /** - * @return string|null - */ - public function getPerformanceVatNumber(): ?string - { - return $this->performanceVatNumber; - } - - /** - * @param string|null $performanceVatNumber - * @return $this - * @throws Exception - */ - public function setPerformanceVatNumber(?string $performanceVatNumber): self - { - if ( - $performanceVatNumber !== null && - !in_array($this->getLineType(), [LineType::DETAIL(), LineType::VAT()]) - ) { - throw Exception::invalidFieldForLineType('performanceVatNumber', $this); - } - - $this->performanceVatNumber = $performanceVatNumber; - - return $this; - } - - /** - * @return \DateTimeInterface|null - */ - public function getPerformanceDate(): ?\DateTimeInterface - { - return $this->performanceDate; - } - - /** - * @param \DateTimeInterface|null $performanceDate - * @return $this - * @throws Exception - */ - public function setPerformanceDate(?\DateTimeInterface $performanceDate): self - { - if ( - $performanceDate !== null && - !in_array($this->getLineType(), [LineType::DETAIL(), LineType::VAT()]) - ) { - throw Exception::invalidFieldForLineType('performanceDate', $this); - } - - $this->performanceDate = $performanceDate; - - return $this; - } -} diff --git a/src/Transactions/TransactionLineFields/PeriodField.php b/src/Transactions/TransactionLineFields/PeriodField.php deleted file mode 100644 index 13fe4357..00000000 --- a/src/Transactions/TransactionLineFields/PeriodField.php +++ /dev/null @@ -1,37 +0,0 @@ -period; - } - - /** - * @param string $period - * @return $this - */ - public function setPeriod(string $period): self - { - if (!preg_match("!\\d{4}/\\d{1,2}!", $period)) { - throw new \InvalidArgumentException("Period must be in YYYY/PP format (got: {$period}."); - } - - $this->period = $period; - - return $this; - } -} diff --git a/src/Transactions/TransactionLineFields/ThreeDimFields.php b/src/Transactions/TransactionLineFields/ThreeDimFields.php deleted file mode 100644 index 6b002614..00000000 --- a/src/Transactions/TransactionLineFields/ThreeDimFields.php +++ /dev/null @@ -1,66 +0,0 @@ -dim1; - } - - /** - * @param string|null $dim1 - * @return $this - */ - public function setDim1(?string $dim1) - { - $this->dim1 = $dim1; - return $this; - } - - final public function getDim2(): ?string - { - return $this->dim2; - } - - /** - * @param string|null $dim2 - * @return $this - */ - public function setDim2(?string $dim2) - { - $this->dim2 = $dim2; - return $this; - } - - final public function getDim3(): ?string - { - return $this->dim3; - } - - /** - * @param string|null $dim3 - * @return $this - */ - public function setDim3(?string $dim3) - { - $this->dim3 = $dim3; - return $this; - } -} diff --git a/src/Transactions/TransactionLineFields/ValueOpenField.php b/src/Transactions/TransactionLineFields/ValueOpenField.php deleted file mode 100644 index 1155b103..00000000 --- a/src/Transactions/TransactionLineFields/ValueOpenField.php +++ /dev/null @@ -1,43 +0,0 @@ -valueOpen; - } - - /** - * @param Money|null $valueOpen - * @return $this - * @throws Exception - */ - public function setValueOpen(?Money $valueOpen): self - { - if ($valueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('valueOpen', $this); - } - - $this->valueOpen = $valueOpen; - - return $this; - } -} diff --git a/src/Transactions/TransactionLineFields/VatCodeField.php b/src/Transactions/TransactionLineFields/VatCodeField.php deleted file mode 100644 index d2421d11..00000000 --- a/src/Transactions/TransactionLineFields/VatCodeField.php +++ /dev/null @@ -1,33 +0,0 @@ -vatCode = $vatCode; - - return $this; - } - - /** - * @return null|string - */ - public function getVatCode(): ?string - { - return $this->vatCode; - } -} \ No newline at end of file diff --git a/src/Transactions/TransactionLineFields/VatTotalFields.php b/src/Transactions/TransactionLineFields/VatTotalFields.php deleted file mode 100644 index f688a67e..00000000 --- a/src/Transactions/TransactionLineFields/VatTotalFields.php +++ /dev/null @@ -1,76 +0,0 @@ -vatTotal) ? $this->vatTotal->absolute() : null; - } - - /** - * @param Money|null $vatTotal - * @return $this - * @throws Exception - */ - public function setVatTotal(?Money $vatTotal): self - { - if ($vatTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatTotal', $this); - } - - $this->vatTotal = $vatTotal; - - return $this; - } - - /** - * @return Money|null - */ - public function getVatBaseTotal(): ?Money - { - return !empty($this->vatBaseTotal) ? $this->vatBaseTotal->absolute() : null; - } - - /** - * @param Money|null $vatBaseTotal - * @return $this - * @throws Exception - */ - public function setVatBaseTotal(?Money $vatBaseTotal): self - { - if ($vatBaseTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatBaseTotal', $this); - } - - $this->vatBaseTotal = $vatBaseTotal; - - return $this; - } -} diff --git a/src/Transactions/TransactionLineFields/VatTurnoverFields.php b/src/Transactions/TransactionLineFields/VatTurnoverFields.php deleted file mode 100644 index 9b840455..00000000 --- a/src/Transactions/TransactionLineFields/VatTurnoverFields.php +++ /dev/null @@ -1,81 +0,0 @@ -vatTurnover; - } - - /** - * @param Money|null $vatTurnover - * @return $this - */ - public function setVatTurnover(?Money $vatTurnover) - { - $this->vatTurnover = $vatTurnover; - - return $this; - } - - /** - * @return Money|null - */ - public function getVatBaseTurnover(): ?Money - { - return $this->vatBaseTurnover; - } - - /** - * @param Money|null $vatBaseTurnover - * @return $this - */ - public function setVatBaseTurnover(?Money $vatBaseTurnover) - { - $this->vatBaseTurnover = $vatBaseTurnover; - - return $this; - } - - /** - * @return Money|null - */ - public function getVatRepTurnover(): ?Money - { - return $this->vatRepTurnover; - } - - /** - * @param Money|null $vatRepTurnover - * @return $this - */ - public function setVatRepTurnover(?Money $vatRepTurnover) - { - $this->vatRepTurnover = $vatRepTurnover; - - return $this; - } -} - diff --git a/src/UserRole.php b/src/UserRole.php index d755c53b..1ab3720c 100644 --- a/src/UserRole.php +++ b/src/UserRole.php @@ -15,6 +15,7 @@ class UserRole { use CodeField; + use LevelField; use NameField; use ShortNameField; } \ No newline at end of file diff --git a/src/VatCodeAccount.php b/src/VatCodeAccount.php index aeebc52d..3d51dd17 100644 --- a/src/VatCodeAccount.php +++ b/src/VatCodeAccount.php @@ -2,12 +2,12 @@ namespace PhpTwinfield; -use PhpTwinfield\Fields\IDField; use PhpTwinfield\Fields\Dim1Field; +use PhpTwinfield\Fields\IDField; +use PhpTwinfield\Fields\LineTypeField; use PhpTwinfield\Fields\PercentageField; use PhpTwinfield\Fields\VatCode\GroupCountryField; use PhpTwinfield\Fields\VatCode\GroupField; -use PhpTwinfield\Fields\VatCode\LineTypeField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/VAT @@ -15,8 +15,8 @@ */ class VatCodeAccount extends BaseObject { - use IDField; use Dim1Field; + use IDField; use GroupCountryField; use GroupField; use LineTypeField; diff --git a/src/VatCodePercentage.php b/src/VatCodePercentage.php index dbf78012..e99b78db 100644 --- a/src/VatCodePercentage.php +++ b/src/VatCodePercentage.php @@ -3,11 +3,11 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\CreatedField; +use PhpTwinfield\Fields\DateField; use PhpTwinfield\Fields\NameField; use PhpTwinfield\Fields\PercentageField; use PhpTwinfield\Fields\ShortNameField; use PhpTwinfield\Fields\UserField; -use PhpTwinfield\Fields\VatCode\DateField; /** * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/VAT @@ -35,10 +35,10 @@ public function addAccount(VatCodeAccount $account) return $this; } - public function removeAccount($index) + public function removeAccount($id) { - if (array_key_exists($index, $this->accounts)) { - unset($this->accounts[$index]); + if (array_key_exists($id, $this->accounts)) { + unset($this->accounts[$id]); return true; } else { return false; diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index d4add1d2..f4113615 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\IntegrationTests; use DateTimeImmutable; -use Money\Currency; use Money\Money; use PhpTwinfield\ApiConnectors\TransactionApiConnector; use PhpTwinfield\BankTransaction; @@ -12,6 +11,7 @@ use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\Destiny; use PhpTwinfield\Enums\LineType; +use PhpTwinfield\Enums\MatchStatus; use PhpTwinfield\Mappers\TransactionMapper; use PhpTwinfield\Office; use PhpTwinfield\Response\Response; @@ -58,15 +58,15 @@ public function testGetBankTransactionWorks() $this->assertSame('BNK', $bankTransaction->getCode()); $this->assertSame(201300008, $bankTransaction->getNumber()); $this->assertSame('2013/11', $bankTransaction->getPeriod()); - $this->assertEquals(new Currency('EUR'), $bankTransaction->getCurrency()); + $this->assertEquals('EUR', $bankTransaction->getCurrencyToString()); $this->assertEquals(new DateTimeImmutable('2013-11-04'), $bankTransaction->getDate()); $this->assertSame('import', $bankTransaction->getOrigin()); $this->assertNull($bankTransaction->getFreetext1()); $this->assertNull($bankTransaction->getFreetext2()); $this->assertNull($bankTransaction->getFreetext3()); $this->assertSame(4, $bankTransaction->getStatementnumber()); - $this->assertTrue(Money::EUR(97401)->equals($bankTransaction->getStartvalue())); - $this->assertTrue(Money::EUR(140956)->equals($bankTransaction->getClosevalue())); + $this->assertTrue(Money::EUR(97401)->equals($bankTransaction->getStartValue())); + $this->assertTrue(Money::EUR(140956)->equals($bankTransaction->getCloseValue())); /** @var BankTransactionLine[] $bankTransactionLines */ $bankTransactionLines = $bankTransaction->getLines(); @@ -75,14 +75,14 @@ public function testGetBankTransactionWorks() $this->assertEquals(LineType::TOTAL(), $totalLine->getLineType()); $this->assertSame(1, $totalLine->getId()); - $this->assertSame('1001', $totalLine->getDim1()); + $this->assertSame('1001', $totalLine->getDim1ToString()); $this->assertEquals(DebitCredit::DEBIT(), $totalLine->getDebitCredit()); $this->assertEquals(Money::EUR(43555), $totalLine->getValue()); $this->assertEquals(Money::EUR(43555), $totalLine->getBaseValue()); $this->assertSame(1.0, $totalLine->getRate()); $this->assertEquals(Money::EUR(65333), $totalLine->getRepValue()); $this->assertSame(1.500000000, $totalLine->getRepRate()); - $this->assertSame(BankTransactionLine::MATCHSTATUS_NOTMATCHABLE, $totalLine->getMatchStatus()); + $this->assertSame(MatchStatus::NOTMATCHABLE(), $totalLine->getMatchStatus()); $this->assertNull($totalLine->getMatchLevel()); $this->assertNull($totalLine->getBaseValueOpen()); $this->assertNull($totalLine->getVatCode()); @@ -96,8 +96,8 @@ public function testGetBankTransactionWorks() $this->assertEquals(LineType::DETAIL(), $detailLine->getLineType()); $this->assertSame(2, $detailLine->getId()); - $this->assertSame('1300', $detailLine->getDim1()); - $this->assertSame('1000', $detailLine->getDim2()); + $this->assertSame('1300', $detailLine->getDim1ToString()); + $this->assertSame('1000', $detailLine->getDim2ToString()); $this->assertEquals(DebitCredit::CREDIT(), $detailLine->getDebitCredit()); $this->assertSame('11001770', $detailLine->getInvoiceNumber()); $this->assertEquals(Money::EUR(43555), $detailLine->getValue()); @@ -106,7 +106,7 @@ public function testGetBankTransactionWorks() $this->assertEquals(Money::EUR(65333), $totalLine->getRepValue()); $this->assertSame(1.500000000, $totalLine->getRepRate()); $this->assertSame('Invoice paid', $detailLine->getDescription()); - $this->assertSame(BankTransactionLine::MATCHSTATUS_AVAILABLE, $detailLine->getMatchStatus()); + $this->assertSame(MatchStatus::AVAILABLE(), $detailLine->getMatchStatus()); $this->assertSame(2, $detailLine->getMatchLevel()); $this->assertEquals(Money::EUR(43555), $detailLine->getBaseValueOpen()); $this->assertEquals(Money::EUR(65333), $detailLine->getRepValue()); @@ -128,24 +128,24 @@ public function testSendBankTransactionWorks() ->setDestiny(Destiny::TEMPORARY()) ->setRaiseWarning(false) ->setCode('BNK') - ->setCurrency(new Currency('EUR')) + ->setCurrencyFromString('EUR') ->setDate(new DateTimeImmutable('2013-11-04')) ->setStatementnumber(4) - ->setStartvalue(Money::EUR(97401)); + ->setStartValue(Money::EUR(97401)); $totalLine = new BankTransactionLine(); $totalLine ->setLineType(LineType::TOTAL()) ->setId('1') - ->setDim1('1001') + ->setDim1FromString('1001') ->setValue(Money::EUR(43555)); $detailLine = new BankTransactionLine(); $detailLine ->setLineType(LineType::DETAIL()) ->setId('2') - ->setDim1('1300') - ->setDim2('1000') + ->setDim1FromString('1300') + ->setDim2FromString('1000') ->setValue(Money::EUR(43555)) ->setInvoiceNumber('11001770') ->setDescription('Invoice paid'); diff --git a/tests/IntegrationTests/BrowseDataApiConnectorTest.php b/tests/IntegrationTests/BrowseDataApiConnectorTest.php index 83dedc14..ce12c2f3 100644 --- a/tests/IntegrationTests/BrowseDataApiConnectorTest.php +++ b/tests/IntegrationTests/BrowseDataApiConnectorTest.php @@ -37,7 +37,7 @@ public function testGetBrowseDefinition() $this->assertInstanceOf(BrowseDefinition::class, $browseDefinition); - $this->assertEquals('001', $browseDefinition->getOffice()->getCode()); + $this->assertEquals('001', $browseDefinition->getOfficeToCode()); $this->assertEquals('000', $browseDefinition->getCode()); $this->assertEquals('General ledger transactions', $browseDefinition->getName()); $this->assertEquals('General ledger transactions', $browseDefinition->getShortName()); @@ -207,7 +207,7 @@ public function testGetBrowseData() // Rows $row1 = $browseData->getRows()[0]; $this->assertCount(6, $browseData->getRows()); - $this->assertEquals('001', $row1->getOffice()->getCode()); + $this->assertEquals('001', $row1->getOfficeToString()); $this->assertEquals('BNK', $row1->getCode()); $this->assertEquals('201300001', $row1->getNumber()); $this->assertEquals('2', $row1->getLine()); diff --git a/tests/IntegrationTests/CashTransactionIntegrationTest.php b/tests/IntegrationTests/CashTransactionIntegrationTest.php index d6c4b11d..3b4b3123 100644 --- a/tests/IntegrationTests/CashTransactionIntegrationTest.php +++ b/tests/IntegrationTests/CashTransactionIntegrationTest.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\IntegrationTests; use DateTimeImmutable; -use Money\Currency; use Money\Money; use PhpTwinfield\ApiConnectors\TransactionApiConnector; use PhpTwinfield\CashTransaction; @@ -12,6 +11,7 @@ use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\Destiny; use PhpTwinfield\Enums\LineType; +use PhpTwinfield\Enums\MatchStatus; use PhpTwinfield\Mappers\TransactionMapper; use PhpTwinfield\Office; use PhpTwinfield\Response\Response; @@ -60,15 +60,15 @@ public function testGetCashTransactionWorks() $this->assertSame('CASH', $cashTransaction->getCode()); $this->assertSame(201300008, $cashTransaction->getNumber()); $this->assertSame('2013/11', $cashTransaction->getPeriod()); - $this->assertEquals(new Currency('EUR'), $cashTransaction->getCurrency()); + $this->assertEquals('EUR', $cashTransaction->getCurrencyToString()); $this->assertEquals(new DateTimeImmutable('2013-11-04'), $cashTransaction->getDate()); $this->assertSame('import', $cashTransaction->getOrigin()); $this->assertNull($cashTransaction->getFreetext1()); $this->assertNull($cashTransaction->getFreetext2()); $this->assertNull($cashTransaction->getFreetext3()); $this->assertSame(4, $cashTransaction->getStatementnumber()); - $this->assertTrue(Money::EUR(97401)->equals($cashTransaction->getStartvalue())); - $this->assertTrue(Money::EUR(140956)->equals($cashTransaction->getClosevalue())); + $this->assertTrue(Money::EUR(97401)->equals($cashTransaction->getStartValue())); + $this->assertTrue(Money::EUR(140956)->equals($cashTransaction->getCloseValue())); /** @var CashTransactionLine[] $cashTransactionLines */ $cashTransactionLines = $cashTransaction->getLines(); @@ -77,14 +77,14 @@ public function testGetCashTransactionWorks() $this->assertEquals(LineType::TOTAL(), $totalLine->getLineType()); $this->assertSame(1, $totalLine->getId()); - $this->assertSame('1002', $totalLine->getDim1()); + $this->assertSame('1002', $totalLine->getDim1ToString()); $this->assertEquals(DebitCredit::DEBIT(), $totalLine->getDebitCredit()); $this->assertEquals(Money::EUR(43555), $totalLine->getValue()); $this->assertEquals(Money::EUR(43555), $totalLine->getBaseValue()); $this->assertSame(1.0, $totalLine->getRate()); $this->assertEquals(Money::EUR(65333), $totalLine->getRepValue()); $this->assertSame(1.500000000, $totalLine->getRepRate()); - $this->assertSame(CashTransactionLine::MATCHSTATUS_NOTMATCHABLE, $totalLine->getMatchStatus()); + $this->assertSame(MatchStatus::NOTMATCHABLE(), $totalLine->getMatchStatus()); $this->assertNull($totalLine->getMatchLevel()); $this->assertNull($totalLine->getBaseValueOpen()); $this->assertNull($totalLine->getVatCode()); @@ -98,8 +98,8 @@ public function testGetCashTransactionWorks() $this->assertEquals(LineType::DETAIL(), $detailLine->getLineType()); $this->assertSame(2, $detailLine->getId()); - $this->assertSame('1300', $detailLine->getDim1()); - $this->assertSame('1000', $detailLine->getDim2()); + $this->assertSame('1300', $detailLine->getDim1ToString()); + $this->assertSame('1000', $detailLine->getDim2ToString()); $this->assertEquals(DebitCredit::CREDIT(), $detailLine->getDebitCredit()); $this->assertSame('11001770', $detailLine->getInvoiceNumber()); $this->assertEquals(Money::EUR(43555), $detailLine->getValue()); @@ -108,7 +108,7 @@ public function testGetCashTransactionWorks() $this->assertEquals(Money::EUR(65333), $totalLine->getRepValue()); $this->assertSame(1.500000000, $totalLine->getRepRate()); $this->assertSame('Invoice paid', $detailLine->getDescription()); - $this->assertSame(SalesTransactionLine::MATCHSTATUS_AVAILABLE, $detailLine->getMatchStatus()); + $this->assertSame(MatchStatus::AVAILABLE(), $detailLine->getMatchStatus()); $this->assertSame(2, $detailLine->getMatchLevel()); $this->assertEquals(Money::EUR(43555), $detailLine->getBaseValueOpen()); $this->assertEquals(Money::EUR(65333), $detailLine->getRepValue()); @@ -130,7 +130,7 @@ public function testSendCashTransactionWorks() ->setDestiny(Destiny::TEMPORARY()) ->setRaiseWarning(false) ->setCode('CASH') - ->setCurrency(new Currency('EUR')) + ->setCurrencyFromString('EUR') ->setDate(new DateTimeImmutable('2013-11-04')) ->setStatementnumber(4) ->setStartvalue(Money::EUR(97401)); @@ -139,15 +139,15 @@ public function testSendCashTransactionWorks() $totalLine ->setLineType(LineType::TOTAL()) ->setId('1') - ->setDim1('1002') + ->setDim1FromString('1002') ->setValue(Money::EUR(43555)); $detailLine = new CashTransactionLine(); $detailLine ->setLineType(LineType::DETAIL()) ->setId('2') - ->setDim1('1300') - ->setDim2('1000') + ->setDim1FromString('1300') + ->setDim2FromString('1000') ->setValue(Money::EUR(43555)) ->setInvoiceNumber('11001770') ->setDescription('Invoice paid'); diff --git a/tests/IntegrationTests/JournalTransactionIntegrationTest.php b/tests/IntegrationTests/JournalTransactionIntegrationTest.php index ee16f03c..cb9d0312 100644 --- a/tests/IntegrationTests/JournalTransactionIntegrationTest.php +++ b/tests/IntegrationTests/JournalTransactionIntegrationTest.php @@ -2,13 +2,13 @@ namespace PhpTwinfield\IntegrationTests; -use Money\Currency; use Money\Money; use PhpTwinfield\ApiConnectors\TransactionApiConnector; use PhpTwinfield\DomDocuments\TransactionsDocument; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\Destiny; use PhpTwinfield\Enums\LineType; +use PhpTwinfield\Enums\MatchStatus; use PhpTwinfield\JournalTransaction; use PhpTwinfield\JournalTransactionLine; use PhpTwinfield\Mappers\TransactionMapper; @@ -57,7 +57,7 @@ public function testGetJournalTransactionWorks() $this->assertSame('MEMO', $journalTransaction->getCode()); $this->assertSame(201300003, $journalTransaction->getNumber()); $this->assertSame('2013/11', $journalTransaction->getPeriod()); - $this->assertEquals(new Currency('EUR'), $journalTransaction->getCurrency()); + $this->assertEquals('EUR', $journalTransaction->getCurrencyToString()); $this->assertEquals(new \DateTimeImmutable('2013-11-04'), $journalTransaction->getDate()); $this->assertSame('import', $journalTransaction->getOrigin()); $this->assertNull($journalTransaction->getFreetext1()); @@ -72,7 +72,7 @@ public function testGetJournalTransactionWorks() $this->assertEquals(LineType::DETAIL(), $detailLine1->getLineType()); $this->assertSame(1, $detailLine1->getId()); - $this->assertSame('4008', $detailLine1->getDim1()); + $this->assertSame('4008', $detailLine1->getDim1ToString()); $this->assertNull($detailLine1->getDim2()); $this->assertEquals(DebitCredit::DEBIT(), $detailLine1->getDebitCredit()); $this->assertEquals(Money::EUR(43555), $detailLine1->getValue()); @@ -81,7 +81,7 @@ public function testGetJournalTransactionWorks() $this->assertEquals(Money::EUR(65333), $detailLine1->getRepValue()); $this->assertSame(1.500000000, $detailLine1->getRepRate()); $this->assertNull($detailLine1->getDescription()); - $this->assertSame(JournalTransactionLine::MATCHSTATUS_NOTMATCHABLE, $detailLine1->getMatchStatus()); + $this->assertSame(MatchStatus::NOTMATCHABLE(), $detailLine1->getMatchStatus()); $this->assertNull($detailLine1->getMatchLevel()); $this->assertNull($detailLine1->getBaseValueOpen()); $this->assertNull($detailLine1->getVatCode()); @@ -94,8 +94,8 @@ public function testGetJournalTransactionWorks() $this->assertEquals(LineType::DETAIL(), $detailLine2->getLineType()); $this->assertSame(2, $detailLine2->getId()); - $this->assertSame('1300', $detailLine2->getDim1()); - $this->assertSame('1000', $detailLine2->getDim2()); + $this->assertSame('1300', $detailLine2->getDim1ToString()); + $this->assertSame('1000', $detailLine2->getDim2ToString()); $this->assertEquals(DebitCredit::CREDIT(), $detailLine2->getDebitCredit()); $this->assertEquals(Money::EUR(43555), $detailLine2->getValue()); $this->assertEquals(Money::EUR(43555), $detailLine2->getBaseValue()); @@ -103,7 +103,7 @@ public function testGetJournalTransactionWorks() $this->assertEquals(Money::EUR(65333), $detailLine2->getRepValue()); $this->assertSame(1.500000000, $detailLine2->getRepRate()); $this->assertSame('Invoice paid', $detailLine2->getDescription()); - $this->assertSame(JournalTransactionLine::MATCHSTATUS_AVAILABLE, $detailLine2->getMatchStatus()); + $this->assertSame(MatchStatus::AVAILABLE(), $detailLine2->getMatchStatus()); $this->assertSame(2, $detailLine2->getMatchLevel()); $this->assertEquals(Money::EUR(43555), $detailLine2->getBaseValueOpen()); $this->assertNull($detailLine2->getVatCode()); @@ -121,7 +121,7 @@ public function testSendJournalTransactionWorks() $journalTransaction ->setDestiny(Destiny::TEMPORARY()) ->setCode('MEMO') - ->setCurrency(new Currency('EUR')) + ->setCurrencyFromString('EUR') ->setDate(new \DateTimeImmutable('2013-11-04')) ->setOffice(Office::fromCode('001')); @@ -129,15 +129,15 @@ public function testSendJournalTransactionWorks() $detailLine1 ->setLineType(LineType::DETAIL()) ->setId('1') - ->setDim1('4008') + ->setDim1FromString('4008') ->setValue(Money::EUR(-43555)); $detailLine2 = new JournalTransactionLine(); $detailLine2 ->setLineType(LineType::DETAIL()) ->setId('2') - ->setDim1('1300') - ->setDim2('1000') + ->setDim1FromString('1300') + ->setDim2FromString('1000') ->setValue(Money::EUR(43555)) ->setInvoiceNumber('11001770') ->setDescription('Invoice paid'); diff --git a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php index d93bc135..6c20fc6f 100644 --- a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php +++ b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php @@ -2,13 +2,13 @@ namespace PhpTwinfield\IntegrationTests; -use Money\Currency; use Money\Money; use PhpTwinfield\ApiConnectors\TransactionApiConnector; use PhpTwinfield\DomDocuments\TransactionsDocument; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\Destiny; use PhpTwinfield\Enums\LineType; +use PhpTwinfield\Enums\MatchStatus; use PhpTwinfield\Mappers\TransactionMapper; use PhpTwinfield\Office; use PhpTwinfield\PurchaseTransaction; @@ -56,7 +56,7 @@ public function testGetPurchaseTransactionWorks() $this->assertSame('INK', $purchaseTransaction->getCode()); $this->assertSame(201300021, $purchaseTransaction->getNumber()); $this->assertSame('2013/05', $purchaseTransaction->getPeriod()); - $this->assertEquals(new Currency('EUR'), $purchaseTransaction->getCurrency()); + $this->assertEquals('EUR', $purchaseTransaction->getCurrencyToString()); $this->assertEquals(new \DateTimeImmutable('2013-05-02'), $purchaseTransaction->getDate()); $this->assertSame('import', $purchaseTransaction->getOrigin()); $this->assertNull($purchaseTransaction->getFreetext1()); @@ -73,8 +73,8 @@ public function testGetPurchaseTransactionWorks() $this->assertEquals(LineType::TOTAL(), $totalLine->getLineType()); $this->assertSame(1, $totalLine->getId()); - $this->assertSame('1600', $totalLine->getDim1()); - $this->assertSame('2000', $totalLine->getDim2()); + $this->assertSame('1600', $totalLine->getDim1ToString()); + $this->assertSame('2000', $totalLine->getDim2ToString()); $this->assertEquals(DebitCredit::CREDIT(), $totalLine->getDebitCredit()); $this->assertEquals(Money::EUR(12100), $totalLine->getValue()); $this->assertEquals(Money::EUR(12100), $totalLine->getBaseValue()); @@ -82,7 +82,7 @@ public function testGetPurchaseTransactionWorks() $this->assertEquals(Money::EUR(15653), $totalLine->getRepValue()); $this->assertSame(1.293600000, $totalLine->getRepRate()); $this->assertSame('', $totalLine->getDescription()); - $this->assertSame(PurchaseTransactionLine::MATCHSTATUS_AVAILABLE, $totalLine->getMatchStatus()); + $this->assertSame(MatchStatus::AVAILABLE(), $totalLine->getMatchStatus()); $this->assertSame(2, $totalLine->getMatchLevel()); $this->assertEquals(Money::EUR(12100), $totalLine->getBaseValueOpen()); $this->assertNull($totalLine->getVatCode()); @@ -93,7 +93,7 @@ public function testGetPurchaseTransactionWorks() $this->assertEquals(LineType::DETAIL(), $detailLine->getLineType()); $this->assertSame(2, $detailLine->getId()); - $this->assertSame('8020', $detailLine->getDim1()); + $this->assertSame('8020', $detailLine->getDim1ToString()); $this->assertNull($detailLine->getDim2()); $this->assertEquals(DebitCredit::DEBIT(), $detailLine->getDebitCredit()); $this->assertEquals(Money::EUR(10000), $detailLine->getValue()); @@ -102,10 +102,10 @@ public function testGetPurchaseTransactionWorks() $this->assertEquals(Money::EUR(12936), $detailLine->getRepValue()); $this->assertSame(1.293600000, $detailLine->getRepRate()); $this->assertSame('Outfit', $detailLine->getDescription()); - $this->assertSame(PurchaseTransactionLine::MATCHSTATUS_NOTMATCHABLE, $detailLine->getMatchStatus()); + $this->assertSame(MatchStatus::NOTMATCHABLE(), $detailLine->getMatchStatus()); $this->assertNull($detailLine->getMatchLevel()); $this->assertNull($detailLine->getBaseValueOpen()); - $this->assertSame('IH', $detailLine->getVatCode()); + $this->assertSame('IH', $detailLine->getVatCodeToString()); $this->assertEquals(Money::EUR(2100), $detailLine->getVatValue()); $this->assertNull($detailLine->getVatTotal()); $this->assertNull($detailLine->getVatBaseTotal()); @@ -113,7 +113,7 @@ public function testGetPurchaseTransactionWorks() $this->assertEquals(LineType::VAT(), $vatLine->getLineType()); $this->assertSame(3, $vatLine->getId()); - $this->assertSame('1510', $vatLine->getDim1()); + $this->assertSame('1510', $vatLine->getDim1ToString()); $this->assertNull($vatLine->getDim2()); $this->assertEquals(DebitCredit::DEBIT(), $vatLine->getDebitCredit()); $this->assertEquals(Money::EUR(2100), $vatLine->getValue()); @@ -125,7 +125,7 @@ public function testGetPurchaseTransactionWorks() $this->assertNull($vatLine->getMatchStatus()); $this->assertNull($vatLine->getMatchLevel()); $this->assertNull($vatLine->getBaseValueOpen()); - $this->assertSame('IH', $vatLine->getVatCode()); + $this->assertSame('IH', $vatLine->getVatCodeToString()); $this->assertNull($vatLine->getVatValue()); $this->assertNull($vatLine->getVatTotal()); $this->assertNull($vatLine->getVatBaseTotal()); @@ -139,7 +139,7 @@ public function testSendPurchaseTransactionWorks() ->setDestiny(Destiny::TEMPORARY()) ->setRaiseWarning(false) ->setCode('INK') - ->setCurrency(new Currency('EUR')) + ->setCurrencyFromString('EUR') ->setDate(new \DateTimeImmutable('2013-05-02')) ->setPeriod('2013/05') ->setInvoiceNumber('20130-5481') @@ -151,8 +151,8 @@ public function testSendPurchaseTransactionWorks() $totalLine ->setLineType(LineType::TOTAL()) ->setId('1') - ->setDim1('1600') - ->setDim2('2000') + ->setDim1FromString('1600') + ->setDim2FromString('2000') ->setValue(Money::EUR(12100)) ->setDescription(''); @@ -160,10 +160,10 @@ public function testSendPurchaseTransactionWorks() $detailLine ->setLineType(LineType::DETAIL()) ->setId('2') - ->setDim1('8020') + ->setDim1FromString('8020') ->setValue(Money::EUR(10000)) ->setDescription('Outfit') - ->setVatCode('IH'); + ->setVatCodeFromString('IH'); $purchaseTransaction ->addLine($totalLine) diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index 15f1121a..4b110df6 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -2,13 +2,13 @@ namespace PhpTwinfield\IntegrationTests; -use Money\Currency; use Money\Money; use PhpTwinfield\ApiConnectors\TransactionApiConnector; use PhpTwinfield\DomDocuments\TransactionsDocument; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\Destiny; use PhpTwinfield\Enums\LineType; +use PhpTwinfield\Enums\MatchStatus; use PhpTwinfield\Mappers\TransactionMapper; use PhpTwinfield\Office; use PhpTwinfield\Response\Response; @@ -56,7 +56,7 @@ public function testGetSalesTransactionWorks() $this->assertSame('SLS', $salesTransaction->getCode()); $this->assertSame(201300095, $salesTransaction->getNumber()); $this->assertSame('2013/05', $salesTransaction->getPeriod()); - $this->assertEquals(new Currency('EUR'), $salesTransaction->getCurrency()); + $this->assertEquals('EUR', $salesTransaction->getCurrencyToString()); $this->assertEquals(new \DateTimeImmutable('2013-05-02'), $salesTransaction->getDate()); $this->assertSame('import', $salesTransaction->getOrigin()); $this->assertNull($salesTransaction->getFreetext1()); @@ -74,8 +74,8 @@ public function testGetSalesTransactionWorks() $this->assertEquals(LineType::TOTAL(), $totalLine->getLineType()); $this->assertSame(1, $totalLine->getId()); - $this->assertSame('1300', $totalLine->getDim1()); - $this->assertSame('1000', $totalLine->getDim2()); + $this->assertSame('1300', $totalLine->getDim1ToString()); + $this->assertSame('1000', $totalLine->getDim2ToString()); $this->assertEquals(DebitCredit::DEBIT(), $totalLine->getDebitCredit()); $this->assertEquals(Money::EUR(12100), $totalLine->getValue()); $this->assertEquals(Money::EUR(12100), $totalLine->getBaseValue()); @@ -83,7 +83,7 @@ public function testGetSalesTransactionWorks() $this->assertEquals(Money::EUR(15653), $totalLine->getRepValue()); $this->assertSame(1.293600000, $totalLine->getRepRate()); $this->assertSame('', $totalLine->getDescription()); - $this->assertSame(SalesTransactionLine::MATCHSTATUS_AVAILABLE, $totalLine->getMatchStatus()); + $this->assertSame(MatchStatus::AVAILABLE(), $totalLine->getMatchStatus()); $this->assertSame(2, $totalLine->getMatchLevel()); $this->assertEquals(Money::EUR(12100), $totalLine->getBaseValueOpen()); $this->assertNull($totalLine->getVatCode()); @@ -98,7 +98,7 @@ public function testGetSalesTransactionWorks() $this->assertEquals(LineType::DETAIL(), $detailLine->getLineType()); $this->assertSame(2, $detailLine->getId()); - $this->assertSame('8020', $detailLine->getDim1()); + $this->assertSame('8020', $detailLine->getDim1ToString()); $this->assertNull($detailLine->getDim2()); $this->assertEquals(DebitCredit::CREDIT(), $detailLine->getDebitCredit()); $this->assertEquals(Money::EUR(10000), $detailLine->getValue()); @@ -107,10 +107,10 @@ public function testGetSalesTransactionWorks() $this->assertEquals(Money::EUR(12936), $detailLine->getRepValue()); $this->assertSame(1.293600000, $detailLine->getRepRate()); $this->assertSame('Outfit', $detailLine->getDescription()); - $this->assertSame(SalesTransactionLine::MATCHSTATUS_NOTMATCHABLE, $detailLine->getMatchStatus()); + $this->assertSame(MatchStatus::NOTMATCHABLE(), $detailLine->getMatchStatus()); $this->assertNull($detailLine->getMatchLevel()); $this->assertNull($detailLine->getBaseValueOpen()); - $this->assertSame('VH', $detailLine->getVatCode()); + $this->assertSame('VH', $detailLine->getVatCodeToString()); $this->assertEquals(Money::EUR(2100), $detailLine->getVatValue()); $this->assertNull($detailLine->getVatTotal()); $this->assertNull($detailLine->getVatBaseTotal()); @@ -122,7 +122,7 @@ public function testGetSalesTransactionWorks() $this->assertEquals(LineType::VAT(), $vatLine->getLineType()); $this->assertSame(3, $vatLine->getId()); - $this->assertSame('1530', $vatLine->getDim1()); + $this->assertSame('1530', $vatLine->getDim1ToString()); $this->assertNull($vatLine->getDim2()); $this->assertEquals(DebitCredit::CREDIT(), $vatLine->getDebitCredit()); $this->assertEquals(Money::EUR(2100), $vatLine->getValue()); @@ -134,7 +134,7 @@ public function testGetSalesTransactionWorks() $this->assertNull($vatLine->getMatchStatus()); $this->assertNull($vatLine->getMatchLevel()); $this->assertNull($vatLine->getBaseValueOpen()); - $this->assertSame('VH', $vatLine->getVatCode()); + $this->assertSame('VH', $vatLine->getVatCodeToString()); $this->assertNull($vatLine->getVatValue()); $this->assertNull($vatLine->getVatTotal()); $this->assertNull($vatLine->getVatBaseTotal()); @@ -152,7 +152,7 @@ public function testSendSalesTransactionWorks() ->setDestiny(Destiny::TEMPORARY()) ->setRaiseWarning(false) ->setCode('SLS') - ->setCurrency(new Currency('EUR')) + ->setCurrencyFromString('EUR') ->setDate(new \DateTimeImmutable('2013-05-02')) ->setPeriod('2013/05') ->setInvoiceNumber('20130-6000') @@ -164,8 +164,8 @@ public function testSendSalesTransactionWorks() $totalLine ->setLineType(LineType::TOTAL()) ->setId('1') - ->setDim1('1300') - ->setDim2('1000') + ->setDim1FromString('1300') + ->setDim2FromString('1000') ->setValue(Money::EUR(12100)) ->setDescription(''); @@ -173,10 +173,10 @@ public function testSendSalesTransactionWorks() $detailLine ->setLineType(LineType::DETAIL()) ->setId('2') - ->setDim1('8020') + ->setDim1FromString('8020') ->setValue(Money::EUR(10000)) ->setDescription('Outfit') - ->setVatCode('VH'); + ->setVatCodeFromString('VH'); $salesTransaction ->addLine($totalLine) diff --git a/tests/UnitTests/ApiConnectors/MatchesApiConnectorTest.php b/tests/UnitTests/ApiConnectors/MatchesApiConnectorTest.php index 821f2e5a..fd3b45c8 100644 --- a/tests/UnitTests/ApiConnectors/MatchesApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/MatchesApiConnectorTest.php @@ -87,15 +87,15 @@ public function testSendAllReturnsMappedObjects() $this->assertCount(2, $lines); $line = $lines[0]; - $this->assertEquals("VRK", $line->getTranscode()); - $this->assertSame(201700103, $line->getTransnumber()); - $this->assertSame(1, $line->getTransline()); + $this->assertEquals("VRK", $line->getTransCode()); + $this->assertSame(201700103, $line->getTransNumber()); + $this->assertSame(1, $line->getTransLine()); $this->assertEquals(Money::EUR(526), $line->getMatchValue()); $line = $lines[1]; - $this->assertEquals("DUM2", $line->getTranscode()); - $this->assertSame(201700029, $line->getTransnumber()); - $this->assertSame(79, $line->getTransline()); + $this->assertEquals("DUM2", $line->getTransCode()); + $this->assertSame(201700029, $line->getTransNumber()); + $this->assertSame(79, $line->getTransLine()); $this->assertEquals(Money::EUR(-526), $line->getMatchValue()); /** @var MatchSet $matchSet */ @@ -113,15 +113,15 @@ public function testSendAllReturnsMappedObjects() $this->assertCount(2, $lines); $line = $lines[0]; - $this->assertEquals("VRK", $line->getTranscode()); - $this->assertSame(201700100, $line->getTransnumber()); - $this->assertSame(1, $line->getTransline()); + $this->assertEquals("VRK", $line->getTransCode()); + $this->assertSame(201700100, $line->getTransNumber()); + $this->assertSame(1, $line->getTransLine()); $this->assertEquals(Money::EUR(140), $line->getMatchValue()); $line = $lines[1]; - $this->assertEquals("DUM2", $line->getTranscode()); - $this->assertSame(201700029, $line->getTransnumber()); - $this->assertSame(64, $line->getTransline()); + $this->assertEquals("DUM2", $line->getTransCode()); + $this->assertSame(201700029, $line->getTransNumber()); + $this->assertSame(64, $line->getTransLine()); $this->assertEquals(Money::EUR(-140), $line->getMatchValue()); } } diff --git a/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php b/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php index f60c099e..d4be823e 100644 --- a/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php @@ -122,7 +122,7 @@ public function testSendReturnsMappedObjects() $mapped = $this->apiConnector->send($transaction); $this->assertEquals("VRK", $mapped->getCode()); - $this->assertEquals(new Currency("EUR"), $mapped->getCurrency()); + $this->assertEquals("EUR", $mapped->getCurrencyToString()); $this->assertEquals("2017/09", $mapped->getPeriod()); $this->assertEquals("INV123458", $mapped->getInvoiceNumber()); $this->assertEquals(new \DateTimeImmutable("2017-09-01"), $mapped->getDate()); diff --git a/tests/UnitTests/BankTransactionLineUnitTest.php b/tests/UnitTests/BankTransactionLineUnitTest.php index 80f05e00..c559f4b7 100644 --- a/tests/UnitTests/BankTransactionLineUnitTest.php +++ b/tests/UnitTests/BankTransactionLineUnitTest.php @@ -7,6 +7,7 @@ use PhpTwinfield\BankTransaction; use PhpTwinfield\BankTransactionLine; use PhpTwinfield\Enums\LineType; +use PhpTwinfield\Enums\MatchStatus; use PhpTwinfield\SalesTransaction; class BankTransactionLineUnitTest extends \PHPUnit\Framework\TestCase @@ -83,8 +84,8 @@ public function testSetMatchStatus() { $this->line->setLineType(LineType::DETAIL()); - $this->assertEquals($this->line, $this->line->setMatchStatus(BankTransactionLine::MATCHSTATUS_MATCHED), 'Fluid interface is expected'); - $this->assertSame(BankTransactionLine::MATCHSTATUS_MATCHED, $this->line->getMatchStatus()); + $this->assertEquals($this->line, $this->line->setMatchStatus(MatchStatus::MATCHED()), 'Fluid interface is expected'); + $this->assertSame(MatchStatus::MATCHED(), $this->line->getMatchStatus()); } public function testCanNotSetMatchStatusOtherThanNotMatchableIfLineTypeIsNotDetail() @@ -92,7 +93,7 @@ public function testCanNotSetMatchStatusOtherThanNotMatchableIfLineTypeIsNotDeta $this->expectExceptionMessage('Invalid match status \'matched\' for line class PhpTwinfield\BankTransactionLine and type \'vat\'.'); $this->line->setLineType(LineType::VAT()); - $this->line->setMatchStatus(BankTransactionLine::MATCHSTATUS_MATCHED); + $this->line->setMatchStatus(MatchStatus::MATCHED()); } public function testSetMatchLevel() diff --git a/tests/UnitTests/BankTransactionUnitTest.php b/tests/UnitTests/BankTransactionUnitTest.php index 99aece47..6c82268b 100644 --- a/tests/UnitTests/BankTransactionUnitTest.php +++ b/tests/UnitTests/BankTransactionUnitTest.php @@ -2,7 +2,6 @@ namespace PhpTwinfield\UnitTests; use InvalidArgumentException; -use Money\Currency; use Money\Money; use PhpTwinfield\BankTransaction; use PhpTwinfield\BankTransactionLine; @@ -23,46 +22,46 @@ protected function setUp() public function testSetStartValue() { - $this->bankTransaction->setStartvalue(Money::EUR(100)); + $this->bankTransaction->setStartValue(Money::EUR(100)); - $this->assertEquals(new Currency('EUR'), $this->bankTransaction->getCurrency()); - $this->assertEquals(Money::EUR(100), $this->bankTransaction->getStartvalue()); - $this->assertEquals(Money::EUR(100), $this->bankTransaction->getClosevalue()); + $this->assertEquals('EUR', $this->bankTransaction->getCurrencyToString()); + $this->assertEquals(Money::EUR(100), $this->bankTransaction->getStartValue()); + $this->assertEquals(Money::EUR(100), $this->bankTransaction->getCloseValue()); } public function testSetCurrencyWithoutStartValue() { - $this->bankTransaction->setCurrency(new Currency('EUR')); - $this->assertEquals(new Currency('EUR'), $this->bankTransaction->getCurrency()); + $this->bankTransaction->setCurrencyFromString('EUR'); + $this->assertEquals('EUR', $this->bankTransaction->getCurrencyToString()); } public function testSetCurrencyWithZeroStartValue() { $this->bankTransaction->setStartvalue(Money::EUR(0)); - $this->bankTransaction->setCurrency(new Currency('EUR')); + $this->bankTransaction->setCurrencyFromString('EUR'); - $this->assertEquals(new Currency('EUR'), $this->bankTransaction->getCurrency()); + $this->assertEquals('EUR', $this->bankTransaction->getCurrencyToString()); } public function testSetCurrencyWithStartValue() { $this->expectException(InvalidArgumentException::class); - $this->bankTransaction->setStartvalue(Money::EUR(100)); - $this->bankTransaction->setCurrency(new Currency('EUR')); + $this->bankTransaction->setStartValue(Money::EUR(100)); + $this->bankTransaction->setCurrencyFromString('EUR'); } public function testAddLineWithWrongTransactionLine() { $this->expectException(InvalidArgumentException::class); - $this->bankTransaction->setStartvalue(Money::EUR(100)); + $this->bankTransaction->setStartValue(Money::EUR(100)); $this->bankTransaction->addLine(new SalesTransactionLine()); } public function testAddLineUpdatesCloseValue() { - $this->bankTransaction->setStartvalue(Money::EUR(100)); + $this->bankTransaction->setStartValue(Money::EUR(100)); $totalLine = new BankTransactionLine(); $totalLine @@ -83,6 +82,6 @@ public function testAddLineUpdatesCloseValue() $this->bankTransaction->addLine($detailLine1); $this->bankTransaction->addLine($detailLine2); - $this->assertEquals(Money::EUR(200), $this->bankTransaction->getClosevalue()); + $this->assertEquals(Money::EUR(200), $this->bankTransaction->getCloseValue()); } } diff --git a/tests/UnitTests/CashTransactionLineUnitTest.php b/tests/UnitTests/CashTransactionLineUnitTest.php index 1e10ce41..e9e8ecfa 100644 --- a/tests/UnitTests/CashTransactionLineUnitTest.php +++ b/tests/UnitTests/CashTransactionLineUnitTest.php @@ -7,6 +7,7 @@ use PhpTwinfield\CashTransaction; use PhpTwinfield\CashTransactionLine; use PhpTwinfield\Enums\LineType; +use PhpTwinfield\Enums\MatchStatus; use PhpTwinfield\SalesTransaction; class CashTransactionLineUnitTest extends \PHPUnit\Framework\TestCase @@ -83,8 +84,8 @@ public function testSetMatchStatus() { $this->line->setLineType(LineType::DETAIL()); - $this->assertEquals($this->line, $this->line->setMatchStatus(CashTransactionLine::MATCHSTATUS_MATCHED), 'Fluid interface is expected'); - $this->assertSame(CashTransactionLine::MATCHSTATUS_MATCHED, $this->line->getMatchStatus()); + $this->assertEquals($this->line, $this->line->setMatchStatus(MatchStatus::MATCHED()), 'Fluid interface is expected'); + $this->assertSame(MatchStatus::MATCHED(), $this->line->getMatchStatus()); } public function testCanNotSetMatchStatusOtherThanNotMatchableIfLineTypeIsNotDetail() @@ -92,7 +93,7 @@ public function testCanNotSetMatchStatusOtherThanNotMatchableIfLineTypeIsNotDeta $this->expectExceptionMessage('Invalid match status \'matched\' for line class PhpTwinfield\CashTransactionLine and type \'vat\'.'); $this->line->setLineType(LineType::VAT()); - $this->line->setMatchStatus(CashTransactionLine::MATCHSTATUS_MATCHED); + $this->line->setMatchStatus(MatchStatus::MATCHED()); } public function testSetMatchLevel() diff --git a/tests/UnitTests/CashTransactionUnitTest.php b/tests/UnitTests/CashTransactionUnitTest.php index a3b5dcc3..b07f4169 100644 --- a/tests/UnitTests/CashTransactionUnitTest.php +++ b/tests/UnitTests/CashTransactionUnitTest.php @@ -2,7 +2,6 @@ namespace PhpTwinfield\UnitTests; use InvalidArgumentException; -use Money\Currency; use Money\Money; use PhpTwinfield\CashTransaction; use PhpTwinfield\CashTransactionLine; @@ -23,46 +22,46 @@ protected function setUp() public function testSetStartValue() { - $this->cashTransaction->setStartvalue(Money::EUR(100)); + $this->cashTransaction->setStartValue(Money::EUR(100)); - $this->assertEquals(new Currency('EUR'), $this->cashTransaction->getCurrency()); - $this->assertEquals(Money::EUR(100), $this->cashTransaction->getStartvalue()); - $this->assertEquals(Money::EUR(100), $this->cashTransaction->getClosevalue()); + $this->assertEquals('EUR', $this->cashTransaction->getCurrencyToString()); + $this->assertEquals(Money::EUR(100), $this->cashTransaction->getStartValue()); + $this->assertEquals(Money::EUR(100), $this->cashTransaction->getCloseValue()); } public function testSetCurrencyWithoutStartValue() { - $this->cashTransaction->setCurrency(new Currency('EUR')); - $this->assertEquals(new Currency('EUR'), $this->cashTransaction->getCurrency()); + $this->cashTransaction->setCurrencyFromString('EUR'); + $this->assertEquals('EUR', $this->cashTransaction->getCurrencyToString()); } public function testSetCurrencyWithZeroStartValue() { $this->cashTransaction->setStartvalue(Money::EUR(0)); - $this->cashTransaction->setCurrency(new Currency('EUR')); + $this->cashTransaction->setCurrencyFromString('EUR'); - $this->assertEquals(new Currency('EUR'), $this->cashTransaction->getCurrency()); + $this->assertEquals('EUR', $this->cashTransaction->getCurrencyToString()); } public function testSetCurrencyWithStartValue() { $this->expectException(InvalidArgumentException::class); - $this->cashTransaction->setStartvalue(Money::EUR(100)); - $this->cashTransaction->setCurrency(new Currency('EUR')); + $this->cashTransaction->setStartValue(Money::EUR(100)); + $this->cashTransaction->setCurrencyFromString('EUR'); } public function testAddLineWithWrongTransactionLine() { $this->expectException(InvalidArgumentException::class); - $this->cashTransaction->setStartvalue(Money::EUR(100)); + $this->cashTransaction->setStartValue(Money::EUR(100)); $this->cashTransaction->addLine(new SalesTransactionLine()); } public function testAddLineUpdatesCloseValue() { - $this->cashTransaction->setStartvalue(Money::EUR(100)); + $this->cashTransaction->setStartValue(Money::EUR(100)); $totalLine = new CashTransactionLine(); $totalLine @@ -83,6 +82,6 @@ public function testAddLineUpdatesCloseValue() $this->cashTransaction->addLine($detailLine1); $this->cashTransaction->addLine($detailLine2); - $this->assertEquals(Money::EUR(200), $this->cashTransaction->getClosevalue()); + $this->assertEquals(Money::EUR(200), $this->cashTransaction->getCloseValue()); } -} \ No newline at end of file +} diff --git a/tests/UnitTests/DomDocuments/ElectronicBankStatementDocumentUnitTest.php b/tests/UnitTests/DomDocuments/ElectronicBankStatementDocumentUnitTest.php index 09dd1606..bd4715af 100644 --- a/tests/UnitTests/DomDocuments/ElectronicBankStatementDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/ElectronicBankStatementDocumentUnitTest.php @@ -13,9 +13,9 @@ public function testDocumentationExampleCreatedSuccessfully() { $statement = new ElectronicBankStatement(); $statement->setIban("NL91ABNA0417164300"); - $statement->setStartvalue(Money::EUR(768)); + $statement->setStartValue(Money::EUR(768)); $statement->setDate(new \DateTimeImmutable("2013-11-08")); - $statement->setStatementnumber(2); + $statement->setStatementNumber(2); $transaction1 = new ElectronicBankStatementTransaction(); $transaction1->setType("N100"); @@ -66,8 +66,8 @@ public function testImportDuplicateIsSet() $statement = new ElectronicBankStatement(); $statement->setImportDuplicate(true); $statement->setDate(new \DateTimeImmutable("2017-11-30")); - $statement->setStartvalue(Money::EUR(0)); - $statement->setStatementnumber(236); + $statement->setStartValue(Money::EUR(0)); + $statement->setStatementNumber(236); $domdocument = new ElectronicBankStatementDocument(); $domdocument->addStatement($statement); @@ -96,8 +96,8 @@ public function testNegativeBalanceIsPossible() $statement = new ElectronicBankStatement(); $statement->setImportDuplicate(true); $statement->setDate(new \DateTimeImmutable("2017-11-30")); - $statement->setStartvalue(Money::EUR(-1)); - $statement->setStatementnumber(237); + $statement->setStartValue(Money::EUR(-1)); + $statement->setStatementNumber(237); $domdocument = new ElectronicBankStatementDocument(); $domdocument->addStatement($statement); diff --git a/tests/UnitTests/ElectronicBankStatementUnitTest.php b/tests/UnitTests/ElectronicBankStatementUnitTest.php index df0e8bab..0f4c8905 100644 --- a/tests/UnitTests/ElectronicBankStatementUnitTest.php +++ b/tests/UnitTests/ElectronicBankStatementUnitTest.php @@ -2,7 +2,6 @@ namespace PhpTwinfield\UnitTests; -use Money\Currency; use Money\Money; use PhpTwinfield\ElectronicBankStatement; use PHPUnit\Framework\TestCase; @@ -15,7 +14,7 @@ class ElectronicBankStatementUnitTest extends TestCase public function testCanSetCurrencyManually() { $ebs = new ElectronicBankStatement(); - $ebs->setCurrency(new Currency("HUF")); + $ebs->setCurrencyFromString("HUF"); $this->assertEquals("HUF", $ebs->getCurrency()); } @@ -26,8 +25,8 @@ public function testCanSetCurrencyManually() public function testCannotChangeCurrencyOnceValueIsSet() { $ebs = new ElectronicBankStatement(); - $ebs->setStartvalue(Money::GBP(1)); + $ebs->setStartValue(Money::GBP(1)); - $ebs->setCurrency(new Currency("EUR")); + $ebs->setCurrencyFromString("EUR"); } } diff --git a/tests/UnitTests/Transactions/TransactionLineFields/ValueFieldsUnitTest.php b/tests/UnitTests/Transactions/TransactionLineFields/ValueFieldsUnitTest.php index 6ff22630..9f32d6f7 100644 --- a/tests/UnitTests/Transactions/TransactionLineFields/ValueFieldsUnitTest.php +++ b/tests/UnitTests/Transactions/TransactionLineFields/ValueFieldsUnitTest.php @@ -3,7 +3,7 @@ use Money\Money; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\LineType; -use PhpTwinfield\Transactions\TransactionLineFields\ValueFields; +use PhpTwinfield\Fields\Transaction\TransactionLine\ValueFields; use PHPUnit\Framework\TestCase; /** diff --git a/usage.md b/usage.md index 848e1c2d..9c4d130d 100644 --- a/usage.md +++ b/usage.md @@ -1,9 +1,9 @@ -## Usage +# Usage -### Authentication +## Authentication You need to set up a `\PhpTwinfield\Secure\AuthenticatedConnection` class with your credentials. -#### Session Login +### Session Login **:warning: Note that Twinfield has stated that session login is deprecated and will be removed. End of life date will be announced later. See https://c3.twinfield.com/webservices/documentation/#/ApiReference/Authentication/WebServices** When using basic username and password authentication, the `\PhpTwinfield\Secure\WebservicesAuthentication` class should be used, as follows: @@ -12,10 +12,10 @@ When using basic username and password authentication, the `\PhpTwinfield\Secure $connection = new Secure\WebservicesAuthentication("username", "password", "organization"); ``` -#### OAuth2 +### OAuth2 In order to use OAuth2 to authenticate with Twinfield, one should use the `\PhpTwinfield\Secure\Provider\OAuthProvider` to retrieve an `\League\OAuth2\Client\Token\AccessToken` object, and extract the refresh token from this object. Furthermore, it is required to set up a default `\PhpTwinfield\Office`, that will be used during requests to Twinfield. **Please note:** when a different office is specified when sending a request through one of the `ApiConnectors`, this Office will override the default. -##### Request a client ID/Secret from Twinfield +#### Request a client ID/Secret from Twinfield Go to the [Twinfield web site](https://www.twinfield.nl/openid-connect-request/) in order to register your OpenID Connect / OAuth 2.0 client and get your Client ID and Secret. Fill in your personal information en pick the following: * Flow: Authorization Code * Consent: Your choice @@ -24,9 +24,9 @@ Go to the [Twinfield web site](https://www.twinfield.nl/openid-connect-request/) * Post logout URL: Your choice, can be left blank * Add more post logout URL's?: Your choice -##### Grant Authorization and retrieve initial Access Token -See [Authorization Example](examples/Authorization.php) for a complete example -Also see [RenewAuthorization Example](examples/RenewAuthorization.php) for a complete example on how/when to request users to renew their authorization +#### Grant Authorization and retrieve initial Access Token +See [Authorization Example](examples/Authorization.php) for a complete example. +Also see [RenewAuthorization Example](examples/RenewAuthorization.php) for a complete example on how/when to request users to renew their authorization. On loading a page containing the following code the user will be redirected to the Twinfield Login page. After successful login and optionally consent (see above) the user will be redirected back to the page at which point the Access Token and Refresh Token can be retrieved. @@ -102,8 +102,8 @@ if (!isset($_GET['code'])) { } ``` -##### Optionally: Store a valid access token and cluster through a scheduled task/cron job running in the background -See [RenewAccessToken Example](examples/RenewAccessToken.php) for a complete example +#### Optionally: Store a valid access token and cluster through a scheduled task/cron job running in the background +See [RenewAccessToken Example](examples/RenewAccessToken.php) for a complete example. Running the following code every 60 minutes (or a bit less as Access Tokens are valid for exactly 60 minutes) will reduce connection time when working with the Api (by about 2 seconds). It will also reduce connection load on Twinfield when making more than 20-30 connections/day. @@ -135,8 +135,8 @@ if ($validationResult !== false) { } ``` -##### Connection -See [Connection Example](examples/Connection.php) for a complete example +#### Connection +See [Connection Example](examples/Connection.php) for a complete example. Using the stored Refresh Token and optionally Access Token/Cluster, we can create an instance of the `\PhpTwinfield\Secure\OpenIdConnectAuthentication` class, as follows: @@ -162,8 +162,8 @@ if ($accessTokenStorage['access_expiry'] > time()) { } ``` -### Getting data from the API -See [Customer Example](examples/Customer.php) among others for a complete example +## Getting data from the API +See [Customer Example](examples/Customer.php) among others for a complete example. In order to communicate with the Twinfield API, you need to create an `ApiConnector` instance for the corresponding resource and use the `get()` or `list()` method. @@ -173,8 +173,6 @@ The `ApiConnector` takes a `Secure\AuthenticatedConnection` object: An example: ```php - -$connection = new Secure\WebservicesAuthentication("username", "password", "organization"); $customerApiConnector = new ApiConnectors\CustomerApiConnector($connection); // Get one customer. @@ -185,13 +183,13 @@ $customer = $customerApiConnector->get('1001', $office); $customer = $customerApiConnector->listAll($office); ``` -### Creating or updating objects -See [Customer Example](examples/Customer.php) among others for a complete example +## Creating or updating objects +See [Customer Example](examples/Customer.php) among others for a complete example. If you want to create or update a customer or any other object, it's just as easy: ```php -$customer_factory = new ApiConnectors\CustomerApiConnector($connection); +$customerApiConnector = new ApiConnectors\CustomerApiConnector($connection); // First, create the objects you want to send. $customer = new Customer(); @@ -201,8 +199,8 @@ $customer ->setOffice($office) ->setEBilling(false); -$customer_address = new CustomerAddress(); -$customer_address +$customerAddress = new CustomerAddress(); +$customerAddress ->setType('invoice') ->setDefault(false) ->setPostcode('1212 AB') @@ -211,46 +209,46 @@ $customer_address ->setTelephone('010-12345') ->setFax('010-1234') ->setEmail('johndoe@example.com'); -$customer->addAddress($customer_address); +$customer->addAddress($customerAddress); // And secondly, send it to Twinfield. -$customer_factory->send($customer); +$customerApiConnector->send($customer); ``` You can also send multiple objects in one batch, chunking is handled automatically. -### Browse data -See [BrowseData Example](examples/BrowseData.php) for a complete example +## Browse data +See [BrowseData Example](examples/BrowseData.php) for a complete example. In order to get financial data out of Twinfield like general ledger transactions, sales invoices, and so on, you can use the the browse data functionality. More information about the browse data functionality in Twinfield can be found in the [documentation](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Request/BrowseData). -#### Browse definition +### Browse definition You can retrieve the browse definition of a browse code as follows. You don't need to retrieve the browse definition for getting the browse data. It's only for viewing the browse definition of a browse code to know exactly which columns are available. ```php -$connector = new BrowseDataApiConnector($connection); -$browseDefinition = $connector->getBrowseDefinition('000'); +$browseDataApiConnector = new BrowseDataApiConnector($connection); +$browseDefinition = $browseDataApiConnector->getBrowseDefinition('000'); ``` -#### Browse fields +### Browse fields You can retrieve the browse fields as follows. You don't need to retrieve the browse fields for getting the browse data. It's only for viewing the definitions of all browse fields so you now what you can expect when retrieving browse data. ```php -$connector = new BrowseDataApiConnector($connection); -$browseFields = $connector->getBrowseFields(); +$browseDataApiConnector = new BrowseDataApiConnector($connection); +$browseFields = $browseDataApiConnector->getBrowseFields(); ``` -#### Browse data +### Browse data You can retrieve browse data of a browse code as follows. ```php -$connector = new BrowseDataApiConnector($connection); +$browseDataApiConnector = new BrowseDataApiConnector($connection); // First, create the columns that you want to retrieve (see the browse definition for which columns are available) $columns[] = (new BrowseColumn()) @@ -305,5 +303,5 @@ $columns[] = (new BrowseColumn()) $sortFields[] = new BrowseSortField('fin.trs.head.code'); // Get the browse data -$browseData = $connector->getBrowseData('000', $columns, $sortFields); +$browseData = $browseDataApiConnector->getBrowseData('000', $columns, $sortFields); ``` \ No newline at end of file From 23c35889d0161b4546fbdcb779c8707991dd48cb Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 20 May 2019 10:45:36 +0200 Subject: [PATCH 217/388] Upload --- src/Mappers/BaseMapper.php | 2 +- src/SalesTransactionLine.php | 2 +- tests/IntegrationTests/BankTransactionIntegrationTest.php | 4 ++-- tests/IntegrationTests/BrowseDataApiConnectorTest.php | 2 +- tests/IntegrationTests/CashTransactionIntegrationTest.php | 6 +++--- tests/UnitTests/BankTransactionLineUnitTest.php | 8 ++++---- tests/UnitTests/CashTransactionLineUnitTest.php | 8 ++++---- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index 9f42075a..d4b73f4d 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -10,7 +10,7 @@ abstract class BaseMapper { - private static function checkForMessage($object, \DOMElement $element): void + protected static function checkForMessage($object, \DOMElement $element): void { if ($element->hasAttribute('msg')) { $message = new Message(); diff --git a/src/SalesTransactionLine.php b/src/SalesTransactionLine.php index 3fc534a9..dbb2188b 100644 --- a/src/SalesTransactionLine.php +++ b/src/SalesTransactionLine.php @@ -117,7 +117,7 @@ public function setDim2(?Dummy $dim2): parent */ public function setDim3(?Dummy $dim3): parent { - if ($dim3 !== null && ($this->getLineType()->equals(LineType::TOTAL()) || $this->getLineType()->equals(LineType::VAT())) { + if ($dim3 !== null && ($this->getLineType()->equals(LineType::TOTAL()) || $this->getLineType()->equals(LineType::VAT()))) { throw Exception::invalidDimensionForLineType(3, $this); } diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index f4113615..0d26aa0e 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -64,7 +64,7 @@ public function testGetBankTransactionWorks() $this->assertNull($bankTransaction->getFreetext1()); $this->assertNull($bankTransaction->getFreetext2()); $this->assertNull($bankTransaction->getFreetext3()); - $this->assertSame(4, $bankTransaction->getStatementnumber()); + $this->assertSame(4, $bankTransaction->getStatementNumber()); $this->assertTrue(Money::EUR(97401)->equals($bankTransaction->getStartValue())); $this->assertTrue(Money::EUR(140956)->equals($bankTransaction->getCloseValue())); @@ -130,7 +130,7 @@ public function testSendBankTransactionWorks() ->setCode('BNK') ->setCurrencyFromString('EUR') ->setDate(new DateTimeImmutable('2013-11-04')) - ->setStatementnumber(4) + ->setStatementNumber(4) ->setStartValue(Money::EUR(97401)); $totalLine = new BankTransactionLine(); diff --git a/tests/IntegrationTests/BrowseDataApiConnectorTest.php b/tests/IntegrationTests/BrowseDataApiConnectorTest.php index ce12c2f3..490c46e8 100644 --- a/tests/IntegrationTests/BrowseDataApiConnectorTest.php +++ b/tests/IntegrationTests/BrowseDataApiConnectorTest.php @@ -37,7 +37,7 @@ public function testGetBrowseDefinition() $this->assertInstanceOf(BrowseDefinition::class, $browseDefinition); - $this->assertEquals('001', $browseDefinition->getOfficeToCode()); + $this->assertEquals('001', $browseDefinition->getOfficeToString()); $this->assertEquals('000', $browseDefinition->getCode()); $this->assertEquals('General ledger transactions', $browseDefinition->getName()); $this->assertEquals('General ledger transactions', $browseDefinition->getShortName()); diff --git a/tests/IntegrationTests/CashTransactionIntegrationTest.php b/tests/IntegrationTests/CashTransactionIntegrationTest.php index 3b4b3123..d64d5885 100644 --- a/tests/IntegrationTests/CashTransactionIntegrationTest.php +++ b/tests/IntegrationTests/CashTransactionIntegrationTest.php @@ -66,7 +66,7 @@ public function testGetCashTransactionWorks() $this->assertNull($cashTransaction->getFreetext1()); $this->assertNull($cashTransaction->getFreetext2()); $this->assertNull($cashTransaction->getFreetext3()); - $this->assertSame(4, $cashTransaction->getStatementnumber()); + $this->assertSame(4, $cashTransaction->getStatementNumber()); $this->assertTrue(Money::EUR(97401)->equals($cashTransaction->getStartValue())); $this->assertTrue(Money::EUR(140956)->equals($cashTransaction->getCloseValue())); @@ -132,8 +132,8 @@ public function testSendCashTransactionWorks() ->setCode('CASH') ->setCurrencyFromString('EUR') ->setDate(new DateTimeImmutable('2013-11-04')) - ->setStatementnumber(4) - ->setStartvalue(Money::EUR(97401)); + ->setStatementNumber(4) + ->setStartValue(Money::EUR(97401)); $totalLine = new CashTransactionLine(); $totalLine diff --git a/tests/UnitTests/BankTransactionLineUnitTest.php b/tests/UnitTests/BankTransactionLineUnitTest.php index c559f4b7..3f775b38 100644 --- a/tests/UnitTests/BankTransactionLineUnitTest.php +++ b/tests/UnitTests/BankTransactionLineUnitTest.php @@ -52,8 +52,8 @@ public function testSetDim2() { $this->line->setLineType(LineType::DETAIL()); - $this->assertEquals($this->line, $this->line->setDim2('test'), 'Fluid interface is expected'); - $this->assertSame('test', $this->line->getDim2()); + $this->assertEquals($this->line, $this->line->setDim2FromString('test'), 'Fluid interface is expected'); + $this->assertSame('test', $this->line->getDim2ToString()); } public function testCanNotSetDim2IfLineTypeIsNotDetail() @@ -68,8 +68,8 @@ public function testSetDim3() { $this->line->setLineType(LineType::DETAIL()); - $this->assertEquals($this->line, $this->line->setDim3('test'), 'Fluid interface is expected'); - $this->assertSame('test', $this->line->getDim3()); + $this->assertEquals($this->line, $this->line->setDim3FromString('test'), 'Fluid interface is expected'); + $this->assertSame('test', $this->line->getDim3ToString()); } public function testCanNotSetDim3IfLineTypeIsNotDetail() diff --git a/tests/UnitTests/CashTransactionLineUnitTest.php b/tests/UnitTests/CashTransactionLineUnitTest.php index e9e8ecfa..52343d40 100644 --- a/tests/UnitTests/CashTransactionLineUnitTest.php +++ b/tests/UnitTests/CashTransactionLineUnitTest.php @@ -52,8 +52,8 @@ public function testSetDim2() { $this->line->setLineType(LineType::DETAIL()); - $this->assertEquals($this->line, $this->line->setDim2('test'), 'Fluid interface is expected'); - $this->assertSame('test', $this->line->getDim2()); + $this->assertEquals($this->line, $this->line->setDim2FromString('test'), 'Fluid interface is expected'); + $this->assertSame('test', $this->line->getDim2ToString()); } public function testCanNotSetDim2IfLineTypeIsNotDetail() @@ -68,8 +68,8 @@ public function testSetDim3() { $this->line->setLineType(LineType::DETAIL()); - $this->assertEquals($this->line, $this->line->setDim3('test'), 'Fluid interface is expected'); - $this->assertSame('test', $this->line->getDim3()); + $this->assertEquals($this->line, $this->line->setDim3FromString('test'), 'Fluid interface is expected'); + $this->assertSame('test', $this->line->getDim3ToString()); } public function testCanNotSetDim3IfLineTypeIsNotDetail() From a9a47c1e74fa26c16ce78c7ef7e6f9648b829283 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 20 May 2019 10:52:47 +0200 Subject: [PATCH 218/388] Update LinesField.php --- src/Fields/Transaction/LinesField.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Fields/Transaction/LinesField.php b/src/Fields/Transaction/LinesField.php index e4ca3fc0..4914c6c4 100644 --- a/src/Fields/Transaction/LinesField.php +++ b/src/Fields/Transaction/LinesField.php @@ -2,6 +2,7 @@ namespace PhpTwinfield\Fields\Transaction; +use PhpTwinfield\BaseTransaction; use PhpTwinfield\Enums\LineType; use Webmozart\Assert\Assert; @@ -70,10 +71,10 @@ private function getVatLines(): array } /** - * @param $line + * @param BaseTransaction $line * @return $this */ - public function addLine($line) + public function addLine(BaseTransaction $line) { Assert::isInstanceOf($line, $this->getLineClassName()); From 511901ea150ee031e888798b1a63af33872e051b Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 20 May 2019 11:02:48 +0200 Subject: [PATCH 219/388] Upload --- src/BankTransactionLine.php | 9 ++++----- src/CashTransactionLine.php | 9 ++++----- src/JournalTransactionLine.php | 9 ++++----- src/PurchaseTransactionLine.php | 5 ++--- src/SalesTransactionLine.php | 9 ++++----- tests/IntegrationTests/InvoiceIntegrationTest.php | 6 +++--- .../JournalTransactionIntegrationTest.php | 3 --- 7 files changed, 21 insertions(+), 29 deletions(-) diff --git a/src/BankTransactionLine.php b/src/BankTransactionLine.php index 4de4abe7..97f95027 100644 --- a/src/BankTransactionLine.php +++ b/src/BankTransactionLine.php @@ -3,7 +3,6 @@ namespace PhpTwinfield; use Money\Money; -use PhpTwinfield\Dummy; use PhpTwinfield\Enums\LineType; use PhpTwinfield\Enums\PerformanceType; use PhpTwinfield\Fields\PerformanceDateField; @@ -91,11 +90,11 @@ public function setCurrencyDate(?\DateTimeInterface $currencyDate): self * * If line type = vat empty. * - * @param Dummy|null $dim2 + * @param $dim2 * @return $this * @throws Exception */ - public function setDim2(?Dummy $dim2): parent + public function setDim2($dim2): parent { if ($dim2 !== null && ($this->getLineType()->equals(LineType::VAT()) || $this->getLineType()->equals(LineType::TOTAL()))) { throw Exception::invalidDimensionForLineType(2, $this); @@ -111,11 +110,11 @@ public function setDim2(?Dummy $dim2): parent * * If line type = vat empty. * - * @param Dummy|null $dim3 + * @param $dim3 * @return $this * @throws Exception */ - public function setDim3(?Dummy $dim3): parent + public function setDim3($dim3): parent { if ($dim3 !== null && ($this->getLineType()->equals(LineType::VAT()) || $this->getLineType()->equals(LineType::TOTAL()))) { throw Exception::invalidDimensionForLineType(3, $this); diff --git a/src/CashTransactionLine.php b/src/CashTransactionLine.php index 43ecfa28..4d08cd27 100644 --- a/src/CashTransactionLine.php +++ b/src/CashTransactionLine.php @@ -3,7 +3,6 @@ namespace PhpTwinfield; use Money\Money; -use PhpTwinfield\Dummy; use PhpTwinfield\Enums\LineType; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PerformanceTypeField; @@ -90,11 +89,11 @@ public function setCurrencyDate(?\DateTimeInterface $currencyDate): self * * If line type = vat empty. * - * @param Dummy|null $dim2 + * @param $dim2 * @return $this * @throws Exception */ - public function setDim2(?Dummy $dim2): parent + public function setDim2($dim2): parent { if ($dim2 !== null && ($this->getLineType()->equals(LineType::VAT()) || $this->getLineType()->equals(LineType::TOTAL()))) { throw Exception::invalidDimensionForLineType(2, $this); @@ -110,11 +109,11 @@ public function setDim2(?Dummy $dim2): parent * * If line type = vat empty. * - * @param Dummy|null $dim3 + * @param $dim3 * @return $this * @throws Exception */ - public function setDim3(?Dummy $dim3): parent + public function setDim3($dim3): parent { if ($dim3 !== null && ($this->getLineType()->equals(LineType::VAT()) || $this->getLineType()->equals(LineType::TOTAL()))) { throw Exception::invalidDimensionForLineType(3, $this); diff --git a/src/JournalTransactionLine.php b/src/JournalTransactionLine.php index b72f5d95..c3d254a5 100644 --- a/src/JournalTransactionLine.php +++ b/src/JournalTransactionLine.php @@ -3,7 +3,6 @@ namespace PhpTwinfield; use Money\Money; -use PhpTwinfield\Dummy; use PhpTwinfield\Enums\LineType; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PerformanceTypeField; @@ -101,11 +100,11 @@ public function setCurrencyDate(?\DateTimeInterface $currencyDate): self * * If line type = vat empty. * - * @param Dummy|null $dim2 + * @param $dim2 * @return $this * @throws Exception */ - public function setDim2(?Dummy $dim2): parent + public function setDim2($dim2): parent { if ($dim2 !== null && $this->getLineType()->equals(LineType::VAT())) { throw Exception::invalidDimensionForLineType(2, $this); @@ -119,11 +118,11 @@ public function setDim2(?Dummy $dim2): parent * * If line type = vat empty. * - * @param Dummy|null $dim3 + * @param $dim3 * @return $this * @throws Exception */ - public function setDim3(?Dummy $dim3): parent + public function setDim3($dim3): parent { if ($dim3 !== null && $this->getLineType()->equals(LineType::VAT())) { throw Exception::invalidDimensionForLineType(3, $this); diff --git a/src/PurchaseTransactionLine.php b/src/PurchaseTransactionLine.php index 97e22fc1..f90cd888 100644 --- a/src/PurchaseTransactionLine.php +++ b/src/PurchaseTransactionLine.php @@ -3,7 +3,6 @@ namespace PhpTwinfield; use Money\Money; -use PhpTwinfield\Dummy; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\LineType; use PhpTwinfield\Fields\Transaction\TransactionLine\BaselineField; @@ -86,11 +85,11 @@ public function setBaseValueOpen(?Money $baseValueOpen): parent * * If line type = vat the project or asset or empty. * - * @param Dummy|null $dim3 + * @param $dim3 * @return $this * @throws Exception */ - public function setDim3(?Dummy $dim3): parent + public function setDim3($dim3): parent { if ($dim3 !== null && $this->getLineType()->equals(LineType::TOTAL())) { throw Exception::invalidDimensionForLineType(3, $this); diff --git a/src/SalesTransactionLine.php b/src/SalesTransactionLine.php index dbb2188b..eaf9b437 100644 --- a/src/SalesTransactionLine.php +++ b/src/SalesTransactionLine.php @@ -3,7 +3,6 @@ namespace PhpTwinfield; use Money\Money; -use PhpTwinfield\Dummy; use PhpTwinfield\Enums\LineType; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PerformanceTypeField; @@ -91,11 +90,11 @@ public function setBaseValueOpen(?Money $baseValueOpen): parent * * If line type = vat empty. * - * @param Dummy|null $dim2 + * @param $dim2 * @return $this * @throws Exception */ - public function setDim2(?Dummy $dim2): parent + public function setDim2($dim2): parent { if ($dim2 !== null && $this->getLineType()->equals(LineType::VAT())) { throw Exception::invalidDimensionForLineType(2, $this); @@ -111,11 +110,11 @@ public function setDim2(?Dummy $dim2): parent * * If line type = empty. * - * @param Dummy|null $dim3 + * @param $dim3 * @return $this * @throws Exception */ - public function setDim3(?Dummy $dim3): parent + public function setDim3($dim3): parent { if ($dim3 !== null && ($this->getLineType()->equals(LineType::TOTAL()) || $this->getLineType()->equals(LineType::VAT()))) { throw Exception::invalidDimensionForLineType(3, $this); diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index cb100051..cfc357e5 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -66,7 +66,7 @@ public function testGetConceptInvoiceWorks() $this->assertInstanceOf(Invoice::class, $invoice); $this->assertEquals(Office::fromCode("11024"), $invoice->getOffice()); $this->assertSame('FACTUUR', $invoice->getInvoiceTypeToString()); - $this->assertSame(5, $invoice->getInvoiceNumber()); + $this->assertSame('5', $invoice->getInvoiceNumber()); $this->assertSame('20120831', $invoice->getInvoiceDateToString()); $this->assertSame('BNK', $invoice->getBankToString()); $this->assertSame(1, $invoice->getInvoiceAddressNumber()); @@ -134,7 +134,7 @@ public function testGetFinalInvoiceWorks() $this->assertInstanceOf(Invoice::class, $invoice); $this->assertEquals(Office::fromCode("11024"), $invoice->getOffice()); $this->assertSame('FACTUUR', $invoice->getInvoiceTypeToString()); - $this->assertSame(5, $invoice->getInvoiceNumber()); + $this->assertSame('5', $invoice->getInvoiceNumber()); $this->assertSame('20120831', $invoice->getInvoiceDateToString()); $this->assertSame('BNK', $invoice->getBankToString()); $this->assertSame(1, $invoice->getInvoiceAddressNumber()); @@ -195,7 +195,7 @@ public function testSendInvoiceWorks() $invoice = new Invoice(); $invoice->setOffice(Office::fromCode('11024')); $invoice->setInvoiceTypeFromString('FACTUUR'); - $invoice->setInvoiceNumber(5); + $invoice->setInvoiceNumber('5'); $invoice->setInvoiceDateFromString('20120831'); $invoice->setBankFromString('BNK'); $invoice->setInvoiceAddressNumber(1); diff --git a/tests/IntegrationTests/JournalTransactionIntegrationTest.php b/tests/IntegrationTests/JournalTransactionIntegrationTest.php index cb9d0312..c5ac1399 100644 --- a/tests/IntegrationTests/JournalTransactionIntegrationTest.php +++ b/tests/IntegrationTests/JournalTransactionIntegrationTest.php @@ -90,7 +90,6 @@ public function testGetJournalTransactionWorks() $this->assertNull($detailLine1->getPerformanceCountry()); $this->assertNull($detailLine1->getPerformanceVatNumber()); $this->assertNull($detailLine1->getPerformanceDate()); - $this->assertNull($detailLine1->getInvoiceNumber()); $this->assertEquals(LineType::DETAIL(), $detailLine2->getLineType()); $this->assertSame(2, $detailLine2->getId()); @@ -112,7 +111,6 @@ public function testGetJournalTransactionWorks() $this->assertNull($detailLine2->getPerformanceCountry()); $this->assertNull($detailLine2->getPerformanceVatNumber()); $this->assertNull($detailLine2->getPerformanceDate()); - $this->assertSame('11001770', $detailLine2->getInvoiceNumber()); } public function testSendJournalTransactionWorks() @@ -139,7 +137,6 @@ public function testSendJournalTransactionWorks() ->setDim1FromString('1300') ->setDim2FromString('1000') ->setValue(Money::EUR(43555)) - ->setInvoiceNumber('11001770') ->setDescription('Invoice paid'); $journalTransaction From 1b895affd84fc5f2992fd8dc31ba061270caeb98 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 20 May 2019 11:15:09 +0200 Subject: [PATCH 220/388] Upload --- src/BankTransactionLine.php | 4 ++-- src/BaseTransactionLine.php | 6 +++--- src/CashTransactionLine.php | 4 ++-- src/Enums/MatchStatus.php | 2 ++ src/JournalTransaction.php | 12 ++++++++++++ src/JournalTransactionLine.php | 8 ++++---- src/PurchaseTransaction.php | 12 ++++++++++++ src/PurchaseTransactionLine.php | 4 ++-- src/SalesTransaction.php | 12 ++++++++++++ src/SalesTransactionLine.php | 4 ++-- 10 files changed, 53 insertions(+), 15 deletions(-) diff --git a/src/BankTransactionLine.php b/src/BankTransactionLine.php index 97f95027..471c0a3e 100644 --- a/src/BankTransactionLine.php +++ b/src/BankTransactionLine.php @@ -220,11 +220,11 @@ public function setPerformanceDate(?\DateTimeInterface $performanceDate): self /* * Relation of the transaction. Only if line type is detail. Read-only attribute. * - * @param string|null $relation + * @param int|null $relation * @return $this * @throws Exception */ - public function setRelation(?string $relation): parent + public function setRelation(?int $relation): parent { if ($relation !== null && !$this->getLineType()->equals(LineType::DETAIL())) { throw Exception::invalidRelationForLineType($relation, $this); diff --git a/src/BaseTransactionLine.php b/src/BaseTransactionLine.php index f35ed65a..3caf3b19 100644 --- a/src/BaseTransactionLine.php +++ b/src/BaseTransactionLine.php @@ -109,7 +109,7 @@ public function setVatBaseTurnover(?Money $vatBaseTurnover): self if (!$this->getLineType()->equals(LineType::VAT())) { throw Exception::invalidFieldForLineType('vatbaseturnover', $this); } - return parent::setVatBaseTurnover($vatBaseTurnover); + return $this; } /* @@ -155,7 +155,7 @@ public function setVatRepTurnover(?Money $vatRepTurnover): self if (!$this->getLineType()->equals(LineType::VAT())) { throw Exception::invalidFieldForLineType('vatrepturnover', $this); } - return parent::setVatRepTurnover($vatRepTurnover); + return $this; } /* @@ -186,7 +186,7 @@ public function setVatTurnover(?Money $vatTurnover): self if (!$this->getLineType()->equals(LineType::VAT())) { throw Exception::invalidFieldForLineType('vatturnover', $this); } - return parent::setVatTurnover($vatTurnover); + return $this; } /* diff --git a/src/CashTransactionLine.php b/src/CashTransactionLine.php index 4d08cd27..93265a7f 100644 --- a/src/CashTransactionLine.php +++ b/src/CashTransactionLine.php @@ -219,11 +219,11 @@ public function setPerformanceDate(?\DateTimeInterface $performanceDate): self /* * Relation of the transaction. Only if line type is detail. Read-only attribute. * - * @param string|null $relation + * @param int|null $relation * @return $this * @throws Exception */ - public function setRelation(?string $relation): parent + public function setRelation(?int $relation): parent { if ($relation !== null && !$this->getLineType()->equals(LineType::DETAIL())) { throw Exception::invalidRelationForLineType($relation, $this); diff --git a/src/Enums/MatchStatus.php b/src/Enums/MatchStatus.php index 1867dc5a..4711a518 100644 --- a/src/Enums/MatchStatus.php +++ b/src/Enums/MatchStatus.php @@ -8,6 +8,7 @@ * @method static MatchStatus AVAILABLE() * @method static MatchStatus EMPTY() * @method static MatchStatus MATCHABLE() + * @method static MatchStatus MATCHED() * @method static MatchStatus NOTMATCHABLE() * @method static MatchStatus PROPOSED() */ @@ -16,6 +17,7 @@ class MatchStatus extends Enum public const AVAILABLE = "available"; public const EMPTY = ""; public const MATCHABLE = "matchable"; + public const MATCHED = "matched"; public const NOTMATCHABLE = "notmatchable"; public const PROPOSED = "proposed"; } \ No newline at end of file diff --git a/src/JournalTransaction.php b/src/JournalTransaction.php index 9c762ceb..fd90132b 100644 --- a/src/JournalTransaction.php +++ b/src/JournalTransaction.php @@ -3,6 +3,7 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\Transaction\RegimeField; +use PhpTwinfield\JournalTransactionLine; /* * @link https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/JournalTransactions @@ -18,4 +19,15 @@ public function getLineClassName(): string { return JournalTransactionLine::class; } + + /* + * @param JournalTransactionLine $line + * @return $this + */ + public function addLine(JournalTransactionLine $line) + { + parent::addLine($line); + + return $this; + } } diff --git a/src/JournalTransactionLine.php b/src/JournalTransactionLine.php index c3d254a5..215743a2 100644 --- a/src/JournalTransactionLine.php +++ b/src/JournalTransactionLine.php @@ -160,11 +160,11 @@ protected function isIncomingTransactionType(): bool } /* - * @param LineType $lineType + * @param LineType|null $lineType * @return $this * @throws Exception */ - public function setLineType(LineType $lineType): parent + public function setLineType(?LineType $lineType): parent { // Only 'detail' and 'vat' are supported. if ($lineType->equals(LineType::TOTAL())) { @@ -257,11 +257,11 @@ public function setPerformanceDate(?\DateTimeInterface $performanceDate): self /* * Relation of the transaction. Only if line type is detail. Read-only attribute. * - * @param string|null $relation + * @param int|null $relation * @return $this * @throws Exception */ - public function setRelation(?string $relation): parent + public function setRelation(?int $relation): parent { if ($relation !== null && !$this->getLineType()->equals(LineType::DETAIL())) { throw Exception::invalidRelationForLineType($relation, $this); diff --git a/src/PurchaseTransaction.php b/src/PurchaseTransaction.php index 05f6d7fc..6cd8e1fe 100644 --- a/src/PurchaseTransaction.php +++ b/src/PurchaseTransaction.php @@ -6,6 +6,7 @@ use PhpTwinfield\Fields\Transaction\InvoiceNumberField; use PhpTwinfield\Fields\Transaction\InvoiceNumberRaiseWarningField; use PhpTwinfield\Fields\Transaction\PaymentReferenceField; +use PhpTwinfield\PurchaseTransactionLine; /* * @link https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions @@ -24,4 +25,15 @@ public function getLineClassName(): string { return PurchaseTransactionLine::class; } + + /* + * @param PurchaseTransactionLine $line + * @return $this + */ + public function addLine(PurchaseTransactionLine $line) + { + parent::addLine($line); + + return $this; + } } diff --git a/src/PurchaseTransactionLine.php b/src/PurchaseTransactionLine.php index f90cd888..b2047640 100644 --- a/src/PurchaseTransactionLine.php +++ b/src/PurchaseTransactionLine.php @@ -211,11 +211,11 @@ public function setPerformanceDate(?\DateTimeInterface $performanceDate): parent /* * Relation of the transaction. Only if line type is total. Read-only attribute. * - * @param string|null $relation + * @param int|null $relation * @return $this * @throws Exception */ - public function setRelation(?string $relation): parent + public function setRelation(?int $relation): parent { if ($relation !== null && !$this->getLineType()->equals(LineType::TOTAL())) { throw Exception::invalidRelationForLineType($relation, $this); diff --git a/src/SalesTransaction.php b/src/SalesTransaction.php index b1a547b4..cc270c41 100644 --- a/src/SalesTransaction.php +++ b/src/SalesTransaction.php @@ -7,6 +7,7 @@ use PhpTwinfield\Fields\Transaction\InvoiceNumberRaiseWarningField; use PhpTwinfield\Fields\Transaction\OriginReferenceField; use PhpTwinfield\Fields\Transaction\PaymentReferenceField; +use PhpTwinfield\SalesTransactionLine; /* * @link https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions @@ -26,4 +27,15 @@ public function getLineClassName(): string { return SalesTransactionLine::class; } + + /* + * @param SalesTransactionLine $line + * @return $this + */ + public function addLine(SalesTransactionLine $line) + { + parent::addLine($line); + + return $this; + } } diff --git a/src/SalesTransactionLine.php b/src/SalesTransactionLine.php index eaf9b437..cf856546 100644 --- a/src/SalesTransactionLine.php +++ b/src/SalesTransactionLine.php @@ -220,11 +220,11 @@ public function setPerformanceDate(?\DateTimeInterface $performanceDate): self /* * Relation of the transaction. Only if line type is total. Read-only attribute. * - * @param string|null $relation + * @param int|null $relation * @return $this * @throws Exception */ - public function setRelation(?string $relation): parent + public function setRelation(?int $relation): parent { if ($relation !== null && !$this->getLineType()->equals(LineType::TOTAL())) { throw Exception::invalidRelationForLineType($relation, $this); From d473a43fa954481250d8af39254cd06c1bab07fe Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 20 May 2019 11:24:23 +0200 Subject: [PATCH 221/388] Upload --- src/BankTransaction.php | 4 +- src/CashTransaction.php | 4 +- src/CashTransactionLine.php | 1 + src/Fields/Transaction/LinesField.php | 5 +- .../TransactionLine/ValueFields.php | 1 + src/JournalTransaction.php | 12 ---- src/JournalTransactionLine.php | 1 + src/PurchaseTransaction.php | 12 ---- src/PurchaseTransactionLine.php | 64 ------------------- src/SalesTransaction.php | 12 ---- src/SalesTransactionLine.php | 1 + 11 files changed, 10 insertions(+), 107 deletions(-) diff --git a/src/BankTransaction.php b/src/BankTransaction.php index f84a731f..278a2a38 100644 --- a/src/BankTransaction.php +++ b/src/BankTransaction.php @@ -33,10 +33,10 @@ public function getLineClassName(): string } /* - * @param BankTransactionLine $line + * @param $line * @return $this */ - public function addLine(BankTransactionLine $line) + public function addLine($line) { parent::addLine($line); diff --git a/src/CashTransaction.php b/src/CashTransaction.php index ba4f459f..472524c6 100644 --- a/src/CashTransaction.php +++ b/src/CashTransaction.php @@ -33,10 +33,10 @@ public function getLineClassName(): string } /* - * @param CashTransactionLine $line + * @param $line * @return $this */ - public function addLine(CashTransactionLine $line) + public function addLine($line) { parent::addLine($line); diff --git a/src/CashTransactionLine.php b/src/CashTransactionLine.php index 93265a7f..fe57bd13 100644 --- a/src/CashTransactionLine.php +++ b/src/CashTransactionLine.php @@ -4,6 +4,7 @@ use Money\Money; use PhpTwinfield\Enums\LineType; +use PhpTwinfield\Enums\PerformanceType; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PerformanceTypeField; use PhpTwinfield\Fields\Transaction\TransactionLine\CurrencyDateField; diff --git a/src/Fields/Transaction/LinesField.php b/src/Fields/Transaction/LinesField.php index 4914c6c4..e4ca3fc0 100644 --- a/src/Fields/Transaction/LinesField.php +++ b/src/Fields/Transaction/LinesField.php @@ -2,7 +2,6 @@ namespace PhpTwinfield\Fields\Transaction; -use PhpTwinfield\BaseTransaction; use PhpTwinfield\Enums\LineType; use Webmozart\Assert\Assert; @@ -71,10 +70,10 @@ private function getVatLines(): array } /** - * @param BaseTransaction $line + * @param $line * @return $this */ - public function addLine(BaseTransaction $line) + public function addLine($line) { Assert::isInstanceOf($line, $this->getLineClassName()); diff --git a/src/Fields/Transaction/TransactionLine/ValueFields.php b/src/Fields/Transaction/TransactionLine/ValueFields.php index fde35e95..92ef971e 100644 --- a/src/Fields/Transaction/TransactionLine/ValueFields.php +++ b/src/Fields/Transaction/TransactionLine/ValueFields.php @@ -5,6 +5,7 @@ use Money\Money; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\LineType; +use PhpTwinfield\Util; use Webmozart\Assert\Assert; trait ValueFields diff --git a/src/JournalTransaction.php b/src/JournalTransaction.php index fd90132b..9c762ceb 100644 --- a/src/JournalTransaction.php +++ b/src/JournalTransaction.php @@ -3,7 +3,6 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\Transaction\RegimeField; -use PhpTwinfield\JournalTransactionLine; /* * @link https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/JournalTransactions @@ -19,15 +18,4 @@ public function getLineClassName(): string { return JournalTransactionLine::class; } - - /* - * @param JournalTransactionLine $line - * @return $this - */ - public function addLine(JournalTransactionLine $line) - { - parent::addLine($line); - - return $this; - } } diff --git a/src/JournalTransactionLine.php b/src/JournalTransactionLine.php index 215743a2..e298d607 100644 --- a/src/JournalTransactionLine.php +++ b/src/JournalTransactionLine.php @@ -4,6 +4,7 @@ use Money\Money; use PhpTwinfield\Enums\LineType; +use PhpTwinfield\Enums\PerformanceType; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PerformanceTypeField; use PhpTwinfield\Fields\Transaction\InvoiceNumberField; diff --git a/src/PurchaseTransaction.php b/src/PurchaseTransaction.php index 6cd8e1fe..05f6d7fc 100644 --- a/src/PurchaseTransaction.php +++ b/src/PurchaseTransaction.php @@ -6,7 +6,6 @@ use PhpTwinfield\Fields\Transaction\InvoiceNumberField; use PhpTwinfield\Fields\Transaction\InvoiceNumberRaiseWarningField; use PhpTwinfield\Fields\Transaction\PaymentReferenceField; -use PhpTwinfield\PurchaseTransactionLine; /* * @link https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions @@ -25,15 +24,4 @@ public function getLineClassName(): string { return PurchaseTransactionLine::class; } - - /* - * @param PurchaseTransactionLine $line - * @return $this - */ - public function addLine(PurchaseTransactionLine $line) - { - parent::addLine($line); - - return $this; - } } diff --git a/src/PurchaseTransactionLine.php b/src/PurchaseTransactionLine.php index b2047640..b61c1782 100644 --- a/src/PurchaseTransactionLine.php +++ b/src/PurchaseTransactionLine.php @@ -144,70 +144,6 @@ public function setMatchLevel(?int $matchLevel): parent return parent::setMatchLevel($matchLevel); } - /* - * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The performance type. - * - * @param PerformanceType|null $performanceType - * @return $this - * @throws Exception - */ - public function setPerformanceType(?PerformanceType $performanceType): parent - { - if ($performanceType !== null && $this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('performanceType', $this); - } - - return parent::setPerformanceType($performanceType); - } - - /* - * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The ISO country codes are used. If not added to the request, by default the country code of the customer will be taken. - * - * @param Country|null $performanceCountry - * @return $this - * @throws Exception - */ - public function setPerformanceCountry(?Country $performanceCountry): parent - { - if ($performanceCountry !== null && $this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('performanceCountry', $this); - } - - return parent::setPerformanceCountry($performanceCountry); - } - - /* - * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. If not added to the request, by default the VAT number of the customer will be taken. - * - * @param string|null $performanceVatNumber - * @return $this - * @throws Exception - */ - public function setPerformanceVatNumber(?string $performanceVatNumber): parent - { - if ($performanceVatNumber !== null && $this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('performanceVatNumber', $this); - } - - return parent::setPerformanceVatNumber($performanceVatNumber); - } - - /* - * Only if line type is detail or vat. Mandatory in case of an ICT VAT code but only if performancetype is services. - * - * @param \DateTimeInterface|null $performanceDate - * @return $this - * @throws Exception - */ - public function setPerformanceDate(?\DateTimeInterface $performanceDate): parent - { - if ($performanceDate !== null && (!$this->getPerformanceType()->equals(PerformanceType::SERVICES()) || $this->getLineType()->equals(LineType::TOTAL()))) { - throw Exception::invalidFieldForLineType('performanceDate', $this); - } - - return parent::setPerformanceDate($performanceDate); - } - /* * Relation of the transaction. Only if line type is total. Read-only attribute. * diff --git a/src/SalesTransaction.php b/src/SalesTransaction.php index cc270c41..b1a547b4 100644 --- a/src/SalesTransaction.php +++ b/src/SalesTransaction.php @@ -7,7 +7,6 @@ use PhpTwinfield\Fields\Transaction\InvoiceNumberRaiseWarningField; use PhpTwinfield\Fields\Transaction\OriginReferenceField; use PhpTwinfield\Fields\Transaction\PaymentReferenceField; -use PhpTwinfield\SalesTransactionLine; /* * @link https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions @@ -27,15 +26,4 @@ public function getLineClassName(): string { return SalesTransactionLine::class; } - - /* - * @param SalesTransactionLine $line - * @return $this - */ - public function addLine(SalesTransactionLine $line) - { - parent::addLine($line); - - return $this; - } } diff --git a/src/SalesTransactionLine.php b/src/SalesTransactionLine.php index cf856546..51a79391 100644 --- a/src/SalesTransactionLine.php +++ b/src/SalesTransactionLine.php @@ -4,6 +4,7 @@ use Money\Money; use PhpTwinfield\Enums\LineType; +use PhpTwinfield\Enums\PerformanceType; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PerformanceTypeField; use PhpTwinfield\Fields\Transaction\TransactionLine\BaselineField; From 715cfaebabf554dd72480a79fd7d95f865788c00 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 20 May 2019 11:43:35 +0200 Subject: [PATCH 222/388] Upload --- src/BankTransactionLine.php | 12 ++++++------ src/BaseTransactionLine.php | 24 +++++++++++++++++++++-- src/CashTransactionLine.php | 12 ++++++------ src/DomDocuments/TransactionsDocument.php | 3 +++ src/ElectronicBankStatement.php | 16 ++++++++------- src/JournalTransactionLine.php | 17 ++++++++-------- src/PurchaseTransactionLine.php | 8 ++++---- src/SalesTransactionLine.php | 14 ++++++------- 8 files changed, 66 insertions(+), 40 deletions(-) diff --git a/src/BankTransactionLine.php b/src/BankTransactionLine.php index 471c0a3e..af4b4753 100644 --- a/src/BankTransactionLine.php +++ b/src/BankTransactionLine.php @@ -80,7 +80,7 @@ public function setCurrencyDate(?\DateTimeInterface $currencyDate): self throw Exception::invalidFieldForLineType('currencyDate', $this); } - return parent::setCurrencyDate($currencyDate); + return $this; } /* @@ -166,7 +166,7 @@ public function setPerformanceType(?PerformanceType $performanceType): self throw Exception::invalidFieldForLineType('performanceType', $this); } - return parent::setPerformanceType($performanceType); + return $this; } /* @@ -182,7 +182,7 @@ public function setPerformanceCountry(?Country $performanceCountry): self throw Exception::invalidFieldForLineType('performanceCountry', $this); } - return parent::setPerformanceCountry($performanceCountry); + return $this; } /* @@ -198,7 +198,7 @@ public function setPerformanceVatNumber(?string $performanceVatNumber): self throw Exception::invalidFieldForLineType('performanceVatNumber', $this); } - return parent::setPerformanceVatNumber($performanceVatNumber); + return $this; } /* @@ -214,7 +214,7 @@ public function setPerformanceDate(?\DateTimeInterface $performanceDate): self throw Exception::invalidFieldForLineType('performanceDate', $this); } - return parent::setPerformanceDate($performanceDate); + return $this; } /* @@ -230,7 +230,7 @@ public function setRelation(?int $relation): parent throw Exception::invalidRelationForLineType($relation, $this); } - return $this; + return parent::setRelation($relation); } /* diff --git a/src/BaseTransactionLine.php b/src/BaseTransactionLine.php index 3caf3b19..19172152 100644 --- a/src/BaseTransactionLine.php +++ b/src/BaseTransactionLine.php @@ -61,6 +61,25 @@ abstract class BaseTransactionLine use VatTurnoverField; use VatValueField; + /* + * Set the transaction on the line. This is needed later on. + * + * @param $object + * @throws \InvalidArgumentException If a transaction is invalid or if a transaction is already set. + * @internal + */ + public function setTransaction($object): void; + + /* + * Gets the transaction from the line. + * + * Note that you should add the return type when implementing. + * + * @see MatchReferenceInterface + * @internal + */ + public function getTransaction(); + /* * This will get you a unique reference to the object in Twinfield. * @@ -109,6 +128,7 @@ public function setVatBaseTurnover(?Money $vatBaseTurnover): self if (!$this->getLineType()->equals(LineType::VAT())) { throw Exception::invalidFieldForLineType('vatbaseturnover', $this); } + return $this; } @@ -155,6 +175,7 @@ public function setVatRepTurnover(?Money $vatRepTurnover): self if (!$this->getLineType()->equals(LineType::VAT())) { throw Exception::invalidFieldForLineType('vatrepturnover', $this); } + return $this; } @@ -170,7 +191,6 @@ public function setVatRepValue(?Money $vatRepValue): self } $this->vatRepValue = $vatRepValue; - return $this; } @@ -186,6 +206,7 @@ public function setVatTurnover(?Money $vatTurnover): self if (!$this->getLineType()->equals(LineType::VAT())) { throw Exception::invalidFieldForLineType('vatturnover', $this); } + return $this; } @@ -201,7 +222,6 @@ public function setVatValue(?Money $vatValue): self } $this->vatValue = $vatValue; - return $this; } } diff --git a/src/CashTransactionLine.php b/src/CashTransactionLine.php index fe57bd13..006cb67c 100644 --- a/src/CashTransactionLine.php +++ b/src/CashTransactionLine.php @@ -80,7 +80,7 @@ public function setCurrencyDate(?\DateTimeInterface $currencyDate): self throw Exception::invalidFieldForLineType('currencyDate', $this); } - return parent::setCurrencyDate($currencyDate); + return $this; } /* @@ -166,7 +166,7 @@ public function setPerformanceType(?PerformanceType $performanceType): self throw Exception::invalidFieldForLineType('performanceType', $this); } - return parent::setPerformanceType($performanceType); + return $this; } /* @@ -182,7 +182,7 @@ public function setPerformanceCountry(?Country $performanceCountry): self throw Exception::invalidFieldForLineType('performanceCountry', $this); } - return parent::setPerformanceCountry($performanceCountry); + return $this; } /* @@ -198,7 +198,7 @@ public function setPerformanceVatNumber(?string $performanceVatNumber): self throw Exception::invalidFieldForLineType('performanceVatNumber', $this); } - return parent::setPerformanceVatNumber($performanceVatNumber); + return $this; } /* @@ -214,7 +214,7 @@ public function setPerformanceDate(?\DateTimeInterface $performanceDate): self throw Exception::invalidFieldForLineType('performanceDate', $this); } - return parent::setPerformanceDate($performanceDate); + return $this; } /* @@ -230,7 +230,7 @@ public function setRelation(?int $relation): parent throw Exception::invalidRelationForLineType($relation, $this); } - return $this; + return parent::setRelation($relation); } /* diff --git a/src/DomDocuments/TransactionsDocument.php b/src/DomDocuments/TransactionsDocument.php index 1379a949..6e7c5e32 100644 --- a/src/DomDocuments/TransactionsDocument.php +++ b/src/DomDocuments/TransactionsDocument.php @@ -9,6 +9,8 @@ use PhpTwinfield\Enums\LineType; use PhpTwinfield\Fields\DueDateField; use PhpTwinfield\Fields\FreeText1Field; +use PhpTwinfield\Fields\FreeText2Field; +use PhpTwinfield\Fields\FreeText3Field; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PerformanceTypeField; use PhpTwinfield\Fields\Transaction\InvoiceNumberField; @@ -18,6 +20,7 @@ use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceCountryField; use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceVatNumberField; use PhpTwinfield\Fields\Transaction\TransactionLine\ValueFields; +use PhpTwinfield\Fields\Transaction\TransactionLine\ValueOpenField; use PhpTwinfield\Fields\Transaction\TransactionLine\VatBaseTotalField; use PhpTwinfield\Fields\Transaction\TransactionLine\VatTotalField; use PhpTwinfield\Util; diff --git a/src/ElectronicBankStatement.php b/src/ElectronicBankStatement.php index 40b0d716..a6254f93 100644 --- a/src/ElectronicBankStatement.php +++ b/src/ElectronicBankStatement.php @@ -2,7 +2,6 @@ namespace PhpTwinfield; -use Money\Currency; use Money\Money; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Fields\DateField; @@ -60,8 +59,11 @@ class ElectronicBankStatement public function __construct() { - $this->currency = new Currency("EUR"); - $this->startValue = new Money(0, $this->getCurrency()); + $currency = new \PhpTwinfield\Currency; + $currency->setCode('EUR'); + $this->currency = $currency; + $this->closeValue = new \Money\Money(0, new \Money\Currency('EUR')); + $this->startValue = new \Money\Money(0, new \Money\Currency('EUR')); } public function getAccount(): ?string @@ -130,17 +132,17 @@ public function getTransactions(): array public function setTransactions(array $transactions): void { Assert::allIsInstanceOf($transactions, ElectronicBankStatementTransaction::class); - Assert::notEmpty($this->startvalue); + Assert::notEmpty($this->startValue); $this->transactions = $transactions; - $this->closevalue = $this->startvalue; + $this->closeValue = $this->startValue; foreach ($transactions as $transaction) { if ($transaction->getDebitCredit() == DebitCredit::CREDIT()) { - $this->closevalue = $this->closevalue->add($transaction->getValue()); + $this->closeValue = $this->closeValue->add($transaction->getValue()); } else { - $this->closevalue = $this->closevalue->subtract($transaction->getValue()); + $this->closeValue = $this->closeValue->subtract($transaction->getValue()); } } } diff --git a/src/JournalTransactionLine.php b/src/JournalTransactionLine.php index e298d607..2a0e91f8 100644 --- a/src/JournalTransactionLine.php +++ b/src/JournalTransactionLine.php @@ -61,7 +61,8 @@ public function setBaseline(?int $baseline): self if (!$this->getLineType()->equals(LineType::VAT())) { throw Exception::invalidFieldForLineType("baseline", $this); } - return parent::setBaseline($baseline); + + return $this; } /* @@ -93,7 +94,7 @@ public function setCurrencyDate(?\DateTimeInterface $currencyDate): self throw Exception::invalidFieldForLineType('currencyDate', $this); } - return parent::setCurrencyDate($currencyDate); + return $this; } /* @@ -143,7 +144,7 @@ public function setInvoiceNumber(?string $invoiceNumber): self throw Exception::invalidFieldForLineType('invoiceNumber', $this); } - return parent::setInvoiceNumber($invoiceNumber); + return $this; } /* @@ -204,7 +205,7 @@ public function setPerformanceType(?PerformanceType $performanceType): self throw Exception::invalidFieldForLineType('performanceType', $this); } - return parent::setPerformanceType($performanceType); + return $this; } /* @@ -220,7 +221,7 @@ public function setPerformanceCountry(?Country $performanceCountry): self throw Exception::invalidFieldForLineType('performanceCountry', $this); } - return parent::setPerformanceCountry($performanceCountry); + return $this; } /* @@ -236,7 +237,7 @@ public function setPerformanceVatNumber(?string $performanceVatNumber): self throw Exception::invalidFieldForLineType('performanceVatNumber', $this); } - return parent::setPerformanceVatNumber($performanceVatNumber); + return $this; } /* @@ -252,7 +253,7 @@ public function setPerformanceDate(?\DateTimeInterface $performanceDate): self throw Exception::invalidFieldForLineType('performanceDate', $this); } - return parent::setPerformanceDate($performanceDate); + return $this; } /* @@ -268,7 +269,7 @@ public function setRelation(?int $relation): parent throw Exception::invalidRelationForLineType($relation, $this); } - return $this; + return parent::setRelation($relation); } /* diff --git a/src/PurchaseTransactionLine.php b/src/PurchaseTransactionLine.php index b61c1782..eea6fbf3 100644 --- a/src/PurchaseTransactionLine.php +++ b/src/PurchaseTransactionLine.php @@ -59,7 +59,7 @@ public function setBaseline(?int $baseline): self if (!$this->getLineType()->equals(LineType::VAT())) { throw Exception::invalidFieldForLineType("baseline", $this); } - return parent::setBaseline($baseline); + return $this; } /* @@ -125,7 +125,7 @@ public function setMatchDate(?\DateTimeInterface $matchDate): self throw Exception::invalidFieldForLineType('matchDate', $this); } - return parent::setMatchDate($matchDate); + return $this; } /* @@ -157,7 +157,7 @@ public function setRelation(?int $relation): parent throw Exception::invalidRelationForLineType($relation, $this); } - return $this; + return parent::setRelation($relation); } /* @@ -189,7 +189,7 @@ public function setValueOpen(?Money $valueOpen): self throw Exception::invalidFieldForLineType('valueOpen', $this); } - return parent::setValueOpen($valueOpen); + return $this; } /* diff --git a/src/SalesTransactionLine.php b/src/SalesTransactionLine.php index 51a79391..8e20a919 100644 --- a/src/SalesTransactionLine.php +++ b/src/SalesTransactionLine.php @@ -65,7 +65,7 @@ public function setBaseline(?int $baseline): self if (!$this->getLineType()->equals(LineType::VAT())) { throw Exception::invalidFieldForLineType("baseline", $this); } - return parent::setBaseline($baseline); + return $this; } /* @@ -167,7 +167,7 @@ public function setPerformanceType(?PerformanceType $performanceType): self throw Exception::invalidFieldForLineType('performanceType', $this); } - return parent::setPerformanceType($performanceType); + return $this; } /* @@ -183,7 +183,7 @@ public function setPerformanceCountry(?Country $performanceCountry): self throw Exception::invalidFieldForLineType('performanceCountry', $this); } - return parent::setPerformanceCountry($performanceCountry); + return $this; } /* @@ -199,7 +199,7 @@ public function setPerformanceVatNumber(?string $performanceVatNumber): self throw Exception::invalidFieldForLineType('performanceVatNumber', $this); } - return parent::setPerformanceVatNumber($performanceVatNumber); + return $this; } /* @@ -215,7 +215,7 @@ public function setPerformanceDate(?\DateTimeInterface $performanceDate): self throw Exception::invalidFieldForLineType('performanceDate', $this); } - return parent::setPerformanceDate($performanceDate); + return $this; } /* @@ -231,7 +231,7 @@ public function setRelation(?int $relation): parent throw Exception::invalidRelationForLineType($relation, $this); } - return $this; + return parent::setRelation($relation); } /* @@ -263,7 +263,7 @@ public function setValueOpen(?Money $valueOpen): self throw Exception::invalidFieldForLineType('valueOpen', $this); } - return parent::setValueOpen($valueOpen); + return $this; } /* From 84bd96614a24eecf0b99f24a2b7421addec2dee9 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 20 May 2019 11:45:43 +0200 Subject: [PATCH 223/388] Update BaseTransactionLine.php --- src/BaseTransactionLine.php | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/BaseTransactionLine.php b/src/BaseTransactionLine.php index 19172152..3d0396b3 100644 --- a/src/BaseTransactionLine.php +++ b/src/BaseTransactionLine.php @@ -61,25 +61,6 @@ abstract class BaseTransactionLine use VatTurnoverField; use VatValueField; - /* - * Set the transaction on the line. This is needed later on. - * - * @param $object - * @throws \InvalidArgumentException If a transaction is invalid or if a transaction is already set. - * @internal - */ - public function setTransaction($object): void; - - /* - * Gets the transaction from the line. - * - * Note that you should add the return type when implementing. - * - * @see MatchReferenceInterface - * @internal - */ - public function getTransaction(); - /* * This will get you a unique reference to the object in Twinfield. * From ea1110cfd2efe0d0ed98203f949f1fba7315840f Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 20 May 2019 11:58:30 +0200 Subject: [PATCH 224/388] Upload --- src/BankTransactionLine.php | 32 ++++++++++++++++---------------- src/CashTransactionLine.php | 32 ++++++++++++++++---------------- src/JournalTransactionLine.php | 2 +- src/PurchaseTransactionLine.php | 32 ++++++++++++++++---------------- src/SalesTransactionLine.php | 32 ++++++++++++++++---------------- 5 files changed, 65 insertions(+), 65 deletions(-) diff --git a/src/BankTransactionLine.php b/src/BankTransactionLine.php index af4b4753..082ca8cc 100644 --- a/src/BankTransactionLine.php +++ b/src/BankTransactionLine.php @@ -227,7 +227,7 @@ public function setPerformanceDate(?\DateTimeInterface $performanceDate): self public function setRelation(?int $relation): parent { if ($relation !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidRelationForLineType($relation, $this); + throw Exception::invalidFieldForLineType('relation', $this); } return parent::setRelation($relation); @@ -252,48 +252,48 @@ public function setRepValueOpen(?Money $repValueOpen): parent /* * Only if line type is total. The total VAT amount in the currency of the bank transaction * - * @param Money|null $vatValueOpen + * @param Money|null $vatTotal * @return $this * @throws Exception */ - public function setVatValueOpen(?Money $vatValueOpen): parent + public function setVatTotal(?Money $vatTotal): parent { - if ($vatValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatValueOpen', $this); + if ($vatTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatTotal', $this); } - return parent::setVatValueOpen($vatValueOpen); + return parent::setVatTotal($vatTotal); } /* * Only if line type is total. The total VAT amount in base currency. * - * @param Money|null $vatBaseValueOpen + * @param Money|null $vatBaseTotal * @return $this * @throws Exception */ - public function setVatBaseValueOpen(?Money $vatBaseValueOpen): parent + public function setVatBaseTotal(?Money $vatBaseTotal): parent { - if ($vatBaseValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatBaseValueOpen', $this); + if ($vatBaseTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatBaseTotal', $this); } - return parent::setVatBaseValueOpen($vatBaseValueOpen); + return parent::setVatBaseTotal($vatBaseTotal); } /* * Only if line type is total. The total VAT amount in reporting currency. * - * @param Money|null $vatRepValueOpen + * @param Money|null $vatRepTotal * @return $this * @throws Exception */ - public function setVatRepValueOpen(?Money $vatRepValueOpen): parent + public function setVatRepTotal(?Money $vatRepTotal): parent { - if ($vatRepValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatRepValueOpen', $this); + if ($vatRepTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatRepTotal', $this); } - return parent::setVatRepValueOpen($vatRepValueOpen); + return parent::setVatRepTotal($vatRepTotal); } } diff --git a/src/CashTransactionLine.php b/src/CashTransactionLine.php index 006cb67c..ccd98483 100644 --- a/src/CashTransactionLine.php +++ b/src/CashTransactionLine.php @@ -227,7 +227,7 @@ public function setPerformanceDate(?\DateTimeInterface $performanceDate): self public function setRelation(?int $relation): parent { if ($relation !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidRelationForLineType($relation, $this); + throw Exception::invalidFieldForLineType('relation', $this); } return parent::setRelation($relation); @@ -252,48 +252,48 @@ public function setRepValueOpen(?Money $repValueOpen): parent /* * Only if line type is total. The total VAT amount in the currency of the cash transaction * - * @param Money|null $vatValueOpen + * @param Money|null $vatTotal * @return $this * @throws Exception */ - public function setVatValueOpen(?Money $vatValueOpen): parent + public function setVatTotal(?Money $vatTotal): parent { - if ($vatValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatValueOpen', $this); + if ($vatTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatTotal', $this); } - return parent::setVatValueOpen($vatValueOpen); + return parent::setVatTotal($vatTotal); } /* * Only if line type is total. The total VAT amount in base currency. * - * @param Money|null $vatBaseValueOpen + * @param Money|null $vatBaseTotal * @return $this * @throws Exception */ - public function setVatBaseValueOpen(?Money $vatBaseValueOpen): parent + public function setVatBaseTotal(?Money $vatBaseTotal): parent { - if ($vatBaseValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatBaseValueOpen', $this); + if ($vatBaseTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatBaseTotal', $this); } - return parent::setVatBaseValueOpen($vatBaseValueOpen); + return parent::setVatBaseTotal($vatBaseTotal); } /* * Only if line type is total. The total VAT amount in reporting currency. * - * @param Money|null $vatRepValueOpen + * @param Money|null $vatRepTotal * @return $this * @throws Exception */ - public function setVatRepValueOpen(?Money $vatRepValueOpen): parent + public function setVatRepTotal(?Money $vatRepTotal): parent { - if ($vatRepValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatRepValueOpen', $this); + if ($vatRepTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatRepTotal', $this); } - return parent::setVatRepValueOpen($vatRepValueOpen); + return parent::setVatRepTotal($vatRepTotal); } } diff --git a/src/JournalTransactionLine.php b/src/JournalTransactionLine.php index 2a0e91f8..07ffb00c 100644 --- a/src/JournalTransactionLine.php +++ b/src/JournalTransactionLine.php @@ -266,7 +266,7 @@ public function setPerformanceDate(?\DateTimeInterface $performanceDate): self public function setRelation(?int $relation): parent { if ($relation !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidRelationForLineType($relation, $this); + throw Exception::invalidFieldForLineType('relation', $this); } return parent::setRelation($relation); diff --git a/src/PurchaseTransactionLine.php b/src/PurchaseTransactionLine.php index eea6fbf3..7b5fb944 100644 --- a/src/PurchaseTransactionLine.php +++ b/src/PurchaseTransactionLine.php @@ -154,7 +154,7 @@ public function setMatchLevel(?int $matchLevel): parent public function setRelation(?int $relation): parent { if ($relation !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidRelationForLineType($relation, $this); + throw Exception::invalidFieldForLineType('relation', $this); } return parent::setRelation($relation); @@ -195,48 +195,48 @@ public function setValueOpen(?Money $valueOpen): self /* * Only if line type is total. The total VAT amount in the currency of the purchase transaction * - * @param Money|null $vatValueOpen + * @param Money|null $vatTotal * @return $this * @throws Exception */ - public function setVatValueOpen(?Money $vatValueOpen): parent + public function setVatTotal(?Money $vatTotal): parent { - if ($vatValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatValueOpen', $this); + if ($vatTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatTotal', $this); } - return parent::setVatValueOpen($vatValueOpen); + return parent::setVatTotal($vatTotal); } /* * Only if line type is total. The total VAT amount in base currency. * - * @param Money|null $vatBaseValueOpen + * @param Money|null $vatBaseTotal * @return $this * @throws Exception */ - public function setVatBaseValueOpen(?Money $vatBaseValueOpen): parent + public function setVatBaseTotal(?Money $vatBaseTotal): parent { - if ($vatBaseValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatBaseValueOpen', $this); + if ($vatBaseTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatBaseTotal', $this); } - return parent::setVatBaseValueOpen($vatBaseValueOpen); + return parent::setVatBaseTotal($vatBaseTotal); } /* * Only if line type is total. The total VAT amount in reporting currency. * - * @param Money|null $vatRepValueOpen + * @param Money|null $vatRepTotal * @return $this * @throws Exception */ - public function setVatRepValueOpen(?Money $vatRepValueOpen): parent + public function setVatRepTotal(?Money $vatRepTotal): parent { - if ($vatRepValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatRepValueOpen', $this); + if ($vatRepTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatRepTotal', $this); } - return parent::setVatRepValueOpen($vatRepValueOpen); + return parent::setVatRepTotal($vatRepTotal); } } diff --git a/src/SalesTransactionLine.php b/src/SalesTransactionLine.php index 8e20a919..197020b1 100644 --- a/src/SalesTransactionLine.php +++ b/src/SalesTransactionLine.php @@ -228,7 +228,7 @@ public function setPerformanceDate(?\DateTimeInterface $performanceDate): self public function setRelation(?int $relation): parent { if ($relation !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidRelationForLineType($relation, $this); + throw Exception::invalidFieldForLineType('relation', $this); } return parent::setRelation($relation); @@ -269,48 +269,48 @@ public function setValueOpen(?Money $valueOpen): self /* * Only if line type is total. The total VAT amount in the currency of the sales transaction * - * @param Money|null $vatValueOpen + * @param Money|null $vatTotal * @return $this * @throws Exception */ - public function setVatValueOpen(?Money $vatValueOpen): parent + public function setVatTotal(?Money $vatTotal): parent { - if ($vatValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatValueOpen', $this); + if ($vatTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatTotal', $this); } - return parent::setVatValueOpen($vatValueOpen); + return parent::setVatTotal($vatTotal); } /* * Only if line type is total. The total VAT amount in base currency. * - * @param Money|null $vatBaseValueOpen + * @param Money|null $vatBaseTotal * @return $this * @throws Exception */ - public function setVatBaseValueOpen(?Money $vatBaseValueOpen): parent + public function setVatBaseTotal(?Money $vatBaseTotal): parent { - if ($vatBaseValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatBaseValueOpen', $this); + if ($vatBaseTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatBaseTotal', $this); } - return parent::setVatBaseValueOpen($vatBaseValueOpen); + return parent::setVatBaseTotal($vatBaseTotal); } /* * Only if line type is total. The total VAT amount in reporting currency. * - * @param Money|null $vatRepValueOpen + * @param Money|null $vatRepTotal * @return $this * @throws Exception */ - public function setVatRepValueOpen(?Money $vatRepValueOpen): parent + public function setVatRepTotal(?Money $vatRepTotal): parent { - if ($vatRepValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatRepValueOpen', $this); + if ($vatRepTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { + throw Exception::invalidFieldForLineType('vatRepTotal', $this); } - return parent::setVatRepValueOpen($vatRepValueOpen); + return parent::setVatRepTotal($vatRepTotal); } } From fd87d27087092600ff17826ed299ff48b3fe704b Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 20 May 2019 12:07:13 +0200 Subject: [PATCH 225/388] Upload --- src/BankTransactionLine.php | 12 ++++++------ src/CashTransactionLine.php | 12 ++++++------ src/ElectronicBankStatement.php | 2 ++ src/Fields/CurrencyField.php | 2 +- src/PurchaseTransactionLine.php | 12 ++++++------ src/SalesTransactionLine.php | 12 ++++++------ tests/UnitTests/BankTransactionLineUnitTest.php | 16 ---------------- tests/UnitTests/CashTransactionLineUnitTest.php | 16 ---------------- 8 files changed, 27 insertions(+), 57 deletions(-) diff --git a/src/BankTransactionLine.php b/src/BankTransactionLine.php index 082ca8cc..69f7c4d8 100644 --- a/src/BankTransactionLine.php +++ b/src/BankTransactionLine.php @@ -256,13 +256,13 @@ public function setRepValueOpen(?Money $repValueOpen): parent * @return $this * @throws Exception */ - public function setVatTotal(?Money $vatTotal): parent + public function setVatTotal(?Money $vatTotal): self { if ($vatTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { throw Exception::invalidFieldForLineType('vatTotal', $this); } - return parent::setVatTotal($vatTotal); + return $this; } /* @@ -272,13 +272,13 @@ public function setVatTotal(?Money $vatTotal): parent * @return $this * @throws Exception */ - public function setVatBaseTotal(?Money $vatBaseTotal): parent + public function setVatBaseTotal(?Money $vatBaseTotal): self { if ($vatBaseTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { throw Exception::invalidFieldForLineType('vatBaseTotal', $this); } - return parent::setVatBaseTotal($vatBaseTotal); + return $this; } /* @@ -288,12 +288,12 @@ public function setVatBaseTotal(?Money $vatBaseTotal): parent * @return $this * @throws Exception */ - public function setVatRepTotal(?Money $vatRepTotal): parent + public function setVatRepTotal(?Money $vatRepTotal): self { if ($vatRepTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { throw Exception::invalidFieldForLineType('vatRepTotal', $this); } - return parent::setVatRepTotal($vatRepTotal); + return $this; } } diff --git a/src/CashTransactionLine.php b/src/CashTransactionLine.php index ccd98483..f3011e23 100644 --- a/src/CashTransactionLine.php +++ b/src/CashTransactionLine.php @@ -256,13 +256,13 @@ public function setRepValueOpen(?Money $repValueOpen): parent * @return $this * @throws Exception */ - public function setVatTotal(?Money $vatTotal): parent + public function setVatTotal(?Money $vatTotal): self { if ($vatTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { throw Exception::invalidFieldForLineType('vatTotal', $this); } - return parent::setVatTotal($vatTotal); + return $this; } /* @@ -272,13 +272,13 @@ public function setVatTotal(?Money $vatTotal): parent * @return $this * @throws Exception */ - public function setVatBaseTotal(?Money $vatBaseTotal): parent + public function setVatBaseTotal(?Money $vatBaseTotal): self { if ($vatBaseTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { throw Exception::invalidFieldForLineType('vatBaseTotal', $this); } - return parent::setVatBaseTotal($vatBaseTotal); + return $this; } /* @@ -288,12 +288,12 @@ public function setVatBaseTotal(?Money $vatBaseTotal): parent * @return $this * @throws Exception */ - public function setVatRepTotal(?Money $vatRepTotal): parent + public function setVatRepTotal(?Money $vatRepTotal): self { if ($vatRepTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { throw Exception::invalidFieldForLineType('vatRepTotal', $this); } - return parent::setVatRepTotal($vatRepTotal); + return $this; } } diff --git a/src/ElectronicBankStatement.php b/src/ElectronicBankStatement.php index a6254f93..c08a84b3 100644 --- a/src/ElectronicBankStatement.php +++ b/src/ElectronicBankStatement.php @@ -4,6 +4,7 @@ use Money\Money; use PhpTwinfield\Enums\DebitCredit; +use PhpTwinfield\Fields\CurrencyField; use PhpTwinfield\Fields\DateField; use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\Transaction\CloseValueField; @@ -17,6 +18,7 @@ class ElectronicBankStatement { use CloseValueField; + use CurrencyField; use DateField; use OfficeField; use StartValueField; diff --git a/src/Fields/CurrencyField.php b/src/Fields/CurrencyField.php index c67c11ed..36c17486 100644 --- a/src/Fields/CurrencyField.php +++ b/src/Fields/CurrencyField.php @@ -6,7 +6,7 @@ /** * The currency - * Used by: BaseTransaction, CustomerPostingRule, Invoice, Rate, SupplierPostingRule + * Used by: BaseTransaction, CustomerPostingRule, ElectronicBankStatement, Invoice, Rate, SupplierPostingRule * * @package PhpTwinfield\Traits */ diff --git a/src/PurchaseTransactionLine.php b/src/PurchaseTransactionLine.php index 7b5fb944..e09e9237 100644 --- a/src/PurchaseTransactionLine.php +++ b/src/PurchaseTransactionLine.php @@ -199,13 +199,13 @@ public function setValueOpen(?Money $valueOpen): self * @return $this * @throws Exception */ - public function setVatTotal(?Money $vatTotal): parent + public function setVatTotal(?Money $vatTotal): self { if ($vatTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { throw Exception::invalidFieldForLineType('vatTotal', $this); } - return parent::setVatTotal($vatTotal); + return $this; } /* @@ -215,13 +215,13 @@ public function setVatTotal(?Money $vatTotal): parent * @return $this * @throws Exception */ - public function setVatBaseTotal(?Money $vatBaseTotal): parent + public function setVatBaseTotal(?Money $vatBaseTotal): self { if ($vatBaseTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { throw Exception::invalidFieldForLineType('vatBaseTotal', $this); } - return parent::setVatBaseTotal($vatBaseTotal); + return $this; } /* @@ -231,12 +231,12 @@ public function setVatBaseTotal(?Money $vatBaseTotal): parent * @return $this * @throws Exception */ - public function setVatRepTotal(?Money $vatRepTotal): parent + public function setVatRepTotal(?Money $vatRepTotal): self { if ($vatRepTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { throw Exception::invalidFieldForLineType('vatRepTotal', $this); } - return parent::setVatRepTotal($vatRepTotal); + return $this; } } diff --git a/src/SalesTransactionLine.php b/src/SalesTransactionLine.php index 197020b1..0f93d9c8 100644 --- a/src/SalesTransactionLine.php +++ b/src/SalesTransactionLine.php @@ -273,13 +273,13 @@ public function setValueOpen(?Money $valueOpen): self * @return $this * @throws Exception */ - public function setVatTotal(?Money $vatTotal): parent + public function setVatTotal(?Money $vatTotal): self { if ($vatTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { throw Exception::invalidFieldForLineType('vatTotal', $this); } - return parent::setVatTotal($vatTotal); + return $this; } /* @@ -289,13 +289,13 @@ public function setVatTotal(?Money $vatTotal): parent * @return $this * @throws Exception */ - public function setVatBaseTotal(?Money $vatBaseTotal): parent + public function setVatBaseTotal(?Money $vatBaseTotal): self { if ($vatBaseTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { throw Exception::invalidFieldForLineType('vatBaseTotal', $this); } - return parent::setVatBaseTotal($vatBaseTotal); + return $this; } /* @@ -305,12 +305,12 @@ public function setVatBaseTotal(?Money $vatBaseTotal): parent * @return $this * @throws Exception */ - public function setVatRepTotal(?Money $vatRepTotal): parent + public function setVatRepTotal(?Money $vatRepTotal): self { if ($vatRepTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { throw Exception::invalidFieldForLineType('vatRepTotal', $this); } - return parent::setVatRepTotal($vatRepTotal); + return $this; } } diff --git a/tests/UnitTests/BankTransactionLineUnitTest.php b/tests/UnitTests/BankTransactionLineUnitTest.php index 3f775b38..5b114daa 100644 --- a/tests/UnitTests/BankTransactionLineUnitTest.php +++ b/tests/UnitTests/BankTransactionLineUnitTest.php @@ -175,20 +175,4 @@ public function testCanNotSetVatRepTurnoverIfLineTypeIsNotVat() $this->line->setLineType(LineType::DETAIL()); $this->line->setVatRepTurnover(Money::EUR(100)); } - - public function testSetInvoiceNumber() - { - $this->line->setLineType(LineType::DETAIL()); - - $this->assertEquals($this->line, $this->line->setInvoiceNumber('11001770'), 'Fluid interface is expected'); - $this->assertSame('11001770', $this->line->getInvoiceNumber()); - } - - public function testCanNotSetInvoiceNumberIfLineTypeIsNotDetail() - { - $this->expectExceptionMessage('Invalid field \'invoicenumber\' for line class PhpTwinfield\BankTransactionLine and type \'total\'.'); - - $this->line->setLineType(LineType::TOTAL()); - $this->line->setInvoiceNumber('11001770'); - } } diff --git a/tests/UnitTests/CashTransactionLineUnitTest.php b/tests/UnitTests/CashTransactionLineUnitTest.php index 52343d40..d46f2d05 100644 --- a/tests/UnitTests/CashTransactionLineUnitTest.php +++ b/tests/UnitTests/CashTransactionLineUnitTest.php @@ -175,20 +175,4 @@ public function testCanNotSetVatRepTurnoverIfLineTypeIsNotVat() $this->line->setLineType(LineType::DETAIL()); $this->line->setVatRepTurnover(Money::EUR(100)); } - - public function testSetInvoiceNumber() - { - $this->line->setLineType(LineType::DETAIL()); - - $this->assertEquals($this->line, $this->line->setInvoiceNumber('11001770'), 'Fluid interface is expected'); - $this->assertSame('11001770', $this->line->getInvoiceNumber()); - } - - public function testCanNotSetInvoiceNumberIfLineTypeIsNotDetail() - { - $this->expectExceptionMessage('Invalid field \'invoicenumber\' for line class PhpTwinfield\CashTransactionLine and type \'total\'.'); - - $this->line->setLineType(LineType::TOTAL()); - $this->line->setInvoiceNumber('11001770'); - } } From 8b93d383a16b4447b9630b11170a83965695f3a0 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 20 May 2019 21:10:30 +0200 Subject: [PATCH 226/388] Upload --- src/BankTransaction.php | 6 ++++++ src/CashTransaction.php | 6 ++++++ src/DomDocuments/TransactionsDocument.php | 4 ++-- src/Fields/Transaction/TransactionLine/MatchStatusField.php | 2 +- tests/IntegrationTests/BankTransactionIntegrationTest.php | 4 +--- tests/IntegrationTests/CashTransactionIntegrationTest.php | 4 +--- .../IntegrationTests/JournalTransactionIntegrationTest.php | 2 +- .../IntegrationTests/PurchaseTransactionIntegrationTest.php | 2 +- tests/IntegrationTests/SalesTransactionIntegrationTest.php | 2 +- tests/UnitTests/BankTransactionUnitTest.php | 1 + 10 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/BankTransaction.php b/src/BankTransaction.php index 278a2a38..e7c1dac1 100644 --- a/src/BankTransaction.php +++ b/src/BankTransaction.php @@ -52,6 +52,12 @@ public function addLine($line) } } + if ($line->getDebitCredit()->equals(DebitCredit::CREDIT())) {. + $this->closeValue = $this->getCloseValue()->add($line->startValue()); + } else { + $this->closeValue = $this->getCloseValue()->subtract($line->startValue()); + } + return $this; } } diff --git a/src/CashTransaction.php b/src/CashTransaction.php index 472524c6..de8c3368 100644 --- a/src/CashTransaction.php +++ b/src/CashTransaction.php @@ -52,6 +52,12 @@ public function addLine($line) } } + if ($line->getDebitCredit()->equals(DebitCredit::CREDIT())) {. + $this->closeValue = $this->getCloseValue()->add($line->startValue()); + } else { + $this->closeValue = $this->getCloseValue()->subtract($line->startValue()); + } + return $this; } } diff --git a/src/DomDocuments/TransactionsDocument.php b/src/DomDocuments/TransactionsDocument.php index 6e7c5e32..4f4b75d8 100644 --- a/src/DomDocuments/TransactionsDocument.php +++ b/src/DomDocuments/TransactionsDocument.php @@ -55,8 +55,8 @@ public function addTransaction(BaseTransaction $transaction) if ($transaction->getRaiseWarning() !== null) { $transactionElement->appendChild($this->createNodeWithTextContent('raisewarning', $transaction->getRaiseWarningToString())); } - if ($transaction->isAutoBalanceVat() !== null) { - $transactionElement->appendChild($this->createNodeWithTextContent('autobalancevat', $transaction->isAutoBalanceVatToString())); + if ($transaction->getAutoBalanceVat() !== null) { + $transactionElement->appendChild($this->createNodeWithTextContent('autobalancevat', $transaction->getAutoBalanceVatToString())); } $this->rootElement->appendChild($transactionElement); diff --git a/src/Fields/Transaction/TransactionLine/MatchStatusField.php b/src/Fields/Transaction/TransactionLine/MatchStatusField.php index b7686f74..f48b1465 100644 --- a/src/Fields/Transaction/TransactionLine/MatchStatusField.php +++ b/src/Fields/Transaction/TransactionLine/MatchStatusField.php @@ -13,7 +13,7 @@ trait MatchStatusField */ private $matchStatus; - public function getStatus(): ?MatchStatus + public function getMatchStatus(): ?MatchStatus { return $this->matchStatus; } diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index 0d26aa0e..ff9ef245 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -52,7 +52,7 @@ public function testGetBankTransactionWorks() $this->assertInstanceOf(BankTransaction::class, $bankTransaction); $this->assertEquals(Destiny::TEMPORARY(), $bankTransaction->getDestiny()); - $this->assertNull($bankTransaction->isAutoBalanceVat()); + $this->assertNull($bankTransaction->getAutoBalanceVat()); $this->assertSame(false, $bankTransaction->getRaiseWarning()); $this->assertEquals(Office::fromCode('001'), $bankTransaction->getOffice()); $this->assertSame('BNK', $bankTransaction->getCode()); @@ -99,7 +99,6 @@ public function testGetBankTransactionWorks() $this->assertSame('1300', $detailLine->getDim1ToString()); $this->assertSame('1000', $detailLine->getDim2ToString()); $this->assertEquals(DebitCredit::CREDIT(), $detailLine->getDebitCredit()); - $this->assertSame('11001770', $detailLine->getInvoiceNumber()); $this->assertEquals(Money::EUR(43555), $detailLine->getValue()); $this->assertEquals(Money::EUR(43555), $totalLine->getBaseValue()); $this->assertSame(1.0, $totalLine->getRate()); @@ -147,7 +146,6 @@ public function testSendBankTransactionWorks() ->setDim1FromString('1300') ->setDim2FromString('1000') ->setValue(Money::EUR(43555)) - ->setInvoiceNumber('11001770') ->setDescription('Invoice paid'); $bankTransaction diff --git a/tests/IntegrationTests/CashTransactionIntegrationTest.php b/tests/IntegrationTests/CashTransactionIntegrationTest.php index d64d5885..45f20312 100644 --- a/tests/IntegrationTests/CashTransactionIntegrationTest.php +++ b/tests/IntegrationTests/CashTransactionIntegrationTest.php @@ -54,7 +54,7 @@ public function testGetCashTransactionWorks() $this->assertInstanceOf(CashTransaction::class, $cashTransaction); $this->assertEquals(Destiny::TEMPORARY(), $cashTransaction->getDestiny()); - $this->assertNull($cashTransaction->isAutoBalanceVat()); + $this->assertNull($cashTransaction->getAutoBalanceVat()); $this->assertSame(false, $cashTransaction->getRaiseWarning()); $this->assertEquals(Office::fromCode('001'), $cashTransaction->getOffice()); $this->assertSame('CASH', $cashTransaction->getCode()); @@ -101,7 +101,6 @@ public function testGetCashTransactionWorks() $this->assertSame('1300', $detailLine->getDim1ToString()); $this->assertSame('1000', $detailLine->getDim2ToString()); $this->assertEquals(DebitCredit::CREDIT(), $detailLine->getDebitCredit()); - $this->assertSame('11001770', $detailLine->getInvoiceNumber()); $this->assertEquals(Money::EUR(43555), $detailLine->getValue()); $this->assertEquals(Money::EUR(43555), $totalLine->getBaseValue()); $this->assertSame(1.0, $totalLine->getRate()); @@ -149,7 +148,6 @@ public function testSendCashTransactionWorks() ->setDim1FromString('1300') ->setDim2FromString('1000') ->setValue(Money::EUR(43555)) - ->setInvoiceNumber('11001770') ->setDescription('Invoice paid'); $cashTransaction diff --git a/tests/IntegrationTests/JournalTransactionIntegrationTest.php b/tests/IntegrationTests/JournalTransactionIntegrationTest.php index c5ac1399..a04c38db 100644 --- a/tests/IntegrationTests/JournalTransactionIntegrationTest.php +++ b/tests/IntegrationTests/JournalTransactionIntegrationTest.php @@ -51,7 +51,7 @@ public function testGetJournalTransactionWorks() $this->assertInstanceOf(JournalTransaction::class, $journalTransaction); $this->assertEquals(Destiny::TEMPORARY(), $journalTransaction->getDestiny()); - $this->assertNull($journalTransaction->isAutoBalanceVat()); + $this->assertNull($journalTransaction->getAutoBalanceVat()); $this->assertNull($journalTransaction->getRaiseWarning()); $this->assertEquals(Office::fromCode('0-0-1-NL-001'), $journalTransaction->getOffice()); $this->assertSame('MEMO', $journalTransaction->getCode()); diff --git a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php index 6c20fc6f..7633aa87 100644 --- a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php +++ b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php @@ -50,7 +50,7 @@ public function testGetPurchaseTransactionWorks() $this->assertInstanceOf(PurchaseTransaction::class, $purchaseTransaction); $this->assertEquals(Destiny::TEMPORARY(), $purchaseTransaction->getDestiny()); - $this->assertNull($purchaseTransaction->isAutoBalanceVat()); + $this->assertNull($purchaseTransaction->getAutoBalanceVat()); $this->assertSame(false, $purchaseTransaction->getRaiseWarning()); $this->assertEquals(Office::fromCode('001'), $purchaseTransaction->getOffice()); $this->assertSame('INK', $purchaseTransaction->getCode()); diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index 4b110df6..255f69fa 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -50,7 +50,7 @@ public function testGetSalesTransactionWorks() $this->assertInstanceOf(SalesTransaction::class, $salesTransaction); $this->assertEquals(Destiny::TEMPORARY(), $salesTransaction->getDestiny()); - $this->assertNull($salesTransaction->isAutoBalanceVat()); + $this->assertNull($salesTransaction->getAutoBalanceVat()); $this->assertSame(false, $salesTransaction->getRaiseWarning()); $this->assertEquals(Office::fromCode('001'), $salesTransaction->getOffice()); $this->assertSame('SLS', $salesTransaction->getCode()); diff --git a/tests/UnitTests/BankTransactionUnitTest.php b/tests/UnitTests/BankTransactionUnitTest.php index 6c82268b..85285f84 100644 --- a/tests/UnitTests/BankTransactionUnitTest.php +++ b/tests/UnitTests/BankTransactionUnitTest.php @@ -23,6 +23,7 @@ protected function setUp() public function testSetStartValue() { $this->bankTransaction->setStartValue(Money::EUR(100)); + $this->bankTransaction->setCurrencyFromString('EUR'); $this->assertEquals('EUR', $this->bankTransaction->getCurrencyToString()); $this->assertEquals(Money::EUR(100), $this->bankTransaction->getStartValue()); From 9d80a55b49c907988a8c525b2833efad179515ff Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 20 May 2019 21:12:36 +0200 Subject: [PATCH 227/388] Upload --- src/BankTransaction.php | 2 +- src/CashTransaction.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BankTransaction.php b/src/BankTransaction.php index e7c1dac1..b7a39c31 100644 --- a/src/BankTransaction.php +++ b/src/BankTransaction.php @@ -52,7 +52,7 @@ public function addLine($line) } } - if ($line->getDebitCredit()->equals(DebitCredit::CREDIT())) {. + if ($line->getDebitCredit()->equals(DebitCredit::CREDIT())) { $this->closeValue = $this->getCloseValue()->add($line->startValue()); } else { $this->closeValue = $this->getCloseValue()->subtract($line->startValue()); diff --git a/src/CashTransaction.php b/src/CashTransaction.php index de8c3368..ae91fa7f 100644 --- a/src/CashTransaction.php +++ b/src/CashTransaction.php @@ -52,7 +52,7 @@ public function addLine($line) } } - if ($line->getDebitCredit()->equals(DebitCredit::CREDIT())) {. + if ($line->getDebitCredit()->equals(DebitCredit::CREDIT())) { $this->closeValue = $this->getCloseValue()->add($line->startValue()); } else { $this->closeValue = $this->getCloseValue()->subtract($line->startValue()); From 4f1cf7136ec3172826a08b052b7bdecea904b98a Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 20 May 2019 21:12:59 +0200 Subject: [PATCH 228/388] Update TransactionsDocument.php --- src/DomDocuments/TransactionsDocument.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DomDocuments/TransactionsDocument.php b/src/DomDocuments/TransactionsDocument.php index 4f4b75d8..dd5499a2 100644 --- a/src/DomDocuments/TransactionsDocument.php +++ b/src/DomDocuments/TransactionsDocument.php @@ -269,7 +269,7 @@ public function addTransaction(BaseTransaction $transaction) } if (!LineType::TOTAL()->equals($transactionLine->getLineType()) && $transactionLine->getVatCode() !== null) { - $vatCodeElement = $this->createNodeWithTextContent('vatcode', $transactionLine->getVatCodeToSring()); + $vatCodeElement = $this->createNodeWithTextContent('vatcode', $transactionLine->getVatCodeToString()); $lineElement->appendChild($vatCodeElement); } } From 900e206ebc239c67c4a8a5bc52e5d5b663a0516f Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 20 May 2019 21:27:25 +0200 Subject: [PATCH 229/388] Upload --- src/BankTransaction.php | 4 ++-- src/BankTransactionLine.php | 17 +++++++++++++++++ src/BaseTransactionLine.php | 16 ---------------- src/CashTransaction.php | 4 ++-- src/CashTransactionLine.php | 17 +++++++++++++++++ src/DomDocuments/TransactionsDocument.php | 4 ++-- src/JournalTransactionLine.php | 19 ++++++++++++++++++- src/PurchaseTransactionLine.php | 17 +++++++++++++++++ src/SalesTransactionLine.php | 17 +++++++++++++++++ 9 files changed, 92 insertions(+), 23 deletions(-) diff --git a/src/BankTransaction.php b/src/BankTransaction.php index b7a39c31..c4a86ef3 100644 --- a/src/BankTransaction.php +++ b/src/BankTransaction.php @@ -53,9 +53,9 @@ public function addLine($line) } if ($line->getDebitCredit()->equals(DebitCredit::CREDIT())) { - $this->closeValue = $this->getCloseValue()->add($line->startValue()); + $this->closeValue = $this->getCloseValue()->add($line->getStartValue()); } else { - $this->closeValue = $this->getCloseValue()->subtract($line->startValue()); + $this->closeValue = $this->getCloseValue()->subtract($line->getStartValue()); } return $this; diff --git a/src/BankTransactionLine.php b/src/BankTransactionLine.php index 69f7c4d8..c865974d 100644 --- a/src/BankTransactionLine.php +++ b/src/BankTransactionLine.php @@ -5,6 +5,7 @@ use Money\Money; use PhpTwinfield\Enums\LineType; use PhpTwinfield\Enums\PerformanceType; +use PhpTwinfield\Enums\MatchStatus; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PerformanceTypeField; use PhpTwinfield\Fields\Transaction\TransactionLine\CurrencyDateField; @@ -153,6 +154,22 @@ public function setMatchLevel(?int $matchLevel): parent return parent::setMatchLevel($matchLevel); } + /* + * Payment status of the transaction. If line type total or vat always notmatchable. Read-only attribute. + * + * @param MatchStatus|null $matchStatus + * @return $this + * @throws Exception + */ + public function setMatchStatus(?MatchStatus $matchStatus): parent + { + if ($matchStatus !== null && in_array($this->getLineType(), [LineType::TOTAL(), LineType::VAT()]) && $matchStatus != MatchStatus::NOTMATCHABLE()) { + throw Exception::invalidMatchStatusForLineType($matchStatus, $this); + } + + return parent::setMatchStatus($matchStatus); + } + /* * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The performance type. * diff --git a/src/BaseTransactionLine.php b/src/BaseTransactionLine.php index 3d0396b3..59e412c1 100644 --- a/src/BaseTransactionLine.php +++ b/src/BaseTransactionLine.php @@ -81,22 +81,6 @@ public function getReference(): MatchReferenceInterface ); } - /* - * Payment status of the transaction. If line type total or vat always notmatchable. Read-only attribute. - * - * @param MatchStatus|null $matchStatus - * @return $this - * @throws Exception - */ - public function setMatchStatus(?MatchStatus $matchStatus): self - { - if ($matchStatus !== null && in_array($this->getLineType(), [LineType::TOTAL(), LineType::VAT()]) && $matchStatus != MatchStatus::NOTMATCHABLE()) { - throw Exception::invalidMatchStatusForLineType($matchStatus, $this); - } - - return $this; - } - /* * Only if line type is vat. Amount on which VAT was calculated in base currency. * diff --git a/src/CashTransaction.php b/src/CashTransaction.php index ae91fa7f..57a8f9fa 100644 --- a/src/CashTransaction.php +++ b/src/CashTransaction.php @@ -53,9 +53,9 @@ public function addLine($line) } if ($line->getDebitCredit()->equals(DebitCredit::CREDIT())) { - $this->closeValue = $this->getCloseValue()->add($line->startValue()); + $this->closeValue = $this->getCloseValue()->add($line->getStartValue()); } else { - $this->closeValue = $this->getCloseValue()->subtract($line->startValue()); + $this->closeValue = $this->getCloseValue()->subtract($line->getStartValue()); } return $this; diff --git a/src/CashTransactionLine.php b/src/CashTransactionLine.php index f3011e23..a5d6f73e 100644 --- a/src/CashTransactionLine.php +++ b/src/CashTransactionLine.php @@ -5,6 +5,7 @@ use Money\Money; use PhpTwinfield\Enums\LineType; use PhpTwinfield\Enums\PerformanceType; +use PhpTwinfield\Enums\MatchStatus; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PerformanceTypeField; use PhpTwinfield\Fields\Transaction\TransactionLine\CurrencyDateField; @@ -153,6 +154,22 @@ public function setMatchLevel(?int $matchLevel): parent return parent::setMatchLevel($matchLevel); } + /* + * Payment status of the transaction. If line type total or vat always notmatchable. Read-only attribute. + * + * @param MatchStatus|null $matchStatus + * @return $this + * @throws Exception + */ + public function setMatchStatus(?MatchStatus $matchStatus): parent + { + if ($matchStatus !== null && in_array($this->getLineType(), [LineType::TOTAL(), LineType::VAT()]) && $matchStatus != MatchStatus::NOTMATCHABLE()) { + throw Exception::invalidMatchStatusForLineType($matchStatus, $this); + } + + return parent::setMatchStatus($matchStatus); + } + /* * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The performance type. * diff --git a/src/DomDocuments/TransactionsDocument.php b/src/DomDocuments/TransactionsDocument.php index dd5499a2..91143688 100644 --- a/src/DomDocuments/TransactionsDocument.php +++ b/src/DomDocuments/TransactionsDocument.php @@ -53,10 +53,10 @@ public function addTransaction(BaseTransaction $transaction) $transactionElement->setAttribute('destiny', $transaction->getDestiny()); if ($transaction->getRaiseWarning() !== null) { - $transactionElement->appendChild($this->createNodeWithTextContent('raisewarning', $transaction->getRaiseWarningToString())); + $transactionElement->setAttribute('raisewarning', $transaction->getRaiseWarningToString()); } if ($transaction->getAutoBalanceVat() !== null) { - $transactionElement->appendChild($this->createNodeWithTextContent('autobalancevat', $transaction->getAutoBalanceVatToString())); + $transactionElement->setAttribute('autobalancevat', $transaction->getAutoBalanceVatToString()); } $this->rootElement->appendChild($transactionElement); diff --git a/src/JournalTransactionLine.php b/src/JournalTransactionLine.php index 07ffb00c..1a1bfa4a 100644 --- a/src/JournalTransactionLine.php +++ b/src/JournalTransactionLine.php @@ -5,6 +5,7 @@ use Money\Money; use PhpTwinfield\Enums\LineType; use PhpTwinfield\Enums\PerformanceType; +use PhpTwinfield\Enums\MatchStatus; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PerformanceTypeField; use PhpTwinfield\Fields\Transaction\InvoiceNumberField; @@ -192,7 +193,23 @@ public function setMatchLevel(?int $matchLevel): parent return parent::setMatchLevel($matchLevel); } - /* + /* + * Payment status of the transaction. If line type vat always notmatchable. Read-only attribute. + * + * @param MatchStatus|null $matchStatus + * @return $this + * @throws Exception + */ + public function setMatchStatus(?MatchStatus $matchStatus): parent + { + if ($matchStatus !== null && in_array($this->getLineType(), [LineType::VAT()]) && $matchStatus != MatchStatus::NOTMATCHABLE()) { + throw Exception::invalidMatchStatusForLineType($matchStatus, $this); + } + + return parent::setMatchStatus($matchStatus); + } + + /* * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The performance type. * * @param PerformanceType|null $performanceType diff --git a/src/PurchaseTransactionLine.php b/src/PurchaseTransactionLine.php index e09e9237..91c0f4a0 100644 --- a/src/PurchaseTransactionLine.php +++ b/src/PurchaseTransactionLine.php @@ -5,6 +5,7 @@ use Money\Money; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\LineType; +use PhpTwinfield\Enums\MatchStatus; use PhpTwinfield\Fields\Transaction\TransactionLine\BaselineField; use PhpTwinfield\Fields\Transaction\TransactionLine\MatchDateField; use PhpTwinfield\Fields\Transaction\TransactionLine\ValueOpenField; @@ -143,6 +144,22 @@ public function setMatchLevel(?int $matchLevel): parent return parent::setMatchLevel($matchLevel); } + + /* + * Payment status of the transaction. If line type detail or vat always notmatchable. Read-only attribute. + * + * @param MatchStatus|null $matchStatus + * @return $this + * @throws Exception + */ + public function setMatchStatus(?MatchStatus $matchStatus): parent + { + if ($matchStatus !== null && in_array($this->getLineType(), [LineType::DETAIL(), LineType::VAT()]) && $matchStatus != MatchStatus::NOTMATCHABLE()) { + throw Exception::invalidMatchStatusForLineType($matchStatus, $this); + } + + return parent::setMatchStatus($matchStatus); + } /* * Relation of the transaction. Only if line type is total. Read-only attribute. diff --git a/src/SalesTransactionLine.php b/src/SalesTransactionLine.php index 0f93d9c8..58b3b40b 100644 --- a/src/SalesTransactionLine.php +++ b/src/SalesTransactionLine.php @@ -5,6 +5,7 @@ use Money\Money; use PhpTwinfield\Enums\LineType; use PhpTwinfield\Enums\PerformanceType; +use PhpTwinfield\Enums\MatchStatus; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PerformanceTypeField; use PhpTwinfield\Fields\Transaction\TransactionLine\BaselineField; @@ -153,6 +154,22 @@ public function setMatchLevel(?int $matchLevel): parent return parent::setMatchLevel($matchLevel); } + + /* + * Payment status of the transaction. If line type detail or vat always notmatchable. Read-only attribute. + * + * @param MatchStatus|null $matchStatus + * @return $this + * @throws Exception + */ + public function setMatchStatus(?MatchStatus $matchStatus): parent + { + if ($matchStatus !== null && in_array($this->getLineType(), [LineType::DETAIL(), LineType::VAT()]) && $matchStatus != MatchStatus::NOTMATCHABLE()) { + throw Exception::invalidMatchStatusForLineType($matchStatus, $this); + } + + return parent::setMatchStatus($matchStatus); + } /* * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The performance type. From 352c0bba757cafa1ec17388000330325057569f2 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 20 May 2019 21:37:07 +0200 Subject: [PATCH 230/388] Upload --- src/BankTransaction.php | 4 ++-- src/BaseTransactionLine.php | 12 ++++++------ src/CashTransaction.php | 4 ++-- src/DomDocuments/MatchDocument.php | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/BankTransaction.php b/src/BankTransaction.php index c4a86ef3..9dac1fe9 100644 --- a/src/BankTransaction.php +++ b/src/BankTransaction.php @@ -53,9 +53,9 @@ public function addLine($line) } if ($line->getDebitCredit()->equals(DebitCredit::CREDIT())) { - $this->closeValue = $this->getCloseValue()->add($line->getStartValue()); + $this->closeValue = $this->getCloseValue()->add($this->getStartValue()); } else { - $this->closeValue = $this->getCloseValue()->subtract($line->getStartValue()); + $this->closeValue = $this->getCloseValue()->subtract($this->getStartValue()); } return $this; diff --git a/src/BaseTransactionLine.php b/src/BaseTransactionLine.php index 59e412c1..38c60855 100644 --- a/src/BaseTransactionLine.php +++ b/src/BaseTransactionLine.php @@ -91,9 +91,9 @@ public function getReference(): MatchReferenceInterface public function setVatBaseTurnover(?Money $vatBaseTurnover): self { if (!$this->getLineType()->equals(LineType::VAT())) { - throw Exception::invalidFieldForLineType('vatbaseturnover', $this); + throw Exception::invalidFieldForLineType('vatBaseTurnover', $this); } - + return $this; } @@ -138,9 +138,9 @@ public function setVatCode(?VatCode $vatCode): self public function setVatRepTurnover(?Money $vatRepTurnover): self { if (!$this->getLineType()->equals(LineType::VAT())) { - throw Exception::invalidFieldForLineType('vatrepturnover', $this); + throw Exception::invalidFieldForLineType('vatRepTurnover', $this); } - + return $this; } @@ -169,9 +169,9 @@ public function setVatRepValue(?Money $vatRepValue): self public function setVatTurnover(?Money $vatTurnover): self { if (!$this->getLineType()->equals(LineType::VAT())) { - throw Exception::invalidFieldForLineType('vatturnover', $this); + throw Exception::invalidFieldForLineType('vatTurnover', $this); } - + return $this; } diff --git a/src/CashTransaction.php b/src/CashTransaction.php index 57a8f9fa..160106e0 100644 --- a/src/CashTransaction.php +++ b/src/CashTransaction.php @@ -53,9 +53,9 @@ public function addLine($line) } if ($line->getDebitCredit()->equals(DebitCredit::CREDIT())) { - $this->closeValue = $this->getCloseValue()->add($line->getStartValue()); + $this->closeValue = $this->getCloseValue()->add($this->getStartValue()); } else { - $this->closeValue = $this->getCloseValue()->subtract($line->getStartValue()); + $this->closeValue = $this->getCloseValue()->subtract($this->getStartValue()); } return $this; diff --git a/src/DomDocuments/MatchDocument.php b/src/DomDocuments/MatchDocument.php index 42eb7b02..5c682b3d 100644 --- a/src/DomDocuments/MatchDocument.php +++ b/src/DomDocuments/MatchDocument.php @@ -12,7 +12,7 @@ public function addMatchSet(MatchSet $matchSet) { $set = $this->createElement("set"); - $set->appendChild($this->createNodeWithTextContent('office', $transaction->getOfficeToString())); + $set->appendChild($this->createNodeWithTextContent('office', $matchSet->getOfficeToString())); $set->appendChild($this->createNodeWithTextContent("matchcode", $matchSet->getMatchCode()->getValue())); From 501813c66340a64ed17b65665b029320a12ddb25 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 20 May 2019 22:21:29 +0200 Subject: [PATCH 231/388] Upload --- src/DomDocuments/TransactionsDocument.php | 8 ++--- .../TransactionLine/MatchDateField.php | 2 +- src/MatchSet.php | 35 ++++--------------- 3 files changed, 11 insertions(+), 34 deletions(-) diff --git a/src/DomDocuments/TransactionsDocument.php b/src/DomDocuments/TransactionsDocument.php index 91143688..4cb306c2 100644 --- a/src/DomDocuments/TransactionsDocument.php +++ b/src/DomDocuments/TransactionsDocument.php @@ -16,6 +16,7 @@ use PhpTwinfield\Fields\Transaction\InvoiceNumberField; use PhpTwinfield\Fields\Transaction\PaymentReferenceField; use PhpTwinfield\Fields\Transaction\StatementNumberField; +use PhpTwinfield\Fields\Transaction\TransactionLine\BaselineField; use PhpTwinfield\Fields\Transaction\TransactionLine\FreeCharField; use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceCountryField; use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceVatNumberField; @@ -256,11 +257,8 @@ public function addTransaction(BaseTransaction $transaction) $lineElement->appendChild($vatElement); } - $baseline = $transactionLine->getBaseline(); - - if (!empty($baseline)) { - $baselineElement = $this->createNodeWithTextContent('baseline', $baseline); - $lineElement->appendChild($baselineElement); + if (Util::objectUses(BaselineField::class, $transactionLine) && $transactionLine->getBaseline() !== null) { + $lineElement->appendChild($this->createNodeWithTextContent('baseline', $transactionLine->getBaseline())); } if ($transactionLine->getDescription() !== null) { diff --git a/src/Fields/Transaction/TransactionLine/MatchDateField.php b/src/Fields/Transaction/TransactionLine/MatchDateField.php index d73b4d70..427a1758 100644 --- a/src/Fields/Transaction/TransactionLine/MatchDateField.php +++ b/src/Fields/Transaction/TransactionLine/MatchDateField.php @@ -7,7 +7,7 @@ /** * Match date field - * Used by: PurchaseTransactionLine + * Used by: MatchSet, PurchaseTransactionLine * * @package PhpTwinfield\Traits * @see Util::formatDateTime() diff --git a/src/MatchSet.php b/src/MatchSet.php index 2adaa722..4f02f5a8 100644 --- a/src/MatchSet.php +++ b/src/MatchSet.php @@ -2,11 +2,14 @@ namespace PhpTwinfield; +use PhpTwinfield\Enums\MatchCode; use PhpTwinfield\Fields\OfficeField; +use PhpTwinfield\Fields\Transaction\TransactionLine\MatchDateField; use Webmozart\Assert\Assert; class MatchSet { + use MatchDateField; use OfficeField; /** @@ -14,54 +17,30 @@ class MatchSet */ private $matchCode; - /** - * @var \DateTimeInterface - */ - private $matchDate; - /** * @var MatchLine[] */ private $lines = []; /** - * @return Enums\MatchCode + * @return MatchCode */ - public function getMatchCode(): Enums\MatchCode + public function getMatchCode(): MatchCode { return $this->matchCode; } /** - * @param Enums\MatchCode $matchCode + * @param MatchCode $matchCode * @return $this */ - public function setMatchCode(Enums\MatchCode $matchCode) + public function setMatchCode(MatchCode $matchCode) { $this->matchCode = $matchCode; return $this; } - /** - * @return \DateTimeInterface - */ - public function getMatchDate(): \DateTimeInterface - { - return $this->matchDate; - } - - /** - * @param \DateTimeInterface $matchDate - * @return $this - */ - public function setMatchDate(\DateTimeInterface $matchDate) - { - $this->matchDate = $matchDate; - - return $this; - } - /** * @param MatchLine $line * @internal Don't call this, use \PhpTwinfield\MatchLine::addToMatchSet From cf55a0f98e2c7defaa5ab59ca1ab753d208ad993 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 20 May 2019 23:30:05 +0200 Subject: [PATCH 232/388] Upload --- .../Transaction/TransactionLine/CurrencyDateField.php | 8 ++++---- src/Fields/Transaction/TransactionLine/MatchDateField.php | 8 ++++---- tests/UnitTests/CashTransactionUnitTest.php | 1 + .../ElectronicBankStatementDocumentUnitTest.php | 8 ++++---- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Fields/Transaction/TransactionLine/CurrencyDateField.php b/src/Fields/Transaction/TransactionLine/CurrencyDateField.php index 0494a312..7737fa49 100644 --- a/src/Fields/Transaction/TransactionLine/CurrencyDateField.php +++ b/src/Fields/Transaction/TransactionLine/CurrencyDateField.php @@ -10,8 +10,8 @@ * Used by: BankTransactionLine, CashTransactionLine, JournalTransactionLine * * @package PhpTwinfield\Traits - * @see Util::formatDateTime() - * @see Util::parseDateTime() + * @see Util::formatDate() + * @see Util::parseDate() */ trait CurrencyDateField { @@ -34,7 +34,7 @@ public function getCurrencyDate(): ?\DateTimeInterface public function getCurrencyDateToString(): ?string { if ($this->getCurrencyDate() != null) { - return Util::formatDateTime($this->getCurrencyDate()); + return Util::formatDate($this->getCurrencyDate()); } else { return null; } @@ -58,7 +58,7 @@ public function setCurrencyDate(?\DateTimeInterface $currencyDate) public function setCurrencyDateFromString(?string $currencyDateString) { if ((bool)strtotime($currencyDateString)) { - return $this->setCurrencyDate(Util::parseDateTime($currencyDateString)); + return $this->setCurrencyDate(Util::parseDate($currencyDateString)); } else { return $this->setCurrencyDate(null); } diff --git a/src/Fields/Transaction/TransactionLine/MatchDateField.php b/src/Fields/Transaction/TransactionLine/MatchDateField.php index 427a1758..a21dc0a9 100644 --- a/src/Fields/Transaction/TransactionLine/MatchDateField.php +++ b/src/Fields/Transaction/TransactionLine/MatchDateField.php @@ -10,8 +10,8 @@ * Used by: MatchSet, PurchaseTransactionLine * * @package PhpTwinfield\Traits - * @see Util::formatDateTime() - * @see Util::parseDateTime() + * @see Util::formatDate() + * @see Util::parseDate() */ trait MatchDateField { @@ -34,7 +34,7 @@ public function getMatchDate(): ?\DateTimeInterface public function getMatchDateToString(): ?string { if ($this->getMatchDate() != null) { - return Util::formatDateTime($this->getMatchDate()); + return Util::formatDate($this->getMatchDate()); } else { return null; } @@ -58,7 +58,7 @@ public function setMatchDate(?\DateTimeInterface $matchDate) public function setMatchDateFromString(?string $matchDateString) { if ((bool)strtotime($matchDateString)) { - return $this->setMatchDate(Util::parseDateTime($matchDateString)); + return $this->setMatchDate(Util::parseDate($matchDateString)); } else { return $this->setMatchDate(null); } diff --git a/tests/UnitTests/CashTransactionUnitTest.php b/tests/UnitTests/CashTransactionUnitTest.php index b07f4169..ae0f67aa 100644 --- a/tests/UnitTests/CashTransactionUnitTest.php +++ b/tests/UnitTests/CashTransactionUnitTest.php @@ -23,6 +23,7 @@ protected function setUp() public function testSetStartValue() { $this->cashTransaction->setStartValue(Money::EUR(100)); + $this->cashTransaction->setCurrencyFromString('EUR'); $this->assertEquals('EUR', $this->cashTransaction->getCurrencyToString()); $this->assertEquals(Money::EUR(100), $this->cashTransaction->getStartValue()); diff --git a/tests/UnitTests/DomDocuments/ElectronicBankStatementDocumentUnitTest.php b/tests/UnitTests/DomDocuments/ElectronicBankStatementDocumentUnitTest.php index bd4715af..e7d4dbaa 100644 --- a/tests/UnitTests/DomDocuments/ElectronicBankStatementDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/ElectronicBankStatementDocumentUnitTest.php @@ -45,13 +45,13 @@ public function testDocumentationExampleCreatedSuccessfully() N100 credit - 151.00 + 151 Invoice 3722838 N999 debit - 7.50 + 7.5 Costs *300 @@ -78,8 +78,8 @@ public function testImportDuplicateIsSet() 20171130 EUR - 0.00 - 0.00 + 0 + 0 236 From 39fe6daaaaddfca08fee3161c8cdb930dde8ce1e Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 00:00:27 +0200 Subject: [PATCH 233/388] Upload --- src/BankTransactionLine.php | 20 ++++++++++---------- src/BaseTransactionLine.php | 14 +++++++------- src/CashTransactionLine.php | 22 +++++++++++----------- src/JournalTransactionLine.php | 18 +++++++++--------- src/Mappers/MatchSetMapper.php | 8 +++++--- src/PurchaseTransactionLine.php | 16 ++++++++-------- src/SalesTransactionLine.php | 24 ++++++++++++------------ 7 files changed, 62 insertions(+), 60 deletions(-) diff --git a/src/BankTransactionLine.php b/src/BankTransactionLine.php index c865974d..cf735116 100644 --- a/src/BankTransactionLine.php +++ b/src/BankTransactionLine.php @@ -62,7 +62,7 @@ public function getTransaction(): BankTransaction public function setBaseValueOpen(?Money $baseValueOpen): parent { if ($baseValueOpen !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('baseValueOpen', $this); + throw Exception::invalidFieldForLineType('basevalueopen', $this); } return parent::setBaseValueOpen($baseValueOpen); @@ -78,7 +78,7 @@ public function setBaseValueOpen(?Money $baseValueOpen): parent public function setCurrencyDate(?\DateTimeInterface $currencyDate): self { if ($currencyDate !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('currencyDate', $this); + throw Exception::invalidFieldForLineType('currencydate', $this); } return $this; @@ -148,7 +148,7 @@ protected function isIncomingTransactionType(): bool public function setMatchLevel(?int $matchLevel): parent { if ($matchLevel !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('matchLevel', $this); + throw Exception::invalidFieldForLineType('matchlevel', $this); } return parent::setMatchLevel($matchLevel); @@ -180,7 +180,7 @@ public function setMatchStatus(?MatchStatus $matchStatus): parent public function setPerformanceType(?PerformanceType $performanceType): self { if ($performanceType !== null && $this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('performanceType', $this); + throw Exception::invalidFieldForLineType('performancetype', $this); } return $this; @@ -196,7 +196,7 @@ public function setPerformanceType(?PerformanceType $performanceType): self public function setPerformanceCountry(?Country $performanceCountry): self { if ($performanceCountry !== null && $this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('performanceCountry', $this); + throw Exception::invalidFieldForLineType('performancecountry', $this); } return $this; @@ -212,7 +212,7 @@ public function setPerformanceCountry(?Country $performanceCountry): self public function setPerformanceVatNumber(?string $performanceVatNumber): self { if ($performanceVatNumber !== null && $this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('performanceVatNumber', $this); + throw Exception::invalidFieldForLineType('performancevatnumber', $this); } return $this; @@ -228,7 +228,7 @@ public function setPerformanceVatNumber(?string $performanceVatNumber): self public function setPerformanceDate(?\DateTimeInterface $performanceDate): self { if ($performanceDate !== null && (!$this->getPerformanceType()->equals(PerformanceType::SERVICES()) || $this->getLineType()->equals(LineType::TOTAL()))) { - throw Exception::invalidFieldForLineType('performanceDate', $this); + throw Exception::invalidFieldForLineType('performancedate', $this); } return $this; @@ -260,7 +260,7 @@ public function setRelation(?int $relation): parent public function setRepValueOpen(?Money $repValueOpen): parent { if ($repValueOpen !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('repValueOpen', $this); + throw Exception::invalidFieldForLineType('repvalueopen', $this); } return parent::setRepValueOpen($repValueOpen); @@ -292,7 +292,7 @@ public function setVatTotal(?Money $vatTotal): self public function setVatBaseTotal(?Money $vatBaseTotal): self { if ($vatBaseTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatBaseTotal', $this); + throw Exception::invalidFieldForLineType('vatbasetotal', $this); } return $this; @@ -308,7 +308,7 @@ public function setVatBaseTotal(?Money $vatBaseTotal): self public function setVatRepTotal(?Money $vatRepTotal): self { if ($vatRepTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatRepTotal', $this); + throw Exception::invalidFieldForLineType('vatreptotal', $this); } return $this; diff --git a/src/BaseTransactionLine.php b/src/BaseTransactionLine.php index 38c60855..a6025c6e 100644 --- a/src/BaseTransactionLine.php +++ b/src/BaseTransactionLine.php @@ -91,7 +91,7 @@ public function getReference(): MatchReferenceInterface public function setVatBaseTurnover(?Money $vatBaseTurnover): self { if (!$this->getLineType()->equals(LineType::VAT())) { - throw Exception::invalidFieldForLineType('vatBaseTurnover', $this); + throw Exception::invalidFieldForLineType('vatbaseturnover', $this); } return $this; @@ -105,7 +105,7 @@ public function setVatBaseTurnover(?Money $vatBaseTurnover): self public function setVatBaseValue(?Money $vatBaseValue): self { if ($vatBaseValue !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('vatBaseValue', $this); + throw Exception::invalidFieldForLineType('vatbasevalue', $this); } $this->vatBaseValue = $vatBaseValue; @@ -121,7 +121,7 @@ public function setVatBaseValue(?Money $vatBaseValue): self public function setVatCode(?VatCode $vatCode): self { if ($vatCode !== null && !in_array($this->getLineType(), [LineType::DETAIL(), LineType::VAT()])) { - throw Exception::invalidFieldForLineType('vatCode', $this); + throw Exception::invalidFieldForLineType('vatcode', $this); } $this->vatCode = $vatCode; @@ -138,7 +138,7 @@ public function setVatCode(?VatCode $vatCode): self public function setVatRepTurnover(?Money $vatRepTurnover): self { if (!$this->getLineType()->equals(LineType::VAT())) { - throw Exception::invalidFieldForLineType('vatRepTurnover', $this); + throw Exception::invalidFieldForLineType('vatrepturnover', $this); } return $this; @@ -152,7 +152,7 @@ public function setVatRepTurnover(?Money $vatRepTurnover): self public function setVatRepValue(?Money $vatRepValue): self { if ($vatRepValue !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('vatRepValue', $this); + throw Exception::invalidFieldForLineType('vatrepvalue', $this); } $this->vatRepValue = $vatRepValue; @@ -169,7 +169,7 @@ public function setVatRepValue(?Money $vatRepValue): self public function setVatTurnover(?Money $vatTurnover): self { if (!$this->getLineType()->equals(LineType::VAT())) { - throw Exception::invalidFieldForLineType('vatTurnover', $this); + throw Exception::invalidFieldForLineType('vatturnover', $this); } return $this; @@ -183,7 +183,7 @@ public function setVatTurnover(?Money $vatTurnover): self public function setVatValue(?Money $vatValue): self { if ($vatValue !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('vatValue', $this); + throw Exception::invalidFieldForLineType('vatvalue', $this); } $this->vatValue = $vatValue; diff --git a/src/CashTransactionLine.php b/src/CashTransactionLine.php index a5d6f73e..51537a35 100644 --- a/src/CashTransactionLine.php +++ b/src/CashTransactionLine.php @@ -62,7 +62,7 @@ public function getTransaction(): CashTransaction public function setBaseValueOpen(?Money $baseValueOpen): parent { if ($baseValueOpen !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('baseValueOpen', $this); + throw Exception::invalidFieldForLineType('basevalueopen', $this); } return parent::setBaseValueOpen($baseValueOpen); @@ -78,7 +78,7 @@ public function setBaseValueOpen(?Money $baseValueOpen): parent public function setCurrencyDate(?\DateTimeInterface $currencyDate): self { if ($currencyDate !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('currencyDate', $this); + throw Exception::invalidFieldForLineType('currencydate', $this); } return $this; @@ -148,7 +148,7 @@ protected function isIncomingTransactionType(): bool public function setMatchLevel(?int $matchLevel): parent { if ($matchLevel !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('matchLevel', $this); + throw Exception::invalidFieldForLineType('matchlevel', $this); } return parent::setMatchLevel($matchLevel); @@ -180,7 +180,7 @@ public function setMatchStatus(?MatchStatus $matchStatus): parent public function setPerformanceType(?PerformanceType $performanceType): self { if ($performanceType !== null && $this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('performanceType', $this); + throw Exception::invalidFieldForLineType('performancetype', $this); } return $this; @@ -196,7 +196,7 @@ public function setPerformanceType(?PerformanceType $performanceType): self public function setPerformanceCountry(?Country $performanceCountry): self { if ($performanceCountry !== null && $this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('performanceCountry', $this); + throw Exception::invalidFieldForLineType('performancecountry', $this); } return $this; @@ -212,7 +212,7 @@ public function setPerformanceCountry(?Country $performanceCountry): self public function setPerformanceVatNumber(?string $performanceVatNumber): self { if ($performanceVatNumber !== null && $this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('performanceVatNumber', $this); + throw Exception::invalidFieldForLineType('performancevatnumber', $this); } return $this; @@ -228,7 +228,7 @@ public function setPerformanceVatNumber(?string $performanceVatNumber): self public function setPerformanceDate(?\DateTimeInterface $performanceDate): self { if ($performanceDate !== null && (!$this->getPerformanceType()->equals(PerformanceType::SERVICES()) || $this->getLineType()->equals(LineType::TOTAL()))) { - throw Exception::invalidFieldForLineType('performanceDate', $this); + throw Exception::invalidFieldForLineType('performancedate', $this); } return $this; @@ -260,7 +260,7 @@ public function setRelation(?int $relation): parent public function setRepValueOpen(?Money $repValueOpen): parent { if ($repValueOpen !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('repValueOpen', $this); + throw Exception::invalidFieldForLineType('repvalueopen', $this); } return parent::setRepValueOpen($repValueOpen); @@ -276,7 +276,7 @@ public function setRepValueOpen(?Money $repValueOpen): parent public function setVatTotal(?Money $vatTotal): self { if ($vatTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatTotal', $this); + throw Exception::invalidFieldForLineType('vattotal', $this); } return $this; @@ -292,7 +292,7 @@ public function setVatTotal(?Money $vatTotal): self public function setVatBaseTotal(?Money $vatBaseTotal): self { if ($vatBaseTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatBaseTotal', $this); + throw Exception::invalidFieldForLineType('vatbasetotal', $this); } return $this; @@ -308,7 +308,7 @@ public function setVatBaseTotal(?Money $vatBaseTotal): self public function setVatRepTotal(?Money $vatRepTotal): self { if ($vatRepTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatRepTotal', $this); + throw Exception::invalidFieldForLineType('vatreptotal', $this); } return $this; diff --git a/src/JournalTransactionLine.php b/src/JournalTransactionLine.php index 1a1bfa4a..66a5176d 100644 --- a/src/JournalTransactionLine.php +++ b/src/JournalTransactionLine.php @@ -76,7 +76,7 @@ public function setBaseline(?int $baseline): self public function setBaseValueOpen(?Money $baseValueOpen): parent { if ($baseValueOpen !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('baseValueOpen', $this); + throw Exception::invalidFieldForLineType('basevalueopen', $this); } return parent::setBaseValueOpen($baseValueOpen); @@ -92,7 +92,7 @@ public function setBaseValueOpen(?Money $baseValueOpen): parent public function setCurrencyDate(?\DateTimeInterface $currencyDate): self { if ($currencyDate !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('currencyDate', $this); + throw Exception::invalidFieldForLineType('currencydate', $this); } return $this; @@ -142,7 +142,7 @@ public function setDim3($dim3): parent public function setInvoiceNumber(?string $invoiceNumber): self { if ($invoiceNumber !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('invoiceNumber', $this); + throw Exception::invalidFieldForLineType('invoicenumber', $this); } return $this; @@ -187,7 +187,7 @@ public function setLineType(?LineType $lineType): parent public function setMatchLevel(?int $matchLevel): parent { if ($matchLevel !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('matchLevel', $this); + throw Exception::invalidFieldForLineType('matchlevel', $this); } return parent::setMatchLevel($matchLevel); @@ -219,7 +219,7 @@ public function setMatchStatus(?MatchStatus $matchStatus): parent public function setPerformanceType(?PerformanceType $performanceType): self { if ($performanceType !== null && $this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('performanceType', $this); + throw Exception::invalidFieldForLineType('performancetype', $this); } return $this; @@ -235,7 +235,7 @@ public function setPerformanceType(?PerformanceType $performanceType): self public function setPerformanceCountry(?Country $performanceCountry): self { if ($performanceCountry !== null && $this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('performanceCountry', $this); + throw Exception::invalidFieldForLineType('performancecountry', $this); } return $this; @@ -251,7 +251,7 @@ public function setPerformanceCountry(?Country $performanceCountry): self public function setPerformanceVatNumber(?string $performanceVatNumber): self { if ($performanceVatNumber !== null && $this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('performanceVatNumber', $this); + throw Exception::invalidFieldForLineType('performancevatnumber', $this); } return $this; @@ -267,7 +267,7 @@ public function setPerformanceVatNumber(?string $performanceVatNumber): self public function setPerformanceDate(?\DateTimeInterface $performanceDate): self { if ($performanceDate !== null && (!$this->getPerformanceType()->equals(PerformanceType::SERVICES()) || $this->getLineType()->equals(LineType::TOTAL()))) { - throw Exception::invalidFieldForLineType('performanceDate', $this); + throw Exception::invalidFieldForLineType('performancedate', $this); } return $this; @@ -299,7 +299,7 @@ public function setRelation(?int $relation): parent public function setRepValueOpen(?Money $repValueOpen): parent { if ($repValueOpen !== null && !$this->getLineType()->equals(LineType::DETAIL())) { - throw Exception::invalidFieldForLineType('repValueOpen', $this); + throw Exception::invalidFieldForLineType('repvalueopen', $this); } return parent::setRepValueOpen($repValueOpen); diff --git a/src/Mappers/MatchSetMapper.php b/src/Mappers/MatchSetMapper.php index be34f406..cb5daa35 100644 --- a/src/Mappers/MatchSetMapper.php +++ b/src/Mappers/MatchSetMapper.php @@ -29,11 +29,13 @@ public static function map(\DOMDocument $document): MatchSet private static function createMatchSetFrom(\DOMDocument $document): MatchSet { + $MatchSetElement = $document->documentElement; + $matchSet = new MatchSet(); - $matchSet->setOffice(Office::fromCode(self::getField(null, $document, "office"))); - $matchSet->setMatchCode(new MatchCode(self::getField(null, $document, "matchcode"))); - $matchSet->setMatchDate(\DateTimeImmutable::createFromFormat("Ymd", self::getField(null, $document, "matchdate"))); + $matchSet->setOffice(Office::fromCode(self::getField(null, $MatchSetElement, "office"))); + $matchSet->setMatchCode(new MatchCode(self::getField(null, $MatchSetElement, "matchcode"))); + $matchSet->setMatchDate(\DateTimeImmutable::createFromFormat("Ymd", self::getField(null, $MatchSetElement, "matchdate"))); return $matchSet; } diff --git a/src/PurchaseTransactionLine.php b/src/PurchaseTransactionLine.php index 91c0f4a0..91cdda8d 100644 --- a/src/PurchaseTransactionLine.php +++ b/src/PurchaseTransactionLine.php @@ -73,7 +73,7 @@ public function setBaseline(?int $baseline): self public function setBaseValueOpen(?Money $baseValueOpen): parent { if ($baseValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('baseValueOpen', $this); + throw Exception::invalidFieldForLineType('basevalueopen', $this); } return parent::setBaseValueOpen($baseValueOpen); @@ -123,7 +123,7 @@ protected function isIncomingTransactionType(): bool public function setMatchDate(?\DateTimeInterface $matchDate): self { if ($matchDate !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('matchDate', $this); + throw Exception::invalidFieldForLineType('matchdate', $this); } return $this; @@ -139,7 +139,7 @@ public function setMatchDate(?\DateTimeInterface $matchDate): self public function setMatchLevel(?int $matchLevel): parent { if ($matchLevel !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('matchLevel', $this); + throw Exception::invalidFieldForLineType('matchlevel', $this); } return parent::setMatchLevel($matchLevel); @@ -187,7 +187,7 @@ public function setRelation(?int $relation): parent public function setRepValueOpen(?Money $repValueOpen): parent { if ($repValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('repValueOpen', $this); + throw Exception::invalidFieldForLineType('repvalueopen', $this); } return parent::setRepValueOpen($repValueOpen); @@ -203,7 +203,7 @@ public function setRepValueOpen(?Money $repValueOpen): parent public function setValueOpen(?Money $valueOpen): self { if ($valueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('valueOpen', $this); + throw Exception::invalidFieldForLineType('valueopen', $this); } return $this; @@ -219,7 +219,7 @@ public function setValueOpen(?Money $valueOpen): self public function setVatTotal(?Money $vatTotal): self { if ($vatTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatTotal', $this); + throw Exception::invalidFieldForLineType('vattotal', $this); } return $this; @@ -235,7 +235,7 @@ public function setVatTotal(?Money $vatTotal): self public function setVatBaseTotal(?Money $vatBaseTotal): self { if ($vatBaseTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatBaseTotal', $this); + throw Exception::invalidFieldForLineType('vatbasetotal', $this); } return $this; @@ -251,7 +251,7 @@ public function setVatBaseTotal(?Money $vatBaseTotal): self public function setVatRepTotal(?Money $vatRepTotal): self { if ($vatRepTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatRepTotal', $this); + throw Exception::invalidFieldForLineType('vatreptotal', $this); } return $this; diff --git a/src/SalesTransactionLine.php b/src/SalesTransactionLine.php index 58b3b40b..9d20a92e 100644 --- a/src/SalesTransactionLine.php +++ b/src/SalesTransactionLine.php @@ -79,7 +79,7 @@ public function setBaseline(?int $baseline): self public function setBaseValueOpen(?Money $baseValueOpen): parent { if ($baseValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('baseValueOpen', $this); + throw Exception::invalidFieldForLineType('basevalueopen', $this); } return parent::setBaseValueOpen($baseValueOpen); @@ -149,12 +149,12 @@ protected function isIncomingTransactionType(): bool public function setMatchLevel(?int $matchLevel): parent { if ($matchLevel !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('matchLevel', $this); + throw Exception::invalidFieldForLineType('matchlevel', $this); } return parent::setMatchLevel($matchLevel); } - + /* * Payment status of the transaction. If line type detail or vat always notmatchable. Read-only attribute. * @@ -181,7 +181,7 @@ public function setMatchStatus(?MatchStatus $matchStatus): parent public function setPerformanceType(?PerformanceType $performanceType): self { if ($performanceType !== null && $this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('performanceType', $this); + throw Exception::invalidFieldForLineType('performancetype', $this); } return $this; @@ -197,7 +197,7 @@ public function setPerformanceType(?PerformanceType $performanceType): self public function setPerformanceCountry(?Country $performanceCountry): self { if ($performanceCountry !== null && $this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('performanceCountry', $this); + throw Exception::invalidFieldForLineType('performancecountry', $this); } return $this; @@ -213,7 +213,7 @@ public function setPerformanceCountry(?Country $performanceCountry): self public function setPerformanceVatNumber(?string $performanceVatNumber): self { if ($performanceVatNumber !== null && $this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('performanceVatNumber', $this); + throw Exception::invalidFieldForLineType('performancevatnumber', $this); } return $this; @@ -229,7 +229,7 @@ public function setPerformanceVatNumber(?string $performanceVatNumber): self public function setPerformanceDate(?\DateTimeInterface $performanceDate): self { if ($performanceDate !== null && (!$this->getPerformanceType()->equals(PerformanceType::SERVICES()) || $this->getLineType()->equals(LineType::TOTAL()))) { - throw Exception::invalidFieldForLineType('performanceDate', $this); + throw Exception::invalidFieldForLineType('performancedate', $this); } return $this; @@ -261,7 +261,7 @@ public function setRelation(?int $relation): parent public function setRepValueOpen(?Money $reValueOpen): parent { if ($reValueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('reValueOpen', $this); + throw Exception::invalidFieldForLineType('repvalueopen', $this); } return parent::setRepValueOpen($reValueOpen); @@ -277,7 +277,7 @@ public function setRepValueOpen(?Money $reValueOpen): parent public function setValueOpen(?Money $valueOpen): self { if ($valueOpen !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('valueOpen', $this); + throw Exception::invalidFieldForLineType('valueopen', $this); } return $this; @@ -293,7 +293,7 @@ public function setValueOpen(?Money $valueOpen): self public function setVatTotal(?Money $vatTotal): self { if ($vatTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatTotal', $this); + throw Exception::invalidFieldForLineType('vattotal', $this); } return $this; @@ -309,7 +309,7 @@ public function setVatTotal(?Money $vatTotal): self public function setVatBaseTotal(?Money $vatBaseTotal): self { if ($vatBaseTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatBaseTotal', $this); + throw Exception::invalidFieldForLineType('vatbasetotal', $this); } return $this; @@ -325,7 +325,7 @@ public function setVatBaseTotal(?Money $vatBaseTotal): self public function setVatRepTotal(?Money $vatRepTotal): self { if ($vatRepTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatRepTotal', $this); + throw Exception::invalidFieldForLineType('vatreptotal', $this); } return $this; From dd99194c4436ae805250493eb257c5371c18e841 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 08:18:54 +0200 Subject: [PATCH 234/388] Upload --- src/BankTransaction.php | 28 ++-- src/BaseTransaction.php | 6 +- src/CashTransaction.php | 28 ++-- src/ElectronicBankStatement.php | 10 +- .../Transaction/CloseAndStartValueFields.php | 123 ++++++++++++++++++ src/Fields/Transaction/CloseValueField.php | 62 --------- 6 files changed, 161 insertions(+), 96 deletions(-) create mode 100644 src/Fields/Transaction/CloseAndStartValueFields.php delete mode 100644 src/Fields/Transaction/CloseValueField.php diff --git a/src/BankTransaction.php b/src/BankTransaction.php index 9dac1fe9..9e35465d 100644 --- a/src/BankTransaction.php +++ b/src/BankTransaction.php @@ -5,8 +5,7 @@ use PhpTwinfield\BankTransactionLine; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\LineType; -use PhpTwinfield\Fields\Transaction\CloseValueField; -use PhpTwinfield\Fields\Transaction\StartValueField; +use PhpTwinfield\Fields\Transaction\CloseAndStartValueFields; use PhpTwinfield\Fields\Transaction\StatementNumberField; /* @@ -14,13 +13,14 @@ */ class BankTransaction extends BaseTransaction { - use CloseValueField; - use StartValueField; + use CloseAndStartValueFields { + setCurrency as protected traitSetCurrency; + } + use StatementNumberField; public function __construct() { - $this->closeValue = new \Money\Money(0, new \Money\Currency('EUR')); $this->startValue = new \Money\Money(0, new \Money\Currency('EUR')); } @@ -32,6 +32,18 @@ public function getLineClassName(): string return BankTransactionLine::class; } + /* + * Set the currency. Can only be done when the start value is still 0. + * + * @param Currency $currency + * @return $this + */ + public function setCurrency(?Currency $currency): parent + { + $this->traitSetCurrency($currency); + return $this; + } + /* * @param $line * @return $this @@ -52,12 +64,6 @@ public function addLine($line) } } - if ($line->getDebitCredit()->equals(DebitCredit::CREDIT())) { - $this->closeValue = $this->getCloseValue()->add($this->getStartValue()); - } else { - $this->closeValue = $this->getCloseValue()->subtract($this->getStartValue()); - } - return $this; } } diff --git a/src/BaseTransaction.php b/src/BaseTransaction.php index 31f840f5..8e7b4847 100644 --- a/src/BaseTransaction.php +++ b/src/BaseTransaction.php @@ -45,10 +45,6 @@ abstract class BaseTransaction extends BaseObject public function getBookingReference(): BookingReference { - return new BookingReference( - $this->office, - $this->code, - $this->number - ); + return new BookingReference($this->office, $this->code, $this->number); } } \ No newline at end of file diff --git a/src/CashTransaction.php b/src/CashTransaction.php index 160106e0..ac868503 100644 --- a/src/CashTransaction.php +++ b/src/CashTransaction.php @@ -5,8 +5,7 @@ use PhpTwinfield\CashTransactionLine; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\LineType; -use PhpTwinfield\Fields\Transaction\CloseValueField; -use PhpTwinfield\Fields\Transaction\StartValueField; +use PhpTwinfield\Fields\Transaction\CloseAndStartValueFields; use PhpTwinfield\Fields\Transaction\StatementNumberField; /* @@ -14,13 +13,14 @@ */ class CashTransaction extends BaseTransaction { - use CloseValueField; - use StartValueField; + use CloseAndStartValueFields { + setCurrency as protected traitSetCurrency; + } + use StatementNumberField; public function __construct() { - $this->closeValue = new \Money\Money(0, new \Money\Currency('EUR')); $this->startValue = new \Money\Money(0, new \Money\Currency('EUR')); } @@ -32,6 +32,18 @@ public function getLineClassName(): string return CashTransactionLine::class; } + /* + * Set the currency. Can only be done when the start value is still 0. + * + * @param Currency $currency + * @return $this + */ + public function setCurrency(?Currency $currency): parent + { + $this->traitSetCurrency($currency); + return $this; + } + /* * @param $line * @return $this @@ -52,12 +64,6 @@ public function addLine($line) } } - if ($line->getDebitCredit()->equals(DebitCredit::CREDIT())) { - $this->closeValue = $this->getCloseValue()->add($this->getStartValue()); - } else { - $this->closeValue = $this->getCloseValue()->subtract($this->getStartValue()); - } - return $this; } } diff --git a/src/ElectronicBankStatement.php b/src/ElectronicBankStatement.php index c08a84b3..d132c3ea 100644 --- a/src/ElectronicBankStatement.php +++ b/src/ElectronicBankStatement.php @@ -7,8 +7,7 @@ use PhpTwinfield\Fields\CurrencyField; use PhpTwinfield\Fields\DateField; use PhpTwinfield\Fields\OfficeField; -use PhpTwinfield\Fields\Transaction\CloseValueField; -use PhpTwinfield\Fields\Transaction\StartValueField; +use PhpTwinfield\Fields\Transaction\CloseAndStartValueFields; use PhpTwinfield\Fields\Transaction\StatementNumberField; use Webmozart\Assert\Assert; @@ -17,11 +16,9 @@ */ class ElectronicBankStatement { - use CloseValueField; - use CurrencyField; + use CloseAndStartValueFields; use DateField; use OfficeField; - use StartValueField; use StatementNumberField; /* @@ -64,8 +61,7 @@ public function __construct() $currency = new \PhpTwinfield\Currency; $currency->setCode('EUR'); $this->currency = $currency; - $this->closeValue = new \Money\Money(0, new \Money\Currency('EUR')); - $this->startValue = new \Money\Money(0, new \Money\Currency('EUR')); + $this->startValue = new \Money\Money(0, new \Money\Currency($currency->getCode())); } public function getAccount(): ?string diff --git a/src/Fields/Transaction/CloseAndStartValueFields.php b/src/Fields/Transaction/CloseAndStartValueFields.php new file mode 100644 index 00000000..3c4943c5 --- /dev/null +++ b/src/Fields/Transaction/CloseAndStartValueFields.php @@ -0,0 +1,123 @@ +currency; + } + + public function getCurrencyToString(): ?string + { + if ($this->getCurrency() != null) { + return $this->currency->getCode(); + } else { + return null; + } + } + + /** + * Set the currency. Can only be done when the start value is still 0. + * + * @param Currency $currency + * @return $this + */ + public function setCurrency(?Currency $currency): self + { + Assert::true($this->startValue->isZero()); + $this->setStartValue(new Money(0, new \Money\Currency($currency->getCode()))); + + return $this; + } + + /** + * @param string|null $currencyCode + * @return $this + * @throws Exception + */ + public function setCurrencyFromString(?string $currencyCode) + { + $currency = new Currency(); + $currency->setCode($currencyCode); + return $this->setCurrency($currency); + } + + /** + * @return Money|null + */ + public function getStartValue(): ?Money + { + return $this->startValue; + } + + /** + * @return float|null + */ + public function getStartValueToFloat(): ?float + { + if ($this->getStartValue() != null) { + return Util::formatMoney($this->getStartValue()); + } else { + return 0; + } + } + + /** + * @param Money|null $startValue + * @return $this + */ + public function setStartValue(?Money $startValue) + { + $this->setCurrencyFromString($startValue->getCurrency()); + $this->startValue = $startValue; + $this->closeValue = $startValue; + + return $this; + } + + /** + * @param float|null $startValueFloat + * @return $this + * @throws Exception + */ + public function setStartValueFromFloat(?float $startValueFloat) + { + if ((float)$startValueFloat) { + return $this->setStartValue(Money::EUR(100 * $startValueFloat)); + } else { + return $this->setStartValue(Money::EUR(0)); + } + } + + public function getCloseValue(): Money + { + return $this->closeValue ?? new Money(0, new \Money\Currency($this->getCurrencyToString())); + } +} \ No newline at end of file diff --git a/src/Fields/Transaction/CloseValueField.php b/src/Fields/Transaction/CloseValueField.php deleted file mode 100644 index 827a4be1..00000000 --- a/src/Fields/Transaction/CloseValueField.php +++ /dev/null @@ -1,62 +0,0 @@ -closeValue; - } - - /** - * @return float|null - */ - public function getCloseValueToFloat(): ?float - { - if ($this->getCloseValue() != null) { - return Util::formatMoney($this->getCloseValue()); - } else { - return 0; - } - } - - /** - * @param Money|null $closeValue - * @return $this - */ - public function setCloseValue(?Money $closeValue) - { - $this->closeValue = $closeValue; - - return $this; - } - - /** - * @param float|null $closeValueFloat - * @return $this - * @throws Exception - */ - public function setCloseValueFromFloat(?float $closeValueFloat) - { - if ((float)$closeValueFloat) { - return $this->setCloseValue(Money::EUR(100 * $closeValueFloat)); - } else { - return $this->setCloseValue(Money::EUR(0)); - } - } -} \ No newline at end of file From 036b0e079c7aa3d4d56c056b737191ddd51e4136 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 08:24:43 +0200 Subject: [PATCH 235/388] Update CloseAndStartValueFields.php --- src/Fields/Transaction/CloseAndStartValueFields.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Fields/Transaction/CloseAndStartValueFields.php b/src/Fields/Transaction/CloseAndStartValueFields.php index 3c4943c5..ea3f210b 100644 --- a/src/Fields/Transaction/CloseAndStartValueFields.php +++ b/src/Fields/Transaction/CloseAndStartValueFields.php @@ -53,7 +53,7 @@ public function setCurrency(?Currency $currency): self { Assert::true($this->startValue->isZero()); $this->setStartValue(new Money(0, new \Money\Currency($currency->getCode()))); - + return $this; } @@ -66,9 +66,10 @@ public function setCurrencyFromString(?string $currencyCode) { $currency = new Currency(); $currency->setCode($currencyCode); + return $this->setCurrency($currency); } - + /** * @return Money|null */ @@ -93,13 +94,11 @@ public function getStartValueToFloat(): ?float * @param Money|null $startValue * @return $this */ - public function setStartValue(?Money $startValue) + public function setStartValue(?Money $startValue): void { $this->setCurrencyFromString($startValue->getCurrency()); $this->startValue = $startValue; $this->closeValue = $startValue; - - return $this; } /** @@ -110,9 +109,9 @@ public function setStartValue(?Money $startValue) public function setStartValueFromFloat(?float $startValueFloat) { if ((float)$startValueFloat) { - return $this->setStartValue(Money::EUR(100 * $startValueFloat)); + $this->setStartValue(Money::EUR(100 * $startValueFloat)); } else { - return $this->setStartValue(Money::EUR(0)); + $this->setStartValue(Money::EUR(0)); } } From 7f2c6dba303698fc5b67c3b23aee5fde49b941b9 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 08:25:04 +0200 Subject: [PATCH 236/388] Update CloseAndStartValueFields.php --- src/Fields/Transaction/CloseAndStartValueFields.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Fields/Transaction/CloseAndStartValueFields.php b/src/Fields/Transaction/CloseAndStartValueFields.php index ea3f210b..cd5bf155 100644 --- a/src/Fields/Transaction/CloseAndStartValueFields.php +++ b/src/Fields/Transaction/CloseAndStartValueFields.php @@ -4,6 +4,7 @@ use Money\Money; use PhpTwinfield\Currency; +use PhpTwinfield\Util; use Webmozart\Assert\Assert; trait CloseAndStartValueFields From 4a58c610777d4f526641447efeb193f81f21c929 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 08:28:18 +0200 Subject: [PATCH 237/388] Update CloseAndStartValueFields.php --- src/Fields/Transaction/CloseAndStartValueFields.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Fields/Transaction/CloseAndStartValueFields.php b/src/Fields/Transaction/CloseAndStartValueFields.php index cd5bf155..7019fdb5 100644 --- a/src/Fields/Transaction/CloseAndStartValueFields.php +++ b/src/Fields/Transaction/CloseAndStartValueFields.php @@ -97,7 +97,10 @@ public function getStartValueToFloat(): ?float */ public function setStartValue(?Money $startValue): void { - $this->setCurrencyFromString($startValue->getCurrency()); + $currency = new Currency(); + $currency->setCode($startValue->getCurrency()); + + $this->currency = $currency; $this->startValue = $startValue; $this->closeValue = $startValue; } From dc31e4b795b7ddfbe4391769ec47f42e44964fda Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 08:33:38 +0200 Subject: [PATCH 238/388] Update CloseAndStartValueFields.php --- src/Fields/Transaction/CloseAndStartValueFields.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Fields/Transaction/CloseAndStartValueFields.php b/src/Fields/Transaction/CloseAndStartValueFields.php index 7019fdb5..c5d0173c 100644 --- a/src/Fields/Transaction/CloseAndStartValueFields.php +++ b/src/Fields/Transaction/CloseAndStartValueFields.php @@ -123,4 +123,16 @@ public function getCloseValue(): Money { return $this->closeValue ?? new Money(0, new \Money\Currency($this->getCurrencyToString())); } + + /** + * @return float|null + */ + public function getCloseValueToFloat(): ?float + { + if ($this->getCloseValue() != null) { + return Util::formatMoney($this->getCloseValue()); + } else { + return 0; + } + } } \ No newline at end of file From 2dd2e3baa9a61dc7452dcbf666e91ba699da6ef1 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 08:44:06 +0200 Subject: [PATCH 239/388] Upload --- .../Transaction/CloseAndStartValueFields.php | 4 +- src/Fields/Transaction/StartValueField.php | 62 ------------------- .../PerformanceCountryField.php | 6 +- src/Mappers/TransactionMapper.php | 1 - tests/UnitTests/BankTransactionUnitTest.php | 2 +- tests/UnitTests/CashTransactionUnitTest.php | 2 +- 6 files changed, 7 insertions(+), 70 deletions(-) delete mode 100644 src/Fields/Transaction/StartValueField.php diff --git a/src/Fields/Transaction/CloseAndStartValueFields.php b/src/Fields/Transaction/CloseAndStartValueFields.php index c5d0173c..11f3dae4 100644 --- a/src/Fields/Transaction/CloseAndStartValueFields.php +++ b/src/Fields/Transaction/CloseAndStartValueFields.php @@ -113,9 +113,9 @@ public function setStartValue(?Money $startValue): void public function setStartValueFromFloat(?float $startValueFloat) { if ((float)$startValueFloat) { - $this->setStartValue(Money::EUR(100 * $startValueFloat)); + $this->setStartValue(new Money(100 * $startValueFloat, new \Money\Currency($this->getCurrencyToString()))); } else { - $this->setStartValue(Money::EUR(0)); + $this->setStartValue(new Money(0, new \Money\Currency($this->getCurrencyToString()))); } } diff --git a/src/Fields/Transaction/StartValueField.php b/src/Fields/Transaction/StartValueField.php deleted file mode 100644 index 65a98ad9..00000000 --- a/src/Fields/Transaction/StartValueField.php +++ /dev/null @@ -1,62 +0,0 @@ -startValue; - } - - /** - * @return float|null - */ - public function getStartValueToFloat(): ?float - { - if ($this->getStartValue() != null) { - return Util::formatMoney($this->getStartValue()); - } else { - return 0; - } - } - - /** - * @param Money|null $startValue - * @return $this - */ - public function setStartValue(?Money $startValue) - { - $this->startValue = $startValue; - - return $this; - } - - /** - * @param float|null $startValueFloat - * @return $this - * @throws Exception - */ - public function setStartValueFromFloat(?float $startValueFloat) - { - if ((float)$startValueFloat) { - return $this->setStartValue(Money::EUR(100 * $startValueFloat)); - } else { - return $this->setStartValue(Money::EUR(0)); - } - } -} \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/PerformanceCountryField.php b/src/Fields/Transaction/TransactionLine/PerformanceCountryField.php index 38c9daf2..05e659cd 100644 --- a/src/Fields/Transaction/TransactionLine/PerformanceCountryField.php +++ b/src/Fields/Transaction/TransactionLine/PerformanceCountryField.php @@ -41,14 +41,14 @@ public function setPerformanceCountry(?Country $performanceCountry): self } /** - * @param string|null $performanceCountry + * @param string|null $performanceCountryCode * @return $this * @throws Exception */ - public function setPerformanceCountryFromString(?string $performanceCountry) + public function setPerformanceCountryFromString(?string $performanceCountryCode) { $performanceCountry = new Country(); - $performanceCountry->setCode($performanceCountry); + $performanceCountry->setCode($performanceCountryCode); return $this->setPerformanceCountry($performanceCountry); } } \ No newline at end of file diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 28749a1b..ac31c34b 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -124,7 +124,6 @@ public static function map(string $transactionClassName, Response $response): Ba } if ($transaction instanceof BankTransaction || $transaction instanceof CashTransaction) { - $transaction->setCloseValueFromFloat(self::getField($transaction, $transactionElement, 'closevalue')); $transaction->setStartValueFromFloat(self::getField($transaction, $transactionElement, 'startvalue')); } diff --git a/tests/UnitTests/BankTransactionUnitTest.php b/tests/UnitTests/BankTransactionUnitTest.php index 85285f84..053b777a 100644 --- a/tests/UnitTests/BankTransactionUnitTest.php +++ b/tests/UnitTests/BankTransactionUnitTest.php @@ -22,8 +22,8 @@ protected function setUp() public function testSetStartValue() { - $this->bankTransaction->setStartValue(Money::EUR(100)); $this->bankTransaction->setCurrencyFromString('EUR'); + $this->bankTransaction->setStartValue(Money::EUR(100)); $this->assertEquals('EUR', $this->bankTransaction->getCurrencyToString()); $this->assertEquals(Money::EUR(100), $this->bankTransaction->getStartValue()); diff --git a/tests/UnitTests/CashTransactionUnitTest.php b/tests/UnitTests/CashTransactionUnitTest.php index ae0f67aa..dc328760 100644 --- a/tests/UnitTests/CashTransactionUnitTest.php +++ b/tests/UnitTests/CashTransactionUnitTest.php @@ -22,8 +22,8 @@ protected function setUp() public function testSetStartValue() { - $this->cashTransaction->setStartValue(Money::EUR(100)); $this->cashTransaction->setCurrencyFromString('EUR'); + $this->cashTransaction->setStartValue(Money::EUR(100)); $this->assertEquals('EUR', $this->cashTransaction->getCurrencyToString()); $this->assertEquals(Money::EUR(100), $this->cashTransaction->getStartValue()); From f31caf2ea6378d8f2b97dcea87f5c60dff0930a2 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 08:55:14 +0200 Subject: [PATCH 240/388] Upload --- src/DomDocuments/TransactionsDocument.php | 4 ++-- .../resources/purchaseTransactionSendRequest.xml | 4 ++-- .../resources/salesTransactionSendRequest.xml | 4 ++-- tests/UnitTests/BankTransactionLineUnitTest.php | 4 ++-- tests/UnitTests/CashTransactionLineUnitTest.php | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/DomDocuments/TransactionsDocument.php b/src/DomDocuments/TransactionsDocument.php index 4cb306c2..f4cf01ab 100644 --- a/src/DomDocuments/TransactionsDocument.php +++ b/src/DomDocuments/TransactionsDocument.php @@ -114,7 +114,7 @@ public function addTransaction(BaseTransaction $transaction) $headerElement->appendChild($this->createNodeWithTextContent('closevalue', $transaction->getCloseValueToFloat())); } - if (Util::objectUses(FreeText1Field::class, $transaction)) { + if (Util::objectUses(FreeText1Field::class, $transaction) && $transaction->getFreetext1() !== null) { $headerElement->appendChild($this->createNodeWithTextContent("freetext1", $transaction->getFreetext1())); } @@ -122,7 +122,7 @@ public function addTransaction(BaseTransaction $transaction) $headerElement->appendChild($this->createNodeWithTextContent("freetext2", $transaction->getFreetext2())); } - if (Util::objectUses(FreeText3Field::class, $transaction)) { + if (Util::objectUses(FreeText3Field::class, $transaction) && $transaction->getFreetext3() !== null) { $headerElement->appendChild($this->createNodeWithTextContent("freetext3", $transaction->getFreetext3())); } diff --git a/tests/IntegrationTests/resources/purchaseTransactionSendRequest.xml b/tests/IntegrationTests/resources/purchaseTransactionSendRequest.xml index 47ba4d38..2eac4d75 100644 --- a/tests/IntegrationTests/resources/purchaseTransactionSendRequest.xml +++ b/tests/IntegrationTests/resources/purchaseTransactionSendRequest.xml @@ -15,13 +15,13 @@ 1600 2000 credit - 121.00 + 121 8020 debit - 100.00 + 100 Outfit IH diff --git a/tests/IntegrationTests/resources/salesTransactionSendRequest.xml b/tests/IntegrationTests/resources/salesTransactionSendRequest.xml index ae5107e3..f871a257 100644 --- a/tests/IntegrationTests/resources/salesTransactionSendRequest.xml +++ b/tests/IntegrationTests/resources/salesTransactionSendRequest.xml @@ -15,13 +15,13 @@ 1300 1000 debit - 121.00 + 121 8020 credit - 100.00 + 100 Outfit VH diff --git a/tests/UnitTests/BankTransactionLineUnitTest.php b/tests/UnitTests/BankTransactionLineUnitTest.php index 5b114daa..1121d305 100644 --- a/tests/UnitTests/BankTransactionLineUnitTest.php +++ b/tests/UnitTests/BankTransactionLineUnitTest.php @@ -106,7 +106,7 @@ public function testSetMatchLevel() public function testCanNotSetMatchLevelIfLineTypeIsNotDetail() { - $this->expectExceptionMessage('Invalid field \'matchLevel\' for line class PhpTwinfield\BankTransactionLine and type \'vat\'.'); + $this->expectExceptionMessage('Invalid field \'matchlevel\' for line class PhpTwinfield\BankTransactionLine and type \'vat\'.'); $this->line->setLineType(LineType::VAT()); $this->line->setMatchLevel(1); @@ -122,7 +122,7 @@ public function testSetBaseValueOpen() public function testCanNotSetBaseValueOpenIfLineTypeIsNotDetail() { - $this->expectExceptionMessage('Invalid field \'baseValueOpen\' for line class PhpTwinfield\BankTransactionLine and type \'vat\'.'); + $this->expectExceptionMessage('Invalid field \'basevalueopen\' for line class PhpTwinfield\BankTransactionLine and type \'vat\'.'); $this->line->setLineType(LineType::VAT()); $this->line->setBaseValueOpen(Money::EUR(100)); diff --git a/tests/UnitTests/CashTransactionLineUnitTest.php b/tests/UnitTests/CashTransactionLineUnitTest.php index d46f2d05..09065f93 100644 --- a/tests/UnitTests/CashTransactionLineUnitTest.php +++ b/tests/UnitTests/CashTransactionLineUnitTest.php @@ -106,7 +106,7 @@ public function testSetMatchLevel() public function testCanNotSetMatchLevelIfLineTypeIsNotDetail() { - $this->expectExceptionMessage('Invalid field \'matchLevel\' for line class PhpTwinfield\CashTransactionLine and type \'vat\'.'); + $this->expectExceptionMessage('Invalid field \'matchlevel\' for line class PhpTwinfield\CashTransactionLine and type \'vat\'.'); $this->line->setLineType(LineType::VAT()); $this->line->setMatchLevel(1); @@ -122,7 +122,7 @@ public function testSetBaseValueOpen() public function testCanNotSetBaseValueOpenIfLineTypeIsNotDetail() { - $this->expectExceptionMessage('Invalid field \'baseValueOpen\' for line class PhpTwinfield\CashTransactionLine and type \'vat\'.'); + $this->expectExceptionMessage('Invalid field \'basevalueopen\' for line class PhpTwinfield\CashTransactionLine and type \'vat\'.'); $this->line->setLineType(LineType::VAT()); $this->line->setBaseValueOpen(Money::EUR(100)); From 3ac3c74bdfad86d506fdaaf7762840d49787d4a8 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 09:12:48 +0200 Subject: [PATCH 241/388] Upload --- src/BaseTransactionLine.php | 9 +++++++++ .../resources/journalTransactionSendRequest.xml | 1 - 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/BaseTransactionLine.php b/src/BaseTransactionLine.php index a6025c6e..1daff5c5 100644 --- a/src/BaseTransactionLine.php +++ b/src/BaseTransactionLine.php @@ -94,6 +94,8 @@ public function setVatBaseTurnover(?Money $vatBaseTurnover): self throw Exception::invalidFieldForLineType('vatbaseturnover', $this); } + $this->vatBaseTurnover = $vatBaseTurnover; + return $this; } @@ -125,6 +127,7 @@ public function setVatCode(?VatCode $vatCode): self } $this->vatCode = $vatCode; + return $this; } @@ -141,6 +144,8 @@ public function setVatRepTurnover(?Money $vatRepTurnover): self throw Exception::invalidFieldForLineType('vatrepturnover', $this); } + $this->vatRepTurnover = $vatRepTurnover; + return $this; } @@ -156,6 +161,7 @@ public function setVatRepValue(?Money $vatRepValue): self } $this->vatRepValue = $vatRepValue; + return $this; } @@ -172,6 +178,8 @@ public function setVatTurnover(?Money $vatTurnover): self throw Exception::invalidFieldForLineType('vatturnover', $this); } + $this->vatTurnover = $vatTurnover; + return $this; } @@ -187,6 +195,7 @@ public function setVatValue(?Money $vatValue): self } $this->vatValue = $vatValue; + return $this; } } diff --git a/tests/IntegrationTests/resources/journalTransactionSendRequest.xml b/tests/IntegrationTests/resources/journalTransactionSendRequest.xml index 6b07a8b6..9664904c 100644 --- a/tests/IntegrationTests/resources/journalTransactionSendRequest.xml +++ b/tests/IntegrationTests/resources/journalTransactionSendRequest.xml @@ -17,7 +17,6 @@ 1000 credit 435.55 - 11001770 Invoice paid From a4d870990c4df6ada8df56217906018cf81e01c4 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 10:59:48 +0200 Subject: [PATCH 242/388] Upload --- src/BankTransaction.php | 1 + src/BankTransactionLine.php | 18 +- src/CashTransaction.php | 1 + src/CashTransactionLine.php | 16 ++ .../AssetMethod/AssetsToActivateField.php | 6 +- src/Fields/AssetMethod/DepreciationField.php | 6 +- .../AssetMethod/DepreciationGroupField.php | 6 +- src/Fields/AssetMethod/PurchaseValueField.php | 6 +- .../AssetMethod/PurchaseValueGroupField.php | 6 +- .../AssetMethod/ReconciliationField.php | 6 +- src/Fields/AssetMethod/SalesField.php | 6 +- src/Fields/AssetMethod/ToBeInvoicedField.php | 6 +- src/Fields/CurrencyField.php | 6 +- src/Fields/CustomerField.php | 6 +- src/Fields/Dim1Field.php | 6 +- src/Fields/Dim2Field.php | 6 +- src/Fields/Dim3Field.php | 6 +- src/Fields/Dim4Field.php | 6 +- .../Dimensions/DimensionGroup/CodeField.php | 6 +- .../Dimensions/DimensionGroup/GroupField.php | 6 +- .../Dimensions/DimensionType/TypeField.php | 6 +- src/Fields/Dimensions/Level2/CountryField.php | 6 +- .../Level2/Customer/DiscountArticleField.php | 6 +- .../Level2/Customer/ResponsibleUserField.php | 6 +- .../Dimensions/Level2/Dimension1Field.php | 6 +- .../Dimensions/Level2/Dimension2Field.php | 6 +- .../Dimensions/Level2/Dimension3Field.php | 6 +- src/Fields/Dimensions/Level2/PayCodeField.php | 6 +- .../Dimensions/Level34/AuthoriserField.php | 6 +- .../Level34/FixedAsset/Dim5Field.php | 6 +- .../Level34/FixedAsset/Dim6Field.php | 6 +- .../Level34/FixedAsset/MethodField.php | 6 +- src/Fields/Dimensions/SubstituteWithField.php | 6 +- src/Fields/Invoice/Article/FreeText1Field.php | 6 +- src/Fields/Invoice/Article/FreeText2Field.php | 6 +- src/Fields/Invoice/ArticleField.php | 6 +- src/Fields/Invoice/BankField.php | 6 +- src/Fields/Invoice/InvoiceTypeField.php | 6 +- src/Fields/Invoice/SubArticleField.php | 6 +- src/Fields/Office/CountryCodeField.php | 6 +- src/Fields/OfficeField.php | 6 +- src/Fields/RateField.php | 6 +- .../Transaction/CloseAndStartValueFields.php | 6 +- .../TransactionLine/DestOfficeField.php | 6 +- .../Transaction/TransactionLine/Dim1Field.php | 6 +- .../PerformanceCountryField.php | 6 +- src/Fields/User/RoleField.php | 6 +- src/Fields/UserField.php | 6 +- src/Fields/VatCode/GroupCountryField.php | 6 +- src/Fields/VatCode/GroupField.php | 6 +- src/Fields/VatCodeField.php | 6 +- src/JournalTransactionLine.php | 20 +- src/Mappers/TransactionMapper.php | 179 ++++++++++-------- src/PurchaseTransactionLine.php | 15 +- src/SalesTransactionLine.php | 19 ++ .../ElectronicBankStatementUnitTest.php | 2 +- 56 files changed, 326 insertions(+), 227 deletions(-) diff --git a/src/BankTransaction.php b/src/BankTransaction.php index 9e35465d..53601db3 100644 --- a/src/BankTransaction.php +++ b/src/BankTransaction.php @@ -41,6 +41,7 @@ public function getLineClassName(): string public function setCurrency(?Currency $currency): parent { $this->traitSetCurrency($currency); + return $this; } diff --git a/src/BankTransactionLine.php b/src/BankTransactionLine.php index cf735116..d0e387fa 100644 --- a/src/BankTransactionLine.php +++ b/src/BankTransactionLine.php @@ -81,6 +81,8 @@ public function setCurrencyDate(?\DateTimeInterface $currencyDate): self throw Exception::invalidFieldForLineType('currencydate', $this); } + $this->currencyDate = $currencyDate; + return $this; } @@ -183,6 +185,8 @@ public function setPerformanceType(?PerformanceType $performanceType): self throw Exception::invalidFieldForLineType('performancetype', $this); } + $this->performanceType = $performanceType; + return $this; } @@ -199,6 +203,8 @@ public function setPerformanceCountry(?Country $performanceCountry): self throw Exception::invalidFieldForLineType('performancecountry', $this); } + $this->performanceCountry = $performanceCountry; + return $this; } @@ -215,6 +221,8 @@ public function setPerformanceVatNumber(?string $performanceVatNumber): self throw Exception::invalidFieldForLineType('performancevatnumber', $this); } + $this->performanceVatNumber = $performanceVatNumber; + return $this; } @@ -231,6 +239,8 @@ public function setPerformanceDate(?\DateTimeInterface $performanceDate): self throw Exception::invalidFieldForLineType('performancedate', $this); } + $this->performanceDate = $performanceDate; + return $this; } @@ -276,9 +286,11 @@ public function setRepValueOpen(?Money $repValueOpen): parent public function setVatTotal(?Money $vatTotal): self { if ($vatTotal !== null && !$this->getLineType()->equals(LineType::TOTAL())) { - throw Exception::invalidFieldForLineType('vatTotal', $this); + throw Exception::invalidFieldForLineType('vattotal', $this); } + $this->vatTotal = $vatTotal; + return $this; } @@ -295,6 +307,8 @@ public function setVatBaseTotal(?Money $vatBaseTotal): self throw Exception::invalidFieldForLineType('vatbasetotal', $this); } + $this->vatBaseTotal = $vatBaseTotal; + return $this; } @@ -311,6 +325,8 @@ public function setVatRepTotal(?Money $vatRepTotal): self throw Exception::invalidFieldForLineType('vatreptotal', $this); } + $this->vatRepTotal = $vatRepTotal; + return $this; } } diff --git a/src/CashTransaction.php b/src/CashTransaction.php index ac868503..6df540b2 100644 --- a/src/CashTransaction.php +++ b/src/CashTransaction.php @@ -41,6 +41,7 @@ public function getLineClassName(): string public function setCurrency(?Currency $currency): parent { $this->traitSetCurrency($currency); + return $this; } diff --git a/src/CashTransactionLine.php b/src/CashTransactionLine.php index 51537a35..83245300 100644 --- a/src/CashTransactionLine.php +++ b/src/CashTransactionLine.php @@ -81,6 +81,8 @@ public function setCurrencyDate(?\DateTimeInterface $currencyDate): self throw Exception::invalidFieldForLineType('currencydate', $this); } + $this->currencyDate = $currencyDate; + return $this; } @@ -183,6 +185,8 @@ public function setPerformanceType(?PerformanceType $performanceType): self throw Exception::invalidFieldForLineType('performancetype', $this); } + $this->performanceType = $performanceType; + return $this; } @@ -199,6 +203,8 @@ public function setPerformanceCountry(?Country $performanceCountry): self throw Exception::invalidFieldForLineType('performancecountry', $this); } + $this->performanceCountry = $performanceCountry; + return $this; } @@ -215,6 +221,8 @@ public function setPerformanceVatNumber(?string $performanceVatNumber): self throw Exception::invalidFieldForLineType('performancevatnumber', $this); } + $this->performanceVatNumber = $performanceVatNumber; + return $this; } @@ -231,6 +239,8 @@ public function setPerformanceDate(?\DateTimeInterface $performanceDate): self throw Exception::invalidFieldForLineType('performancedate', $this); } + $this->performanceDate = $performanceDate; + return $this; } @@ -279,6 +289,8 @@ public function setVatTotal(?Money $vatTotal): self throw Exception::invalidFieldForLineType('vattotal', $this); } + $this->vatTotal = $vatTotal; + return $this; } @@ -295,6 +307,8 @@ public function setVatBaseTotal(?Money $vatBaseTotal): self throw Exception::invalidFieldForLineType('vatbasetotal', $this); } + $this->vatBaseTotal = $vatBaseTotal; + return $this; } @@ -311,6 +325,8 @@ public function setVatRepTotal(?Money $vatRepTotal): self throw Exception::invalidFieldForLineType('vatreptotal', $this); } + $this->vatRepTotal = $vatRepTotal; + return $this; } } diff --git a/src/Fields/AssetMethod/AssetsToActivateField.php b/src/Fields/AssetMethod/AssetsToActivateField.php index 3b6ea303..21c6c25a 100644 --- a/src/Fields/AssetMethod/AssetsToActivateField.php +++ b/src/Fields/AssetMethod/AssetsToActivateField.php @@ -41,14 +41,14 @@ public function setAssetsToActivate(?GeneralLedger $assetsToActivate): self } /** - * @param string|null $assetsToActivateCode + * @param string|null $assetsToActivateString * @return $this * @throws Exception */ - public function setAssetsToActivateFromString(?string $assetsToActivateCode) + public function setAssetsToActivateFromString(?string $assetsToActivateString) { $assetsToActivate = new GeneralLedger(); - $assetsToActivate->setCode($assetsToActivateCode); + $assetsToActivate->setCode($assetsToActivateString); return $this->setAssetsToActivate($assetsToActivate); } } \ No newline at end of file diff --git a/src/Fields/AssetMethod/DepreciationField.php b/src/Fields/AssetMethod/DepreciationField.php index 84cdb7e4..44495fe9 100644 --- a/src/Fields/AssetMethod/DepreciationField.php +++ b/src/Fields/AssetMethod/DepreciationField.php @@ -41,14 +41,14 @@ public function setDepreciation(?GeneralLedger $depreciation): self } /** - * @param string|null $depreciationCode + * @param string|null $depreciationString * @return $this * @throws Exception */ - public function setDepreciationFromString(?string $depreciationCode) + public function setDepreciationFromString(?string $depreciationString) { $depreciation = new GeneralLedger(); - $depreciation->setCode($depreciationCode); + $depreciation->setCode($depreciationString); return $this->setDepreciation($depreciation); } } \ No newline at end of file diff --git a/src/Fields/AssetMethod/DepreciationGroupField.php b/src/Fields/AssetMethod/DepreciationGroupField.php index 4a7fe10b..919217fe 100644 --- a/src/Fields/AssetMethod/DepreciationGroupField.php +++ b/src/Fields/AssetMethod/DepreciationGroupField.php @@ -41,14 +41,14 @@ public function setDepreciationGroup(?DimensionGroup $depreciationGroup): self } /** - * @param string|null $depreciationGroupCode + * @param string|null $depreciationGroupString * @return $this * @throws Exception */ - public function setDepreciationGroupFromString(?string $depreciationGroupCode) + public function setDepreciationGroupFromString(?string $depreciationGroupString) { $depreciationGroup = new DimensionGroup(); - $depreciationGroup->setCode($depreciationGroupCode); + $depreciationGroup->setCode($depreciationGroupString); return $this->setDepreciationGroup($depreciationGroup); } } \ No newline at end of file diff --git a/src/Fields/AssetMethod/PurchaseValueField.php b/src/Fields/AssetMethod/PurchaseValueField.php index 82fb62bc..5fa689c6 100644 --- a/src/Fields/AssetMethod/PurchaseValueField.php +++ b/src/Fields/AssetMethod/PurchaseValueField.php @@ -41,14 +41,14 @@ public function setPurchaseValue(?GeneralLedger $purchaseValue): self } /** - * @param string|null $purchaseValueCode + * @param string|null $purchaseValueString * @return $this * @throws Exception */ - public function setPurchaseValueFromString(?string $purchaseValueCode) + public function setPurchaseValueFromString(?string $purchaseValueString) { $purchaseValue = new GeneralLedger(); - $purchaseValue->setCode($purchaseValueCode); + $purchaseValue->setCode($purchaseValueString); return $this->setPurchaseValue($purchaseValue); } } \ No newline at end of file diff --git a/src/Fields/AssetMethod/PurchaseValueGroupField.php b/src/Fields/AssetMethod/PurchaseValueGroupField.php index 404f7aca..02dcd3f9 100644 --- a/src/Fields/AssetMethod/PurchaseValueGroupField.php +++ b/src/Fields/AssetMethod/PurchaseValueGroupField.php @@ -41,14 +41,14 @@ public function setPurchaseValueGroup(?DimensionGroup $purchaseValueGroup): self } /** - * @param string|null $purchaseValueGroupCode + * @param string|null $purchaseValueGroupString * @return $this * @throws Exception */ - public function setPurchaseValueGroupFromString(?string $purchaseValueGroupCode) + public function setPurchaseValueGroupFromString(?string $purchaseValueGroupString) { $purchaseValueGroup = new DimensionGroup(); - $purchaseValueGroup->setCode($purchaseValueGroupCode); + $purchaseValueGroup->setCode($purchaseValueGroupString); return $this->setPurchaseValueGroup($purchaseValueGroup); } } \ No newline at end of file diff --git a/src/Fields/AssetMethod/ReconciliationField.php b/src/Fields/AssetMethod/ReconciliationField.php index 0e10916e..d5c5bdcd 100644 --- a/src/Fields/AssetMethod/ReconciliationField.php +++ b/src/Fields/AssetMethod/ReconciliationField.php @@ -41,14 +41,14 @@ public function setReconciliation(?GeneralLedger $reconciliation): self } /** - * @param string|null $reconciliationCode + * @param string|null $reconciliationString * @return $this * @throws Exception */ - public function setReconciliationFromString(?string $reconciliationCode) + public function setReconciliationFromString(?string $reconciliationString) { $reconciliation = new GeneralLedger(); - $reconciliation->setCode($reconciliationCode); + $reconciliation->setCode($reconciliationString); return $this->setReconciliation($reconciliation); } } \ No newline at end of file diff --git a/src/Fields/AssetMethod/SalesField.php b/src/Fields/AssetMethod/SalesField.php index d69dcd8b..1345e3f3 100644 --- a/src/Fields/AssetMethod/SalesField.php +++ b/src/Fields/AssetMethod/SalesField.php @@ -41,14 +41,14 @@ public function setSales(?GeneralLedger $sales): self } /** - * @param string|null $salesCode + * @param string|null $salesString * @return $this * @throws Exception */ - public function setSalesFromString(?string $salesCode) + public function setSalesFromString(?string $salesString) { $sales = new GeneralLedger(); - $sales->setCode($salesCode); + $sales->setCode($salesString); return $this->setSales($sales); } } \ No newline at end of file diff --git a/src/Fields/AssetMethod/ToBeInvoicedField.php b/src/Fields/AssetMethod/ToBeInvoicedField.php index e7269e3a..ff9f2760 100644 --- a/src/Fields/AssetMethod/ToBeInvoicedField.php +++ b/src/Fields/AssetMethod/ToBeInvoicedField.php @@ -41,14 +41,14 @@ public function setToBeInvoiced(?GeneralLedger $toBeInvoiced): self } /** - * @param string|null $toBeInvoicedCode + * @param string|null $toBeInvoicedString * @return $this * @throws Exception */ - public function setToBeInvoicedFromString(?string $toBeInvoicedCode) + public function setToBeInvoicedFromString(?string $toBeInvoicedString) { $toBeInvoiced = new GeneralLedger(); - $toBeInvoiced->setCode($toBeInvoicedCode); + $toBeInvoiced->setCode($toBeInvoicedString); return $this->setToBeInvoiced($toBeInvoiced); } } \ No newline at end of file diff --git a/src/Fields/CurrencyField.php b/src/Fields/CurrencyField.php index 36c17486..489a1eec 100644 --- a/src/Fields/CurrencyField.php +++ b/src/Fields/CurrencyField.php @@ -41,14 +41,14 @@ public function setCurrency(?Currency $currency): self } /** - * @param string|null $currencyCode + * @param string|null $currencyString * @return $this * @throws Exception */ - public function setCurrencyFromString(?string $currencyCode) + public function setCurrencyFromString(?string $currencyString) { $currency = new Currency(); - $currency->setCode($currencyCode); + $currency->setCode($currencyString); return $this->setCurrency($currency); } } \ No newline at end of file diff --git a/src/Fields/CustomerField.php b/src/Fields/CustomerField.php index f724be2b..4dc901f7 100644 --- a/src/Fields/CustomerField.php +++ b/src/Fields/CustomerField.php @@ -41,14 +41,14 @@ public function setCustomer(?Customer $customer): self } /** - * @param string|null $customerCode + * @param string|null $customerString * @return $this * @throws Exception */ - public function setCustomerFromString(?string $customerCode) + public function setCustomerFromString(?string $customerString) { $customer = new Customer(); - $customer->setCode($customerCode); + $customer->setCode($customerString); return $this->setCustomer($customer); } } diff --git a/src/Fields/Dim1Field.php b/src/Fields/Dim1Field.php index 70a67115..1822133e 100644 --- a/src/Fields/Dim1Field.php +++ b/src/Fields/Dim1Field.php @@ -41,14 +41,14 @@ public function setDim1(?GeneralLedger $dim1): self } /** - * @param string|null $dim1Code + * @param string|null $dim1String * @return $this * @throws Exception */ - public function setDim1FromString(?string $dim1Code) + public function setDim1FromString(?string $dim1String) { $dim1 = new GeneralLedger(); - $dim1->setCode($dim1Code); + $dim1->setCode($dim1String); return $this->setDim1($dim1); } } \ No newline at end of file diff --git a/src/Fields/Dim2Field.php b/src/Fields/Dim2Field.php index e64667c0..7f0d5870 100644 --- a/src/Fields/Dim2Field.php +++ b/src/Fields/Dim2Field.php @@ -41,14 +41,14 @@ public function setDim2($dim2): self } /** - * @param string|null $dim2Code + * @param string|null $dim2String * @return $this * @throws Exception */ - public function setDim2FromString(?string $dim2Code) + public function setDim2FromString(?string $dim2String) { $dim2 = new Dummy(); - $dim2->setCode($dim2Code); + $dim2->setCode($dim2String); return $this->setDim2($dim2); } } diff --git a/src/Fields/Dim3Field.php b/src/Fields/Dim3Field.php index f4bdb6d4..a304594c 100644 --- a/src/Fields/Dim3Field.php +++ b/src/Fields/Dim3Field.php @@ -41,14 +41,14 @@ public function setDim3($dim3): self } /** - * @param string|null $dim3Code + * @param string|null $dim3String * @return $this * @throws Exception */ - public function setDim3FromString(?string $dim3Code) + public function setDim3FromString(?string $dim3String) { $dim3 = new Dummy(); - $dim3->setCode($dim3Code); + $dim3->setCode($dim3String); return $this->setDim3($dim3); } } diff --git a/src/Fields/Dim4Field.php b/src/Fields/Dim4Field.php index 31b57b57..14251b3e 100644 --- a/src/Fields/Dim4Field.php +++ b/src/Fields/Dim4Field.php @@ -41,14 +41,14 @@ public function setDim4($dim4): self } /** - * @param string|null $dim4Code + * @param string|null $dim4String * @return $this * @throws Exception */ - public function setDim4FromString(?string $dim4Code) + public function setDim4FromString(?string $dim4String) { $dim4 = new Dummy(); - $dim4->setCode($dim4Code); + $dim4->setCode($dim4String); return $this->setDim4($dim4); } } diff --git a/src/Fields/Dimensions/DimensionGroup/CodeField.php b/src/Fields/Dimensions/DimensionGroup/CodeField.php index 4a91387f..80f3e9ac 100644 --- a/src/Fields/Dimensions/DimensionGroup/CodeField.php +++ b/src/Fields/Dimensions/DimensionGroup/CodeField.php @@ -41,14 +41,14 @@ public function setCode($code): self } /** - * @param string|null $codeCode + * @param string|null $codeString * @return $this * @throws Exception */ - public function setCodeFromString(?string $codeCode) + public function setCodeFromString(?string $codeString) { $code = new Dummy(); - $code->setCode($codeCode); + $code->setCode($codeString); return $this->setCode($code); } } diff --git a/src/Fields/Dimensions/DimensionGroup/GroupField.php b/src/Fields/Dimensions/DimensionGroup/GroupField.php index 106a543a..438efd60 100644 --- a/src/Fields/Dimensions/DimensionGroup/GroupField.php +++ b/src/Fields/Dimensions/DimensionGroup/GroupField.php @@ -41,14 +41,14 @@ public function setGroup(?DimensionGroup $group): self } /** - * @param string|null $groupCode + * @param string|null $groupString * @return $this * @throws Exception */ - public function setGroupFromString(?string $groupCode) + public function setGroupFromString(?string $groupString) { $group = new DimensionGroup(); - $group->setCode($groupCode); + $group->setCode($groupString); return $this->setGroup($group); } } diff --git a/src/Fields/Dimensions/DimensionType/TypeField.php b/src/Fields/Dimensions/DimensionType/TypeField.php index 117f6119..81c5b837 100644 --- a/src/Fields/Dimensions/DimensionType/TypeField.php +++ b/src/Fields/Dimensions/DimensionType/TypeField.php @@ -41,14 +41,14 @@ public function setType(?DimensionType $type): self } /** - * @param string|null $typeCode + * @param string|null $typeString * @return $this * @throws Exception */ - public function setTypeFromString(?string $typeCode) + public function setTypeFromString(?string $typeString) { $type = new DimensionType(); - $type->setCode($typeCode); + $type->setCode($typeString); return $this->setType($type); } } diff --git a/src/Fields/Dimensions/Level2/CountryField.php b/src/Fields/Dimensions/Level2/CountryField.php index 0a3356c8..31935a3d 100644 --- a/src/Fields/Dimensions/Level2/CountryField.php +++ b/src/Fields/Dimensions/Level2/CountryField.php @@ -41,14 +41,14 @@ public function setCountry(?Country $country): self } /** - * @param string|null $countryCode + * @param string|null $countryString * @return $this * @throws Exception */ - public function setCountryFromString(?string $countryCode) + public function setCountryFromString(?string $countryString) { $country = new Country(); - $country->setCode($countryCode); + $country->setCode($countryString); return $this->setCountry($country); } } diff --git a/src/Fields/Dimensions/Level2/Customer/DiscountArticleField.php b/src/Fields/Dimensions/Level2/Customer/DiscountArticleField.php index 58aeb06c..ad1e97e6 100644 --- a/src/Fields/Dimensions/Level2/Customer/DiscountArticleField.php +++ b/src/Fields/Dimensions/Level2/Customer/DiscountArticleField.php @@ -41,14 +41,14 @@ public function setDiscountArticle(?Article $discountArticle): self } /** - * @param string|null $discountArticleCode + * @param string|null $discountArticleString * @return $this * @throws Exception */ - public function setDiscountArticleFromString(?string $discountArticleCode) + public function setDiscountArticleFromString(?string $discountArticleString) { $discountArticle = new Article(); - $discountArticle->setCode($discountArticleCode); + $discountArticle->setCode($discountArticleString); return $this->setDiscountArticle($discountArticle); } } diff --git a/src/Fields/Dimensions/Level2/Customer/ResponsibleUserField.php b/src/Fields/Dimensions/Level2/Customer/ResponsibleUserField.php index a4925fdd..e1e54a24 100644 --- a/src/Fields/Dimensions/Level2/Customer/ResponsibleUserField.php +++ b/src/Fields/Dimensions/Level2/Customer/ResponsibleUserField.php @@ -41,14 +41,14 @@ public function setResponsibleUser(?User $responsibleUser): self } /** - * @param string|null $responsibleUserCode + * @param string|null $responsibleUserString * @return $this * @throws Exception */ - public function setResponsibleUserFromString(?string $responsibleUserCode) + public function setResponsibleUserFromString(?string $responsibleUserString) { $responsibleUser = new User(); - $responsibleUser->setCode($responsibleUserCode); + $responsibleUser->setCode($responsibleUserString); return $this->setResponsibleUser($responsibleUser); } } diff --git a/src/Fields/Dimensions/Level2/Dimension1Field.php b/src/Fields/Dimensions/Level2/Dimension1Field.php index 1d5e508f..791402bd 100644 --- a/src/Fields/Dimensions/Level2/Dimension1Field.php +++ b/src/Fields/Dimensions/Level2/Dimension1Field.php @@ -41,14 +41,14 @@ public function setDimension1(?GeneralLedger $dimension1): self } /** - * @param string|null $dimension1Code + * @param string|null $dimension1String * @return $this * @throws Exception */ - public function setDimension1FromString(?string $dimension1Code) + public function setDimension1FromString(?string $dimension1String) { $dimension1 = new GeneralLedger(); - $dimension1->setCode($dimension1Code); + $dimension1->setCode($dimension1String); return $this->setDimension1($dimension1); } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/Dimension2Field.php b/src/Fields/Dimensions/Level2/Dimension2Field.php index 1063575e..7a6515dc 100644 --- a/src/Fields/Dimensions/Level2/Dimension2Field.php +++ b/src/Fields/Dimensions/Level2/Dimension2Field.php @@ -41,14 +41,14 @@ public function setDimension2(?CostCenter $dimension2): self } /** - * @param string|null $dimension2Code + * @param string|null $dimension2String * @return $this * @throws Exception */ - public function setDimension2FromString(?string $dimension2Code) + public function setDimension2FromString(?string $dimension2String) { $dimension2 = new CostCenter(); - $dimension2->setCode($dimension2Code); + $dimension2->setCode($dimension2String); return $this->setDimension2($dimension2); } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/Dimension3Field.php b/src/Fields/Dimensions/Level2/Dimension3Field.php index 388cecca..7ecc0e79 100644 --- a/src/Fields/Dimensions/Level2/Dimension3Field.php +++ b/src/Fields/Dimensions/Level2/Dimension3Field.php @@ -41,14 +41,14 @@ public function setDimension3($dimension3): self } /** - * @param string|null $dimension3Code + * @param string|null $dimension3String * @return $this * @throws Exception */ - public function setDimension3FromString(?string $dimension3Code) + public function setDimension3FromString(?string $dimension3String) { $dimension3 = new Dummy(); - $dimension3->setCode($dimension3Code); + $dimension3->setCode($dimension3String); return $this->setDimension3($dimension3); } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/PayCodeField.php b/src/Fields/Dimensions/Level2/PayCodeField.php index da46e409..03976736 100644 --- a/src/Fields/Dimensions/Level2/PayCodeField.php +++ b/src/Fields/Dimensions/Level2/PayCodeField.php @@ -41,14 +41,14 @@ public function setPayCode(?PayCode $payCode): self } /** - * @param string|null $payCodeCode + * @param string|null $payCodeString * @return $this * @throws Exception */ - public function setPayCodeFromString(?string $payCodeCode) + public function setPayCodeFromString(?string $payCodeString) { $payCode = new PayCode(); - $payCode->setCode($payCodeCode); + $payCode->setCode($payCodeString); return $this->setPayCode($payCode); } } diff --git a/src/Fields/Dimensions/Level34/AuthoriserField.php b/src/Fields/Dimensions/Level34/AuthoriserField.php index 4d9f458e..a0fdced8 100644 --- a/src/Fields/Dimensions/Level34/AuthoriserField.php +++ b/src/Fields/Dimensions/Level34/AuthoriserField.php @@ -41,14 +41,14 @@ public function setAuthoriser(?User $authoriser): self } /** - * @param string|null $authoriserCode + * @param string|null $authoriserString * @return $this * @throws Exception */ - public function setAuthoriserFromString(?string $authoriserCode) + public function setAuthoriserFromString(?string $authoriserString) { $authoriser = new User(); - $authoriser->setCode($authoriserCode); + $authoriser->setCode($authoriserString); return $this->setAuthoriser($authoriser); } } diff --git a/src/Fields/Dimensions/Level34/FixedAsset/Dim5Field.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim5Field.php index 3629ff38..0a6615a4 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/Dim5Field.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim5Field.php @@ -41,14 +41,14 @@ public function setDim5($dim5): self } /** - * @param string|null $dim5Code + * @param string|null $dim5String * @return $this * @throws Exception */ - public function setDim5FromString(?string $dim5Code) + public function setDim5FromString(?string $dim5String) { $dim5 = new Dummy(); - $dim5->setCode($dim5Code); + $dim5->setCode($dim5String); return $this->setDim5($dim5); } } diff --git a/src/Fields/Dimensions/Level34/FixedAsset/Dim6Field.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim6Field.php index 128488f3..6ab99d32 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/Dim6Field.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim6Field.php @@ -41,14 +41,14 @@ public function setDim6($dim6): self } /** - * @param string|null $dim6Code + * @param string|null $dim6String * @return $this * @throws Exception */ - public function setDim6FromString(?string $dim6Code) + public function setDim6FromString(?string $dim6String) { $dim6 = new Dummy(); - $dim6->setCode($dim6Code); + $dim6->setCode($dim6String); return $this->setDim6($dim6); } } diff --git a/src/Fields/Dimensions/Level34/FixedAsset/MethodField.php b/src/Fields/Dimensions/Level34/FixedAsset/MethodField.php index bd1de558..0575071d 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/MethodField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/MethodField.php @@ -41,14 +41,14 @@ public function setMethod(?AssetMethod $method): self } /** - * @param string|null $methodCode + * @param string|null $methodString * @return $this * @throws Exception */ - public function setMethodFromString(?string $methodCode) + public function setMethodFromString(?string $methodString) { $method = new AssetMethod(); - $method->setCode($methodCode); + $method->setCode($methodString); return $this->setMethod($method); } } diff --git a/src/Fields/Dimensions/SubstituteWithField.php b/src/Fields/Dimensions/SubstituteWithField.php index 7ff9b3b7..34b83f0d 100644 --- a/src/Fields/Dimensions/SubstituteWithField.php +++ b/src/Fields/Dimensions/SubstituteWithField.php @@ -41,14 +41,14 @@ public function setSubstituteWith($substituteWith): self } /** - * @param string|null $substituteWithCode + * @param string|null $substituteWithString * @return $this * @throws Exception */ - public function setSubstituteWithFromString(?string $substituteWithCode) + public function setSubstituteWithFromString(?string $substituteWithString) { $substituteWith = new Dummy(); - $substituteWith->setCode($substituteWithCode); + $substituteWith->setCode($substituteWithString); return $this->setSubstituteWith($substituteWith); } } diff --git a/src/Fields/Invoice/Article/FreeText1Field.php b/src/Fields/Invoice/Article/FreeText1Field.php index c23b6034..8782820c 100644 --- a/src/Fields/Invoice/Article/FreeText1Field.php +++ b/src/Fields/Invoice/Article/FreeText1Field.php @@ -41,14 +41,14 @@ public function setFreeText1(?GeneralLedger $freeText1): self } /** - * @param string|null $freeText1Code + * @param string|null $freeText1String * @return $this * @throws Exception */ - public function setFreeText1FromString(?string $freeText1Code) + public function setFreeText1FromString(?string $freeText1String) { $freeText1 = new GeneralLedger(); - $freeText1->setCode($freeText1Code); + $freeText1->setCode($freeText1String); return $this->setFreeText1($freeText1); } } diff --git a/src/Fields/Invoice/Article/FreeText2Field.php b/src/Fields/Invoice/Article/FreeText2Field.php index fc800bb2..33f78aea 100644 --- a/src/Fields/Invoice/Article/FreeText2Field.php +++ b/src/Fields/Invoice/Article/FreeText2Field.php @@ -41,14 +41,14 @@ public function setFreeText2(?CostCenter $freeText2): self } /** - * @param string|null $freeText2Code + * @param string|null $freeText2String * @return $this * @throws Exception */ - public function setFreeText2FromString(?string $freeText2Code) + public function setFreeText2FromString(?string $freeText2String) { $freeText2 = new CostCenter(); - $freeText2->setCode($freeText2Code); + $freeText2->setCode($freeText2String); return $this->setFreeText2($freeText2); } } diff --git a/src/Fields/Invoice/ArticleField.php b/src/Fields/Invoice/ArticleField.php index 477bda88..19b12227 100644 --- a/src/Fields/Invoice/ArticleField.php +++ b/src/Fields/Invoice/ArticleField.php @@ -41,14 +41,14 @@ public function setArticle(?Article $article): self } /** - * @param string|null $articleCode + * @param string|null $articleString * @return $this * @throws Exception */ - public function setArticleFromString(?string $articleCode) + public function setArticleFromString(?string $articleString) { $article = new Article(); - $article->setCode($articleCode); + $article->setCode($articleString); return $this->setArticle($article); } } diff --git a/src/Fields/Invoice/BankField.php b/src/Fields/Invoice/BankField.php index ba1f0564..c22211d8 100644 --- a/src/Fields/Invoice/BankField.php +++ b/src/Fields/Invoice/BankField.php @@ -41,14 +41,14 @@ public function setBank(?CashBankBook $bank): self } /** - * @param string|null $bankCode + * @param string|null $bankString * @return $this * @throws Exception */ - public function setBankFromString(?string $bankCode) + public function setBankFromString(?string $bankString) { $bank = new CashBankBook(); - $bank->setCode($bankCode); + $bank->setCode($bankString); return $this->setBank($bank); } } diff --git a/src/Fields/Invoice/InvoiceTypeField.php b/src/Fields/Invoice/InvoiceTypeField.php index abc3eb30..2ec57a37 100644 --- a/src/Fields/Invoice/InvoiceTypeField.php +++ b/src/Fields/Invoice/InvoiceTypeField.php @@ -41,14 +41,14 @@ public function setInvoiceType(?InvoiceType $invoiceType): self } /** - * @param string|null $invoiceTypeCode + * @param string|null $invoiceTypeString * @return $this * @throws Exception */ - public function setInvoiceTypeFromString(?string $invoiceTypeCode) + public function setInvoiceTypeFromString(?string $invoiceTypeString) { $invoiceType = new InvoiceType(); - $invoiceType->setCode($invoiceTypeCode); + $invoiceType->setCode($invoiceTypeString); return $this->setInvoiceType($invoiceType); } } diff --git a/src/Fields/Invoice/SubArticleField.php b/src/Fields/Invoice/SubArticleField.php index a256d967..e0c1986a 100644 --- a/src/Fields/Invoice/SubArticleField.php +++ b/src/Fields/Invoice/SubArticleField.php @@ -41,14 +41,14 @@ public function setSubArticle(?ArticleLine $subArticle): self } /** - * @param string|null $subArticleCode + * @param string|null $subArticleString * @return $this * @throws Exception */ - public function setSubArticleFromString(?string $subArticleCode) + public function setSubArticleFromString(?string $subArticleString) { $subArticle = new ArticleLine(); - $subArticle->setSubCode($subArticleCode); + $subArticle->setSubCode($subArticleString); return $this->setSubArticle($subArticle); } } diff --git a/src/Fields/Office/CountryCodeField.php b/src/Fields/Office/CountryCodeField.php index 3b18fe44..c6dbd581 100644 --- a/src/Fields/Office/CountryCodeField.php +++ b/src/Fields/Office/CountryCodeField.php @@ -41,14 +41,14 @@ public function setCountryCode(?Country $countryCode): self } /** - * @param string|null $countryCode + * @param string|null $countryCodeString * @return $this * @throws Exception */ - public function setCountryCodeFromString(?string $countryCode) + public function setCountryCodeFromString(?string $countryCodeString) { $countryCode = new Country(); - $countryCode->setCode($countryCode); + $countryCode->setCode($countryCodeString); return $this->setCountryCode($countryCode); } } \ No newline at end of file diff --git a/src/Fields/OfficeField.php b/src/Fields/OfficeField.php index bb147f7e..92cc1eb0 100644 --- a/src/Fields/OfficeField.php +++ b/src/Fields/OfficeField.php @@ -40,14 +40,14 @@ public function setOffice(?Office $office): self } /** - * @param string|null $officeCode + * @param string|null $officeString * @return $this * @throws Exception */ - public function setOfficeFromString(?string $officeCode) + public function setOfficeFromString(?string $officeString) { $office = new Office(); - $office->setCode($officeCode); + $office->setCode($officeString); return $this->setOffice($office); } } diff --git a/src/Fields/RateField.php b/src/Fields/RateField.php index d40b7d12..5c7c3982 100644 --- a/src/Fields/RateField.php +++ b/src/Fields/RateField.php @@ -41,14 +41,14 @@ public function setRate(?Rate $rate): self } /** - * @param string|null $rateCode + * @param string|null $rateString * @return $this * @throws Exception */ - public function setRateFromString(?string $rateCode) + public function setRateFromString(?string $rateString) { $rate = new Rate(); - $rate->setCode($rateCode); + $rate->setCode($rateString); return $this->setRate($rate); } } diff --git a/src/Fields/Transaction/CloseAndStartValueFields.php b/src/Fields/Transaction/CloseAndStartValueFields.php index 11f3dae4..6c0647ed 100644 --- a/src/Fields/Transaction/CloseAndStartValueFields.php +++ b/src/Fields/Transaction/CloseAndStartValueFields.php @@ -59,14 +59,14 @@ public function setCurrency(?Currency $currency): self } /** - * @param string|null $currencyCode + * @param string|null $currencyString * @return $this * @throws Exception */ - public function setCurrencyFromString(?string $currencyCode) + public function setCurrencyFromString(?string $currencyString) { $currency = new Currency(); - $currency->setCode($currencyCode); + $currency->setCode($currencyString); return $this->setCurrency($currency); } diff --git a/src/Fields/Transaction/TransactionLine/DestOfficeField.php b/src/Fields/Transaction/TransactionLine/DestOfficeField.php index 0e2e2e1c..3e00d6bb 100644 --- a/src/Fields/Transaction/TransactionLine/DestOfficeField.php +++ b/src/Fields/Transaction/TransactionLine/DestOfficeField.php @@ -40,14 +40,14 @@ public function setDestOffice(?Office $destOffice): self } /** - * @param string|null $officeCode + * @param string|null $officeString * @return $this * @throws Exception */ - public function setDestOfficeFromString(?string $officeCode) + public function setDestOfficeFromString(?string $officeString) { $destOffice = new Office(); - $destOffice->setCode($officeCode); + $destOffice->setCode($officeString); return $this->setDestOffice($destOffice); } } diff --git a/src/Fields/Transaction/TransactionLine/Dim1Field.php b/src/Fields/Transaction/TransactionLine/Dim1Field.php index 123a97de..81a43c0a 100644 --- a/src/Fields/Transaction/TransactionLine/Dim1Field.php +++ b/src/Fields/Transaction/TransactionLine/Dim1Field.php @@ -41,14 +41,14 @@ public function setDim1($dim1): self } /** - * @param string|null $dim1Code + * @param string|null $dim1String * @return $this * @throws Exception */ - public function setDim1FromString(?string $dim1Code) + public function setDim1FromString(?string $dim1String) { $dim1 = new Dummy(); - $dim1->setCode($dim1Code); + $dim1->setCode($dim1String); return $this->setDim1($dim1); } } diff --git a/src/Fields/Transaction/TransactionLine/PerformanceCountryField.php b/src/Fields/Transaction/TransactionLine/PerformanceCountryField.php index 05e659cd..fb607c54 100644 --- a/src/Fields/Transaction/TransactionLine/PerformanceCountryField.php +++ b/src/Fields/Transaction/TransactionLine/PerformanceCountryField.php @@ -41,14 +41,14 @@ public function setPerformanceCountry(?Country $performanceCountry): self } /** - * @param string|null $performanceCountryCode + * @param string|null $performanceCountryString * @return $this * @throws Exception */ - public function setPerformanceCountryFromString(?string $performanceCountryCode) + public function setPerformanceCountryFromString(?string $performanceCountryString) { $performanceCountry = new Country(); - $performanceCountry->setCode($performanceCountryCode); + $performanceCountry->setCode($performanceCountryString); return $this->setPerformanceCountry($performanceCountry); } } \ No newline at end of file diff --git a/src/Fields/User/RoleField.php b/src/Fields/User/RoleField.php index 8f665a88..f9bd929c 100644 --- a/src/Fields/User/RoleField.php +++ b/src/Fields/User/RoleField.php @@ -41,14 +41,14 @@ public function setRole(?UserRole $role): self } /** - * @param string|null $roleCode + * @param string|null $roleString * @return $this * @throws Exception */ - public function setRoleFromString(?string $roleCode) + public function setRoleFromString(?string $roleString) { $role = new UserRole(); - $role->setCode($roleCode); + $role->setCode($roleString); return $this->setRole($role); } } diff --git a/src/Fields/UserField.php b/src/Fields/UserField.php index 882482d7..5d3cdcf1 100644 --- a/src/Fields/UserField.php +++ b/src/Fields/UserField.php @@ -41,14 +41,14 @@ public function setUser(?User $user): self } /** - * @param string|null $userCode + * @param string|null $userString * @return $this * @throws Exception */ - public function setUserFromString(?string $userCode) + public function setUserFromString(?string $userString) { $user = new User(); - $user->setCode($userCode); + $user->setCode($userString); return $this->setUser($user); } } diff --git a/src/Fields/VatCode/GroupCountryField.php b/src/Fields/VatCode/GroupCountryField.php index 513a6784..c9f31fbf 100644 --- a/src/Fields/VatCode/GroupCountryField.php +++ b/src/Fields/VatCode/GroupCountryField.php @@ -41,14 +41,14 @@ public function setGroupCountry(?VatGroupCountry $groupCountry): self } /** - * @param string|null $groupCountryCode + * @param string|null $groupCountryString * @return $this * @throws Exception */ - public function setGroupCountryFromString(?string $groupCountryCode) + public function setGroupCountryFromString(?string $groupCountryString) { $groupCountry = new VatGroupCountry(); - $groupCountry->setCode($groupCountryCode); + $groupCountry->setCode($groupCountryString); return $this->setGroupCountry($groupCountry); } } \ No newline at end of file diff --git a/src/Fields/VatCode/GroupField.php b/src/Fields/VatCode/GroupField.php index 8b7bef8a..56d8d3de 100644 --- a/src/Fields/VatCode/GroupField.php +++ b/src/Fields/VatCode/GroupField.php @@ -41,14 +41,14 @@ public function setGroup(?VatGroup $group): self } /** - * @param string|null $groupCode + * @param string|null $groupString * @return $this * @throws Exception */ - public function setGroupFromString(?string $groupCode) + public function setGroupFromString(?string $groupString) { $group = new VatGroup(); - $group->setCode($groupCode); + $group->setCode($groupString); return $this->setGroup($group); } } \ No newline at end of file diff --git a/src/Fields/VatCodeField.php b/src/Fields/VatCodeField.php index 3b61a21b..565a4400 100644 --- a/src/Fields/VatCodeField.php +++ b/src/Fields/VatCodeField.php @@ -41,14 +41,14 @@ public function setVatCode(?VatCode $vatCode): self } /** - * @param string|null $vatCodeCode + * @param string|null $vatCodeString * @return $this * @throws Exception */ - public function setVatCodeFromString(?string $vatCodeCode) + public function setVatCodeFromString(?string $vatCodeString) { $vatCode = new VatCode(); - $vatCode->setCode($vatCodeCode); + $vatCode->setCode($vatCodeString); return $this->setVatCode($vatCode); } } diff --git a/src/JournalTransactionLine.php b/src/JournalTransactionLine.php index 66a5176d..d3f73df5 100644 --- a/src/JournalTransactionLine.php +++ b/src/JournalTransactionLine.php @@ -62,7 +62,9 @@ public function setBaseline(?int $baseline): self if (!$this->getLineType()->equals(LineType::VAT())) { throw Exception::invalidFieldForLineType("baseline", $this); } - + + $this->baseline = $baseline; + return $this; } @@ -95,6 +97,8 @@ public function setCurrencyDate(?\DateTimeInterface $currencyDate): self throw Exception::invalidFieldForLineType('currencydate', $this); } + $this->currencyDate = $currencyDate; + return $this; } @@ -145,6 +149,8 @@ public function setInvoiceNumber(?string $invoiceNumber): self throw Exception::invalidFieldForLineType('invoicenumber', $this); } + $this->invoiceNumber = $invoiceNumber; + return $this; } @@ -192,7 +198,7 @@ public function setMatchLevel(?int $matchLevel): parent return parent::setMatchLevel($matchLevel); } - + /* * Payment status of the transaction. If line type vat always notmatchable. Read-only attribute. * @@ -208,7 +214,7 @@ public function setMatchStatus(?MatchStatus $matchStatus): parent return parent::setMatchStatus($matchStatus); } - + /* * Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The performance type. * @@ -222,6 +228,8 @@ public function setPerformanceType(?PerformanceType $performanceType): self throw Exception::invalidFieldForLineType('performancetype', $this); } + $this->performanceType = $performanceType; + return $this; } @@ -238,6 +246,8 @@ public function setPerformanceCountry(?Country $performanceCountry): self throw Exception::invalidFieldForLineType('performancecountry', $this); } + $this->performanceCountry = $performanceCountry; + return $this; } @@ -254,6 +264,8 @@ public function setPerformanceVatNumber(?string $performanceVatNumber): self throw Exception::invalidFieldForLineType('performancevatnumber', $this); } + $this->performanceVatNumber = $performanceVatNumber; + return $this; } @@ -270,6 +282,8 @@ public function setPerformanceDate(?\DateTimeInterface $performanceDate): self throw Exception::invalidFieldForLineType('performancedate', $this); } + $this->performanceDate = $performanceDate; + return $this; } diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index ac31c34b..5cfe646d 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -16,15 +16,23 @@ use PhpTwinfield\Fields\Transaction\InvoiceNumberField; use PhpTwinfield\Fields\Transaction\PaymentReferenceField; use PhpTwinfield\Fields\Transaction\StatementNumberField; +use PhpTwinfield\Fields\Transaction\TransactionLine\BaselineField; +use PhpTwinfield\Fields\Transaction\TransactionLine\CloseAndStartValueFields; +use PhpTwinfield\Fields\Transaction\TransactionLine\CurrencyDateField; +use PhpTwinfield\Fields\Transaction\TransactionLine\MatchDateField; +use PhpTwinfield\Fields\Transaction\TransactionLine\OriginReferenceField; use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceCountryField; use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceVatNumberField; +use PhpTwinfield\Fields\Transaction\TransactionLine\RegimeField; use PhpTwinfield\Fields\Transaction\TransactionLine\ValueOpenField; use PhpTwinfield\Fields\Transaction\TransactionLine\VatBaseTotalField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatRepTotalField; use PhpTwinfield\Fields\Transaction\TransactionLine\VatTotalField; use PhpTwinfield\JournalTransaction; use PhpTwinfield\Message\Message; -use PhpTwinfield\Response\Response; +use PhpTwinfield\PurchaseTransaction; use PhpTwinfield\SalesTransaction; +use PhpTwinfield\Response\Response; use PhpTwinfield\Util; class TransactionMapper extends BaseMapper @@ -78,33 +86,23 @@ public static function map(string $transactionClassName, Response $response): Ba } $transaction->setCode(self::getField($transaction, $transactionElement, 'code')) + ->setCurrencyFromString(self::getField($transaction, $transactionElement, 'currency')) ->setDateFromString(self::getField($transaction, $transactionElement, 'date')) ->setFreetext1(self::getField($transaction, $transactionElement, 'freetext1')) ->setFreetext2(self::getField($transaction, $transactionElement, 'freetext2')) ->setFreetext3(self::getField($transaction, $transactionElement, 'freetext3')) ->setOfficeFromString(self::getField($transaction, $transactionElement, 'office')) ->setOrigin(self::getField($transaction, $transactionElement, 'origin')) + ->setNumber(self::getField($transaction, $transactionElement, 'number')) ->setPeriod(self::getField($transaction, $transactionElement, 'period')); - $currency = self::getField($transaction, $transactionElement, 'currency'); - - if (!empty($currency)) { - $transaction->setCurrencyFromString($currency); - } - - $number = self::getField($transaction, $transactionElement, 'number'); - - if (!empty($number)) { - $transaction->setNumber($number); - } - - if (Util::objectUses(DueDateField::class, $transaction)) { $transaction->setDueDateFromString(self::getField($transaction, $transactionElement, 'duedate')); } if (Util::objectUses(InvoiceNumberField::class, $transaction)) { $transaction->setInvoiceNumber(self::getField($transaction, $transactionElement, 'invoicenumber')); + $transaction->setInvoiceNumberRaiseWarning(self::parseBooleanAttribute(self::getAttribute($transactionElement, 'invoicenumber', 'raisewarning'))); } if (Util::objectUses(PaymentReferenceField::class, $transaction)) { @@ -115,15 +113,15 @@ public static function map(string $transactionClassName, Response $response): Ba $transaction->setStatementnumber(self::getField($transaction, $transactionElement, 'statementnumber')); } - if ($transaction instanceof SalesTransaction) { + if (Util::objectUses(OriginReferenceField::class, $transaction)) { $transaction->setOriginReference(self::getField($transaction, $transactionElement, 'originreference')); } - if ($transaction instanceof JournalTransaction) { + if (Util::objectUses(RegimeField::class, $transaction)) { $transaction->setRegime(self::getField($transaction, $transactionElement, 'regime')); } - if ($transaction instanceof BankTransaction || $transaction instanceof CashTransaction) { + if (Util::objectUses(CloseAndStartValueFields::class, $transaction)) { $transaction->setStartValueFromFloat(self::getField($transaction, $transactionElement, 'startvalue')); } @@ -146,103 +144,124 @@ public static function map(string $transactionClassName, Response $response): Ba $lineType = $lineElement->getAttribute('type'); $transactionLine - ->setLineType(new LineType($lineType)) - ->setId($lineElement->getAttribute('id')) - ->setDim1FromString(self::getField($transaction, $lineElement, 'dim1')) - ->setDim2FromString(self::getField($transaction, $lineElement, 'dim2')) - ->setValueFromFloat(self::getField($transaction, $lineElement, 'value')) - ->setDebitCredit(self::parseEnumAttribute('DebitCredit', self::getField($transaction, $lineElement, 'debitcredit'))) ->setBaseValueFromFloat(self::getField($transaction, $lineElement, 'basevalue')) - ->setRate(self::getField($transaction, $lineElement, 'rate')) - ->setRepValueFromFloat(self::getField($transaction, $lineElement, 'repvalue')) - ->setRepRate(self::getField($transaction, $lineElement, 'reprate')) + ->setComment(self::getField($transaction, $lineElement, 'comment')) + ->setDebitCredit(self::parseEnumAttribute('DebitCredit', self::getField($transaction, $lineElement, 'debitcredit'))) ->setDescription(self::getField($transaction, $lineElement, 'description')) + ->setDestOfficeFromString(self::getField($transaction, $lineElement, 'destoffice')) + ->setDim1FromString(self::getField($transaction, $lineElement, 'dim1')) + ->setFreeChar(self::getField($transaction, $lineElement, 'freechar')) + ->setId($lineElement->getAttribute('id')) + ->setLineType(new LineType($lineType)) ->setMatchStatusFromString(self::getField($transaction, $lineElement, 'matchstatus')) - ->setMatchLevel(self::getField($transaction, $lineElement, 'matchlevel')) - ->setVatCodeFromString(self::getField($transaction, $lineElement, 'vatcode')); - - $baseValueOpen = self::getField($transaction, $lineElement, 'basevalueopen') ?: self::getField($transaction, $lineElement, 'openbasevalue'); + ->setRate(self::getField($transaction, $lineElement, 'rate')) + ->setRepRate(self::getField($transaction, $lineElement, 'reprate')) + ->setRepValueFromFloat(self::getField($transaction, $lineElement, 'repvalue')) + ->setValueFromFloat(self::getField($transaction, $lineElement, 'value')); - if ($baseValueOpen) { - $transactionLine->setBaseValueOpenFromFloat($baseValueOpen); - } + if ($transaction instanceof BankTransaction || $transaction instanceof CashTransaction || $transaction instanceof JournalTransaction) { + if ($lineType == LineType::DETAIL()) { + $baseValueOpen = self::getField($transaction, $lineElement, 'basevalueopen') ?: self::getField($transaction, $lineElement, 'openbasevalue'); - $vatValue = self::getField($transaction, $lineElement, 'vatvalue'); + if ($baseValueOpen) { + $transactionLine->setBaseValueOpenFromFloat($baseValueOpen); + } - if ($lineType == LineType::DETAIL() && $vatValue) { - $transactionLine->setVatValueFromFloat($vatValue); + $transactionLine->setDim2FromString(self::getField($transaction, $lineElement, 'dim2')); + $transactionLine->setDim3FromString(self::getField($transaction, $lineElement, 'dim3')); + $transactionLine->setMatchLevel(self::getField($transaction, $lineElement, 'matchlevel')); + $transactionLine->setRelation(self::getField($transaction, $lineElement, 'relation')); + $transactionLine->setRepValueOpenFromFloat(self::getField($transaction, $lineElement, 'repvalueopen')); + } } - $baseline = self::getField($transaction, $lineElement, 'baseline'); + if ($transaction instanceof PurchaseTransaction || $transaction instanceof SalesTransaction) { + if (!($transaction instanceof SalesTransaction && $lineType == LineType::VAT())) { + $transactionLine->setDim2FromString(self::getField($transaction, $lineElement, 'dim2')); + $transactionLine->setDim3FromString(self::getField($transaction, $lineElement, 'dim3')); + } - if ($baseline) { - $transactionLine->setBaseline($baseline); - } + if ($lineType == LineType::TOTAL()) { + $baseValueOpen = self::getField($transaction, $lineElement, 'basevalueopen') ?: self::getField($transaction, $lineElement, 'openbasevalue'); - if (Util::objectUses(FreeText1Field::class, $transactionLine)) { - $freetext1 = self::getField($transaction, $lineElement, 'freetext1'); + if ($baseValueOpen) { + $transactionLine->setBaseValueOpenFromFloat($baseValueOpen); + } - if ($freetext1) { - $transactionLine->setFreetext1($freetext1); + $transactionLine->setMatchLevel(self::getField($transaction, $lineElement, 'matchlevel')); + $transactionLine->setRelation(self::getField($transaction, $lineElement, 'relation')); + $transactionLine->setRepValueOpenFromFloat(self::getField($transaction, $lineElement, 'repvalueopen')); } } - if (Util::objectUses(FreeText2Field::class, $transactionLine)) { - $freetext2 = self::getField($transaction, $lineElement, 'freetext2'); - if ($freetext2) { - $transactionLine->setFreetext2($freetext2); + if ($lineType == LineType::DETAIL()) { + if (Util::objectUses(CurrencyDateField::class, $transactionLine)) { + $transactionLine->setCurrencyDateFromString(self::getField($transaction, $lineElement, 'currencydate')); } - } - if (Util::objectUses(FreeText3Field::class, $transactionLine)) { - $freetext3 = self::getField($transaction, $lineElement, 'freetext3'); - if ($freetext3) { - $transactionLine->setFreetext3($freetext3); + if (Util::objectUses(InvoiceNumberField::class, $transactionLine)) { + $transactionLine->setInvoiceNumber(self::getField($transaction, $lineElement, 'invoicenumber')); } - } - if (Util::objectUses(PerformanceTypeField::class, $transactionLine)) { - $transactionLine->setPerformanceTypeFromString(self::getField($transaction, $lineElement, 'performancetype')); + $transactionLine->setVatBaseValueFromFloat(self::getField($transaction, $lineElement, 'vatbasevalue')); + $transactionLine->setVatRepValueFromFloat(self::getField($transaction, $lineElement, 'vatrepvalue')); + $transactionLine->setVatValueFromFloat(self::getField($transaction, $lineElement, 'vatvalue')); } - if (Util::objectUses(PerformanceCountryField::class, $transactionLine)) { - $transactionLine->setPerformanceCountryFromString(self::getField($transaction, $lineElement, 'performancecountry')); - } + if ($lineType == LineType::VAT()) { + if (Util::objectUses(BaselineField::class, $transactionLine)) { + $transactionLine->setBaseline(self::getField($transaction, $lineElement, 'baseline')); + } - if (Util::objectUses(PerformanceVatNumberField::class, $transactionLine)) { - $transactionLine->setPerformanceVatNumber(self::getField($transaction, $lineElement, 'performancevatnumber')); + $transactionLine->setVatBaseTurnoverFromFloat(self::getField($transaction, $lineElement, 'vatbaseturnover')); + $transactionLine->setVatRepTurnoverFromFloat(self::getField($transaction, $lineElement, 'vatrepturnover')); + $transactionLine->setVatTurnoverFromFloat(self::getField($transaction, $lineElement, 'vatturnover')); } - if (Util::objectUses(PerformanceDateField::class, $transactionLine)) { - $transactionLine->setPerformanceDateFromString(self::getField($transaction, $lineElement, 'performancedate')); - } + if ($lineType != LineType::TOTAL()) { + if (Util::objectUses(PerformanceCountryField::class, $transactionLine)) { + $transactionLine->setPerformanceCountryFromString(self::getField($transaction, $lineElement, 'performancecountry')); + } - if (in_array(ValueOpenField::class, class_uses($transactionLine))) { - $valueOpen = self::getField($transaction, $lineElement, 'valueopen') ?: self::getField($transaction, $lineElement, 'openvalue'); + if (Util::objectUses(PerformanceDateField::class, $transactionLine)) { + $transactionLine->setPerformanceDateFromString(self::getField($transaction, $lineElement, 'performancedate')); + } + + if (Util::objectUses(PerformanceTypeField::class, $transactionLine)) { + $transactionLine->setPerformanceTypeFromString(self::getField($transaction, $lineElement, 'performancetype')); + } - if ($valueOpen) { - $transactionLine->setValueOpenFromFloat($valueOpen); + if (Util::objectUses(PerformanceVatNumberField::class, $transactionLine)) { + $transactionLine->setPerformanceVatNumber(self::getField($transaction, $lineElement, 'performancevatnumber')); } + + $transactionLine->setVatCodeFromString(self::getField($transaction, $lineElement, 'vatcode')); } - if (Util::objectUses(VatTotalField::class, $transactionLine)) { - $vatTotal = self::getField($transaction, $lineElement, 'vattotal'); + if ($lineType == LineType::TOTAL()) { + if (Util::objectUses(MatchDateField::class, $transactionLine)) { + $transactionLine->setMatchDateFromString(self::getField($transaction, $lineElement, 'matchdate')); + } + + if (Util::objectUses(ValueOpenField::class, $transactionLine)) { + $valueOpen = self::getField($transaction, $lineElement, 'valueopen') ?: self::getField($transaction, $lineElement, 'openvalue'); - if ($vatTotal) { - $transactionLine->setVatTotalFromFloat($vatTotal); + if ($valueOpen) { + $transactionLine->setValueOpenFromFloat($valueOpen); + } } - } - if (Util::objectUses(VatBaseTotalField::class, $transactionLine)) { - $vatBaseTotal = self::getField($transaction, $lineElement, 'vatbasetotal'); + if (Util::objectUses(VatBaseTotalField::class, $transactionLine)) { + $transactionLine->setVatBaseTotalFromFloat(self::getField($transaction, $lineElement, 'vatbasetotal')); + } - if ($vatBaseTotal) { - $transactionLine->setVatBaseTotalFromFloat($vatBaseTotal); + if (Util::objectUses(VatRepTotalField::class, $transactionLine)) { + $transactionLine->setVatRepTotalFromFloat(self::getField($transaction, $lineElement, 'vatreptotal')); } - } - if (Util::objectUses(InvoiceNumberField::class, $transactionLine)) { - $transactionLine->setInvoiceNumber(self::getField($transaction, $lineElement, 'invoicenumber')); + if (Util::objectUses(VatTotalField::class, $transactionLine)) { + $transactionLine->setVatTotalFromFloat(self::getField($transaction, $lineElement, 'vattotal')); + } } $transaction->addLine($transactionLine); diff --git a/src/PurchaseTransactionLine.php b/src/PurchaseTransactionLine.php index 91cdda8d..6cd85e7c 100644 --- a/src/PurchaseTransactionLine.php +++ b/src/PurchaseTransactionLine.php @@ -60,6 +60,9 @@ public function setBaseline(?int $baseline): self if (!$this->getLineType()->equals(LineType::VAT())) { throw Exception::invalidFieldForLineType("baseline", $this); } + + $this->baseline = $baseline; + return $this; } @@ -126,6 +129,8 @@ public function setMatchDate(?\DateTimeInterface $matchDate): self throw Exception::invalidFieldForLineType('matchdate', $this); } + $this->matchDate = $matchDate; + return $this; } @@ -144,7 +149,7 @@ public function setMatchLevel(?int $matchLevel): parent return parent::setMatchLevel($matchLevel); } - + /* * Payment status of the transaction. If line type detail or vat always notmatchable. Read-only attribute. * @@ -206,6 +211,8 @@ public function setValueOpen(?Money $valueOpen): self throw Exception::invalidFieldForLineType('valueopen', $this); } + $this->valueOpen = $valueOpen; + return $this; } @@ -222,6 +229,8 @@ public function setVatTotal(?Money $vatTotal): self throw Exception::invalidFieldForLineType('vattotal', $this); } + $this->vatTotal = $vatTotal; + return $this; } @@ -238,6 +247,8 @@ public function setVatBaseTotal(?Money $vatBaseTotal): self throw Exception::invalidFieldForLineType('vatbasetotal', $this); } + $this->vatBaseTotal = $vatBaseTotal; + return $this; } @@ -254,6 +265,8 @@ public function setVatRepTotal(?Money $vatRepTotal): self throw Exception::invalidFieldForLineType('vatreptotal', $this); } + $this->vatRepTotal = $vatRepTotal; + return $this; } } diff --git a/src/SalesTransactionLine.php b/src/SalesTransactionLine.php index 9d20a92e..fcefdf5c 100644 --- a/src/SalesTransactionLine.php +++ b/src/SalesTransactionLine.php @@ -66,6 +66,9 @@ public function setBaseline(?int $baseline): self if (!$this->getLineType()->equals(LineType::VAT())) { throw Exception::invalidFieldForLineType("baseline", $this); } + + $this->baseline = $baseline; + return $this; } @@ -184,6 +187,8 @@ public function setPerformanceType(?PerformanceType $performanceType): self throw Exception::invalidFieldForLineType('performancetype', $this); } + $this->performanceType = $performanceType; + return $this; } @@ -200,6 +205,8 @@ public function setPerformanceCountry(?Country $performanceCountry): self throw Exception::invalidFieldForLineType('performancecountry', $this); } + $this->performanceCountry = $performanceCountry; + return $this; } @@ -216,6 +223,8 @@ public function setPerformanceVatNumber(?string $performanceVatNumber): self throw Exception::invalidFieldForLineType('performancevatnumber', $this); } + $this->performanceVatNumber = $performanceVatNumber; + return $this; } @@ -232,6 +241,8 @@ public function setPerformanceDate(?\DateTimeInterface $performanceDate): self throw Exception::invalidFieldForLineType('performancedate', $this); } + $this->performanceDate = $performanceDate; + return $this; } @@ -280,6 +291,8 @@ public function setValueOpen(?Money $valueOpen): self throw Exception::invalidFieldForLineType('valueopen', $this); } + $this->valueOpen = $valueOpen; + return $this; } @@ -296,6 +309,8 @@ public function setVatTotal(?Money $vatTotal): self throw Exception::invalidFieldForLineType('vattotal', $this); } + $this->vatTotal = $vatTotal; + return $this; } @@ -312,6 +327,8 @@ public function setVatBaseTotal(?Money $vatBaseTotal): self throw Exception::invalidFieldForLineType('vatbasetotal', $this); } + $this->vatBaseTotal = $vatBaseTotal; + return $this; } @@ -328,6 +345,8 @@ public function setVatRepTotal(?Money $vatRepTotal): self throw Exception::invalidFieldForLineType('vatreptotal', $this); } + $this->vatRepTotal = $vatRepTotal; + return $this; } } diff --git a/tests/UnitTests/ElectronicBankStatementUnitTest.php b/tests/UnitTests/ElectronicBankStatementUnitTest.php index 0f4c8905..ac5a5d98 100644 --- a/tests/UnitTests/ElectronicBankStatementUnitTest.php +++ b/tests/UnitTests/ElectronicBankStatementUnitTest.php @@ -16,7 +16,7 @@ public function testCanSetCurrencyManually() $ebs = new ElectronicBankStatement(); $ebs->setCurrencyFromString("HUF"); - $this->assertEquals("HUF", $ebs->getCurrency()); + $this->assertEquals("HUF", $ebs->getCurrencyToCode()); } /** From 0f19a0ae67f951d315f2b0c8d6c7155b809d62dc Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 11:47:09 +0200 Subject: [PATCH 243/388] Upload --- src/DomDocuments/TransactionsDocument.php | 193 +++++++--------------- src/Mappers/TransactionMapper.php | 26 +-- 2 files changed, 77 insertions(+), 142 deletions(-) diff --git a/src/DomDocuments/TransactionsDocument.php b/src/DomDocuments/TransactionsDocument.php index f4cf01ab..b1a64a07 100644 --- a/src/DomDocuments/TransactionsDocument.php +++ b/src/DomDocuments/TransactionsDocument.php @@ -66,63 +66,57 @@ public function addTransaction(BaseTransaction $transaction) $headerElement = $this->createElement('header'); $transactionElement->appendChild($headerElement); - $codeElement = $this->createNodeWithTextContent('code', $transaction->getCode()); - $headerElement->appendChild($codeElement); + $headerElement->appendChild($this->createNodeWithTextContent('office', $transaction->getOfficeToString())); + $headerElement->appendChild($this->createNodeWithTextContent('code', $transaction->getCode())); if ($transaction->getNumber() !== null) { - $numberElement = $this->createNodeWithTextContent('number', $transaction->getNumber()); - $headerElement->appendChild($numberElement); + $headerElement->appendChild($this->createNodeWithTextContent('number', $transaction->getNumber())); } - if ($transaction->getCurrency() !== null) { - $currencyElement = $this->createNodeWithTextContent('currency', $transaction->getCurrencyToString()); - $headerElement->appendChild($currencyElement); - } - - $dateElement = $this->createNodeWithTextContent("date", $transaction->getDateToString()); - $headerElement->appendChild($dateElement); - if ($transaction->getPeriod() !== null) { - $periodElement = $this->createNodeWithTextContent('period', $transaction->getPeriod()); - $headerElement->appendChild($periodElement); + $headerElement->appendChild($this->createNodeWithTextContent('period', $transaction->getPeriod())); } - if (in_array(InvoiceNumberField::class, class_uses($transaction)) && $transaction->getInvoiceNumber() !== null) { - $invoiceNumberElement = $this->createNodeWithTextContent('invoicenumber', $transaction->getInvoiceNumber()); - $headerElement->appendChild($invoiceNumberElement); + if ($transaction->getCurrency() !== null) { + $headerElement->appendChild($this->createNodeWithTextContent('currency', $transaction->getCurrencyToString())); } - if (in_array(PaymentReferenceField::class, class_uses($transaction)) && $transaction->getPaymentReference() !== null) { - $paymentReferenceElement = $this->createNodeWithTextContent('paymentreference', $transaction->getPaymentReference()); - $headerElement->appendChild($paymentReferenceElement); + if ($transaction->getRegime() !== null) { + $headerElement->appendChild($this->createNodeWithTextContent('regime', $transaction->getRegime())); } - $officeElement = $this->createNodeWithTextContent('office', $transaction->getOfficeToString()); - $headerElement->appendChild($officeElement); - - if (Util::objectUses(DueDateField::class, $transaction) && $transaction->getDueDate() !== null) { - $dueDateElement = $this->createNodeWithTextContent("duedate", $transaction->getDueDateToString()); - $headerElement->appendChild($dueDateElement); - } + $headerElement->appendChild($this->createNodeWithTextContent("date", $transaction->getDateToString())); if (Util::objectUses(StatementNumberField::class, $transaction) && $transaction->getStatementnumber() !== null) { $headerElement->appendChild($this->createNodeWithTextContent('statementnumber', $transaction->getStatementnumber())); } - if ($transaction instanceof BankTransaction || $transaction instanceof CashTransaction) { + if (Util::objectUses(CloseAndStartValueFields::class, $transaction)) { $headerElement->appendChild($this->createNodeWithTextContent('startvalue', $transaction->getStartValueToFloat())); $headerElement->appendChild($this->createNodeWithTextContent('closevalue', $transaction->getCloseValueToFloat())); } - if (Util::objectUses(FreeText1Field::class, $transaction) && $transaction->getFreetext1() !== null) { + if (Util::objectUses(DueDateField::class, $transaction) && $transaction->getDueDate() !== null) { + $headerElement->appendChild($this->createNodeWithTextContent("duedate", $transaction->getDueDateToString())); + } + + if (Util::objectUses(InvoiceNumberField::class, $transaction) && $transaction->getInvoiceNumber() !== null) { + $headerElement->appendChild($this->createNodeWithTextContent('invoicenumber', $transaction->getInvoiceNumber())); + } + + if (Util::objectUses(PaymentReferenceField::class, $transaction) && $transaction->getPaymentReference() !== null) { + $headerElement->appendChild($this->createNodeWithTextContent('paymentreference', $transaction->getPaymentReference())); + } + + if ($transaction->getFreetext1() !== null) { $headerElement->appendChild($this->createNodeWithTextContent("freetext1", $transaction->getFreetext1())); } - if (Util::objectUses(FreeText2Field::class, $transaction) && $transaction->getFreetext2() !== null) { + if ($transaction->getFreetext2() !== null) { $headerElement->appendChild($this->createNodeWithTextContent("freetext2", $transaction->getFreetext2())); } - if (Util::objectUses(FreeText3Field::class, $transaction) && $transaction->getFreetext3() !== null) { + if ($transaction->getFreetext3() !== null) { $headerElement->appendChild($this->createNodeWithTextContent("freetext3", $transaction->getFreetext3())); } @@ -137,138 +131,79 @@ public function addTransaction(BaseTransaction $transaction) $lineElement->setAttribute('id', $transactionLine->getId()); $linesElement->appendChild($lineElement); - $dim1Element = $this->createNodeWithTextContent('dim1', $transactionLine->getDim1ToString()); - $lineElement->appendChild($dim1Element); + $lineElement->appendChild($this->createNodeWithTextContent('dim1', $transactionLine->getDim1ToString())); - $dim2 = $transactionLine->getDim2ToString(); - - if (!empty($dim2)) { - $dim2Element = $this->createNodeWithTextContent('dim2', $dim2); - $lineElement->appendChild($dim2Element); + if (!empty($transactionLine->getDim2ToString())) { + $lineElement->appendChild($this->createNodeWithTextContent('dim2', $transactionLine->getDim2ToString())); } - if (in_array(ValueOpenField::class, class_uses($transactionLine))) { - $debitCreditElement = $this->createNodeWithTextContent('debitcredit', $transactionLine->getDebitCredit()); - $lineElement->appendChild($debitCreditElement); - - $valueElement = $this->createNodeWithTextContent('value', $transactionLine->getValueToFloat()); - $lineElement->appendChild($valueElement); + if (!empty($transactionLine->getDim3ToString())) { + $lineElement->appendChild($this->createNodeWithTextContent('dim3', $transactionLine->getDim3ToString())); } - if (Util::objectUses(PerformanceTypeField::class, $transactionLine)) { - $performanceType = $transactionLine->getPerformanceType(); - - if (!empty($performanceType)) { - $perfElement = $this->createNodeWithTextContent('performancetype', $performanceType); - $lineElement->appendChild($perfElement); - } + if (Util::objectUses(ValueFields::class, $transactionLine)) { + $lineElement->appendChild($this->createNodeWithTextContent('debitcredit', $transactionLine->getDebitCredit())); + $lineElement->appendChild($this->createNodeWithTextContent('value', $transactionLine->getValueToFloat())); } - if (Util::objectUses(PerformanceCountryField::class, $transactionLine)) { - $performanceCountry = $transactionLine->getPerformanceCountryToString(); - - if (!empty($performanceCountry)) { - $perfCountryElement = $this->createNodeWithTextContent('performancecountry', $performanceCountry); - $lineElement->appendChild($perfCountryElement); - } + if (Util::objectUses(BaselineField::class, $transactionLine) && !empty($transactionLine->getBaseline())) { + $lineElement->appendChild($this->createNodeWithTextContent('baseline', $transactionLine->getBaseline())); } - if (Util::objectUses(PerformanceVatNumberField::class, $transactionLine)) { - $performanceVatNumber = $transactionLine->getPerformanceVatNumber(); - - if (!empty($performanceVatNumber)) { - $perfVatNumberElement = $this->createNodeWithTextContent('performancevatnumber', $performanceVatNumber); - $lineElement->appendChild($perfVatNumberElement); - } + if (!empty($transactionLine->getDescription())) { + $lineElement->appendChild($this->createNodeWithTextContent('description', $transactionLine->getDescription())); } - if (Util::objectUses(PerformanceDateField::class, $transactionLine)) { - $performanceDate = $transactionLine->getPerformanceDateToString(); - - if (!empty($performanceDate)) { - $dueDateElement = $this->createNodeWithTextContent("performancedate", $performanceDate); - $lineElement->appendChild($dueDateElement); - } + if (Util::objectUses(FreeCharField::class, $transactionLine) && !empty($transactionLine->getFreeChar())) { + $lineElement->appendChild($this->createNodeWithTextContent('freechar', $freeChar)); } - if (Util::objectUses(FreeCharField::class, $transactionLine)) { - $freeChar = $transactionLine->getFreeChar(); - - if (!empty($freeChar)) { - $freeCharElement = $this->createNodeWithTextContent('freechar', $freeChar); - $lineElement->appendChild($freeCharElement); - } + if (Util::objectUses(FreeText1Field::class, $transactionLine) && !empty($transactionLine->getFreetext1())) { + $lineElement->appendChild($this->createNodeWithTextContent('freetext1', $transactionLine->getFreetext1())); } - if (Util::objectUses(FreeText1Field::class, $transactionLine)) { - $freetext1 = $transactionLine->getFreetext1(); - - if (!empty($freetext1)) { - $freetext1Element = $this->createNodeWithTextContent('freetext1', $freetext1); - $lineElement->appendChild($freetext1Element); - } + if (Util::objectUses(FreeText2Field::class, $transactionLine) && !empty($transactionLine->getFreetext2())) { + $lineElement->appendChild($this->createNodeWithTextContent('freetext2', $transactionLine->getFreetext2())); } - if (Util::objectUses(FreeText2Field::class, $transactionLine)) { - $freetext2 = $transactionLine->getFreetext2(); - - if (!empty($freetext2)) { - $freetext2Element = $this->createNodeWithTextContent('freetext2', $freetext2); - $lineElement->appendChild($freetext2Element); - } + if (Util::objectUses(FreeText3Field::class, $transactionLine) && !empty($transactionLine->getFreetext3())) { + $lineElement->appendChild($this->createNodeWithTextContent('freetext3', $transactionLine->getFreetext3())); } - if (Util::objectUses(FreeText3Field::class, $transactionLine)) { - $freetext3 = $transactionLine->getFreetext3(); - - if (!empty($freetext3)) { - $freetext3Element = $this->createNodeWithTextContent('freetext3', $freetext3); - $lineElement->appendChild($freetext3Element); - } + if (Util::objectUses(InvoiceNumberField::class, $transactionLine) && !empty($transactionLine->getInvoiceNumber())) { + $lineElement->appendChild($this->createNodeWithTextContent('invoicenumber', $transactionLine->getInvoiceNumber())); } - if (Util::objectUses(VatTotalField::class, $transactionLine)) { - $vatTotal = $transactionLine->getVatTotal(); - - if (!empty($vatTotal)) { - $vatTotalElement = $this->createNodeWithTextContent('vattotal', $transactionLine->getVatTotalToFloat()); - $lineElement->appendChild($vatTotalElement); - } + if (Util::objectUses(PerformanceCountryField::class, $transactionLine) && !empty($transactionLine->getPerformanceCountryToString())) { + $lineElement->appendChild($this->createNodeWithTextContent('performancecountry', $performanceCountry)); } - if (Util::objectUses(VatBaseTotalField::class, $transactionLine)) { - $vatBaseTotal= $transactionLine->getVatBaseTotal(); - - if (!empty($vatBaseTotal)) { - $vatBaseTotalElement = $this->createNodeWithTextContent('vatbasetotal', $transactionLine->getVatBaseTotalToFloat()); - $lineElement->appendChild($vatBaseTotalElement); - } + if (Util::objectUses(PerformanceDateField::class, $transactionLine) && !empty($transactionLine->getPerformanceDateToString())) { + $lineElement->appendChild($this->createNodeWithTextContent("performancedate", $performanceDate)); } - if (Util::objectUses(InvoiceNumberField::class, $transactionLine) && $transactionLine->getInvoiceNumber() !== null) { - $invoiceNumberElement = $this->createNodeWithTextContent('invoicenumber', $transactionLine->getInvoiceNumber()); - $lineElement->appendChild($invoiceNumberElement); + if (Util::objectUses(PerformanceTypeField::class, $transactionLine) && !empty($transactionLine->getPerformanceType())) { + $lineElement->appendChild($this->createNodeWithTextContent('performancetype', $performanceType)); } - $vatValue = $transactionLine->getVatValue(); + if (Util::objectUses(PerformanceVatNumberField::class, $transactionLine) && !empty($transactionLine->getPerformanceVatNumber())) { + $lineElement->appendChild($this->createNodeWithTextContent('performancevatnumber', $performanceVatNumber)); + } - if (!empty($vatValue)) { - $vatElement = $this->createNodeWithTextContent('vatvalue', $transactionLine->getVatValueToFloat()); - $lineElement->appendChild($vatElement); + if (Util::objectUses(VatTotalField::class, $transactionLine) && !empty($transactionLine->getVatTotal())) { + $lineElement->appendChild($this->createNodeWithTextContent('vattotal', $transactionLine->getVatTotalToFloat())); } - if (Util::objectUses(BaselineField::class, $transactionLine) && $transactionLine->getBaseline() !== null) { - $lineElement->appendChild($this->createNodeWithTextContent('baseline', $transactionLine->getBaseline())); + if (Util::objectUses(VatBaseTotalField::class, $transactionLine) && !empty($transactionLine->getVatBaseTotal())) { + $lineElement->appendChild($this->createNodeWithTextContent('vatbasetotal', $transactionLine->getVatBaseTotalToFloat())); } - if ($transactionLine->getDescription() !== null) { - $descriptionElement = $this->createNodeWithTextContent('description', $transactionLine->getDescription()); - $lineElement->appendChild($descriptionElement); + if (!empty($transactionLine->getVatValue())) { + $lineElement->appendChild($this->createNodeWithTextContent('vatvalue', $transactionLine->getVatValueToFloat())); } - if (!LineType::TOTAL()->equals($transactionLine->getLineType()) && $transactionLine->getVatCode() !== null) { - $vatCodeElement = $this->createNodeWithTextContent('vatcode', $transactionLine->getVatCodeToString()); - $lineElement->appendChild($vatCodeElement); + if ($transactionLine->getVatCode() !== null) { + $lineElement->appendChild($this->createNodeWithTextContent('vatcode', $transactionLine->getVatCodeToString())); } } } diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 5cfe646d..14abdc81 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -13,17 +13,17 @@ use PhpTwinfield\Fields\FreeText3Field; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PerformanceTypeField; +use PhpTwinfield\Fields\Transaction\CloseAndStartValueFields; use PhpTwinfield\Fields\Transaction\InvoiceNumberField; +use PhpTwinfield\Fields\Transaction\OriginReferenceField; use PhpTwinfield\Fields\Transaction\PaymentReferenceField; +use PhpTwinfield\Fields\Transaction\RegimeField; use PhpTwinfield\Fields\Transaction\StatementNumberField; use PhpTwinfield\Fields\Transaction\TransactionLine\BaselineField; -use PhpTwinfield\Fields\Transaction\TransactionLine\CloseAndStartValueFields; use PhpTwinfield\Fields\Transaction\TransactionLine\CurrencyDateField; use PhpTwinfield\Fields\Transaction\TransactionLine\MatchDateField; -use PhpTwinfield\Fields\Transaction\TransactionLine\OriginReferenceField; use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceCountryField; use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceVatNumberField; -use PhpTwinfield\Fields\Transaction\TransactionLine\RegimeField; use PhpTwinfield\Fields\Transaction\TransactionLine\ValueOpenField; use PhpTwinfield\Fields\Transaction\TransactionLine\VatBaseTotalField; use PhpTwinfield\Fields\Transaction\TransactionLine\VatRepTotalField; @@ -96,6 +96,10 @@ public static function map(string $transactionClassName, Response $response): Ba ->setNumber(self::getField($transaction, $transactionElement, 'number')) ->setPeriod(self::getField($transaction, $transactionElement, 'period')); + if (Util::objectUses(CloseAndStartValueFields::class, $transaction)) { + $transaction->setStartValueFromFloat(self::getField($transaction, $transactionElement, 'startvalue')); + } + if (Util::objectUses(DueDateField::class, $transaction)) { $transaction->setDueDateFromString(self::getField($transaction, $transactionElement, 'duedate')); } @@ -105,24 +109,20 @@ public static function map(string $transactionClassName, Response $response): Ba $transaction->setInvoiceNumberRaiseWarning(self::parseBooleanAttribute(self::getAttribute($transactionElement, 'invoicenumber', 'raisewarning'))); } - if (Util::objectUses(PaymentReferenceField::class, $transaction)) { - $transaction->setPaymentReference(self::getField($transaction, $transactionElement, 'paymentreference')); - } - - if (Util::objectUses(StatementNumberField::class, $transaction)) { - $transaction->setStatementnumber(self::getField($transaction, $transactionElement, 'statementnumber')); - } - if (Util::objectUses(OriginReferenceField::class, $transaction)) { $transaction->setOriginReference(self::getField($transaction, $transactionElement, 'originreference')); } + if (Util::objectUses(PaymentReferenceField::class, $transaction)) { + $transaction->setPaymentReference(self::getField($transaction, $transactionElement, 'paymentreference')); + } + if (Util::objectUses(RegimeField::class, $transaction)) { $transaction->setRegime(self::getField($transaction, $transactionElement, 'regime')); } - if (Util::objectUses(CloseAndStartValueFields::class, $transaction)) { - $transaction->setStartValueFromFloat(self::getField($transaction, $transactionElement, 'startvalue')); + if (Util::objectUses(StatementNumberField::class, $transaction)) { + $transaction->setStatementnumber(self::getField($transaction, $transactionElement, 'statementnumber')); } // Parse the transaction lines From 75b6bded81a47c4c903ce9873f280b8cc4223787 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 11:59:49 +0200 Subject: [PATCH 244/388] Upload --- src/DomDocuments/TransactionsDocument.php | 20 ++++++++++++-------- src/Mappers/TransactionMapper.php | 4 ++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/DomDocuments/TransactionsDocument.php b/src/DomDocuments/TransactionsDocument.php index b1a64a07..525726ef 100644 --- a/src/DomDocuments/TransactionsDocument.php +++ b/src/DomDocuments/TransactionsDocument.php @@ -13,8 +13,10 @@ use PhpTwinfield\Fields\FreeText3Field; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PerformanceTypeField; +use PhpTwinfield\Fields\Transaction\CloseAndStartValueFields; use PhpTwinfield\Fields\Transaction\InvoiceNumberField; use PhpTwinfield\Fields\Transaction\PaymentReferenceField; +use PhpTwinfield\Fields\Transaction\RegimeField; use PhpTwinfield\Fields\Transaction\StatementNumberField; use PhpTwinfield\Fields\Transaction\TransactionLine\BaselineField; use PhpTwinfield\Fields\Transaction\TransactionLine\FreeCharField; @@ -81,11 +83,11 @@ public function addTransaction(BaseTransaction $transaction) $headerElement->appendChild($this->createNodeWithTextContent('currency', $transaction->getCurrencyToString())); } - if ($transaction->getRegime() !== null) { + if (Util::objectUses(RegimeField::class, $transaction) && $transaction->getRegime() !== null) { $headerElement->appendChild($this->createNodeWithTextContent('regime', $transaction->getRegime())); } - $headerElement->appendChild($this->createNodeWithTextContent("date", $transaction->getDateToString())); + $headerElement->appendChild($this->createNodeWithTextContent("date", $transaction->getDateToString(), array('raisewarning' => 'getDateRaiseWarningToString'))); if (Util::objectUses(StatementNumberField::class, $transaction) && $transaction->getStatementnumber() !== null) { $headerElement->appendChild($this->createNodeWithTextContent('statementnumber', $transaction->getStatementnumber())); @@ -101,7 +103,7 @@ public function addTransaction(BaseTransaction $transaction) } if (Util::objectUses(InvoiceNumberField::class, $transaction) && $transaction->getInvoiceNumber() !== null) { - $headerElement->appendChild($this->createNodeWithTextContent('invoicenumber', $transaction->getInvoiceNumber())); + $headerElement->appendChild($this->createNodeWithTextContent('invoicenumber', $transaction->getInvoiceNumber(), array('raisewarning' => 'getInvoiceNumberRaiseWarningToString'))); } if (Util::objectUses(PaymentReferenceField::class, $transaction) && $transaction->getPaymentReference() !== null) { @@ -155,7 +157,7 @@ public function addTransaction(BaseTransaction $transaction) } if (Util::objectUses(FreeCharField::class, $transactionLine) && !empty($transactionLine->getFreeChar())) { - $lineElement->appendChild($this->createNodeWithTextContent('freechar', $freeChar)); + $lineElement->appendChild($this->createNodeWithTextContent('freechar', $transactionLine->getFreeChar())); } if (Util::objectUses(FreeText1Field::class, $transactionLine) && !empty($transactionLine->getFreetext1())) { @@ -175,21 +177,23 @@ public function addTransaction(BaseTransaction $transaction) } if (Util::objectUses(PerformanceCountryField::class, $transactionLine) && !empty($transactionLine->getPerformanceCountryToString())) { - $lineElement->appendChild($this->createNodeWithTextContent('performancecountry', $performanceCountry)); + $lineElement->appendChild($this->createNodeWithTextContent('performancecountry', $transactionLine->getPerformanceCountryToString())); } if (Util::objectUses(PerformanceDateField::class, $transactionLine) && !empty($transactionLine->getPerformanceDateToString())) { - $lineElement->appendChild($this->createNodeWithTextContent("performancedate", $performanceDate)); + $lineElement->appendChild($this->createNodeWithTextContent("performancedate", $transactionLine->getPerformanceDateToString())); } if (Util::objectUses(PerformanceTypeField::class, $transactionLine) && !empty($transactionLine->getPerformanceType())) { - $lineElement->appendChild($this->createNodeWithTextContent('performancetype', $performanceType)); + $lineElement->appendChild($this->createNodeWithTextContent('performancetype', $transactionLine->getPerformanceType())); } if (Util::objectUses(PerformanceVatNumberField::class, $transactionLine) && !empty($transactionLine->getPerformanceVatNumber())) { - $lineElement->appendChild($this->createNodeWithTextContent('performancevatnumber', $performanceVatNumber)); + $lineElement->appendChild($this->createNodeWithTextContent('performancevatnumber', $transactionLine->getPerformanceVatNumber())); } + // ** // + if (Util::objectUses(VatTotalField::class, $transactionLine) && !empty($transactionLine->getVatTotal())) { $lineElement->appendChild($this->createNodeWithTextContent('vattotal', $transactionLine->getVatTotalToFloat())); } diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 14abdc81..6e060be5 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -146,6 +146,7 @@ public static function map(string $transactionClassName, Response $response): Ba $transactionLine ->setBaseValueFromFloat(self::getField($transaction, $lineElement, 'basevalue')) ->setComment(self::getField($transaction, $lineElement, 'comment')) + ->setValueFromFloat(self::getField($transaction, $lineElement, 'value')) ->setDebitCredit(self::parseEnumAttribute('DebitCredit', self::getField($transaction, $lineElement, 'debitcredit'))) ->setDescription(self::getField($transaction, $lineElement, 'description')) ->setDestOfficeFromString(self::getField($transaction, $lineElement, 'destoffice')) @@ -156,8 +157,7 @@ public static function map(string $transactionClassName, Response $response): Ba ->setMatchStatusFromString(self::getField($transaction, $lineElement, 'matchstatus')) ->setRate(self::getField($transaction, $lineElement, 'rate')) ->setRepRate(self::getField($transaction, $lineElement, 'reprate')) - ->setRepValueFromFloat(self::getField($transaction, $lineElement, 'repvalue')) - ->setValueFromFloat(self::getField($transaction, $lineElement, 'value')); + ->setRepValueFromFloat(self::getField($transaction, $lineElement, 'repvalue')); if ($transaction instanceof BankTransaction || $transaction instanceof CashTransaction || $transaction instanceof JournalTransaction) { if ($lineType == LineType::DETAIL()) { From 0a9dc3b3b5620aee4fe517f87070c73f0097de17 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 12:05:35 +0200 Subject: [PATCH 245/388] Upload --- src/DomDocuments/TransactionsDocument.php | 4 ++-- src/Mappers/TransactionMapper.php | 7 ++++++- tests/UnitTests/ElectronicBankStatementUnitTest.php | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/DomDocuments/TransactionsDocument.php b/src/DomDocuments/TransactionsDocument.php index 525726ef..ab166589 100644 --- a/src/DomDocuments/TransactionsDocument.php +++ b/src/DomDocuments/TransactionsDocument.php @@ -87,7 +87,7 @@ public function addTransaction(BaseTransaction $transaction) $headerElement->appendChild($this->createNodeWithTextContent('regime', $transaction->getRegime())); } - $headerElement->appendChild($this->createNodeWithTextContent("date", $transaction->getDateToString(), array('raisewarning' => 'getDateRaiseWarningToString'))); + $headerElement->appendChild($this->createNodeWithTextContent("date", $transaction->getDateToString(), $transaction, array('raisewarning' => 'getDateRaiseWarningToString'))); if (Util::objectUses(StatementNumberField::class, $transaction) && $transaction->getStatementnumber() !== null) { $headerElement->appendChild($this->createNodeWithTextContent('statementnumber', $transaction->getStatementnumber())); @@ -103,7 +103,7 @@ public function addTransaction(BaseTransaction $transaction) } if (Util::objectUses(InvoiceNumberField::class, $transaction) && $transaction->getInvoiceNumber() !== null) { - $headerElement->appendChild($this->createNodeWithTextContent('invoicenumber', $transaction->getInvoiceNumber(), array('raisewarning' => 'getInvoiceNumberRaiseWarningToString'))); + $headerElement->appendChild($this->createNodeWithTextContent('invoicenumber', $transaction->getInvoiceNumber(), $transaction, array('raisewarning' => 'getInvoiceNumberRaiseWarningToString'))); } if (Util::objectUses(PaymentReferenceField::class, $transaction) && $transaction->getPaymentReference() !== null) { diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 6e060be5..3bf7d4d8 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -151,13 +151,18 @@ public static function map(string $transactionClassName, Response $response): Ba ->setDescription(self::getField($transaction, $lineElement, 'description')) ->setDestOfficeFromString(self::getField($transaction, $lineElement, 'destoffice')) ->setDim1FromString(self::getField($transaction, $lineElement, 'dim1')) - ->setFreeChar(self::getField($transaction, $lineElement, 'freechar')) ->setId($lineElement->getAttribute('id')) ->setLineType(new LineType($lineType)) ->setMatchStatusFromString(self::getField($transaction, $lineElement, 'matchstatus')) ->setRate(self::getField($transaction, $lineElement, 'rate')) ->setRepRate(self::getField($transaction, $lineElement, 'reprate')) ->setRepValueFromFloat(self::getField($transaction, $lineElement, 'repvalue')); + + $freeChar = self::getField($transaction, $lineElement, 'freechar'); + + if ($freeChar !== null && strlen($freeChar) == 1) { + $transactionLine->setFreeChar($freeChar); + } if ($transaction instanceof BankTransaction || $transaction instanceof CashTransaction || $transaction instanceof JournalTransaction) { if ($lineType == LineType::DETAIL()) { diff --git a/tests/UnitTests/ElectronicBankStatementUnitTest.php b/tests/UnitTests/ElectronicBankStatementUnitTest.php index ac5a5d98..5de9a857 100644 --- a/tests/UnitTests/ElectronicBankStatementUnitTest.php +++ b/tests/UnitTests/ElectronicBankStatementUnitTest.php @@ -16,7 +16,7 @@ public function testCanSetCurrencyManually() $ebs = new ElectronicBankStatement(); $ebs->setCurrencyFromString("HUF"); - $this->assertEquals("HUF", $ebs->getCurrencyToCode()); + $this->assertEquals("HUF", $ebs->getCurrencyToString()); } /** From 31dcd9b544893590ee4ec2b2cdebc5d612b0015a Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 12:23:52 +0200 Subject: [PATCH 246/388] Upload --- src/DomDocuments/BaseDocument.php | 4 ++-- src/Mappers/TransactionMapper.php | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/DomDocuments/BaseDocument.php b/src/DomDocuments/BaseDocument.php index 461c5258..5e086465 100644 --- a/src/DomDocuments/BaseDocument.php +++ b/src/DomDocuments/BaseDocument.php @@ -35,11 +35,11 @@ public function __construct($version = "1.0", $encoding = "UTF-8") * * @param string $tag * @param string|null $textContent - * @param object|null $object + * @param $object * @param array|null $attributes * @return \DOMElement */ - final protected function createNodeWithTextContent(string $tag, ?string $textContent, object $object = null, array $attributes = null): \DOMElement + final protected function createNodeWithTextContent(string $tag, ?string $textContent, $object = null, array $attributes = null): \DOMElement { $element = $this->createElement($tag); diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 3bf7d4d8..d2ccd831 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -157,9 +157,9 @@ public static function map(string $transactionClassName, Response $response): Ba ->setRate(self::getField($transaction, $lineElement, 'rate')) ->setRepRate(self::getField($transaction, $lineElement, 'reprate')) ->setRepValueFromFloat(self::getField($transaction, $lineElement, 'repvalue')); - + $freeChar = self::getField($transaction, $lineElement, 'freechar'); - + if ($freeChar !== null && strlen($freeChar) == 1) { $transactionLine->setFreeChar($freeChar); } @@ -181,9 +181,11 @@ public static function map(string $transactionClassName, Response $response): Ba } if ($transaction instanceof PurchaseTransaction || $transaction instanceof SalesTransaction) { - if (!($transaction instanceof SalesTransaction && $lineType == LineType::VAT())) { + if ($lineType == LineType::DETAIL()) { $transactionLine->setDim2FromString(self::getField($transaction, $lineElement, 'dim2')); $transactionLine->setDim3FromString(self::getField($transaction, $lineElement, 'dim3')); + } elseif ($transaction instanceof PurchaseTransaction && $lineType == LineType::VAT()) { + $transactionLine->setDim3FromString(self::getField($transaction, $lineElement, 'dim3')); } if ($lineType == LineType::TOTAL()) { From 5361b7c6106124095dbdbefb7d5b558dbc91e1a3 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 12:32:48 +0200 Subject: [PATCH 247/388] Update TransactionMapper.php --- src/Mappers/TransactionMapper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index d2ccd831..07ef0636 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -153,7 +153,7 @@ public static function map(string $transactionClassName, Response $response): Ba ->setDim1FromString(self::getField($transaction, $lineElement, 'dim1')) ->setId($lineElement->getAttribute('id')) ->setLineType(new LineType($lineType)) - ->setMatchStatusFromString(self::getField($transaction, $lineElement, 'matchstatus')) + ->setMatchStatus(self::parseEnumAttribute('MatchStatus', self::getField($transaction, $lineElement, 'matchstatus'))) ->setRate(self::getField($transaction, $lineElement, 'rate')) ->setRepRate(self::getField($transaction, $lineElement, 'reprate')) ->setRepValueFromFloat(self::getField($transaction, $lineElement, 'repvalue')); From 007cbd997d86142d04948ca4e1851860946c713b Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 12:51:35 +0200 Subject: [PATCH 248/388] Upload --- src/Mappers/TransactionMapper.php | 52 +++++++++---------- .../BankTransactionIntegrationTest.php | 6 ++- .../CashTransactionIntegrationTest.php | 6 ++- .../SalesTransactionIntegrationTest.php | 2 +- .../resources/bankTransactionSendRequest.xml | 5 +- .../resources/cashTransactionSendRequest.xml | 5 +- .../journalTransactionSendRequest.xml | 4 +- .../purchaseTransactionSendRequest.xml | 11 ++-- .../resources/salesTransactionSendRequest.xml | 11 ++-- 9 files changed, 49 insertions(+), 53 deletions(-) diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 07ef0636..10dd6b94 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -186,9 +186,9 @@ public static function map(string $transactionClassName, Response $response): Ba $transactionLine->setDim3FromString(self::getField($transaction, $lineElement, 'dim3')); } elseif ($transaction instanceof PurchaseTransaction && $lineType == LineType::VAT()) { $transactionLine->setDim3FromString(self::getField($transaction, $lineElement, 'dim3')); - } + } elseif ($lineType == LineType::TOTAL()) { + $transactionLine->setDim2FromString(self::getField($transaction, $lineElement, 'dim2')); - if ($lineType == LineType::TOTAL()) { $baseValueOpen = self::getField($transaction, $lineElement, 'basevalueopen') ?: self::getField($transaction, $lineElement, 'openbasevalue'); if ($baseValueOpen) { @@ -213,9 +213,7 @@ public static function map(string $transactionClassName, Response $response): Ba $transactionLine->setVatBaseValueFromFloat(self::getField($transaction, $lineElement, 'vatbasevalue')); $transactionLine->setVatRepValueFromFloat(self::getField($transaction, $lineElement, 'vatrepvalue')); $transactionLine->setVatValueFromFloat(self::getField($transaction, $lineElement, 'vatvalue')); - } - - if ($lineType == LineType::VAT()) { + } elseif ($lineType == LineType::VAT()) { if (Util::objectUses(BaselineField::class, $transactionLine)) { $transactionLine->setBaseline(self::getField($transaction, $lineElement, 'baseline')); } @@ -223,29 +221,7 @@ public static function map(string $transactionClassName, Response $response): Ba $transactionLine->setVatBaseTurnoverFromFloat(self::getField($transaction, $lineElement, 'vatbaseturnover')); $transactionLine->setVatRepTurnoverFromFloat(self::getField($transaction, $lineElement, 'vatrepturnover')); $transactionLine->setVatTurnoverFromFloat(self::getField($transaction, $lineElement, 'vatturnover')); - } - - if ($lineType != LineType::TOTAL()) { - if (Util::objectUses(PerformanceCountryField::class, $transactionLine)) { - $transactionLine->setPerformanceCountryFromString(self::getField($transaction, $lineElement, 'performancecountry')); - } - - if (Util::objectUses(PerformanceDateField::class, $transactionLine)) { - $transactionLine->setPerformanceDateFromString(self::getField($transaction, $lineElement, 'performancedate')); - } - - if (Util::objectUses(PerformanceTypeField::class, $transactionLine)) { - $transactionLine->setPerformanceTypeFromString(self::getField($transaction, $lineElement, 'performancetype')); - } - - if (Util::objectUses(PerformanceVatNumberField::class, $transactionLine)) { - $transactionLine->setPerformanceVatNumber(self::getField($transaction, $lineElement, 'performancevatnumber')); - } - - $transactionLine->setVatCodeFromString(self::getField($transaction, $lineElement, 'vatcode')); - } - - if ($lineType == LineType::TOTAL()) { + } elseif ($lineType == LineType::TOTAL()) { if (Util::objectUses(MatchDateField::class, $transactionLine)) { $transactionLine->setMatchDateFromString(self::getField($transaction, $lineElement, 'matchdate')); } @@ -271,6 +247,26 @@ public static function map(string $transactionClassName, Response $response): Ba } } + if ($lineType != LineType::TOTAL()) { + if (Util::objectUses(PerformanceCountryField::class, $transactionLine)) { + $transactionLine->setPerformanceCountryFromString(self::getField($transaction, $lineElement, 'performancecountry')); + } + + if (Util::objectUses(PerformanceDateField::class, $transactionLine)) { + $transactionLine->setPerformanceDateFromString(self::getField($transaction, $lineElement, 'performancedate')); + } + + if (Util::objectUses(PerformanceTypeField::class, $transactionLine)) { + $transactionLine->setPerformanceTypeFromString(self::getField($transaction, $lineElement, 'performancetype')); + } + + if (Util::objectUses(PerformanceVatNumberField::class, $transactionLine)) { + $transactionLine->setPerformanceVatNumber(self::getField($transaction, $lineElement, 'performancevatnumber')); + } + + $transactionLine->setVatCodeFromString(self::getField($transaction, $lineElement, 'vatcode')); + } + $transaction->addLine($transactionLine); } } diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index ff9ef245..935566b3 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -82,7 +82,8 @@ public function testGetBankTransactionWorks() $this->assertSame(1.0, $totalLine->getRate()); $this->assertEquals(Money::EUR(65333), $totalLine->getRepValue()); $this->assertSame(1.500000000, $totalLine->getRepRate()); - $this->assertSame(MatchStatus::NOTMATCHABLE(), $totalLine->getMatchStatus()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); + $this->assertSame($ReflectObject->getConstant('NOTMATCHABLE'), (string)$totalLine->getMatchStatus()); $this->assertNull($totalLine->getMatchLevel()); $this->assertNull($totalLine->getBaseValueOpen()); $this->assertNull($totalLine->getVatCode()); @@ -105,7 +106,8 @@ public function testGetBankTransactionWorks() $this->assertEquals(Money::EUR(65333), $totalLine->getRepValue()); $this->assertSame(1.500000000, $totalLine->getRepRate()); $this->assertSame('Invoice paid', $detailLine->getDescription()); - $this->assertSame(MatchStatus::AVAILABLE(), $detailLine->getMatchStatus()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); + $this->assertSame($ReflectObject->getConstant('AVAILABLE'), (string)$detailLine->getMatchStatus()); $this->assertSame(2, $detailLine->getMatchLevel()); $this->assertEquals(Money::EUR(43555), $detailLine->getBaseValueOpen()); $this->assertEquals(Money::EUR(65333), $detailLine->getRepValue()); diff --git a/tests/IntegrationTests/CashTransactionIntegrationTest.php b/tests/IntegrationTests/CashTransactionIntegrationTest.php index 45f20312..93789ea6 100644 --- a/tests/IntegrationTests/CashTransactionIntegrationTest.php +++ b/tests/IntegrationTests/CashTransactionIntegrationTest.php @@ -84,7 +84,8 @@ public function testGetCashTransactionWorks() $this->assertSame(1.0, $totalLine->getRate()); $this->assertEquals(Money::EUR(65333), $totalLine->getRepValue()); $this->assertSame(1.500000000, $totalLine->getRepRate()); - $this->assertSame(MatchStatus::NOTMATCHABLE(), $totalLine->getMatchStatus()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); + $this->assertSame($ReflectObject->getConstant('NOTMATCHABLE'), (string)$totalLine->getMatchStatus()); $this->assertNull($totalLine->getMatchLevel()); $this->assertNull($totalLine->getBaseValueOpen()); $this->assertNull($totalLine->getVatCode()); @@ -107,7 +108,8 @@ public function testGetCashTransactionWorks() $this->assertEquals(Money::EUR(65333), $totalLine->getRepValue()); $this->assertSame(1.500000000, $totalLine->getRepRate()); $this->assertSame('Invoice paid', $detailLine->getDescription()); - $this->assertSame(MatchStatus::AVAILABLE(), $detailLine->getMatchStatus()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); + $this->assertSame($ReflectObject->getConstant('AVAILABLE'), (string)$detailLine->getMatchStatus()); $this->assertSame(2, $detailLine->getMatchLevel()); $this->assertEquals(Money::EUR(43555), $detailLine->getBaseValueOpen()); $this->assertEquals(Money::EUR(65333), $detailLine->getRepValue()); diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index 255f69fa..6125d502 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -65,7 +65,7 @@ public function testGetSalesTransactionWorks() $this->assertEquals(new \DateTimeImmutable('2013-05-06'), $salesTransaction->getDueDate()); $this->assertSame('20130-6000', $salesTransaction->getInvoiceNumber()); $this->assertSame('+++100/0160/01495+++', $salesTransaction->getPaymentReference()); - $this->assertSame('', $salesTransaction->getOriginReference()); + $this->assertNull($salesTransaction->getOriginReference()); /** @var SalesTransactionLine[] $salesTransactionLines */ $salesTransactionLines = $salesTransaction->getLines(); diff --git a/tests/IntegrationTests/resources/bankTransactionSendRequest.xml b/tests/IntegrationTests/resources/bankTransactionSendRequest.xml index 0c1ab476..be128c67 100644 --- a/tests/IntegrationTests/resources/bankTransactionSendRequest.xml +++ b/tests/IntegrationTests/resources/bankTransactionSendRequest.xml @@ -1,10 +1,10 @@
+ 001 BNK EUR - 20131104 - 001 + 20131104 4 974.01 1409.56 @@ -20,7 +20,6 @@ 1000 credit 435.55 - 11001770 Invoice paid diff --git a/tests/IntegrationTests/resources/cashTransactionSendRequest.xml b/tests/IntegrationTests/resources/cashTransactionSendRequest.xml index 14088409..b1fe1da8 100644 --- a/tests/IntegrationTests/resources/cashTransactionSendRequest.xml +++ b/tests/IntegrationTests/resources/cashTransactionSendRequest.xml @@ -1,10 +1,10 @@
+ 001 CASH EUR - 20131104 - 001 + 20131104 4 974.01 1409.56 @@ -20,7 +20,6 @@ 1000 credit 435.55 - 11001770 Invoice paid diff --git a/tests/IntegrationTests/resources/journalTransactionSendRequest.xml b/tests/IntegrationTests/resources/journalTransactionSendRequest.xml index 9664904c..94a1e21d 100644 --- a/tests/IntegrationTests/resources/journalTransactionSendRequest.xml +++ b/tests/IntegrationTests/resources/journalTransactionSendRequest.xml @@ -1,10 +1,10 @@
+ 001 MEMO EUR - 20131104 - 001 + 20131104
diff --git a/tests/IntegrationTests/resources/purchaseTransactionSendRequest.xml b/tests/IntegrationTests/resources/purchaseTransactionSendRequest.xml index 2eac4d75..b60cd1fe 100644 --- a/tests/IntegrationTests/resources/purchaseTransactionSendRequest.xml +++ b/tests/IntegrationTests/resources/purchaseTransactionSendRequest.xml @@ -1,14 +1,14 @@
+ 001 INK - EUR - 20130502 2013/05 - 20130-5481 - +++100/0160/01495+++ - 001 + EUR + 20130502 20130506 + 20130-5481 + +++100/0160/01495+++
@@ -16,7 +16,6 @@ 2000 credit 121 - 8020 diff --git a/tests/IntegrationTests/resources/salesTransactionSendRequest.xml b/tests/IntegrationTests/resources/salesTransactionSendRequest.xml index f871a257..52e68d3f 100644 --- a/tests/IntegrationTests/resources/salesTransactionSendRequest.xml +++ b/tests/IntegrationTests/resources/salesTransactionSendRequest.xml @@ -1,14 +1,14 @@
+ 001 SLS - EUR - 20130502 2013/05 - 20130-6000 - +++100/0160/01495+++ - 001 + EUR + 20130502 20130506 + 20130-6000 + +++100/0160/01495+++
@@ -16,7 +16,6 @@ 1000 debit 121 - 8020 From 7d08f62ca042594a6ed8d8163dd8ac9d2a92ec82 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 13:03:07 +0200 Subject: [PATCH 249/388] Upload --- tests/IntegrationTests/BankTransactionIntegrationTest.php | 4 ++-- tests/IntegrationTests/CashTransactionIntegrationTest.php | 4 ++-- .../JournalTransactionIntegrationTest.php | 8 +++++--- .../PurchaseTransactionIntegrationTest.php | 8 +++++--- .../IntegrationTests/SalesTransactionIntegrationTest.php | 8 +++++--- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index 935566b3..0454a101 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -88,8 +88,8 @@ public function testGetBankTransactionWorks() $this->assertNull($totalLine->getBaseValueOpen()); $this->assertNull($totalLine->getVatCode()); $this->assertNull($totalLine->getVatValue()); - $this->assertNull($totalLine->getVatTotal()); - $this->assertNull($totalLine->getVatBaseTotal()); + $this->assertEquals(Money::EUR(0), $totalLine->getVatTotal()); + $this->assertEquals(Money::EUR(0), $totalLine->getVatBaseTotal()); $this->assertNull($totalLine->getPerformanceType()); $this->assertNull($totalLine->getPerformanceCountry()); $this->assertNull($totalLine->getPerformanceVatNumber()); diff --git a/tests/IntegrationTests/CashTransactionIntegrationTest.php b/tests/IntegrationTests/CashTransactionIntegrationTest.php index 93789ea6..28c1898a 100644 --- a/tests/IntegrationTests/CashTransactionIntegrationTest.php +++ b/tests/IntegrationTests/CashTransactionIntegrationTest.php @@ -90,8 +90,8 @@ public function testGetCashTransactionWorks() $this->assertNull($totalLine->getBaseValueOpen()); $this->assertNull($totalLine->getVatCode()); $this->assertNull($totalLine->getVatValue()); - $this->assertNull($totalLine->getVatTotal()); - $this->assertNull($totalLine->getVatBaseTotal()); + $this->assertEquals(Money::EUR(0), $totalLine->getVatTotal()); + $this->assertEquals(Money::EUR(0), $totalLine->getVatBaseTotal()); $this->assertNull($totalLine->getPerformanceType()); $this->assertNull($totalLine->getPerformanceCountry()); $this->assertNull($totalLine->getPerformanceVatNumber()); diff --git a/tests/IntegrationTests/JournalTransactionIntegrationTest.php b/tests/IntegrationTests/JournalTransactionIntegrationTest.php index a04c38db..155905f6 100644 --- a/tests/IntegrationTests/JournalTransactionIntegrationTest.php +++ b/tests/IntegrationTests/JournalTransactionIntegrationTest.php @@ -73,7 +73,7 @@ public function testGetJournalTransactionWorks() $this->assertEquals(LineType::DETAIL(), $detailLine1->getLineType()); $this->assertSame(1, $detailLine1->getId()); $this->assertSame('4008', $detailLine1->getDim1ToString()); - $this->assertNull($detailLine1->getDim2()); + $this->assertNull($detailLine1->getDim2ToString()); $this->assertEquals(DebitCredit::DEBIT(), $detailLine1->getDebitCredit()); $this->assertEquals(Money::EUR(43555), $detailLine1->getValue()); $this->assertEquals(Money::EUR(43555), $detailLine1->getBaseValue()); @@ -81,7 +81,8 @@ public function testGetJournalTransactionWorks() $this->assertEquals(Money::EUR(65333), $detailLine1->getRepValue()); $this->assertSame(1.500000000, $detailLine1->getRepRate()); $this->assertNull($detailLine1->getDescription()); - $this->assertSame(MatchStatus::NOTMATCHABLE(), $detailLine1->getMatchStatus()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); + $this->assertSame($ReflectObject->getConstant('NOTMATCHABLE'), (string)$detailLine1->getMatchStatus()); $this->assertNull($detailLine1->getMatchLevel()); $this->assertNull($detailLine1->getBaseValueOpen()); $this->assertNull($detailLine1->getVatCode()); @@ -102,7 +103,8 @@ public function testGetJournalTransactionWorks() $this->assertEquals(Money::EUR(65333), $detailLine2->getRepValue()); $this->assertSame(1.500000000, $detailLine2->getRepRate()); $this->assertSame('Invoice paid', $detailLine2->getDescription()); - $this->assertSame(MatchStatus::AVAILABLE(), $detailLine2->getMatchStatus()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); + $this->assertSame($ReflectObject->getConstant('AVAILABLE'), (string)$detailLine2->getMatchStatus()); $this->assertSame(2, $detailLine2->getMatchLevel()); $this->assertEquals(Money::EUR(43555), $detailLine2->getBaseValueOpen()); $this->assertNull($detailLine2->getVatCode()); diff --git a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php index 7633aa87..6378aa69 100644 --- a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php +++ b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php @@ -81,8 +81,9 @@ public function testGetPurchaseTransactionWorks() $this->assertSame(1.0, $totalLine->getRate()); $this->assertEquals(Money::EUR(15653), $totalLine->getRepValue()); $this->assertSame(1.293600000, $totalLine->getRepRate()); - $this->assertSame('', $totalLine->getDescription()); - $this->assertSame(MatchStatus::AVAILABLE(), $totalLine->getMatchStatus()); + $this->assertNull($totalLine->getDescription()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); + $this->assertSame($ReflectObject->getConstant('AVAILABLE'), (string)$totalLine->getMatchStatus()); $this->assertSame(2, $totalLine->getMatchLevel()); $this->assertEquals(Money::EUR(12100), $totalLine->getBaseValueOpen()); $this->assertNull($totalLine->getVatCode()); @@ -102,7 +103,8 @@ public function testGetPurchaseTransactionWorks() $this->assertEquals(Money::EUR(12936), $detailLine->getRepValue()); $this->assertSame(1.293600000, $detailLine->getRepRate()); $this->assertSame('Outfit', $detailLine->getDescription()); - $this->assertSame(MatchStatus::NOTMATCHABLE(), $detailLine->getMatchStatus()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); + $this->assertSame($ReflectObject->getConstant('NOTMATCHABLE'), (string)$detailLine->getMatchStatus()); $this->assertNull($detailLine->getMatchLevel()); $this->assertNull($detailLine->getBaseValueOpen()); $this->assertSame('IH', $detailLine->getVatCodeToString()); diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index 6125d502..740bc4e5 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -82,8 +82,9 @@ public function testGetSalesTransactionWorks() $this->assertSame(1.0, $totalLine->getRate()); $this->assertEquals(Money::EUR(15653), $totalLine->getRepValue()); $this->assertSame(1.293600000, $totalLine->getRepRate()); - $this->assertSame('', $totalLine->getDescription()); - $this->assertSame(MatchStatus::AVAILABLE(), $totalLine->getMatchStatus()); + $this->assertNull($totalLine->getDescription()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); + $this->assertSame($ReflectObject->getConstant('AVAILABLE'), (string)$totalLine->getMatchStatus()); $this->assertSame(2, $totalLine->getMatchLevel()); $this->assertEquals(Money::EUR(12100), $totalLine->getBaseValueOpen()); $this->assertNull($totalLine->getVatCode()); @@ -107,7 +108,8 @@ public function testGetSalesTransactionWorks() $this->assertEquals(Money::EUR(12936), $detailLine->getRepValue()); $this->assertSame(1.293600000, $detailLine->getRepRate()); $this->assertSame('Outfit', $detailLine->getDescription()); - $this->assertSame(MatchStatus::NOTMATCHABLE(), $detailLine->getMatchStatus()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); + $this->assertSame($ReflectObject->getConstant('NOTMATCHABLE'), (string)$detailLine->getMatchStatus()); $this->assertNull($detailLine->getMatchLevel()); $this->assertNull($detailLine->getBaseValueOpen()); $this->assertSame('VH', $detailLine->getVatCodeToString()); From a1d8d65540df25f1d055f51c5f8a71d0f31d94aa Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 13:08:30 +0200 Subject: [PATCH 250/388] Upload --- tests/IntegrationTests/BankTransactionIntegrationTest.php | 2 +- tests/IntegrationTests/CashTransactionIntegrationTest.php | 2 +- tests/IntegrationTests/JournalTransactionIntegrationTest.php | 2 +- tests/IntegrationTests/PurchaseTransactionIntegrationTest.php | 2 +- tests/IntegrationTests/SalesTransactionIntegrationTest.php | 2 +- tests/UnitTests/BankTransactionLineUnitTest.php | 3 ++- tests/UnitTests/CashTransactionLineUnitTest.php | 3 ++- 7 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index 0454a101..fc4626e1 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -111,7 +111,7 @@ public function testGetBankTransactionWorks() $this->assertSame(2, $detailLine->getMatchLevel()); $this->assertEquals(Money::EUR(43555), $detailLine->getBaseValueOpen()); $this->assertEquals(Money::EUR(65333), $detailLine->getRepValue()); - $this->assertNull($detailLine->getVatCode()); + $this->assertNull($detailLine->getVatCodeToString()); $this->assertNull($detailLine->getVatValue()); $this->assertNull($detailLine->getVatTotal()); $this->assertNull($detailLine->getVatBaseTotal()); diff --git a/tests/IntegrationTests/CashTransactionIntegrationTest.php b/tests/IntegrationTests/CashTransactionIntegrationTest.php index 28c1898a..3c40e1be 100644 --- a/tests/IntegrationTests/CashTransactionIntegrationTest.php +++ b/tests/IntegrationTests/CashTransactionIntegrationTest.php @@ -113,7 +113,7 @@ public function testGetCashTransactionWorks() $this->assertSame(2, $detailLine->getMatchLevel()); $this->assertEquals(Money::EUR(43555), $detailLine->getBaseValueOpen()); $this->assertEquals(Money::EUR(65333), $detailLine->getRepValue()); - $this->assertNull($detailLine->getVatCode()); + $this->assertNull($detailLine->getVatCodeToString()); $this->assertNull($detailLine->getVatValue()); $this->assertNull($detailLine->getVatTotal()); $this->assertNull($detailLine->getVatBaseTotal()); diff --git a/tests/IntegrationTests/JournalTransactionIntegrationTest.php b/tests/IntegrationTests/JournalTransactionIntegrationTest.php index 155905f6..9e26d019 100644 --- a/tests/IntegrationTests/JournalTransactionIntegrationTest.php +++ b/tests/IntegrationTests/JournalTransactionIntegrationTest.php @@ -107,7 +107,7 @@ public function testGetJournalTransactionWorks() $this->assertSame($ReflectObject->getConstant('AVAILABLE'), (string)$detailLine2->getMatchStatus()); $this->assertSame(2, $detailLine2->getMatchLevel()); $this->assertEquals(Money::EUR(43555), $detailLine2->getBaseValueOpen()); - $this->assertNull($detailLine2->getVatCode()); + $this->assertNull($detailLine2->getVatCodeToString()); $this->assertNull($detailLine2->getVatValue()); $this->assertNull($detailLine2->getPerformanceType()); $this->assertNull($detailLine2->getPerformanceCountry()); diff --git a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php index 6378aa69..bfb9bfee 100644 --- a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php +++ b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php @@ -95,7 +95,7 @@ public function testGetPurchaseTransactionWorks() $this->assertEquals(LineType::DETAIL(), $detailLine->getLineType()); $this->assertSame(2, $detailLine->getId()); $this->assertSame('8020', $detailLine->getDim1ToString()); - $this->assertNull($detailLine->getDim2()); + $this->assertNull($detailLine->getDim2ToString()); $this->assertEquals(DebitCredit::DEBIT(), $detailLine->getDebitCredit()); $this->assertEquals(Money::EUR(10000), $detailLine->getValue()); $this->assertEquals(Money::EUR(10000), $detailLine->getBaseValue()); diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index 740bc4e5..13fecbdf 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -100,7 +100,7 @@ public function testGetSalesTransactionWorks() $this->assertEquals(LineType::DETAIL(), $detailLine->getLineType()); $this->assertSame(2, $detailLine->getId()); $this->assertSame('8020', $detailLine->getDim1ToString()); - $this->assertNull($detailLine->getDim2()); + $this->assertNull($detailLine->getDim2ToString()); $this->assertEquals(DebitCredit::CREDIT(), $detailLine->getDebitCredit()); $this->assertEquals(Money::EUR(10000), $detailLine->getValue()); $this->assertEquals(Money::EUR(10000), $detailLine->getBaseValue()); diff --git a/tests/UnitTests/BankTransactionLineUnitTest.php b/tests/UnitTests/BankTransactionLineUnitTest.php index 1121d305..5e2b58e4 100644 --- a/tests/UnitTests/BankTransactionLineUnitTest.php +++ b/tests/UnitTests/BankTransactionLineUnitTest.php @@ -85,7 +85,8 @@ public function testSetMatchStatus() $this->line->setLineType(LineType::DETAIL()); $this->assertEquals($this->line, $this->line->setMatchStatus(MatchStatus::MATCHED()), 'Fluid interface is expected'); - $this->assertSame(MatchStatus::MATCHED(), $this->line->getMatchStatus()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); + $this->assertSame($ReflectObject->getConstant('MATCHED'), (string)$this->line->getMatchStatus()); } public function testCanNotSetMatchStatusOtherThanNotMatchableIfLineTypeIsNotDetail() diff --git a/tests/UnitTests/CashTransactionLineUnitTest.php b/tests/UnitTests/CashTransactionLineUnitTest.php index 09065f93..55473c21 100644 --- a/tests/UnitTests/CashTransactionLineUnitTest.php +++ b/tests/UnitTests/CashTransactionLineUnitTest.php @@ -85,7 +85,8 @@ public function testSetMatchStatus() $this->line->setLineType(LineType::DETAIL()); $this->assertEquals($this->line, $this->line->setMatchStatus(MatchStatus::MATCHED()), 'Fluid interface is expected'); - $this->assertSame(MatchStatus::MATCHED(), $this->line->getMatchStatus()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); + $this->assertSame($ReflectObject->getConstant('MATCHED'), (string)$this->line->getMatchStatus()); } public function testCanNotSetMatchStatusOtherThanNotMatchableIfLineTypeIsNotDetail() From 564e413c513537db7696bd14678cb7cbdc2f8b1b Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 13:19:01 +0200 Subject: [PATCH 251/388] Upload --- tests/IntegrationTests/BankTransactionIntegrationTest.php | 6 +++--- tests/IntegrationTests/CashTransactionIntegrationTest.php | 6 +++--- .../IntegrationTests/JournalTransactionIntegrationTest.php | 6 +++--- tests/IntegrationTests/SalesTransactionIntegrationTest.php | 6 ++++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index fc4626e1..bcc3d3bf 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -112,9 +112,9 @@ public function testGetBankTransactionWorks() $this->assertEquals(Money::EUR(43555), $detailLine->getBaseValueOpen()); $this->assertEquals(Money::EUR(65333), $detailLine->getRepValue()); $this->assertNull($detailLine->getVatCodeToString()); - $this->assertNull($detailLine->getVatValue()); - $this->assertNull($detailLine->getVatTotal()); - $this->assertNull($detailLine->getVatBaseTotal()); + $this->assertEquals(Money::EUR(0), $detailLine->getVatValue()); + $this->assertEquals(Money::EUR(0), $detailLine->getVatTotal()); + $this->assertEquals(Money::EUR(0), $detailLine->getVatBaseTotal()); $this->assertNull($detailLine->getPerformanceType()); $this->assertNull($detailLine->getPerformanceCountry()); $this->assertNull($detailLine->getPerformanceVatNumber()); diff --git a/tests/IntegrationTests/CashTransactionIntegrationTest.php b/tests/IntegrationTests/CashTransactionIntegrationTest.php index 3c40e1be..bb98cc0e 100644 --- a/tests/IntegrationTests/CashTransactionIntegrationTest.php +++ b/tests/IntegrationTests/CashTransactionIntegrationTest.php @@ -114,9 +114,9 @@ public function testGetCashTransactionWorks() $this->assertEquals(Money::EUR(43555), $detailLine->getBaseValueOpen()); $this->assertEquals(Money::EUR(65333), $detailLine->getRepValue()); $this->assertNull($detailLine->getVatCodeToString()); - $this->assertNull($detailLine->getVatValue()); - $this->assertNull($detailLine->getVatTotal()); - $this->assertNull($detailLine->getVatBaseTotal()); + $this->assertEquals(Money::EUR(0), $detailLine->getVatValue()); + $this->assertEquals(Money::EUR(0), $detailLine->getVatTotal()); + $this->assertEquals(Money::EUR(0), $detailLine->getVatBaseTotal()); $this->assertNull($detailLine->getPerformanceType()); $this->assertNull($detailLine->getPerformanceCountry()); $this->assertNull($detailLine->getPerformanceVatNumber()); diff --git a/tests/IntegrationTests/JournalTransactionIntegrationTest.php b/tests/IntegrationTests/JournalTransactionIntegrationTest.php index 9e26d019..2421bd9c 100644 --- a/tests/IntegrationTests/JournalTransactionIntegrationTest.php +++ b/tests/IntegrationTests/JournalTransactionIntegrationTest.php @@ -85,8 +85,8 @@ public function testGetJournalTransactionWorks() $this->assertSame($ReflectObject->getConstant('NOTMATCHABLE'), (string)$detailLine1->getMatchStatus()); $this->assertNull($detailLine1->getMatchLevel()); $this->assertNull($detailLine1->getBaseValueOpen()); - $this->assertNull($detailLine1->getVatCode()); - $this->assertNull($detailLine1->getVatValue()); + $this->assertNull($detailLine1->getVatCodeToString()); + $this->assertEquals(Money::EUR(0), $detailLine->getVatValue()); $this->assertNull($detailLine1->getPerformanceType()); $this->assertNull($detailLine1->getPerformanceCountry()); $this->assertNull($detailLine1->getPerformanceVatNumber()); @@ -108,7 +108,7 @@ public function testGetJournalTransactionWorks() $this->assertSame(2, $detailLine2->getMatchLevel()); $this->assertEquals(Money::EUR(43555), $detailLine2->getBaseValueOpen()); $this->assertNull($detailLine2->getVatCodeToString()); - $this->assertNull($detailLine2->getVatValue()); + $this->assertEquals(Money::EUR(0), $detailLine2->getVatValue()); $this->assertNull($detailLine2->getPerformanceType()); $this->assertNull($detailLine2->getPerformanceCountry()); $this->assertNull($detailLine2->getPerformanceVatNumber()); diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index 13fecbdf..bf456145 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -117,7 +117,8 @@ public function testGetSalesTransactionWorks() $this->assertNull($detailLine->getVatTotal()); $this->assertNull($detailLine->getVatBaseTotal()); $this->assertNull($detailLine->getValueOpen()); - $this->assertNull($detailLine->getPerformanceType()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); + $this->assertSame($ReflectObject->getConstant(''), (string)$detailLine->getPerformanceType()); $this->assertNull($detailLine->getPerformanceCountry()); $this->assertNull($detailLine->getPerformanceVatNumber()); $this->assertNull($detailLine->getPerformanceDate()); @@ -141,7 +142,8 @@ public function testGetSalesTransactionWorks() $this->assertNull($vatLine->getVatTotal()); $this->assertNull($vatLine->getVatBaseTotal()); $this->assertNull($vatLine->getValueOpen()); - $this->assertNull($vatLine->getPerformanceType()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); + $this->assertSame($ReflectObject->getConstant(''), (string)$vatLine->getPerformanceType()); $this->assertNull($vatLine->getPerformanceCountry()); $this->assertNull($vatLine->getPerformanceVatNumber()); $this->assertNull($vatLine->getPerformanceDate()); From 220c4d2bd22b100ae6421d01bcd4e0546a9754c5 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 13:24:30 +0200 Subject: [PATCH 252/388] Upload --- tests/IntegrationTests/CashTransactionIntegrationTest.php | 4 ++-- tests/IntegrationTests/JournalTransactionIntegrationTest.php | 2 +- tests/IntegrationTests/SalesTransactionIntegrationTest.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/IntegrationTests/CashTransactionIntegrationTest.php b/tests/IntegrationTests/CashTransactionIntegrationTest.php index bb98cc0e..caa597fe 100644 --- a/tests/IntegrationTests/CashTransactionIntegrationTest.php +++ b/tests/IntegrationTests/CashTransactionIntegrationTest.php @@ -115,8 +115,8 @@ public function testGetCashTransactionWorks() $this->assertEquals(Money::EUR(65333), $detailLine->getRepValue()); $this->assertNull($detailLine->getVatCodeToString()); $this->assertEquals(Money::EUR(0), $detailLine->getVatValue()); - $this->assertEquals(Money::EUR(0), $detailLine->getVatTotal()); - $this->assertEquals(Money::EUR(0), $detailLine->getVatBaseTotal()); + $this->assertNull($detailLine->getVatTotal()); + $this->assertNull($detailLine->getVatBaseTotal()); $this->assertNull($detailLine->getPerformanceType()); $this->assertNull($detailLine->getPerformanceCountry()); $this->assertNull($detailLine->getPerformanceVatNumber()); diff --git a/tests/IntegrationTests/JournalTransactionIntegrationTest.php b/tests/IntegrationTests/JournalTransactionIntegrationTest.php index 2421bd9c..169ed97a 100644 --- a/tests/IntegrationTests/JournalTransactionIntegrationTest.php +++ b/tests/IntegrationTests/JournalTransactionIntegrationTest.php @@ -86,7 +86,7 @@ public function testGetJournalTransactionWorks() $this->assertNull($detailLine1->getMatchLevel()); $this->assertNull($detailLine1->getBaseValueOpen()); $this->assertNull($detailLine1->getVatCodeToString()); - $this->assertEquals(Money::EUR(0), $detailLine->getVatValue()); + $this->assertEquals(Money::EUR(0), $detailLine1->getVatValue()); $this->assertNull($detailLine1->getPerformanceType()); $this->assertNull($detailLine1->getPerformanceCountry()); $this->assertNull($detailLine1->getPerformanceVatNumber()); diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index bf456145..dceae3f4 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -143,7 +143,7 @@ public function testGetSalesTransactionWorks() $this->assertNull($vatLine->getVatBaseTotal()); $this->assertNull($vatLine->getValueOpen()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); - $this->assertSame($ReflectObject->getConstant(''), (string)$vatLine->getPerformanceType()); + $this->assertSame($ReflectObject->getConstant('EMPTY'), (string)$vatLine->getPerformanceType()); $this->assertNull($vatLine->getPerformanceCountry()); $this->assertNull($vatLine->getPerformanceVatNumber()); $this->assertNull($vatLine->getPerformanceDate()); From c9a42b99a33389c369b21e54d936781030d88889 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 13:29:34 +0200 Subject: [PATCH 253/388] Upload --- tests/IntegrationTests/BankTransactionIntegrationTest.php | 4 ++-- tests/IntegrationTests/CashTransactionIntegrationTest.php | 3 ++- .../IntegrationTests/JournalTransactionIntegrationTest.php | 6 ++++-- tests/IntegrationTests/SalesTransactionIntegrationTest.php | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index bcc3d3bf..7be9d70f 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -113,8 +113,8 @@ public function testGetBankTransactionWorks() $this->assertEquals(Money::EUR(65333), $detailLine->getRepValue()); $this->assertNull($detailLine->getVatCodeToString()); $this->assertEquals(Money::EUR(0), $detailLine->getVatValue()); - $this->assertEquals(Money::EUR(0), $detailLine->getVatTotal()); - $this->assertEquals(Money::EUR(0), $detailLine->getVatBaseTotal()); + $this->assertNull($detailLine->getVatTotal()); + $this->assertNull($detailLine->getVatBaseTotal()); $this->assertNull($detailLine->getPerformanceType()); $this->assertNull($detailLine->getPerformanceCountry()); $this->assertNull($detailLine->getPerformanceVatNumber()); diff --git a/tests/IntegrationTests/CashTransactionIntegrationTest.php b/tests/IntegrationTests/CashTransactionIntegrationTest.php index caa597fe..dbac3103 100644 --- a/tests/IntegrationTests/CashTransactionIntegrationTest.php +++ b/tests/IntegrationTests/CashTransactionIntegrationTest.php @@ -117,7 +117,8 @@ public function testGetCashTransactionWorks() $this->assertEquals(Money::EUR(0), $detailLine->getVatValue()); $this->assertNull($detailLine->getVatTotal()); $this->assertNull($detailLine->getVatBaseTotal()); - $this->assertNull($detailLine->getPerformanceType()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); + $this->assertSame($ReflectObject->getConstant('EMPTY'), (string)$detailLine->getPerformanceType()); $this->assertNull($detailLine->getPerformanceCountry()); $this->assertNull($detailLine->getPerformanceVatNumber()); $this->assertNull($detailLine->getPerformanceDate()); diff --git a/tests/IntegrationTests/JournalTransactionIntegrationTest.php b/tests/IntegrationTests/JournalTransactionIntegrationTest.php index 169ed97a..f3981c8d 100644 --- a/tests/IntegrationTests/JournalTransactionIntegrationTest.php +++ b/tests/IntegrationTests/JournalTransactionIntegrationTest.php @@ -87,7 +87,8 @@ public function testGetJournalTransactionWorks() $this->assertNull($detailLine1->getBaseValueOpen()); $this->assertNull($detailLine1->getVatCodeToString()); $this->assertEquals(Money::EUR(0), $detailLine1->getVatValue()); - $this->assertNull($detailLine1->getPerformanceType()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); + $this->assertSame($ReflectObject->getConstant('EMPTY'), (string)$detailLine1->getPerformanceType()); $this->assertNull($detailLine1->getPerformanceCountry()); $this->assertNull($detailLine1->getPerformanceVatNumber()); $this->assertNull($detailLine1->getPerformanceDate()); @@ -109,7 +110,8 @@ public function testGetJournalTransactionWorks() $this->assertEquals(Money::EUR(43555), $detailLine2->getBaseValueOpen()); $this->assertNull($detailLine2->getVatCodeToString()); $this->assertEquals(Money::EUR(0), $detailLine2->getVatValue()); - $this->assertNull($detailLine2->getPerformanceType()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); + $this->assertSame($ReflectObject->getConstant('EMPTY'), (string)$detailLine2->getPerformanceType()); $this->assertNull($detailLine2->getPerformanceCountry()); $this->assertNull($detailLine2->getPerformanceVatNumber()); $this->assertNull($detailLine2->getPerformanceDate()); diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index dceae3f4..bc3cd85f 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -118,7 +118,7 @@ public function testGetSalesTransactionWorks() $this->assertNull($detailLine->getVatBaseTotal()); $this->assertNull($detailLine->getValueOpen()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); - $this->assertSame($ReflectObject->getConstant(''), (string)$detailLine->getPerformanceType()); + $this->assertSame($ReflectObject->getConstant('EMPTY'), (string)$detailLine->getPerformanceType()); $this->assertNull($detailLine->getPerformanceCountry()); $this->assertNull($detailLine->getPerformanceVatNumber()); $this->assertNull($detailLine->getPerformanceDate()); From 361a7a17e36b629126308d7d32c7f54f7296e29b Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 13:34:11 +0200 Subject: [PATCH 254/388] Upload --- tests/IntegrationTests/BankTransactionIntegrationTest.php | 5 +++-- tests/IntegrationTests/CashTransactionIntegrationTest.php | 4 +--- tests/IntegrationTests/JournalTransactionIntegrationTest.php | 4 ++-- tests/IntegrationTests/SalesTransactionIntegrationTest.php | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index 7be9d70f..4d33c48e 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -115,8 +115,9 @@ public function testGetBankTransactionWorks() $this->assertEquals(Money::EUR(0), $detailLine->getVatValue()); $this->assertNull($detailLine->getVatTotal()); $this->assertNull($detailLine->getVatBaseTotal()); - $this->assertNull($detailLine->getPerformanceType()); - $this->assertNull($detailLine->getPerformanceCountry()); + $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); + $this->assertSame($ReflectObject->getConstant('EMPTY'), (string)$detailLine->getPerformanceType()); + $this->assertNull($detailLine->getPerformanceCountryToString()); $this->assertNull($detailLine->getPerformanceVatNumber()); $this->assertNull($detailLine->getPerformanceDate()); } diff --git a/tests/IntegrationTests/CashTransactionIntegrationTest.php b/tests/IntegrationTests/CashTransactionIntegrationTest.php index dbac3103..1d09e509 100644 --- a/tests/IntegrationTests/CashTransactionIntegrationTest.php +++ b/tests/IntegrationTests/CashTransactionIntegrationTest.php @@ -15,8 +15,6 @@ use PhpTwinfield\Mappers\TransactionMapper; use PhpTwinfield\Office; use PhpTwinfield\Response\Response; -use PhpTwinfield\SalesTransaction; -use PhpTwinfield\SalesTransactionLine; /** * @covers SalesTransaction @@ -119,7 +117,7 @@ public function testGetCashTransactionWorks() $this->assertNull($detailLine->getVatBaseTotal()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); $this->assertSame($ReflectObject->getConstant('EMPTY'), (string)$detailLine->getPerformanceType()); - $this->assertNull($detailLine->getPerformanceCountry()); + $this->assertNull($detailLine->getPerformanceCountryToString()); $this->assertNull($detailLine->getPerformanceVatNumber()); $this->assertNull($detailLine->getPerformanceDate()); } diff --git a/tests/IntegrationTests/JournalTransactionIntegrationTest.php b/tests/IntegrationTests/JournalTransactionIntegrationTest.php index f3981c8d..11c77efb 100644 --- a/tests/IntegrationTests/JournalTransactionIntegrationTest.php +++ b/tests/IntegrationTests/JournalTransactionIntegrationTest.php @@ -89,7 +89,7 @@ public function testGetJournalTransactionWorks() $this->assertEquals(Money::EUR(0), $detailLine1->getVatValue()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); $this->assertSame($ReflectObject->getConstant('EMPTY'), (string)$detailLine1->getPerformanceType()); - $this->assertNull($detailLine1->getPerformanceCountry()); + $this->assertNull($detailLine1->getPerformanceCountryToString()); $this->assertNull($detailLine1->getPerformanceVatNumber()); $this->assertNull($detailLine1->getPerformanceDate()); @@ -112,7 +112,7 @@ public function testGetJournalTransactionWorks() $this->assertEquals(Money::EUR(0), $detailLine2->getVatValue()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); $this->assertSame($ReflectObject->getConstant('EMPTY'), (string)$detailLine2->getPerformanceType()); - $this->assertNull($detailLine2->getPerformanceCountry()); + $this->assertNull($detailLine2->getPerformanceCountryToString()); $this->assertNull($detailLine2->getPerformanceVatNumber()); $this->assertNull($detailLine2->getPerformanceDate()); } diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index bc3cd85f..9e2a0656 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -119,7 +119,7 @@ public function testGetSalesTransactionWorks() $this->assertNull($detailLine->getValueOpen()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); $this->assertSame($ReflectObject->getConstant('EMPTY'), (string)$detailLine->getPerformanceType()); - $this->assertNull($detailLine->getPerformanceCountry()); + $this->assertNull($detailLine->getPerformanceCountryToString()); $this->assertNull($detailLine->getPerformanceVatNumber()); $this->assertNull($detailLine->getPerformanceDate()); From 9968021ebb38d4a07dbb55264e855dc8f827d080 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 13:39:55 +0200 Subject: [PATCH 255/388] Upload --- src/BaseTransactionLine.php | 2 +- src/TransactionLineInterface.php | 51 +++++++++++++++++++ .../SalesTransactionIntegrationTest.php | 2 +- 3 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 src/TransactionLineInterface.php diff --git a/src/BaseTransactionLine.php b/src/BaseTransactionLine.php index 1daff5c5..8a1c73eb 100644 --- a/src/BaseTransactionLine.php +++ b/src/BaseTransactionLine.php @@ -32,7 +32,7 @@ use PhpTwinfield\Fields\VatCodeField; use PhpTwinfield\Fields\VatValueField; -abstract class BaseTransactionLine +abstract class BaseTransactionLine implements TransactionLineInterface { use BaseValueField; use BaseValueOpenField; diff --git a/src/TransactionLineInterface.php b/src/TransactionLineInterface.php new file mode 100644 index 00000000..d0c47a22 --- /dev/null +++ b/src/TransactionLineInterface.php @@ -0,0 +1,51 @@ +assertNull($vatLine->getValueOpen()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); $this->assertSame($ReflectObject->getConstant('EMPTY'), (string)$vatLine->getPerformanceType()); - $this->assertNull($vatLine->getPerformanceCountry()); + $this->assertNull($vatLine->getPerformanceCountryToString()); $this->assertNull($vatLine->getPerformanceVatNumber()); $this->assertNull($vatLine->getPerformanceDate()); } From 02dd6040203227c7d6eb6ff39cd0e8ef68df5c6f Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 13:42:14 +0200 Subject: [PATCH 256/388] Update TransactionLineInterface.php --- src/TransactionLineInterface.php | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/TransactionLineInterface.php b/src/TransactionLineInterface.php index d0c47a22..de2f39a2 100644 --- a/src/TransactionLineInterface.php +++ b/src/TransactionLineInterface.php @@ -7,20 +7,6 @@ interface TransactionLineInterface { - /** - * Get the type of line. - * - * @return LineType - */ - public function getLineType(): LineType; - - /** - * Get the id of the line (or null if not sent to Twinfield yet). - * - * @return int|null - */ - public function getId(): ?int; - /** * Set the transaction on the line. This is needed later on. * From a683cbb415520944135e0d931fcaa604ff5c555f Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 14:19:53 +0200 Subject: [PATCH 257/388] Upload --- src/DomDocuments/TransactionsDocument.php | 89 ++++++++++++++++------- src/TransactionLineInterface.php | 1 - 2 files changed, 64 insertions(+), 26 deletions(-) diff --git a/src/DomDocuments/TransactionsDocument.php b/src/DomDocuments/TransactionsDocument.php index ab166589..3b939423 100644 --- a/src/DomDocuments/TransactionsDocument.php +++ b/src/DomDocuments/TransactionsDocument.php @@ -19,6 +19,7 @@ use PhpTwinfield\Fields\Transaction\RegimeField; use PhpTwinfield\Fields\Transaction\StatementNumberField; use PhpTwinfield\Fields\Transaction\TransactionLine\BaselineField; +use PhpTwinfield\Fields\Transaction\TransactionLine\CurrencyDateField; use PhpTwinfield\Fields\Transaction\TransactionLine\FreeCharField; use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceCountryField; use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceVatNumberField; @@ -135,11 +136,11 @@ public function addTransaction(BaseTransaction $transaction) $lineElement->appendChild($this->createNodeWithTextContent('dim1', $transactionLine->getDim1ToString())); - if (!empty($transactionLine->getDim2ToString())) { + if (!empty($transactionLine->getDim2())) { $lineElement->appendChild($this->createNodeWithTextContent('dim2', $transactionLine->getDim2ToString())); } - if (!empty($transactionLine->getDim3ToString())) { + if (!empty($transactionLine->getDim3())) { $lineElement->appendChild($this->createNodeWithTextContent('dim3', $transactionLine->getDim3ToString())); } @@ -151,36 +152,40 @@ public function addTransaction(BaseTransaction $transaction) if (Util::objectUses(BaselineField::class, $transactionLine) && !empty($transactionLine->getBaseline())) { $lineElement->appendChild($this->createNodeWithTextContent('baseline', $transactionLine->getBaseline())); } + + if (!empty($transactionLine->getBaseValue())) { + $lineElement->appendChild($this->createNodeWithTextContent('basevalue', $transactionLine->getBaseValueToFloat())); + } + + if (!empty($transactionLine->getComment())) { + $lineElement->appendChild($this->createNodeWithTextContent('comment', $transactionLine->getComment())); + } + + if (Util::objectUses(CurrencyDateField::class, $transactionLine) && !empty($transactionLine->getCurrencyDate())) { + $lineElement->appendChild($this->createNodeWithTextContent("currencydate", $transactionLine->getCurrencyDateToString())); + } if (!empty($transactionLine->getDescription())) { $lineElement->appendChild($this->createNodeWithTextContent('description', $transactionLine->getDescription())); } + + if (!empty($transactionLine->getDestOffice())) { + $lineElement->appendChild($this->createNodeWithTextContent('destoffice', $transactionLine->getDestOfficeToString())); + } if (Util::objectUses(FreeCharField::class, $transactionLine) && !empty($transactionLine->getFreeChar())) { $lineElement->appendChild($this->createNodeWithTextContent('freechar', $transactionLine->getFreeChar())); } - if (Util::objectUses(FreeText1Field::class, $transactionLine) && !empty($transactionLine->getFreetext1())) { - $lineElement->appendChild($this->createNodeWithTextContent('freetext1', $transactionLine->getFreetext1())); - } - - if (Util::objectUses(FreeText2Field::class, $transactionLine) && !empty($transactionLine->getFreetext2())) { - $lineElement->appendChild($this->createNodeWithTextContent('freetext2', $transactionLine->getFreetext2())); - } - - if (Util::objectUses(FreeText3Field::class, $transactionLine) && !empty($transactionLine->getFreetext3())) { - $lineElement->appendChild($this->createNodeWithTextContent('freetext3', $transactionLine->getFreetext3())); - } - if (Util::objectUses(InvoiceNumberField::class, $transactionLine) && !empty($transactionLine->getInvoiceNumber())) { $lineElement->appendChild($this->createNodeWithTextContent('invoicenumber', $transactionLine->getInvoiceNumber())); } - if (Util::objectUses(PerformanceCountryField::class, $transactionLine) && !empty($transactionLine->getPerformanceCountryToString())) { + if (Util::objectUses(PerformanceCountryField::class, $transactionLine) && !empty($transactionLine->getPerformanceCountry())) { $lineElement->appendChild($this->createNodeWithTextContent('performancecountry', $transactionLine->getPerformanceCountryToString())); } - if (Util::objectUses(PerformanceDateField::class, $transactionLine) && !empty($transactionLine->getPerformanceDateToString())) { + if (Util::objectUses(PerformanceDateField::class, $transactionLine) && !empty($transactionLine->getPerformanceDate())) { $lineElement->appendChild($this->createNodeWithTextContent("performancedate", $transactionLine->getPerformanceDateToString())); } @@ -191,24 +196,58 @@ public function addTransaction(BaseTransaction $transaction) if (Util::objectUses(PerformanceVatNumberField::class, $transactionLine) && !empty($transactionLine->getPerformanceVatNumber())) { $lineElement->appendChild($this->createNodeWithTextContent('performancevatnumber', $transactionLine->getPerformanceVatNumber())); } + + if (!empty($transactionLine->getRate())) { + $lineElement->appendChild($this->createNodeWithTextContent('rate', $transactionLine->getRate())); + } + + if (!empty($transactionLine->getRepRate())) { + $lineElement->appendChild($this->createNodeWithTextContent('reprate', $transactionLine->getRepRate())); + } + + if (!empty($transactionLine->getRepValue())) { + $lineElement->appendChild($this->createNodeWithTextContent('repvalue', $transactionLine->getRepValueToFloat())); + } + + if (Util::objectUses(VatBaseTotalField::class, $transactionLine) && !empty($transactionLine->getVatBaseTotal())) { + $lineElement->appendChild($this->createNodeWithTextContent('vatbasetotal', $transactionLine->getVatBaseTotalToFloat())); + } + + if (!empty($transactionLine->getVatBaseTurnover())) { + $lineElement->appendChild($this->createNodeWithTextContent('vatbaseturnover', $transactionLine->getVatBaseTurnoverToFloat())); + } + + if (!empty($transactionLine->getVatBaseValue())) { + $lineElement->appendChild($this->createNodeWithTextContent('vatbasevalue', $transactionLine->getVatBaseValueToFloat())); + } - // ** // + if (!empty($transactionLine->getVatCode())) { + $lineElement->appendChild($this->createNodeWithTextContent('vatcode', $transactionLine->getVatCodeToString())); + } + + if (Util::objectUses(VatRepTotalField::class, $transactionLine) && !empty($transactionLine->getVatRepTotal())) { + $lineElement->appendChild($this->createNodeWithTextContent('vatreptotal', $transactionLine->getVatRepTotalToFloat())); + } + + if (!empty($transactionLine->getVatRepValue())) { + $lineElement->appendChild($this->createNodeWithTextContent('vatrepvalue', $transactionLine->getVatRepValueToFloat())); + } + + if (!empty($transactionLine->getVatRepTurnover())) { + $lineElement->appendChild($this->createNodeWithTextContent('vatrepturnover', $transactionLine->getVatRepTurnoverToFloat())); + } if (Util::objectUses(VatTotalField::class, $transactionLine) && !empty($transactionLine->getVatTotal())) { $lineElement->appendChild($this->createNodeWithTextContent('vattotal', $transactionLine->getVatTotalToFloat())); } - - if (Util::objectUses(VatBaseTotalField::class, $transactionLine) && !empty($transactionLine->getVatBaseTotal())) { - $lineElement->appendChild($this->createNodeWithTextContent('vatbasetotal', $transactionLine->getVatBaseTotalToFloat())); + + if (!empty($transactionLine->getVatTurnover())) { + $lineElement->appendChild($this->createNodeWithTextContent('vatturnover', $transactionLine->getVatTurnoverToFloat())); } - + if (!empty($transactionLine->getVatValue())) { $lineElement->appendChild($this->createNodeWithTextContent('vatvalue', $transactionLine->getVatValueToFloat())); } - - if ($transactionLine->getVatCode() !== null) { - $lineElement->appendChild($this->createNodeWithTextContent('vatcode', $transactionLine->getVatCodeToString())); - } } } } diff --git a/src/TransactionLineInterface.php b/src/TransactionLineInterface.php index de2f39a2..f5b7a0d7 100644 --- a/src/TransactionLineInterface.php +++ b/src/TransactionLineInterface.php @@ -2,7 +2,6 @@ namespace PhpTwinfield; -use PhpTwinfield\Enums\LineType; use PhpTwinfield\MatchReferenceInterface; interface TransactionLineInterface From e0f5377dc1fcc4c449667ecdc32a39060fdc0935 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 14:22:13 +0200 Subject: [PATCH 258/388] Update TransactionsDocument.php --- src/DomDocuments/TransactionsDocument.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DomDocuments/TransactionsDocument.php b/src/DomDocuments/TransactionsDocument.php index 3b939423..ca48eeba 100644 --- a/src/DomDocuments/TransactionsDocument.php +++ b/src/DomDocuments/TransactionsDocument.php @@ -26,13 +26,14 @@ use PhpTwinfield\Fields\Transaction\TransactionLine\ValueFields; use PhpTwinfield\Fields\Transaction\TransactionLine\ValueOpenField; use PhpTwinfield\Fields\Transaction\TransactionLine\VatBaseTotalField; +use PhpTwinfield\Fields\Transaction\TransactionLine\VatRepTotalField; use PhpTwinfield\Fields\Transaction\TransactionLine\VatTotalField; use PhpTwinfield\Util; /** * TransactionsDocument class. * - * @author Dylan Schoenmakers + * @author Dylan Schoenmakers , extended by Yannick Aerssens */ class TransactionsDocument extends BaseDocument { From 424367337bd9d8b9654d968c6d7dfb33258e14cb Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 21 May 2019 14:42:04 +0200 Subject: [PATCH 259/388] Upload --- breaking262.md | 85 -------------------- src/ApiConnectors/BrowseDataApiConnector.php | 4 +- src/ApiConnectors/UserApiConnector.php | 22 ----- 3 files changed, 2 insertions(+), 109 deletions(-) delete mode 100644 breaking262.md diff --git a/breaking262.md b/breaking262.md deleted file mode 100644 index e488cb91..00000000 --- a/breaking262.md +++ /dev/null @@ -1,85 +0,0 @@ -# Breaking changes since 2.6.2 -Release 3.0 added multiple new resources, but also broke several existing ones. - -Breaking changes are present in: -- Bank Transactions (Separate API connector completely removed and functionality moved to general Transactions API Connector) -- Articles -- Customers -- Sales Invoices -- Suppliers -- Vat Codes - -Except for Bank Transactions, the breaking changes are primarily due to the fact that most fields and methods are now properly type cast. - -This means (among others) that all booleans are now type cast as bool, all monetary values are now Money\Money instances and several fields now use Enums instead of strings. - -Another big change is that retrieved fields that are instances of another entity in Twinfield and this library are now retrieved and set in the same way as was already done with Office or Customer codes. -So for example a VAT code retrieved from or set to a PhpTwinfield\Article will now become an instance of PhpTwinfield\VatCode with its $code set to "VH" instead of begin just a string with the value "VH". - -Most of these changed methods have gained ToString/FromString or ToFloat/FromFloat methods that will ease the transition. - -See the tables per class below for breaking changes and suggestions for fixes/replacement methods. - -## Bank Transactions - -| Class/Method | Change | Replaced by | Old Usage | New Usage | -| -------------------------------------------------------------------------- | :-----------------------------------: | :-----------------------------------: | :-----------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------: | -| ApiConnectors\BankTransactionApiConnector | Class removed | ApiConnectors\TransactionApiConnector | $bankTransactionApiConnector = ApiConnectors\BankTransactionApiConnector; | $bankTransactionApiConnector = ApiConnectors\BankTransactionApiConnector; | -| Transactions\BankTransactionLine\Base | Class removed | BankTransactionLine | N.A. | N.A. | -| Transactions\BankTransactionLine\Detail | Class removed | BankTransactionLine | $bankTransactionLineDetail = New Transactions\BankTransactionLine\Detail; | $bankTransactionLineDetail = New BankTransactionLine; $bankTransactionLine->setType(LineType::DETAIL()) | -| Transactions\BankTransactionLine\Total | Class removed | BankTransactionLine | $bankTransactionLineTotal = New Transactions\BankTransactionLine\Total; | $bankTransactionLineTotal = New BankTransactionLine; $bankTransactionLine->setType(LineType::TOTAL()) | -| Transactions\BankTransactionLine\Vat | Class removed | BankTransactionLine | $bankTransactionLineVat = New Transactions\BankTransactionLine\Vat; | $bankTransactionLineVat = New BankTransactionLine; $bankTransactionLine->setType(LineType::VAT()) | -| Transactions\BankTransactionLine\Detail::setAccount | Method removed | BankTransactionLine::setDim1 | $bankTransactionLineDetail->setAccount('4010'); | $bankTransactionLineDetail->setDim1FromString('4010'); | -| Transactions\BankTransactionLine\Detail::setCustomerOrSupplierOrCostCenter | Method removed | BankTransactionLine::setDim2 | $bankTransactionLineDetail->setCustomerOrSupplierOrCostCenter('2010'); | $bankTransactionLineDetail->setDim2FromString('2010'); | -| Transactions\BankTransactionLine\Detail::setProjectOrAsset | Method removed | BankTransactionLine::setDim3 | $bankTransactionLineDetail->setProjectOrAsset('2010'); | $bankTransactionLineDetail->setDim3FromString('P000'); | -| Transactions\BankTransactionLine\Total::setBankBalanceAccount | Method removed | BankTransactionLine::setDim1 | $bankTransactionLineTotal->setBankBalanceAccount('5010'); | $bankTransactionLineTotal->setDim1FromString('5010'); | -| Transactions\BankTransactionLine\Vat::setVatBalanceAccount | Method removed | BankTransactionLine::setDim1 | $bankTransactionLineVat->setVatBalanceAccount('5050'); | $bankTransactionLineVat->setDim1FromString('5050'); | - -## Articles - -| Class/Method | Change | Replaced by | Old Usage | New Usage | -| ---------------------------------- | :--------------------------------------------------------------------: | :-----------------------------------: | :----------------------------------------: | :--------------------------------------------------------------------------------------------------------------------: | -| Article::setStatus | setStatus now expects Enums\Status instead of string | Article::setStatusFromString | $article->setStatus('active'); | $article->setStatusFromString('active'); OR $article->setStatus(Enums\Status::ACTIVE()) | -| Article::setType | setType now expects Enums\ArticleType instead of string | Article::setTypeFromString | $article->setType('normal'); | $article->setTypeFromString('normal'); OR $article->setType(Enums\ArticleType::NORMAL()) | -| Article::setPerformanceType | setPerformanceType now expects Enums\PerformanceType instead of string | Article::setPerformanceTypeFromString | $article->setPerformanceType('services'); | $article->setPerformanceTypeFromString('services'); OR $article->setPerformanceType(Enums\PerformanceType::SERVICES()) | -| Article::getAllowDiscountorPremium | Properly camelCased | Article::getAllowDiscountOrPremium | $article->getAllowDiscountorPremium(true); | $article->getAllowDiscountOrPremium(true); | -| Article::setAllowDiscountorPremium | Properly camelCased | Article::setAllowDiscountOrPremium | $article->setAllowDiscountorPremium(true); | $article->setAllowDiscountOrPremium(true); | - -### Article Lines - -| Class/Method | Change | Replaced by | Old Usage | New Usage | -| ------------------------------ | :---------------------------------------------------------: | :-------------------------------------: | :--------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------: | -| ArticleLine::setStatus | setStatus now expects Enums\Status instead of string | ArticleLine::setStatusFromString | $articleLine->setStatus('active'); | $articleLine->setStatusFromString('active'); OR $articleLine->setStatus(Enums\Status::ACTIVE()) | -| ArticleLine::getUnitsPriceInc | getUnitsPriceInc now returns Money instead of string/float | ArticleLine::getUnitsPriceIncToFloat | $unitsPriceInc = $articleLine->getUnitsPriceInc(); | $unitsPriceInc = $articleLine->getUnitsPriceIncToFloat(); OR $unitsPriceInc = \Money\Formatter\DecimalMoneyFormatter::format($articleLine->getUnitsPriceInc()); | -| ArticleLine::setUnitsPriceInc | setUnitsPriceInc now expects Money instead of string/float | ArticleLine::setUnitsPriceIncFromFloat | $articleLine->setUnitsPriceInc(100.50); | $articleLine->setUnitsPriceIncFromFloat(100.50); OR $articleLine->setUnitsPriceInc(New \Money\Money(10050), new \Money\Currency('EUR')); | -| ArticleLine::getUnitsPriceExcl | getUnitsPriceExcl now returns Money instead of string/float | ArticleLine::getUnitsPriceExclToFloat | $unitsPriceExcl = $articleLine->getUnitsPriceExcl(); | $unitsPriceExcl = $articleLine->getUnitsPriceExclToFloat(); OR $unitsPriceExcl = \Money\Formatter\DecimalMoneyFormatter::format($articleLine->getUnitsPriceExcl()); | -| ArticleLine::setUnitsPriceExcl | setUnitsPriceExcl now expects Money instead of string/float | ArticleLine::setUnitsPriceExclFromFloat | $articleLine->setUnitsPriceExcl(80.75); | $articleLine->setUnitsPriceExclFromFloat(80.75); OR $articleLine->setUnitsPriceExcl(New \Money\Money(8075), new \Money\Currency('EUR')); | -| ArticleLine::getFreeText1 | getFreeText1 now returns GeneralLedger instead of string | ArticleLine::getFreeText1ToString | $dim1 = $articleLine->getFreeText1(); | $dim1 = $articleLine->getFreeText1ToString(); OR $dim1 = $articleLine->getFreeText1()->getCode(); | -| ArticleLine::setFreeText1 | setFreeText1 now expects GeneralLedger instead of string | ArticleLine::setFreeText1FromString | $articleLine->setFreeText1('4050'); | $articleLine->setFreeText1FromString('4050'); OR $dim1 = new GeneralLedger; $dim1->setCode('4050'); $articleLine->setFreeText1($dim1); | - -## Customers - -## Sales Invoices - -## Suppliers - -## Cash/Journal/Purchase/Sale Transactions - -BaseTransaction getCurrency now returns PhpTwinfield\Currency instead of Money\Currency -BaseTransaction setCurrency now expects PhpTwinfield\Currency instead of Money\Currency - -BaseTransactionLine setId -> setID - -BankTransaction getCloseValue Properly camelCased -BankTransaction setCloseValue Properly camelCased - -BankTransaction getStartValue Properly camelCased -BankTransaction setStartValue Properly camelCased - -CashTransaction getCloseValue Properly camelCased -CashTransaction setCloseValue Properly camelCased - -CashTransaction getStartValue Properly camelCased -CashTransaction setStartValue Properly camelCased - -## VAT diff --git a/src/ApiConnectors/BrowseDataApiConnector.php b/src/ApiConnectors/BrowseDataApiConnector.php index 2fa2d9b0..d1f1ba7f 100644 --- a/src/ApiConnectors/BrowseDataApiConnector.php +++ b/src/ApiConnectors/BrowseDataApiConnector.php @@ -2,13 +2,13 @@ namespace PhpTwinfield\ApiConnectors; -use PhpTwinfield\Exception; use PhpTwinfield\BrowseColumn; use PhpTwinfield\BrowseSortField; +use PhpTwinfield\Exception; use PhpTwinfield\Mappers\BrowseDataMapper; use PhpTwinfield\Mappers\BrowseDefinitionMapper; -use PhpTwinfield\Request\BrowseData; use PhpTwinfield\Mappers\BrowseFieldMapper; +use PhpTwinfield\Request\BrowseData; use PhpTwinfield\Request\Catalog\BrowseField; use PhpTwinfield\Request\Read\BrowseDefinition; use Webmozart\Assert\Assert; diff --git a/src/ApiConnectors/UserApiConnector.php b/src/ApiConnectors/UserApiConnector.php index 71cd2dc3..1a8c735a 100644 --- a/src/ApiConnectors/UserApiConnector.php +++ b/src/ApiConnectors/UserApiConnector.php @@ -23,12 +23,6 @@ */ class UserApiConnector extends BaseApiConnector { - const ACCESS_RULES_DISABLED = 0; - const ACCESS_RULES_ENABLED = 1; - - const MUTUAL_OFFICES_DISABLED = 0; - const MUTUAL_OFFICES_ENABLED = 1; - /** * Requests a specific User based off the passed in code and optionally the office. * @@ -55,9 +49,6 @@ public function get(string $code, Office $office): User /** * List all users. * - * @param string|null $officeCode The office code, if only users from one office should be listed - * @param integer|null $accessRules One of the self::ACCESS_RULES_* constants. - * @param integer|null $mutualOffices One of the self::MUTUAL_OFFICES_* constants. * @param string $pattern The search pattern. May contain wildcards * and ? * @param int $field The search field determines which field or fields will be searched. The * available fields depends on the finder type. Passing a value outside the @@ -71,25 +62,12 @@ public function get(string $code, Office $office): User * @return User[] The users found. */ public function listAll( - $officeCode = null, - $accessRules = null, - $mutualOffices = null, $pattern = '*', $field = 0, $firstRow = 1, $maxRows = 100, $options = array() ): array { - if (!is_null($officeCode)) { - $options['office'] = $officeCode; - } - if (!is_null($accessRules)) { - $options['accessRules'] = $accessRules; - } - if (!is_null($mutualOffices)) { - $options['mutualOffices'] = $mutualOffices; - } - $optionsArrayOfString = $this->convertOptionsToArrayOfString($options); $response = $this->getFinderService()->searchFinder(FinderService::TYPE_USERS, $pattern, $field, $firstRow, $maxRows, $optionsArrayOfString); From 619822da1a099b6fbcb2f5ca56a838a70993740c Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 22 May 2019 13:37:46 +0200 Subject: [PATCH 260/388] Upload --- examples/Activity.php | 368 ++++++++++++++++++++++++ examples/Authorization.php | 2 +- examples/CostCenter.php | 19 +- examples/Currency.php | 17 +- examples/DimensionGroup.php | 239 +++++++++++++++ examples/InvoiceType.php | 89 ++++++ examples/Project.php | 368 ++++++++++++++++++++++++ examples/VatCode.php | 300 +++++++++++++++++++ src/DomDocuments/ActivitiesDocument.php | 6 +- src/DomDocuments/ProjectsDocument.php | 6 +- src/Mappers/VatCodeMapper.php | 2 +- 11 files changed, 1401 insertions(+), 15 deletions(-) create mode 100644 examples/Activity.php create mode 100644 examples/DimensionGroup.php create mode 100644 examples/InvoiceType.php create mode 100644 examples/Project.php create mode 100644 examples/VatCode.php diff --git a/examples/Activity.php b/examples/Activity.php new file mode 100644 index 00000000..f3a5ce77 --- /dev/null +++ b/examples/Activity.php @@ -0,0 +1,368 @@ + accessrules = 0 +if ($executeListAllWithFilter) { + $options = array('accessrules' => 0); + + try { + $activities = $activityApiConnector->listAll("A*", 0, 1, 10, $options); + } catch (ResponseException $e) { + $activities = $e->getReturnedObject(); + } + + echo "
";
+    print_r($activities);
+    echo "
"; +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +if ($executeListAllWithoutFilter) { + try { + $activities = $activityApiConnector->listAll(); + } catch (ResponseException $e) { + $activities = $e->getReturnedObject(); + } + + echo "
";
+    print_r($activities);
+    echo "
"; +} + +/* Activity + * \PhpTwinfield\Activity + * Available getters: getBehaviour, getCode, getInUse, getInUseToString, getMessages, getName, getOffice, getOfficeToString, getResult, getShortName, getStatus, getTouched, getType, getTypeToString, getUID, getVatCode, getVatCodeToString, hasMessages, getProjects + * Available setters: setBehaviour, setBehaviourFromString, setCode, setName, setOffice, setOfficeFromString, setShortName, setStatus, setStatusFromString, setType, setTypeFromString, setVatCode, setVatCodeFromString, setProjects + */ + +/* ActivityProjects + * \PhpTwinfield\ActivityProjects + * Available getters: getAuthoriser, getAuthoriserInherit, getAuthoriserInheritToString, getAuthoriserLocked, getAuthoriserLockedToString, getAuthoriserToString, getBillable, getBillableForRatio, getBillableForRatioToString, getBillableInherit, getBillableInheritToString, + * getBillableLocked, getBillableLockedToString, getBillableToString, getCustomer, getCustomerInherit, getCustomerInheritToString, getCustomerLocked, getCustomerLockedToString, getCustomerToString, getInvoiceDescription, getMessages, getRate, getRateInherit, getRateInheritToString, + * getRateLocked, getRateLockedToString, getRateToString, getResult, getValidFrom, getValidFromToString, getValidTill, getValidTillToString, hasMessages, getQuantities + * + * Available setters: setAuthoriser, setAuthoriserFromString, setAuthoriserInherit, setAuthoriserInheritFromString, setAuthoriserLocked, setAuthoriserLockedFromString, setBillable, setBillableForRatio, setBillableForRatioFromString, setBillableFromString, setBillableInherit, setBillableInheritFromString, + * setBillableLocked, setBillableLockedFromString, setCustomer, setCustomerFromString, setCustomerInherit, setCustomerInheritFromString, setCustomerLocked, setCustomerLockedFromString, setInvoiceDescription, setRate, setRateFromString, setRateInherit, setRateInheritFromString, + * setRateLocked, setRateLockedFromString, setValidFrom, setValidFromFromString, setValidTill, setValidTillFromString, addQuantity, removeQuantity + * + */ + +/* ActivityQuantity + * \PhpTwinfield\ActivityQuantity + * Available getters: getBillable, getBillableLocked, getBillableLockedToString, getBillableToString, getLabel, getMandatory, getMandatoryToString, getMessages, getRate, getRateToString, getResult, hasMessages + * Available setters: setBillable, setBillableFromString, setBillableLocked, setBillableLockedFromString, setLabel, setMandatory, setMandatoryFromString, setRate, setRateFromString + */ + +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($activities as $key => $activity) { + echo "Activity {$key}
"; + echo "Code: {$activity->getCode()}
"; + echo "Name: {$activity->getName()}

"; + } +} + +// Read an Activity based off the passed in code and optionally the office. +if ($executeRead) { + try { + $activity = $activityApiConnector->get("A000", $office); + } catch (ResponseException $e) { + $activity = $e->getReturnedObject(); + } + + echo "
";
+    print_r($activity);
+    echo "
"; + + echo "Activity
"; + echo "Behaviour: {$activity->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. + echo "Code: {$activity->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the ACT Dimension type. + echo "InUse (bool): {$activity->getInUse()}
"; // bool|null Indicates whether the activity is used in a transaction or not. Read-only attribute. + echo "InUse (string): {$activity->getInUseToString()}
"; // string|null + + if ($activity->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($activity->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Name: {$activity->getName()}
"; // string|null Activity description. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($activity->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): {$activity->getOfficeToString()}
"; // string|null + echo "Result: {$activity->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$activity->getShortName()}
"; // string|null Short activity description. + echo "Status: {$activity->getStatus()}
"; // Status|null Status of the activity. + echo "Touched: {$activity->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. + echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($activity->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is ACT. + echo "Type (string): {$activity->getTypeToString()}
"; // string|null + echo "UID: {$activity->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. + echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($activity->getVatCode(), true) . "

"; // VatCode|null The VAT code if one code will apply for all activities within the project. Note that if any VAT codes are + echo "VatCode (string): {$activity->getVatCodeToString()}
"; // string|null defined on activity level, these will apply regardless of what is defined on project level. + + $activityProjects = $activity->getProjects(); // ActivityProjects|null ActivityProjects object. + + echo "Authoriser (\\PhpTwinfield\\User):
" . print_r($activityProjects->getAuthoriser(), true) . "

"; // User|null A specific authoriser for an activity. + echo "Authoriser (string): {$activityProjects->getAuthoriserToString()}
"; // string|null If "change" = allow then locked = false and inherit = false + echo "Authoriser Inherit (bool): {$activityProjects->getAuthoriserInherit()}
"; // bool|null + echo "Authoriser Inherit (string): {$activityProjects->getAuthoriserInheritToString()}
"; // string|null If "change" = disallow then locked = true and inherit = false + echo "Authoriser Locked (bool): {$activityProjects->getAuthoriserLocked()}
"; // bool|null + echo "Authoriser Locked (string): {$activityProjects->getAuthoriserLockedToString()}
"; // string|null If "change" = inherit then locked = true and inherit = true + echo "Billable (bool): {$activityProjects->getBillable()}
"; // bool|null Choose to make an activity billable (true) or not (false) and whether or not it should be included when calculating the "productivity" ratio (@forratio). + echo "Billable (string): {$activityProjects->getBillableToString()}
"; // string|null You could also decide that these settings should be inherited from project or user level (@inherit). + echo "Billable ForRatio (bool): {$activityProjects->getBillableForRatio()}
"; // bool|null You can also set whether a change of these settings is allowed or disallowed when a user is entering their timesheet (@locked). + echo "Billable ForRatio (string): {$activityProjects->getBillableForRatioToString()}
"; // string|null If "change" = allow then locked = false and inherit = false. + echo "Billable Inherit (bool): {$activityProjects->getBillableInherit()}
"; // bool|null + echo "Billable Inherit (string): {$activityProjects->getBillableInheritToString()}
"; // string|null If "change" = disallow then locked = true and inherit = false. + echo "Billable Locked (bool): {$activityProjects->getBillableLocked()}
"; // bool|null + echo "Billable Locked (string): {$activityProjects->getBillableLockedToString()}
"; // string|null If "change" = inherit then locked = true and inherit = true + echo "Customer (\\PhpTwinfield\\Customer):
" . print_r($activityProjects->getCustomer(), true) . "

"; // Customer|null An activity always needs to be linked to a customer. + echo "Customer (string): {$activityProjects->getCustomerToString()}
"; // string|null Choose to have the customer ‘inherited’ (from a project) or you can specify the customer here. + echo "Customer Inherit (bool): {$activityProjects->getCustomerInherit()}
"; // bool|null + echo "Customer Inherit (string): {$activityProjects->getCustomerInheritToString()}
"; // string|null If "change" = allow then locked = false and inherit = false + echo "Customer Locked (bool): {$activityProjects->getCustomerLocked()}
"; // bool|null If "change" = disallow then locked = true and inherit = false + echo "Customer Locked (string): {$activityProjects->getCustomerLockedToString()}
"; // string|null If "change" = inherit then locked = true and inherit = true + echo "Invoice Description: {$activityProjects->getInvoiceDescription()}
"; // string|null This field can be used to enter a longer activity description which will be available on the invoice template. + + if ($activityProjects->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($activityProjects->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Rate (\\PhpTwinfield\\Rate):
" . print_r($activityProjects->getRate(), true) . "

"; // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). + echo "Rate (string): {$activityProjects->getRateToString()}
"; // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). + echo "Rate Inherit (bool): {$activityProjects->getRateInherit()}
"; // bool|null + echo "Rate Inherit (string): {$activityProjects->getRateInheritToString()}
"; // string|null If "change" = allow then locked = false and inherit = false + echo "Rate Locked (bool): {$activityProjects->getRateLocked()}
"; // bool|null If "change" = disallow then locked = true and inherit = false + echo "Rate Locked (string): {$activityProjects->getRateLockedToString()}
"; // string|null If "change" = inherit then locked = true and inherit = true + echo "Result: {$activityProjects->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Valid From (\\DateTimeInterface):
" . print_r($activityProjects->getValidFrom(), true) . "

"; // \DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. + echo "Valid From (string): {$activityProjects->getValidFromToString()}
"; // string|null + echo "Valid Till (\\DateTimeInterface):
" . print_r($activityProjects->getValidTill(), true) . "

"; // \DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. + echo "Valid Till (string): {$activityProjects->getValidTillToString()}
"; // string|null + + $activityQuantities = $activityProjects->getQuantities(); // array|null Array of ActivityQuantity objects. + + foreach ($activityQuantities as $key => $activityQuantity) { + echo "ActivityQuantity {$key}
"; + + echo "Billable (bool): {$activityQuantity->getBillable()}
"; // bool|null Is the quantity line billable or not. + echo "Billable (string): {$activityQuantity->getBillableToString()}
"; // string|null If "billable" = true and "change is not allowed" then locked = true + echo "Billable Locked (bool): {$activityQuantity->getBillableLocked()}
"; // bool|null If "billable" = true and "change is allowed" then locked = false + echo "Billable Locked (string): {$activityQuantity->getBillableLockedToString()}
"; // string|null + + if ($activityQuantity->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($activityQuantity->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Label: {$activityQuantity->getLabel()}
"; // string|null The label of the quantity. + echo "Mandatory (bool): {$activityQuantity->getMandatory()}
"; // bool|null Is the quantity line mandatory or not. + echo "Mandatory (string): {$activityQuantity->getMandatoryToString()}
"; // string|null + echo "Rate (\\PhpTwinfield\\Rate):
" . print_r($activityQuantity->getRate(), true) . "

"; // Rate|null The rate. + echo "Rate (string): {$activityQuantity->getRateToString()}
"; // string|null + echo "Result: {$activityQuantity->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + } +} + +// Copy an existing Activity to a new entity +if ($executeCopy) { + try { + $activity = $activityApiConnector->get("A000", $office); + } catch (ResponseException $e) { + $activity = $e->getReturnedObject(); + } + + $activity->setCode("A100"); + + try { + $activityCopy = $activityApiConnector->send($activity); + } catch (ResponseException $e) { + $activityCopy = $e->getReturnedObject(); + } + + echo "
";
+    print_r($activityCopy);
+    echo "
"; + + echo "Result of copy process: {$activityCopy->getResult()}
"; + echo "Code of copied Activity: {$activityCopy->getCode()}
"; +} + +// Create a new Activity from scratch, alternatively read an existing Activity as shown above and than modify the values in the same way as shown below +if ($executeNew) { + $activity = new \PhpTwinfield\Activity; + + // Required values for creating a new Activity + $activity->setCode('A100'); // string|null Dimension code, must be compliant with the mask of the ACT Dimension type. + $activity->setName("Example Activity"); // string|null Activity description. + $activity->setOffice($office); // Office|null Office code. + $activity->setOfficeFromString($officeCode); // string|null + //$activity->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. + //$activity->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case an activity is in use, its status has been changed into hide. Hidden activities can be activated by using active. + //$activity->setStatusFromString('active'); // string|null + //$activity->setStatusFromString('deleted'); // string|null + $dimensionType = new \PhpTwinfield\DimensionType; + $dimensionType->setCode('ACT'); + $activity->setType($dimensionType); // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is ACT. + $activity->setTypeFromString('ACT'); // string|null + + // Optional values for creating a new Activity + $activity->setShortName("ExmplAct"); // string|null Short activity description. + $vatCode = new \PhpTwinfield\VatCode; + $vatCode->setCode('VH'); + $activity->setVatCode($vatCode); // VatCode|null The VAT code if one code will apply for all activities within the project. Note that if any VAT codes are + $activity->setVatCodeFromString('VH'); // string|null defined on activity level, these will apply regardless of what is defined on project level. + + $activityProjects = new \PhpTwinfield\ActivityProjects; + + $authoriser = new \PhpTwinfield\User; + $authoriser->setCode('TWINAPPS'); + $activityProjects->setAuthoriser($authoriser); // User|null A specific authoriser for an activity. + $activityProjects->setAuthoriserFromString('TWINAPPS'); // string|null If "change" = allow then locked = false and inherit = false + $activityProjects->setAuthoriserInherit(false); // bool|null + $activityProjects->setAuthoriserInheritFromString('false'); // string|null If "change" = disallow then locked = true and inherit = false + $activityProjects->setAuthoriserLocked(false); // bool|null + $activityProjects->setAuthoriserLockedFromString('false'); // string|null If "change" = inherit then locked = true and inherit = true + $activityProjects->setBillable(false); // bool|null Choose to make an activity billable (true) or not (false) and whether or not it should be included when calculating the "productivity" ratio (@forratio). + $activityProjects->setBillableFromString('false'); // string|null You could also decide that these settings should be inherited from project or user level (@inherit). + $activityProjects->setBillableForRatio(false); // bool|null You can also set whether a change of these settings is allowed or disallowed when a user is entering their timesheet (@locked). + $activityProjects->setBillableForRatioFromString('false'); // string|null If "change" = allow then locked = false and inherit = false. + $activityProjects->setBillableInherit(false); // bool|null + $activityProjects->setBillableInheritFromString('false'); // string|null If "change" = disallow then locked = true and inherit = false. + $activityProjects->setBillableLocked(false); // bool|null + $activityProjects->setBillableLockedFromString('false'); // string|null If "change" = inherit then locked = true and inherit = true + $customer = new \PhpTwinfield\Customer; + $customer->setCode('1000'); + //$activityProjects->setCustomer($customer); // Customer|null An activity always needs to be linked to a customer. + //$activityProjects->setCustomerFromString('1000'); // string|null Choose to have the customer ‘inherited’ (from a project) or you can specify the customer here. + $activityProjects->setCustomerInherit(true); // bool|null + $activityProjects->setCustomerInheritFromString('true'); // string|null If "change" = allow then locked = false and inherit = false + $activityProjects->setCustomerLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false + $activityProjects->setCustomerLockedFromString('true'); // string|null If "change" = inherit then locked = true and inherit = true + $activityProjects->setInvoiceDescription('Example Invoice Description'); // string|null This field can be used to enter a longer activity description which will be available on the invoice template. + $rate = new \PhpTwinfield\Rate; + $rate->setCode('DIRECT'); + $activityProjects->setRate($rate); // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). + $activityProjects->setRateFromString('DIRECT'); // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). + $activityProjects->setRateInherit(false); // bool|null + $activityProjects->setRateInheritFromString('false'); // string|null If "change" = allow then locked = false and inherit = false + $activityProjects->setRateLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false + $activityProjects->setRateLockedFromString('true'); // string|null If "change" = inherit then locked = true and inherit = true + $validFrom = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); + $activityProjects->setValidFrom($validFrom); // \DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. + $activityProjects->setValidFromFromString('20190101'); // string|null + $validTill = \DateTime::createFromFormat('d-m-Y', '31-12-2019'); + $activityProjects->setValidTill($validTill); // \DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. + $activityProjects->setValidTillFromString('20191231'); // string|null + + // The minimum amount of ActivityQuantities linked to a ActivityProjects object is 0, the maximum amount is 4 + $activityQuantity = new \PhpTwinfield\ActivityQuantity; + + $activityQuantity->setBillable(false); // bool|null Is the quantity line billable or not. + $activityQuantity->setBillableFromString('false'); // string|null If "billable" = true and "change is not allowed" then locked = true + $activityQuantity->setBillableLocked(false); // bool|null + $activityQuantity->setBillableLockedFromString('false'); // string|null If "billable" = true and "change is allowed" then locked = false + $activityQuantity->setLabel('Example Quantity'); // string|null + $activityQuantity->setMandatory(false); // bool|null Is the quantity line mandatory or not. + $activityQuantity->setMandatoryFromString('false'); // string|null + $rate = new \PhpTwinfield\Rate; + $rate->setCode('KILOMETERS'); + $activityQuantity->setRate($rate); // Rate|null The rate. + $activityQuantity->setRateFromString('KILOMETERS'); // string|null + + $activityProjects->addQuantity($activityQuantity); // ActivityQuantity Add an ActivityQuantity object to the ActivityProjects object + //$activityProjects->removeQuantity(0); // int Remove a quantity based on the index of the quantity within the array + + $activity->setProjects($activityProjects); // ActivityProjects Set the ActivityProjects object tot the Activity object + + try { + $activityNew = $activityApiConnector->send($activity); + } catch (ResponseException $e) { + $activityNew = $e->getReturnedObject(); + } + + echo "
";
+    print_r($activityNew);
+    echo "
"; + + echo "Result of creation process: {$activityNew->getResult()}
"; + echo "Code of new Activity: {$activityNew->getCode()}
"; +} + +// Delete a Activity based off the passed in code and optionally the office. +if ($executeDelete) { + try { + $activityDeleted = $activityApiConnector->delete("A100", $office); + } catch (ResponseException $e) { + $activityDeleted = $e->getReturnedObject(); + } + + echo "
";
+    print_r($activityDeleted);
+    echo "
"; + + echo "Result of deletion process: {$activityDeleted->getResult()}
"; +} \ No newline at end of file diff --git a/examples/Authorization.php b/examples/Authorization.php index fd43eb87..59a57452 100644 --- a/examples/Authorization.php +++ b/examples/Authorization.php @@ -95,7 +95,7 @@ function SaveAccessTokenToStore(array $accessTokenStorage) { $validationResult = @file_get_contents($validationUrl . urlencode($accessToken->getToken())); if ($validationResult !== false) { - $resultDecoded = \json_decode($validationResult, true); + $resultDecoded = \json_decode($validationResult, true); $accessTokenStorage = array(); $accessTokenStorage['access_token'] = $accessToken->getToken(); $accessTokenStorage['access_expiry'] = $accessToken->getExpires(); diff --git a/examples/CostCenter.php b/examples/CostCenter.php index fac8dd10..05e3756e 100644 --- a/examples/CostCenter.php +++ b/examples/CostCenter.php @@ -110,7 +110,11 @@ // Read a CostCenter based off the passed in code and optionally the office. if ($executeRead) { - $costCenter = $costCenterApiConnector->get("00000", $office); + try { + $costCenter = $costCenterApiConnector->get("00000", $office); + } catch (ResponseException $e) { + $costCenter = $e->getReturnedObject(); + } echo "
";
     print_r($costCenter);
@@ -129,18 +133,23 @@
     echo "Name: {$costCenter->getName()}
"; // string|null Name of the dimension. echo "Office (\\PhpTwinfield\\Office):
" . print_r($costCenter->getOffice(), true) . "

"; // Office|null Office. echo "Office (string): {$costCenter->getOfficeToString()}
"; // string|null - echo "Result: {$costCenter->getResult()}
"; // int|null Result (0 = error, 1 = success). + echo "Result: {$costCenter->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "ShortName: {$costCenter->getShortName()}
"; // string|null Not in use. echo "Status: {$costCenter->getStatus()}
"; // Status|null Status of the cost center. echo "Touched: {$costCenter->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. - echo "Type:
" . print_r($costCenter->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is KPL. - echo "Type: {$costCenter->getTypeToString()}
"; // string|null + echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($costCenter->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is KPL. + echo "Type (string): {$costCenter->getTypeToString()}
"; // string|null echo "UID: {$costCenter->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. } // Copy an existing CostCenter to a new entity if ($executeCopy) { - $costCenter = $costCenterApiConnector->get("00000", $office); + try { + $costCenter = $costCenterApiConnector->get("00000", $office); + } catch (ResponseException $e) { + $costCenter = $e->getReturnedObject(); + } + $costCenter->setCode("00010"); // string|null Dimension code, must be compliant with the mask of the KPL Dimension type. try { diff --git a/examples/Currency.php b/examples/Currency.php index 42bc46e4..5893ad8e 100644 --- a/examples/Currency.php +++ b/examples/Currency.php @@ -102,7 +102,11 @@ // Read a Currency based off the passed in code and optionally the office. if ($executeRead) { - $currency = $currencyApiConnector->get("USD", $office); + try { + $currency = $currencyApiConnector->get("USD", $office); + } catch (ResponseException $e) { + $currency = $e->getReturnedObject(); + } echo "
";
     print_r($currency);
@@ -118,7 +122,7 @@
     echo "Name: {$currency->getName()}
"; // string|null Name of the currency. echo "Office (\\PhpTwinfield\\Office):
" . print_r($currency->getOffice(), true) . "

"; // Office|null Office of the currency. echo "Office (string): {$currency->getOfficeToString()}
"; // string|null - echo "Result: {$currency->getResult()}
"; // int|null Result (0 = error, 1 = success). + echo "Result: {$currency->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "ShortName: {$currency->getShortName()}
"; // string|null Short name of the currency. NOTE: Because of the "hackish" way a currency is read (because Twinfield does not officially support reading currencies) the get() method will not return the current Short Name echo "Status: {$currency->getStatus()}
"; // Status|null Status of the currency. @@ -132,7 +136,7 @@ } echo "Rate: {$currencyRate->getRate()}
"; // float|null Conversion rate to be used as of the start date. - echo "Result: {$currencyRate->getResult()}
"; // int|null Result (0 = error, 1 = success). + echo "Result: {$currencyRate->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "StartDate (\\DateTimeInterface):
" . print_r($currencyRate->getStartDate(), true) . "

"; // \DateTimeInterface|null Starting date of the rate. echo "StartDate (string): {$currencyRate->getStartDateToString()}
"; // string|null echo "Status: {$currencyRate->getStatus()}
"; // Status|null Status of the currency rate. @@ -141,7 +145,12 @@ // Copy an existing Currency to a new entity if ($executeCopy) { - $currency = $currencyApiConnector->get("USD", $office); + try { + $currency = $currencyApiConnector->get("USD", $office); + } catch (ResponseException $e) { + $currency = $e->getReturnedObject(); + } + $currency->setCode("USD2"); try { diff --git a/examples/DimensionGroup.php b/examples/DimensionGroup.php new file mode 100644 index 00000000..4b52550a --- /dev/null +++ b/examples/DimensionGroup.php @@ -0,0 +1,239 @@ + dimtype = 'BAS' +if ($executeListAllWithFilter) { + $options = array('dimtype' => 'BAS'); + + try { + $dimensionGroups = $dimensionGroupApiConnector->listAll("*", 0, 1, 10, $options); + } catch (ResponseException $e) { + $dimensionGroups = $e->getReturnedObject(); + } + + echo "
";
+    print_r($dimensionGroups);
+    echo "
"; +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +if ($executeListAllWithoutFilter) { + try { + $dimensionGroups = $dimensionGroupApiConnector->listAll(); + } catch (ResponseException $e) { + $dimensionGroups = $e->getReturnedObject(); + } + + echo "
";
+    print_r($dimensionGroups);
+    echo "
"; +} + +/* DimensionGroup + * \PhpTwinfield\DimensionGroup + * Available getters: getCode, getMessages, getName, getOffice, getOfficeToString, getResult, getShortName, getStatus, hasMessages, getDimensions + * Available setters: setCode, setName, setOffice, setOfficeFromString, setShortName, setStatus, setStatusFromString, addDimension,removeDimension + */ + +/* DimensionGroupDimension + * \PhpTwinfield\DimensionGroupDimension + * Available getters: getCode, getCodeToString, getMessages, getResult, getType, getTypeToString, hasMessages + * Available setters: setCode, setCodeFromString, setType, setTypeFromString + */ + +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($dimensionGroups as $key => $dimensionGroup) { + echo "DimensionGroup {$key}
"; + echo "Code: {$dimensionGroup->getCode()}
"; + echo "Name: {$dimensionGroup->getName()}

"; + } +} + +// Read a DimensionGroup based off the passed in code and optionally the office. +if ($executeRead) { + try { + $dimensionGroup = $dimensionGroupApiConnector->get("TSTDIMGRP", $office); + } catch (ResponseException $e) { + $dimensionGroup = $e->getReturnedObject(); + } + + echo "
";
+    print_r($dimensionGroup);
+    echo "
"; + + echo "DimensionGroup
"; + echo "Code: {$dimensionGroup->getCode()}
"; // string|null Dimension group code. + + if ($dimensionGroup->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($dimensionGroup->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Name: {$dimensionGroup->getName()}
"; // string|null Name of the dimension group. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($dimensionGroup->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): {$dimensionGroup->getOfficeToString()}
"; // string|null + echo "Result: {$dimensionGroup->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$dimensionGroup->getShortName()}
"; // string|null Short name of the dimension group. + echo "Status: {$dimensionGroup->getStatus()}
"; // Status|null Status of the dimension group. + + $dimensionGroupDimensions = $dimensionGroup->getDimensions(); // Array|null Array of DimensionGroupDimension objects. + + foreach ($dimensionGroupDimensions as $key => $dimensionGroupDimension) { + echo "DimensionGroupDimension {$key}
"; + + if ($dimensionGroupDimension->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($dimensionGroupDimension->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Code:
" . print_r($dimensionGroupDimension->getCode(), true) . "

"; // object|null Code of the dimension. + echo "Code (string): {$dimensionGroupDimension->getCodeToString()}
"; // string|null + echo "Result: {$dimensionGroupDimension->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($dimensionGroupDimension->getType(), true) . "

"; // DimensionType|null Dimension type. + echo "Type (string): {$dimensionGroupDimension->getTypeToString()}
"; // string|null + } +} + +// Copy an existing DimensionGroup to a new entity +if ($executeCopy) { + try { + $dimensionGroup = $dimensionGroupApiConnector->get("TSTDIMGRP", $office); + } catch (ResponseException $e) { + $dimensionGroup = $e->getReturnedObject(); + } + + $dimensionGroup->setCode("TSTDIMGRP2"); + + try { + $dimensionGroupCopy = $dimensionGroupApiConnector->send($dimensionGroup); + } catch (ResponseException $e) { + $dimensionGroupCopy = $e->getReturnedObject(); + } + + echo "
";
+    print_r($dimensionGroupCopy);
+    echo "
"; + + echo "Result of copy process: {$dimensionGroupCopy->getResult()}
"; + echo "Code of copied DimensionGroup: {$dimensionGroupCopy->getCode()}
"; +} + +// Create a new DimensionGroup from scratch, alternatively read an existing DimensionGroup as shown above and than modify the values in the same way as shown below +if ($executeNew) { + $dimensionGroup = new \PhpTwinfield\DimensionGroup; + + // Required values for creating a new DimensionGroup + $dimensionGroup->setCode('DIMGRP2'); // string|null Dimension group code. + $dimensionGroup->setName("Dimension Group 2"); // string|null Name of the dimension group. + $dimensionGroup->setOffice($office); // Office|null Office code. + $dimensionGroup->setOfficeFromString($officeCode); // string|null + $dimensionGroup->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating active should be used. For deleting deleted should be used. + //$dimensionGroup->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null + $dimensionGroup->setStatusFromString('active'); // string|null + //$dimensionGroup->setStatusFromString('deleted'); // string|null + + // Optional values for creating a new DimensionGroup + $dimensionGroup->setShortName("DIM GRP 2"); // string|null Short name of the dimension group. + + // The minimum amount of DimensionGroupDimensions linked to a DimensionGroup object is 0 + $dimensionGroupDimension = new \PhpTwinfield\DimensionGroupDimension; + $type = new \PhpTwinfield\DimensionType; + $type->setCode('BAS'); + $code = new \PhpTwinfield\GeneralLedger; + $code->setType($type); + $code->setCode('1010'); + $dimensionGroupDimension->setCode($code); // object|null Code of the dimension. + $dimensionGroupDimension->setCodeFromString('1010'); // string|null + $dimensionGroupDimension->setType($type); // DimensionType|null Dimension type. + $dimensionGroupDimension->setTypeFromString('BAS'); // string|null + + $dimensionGroup->addDimension($dimensionGroupDimension); // DimensionGroupDimension Add a DimensionGroupDimension object to the DimensionGroup object + //$dimensionGroup->removeDimension(0); // int Remove a dimension based on the index of the dimension within the array + + try { + $dimensionGroupNew = $dimensionGroupApiConnector->send($dimensionGroup); + } catch (ResponseException $e) { + $dimensionGroupNew = $e->getReturnedObject(); + } + + echo "
";
+    print_r($dimensionGroupNew);
+    echo "
"; + + echo "Result of creation process: {$dimensionGroupNew->getResult()}
"; + echo "Code of new DimensionGroup: {$dimensionGroupNew->getCode()}
"; +} + +// Delete a DimensionGroup based off the passed in code and optionally the office. +if ($executeDelete) { + try { + $dimensionGroupDeleted = $dimensionGroupApiConnector->delete("TSTDIMGRP2", $office); + } catch (ResponseException $e) { + $dimensionGroupDeleted = $e->getReturnedObject(); + } + + echo "
";
+    print_r($dimensionGroupDeleted);
+    echo "
"; + + echo "Result of deletion process: {$dimensionGroupDeleted->getResult()}
"; +} \ No newline at end of file diff --git a/examples/InvoiceType.php b/examples/InvoiceType.php new file mode 100644 index 00000000..1649ebfd --- /dev/null +++ b/examples/InvoiceType.php @@ -0,0 +1,89 @@ + vat = 'exclusive' +if ($executeListAllWithFilter) { + $options = array('vat' => 'exclusive'); + + try { + $invoiceTypes = $invoiceTypeApiConnector->listAll("INV*", 0, 1, 10, $options); + } catch (ResponseException $e) { + $invoiceTypes = $e->getReturnedObject(); + } + + echo "
";
+    print_r($invoiceTypes);
+    echo "
"; +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +if ($executeListAllWithoutFilter) { + try { + $invoiceTypes = $invoiceTypeApiConnector->listAll(); + } catch (ResponseException $e) { + $invoiceTypes = $e->getReturnedObject(); + } + + echo "
";
+    print_r($invoiceTypes);
+    echo "
"; +} + +/* InvoiceType + * \PhpTwinfield\InvoiceType + * Available getters: getCode, getName, getShortName + * Available setters: setCode, setName, setShortName + */ + +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($invoiceTypes as $key => $invoiceType) { + echo "InvoiceType {$key}
"; + echo "Code: {$invoiceType->getCode()}
"; + echo "Name: {$invoiceType->getName()}
"; + echo "VAT: {$invoiceTypeApiConnector->getInvoiceTypeVatType($invoiceType->getCode())}

"; + } +} \ No newline at end of file diff --git a/examples/Project.php b/examples/Project.php new file mode 100644 index 00000000..d7b1b3db --- /dev/null +++ b/examples/Project.php @@ -0,0 +1,368 @@ + accessrules = 0 +if ($executeListAllWithFilter) { + $options = array('accessrules' => 0); + + try { + $projects = $projectApiConnector->listAll("P*", 0, 1, 10, $options); + } catch (ResponseException $e) { + $projects = $e->getReturnedObject(); + } + + echo "
";
+    print_r($projects);
+    echo "
"; +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +if ($executeListAllWithoutFilter) { + try { + $projects = $projectApiConnector->listAll(); + } catch (ResponseException $e) { + $projects = $e->getReturnedObject(); + } + + echo "
";
+    print_r($projects);
+    echo "
"; +} + +/* Project + * \PhpTwinfield\Project + * Available getters: getBehaviour, getCode, getInUse, getInUseToString, getMessages, getName, getOffice, getOfficeToString, getResult, getShortName, getStatus, getTouched, getType, getTypeToString, getUID, getVatCode, getVatCodeToString, hasMessages, getProjects + * Available setters: setBehaviour, setBehaviourFromString, setCode, setName, setOffice, setOfficeFromString, setShortName, setStatus, setStatusFromString, setType, setTypeFromString, setVatCode, setVatCodeFromString, setProjects + */ + +/* ProjectProjects + * \PhpTwinfield\ProjectProjects + * Available getters: getAuthoriser, getAuthoriserInherit, getAuthoriserInheritToString, getAuthoriserLocked, getAuthoriserLockedToString, getAuthoriserToString, getBillable, getBillableForRatio, getBillableForRatioToString, getBillableInherit, getBillableInheritToString, + * getBillableLocked, getBillableLockedToString, getBillableToString, getCustomer, getCustomerInherit, getCustomerInheritToString, getCustomerLocked, getCustomerLockedToString, getCustomerToString, getInvoiceDescription, getMessages, getRate, getRateInherit, getRateInheritToString, + * getRateLocked, getRateLockedToString, getRateToString, getResult, getValidFrom, getValidFromToString, getValidTill, getValidTillToString, hasMessages, getQuantities + * + * Available setters: setAuthoriser, setAuthoriserFromString, setAuthoriserInherit, setAuthoriserInheritFromString, setAuthoriserLocked, setAuthoriserLockedFromString, setBillable, setBillableForRatio, setBillableForRatioFromString, setBillableFromString, setBillableInherit, setBillableInheritFromString, + * setBillableLocked, setBillableLockedFromString, setCustomer, setCustomerFromString, setCustomerInherit, setCustomerInheritFromString, setCustomerLocked, setCustomerLockedFromString, setInvoiceDescription, setRate, setRateFromString, setRateInherit, setRateInheritFromString, + * setRateLocked, setRateLockedFromString, setValidFrom, setValidFromFromString, setValidTill, setValidTillFromString, addQuantity, removeQuantity + * + */ + +/* ProjectQuantity + * \PhpTwinfield\ProjectQuantity + * Available getters: getBillable, getBillableLocked, getBillableLockedToString, getBillableToString, getLabel, getMandatory, getMandatoryToString, getMessages, getRate, getRateToString, getResult, hasMessages + * Available setters: setBillable, setBillableFromString, setBillableLocked, setBillableLockedFromString, setLabel, setMandatory, setMandatoryFromString, setRate, setRateFromString + */ + +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($projects as $key => $project) { + echo "Project {$key}
"; + echo "Code: {$project->getCode()}
"; + echo "Name: {$project->getName()}

"; + } +} + +// Read a Project based off the passed in code and optionally the office. +if ($executeRead) { + try { + $project = $projectApiConnector->get("P0001", $office); + } catch (ResponseException $e) { + $project = $e->getReturnedObject(); + } + + echo "
";
+    print_r($project);
+    echo "
"; + + echo "Project
"; + echo "Behaviour: {$project->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. + echo "Code: {$project->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the PRJ Dimension type. + echo "InUse (bool): {$project->getInUse()}
"; // bool|null Indicates whether the project is used in a transaction or not. Read-only attribute. + echo "InUse (string): {$project->getInUseToString()}
"; // string|null + + if ($project->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($project->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Name: {$project->getName()}
"; // string|null Project description. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($project->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): {$project->getOfficeToString()}
"; // string|null + echo "Result: {$project->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$project->getShortName()}
"; // string|null Short project description. + echo "Status: {$project->getStatus()}
"; // Status|null Status of the project. + echo "Touched: {$project->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. + echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($project->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is PRJ. + echo "Type (string): {$project->getTypeToString()}
"; // string|null + echo "UID: {$project->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. + echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($project->getVatCode(), true) . "

"; // VatCode|null The VAT code if one code will apply for all projects within the project. Note that if any VAT codes are + echo "VatCode (string): {$project->getVatCodeToString()}
"; // string|null defined on project level, these will apply regardless of what is defined on project level. + + $projectProjects = $project->getProjects(); // ProjectProjects|null ProjectProjects object. + + echo "Authoriser (\\PhpTwinfield\\User):
" . print_r($projectProjects->getAuthoriser(), true) . "

"; // User|null A specific authoriser for a project. + echo "Authoriser (string): {$projectProjects->getAuthoriserToString()}
"; // string|null If "change" = allow then locked = false and inherit = false + echo "Authoriser Inherit (bool): {$projectProjects->getAuthoriserInherit()}
"; // bool|null + echo "Authoriser Inherit (string): {$projectProjects->getAuthoriserInheritToString()}
"; // string|null If "change" = disallow then locked = true and inherit = false + echo "Authoriser Locked (bool): {$projectProjects->getAuthoriserLocked()}
"; // bool|null + echo "Authoriser Locked (string): {$projectProjects->getAuthoriserLockedToString()}
"; // string|null If "change" = inherit then locked = true and inherit = true + echo "Billable (bool): {$projectProjects->getBillable()}
"; // bool|null Choose to make a project billable (true) or not (false) and whether or not it should be included when calculating the "productivity" ratio (@forratio). + echo "Billable (string): {$projectProjects->getBillableToString()}
"; // string|null You could also decide that these settings should be inherited from project or user level (@inherit). + echo "Billable ForRatio (bool): {$projectProjects->getBillableForRatio()}
"; // bool|null You can also set whether a change of these settings is allowed or disallowed when a user is entering their timesheet (@locked). + echo "Billable ForRatio (string): {$projectProjects->getBillableForRatioToString()}
"; // string|null If "change" = allow then locked = false and inherit = false. + echo "Billable Inherit (bool): {$projectProjects->getBillableInherit()}
"; // bool|null + echo "Billable Inherit (string): {$projectProjects->getBillableInheritToString()}
"; // string|null If "change" = disallow then locked = true and inherit = false. + echo "Billable Locked (bool): {$projectProjects->getBillableLocked()}
"; // bool|null + echo "Billable Locked (string): {$projectProjects->getBillableLockedToString()}
"; // string|null If "change" = inherit then locked = true and inherit = true + echo "Customer (\\PhpTwinfield\\Customer):
" . print_r($projectProjects->getCustomer(), true) . "

"; // Customer|null A project always needs to be linked to a customer. + echo "Customer (string): {$projectProjects->getCustomerToString()}
"; // string|null Choose to have the customer ‘inherited’ (from a project) or you can specify the customer here. + echo "Customer Inherit (bool): {$projectProjects->getCustomerInherit()}
"; // bool|null + echo "Customer Inherit (string): {$projectProjects->getCustomerInheritToString()}
"; // string|null If "change" = allow then locked = false and inherit = false + echo "Customer Locked (bool): {$projectProjects->getCustomerLocked()}
"; // bool|null If "change" = disallow then locked = true and inherit = false + echo "Customer Locked (string): {$projectProjects->getCustomerLockedToString()}
"; // string|null If "change" = inherit then locked = true and inherit = true + echo "Invoice Description: {$projectProjects->getInvoiceDescription()}
"; // string|null This field can be used to enter a longer project description which will be available on the invoice template. + + if ($projectProjects->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($projectProjects->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Rate (\\PhpTwinfield\\Rate):
" . print_r($projectProjects->getRate(), true) . "

"; // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). + echo "Rate (string): {$projectProjects->getRateToString()}
"; // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). + echo "Rate Inherit (bool): {$projectProjects->getRateInherit()}
"; // bool|null + echo "Rate Inherit (string): {$projectProjects->getRateInheritToString()}
"; // string|null If "change" = allow then locked = false and inherit = false + echo "Rate Locked (bool): {$projectProjects->getRateLocked()}
"; // bool|null If "change" = disallow then locked = true and inherit = false + echo "Rate Locked (string): {$projectProjects->getRateLockedToString()}
"; // string|null If "change" = inherit then locked = true and inherit = true + echo "Result: {$projectProjects->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Valid From (\\DateTimeInterface):
" . print_r($projectProjects->getValidFrom(), true) . "

"; // \DateTimeInterface|null A project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. + echo "Valid From (string): {$projectProjects->getValidFromToString()}
"; // string|null + echo "Valid Till (\\DateTimeInterface):
" . print_r($projectProjects->getValidTill(), true) . "

"; // \DateTimeInterface|null A project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. + echo "Valid Till (string): {$projectProjects->getValidTillToString()}
"; // string|null + + $projectQuantities = $projectProjects->getQuantities(); // array|null Array of ProjectQuantity objects. + + foreach ($projectQuantities as $key => $projectQuantity) { + echo "ProjectQuantity {$key}
"; + + echo "Billable (bool): {$projectQuantity->getBillable()}
"; // bool|null Is the quantity line billable or not. + echo "Billable (string): {$projectQuantity->getBillableToString()}
"; // string|null If "billable" = true and "change is not allowed" then locked = true + echo "Billable Locked (bool): {$projectQuantity->getBillableLocked()}
"; // bool|null If "billable" = true and "change is allowed" then locked = false + echo "Billable Locked (string): {$projectQuantity->getBillableLockedToString()}
"; // string|null + + if ($projectQuantity->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($projectQuantity->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Label: {$projectQuantity->getLabel()}
"; // string|null The label of the quantity. + echo "Mandatory (bool): {$projectQuantity->getMandatory()}
"; // bool|null Is the quantity line mandatory or not. + echo "Mandatory (string): {$projectQuantity->getMandatoryToString()}
"; // string|null + echo "Rate (\\PhpTwinfield\\Rate):
" . print_r($projectQuantity->getRate(), true) . "

"; // Rate|null The rate. + echo "Rate (string): {$projectQuantity->getRateToString()}
"; // string|null + echo "Result: {$projectQuantity->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + } +} + +// Copy an existing Project to a new entity +if ($executeCopy) { + try { + $project = $projectApiConnector->get("P0001", $office); + } catch (ResponseException $e) { + $project = $e->getReturnedObject(); + } + + $project->setCode("P0100"); + + try { + $projectCopy = $projectApiConnector->send($project); + } catch (ResponseException $e) { + $projectCopy = $e->getReturnedObject(); + } + + echo "
";
+    print_r($projectCopy);
+    echo "
"; + + echo "Result of copy process: {$projectCopy->getResult()}
"; + echo "Code of copied Project: {$projectCopy->getCode()}
"; +} + +// Create a new Project from scratch, alternatively read an existing Project as shown above and than modify the values in the same way as shown below +if ($executeNew) { + $project = new \PhpTwinfield\Project; + + // Required values for creating a new Project + $project->setCode('P0100'); // string|null Dimension code, must be compliant with the mask of the PRJ Dimension type. + $project->setName("Example Project"); // string|null Project description. + $project->setOffice($office); // Office|null Office code. + $project->setOfficeFromString($officeCode); // string|null + //$project->setStatus(\PhpTwinfield\Enums\Status::PRJIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. + //$project->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case a project is in use, its status has been changed into hide. Hidden projects can be activated by using active. + //$project->setStatusFromString('active'); // string|null + //$project->setStatusFromString('deleted'); // string|null + $dimensionType = new \PhpTwinfield\DimensionType; + $dimensionType->setCode('PRJ'); + $project->setType($dimensionType); // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is PRJ. + $project->setTypeFromString('PRJ'); // string|null + + // Optional values for creating a new Project + $project->setShortName("ExmplAct"); // string|null Short project description. + $vatCode = new \PhpTwinfield\VatCode; + $vatCode->setCode('VH'); + $project->setVatCode($vatCode); // VatCode|null The VAT code if one code will apply for all projects within the project. Note that if any VAT codes are + $project->setVatCodeFromString('VH'); // string|null defined on project level, these will apply regardless of what is defined on project level. + + $projectProjects = new \PhpTwinfield\ProjectProjects; + + $authoriser = new \PhpTwinfield\User; + $authoriser->setCode('TWINAPPS'); + $projectProjects->setAuthoriser($authoriser); // User|null A specific authoriser for a project. + $projectProjects->setAuthoriserFromString('TWINAPPS'); // string|null If "change" = allow then locked = false and inherit = false + $projectProjects->setAuthoriserInherit(false); // bool|null + $projectProjects->setAuthoriserInheritFromString('false'); // string|null If "change" = disallow then locked = true and inherit = false + $projectProjects->setAuthoriserLocked(false); // bool|null + $projectProjects->setAuthoriserLockedFromString('false'); // string|null If "change" = inherit then locked = true and inherit = true + $projectProjects->setBillable(false); // bool|null Choose to make a project billable (true) or not (false) and whether or not it should be included when calculating the "productivity" ratio (@forratio). + $projectProjects->setBillableFromString('false'); // string|null You could also decide that these settings should be inherited from project or user level (@inherit). + $projectProjects->setBillableForRatio(false); // bool|null You can also set whether a change of these settings is allowed or disallowed when a user is entering their timesheet (@locked). + $projectProjects->setBillableForRatioFromString('false'); // string|null If "change" = allow then locked = false and inherit = false. + $projectProjects->setBillableInherit(false); // bool|null + $projectProjects->setBillableInheritFromString('false'); // string|null If "change" = disallow then locked = true and inherit = false. + $projectProjects->setBillableLocked(false); // bool|null + $projectProjects->setBillableLockedFromString('false'); // string|null If "change" = inherit then locked = true and inherit = true + $customer = new \PhpTwinfield\Customer; + $customer->setCode('1000'); + //$projectProjects->setCustomer($customer); // Customer|null A project always needs to be linked to a customer. + //$projectProjects->setCustomerFromString('1000'); // string|null Choose to have the customer ‘inherited’ (from a project) or you can specify the customer here. + $projectProjects->setCustomerInherit(true); // bool|null + $projectProjects->setCustomerInheritFromString('true'); // string|null If "change" = allow then locked = false and inherit = false + $projectProjects->setCustomerLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false + $projectProjects->setCustomerLockedFromString('true'); // string|null If "change" = inherit then locked = true and inherit = true + $projectProjects->setInvoiceDescription('Example Invoice Description'); // string|null This field can be used to enter a longer project description which will be available on the invoice template. + $rate = new \PhpTwinfield\Rate; + $rate->setCode('DIRECT'); + $projectProjects->setRate($rate); // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). + $projectProjects->setRateFromString('DIRECT'); // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). + $projectProjects->setRateInherit(false); // bool|null + $projectProjects->setRateInheritFromString('false'); // string|null If "change" = allow then locked = false and inherit = false + $projectProjects->setRateLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false + $projectProjects->setRateLockedFromString('true'); // string|null If "change" = inherit then locked = true and inherit = true + $validFrom = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); + $projectProjects->setValidFrom($validFrom); // \DateTimeInterface|null A project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. + $projectProjects->setValidFromFromString('20190101'); // string|null + $validTill = \DateTime::createFromFormat('d-m-Y', '31-12-2019'); + $projectProjects->setValidTill($validTill); // \DateTimeInterface|null A project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. + $projectProjects->setValidTillFromString('20191231'); // string|null + + // The minimum amount of ProjectQuantities linked to a ProjectProjects object is 0, the maximum amount is 4 + $projectQuantity = new \PhpTwinfield\ProjectQuantity; + + $projectQuantity->setBillable(false); // bool|null Is the quantity line billable or not. + $projectQuantity->setBillableFromString('false'); // string|null If "billable" = true and "change is not allowed" then locked = true + $projectQuantity->setBillableLocked(false); // bool|null + $projectQuantity->setBillableLockedFromString('false'); // string|null If "billable" = true and "change is allowed" then locked = false + $projectQuantity->setLabel('Example Quantity'); // string|null + $projectQuantity->setMandatory(false); // bool|null Is the quantity line mandatory or not. + $projectQuantity->setMandatoryFromString('false'); // string|null + $rate = new \PhpTwinfield\Rate; + $rate->setCode('KILOMETERS'); + $projectQuantity->setRate($rate); // Rate|null The rate. + $projectQuantity->setRateFromString('KILOMETERS'); // string|null + + $projectProjects->addQuantity($projectQuantity); // ProjectQuantity Add a ProjectQuantity object to the ProjectProjects object + //$projectProjects->removeQuantity(0); // int Remove a quantity based on the index of the quantity within the array + + $project->setProjects($projectProjects); // ProjectProjects Set the ProjectProjects object tot the Project object + + try { + $projectNew = $projectApiConnector->send($project); + } catch (ResponseException $e) { + $projectNew = $e->getReturnedObject(); + } + + echo "
";
+    print_r($projectNew);
+    echo "
"; + + echo "Result of creation process: {$projectNew->getResult()}
"; + echo "Code of new Project: {$projectNew->getCode()}
"; +} + +// Delete a Project based off the passed in code and optionally the office. +if ($executeDelete) { + try { + $projectDeleted = $projectApiConnector->delete("P0100", $office); + } catch (ResponseException $e) { + $projectDeleted = $e->getReturnedObject(); + } + + echo "
";
+    print_r($projectDeleted);
+    echo "
"; + + echo "Result of deletion process: {$projectDeleted->getResult()}
"; +} \ No newline at end of file diff --git a/examples/VatCode.php b/examples/VatCode.php new file mode 100644 index 00000000..a5daead7 --- /dev/null +++ b/examples/VatCode.php @@ -0,0 +1,300 @@ + vattype = 'sales' +if ($executeListAllWithFilter) { + $options = array('vattype' => 'sales'); + + try { + $vatCodes = $vatCodeApiConnector->listAll("V*", 0, 1, 10, $options); + } catch (ResponseException $e) { + $vatCodes = $e->getReturnedObject(); + } + + echo "
";
+    print_r($vatCodes);
+    echo "
"; +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +if ($executeListAllWithoutFilter) { + try { + $vatCodes = $vatCodeApiConnector->listAll(); + } catch (ResponseException $e) { + $vatCodes = $e->getReturnedObject(); + } + + echo "
";
+    print_r($vatCodes);
+    echo "
"; +} + +/* VatCode + * \PhpTwinfield\VatCode + * Available getters: getCode, getCreated, getCreatedToString, getMessages, getModified, getModifiedToString, getName, getOffice, getOfficeToString, getResult, getShortName, getStatus, getTouched, getType, getUID, getUser, getUserToString, hasMessages, getPercentages + * Available setters: setCode, setName, setOffice, setOfficeFromString, setShortName, setStatus, setStatusFromString, setType, setTypeFromString, addPercentage, removePercentage + */ + +/* VatCodePercentage + * \PhpTwinfield\VatCodePercentage + * Available getters: getCreated, getCreatedToString, getDate, getDateToString, getMessages, getName, getPercentage, getResult, getShortName, getUser, getUserToString, hasMessages, getAccounts + * Available setters: setDate, setDateFromString, setName, setPercentage, setShortName, addAccount, removeAccount + */ + +/* VatCodeAccount + * \PhpTwinfield\VatCodeAccount + * Available getters: getDim1, getDim1ToString, getGroup, getGroupCountry, getGroupCountryToString, getGroupToString, getID, getLineType, getMessages, getPercentage, getResult, hasMessages + * Available setters: setDim1, setDim1FromString, setGroup, setGroupCountry, setGroupCountryFromString, setGroupFromString, setID, setLineType, setLineTypeFromString, setPercentage + */ + +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($vatCodes as $key => $vatCode) { + echo "VatCode {$key}
"; + echo "Code: {$vatCode->getCode()}
"; + echo "Name: {$vatCode->getName()}

"; + } +} + +// Read a VatCode based off the passed in code and optionally the office. +if ($executeRead) { + try { + $vatCode = $vatCodeApiConnector->get("VH", $office); + } catch (ResponseException $e) { + $vatCode = $e->getReturnedObject(); + } + + echo "
";
+    print_r($vatCode);
+    echo "
"; + + echo "VatCode
"; + echo "Code: {$vatCode->getCode()}
"; // string|null VAT code. + echo "Created (\\DateTimeInterface):
" . print_r($vatCode->getCreated(), true) . "

"; // \DateTimeInterface|null The date/time the VAT code was created. Read-only attribute. + echo "Created (string): {$vatCode->getCreatedToString()}
"; // string|null + + if ($vatCode->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($vatCode->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Modified (\\DateTimeInterface):
" . print_r($vatCode->getModified(), true) . "

"; // \DateTimeInterface|null The most recent date/time the VAT code was modified. Read-only attribute. + echo "Modified (string): {$vatCode->getModifiedToString()}
"; // string|null + echo "Name: {$vatCode->getName()}
"; // string|null Name of the VAT. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($vatCode->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): {$vatCode->getOfficeToString()}
"; // string|null + echo "Result: {$vatCode->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$vatCode->getShortName()}
"; // string|null Short name of the VAT. + echo "Status: {$vatCode->getStatus()}
"; // Status|null Status of the VAT. + echo "Touched: {$vatCode->getTouched()}
"; // int|null The number of times the VAT code is modified. Read-only attribute. + echo "Type: {$vatCode->getType()}
"; // VatType|null The VAT type. + echo "UID: {$vatCode->getUID()}
"; // string|null Unique identification of the VAT code. Read-only attribute. + echo "User (\\PhpTwinfield\\User):
" . print_r($vatCode->getUser(), true) . "

"; // User|null The code of the user who created or modified the VAT code. Read-only attribute. + echo "User (string): {$vatCode->getUserToString()}
"; // string|null + + $vatCodePercentages = $vatCode->getPercentages(); // Array|null Array of VatCodePercentage objects. + + foreach ($vatCodePercentages as $key => $vatCodePercentage) { + echo "VatCodePercentage {$key}
"; + + if ($vatCodePercentage->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($vatCodePercentage->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Created (\\DateTimeInterface):
" . print_r($vatCodePercentage->getCreated(), true) . "

"; // \DateTimeInterface|null The date/time the VAT line was created. Read-only attribute. + echo "Created (string): {$vatCodePercentage->getCreatedToString()}
"; // string|null + echo "Date (\\DateTimeInterface):
" . print_r($vatCodePercentage->getDate(), true) . "

"; // \DateTimeInterface|null Effective date. + echo "Date (string): {$vatCodePercentage->getDateToString()}
"; // string|null + echo "Name: {$vatCodePercentage->getName()}
"; // string|null Name of the VAT line. + echo "Percentage: {$vatCodePercentage->getPercentage()}
"; // float|null Percentage of the VAT line. + echo "Result: {$vatCodePercentage->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$vatCodePercentage->getShortName()}
"; // string|null Short name of the VAT line. + echo "User (\\PhpTwinfield\\User):
" . print_r($vatCodePercentage->getUser(), true) . "

"; // User|null The code of the user who created or modified the VAT line. Read-only attribute. + echo "User (string): {$vatCodePercentage->getUserToString()}
"; // string|null + + $vatCodeAccounts = $vatCodePercentage->getAccounts(); // Array|null Array of VatCodeAccount objects. + + foreach ($vatCodeAccounts as $key => $vatCodeAccount) { + echo "VatCodeAccount {$key}
"; + + if ($vatCodeAccount->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($vatCodeAccount->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Dim1 (\\PhpTwinfield\\GeneralLedger):
" . print_r($vatCodeAccount->getDim1(), true) . "

"; // GeneralLedger|null General ledger account on which the VAT amount will be posted. + echo "Dim1 (string): {$vatCodeAccount->getDim1ToString()}
"; // string|null + echo "Group (\\PhpTwinfield\\VatGroup):
" . print_r($vatCodeAccount->getGroup(), true) . "

"; // VatGroup|null The VAT group. + echo "Group (string): {$vatCodeAccount->getGroupToString()}
"; // string|null + echo "GroupCountry (\\PhpTwinfield\\VatGroupCountry):
" . print_r($vatCodeAccount->getGroupCountry(), true) . "

"; // VatGroupCountry|null Country code of the VAT group. + echo "GroupCountry (string): {$vatCodeAccount->getGroupCountryToString()}
"; // string|null + echo "ID: {$vatCodeAccount->getID()}
"; // int|null Line ID. + echo "LineType: {$vatCodeAccount->getLineType()}
"; // LineType|null Is it a vat line or not detail. Use detail in case a part of the calculated vat value should be posted on a different general ledger account. + echo "Percentage: {$vatCodeAccount->getPercentage()}
"; // float|null The VAT percentage. + echo "Result: {$vatCodeAccount->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + } + } +} + +// Copy an existing VatCode to a new entity +if ($executeCopy) { + try { + $vatCode = $vatCodeApiConnector->get("VH", $office); + } catch (ResponseException $e) { + $vatCode = $e->getReturnedObject(); + } + + $vatCode->setCode("VH2"); + + try { + $vatCodeCopy = $vatCodeApiConnector->send($vatCode); + } catch (ResponseException $e) { + $vatCodeCopy = $e->getReturnedObject(); + } + + echo "
";
+    print_r($vatCodeCopy);
+    echo "
"; + + echo "Result of copy process: {$vatCodeCopy->getResult()}
"; + echo "Code of copied VatCode: {$vatCodeCopy->getCode()}
"; +} + +// Create a new VatCode from scratch, alternatively read an existing VatCode as shown above and than modify the values in the same way as shown below +if ($executeNew) { + $vatCode = new \PhpTwinfield\VatCode; + + // Required values for creating a new VatCode + $vatCode->setCode('VH2'); // string|null VAT code. + $vatCode->setName("BTW 21%"); // string|null Name of the VAT. + $vatCode->setOffice($office); // Office|null Office code. + $vatCode->setOfficeFromString($officeCode); // string|null + $vatCode->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating active should be used. For deleting deleted should be used. + //$vatCode->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null + $vatCode->setStatusFromString('active'); // string|null + //$vatCode->setStatusFromString('deleted'); // string|null + $vatCode->setType(\PhpTwinfield\Enums\VatType::SALES()); // VatType|null + $vatCode->setTypeFromString('sales'); // string|null + + // Optional values for creating a new VatCode + $vatCode->setShortName("VH 21%"); // string|null Short name of the VAT. + + // The minimum amount of VatCodePercentages linked to a VatCode object is 0 + $vatCodePercentage = new \PhpTwinfield\VatCodePercentage; + $date = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); + $vatCodePercentage->setDate($date); // \DateTimeInterface|null Effective date. + $vatCodePercentage->setDateFromString('20190101'); // string|null + $vatCodePercentage->setName("BTW 21%"); // string|null Name of the VAT line. + $vatCodePercentage->setPercentage(21); // float|null Percentage of the VAT line. + $vatCodePercentage->setShortName("VH 21%"); // string|null Short name of the VAT line. + + // The minimum amount of VatCodeAccounts linked to a VatCodePercentage object is 1 + $vatCodeAccount = new \PhpTwinfield\VatCodeAccount; + $generalLedger = new \PhpTwinfield\GeneralLedger; + $generalLedger->setCode('1530'); + $vatCodeAccount->setDim1($generalLedger); // GeneralLedger|null General ledger account on which the VAT amount will be posted. + $vatCodeAccount->setDim1FromString('1530'); // string|null + $vatGroup = new \PhpTwinfield\VatGroup; + $vatGroup->setCode('NL1A'); + $vatCodeAccount->setGroup($vatGroup); // VatGroup|null The VAT group. + $vatCodeAccount->setGroupFromString('NL1A'); // string|null + $vatGroupCountry = new \PhpTwinfield\VatGroupCountry; + $vatGroupCountry->setCode('NL'); + $vatCodeAccount->setGroupCountry($vatGroupCountry); // VatGroupCountry|null Country code of the VAT group. + $vatCodeAccount->setGroupCountryFromString('NL'); // string|null + + $vatCodeAccount->setID(1); // int|null Line ID. + $vatCodeAccount->setLineType(\PhpTwinfield\Enums\LineType::VAT()); // LineType|null Is it a vat line or not detail. Use detail in case a part of the calculated vat value should be posted on a different general ledger account. + $vatCodeAccount->setLineTypeFromString('vat'); // string|null + + $vatCodeAccount->setPercentage(100); // float|null Percentage of the VAT line. + + $vatCodePercentage->addAccount($vatCodeAccount); // VatCodeAccount Add a VatCodeAccount object to the VatCodePercentage object + //$vatCodePercentage->removeAccount(1); // int Remove an account based on the id of the account + + $vatCode->addPercentage($vatCodePercentage); // VatCodePercentage Add a VatCodePercentage object to the VatCode object + //$vatCode->removePercentage(0); // int Remove a percentage based on the index of the percentage within the array + + try { + $vatCodeNew = $vatCodeApiConnector->send($vatCode); + } catch (ResponseException $e) { + $vatCodeNew = $e->getReturnedObject(); + } + + echo "
";
+    print_r($vatCodeNew);
+    echo "
"; + + echo "Result of creation process: {$vatCodeNew->getResult()}
"; + echo "Code of new VatCode: {$vatCodeNew->getCode()}
"; +} + +// Delete a VatCode based off the passed in code and optionally the office. +if ($executeDelete) { + try { + $vatCodeDeleted = $vatCodeApiConnector->delete("VH2", $office); + } catch (ResponseException $e) { + $vatCodeDeleted = $e->getReturnedObject(); + } + + echo "
";
+    print_r($vatCodeDeleted);
+    echo "
"; + + echo "Result of deletion process: {$vatCodeDeleted->getResult()}
"; +} \ No newline at end of file diff --git a/src/DomDocuments/ActivitiesDocument.php b/src/DomDocuments/ActivitiesDocument.php index 2e87cc38..c2b49590 100644 --- a/src/DomDocuments/ActivitiesDocument.php +++ b/src/DomDocuments/ActivitiesDocument.php @@ -62,16 +62,18 @@ public function addActivity(Activity $activity) foreach ($inheritArray as $inheritVar => $method) { $methodLocked = "get" . ucfirst($inheritVar) . "Locked"; + $methodLockedString = $methodLocked . "ToString"; $methodInherit = "get" . ucfirst($inheritVar) . "Inherit"; + $methodInheritString = $methodInherit . "ToString"; $elementVar = ""; - if ($projects->$methodLocked() !== true || $projects->$methodInherit() !== true) { + if ($projects->$methodLocked() != true || $projects->$methodInherit() != true) { $elementVar = $projects->$method(); } elseif ($inheritVar == 'billable') { $projects->setBillableForRatio(false); } - $attributesArray = array('locked' => $methodLocked, 'inherit' => $methodInherit); + $attributesArray = array('locked' => $methodLockedString, 'inherit' => $methodInheritString); if ($inheritVar == 'billable') { $attributesArray['forratio'] = 'getBillableForRatioToString'; diff --git a/src/DomDocuments/ProjectsDocument.php b/src/DomDocuments/ProjectsDocument.php index 8bacf77e..a526ecea 100644 --- a/src/DomDocuments/ProjectsDocument.php +++ b/src/DomDocuments/ProjectsDocument.php @@ -62,16 +62,18 @@ public function addProject(Project $project) foreach ($inheritArray as $inheritVar => $method) { $methodLocked = "get" . ucfirst($inheritVar) . "Locked"; + $methodLockedString = $methodLocked . "ToString"; $methodInherit = "get" . ucfirst($inheritVar) . "Inherit"; + $methodInheritString = $methodInherit . "ToString"; $elementVar = ""; - if ($projects->$methodLocked() !== true || $projects->$methodInherit() !== true) { + if ($projects->$methodLocked() != true || $projects->$methodInherit() != true) { $elementVar = $projects->$method(); } elseif ($inheritVar == 'billable') { $projects->setBillableForRatio(false); } - $attributesArray = array('locked' => $methodLocked, 'inherit' => $methodInherit); + $attributesArray = array('locked' => $methodLockedString, 'inherit' => $methodInheritString); if ($inheritVar == 'billable') { $attributesArray['forratio'] = 'getBillableForRatioToString'; diff --git a/src/Mappers/VatCodeMapper.php b/src/Mappers/VatCodeMapper.php index a2f8ce49..e0f257a7 100644 --- a/src/Mappers/VatCodeMapper.php +++ b/src/Mappers/VatCodeMapper.php @@ -91,7 +91,7 @@ public static function map(Response $response) // Set the vat code percentage account elements from the account element $vatCodeAccount->setDim1(self::parseObjectAttribute('GeneralLedger', $vatCodeAccount, $accountElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setGroup(self::parseObjectAttribute('VatGroup', $vatCodeAccount, $accountElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setGroupCountry(self::parseObjectAttribute('Country', $vatCodeAccount, $accountElement, 'groupcountry', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setGroupCountry(self::parseObjectAttribute('VatGroupCountry', $vatCodeAccount, $accountElement, 'groupcountry', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setLineType(self::parseEnumAttribute('LineType', self::getField($vatCodeAccount, $accountElement, 'linetype'))) ->setPercentage(self::getField($vatCodeAccount, $accountElement, 'percentage')); From 2ec6227b53658c2550c793f56c39fad85c01b7f4 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 22 May 2019 21:28:00 +0200 Subject: [PATCH 261/388] Upload --- breaking262.md | 54 +++++++ examples/Currency.php | 5 +- examples/Project.php | 2 +- examples/Rate.php | 264 +++++++++++++++++++++++++++++++++++ src/Fields/CreatedField.php | 2 +- src/Fields/ModifiedField.php | 2 +- src/Fields/TouchedField.php | 2 +- src/Mappers/RateMapper.php | 5 +- src/Rate.php | 6 + 9 files changed, 334 insertions(+), 8 deletions(-) create mode 100644 breaking262.md create mode 100644 examples/Rate.php diff --git a/breaking262.md b/breaking262.md new file mode 100644 index 00000000..f4faa0dd --- /dev/null +++ b/breaking262.md @@ -0,0 +1,54 @@ +# Breaking changes since 2.6.2 +Release ... added multiple new resources, but also broke several existing ones. + +Breaking changes are present in: +- Bank Transactions (Separate API connector completely removed and functionality moved to general Transactions API Connector) +- Articles +- Customers +- Sales Invoices +- Suppliers +- Transactions +- Vat Codes + +Except for Bank Transactions, the breaking changes are primarily due to the fact that most fields and methods are now properly type cast. + +This means (among others) that all booleans are now type cast as bool, all monetary values are now Money\Money instances and several fields now use Enums instead of strings. + +Another big change is that retrieved fields that are instances of another entity in Twinfield and this library are now retrieved and set in the same way as was already done with Office or Customer codes. +So for example a VAT code retrieved from or set to a PhpTwinfield\Article will now become an instance of PhpTwinfield\VatCode with its $code set to "VH" instead of begin just a string with the value "VH". + +Most of these changed methods have gained ToString/FromString or ToFloat/FromFloat methods that will ease the transition. + +See the tables per class below for breaking changes and suggestions for fixes/replacement methods. + +## Bank Transactions + +-TODO + +## Articles + +-TODO + +### Article Lines + +-TODO + +## Customers + +-TODO + +## Sales Invoices + +-TODO + +## Suppliers + +-TODO + +## Cash/Journal/Purchase/Sale Transactions + +-TODO + +## VAT + +-TODO \ No newline at end of file diff --git a/examples/Currency.php b/examples/Currency.php index 5893ad8e..a919b5c4 100644 --- a/examples/Currency.php +++ b/examples/Currency.php @@ -192,9 +192,8 @@ $startDate = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); $currencyRate->setStartDate($startDate); // \DateTimeInterface|null Starting date of the rate. $currencyRate->setStartDateFromString('20190101'); // string|null - //$currencyRate->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null For creating and updating status may be left empty. NOTE: Do not use $currencyRate->setStatusFromString(\PhpTwinfield\Enums\Status::ACTIVE()); - // For deleting deleted should be used. In case a dimension that is used in a transaction is deleted, - // its status has been changed into hide. Hidden dimensions can be activated by using active. + //$currencyRate->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null For creating and updating status may be left empty. NOTE: Do not use $currencyRate->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); + // For deleting deleted should be used. //$currencyRate->setStatusFromString('deleted'); // string|null NOTE: Do not use $currencyRate->setStatusFromString('active'); $currency->addRate($currencyRate); // CurrencyRate Add a CurrencyRate object to the Currency object diff --git a/examples/Project.php b/examples/Project.php index d7b1b3db..b9a4e386 100644 --- a/examples/Project.php +++ b/examples/Project.php @@ -260,7 +260,7 @@ $project->setName("Example Project"); // string|null Project description. $project->setOffice($office); // Office|null Office code. $project->setOfficeFromString($officeCode); // string|null - //$project->setStatus(\PhpTwinfield\Enums\Status::PRJIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. + //$project->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. //$project->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case a project is in use, its status has been changed into hide. Hidden projects can be activated by using active. //$project->setStatusFromString('active'); // string|null //$project->setStatusFromString('deleted'); // string|null diff --git a/examples/Rate.php b/examples/Rate.php new file mode 100644 index 00000000..4dc5cfd7 --- /dev/null +++ b/examples/Rate.php @@ -0,0 +1,264 @@ + ratetype = 'quantity' +if ($executeListAllWithFilter) { + $options = array('ratetype' => 'time'); + + try { + $rates = $rateApiConnector->listAll("DIR*", 0, 1, 10, $options); + } catch (ResponseException $e) { + $rates = $e->getReturnedObject(); + } + + echo "
";
+    print_r($rates);
+    echo "
"; +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +if ($executeListAllWithoutFilter) { + try { + $rates = $rateApiConnector->listAll(); + } catch (ResponseException $e) { + $rates = $e->getReturnedObject(); + } + + echo "
";
+    print_r($rates);
+    echo "
"; +} + +/* Rate + * \PhpTwinfield\Rate + * Available getters: getCode, getCreated, getCreatedToString, getCurrency, getCurrencyToString, getMessages, getModified, getModifiedToString, getName, getOffice, getOfficeToString, getResult, getShortName, getStatus, getTouched, getType, getUnit, getUser, getUserToString, hasMessages, getRateChanges + * Available setters: setCode, setCurrency, setCurrencyFromString, setName, setOffice, setOfficeFromString, setShortName, setStatus, setStatusFromString, setType, setTypeFromString, setUnit, addRateChange, removeRateChange + */ + +/* RateRateChange + * \PhpTwinfield\RateRateChange + * Available getters: getBeginDate, getBeginDateToString, getEndDate, getEndDateToString, getExternalRate, getID, getInternalRate, getMessages, getResult, getStatus, hasMessages + * Available setters: setBeginDate, setBeginDateFromString, setEndDate, setEndDateFromString, setExternalRate, setID, setInternalRate, setStatus, setStatusFromString + */ + +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($rates as $key => $rate) { + echo "Rate {$key}
"; + echo "Code: {$rate->getCode()}
"; + echo "Name: {$rate->getName()}

"; + } +} + +// Read a Rate based off the passed in code and optionally the office. +if ($executeRead) { + try { + $rate = $rateApiConnector->get("DIRECT", $office); + } catch (ResponseException $e) { + $rate = $e->getReturnedObject(); + } + + echo "
";
+    print_r($rate);
+    echo "
"; + + echo "Rate
"; + echo "Code: {$rate->getCode()}
"; // string|null Rate code. + echo "Created (\\DateTimeInterface):
" . print_r($rate->getCreated(), true) . "

"; // \DateTimeInterface|null The date/time the rate was created. Read-only attribute. + echo "Created (string): {$rate->getCreatedToString()}
"; // string|null + echo "Currency (\\PhpTwinfield\\Currency):
" . print_r($rate->getCurrency(), true) . "

"; // Currency|null Currency code. + echo "Currency (string): {$rate->getCurrencyToString()}
"; // string|null + + if ($rate->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($rate->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Modified (\\DateTimeInterface):
" . print_r($rate->getModified(), true) . "

"; // \DateTimeInterface|null The date/time the rate was modified. Read-only attribute. + echo "Modified (string): {$rate->getModifiedToString()}
"; // string|null + echo "Name: {$rate->getName()}
"; // string|null Rate description. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($rate->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): {$rate->getOfficeToString()}
"; // string|null + echo "Result: {$rate->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$rate->getShortName()}
"; // string|null Short rate description. + echo "Status: {$rate->getStatus()}
"; // Status|null Status of the rate. + echo "Touched: {$rate->getTouched()}
"; // int|null The number of times the rate is modified. Read-only attribute. + echo "Type: {$rate->getType()}
"; // RateType|null The rate type. + echo "Unit: {$rate->getUnit()}
"; // int|null How will be charged e.g. if charged per hour Time, set it to 60. If charged per 8 hours, set it to 8 * 60 = 460. + // Quantities refers to items such as kilometers. If charged per kilometer set it to 1. + echo "User (\\PhpTwinfield\\User):
" . print_r($rate->getUser(), true) . "

"; // User|null The code of the user who created or modified the Rate. Read-only attribute. + echo "User (string): {$rate->getUserToString()}
"; // string|null + + $rateRateChanges = $rate->getRateChanges(); // Array|null Array of RateRateChange objects. + + foreach ($rateRateChanges as $key => $rateRateChange) { + echo "RateRateChange {$key}
"; + + echo "BeginDate (\\DateTimeInterface):
" . print_r($rateRateChange->getBeginDate(), true) . "

"; // \DateTimeInterface|null Begin date of the rate. + echo "BeginDate (string): {$rateRateChange->getBeginDateToString()}
"; // string|null + echo "EndDate (\\DateTimeInterface):
" . print_r($rateRateChange->getEndDate(), true) . "

"; // \DateTimeInterface|null End date of the rate. + echo "EndDate (string): {$rateRateChange->getEndDateToString()}
"; // string|null + echo "ExternalRate: {$rateRateChange->getExternalRate()}
"; // int|null The external rate e.g. the selling price per unit. + echo "ID: {$rateRateChange->getID()}
"; // int|null Line ID. + echo "InternalRate: {$rateRateChange->getInternalRate()}
"; // int|null The internal rate e.g. the cost price per unit. + + if ($rateRateChange->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($rateRateChange->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Result: {$rateRateChange->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Status: {$rateRateChange->getStatus()}
"; // Status|null Status of the rate change. + } +} + +// Copy an existing Rate to a new entity +if ($executeCopy) { + try { + $rate = $rateApiConnector->get("DIRECT", $office); + } catch (ResponseException $e) { + $rate = $e->getReturnedObject(); + } + + $rate->setCode("DIRECT2"); + + try { + $rateCopy = $rateApiConnector->send($rate); + } catch (ResponseException $e) { + $rateCopy = $e->getReturnedObject(); + } + + echo "
";
+    print_r($rateCopy);
+    echo "
"; + + echo "Result of copy process: {$rateCopy->getResult()}
"; + echo "Code of copied Rate: {$rateCopy->getCode()}
"; +} + +// Create a new Rate from scratch, alternatively read an existing Rate as shown above and than modify the values in the same way as shown below +if ($executeNew) { + $rate = new \PhpTwinfield\Rate; + + // Required values for creating a new Rate + $rate->setCode('DIRECT2'); // string|null Rate code. + $currency = new \PhpTwinfield\Currency; + $currency->setCode('EUR'); + $rate->setCurrency($currency); // Currency|null Currency code. + $rate->setCurrencyFromString('EUR'); // string|null + $rate->setName("Example Rate"); // string|null Rate description. + $rate->setOffice($office); // Office|null Office code. + $rate->setOfficeFromString($officeCode); // string|null + $rate->setType(\PhpTwinfield\Enums\RateType::TIME()); // RateType|null The rate type. + $rate->setTypeFromString('time'); // string|null + $rate->setUnit(60); // int|null How will be charged e.g. if charged per hour Time, set it to 60. If charged per 8 hours, set it to 8 * 60 = 460. + // Quantities refers to items such as kilometers. If charged per kilometer set it to 1. + // Optional values for creating a new Rate + $rate->setShortName("ExmpleRate"); // string|null Short rate description. + $rate->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. + //$rate->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // For deleting deleted should be used. In case a rate that is in use, its status has been changed into hide. + // Hidden rates can be activated by using active. + $rate->setStatusFromString('active'); // string|null + //$rate->setStatusFromString('deleted'); // string|null + + // The minimum amount of RateRateChanges linked to a Rate object is 0 + $rateRateChange = new \PhpTwinfield\RateRateChange; + $beginDate = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); + $rateRateChange->setBeginDate($beginDate); // \DateTimeInterface|null Begin date of the rate. + $rateRateChange->setBeginDateFromString('20190101'); // string|null + $endDate = \DateTime::createFromFormat('d-m-Y', '31-12-2019'); + $rateRateChange->setEndDate($endDate); // \DateTimeInterface|null Begin date of the rate. + $rateRateChange->setEndDateFromString('20191231'); // string|null + $rateRateChange->setExternalRate(60); // float|null The internal rate e.g. the cost price per unit. + $rateRateChange->setID(2); // int|null Line ID. + $rateRateChange->setInternalRate(120); // float|null The internal rate e.g. the cost price per unit. + //$rateRateChange->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null Status of the rate line. For creating and updating status may be left empty. NOTE: Do not use $rateRateChange->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); + // For deleting deleted should be used. + //$rateRateChange->setStatusFromString('deleted'); // string|null NOTE: Do not use $rateRateChange->setStatusFromString('active'); + + $rate->addRateChange($rateRateChange); // RateRateChange Add a RateRateChange object to the Rate object + //$rate->removeRateChange(2); // int Remove a rate change based on the id of the rate change + + try { + $rateNew = $rateApiConnector->send($rate); + } catch (ResponseException $e) { + $rateNew = $e->getReturnedObject(); + } + + echo "
";
+    print_r($rateNew);
+    echo "
"; + + echo "Result of creation process: {$rateNew->getResult()}
"; + echo "Code of new Rate: {$rateNew->getCode()}
"; + /* */ +} + +// Delete a Rate based off the passed in code and optionally the office. +if ($executeDelete) { + try { + $rateDeleted = $rateApiConnector->delete("DIRECT2", $office); + } catch (ResponseException $e) { + $rateDeleted = $e->getReturnedObject(); + } + + echo "
";
+    print_r($rateDeleted);
+    echo "
"; + + echo "Result of deletion process: {$rateDeleted->getResult()}
"; +} \ No newline at end of file diff --git a/src/Fields/CreatedField.php b/src/Fields/CreatedField.php index 71ce8d97..72470fdc 100644 --- a/src/Fields/CreatedField.php +++ b/src/Fields/CreatedField.php @@ -7,7 +7,7 @@ /** * Created field - * Used by: AssetMethod, Office, User, VatCode, VatCodePercentage + * Used by: AssetMethod, Office, Rate, User, VatCode, VatCodePercentage * * @package PhpTwinfield\Traits * @see Util::formatDateTime() diff --git a/src/Fields/ModifiedField.php b/src/Fields/ModifiedField.php index cc4761b4..c66a09c7 100644 --- a/src/Fields/ModifiedField.php +++ b/src/Fields/ModifiedField.php @@ -7,7 +7,7 @@ /** * Modified field - * Used by: AssetMethod, Office, User, VatCode + * Used by: AssetMethod, Office, Rate, User, VatCode * * @package PhpTwinfield\Traits * @see Util::formatDateTime() diff --git a/src/Fields/TouchedField.php b/src/Fields/TouchedField.php index c7109adb..80296788 100644 --- a/src/Fields/TouchedField.php +++ b/src/Fields/TouchedField.php @@ -6,7 +6,7 @@ trait TouchedField { /** * Touched field - * Used by: Activity, AssetMethod, CostCenter, Customer, FixedAsset, GeneralLedger, Office, Project, Supplier, User, VatCode + * Used by: Activity, AssetMethod, CostCenter, Customer, FixedAsset, GeneralLedger, Office, Project, Rate, Supplier, User, VatCode * * @var int|null */ diff --git a/src/Mappers/RateMapper.php b/src/Mappers/RateMapper.php index 8fe3fe1d..47896275 100644 --- a/src/Mappers/RateMapper.php +++ b/src/Mappers/RateMapper.php @@ -41,10 +41,13 @@ public static function map(Response $response) // Set the rate elements from the rate element $rate->setCode(self::getField($rate, $rateElement, 'code')) + ->setCreated(self::parseDateTimeAttribute(self::getField($rate, $rateElement, 'created'))) ->setCurrency(self::parseObjectAttribute('Currency', $rate, $rateElement, 'currency', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setModified(self::parseDateTimeAttribute(self::getField($rate, $rateElement, 'modified'))) ->setName(self::getField($rate, $rateElement, 'name')) ->setOffice(self::parseObjectAttribute('Office', $rate, $rateElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setShortName(self::getField($rate, $rateElement, 'shortname')) + ->setTouched(self::getField($rate, $rateElement, 'touched')) ->setType(self::parseEnumAttribute('RateType', self::getField($rate, $rateElement, 'type'))) ->setUnit(self::getField($rate, $rateElement, 'unit')) ->setUser(self::parseObjectAttribute('User', $rate, $rateElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); @@ -82,4 +85,4 @@ public static function map(Response $response) // Return the complete object return $rate; } -} +} \ No newline at end of file diff --git a/src/Rate.php b/src/Rate.php index e575ee1c..0d32f077 100644 --- a/src/Rate.php +++ b/src/Rate.php @@ -3,11 +3,14 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\CodeField; +use PhpTwinfield\Fields\CreatedField; use PhpTwinfield\Fields\CurrencyField; +use PhpTwinfield\Fields\ModifiedField; use PhpTwinfield\Fields\NameField; use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\ShortNameField; use PhpTwinfield\Fields\StatusField; +use PhpTwinfield\Fields\TouchedField; use PhpTwinfield\Fields\Rate\TypeField; use PhpTwinfield\Fields\Rate\UnitField; use PhpTwinfield\Fields\UserField; @@ -20,11 +23,14 @@ class Rate extends BaseObject { use CodeField; + use CreatedField; use CurrencyField; + use ModifiedField; use NameField; use OfficeField; use ShortNameField; use StatusField; + use TouchedField; use TypeField; use UnitField; use UserField; From df47753bd6e844c38f94b1a0b4fe811ebe5b7b14 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 22 May 2019 22:46:02 +0200 Subject: [PATCH 262/388] Upload --- examples/Activity.php | 112 ++++++++++---------- examples/Currency.php | 40 +++---- examples/DimensionGroup.php | 32 +++--- examples/DimensionType.php | 202 ++++++++++++++++++++++++++++++++++++ examples/Project.php | 113 ++++++++++---------- examples/Rate.php | 58 +++++------ examples/VatCode.php | 61 +++++------ readme.md | 2 +- 8 files changed, 412 insertions(+), 208 deletions(-) create mode 100644 examples/DimensionType.php diff --git a/examples/Activity.php b/examples/Activity.php index f3a5ce77..169cc134 100644 --- a/examples/Activity.php +++ b/examples/Activity.php @@ -256,87 +256,87 @@ $activity = new \PhpTwinfield\Activity; // Required values for creating a new Activity - $activity->setCode('A100'); // string|null Dimension code, must be compliant with the mask of the ACT Dimension type. - $activity->setName("Example Activity"); // string|null Activity description. - $activity->setOffice($office); // Office|null Office code. - $activity->setOfficeFromString($officeCode); // string|null - //$activity->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. - //$activity->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case an activity is in use, its status has been changed into hide. Hidden activities can be activated by using active. - //$activity->setStatusFromString('active'); // string|null - //$activity->setStatusFromString('deleted'); // string|null + $activity->setCode('A100'); // string|null Dimension code, must be compliant with the mask of the ACT Dimension type. + $activity->setName("Example Activity"); // string|null Activity description. + $activity->setOffice($office); // Office|null Office code. + $activity->setOfficeFromString($officeCode); // string|null + //$activity->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. + //$activity->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case an activity is in use, its status has been changed into hide. Hidden activities can be activated by using active. + //$activity->setStatusFromString('active'); // string|null + //$activity->setStatusFromString('deleted'); // string|null $dimensionType = new \PhpTwinfield\DimensionType; $dimensionType->setCode('ACT'); - $activity->setType($dimensionType); // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is ACT. - $activity->setTypeFromString('ACT'); // string|null + $activity->setType($dimensionType); // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is ACT. + $activity->setTypeFromString('ACT'); // string|null // Optional values for creating a new Activity - $activity->setShortName("ExmplAct"); // string|null Short activity description. + $activity->setShortName("ExmplAct"); // string|null Short activity description. $vatCode = new \PhpTwinfield\VatCode; $vatCode->setCode('VH'); - $activity->setVatCode($vatCode); // VatCode|null The VAT code if one code will apply for all activities within the project. Note that if any VAT codes are - $activity->setVatCodeFromString('VH'); // string|null defined on activity level, these will apply regardless of what is defined on project level. + $activity->setVatCode($vatCode); // VatCode|null The VAT code if one code will apply for all activities within the project. Note that if any VAT codes are + $activity->setVatCodeFromString('VH'); // string|null defined on activity level, these will apply regardless of what is defined on project level. $activityProjects = new \PhpTwinfield\ActivityProjects; $authoriser = new \PhpTwinfield\User; $authoriser->setCode('TWINAPPS'); - $activityProjects->setAuthoriser($authoriser); // User|null A specific authoriser for an activity. - $activityProjects->setAuthoriserFromString('TWINAPPS'); // string|null If "change" = allow then locked = false and inherit = false - $activityProjects->setAuthoriserInherit(false); // bool|null - $activityProjects->setAuthoriserInheritFromString('false'); // string|null If "change" = disallow then locked = true and inherit = false - $activityProjects->setAuthoriserLocked(false); // bool|null - $activityProjects->setAuthoriserLockedFromString('false'); // string|null If "change" = inherit then locked = true and inherit = true - $activityProjects->setBillable(false); // bool|null Choose to make an activity billable (true) or not (false) and whether or not it should be included when calculating the "productivity" ratio (@forratio). - $activityProjects->setBillableFromString('false'); // string|null You could also decide that these settings should be inherited from project or user level (@inherit). - $activityProjects->setBillableForRatio(false); // bool|null You can also set whether a change of these settings is allowed or disallowed when a user is entering their timesheet (@locked). - $activityProjects->setBillableForRatioFromString('false'); // string|null If "change" = allow then locked = false and inherit = false. - $activityProjects->setBillableInherit(false); // bool|null - $activityProjects->setBillableInheritFromString('false'); // string|null If "change" = disallow then locked = true and inherit = false. - $activityProjects->setBillableLocked(false); // bool|null - $activityProjects->setBillableLockedFromString('false'); // string|null If "change" = inherit then locked = true and inherit = true + $activityProjects->setAuthoriser($authoriser); // User|null A specific authoriser for an activity. + $activityProjects->setAuthoriserFromString('TWINAPPS'); // string|null If "change" = allow then locked = false and inherit = false + $activityProjects->setAuthoriserInherit(false); // bool|null + $activityProjects->setAuthoriserInheritFromString('false'); // string|null If "change" = disallow then locked = true and inherit = false + $activityProjects->setAuthoriserLocked(false); // bool|null + $activityProjects->setAuthoriserLockedFromString('false'); // string|null If "change" = inherit then locked = true and inherit = true + $activityProjects->setBillable(false); // bool|null Choose to make an activity billable (true) or not (false) and whether or not it should be included when calculating the "productivity" ratio (@forratio). + $activityProjects->setBillableFromString('false'); // string|null You could also decide that these settings should be inherited from project or user level (@inherit). + $activityProjects->setBillableForRatio(false); // bool|null You can also set whether a change of these settings is allowed or disallowed when a user is entering their timesheet (@locked). + $activityProjects->setBillableForRatioFromString('false'); // string|null If "change" = allow then locked = false and inherit = false. + $activityProjects->setBillableInherit(false); // bool|null + $activityProjects->setBillableInheritFromString('false'); // string|null If "change" = disallow then locked = true and inherit = false. + $activityProjects->setBillableLocked(false); // bool|null + $activityProjects->setBillableLockedFromString('false'); // string|null If "change" = inherit then locked = true and inherit = true $customer = new \PhpTwinfield\Customer; $customer->setCode('1000'); - //$activityProjects->setCustomer($customer); // Customer|null An activity always needs to be linked to a customer. - //$activityProjects->setCustomerFromString('1000'); // string|null Choose to have the customer ‘inherited’ (from a project) or you can specify the customer here. - $activityProjects->setCustomerInherit(true); // bool|null - $activityProjects->setCustomerInheritFromString('true'); // string|null If "change" = allow then locked = false and inherit = false - $activityProjects->setCustomerLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false - $activityProjects->setCustomerLockedFromString('true'); // string|null If "change" = inherit then locked = true and inherit = true - $activityProjects->setInvoiceDescription('Example Invoice Description'); // string|null This field can be used to enter a longer activity description which will be available on the invoice template. + //$activityProjects->setCustomer($customer); // Customer|null An activity always needs to be linked to a customer. + //$activityProjects->setCustomerFromString('1000'); // string|null Choose to have the customer ‘inherited’ (from a project) or you can specify the customer here. + $activityProjects->setCustomerInherit(true); // bool|null + $activityProjects->setCustomerInheritFromString('true'); // string|null If "change" = allow then locked = false and inherit = false + $activityProjects->setCustomerLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false + $activityProjects->setCustomerLockedFromString('true'); // string|null If "change" = inherit then locked = true and inherit = true + $activityProjects->setInvoiceDescription('Example Invoice Description'); // string|null This field can be used to enter a longer activity description which will be available on the invoice template. $rate = new \PhpTwinfield\Rate; $rate->setCode('DIRECT'); - $activityProjects->setRate($rate); // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). - $activityProjects->setRateFromString('DIRECT'); // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). - $activityProjects->setRateInherit(false); // bool|null - $activityProjects->setRateInheritFromString('false'); // string|null If "change" = allow then locked = false and inherit = false - $activityProjects->setRateLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false - $activityProjects->setRateLockedFromString('true'); // string|null If "change" = inherit then locked = true and inherit = true + $activityProjects->setRate($rate); // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). + $activityProjects->setRateFromString('DIRECT'); // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). + $activityProjects->setRateInherit(false); // bool|null + $activityProjects->setRateInheritFromString('false'); // string|null If "change" = allow then locked = false and inherit = false + $activityProjects->setRateLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false + $activityProjects->setRateLockedFromString('true'); // string|null If "change" = inherit then locked = true and inherit = true $validFrom = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); - $activityProjects->setValidFrom($validFrom); // \DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. - $activityProjects->setValidFromFromString('20190101'); // string|null + $activityProjects->setValidFrom($validFrom); // \DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. + $activityProjects->setValidFromFromString('20190101'); // string|null $validTill = \DateTime::createFromFormat('d-m-Y', '31-12-2019'); - $activityProjects->setValidTill($validTill); // \DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. - $activityProjects->setValidTillFromString('20191231'); // string|null + $activityProjects->setValidTill($validTill); // \DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. + $activityProjects->setValidTillFromString('20191231'); // string|null // The minimum amount of ActivityQuantities linked to a ActivityProjects object is 0, the maximum amount is 4 $activityQuantity = new \PhpTwinfield\ActivityQuantity; - $activityQuantity->setBillable(false); // bool|null Is the quantity line billable or not. - $activityQuantity->setBillableFromString('false'); // string|null If "billable" = true and "change is not allowed" then locked = true - $activityQuantity->setBillableLocked(false); // bool|null - $activityQuantity->setBillableLockedFromString('false'); // string|null If "billable" = true and "change is allowed" then locked = false - $activityQuantity->setLabel('Example Quantity'); // string|null - $activityQuantity->setMandatory(false); // bool|null Is the quantity line mandatory or not. - $activityQuantity->setMandatoryFromString('false'); // string|null + $activityQuantity->setBillable(false); // bool|null Is the quantity line billable or not. + $activityQuantity->setBillableFromString('false'); // string|null If "billable" = true and "change is not allowed" then locked = true + $activityQuantity->setBillableLocked(false); // bool|null + $activityQuantity->setBillableLockedFromString('false'); // string|null If "billable" = true and "change is allowed" then locked = false + $activityQuantity->setLabel('Example Quantity'); // string|null + $activityQuantity->setMandatory(false); // bool|null Is the quantity line mandatory or not. + $activityQuantity->setMandatoryFromString('false'); // string|null $rate = new \PhpTwinfield\Rate; $rate->setCode('KILOMETERS'); - $activityQuantity->setRate($rate); // Rate|null The rate. - $activityQuantity->setRateFromString('KILOMETERS'); // string|null + $activityQuantity->setRate($rate); // Rate|null The rate. + $activityQuantity->setRateFromString('KILOMETERS'); // string|null - $activityProjects->addQuantity($activityQuantity); // ActivityQuantity Add an ActivityQuantity object to the ActivityProjects object - //$activityProjects->removeQuantity(0); // int Remove a quantity based on the index of the quantity within the array + $activityProjects->addQuantity($activityQuantity); // ActivityQuantity Add an ActivityQuantity object to the ActivityProjects object + //$activityProjects->removeQuantity(0); // int Remove a quantity based on the index of the quantity within the array - $activity->setProjects($activityProjects); // ActivityProjects Set the ActivityProjects object tot the Activity object + $activity->setProjects($activityProjects); // ActivityProjects Set the ActivityProjects object tot the Activity object try { $activityNew = $activityApiConnector->send($activity); diff --git a/examples/Currency.php b/examples/Currency.php index a919b5c4..938e8176 100644 --- a/examples/Currency.php +++ b/examples/Currency.php @@ -172,32 +172,32 @@ $currency = new \PhpTwinfield\Currency; // Required values for creating a new Currency - $currency->setCode('JPY'); // string|null The code of the currency. - $currency->setName("Japanese yen"); // string|null Name of the currency. - $currency->setOffice($office); // Office|null Office code of the currency. - $currency->setOfficeFromString($officeCode); // string|null + $currency->setCode('JPY'); // string|null The code of the currency. + $currency->setName("Japanese yen"); // string|null Name of the currency. + $currency->setOffice($office); // Office|null Office code of the currency. + $currency->setOfficeFromString($officeCode); // string|null // Optional values for creating a new Currency - $currency->setShortName("Yen"); // string|null Short name of the currency. - //$currency->setShortName("¥"); // string|null - $currency->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. - //$currency->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null For deleting deleted should be used. In case a dimension that is used in a transaction is deleted, - // its status has been changed into hide. Hidden dimensions can be activated by using active. - $currency->setStatusFromString('active'); // string|null - //$currency->setStatusFromString('deleted'); // string|null + $currency->setShortName("Yen"); // string|null Short name of the currency. + //$currency->setShortName("¥"); // string|null + $currency->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. + //$currency->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null For deleting deleted should be used. In case a dimension that is used in a transaction is deleted, + // its status has been changed into hide. Hidden dimensions can be activated by using active. + $currency->setStatusFromString('active'); // string|null + //$currency->setStatusFromString('deleted'); // string|null // The minimum amount of CurrencyRates linked to a Currency object is 0 $currencyRate = new \PhpTwinfield\CurrencyRate; - $currencyRate->setRate(122.87); // float|null Conversion rate to be used as of the start date. + $currencyRate->setRate(122.87); // float|null Conversion rate to be used as of the start date. $startDate = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); - $currencyRate->setStartDate($startDate); // \DateTimeInterface|null Starting date of the rate. - $currencyRate->setStartDateFromString('20190101'); // string|null - //$currencyRate->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null For creating and updating status may be left empty. NOTE: Do not use $currencyRate->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); - // For deleting deleted should be used. - //$currencyRate->setStatusFromString('deleted'); // string|null NOTE: Do not use $currencyRate->setStatusFromString('active'); - - $currency->addRate($currencyRate); // CurrencyRate Add a CurrencyRate object to the Currency object - //$currency->removeRate(0); // int Remove a rate based on the index of the rate within the array + $currencyRate->setStartDate($startDate); // \DateTimeInterface|null Starting date of the rate. + $currencyRate->setStartDateFromString('20190101'); // string|null + //$currencyRate->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null For creating and updating status may be left empty. NOTE: Do not use $currencyRate->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); + // For deleting deleted should be used. + //$currencyRate->setStatusFromString('deleted'); // string|null NOTE: Do not use $currencyRate->setStatusFromString('active'); + + $currency->addRate($currencyRate); // CurrencyRate Add a CurrencyRate object to the Currency object + //$currency->removeRate(0); // int Remove a rate based on the index of the rate within the array try { $currencyNew = $currencyApiConnector->send($currency); diff --git a/examples/DimensionGroup.php b/examples/DimensionGroup.php index 4b52550a..9a89942e 100644 --- a/examples/DimensionGroup.php +++ b/examples/DimensionGroup.php @@ -48,7 +48,7 @@ * to add multiple options. An option name may be used once, specifying an option multiple * times will cause an error. * - * Available options: office, vattype + * Available options: office, prefix, dimtype * * office Sets the office code. * Usage: $options['office'] = 'SomeOfficeCode'; @@ -182,17 +182,17 @@ $dimensionGroup = new \PhpTwinfield\DimensionGroup; // Required values for creating a new DimensionGroup - $dimensionGroup->setCode('DIMGRP2'); // string|null Dimension group code. - $dimensionGroup->setName("Dimension Group 2"); // string|null Name of the dimension group. - $dimensionGroup->setOffice($office); // Office|null Office code. - $dimensionGroup->setOfficeFromString($officeCode); // string|null - $dimensionGroup->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating active should be used. For deleting deleted should be used. - //$dimensionGroup->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null - $dimensionGroup->setStatusFromString('active'); // string|null - //$dimensionGroup->setStatusFromString('deleted'); // string|null + $dimensionGroup->setCode('DIMGRP2'); // string|null Dimension group code. + $dimensionGroup->setName("Dimension Group 2"); // string|null Name of the dimension group. + $dimensionGroup->setOffice($office); // Office|null Office code. + $dimensionGroup->setOfficeFromString($officeCode); // string|null + $dimensionGroup->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating active should be used. For deleting deleted should be used. + //$dimensionGroup->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null + $dimensionGroup->setStatusFromString('active'); // string|null + //$dimensionGroup->setStatusFromString('deleted'); // string|null // Optional values for creating a new DimensionGroup - $dimensionGroup->setShortName("DIM GRP 2"); // string|null Short name of the dimension group. + $dimensionGroup->setShortName("DIM GRP 2"); // string|null Short name of the dimension group. // The minimum amount of DimensionGroupDimensions linked to a DimensionGroup object is 0 $dimensionGroupDimension = new \PhpTwinfield\DimensionGroupDimension; @@ -201,13 +201,13 @@ $code = new \PhpTwinfield\GeneralLedger; $code->setType($type); $code->setCode('1010'); - $dimensionGroupDimension->setCode($code); // object|null Code of the dimension. - $dimensionGroupDimension->setCodeFromString('1010'); // string|null - $dimensionGroupDimension->setType($type); // DimensionType|null Dimension type. - $dimensionGroupDimension->setTypeFromString('BAS'); // string|null + $dimensionGroupDimension->setCode($code); // object|null Code of the dimension. + $dimensionGroupDimension->setCodeFromString('1010'); // string|null + $dimensionGroupDimension->setType($type); // DimensionType|null Dimension type. + $dimensionGroupDimension->setTypeFromString('BAS'); // string|null - $dimensionGroup->addDimension($dimensionGroupDimension); // DimensionGroupDimension Add a DimensionGroupDimension object to the DimensionGroup object - //$dimensionGroup->removeDimension(0); // int Remove a dimension based on the index of the dimension within the array + $dimensionGroup->addDimension($dimensionGroupDimension); // DimensionGroupDimension Add a DimensionGroupDimension object to the DimensionGroup object + //$dimensionGroup->removeDimension(0); // int Remove a dimension based on the index of the dimension within the array try { $dimensionGroupNew = $dimensionGroupApiConnector->send($dimensionGroup); diff --git a/examples/DimensionType.php b/examples/DimensionType.php new file mode 100644 index 00000000..c299076d --- /dev/null +++ b/examples/DimensionType.php @@ -0,0 +1,202 @@ + finlevel = 2 +if ($executeListAllWithFilter) { + $options = array('finlevel' => 2); + + try { + $dimensionTypes = $dimensionTypeApiConnector->listAll("*", 0, 1, 10, $options); + } catch (ResponseException $e) { + $dimensionTypes = $e->getReturnedObject(); + } + + echo "
";
+    print_r($dimensionTypes);
+    echo "
"; +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +if ($executeListAllWithoutFilter) { + try { + $dimensionTypes = $dimensionTypeApiConnector->listAll(); + } catch (ResponseException $e) { + $dimensionTypes = $e->getReturnedObject(); + } + + echo "
";
+    print_r($dimensionTypes);
+    echo "
"; +} + +/* DimensionType + * \PhpTwinfield\DimensionType + * Available getters: getCode, getMask, getMessages, getName, getOffice, getOfficeToString, getResult, getShortName, getStatus, hasMessages, getAddress, getLevels + * Available setters: setCode, setMask, setName, setOffice, setOfficeFromString, setShortName, setStatus, setStatusFromString, setAddress, setLevels + */ + +/* DimensionTypeLevels + * \PhpTwinfield\DimensionTypeLevels + * Available getters: getFinancials, getMessages, getResult, getTime, hasMessages + * Available setters: setFinancials, setTime + */ + +/* DimensionTypeAddress + * \PhpTwinfield\DimensionTypeAddress + * Available getters: getLabel1, getLabel2, getLabel3, getLabel4, getLabel5, getLabel6, getMessages, getResult, hasMessages + * Available setters: setLabel1, setLabel2, setLabel3, setLabel4, setLabel5, setLabel6 + */ + +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($dimensionTypes as $key => $dimensionType) { + echo "DimensionType {$key}
"; + echo "Code: {$dimensionType->getCode()}
"; + echo "Name: {$dimensionType->getName()}

"; + } +} + +// Read a DimensionType based off the passed in code and optionally the office. +if ($executeRead) { + try { + $dimensionType = $dimensionTypeApiConnector->get("ACT", $office); + } catch (ResponseException $e) { + $dimensionType = $e->getReturnedObject(); + } + + echo "
";
+    print_r($dimensionType);
+    echo "
"; + + echo "DimensionType
"; + echo "Code: {$dimensionType->getCode()}
"; // string|null Dimension type. + echo "Mask: {$dimensionType->getMask()}
"; // string|null Dimension type mask. + + if ($dimensionType->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($dimensionType->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Name: {$dimensionType->getName()}
"; // string|null Dimension type name. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($dimensionType->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): {$dimensionType->getOfficeToString()}
"; // string|null + echo "Result: {$dimensionType->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$dimensionType->getShortName()}
"; // string|null Dimension type short name. + echo "Status: {$dimensionType->getStatus()}
"; // Status|null Status of the dimension type. + + $dimensionTypeLevels = $dimensionType->getLevels(); // DimensionTypeLevels|null DimensionTypeLevels object. + + echo "Financials: {$dimensionTypeLevels->getFinancials()}
"; // int|null Read-only attribute. Financial level. + + if ($dimensionTypeLevels->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($dimensionTypeLevels->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Result: {$dimensionTypeLevels->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Time: {$dimensionTypeLevels->getTime()}
"; // int|null Read-only attribute. Level in time & expenses. + + $dimensionTypeAddress = $dimensionType->getAddress(); // DimensionTypeAddress|null DimensionTypeAddress object. + + echo "Label 1: {$dimensionTypeAddress->getLabel1()}
"; // string|null Address labels, description of field1 in the dimension address element. + echo "Label 2: {$dimensionTypeAddress->getLabel2()}
"; // string|null Address labels, description of field2 in the dimension address element. + echo "Label 3: {$dimensionTypeAddress->getLabel3()}
"; // string|null Address labels, description of field3 in the dimension address element. + echo "Label 4: {$dimensionTypeAddress->getLabel4()}
"; // string|null Address labels, description of field4 in the dimension address element. + echo "Label 5: {$dimensionTypeAddress->getLabel5()}
"; // string|null Address labels, description of field5 in the dimension address element. + echo "Label 6: {$dimensionTypeAddress->getLabel6()}
"; // string|null Address labels, description of field6 in the dimension address element. + + if ($dimensionTypeAddress->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($dimensionTypeAddress->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Result: {$dimensionTypeAddress->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). +} + +// Copy an existing DimensionType to a new entity +if ($executeModify) { + try { + $dimensionType = $dimensionTypeApiConnector->get("CRD", $office); + } catch (ResponseException $e) { + $dimensionType = $e->getReturnedObject(); + } + + $dimensionType->setMask("2[0-9][0-9][0-9]"); // string|null Dimension type mask. + $dimensionType->setName("Creditors"); // string|null Dimension type name. + $dimensionType->setShortName("Cred"); // string|null Dimension type short name. + + $dimensionTypeAddress = $dimensionType->getAddress(); + + $dimensionTypeAddress->setLabel1('Tav'); // string|null Address labels, description of field1 in the dimension address element. + $dimensionTypeAddress->setLabel2('Address'); // string|null Address labels, description of field2 in the dimension address element. + $dimensionTypeAddress->setLabel4('VAT'); // string|null Address labels, description of field4 in the dimension address element. + $dimensionTypeAddress->setLabel5('CoC'); // string|null Address labels, description of field5 in the dimension address element. + + try { + $dimensionTypeModify = $dimensionTypeApiConnector->send($dimensionType); + } catch (ResponseException $e) { + $dimensionTypeModify = $e->getReturnedObject(); + } + + echo "
";
+    print_r($dimensionTypeModify);
+    echo "
"; + + echo "Result of modify process: {$dimensionTypeModify->getResult()}
"; + echo "Code of modified DimensionType: {$dimensionTypeModify->getCode()}
"; +} \ No newline at end of file diff --git a/examples/Project.php b/examples/Project.php index b9a4e386..56506eab 100644 --- a/examples/Project.php +++ b/examples/Project.php @@ -256,87 +256,88 @@ $project = new \PhpTwinfield\Project; // Required values for creating a new Project - $project->setCode('P0100'); // string|null Dimension code, must be compliant with the mask of the PRJ Dimension type. - $project->setName("Example Project"); // string|null Project description. - $project->setOffice($office); // Office|null Office code. - $project->setOfficeFromString($officeCode); // string|null - //$project->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. - //$project->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case a project is in use, its status has been changed into hide. Hidden projects can be activated by using active. - //$project->setStatusFromString('active'); // string|null - //$project->setStatusFromString('deleted'); // string|null + // + $project->setCode('P0100'); // string|null Dimension code, must be compliant with the mask of the PRJ Dimension type. + $project->setName("Example Project"); // string|null Project description. + $project->setOffice($office); // Office|null Office code. + $project->setOfficeFromString($officeCode); // string|null + //$project->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. + //$project->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case a project is in use, its status has been changed into hide. Hidden projects can be activated by using active. + //$project->setStatusFromString('active'); // string|null + //$project->setStatusFromString('deleted'); // string|null $dimensionType = new \PhpTwinfield\DimensionType; $dimensionType->setCode('PRJ'); - $project->setType($dimensionType); // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is PRJ. - $project->setTypeFromString('PRJ'); // string|null + $project->setType($dimensionType); // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is PRJ. + $project->setTypeFromString('PRJ'); // string|null // Optional values for creating a new Project - $project->setShortName("ExmplAct"); // string|null Short project description. + $project->setShortName("ExmplAct"); // string|null Short project description. $vatCode = new \PhpTwinfield\VatCode; $vatCode->setCode('VH'); - $project->setVatCode($vatCode); // VatCode|null The VAT code if one code will apply for all projects within the project. Note that if any VAT codes are - $project->setVatCodeFromString('VH'); // string|null defined on project level, these will apply regardless of what is defined on project level. + $project->setVatCode($vatCode); // VatCode|null The VAT code if one code will apply for all projects within the project. Note that if any VAT codes are + $project->setVatCodeFromString('VH'); // string|null defined on project level, these will apply regardless of what is defined on project level. $projectProjects = new \PhpTwinfield\ProjectProjects; $authoriser = new \PhpTwinfield\User; $authoriser->setCode('TWINAPPS'); - $projectProjects->setAuthoriser($authoriser); // User|null A specific authoriser for a project. - $projectProjects->setAuthoriserFromString('TWINAPPS'); // string|null If "change" = allow then locked = false and inherit = false - $projectProjects->setAuthoriserInherit(false); // bool|null - $projectProjects->setAuthoriserInheritFromString('false'); // string|null If "change" = disallow then locked = true and inherit = false - $projectProjects->setAuthoriserLocked(false); // bool|null - $projectProjects->setAuthoriserLockedFromString('false'); // string|null If "change" = inherit then locked = true and inherit = true - $projectProjects->setBillable(false); // bool|null Choose to make a project billable (true) or not (false) and whether or not it should be included when calculating the "productivity" ratio (@forratio). - $projectProjects->setBillableFromString('false'); // string|null You could also decide that these settings should be inherited from project or user level (@inherit). - $projectProjects->setBillableForRatio(false); // bool|null You can also set whether a change of these settings is allowed or disallowed when a user is entering their timesheet (@locked). - $projectProjects->setBillableForRatioFromString('false'); // string|null If "change" = allow then locked = false and inherit = false. - $projectProjects->setBillableInherit(false); // bool|null - $projectProjects->setBillableInheritFromString('false'); // string|null If "change" = disallow then locked = true and inherit = false. - $projectProjects->setBillableLocked(false); // bool|null - $projectProjects->setBillableLockedFromString('false'); // string|null If "change" = inherit then locked = true and inherit = true + $projectProjects->setAuthoriser($authoriser); // User|null A specific authoriser for a project. + $projectProjects->setAuthoriserFromString('TWINAPPS'); // string|null If "change" = allow then locked = false and inherit = false + $projectProjects->setAuthoriserInherit(false); // bool|null + $projectProjects->setAuthoriserInheritFromString('false'); // string|null If "change" = disallow then locked = true and inherit = false + $projectProjects->setAuthoriserLocked(false); // bool|null + $projectProjects->setAuthoriserLockedFromString('false'); // string|null If "change" = inherit then locked = true and inherit = true + $projectProjects->setBillable(false); // bool|null Choose to make a project billable (true) or not (false) and whether or not it should be included when calculating the "productivity" ratio (@forratio). + $projectProjects->setBillableFromString('false'); // string|null You could also decide that these settings should be inherited from project or user level (@inherit). + $projectProjects->setBillableForRatio(false); // bool|null You can also set whether a change of these settings is allowed or disallowed when a user is entering their timesheet (@locked). + $projectProjects->setBillableForRatioFromString('false'); // string|null If "change" = allow then locked = false and inherit = false. + $projectProjects->setBillableInherit(false); // bool|null + $projectProjects->setBillableInheritFromString('false'); // string|null If "change" = disallow then locked = true and inherit = false. + $projectProjects->setBillableLocked(false); // bool|null + $projectProjects->setBillableLockedFromString('false'); // string|null If "change" = inherit then locked = true and inherit = true $customer = new \PhpTwinfield\Customer; $customer->setCode('1000'); - //$projectProjects->setCustomer($customer); // Customer|null A project always needs to be linked to a customer. - //$projectProjects->setCustomerFromString('1000'); // string|null Choose to have the customer ‘inherited’ (from a project) or you can specify the customer here. - $projectProjects->setCustomerInherit(true); // bool|null - $projectProjects->setCustomerInheritFromString('true'); // string|null If "change" = allow then locked = false and inherit = false - $projectProjects->setCustomerLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false - $projectProjects->setCustomerLockedFromString('true'); // string|null If "change" = inherit then locked = true and inherit = true - $projectProjects->setInvoiceDescription('Example Invoice Description'); // string|null This field can be used to enter a longer project description which will be available on the invoice template. + //$projectProjects->setCustomer($customer); // Customer|null A project always needs to be linked to a customer. + //$projectProjects->setCustomerFromString('1000'); // string|null Choose to have the customer ‘inherited’ (from a project) or you can specify the customer here. + $projectProjects->setCustomerInherit(true); // bool|null + $projectProjects->setCustomerInheritFromString('true'); // string|null If "change" = allow then locked = false and inherit = false + $projectProjects->setCustomerLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false + $projectProjects->setCustomerLockedFromString('true'); // string|null If "change" = inherit then locked = true and inherit = true + $projectProjects->setInvoiceDescription('Example Invoice Description'); // string|null This field can be used to enter a longer project description which will be available on the invoice template. $rate = new \PhpTwinfield\Rate; $rate->setCode('DIRECT'); - $projectProjects->setRate($rate); // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). - $projectProjects->setRateFromString('DIRECT'); // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). - $projectProjects->setRateInherit(false); // bool|null - $projectProjects->setRateInheritFromString('false'); // string|null If "change" = allow then locked = false and inherit = false - $projectProjects->setRateLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false - $projectProjects->setRateLockedFromString('true'); // string|null If "change" = inherit then locked = true and inherit = true + $projectProjects->setRate($rate); // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). + $projectProjects->setRateFromString('DIRECT'); // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). + $projectProjects->setRateInherit(false); // bool|null + $projectProjects->setRateInheritFromString('false'); // string|null If "change" = allow then locked = false and inherit = false + $projectProjects->setRateLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false + $projectProjects->setRateLockedFromString('true'); // string|null If "change" = inherit then locked = true and inherit = true $validFrom = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); - $projectProjects->setValidFrom($validFrom); // \DateTimeInterface|null A project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. - $projectProjects->setValidFromFromString('20190101'); // string|null + $projectProjects->setValidFrom($validFrom); // \DateTimeInterface|null A project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. + $projectProjects->setValidFromFromString('20190101'); // string|null $validTill = \DateTime::createFromFormat('d-m-Y', '31-12-2019'); - $projectProjects->setValidTill($validTill); // \DateTimeInterface|null A project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. - $projectProjects->setValidTillFromString('20191231'); // string|null + $projectProjects->setValidTill($validTill); // \DateTimeInterface|null A project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. + $projectProjects->setValidTillFromString('20191231'); // string|null // The minimum amount of ProjectQuantities linked to a ProjectProjects object is 0, the maximum amount is 4 $projectQuantity = new \PhpTwinfield\ProjectQuantity; - $projectQuantity->setBillable(false); // bool|null Is the quantity line billable or not. - $projectQuantity->setBillableFromString('false'); // string|null If "billable" = true and "change is not allowed" then locked = true - $projectQuantity->setBillableLocked(false); // bool|null - $projectQuantity->setBillableLockedFromString('false'); // string|null If "billable" = true and "change is allowed" then locked = false - $projectQuantity->setLabel('Example Quantity'); // string|null - $projectQuantity->setMandatory(false); // bool|null Is the quantity line mandatory or not. - $projectQuantity->setMandatoryFromString('false'); // string|null + $projectQuantity->setBillable(false); // bool|null Is the quantity line billable or not. + $projectQuantity->setBillableFromString('false'); // string|null If "billable" = true and "change is not allowed" then locked = true + $projectQuantity->setBillableLocked(false); // bool|null + $projectQuantity->setBillableLockedFromString('false'); // string|null If "billable" = true and "change is allowed" then locked = false + $projectQuantity->setLabel('Example Quantity'); // string|null + $projectQuantity->setMandatory(false); // bool|null Is the quantity line mandatory or not. + $projectQuantity->setMandatoryFromString('false'); // string|null $rate = new \PhpTwinfield\Rate; $rate->setCode('KILOMETERS'); - $projectQuantity->setRate($rate); // Rate|null The rate. - $projectQuantity->setRateFromString('KILOMETERS'); // string|null + $projectQuantity->setRate($rate); // Rate|null The rate. + $projectQuantity->setRateFromString('KILOMETERS'); // string|null - $projectProjects->addQuantity($projectQuantity); // ProjectQuantity Add a ProjectQuantity object to the ProjectProjects object - //$projectProjects->removeQuantity(0); // int Remove a quantity based on the index of the quantity within the array + $projectProjects->addQuantity($projectQuantity); // ProjectQuantity Add a ProjectQuantity object to the ProjectProjects object + //$projectProjects->removeQuantity(0); // int Remove a quantity based on the index of the quantity within the array - $project->setProjects($projectProjects); // ProjectProjects Set the ProjectProjects object tot the Project object + $project->setProjects($projectProjects); // ProjectProjects Set the ProjectProjects object tot the Project object try { $projectNew = $projectApiConnector->send($project); diff --git a/examples/Rate.php b/examples/Rate.php index 4dc5cfd7..80fbeae4 100644 --- a/examples/Rate.php +++ b/examples/Rate.php @@ -195,43 +195,43 @@ $rate = new \PhpTwinfield\Rate; // Required values for creating a new Rate - $rate->setCode('DIRECT2'); // string|null Rate code. + $rate->setCode('DIRECT2'); // string|null Rate code. $currency = new \PhpTwinfield\Currency; $currency->setCode('EUR'); - $rate->setCurrency($currency); // Currency|null Currency code. - $rate->setCurrencyFromString('EUR'); // string|null - $rate->setName("Example Rate"); // string|null Rate description. - $rate->setOffice($office); // Office|null Office code. - $rate->setOfficeFromString($officeCode); // string|null - $rate->setType(\PhpTwinfield\Enums\RateType::TIME()); // RateType|null The rate type. - $rate->setTypeFromString('time'); // string|null - $rate->setUnit(60); // int|null How will be charged e.g. if charged per hour Time, set it to 60. If charged per 8 hours, set it to 8 * 60 = 460. - // Quantities refers to items such as kilometers. If charged per kilometer set it to 1. + $rate->setCurrency($currency); // Currency|null Currency code. + $rate->setCurrencyFromString('EUR'); // string|null + $rate->setName("Example Rate"); // string|null Rate description. + $rate->setOffice($office); // Office|null Office code. + $rate->setOfficeFromString($officeCode); // string|null + $rate->setType(\PhpTwinfield\Enums\RateType::TIME()); // RateType|null The rate type. + $rate->setTypeFromString('time'); // string|null + $rate->setUnit(60); // int|null How will be charged e.g. if charged per hour Time, set it to 60. If charged per 8 hours, set it to 8 * 60 = 460. + // Quantities refers to items such as kilometers. If charged per kilometer set it to 1. // Optional values for creating a new Rate - $rate->setShortName("ExmpleRate"); // string|null Short rate description. - $rate->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. - //$rate->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // For deleting deleted should be used. In case a rate that is in use, its status has been changed into hide. - // Hidden rates can be activated by using active. - $rate->setStatusFromString('active'); // string|null - //$rate->setStatusFromString('deleted'); // string|null + $rate->setShortName("ExmpleRate"); // string|null Short rate description. + $rate->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. + //$rate->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // For deleting deleted should be used. In case a rate that is in use, its status has been changed into hide. + // Hidden rates can be activated by using active. + $rate->setStatusFromString('active'); // string|null + //$rate->setStatusFromString('deleted'); // string|null // The minimum amount of RateRateChanges linked to a Rate object is 0 $rateRateChange = new \PhpTwinfield\RateRateChange; $beginDate = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); - $rateRateChange->setBeginDate($beginDate); // \DateTimeInterface|null Begin date of the rate. - $rateRateChange->setBeginDateFromString('20190101'); // string|null + $rateRateChange->setBeginDate($beginDate); // \DateTimeInterface|null Begin date of the rate. + $rateRateChange->setBeginDateFromString('20190101'); // string|null $endDate = \DateTime::createFromFormat('d-m-Y', '31-12-2019'); - $rateRateChange->setEndDate($endDate); // \DateTimeInterface|null Begin date of the rate. - $rateRateChange->setEndDateFromString('20191231'); // string|null - $rateRateChange->setExternalRate(60); // float|null The internal rate e.g. the cost price per unit. - $rateRateChange->setID(2); // int|null Line ID. - $rateRateChange->setInternalRate(120); // float|null The internal rate e.g. the cost price per unit. - //$rateRateChange->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null Status of the rate line. For creating and updating status may be left empty. NOTE: Do not use $rateRateChange->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); - // For deleting deleted should be used. - //$rateRateChange->setStatusFromString('deleted'); // string|null NOTE: Do not use $rateRateChange->setStatusFromString('active'); - - $rate->addRateChange($rateRateChange); // RateRateChange Add a RateRateChange object to the Rate object - //$rate->removeRateChange(2); // int Remove a rate change based on the id of the rate change + $rateRateChange->setEndDate($endDate); // \DateTimeInterface|null Begin date of the rate. + $rateRateChange->setEndDateFromString('20191231'); // string|null + $rateRateChange->setExternalRate(60); // float|null The internal rate e.g. the cost price per unit. + $rateRateChange->setID(2); // int|null Line ID. + $rateRateChange->setInternalRate(120); // float|null The internal rate e.g. the cost price per unit. + //$rateRateChange->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null Status of the rate line. For creating and updating status may be left empty. NOTE: Do not use $rateRateChange->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); + // For deleting deleted should be used. + //$rateRateChange->setStatusFromString('deleted'); // string|null NOTE: Do not use $rateRateChange->setStatusFromString('active'); + + $rate->addRateChange($rateRateChange); // RateRateChange Add a RateRateChange object to the Rate object + //$rate->removeRateChange(2); // int Remove a rate change based on the id of the rate change try { $rateNew = $rateApiConnector->send($rate); diff --git a/examples/VatCode.php b/examples/VatCode.php index a5daead7..c87b49e7 100644 --- a/examples/VatCode.php +++ b/examples/VatCode.php @@ -220,55 +220,56 @@ $vatCode = new \PhpTwinfield\VatCode; // Required values for creating a new VatCode - $vatCode->setCode('VH2'); // string|null VAT code. - $vatCode->setName("BTW 21%"); // string|null Name of the VAT. - $vatCode->setOffice($office); // Office|null Office code. - $vatCode->setOfficeFromString($officeCode); // string|null - $vatCode->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating active should be used. For deleting deleted should be used. - //$vatCode->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null - $vatCode->setStatusFromString('active'); // string|null - //$vatCode->setStatusFromString('deleted'); // string|null - $vatCode->setType(\PhpTwinfield\Enums\VatType::SALES()); // VatType|null - $vatCode->setTypeFromString('sales'); // string|null + // + $vatCode->setCode('VH2'); // string|null VAT code. + $vatCode->setName("BTW 21%"); // string|null Name of the VAT. + $vatCode->setOffice($office); // Office|null Office code. + $vatCode->setOfficeFromString($officeCode); // string|null + $vatCode->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating active should be used. For deleting deleted should be used. + //$vatCode->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null + $vatCode->setStatusFromString('active'); // string|null + //$vatCode->setStatusFromString('deleted'); // string|null + $vatCode->setType(\PhpTwinfield\Enums\VatType::SALES()); // VatType|null + $vatCode->setTypeFromString('sales'); // string|null // Optional values for creating a new VatCode - $vatCode->setShortName("VH 21%"); // string|null Short name of the VAT. + $vatCode->setShortName("VH 21%"); // string|null Short name of the VAT. // The minimum amount of VatCodePercentages linked to a VatCode object is 0 $vatCodePercentage = new \PhpTwinfield\VatCodePercentage; $date = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); - $vatCodePercentage->setDate($date); // \DateTimeInterface|null Effective date. - $vatCodePercentage->setDateFromString('20190101'); // string|null - $vatCodePercentage->setName("BTW 21%"); // string|null Name of the VAT line. - $vatCodePercentage->setPercentage(21); // float|null Percentage of the VAT line. - $vatCodePercentage->setShortName("VH 21%"); // string|null Short name of the VAT line. + $vatCodePercentage->setDate($date); // \DateTimeInterface|null Effective date. + $vatCodePercentage->setDateFromString('20190101'); // string|null + $vatCodePercentage->setName("BTW 21%"); // string|null Name of the VAT line. + $vatCodePercentage->setPercentage(21); // float|null Percentage of the VAT line. + $vatCodePercentage->setShortName("VH 21%"); // string|null Short name of the VAT line. // The minimum amount of VatCodeAccounts linked to a VatCodePercentage object is 1 $vatCodeAccount = new \PhpTwinfield\VatCodeAccount; $generalLedger = new \PhpTwinfield\GeneralLedger; $generalLedger->setCode('1530'); - $vatCodeAccount->setDim1($generalLedger); // GeneralLedger|null General ledger account on which the VAT amount will be posted. - $vatCodeAccount->setDim1FromString('1530'); // string|null + $vatCodeAccount->setDim1($generalLedger); // GeneralLedger|null General ledger account on which the VAT amount will be posted. + $vatCodeAccount->setDim1FromString('1530'); // string|null $vatGroup = new \PhpTwinfield\VatGroup; $vatGroup->setCode('NL1A'); - $vatCodeAccount->setGroup($vatGroup); // VatGroup|null The VAT group. - $vatCodeAccount->setGroupFromString('NL1A'); // string|null + $vatCodeAccount->setGroup($vatGroup); // VatGroup|null The VAT group. + $vatCodeAccount->setGroupFromString('NL1A'); // string|null $vatGroupCountry = new \PhpTwinfield\VatGroupCountry; $vatGroupCountry->setCode('NL'); - $vatCodeAccount->setGroupCountry($vatGroupCountry); // VatGroupCountry|null Country code of the VAT group. - $vatCodeAccount->setGroupCountryFromString('NL'); // string|null + $vatCodeAccount->setGroupCountry($vatGroupCountry); // VatGroupCountry|null Country code of the VAT group. + $vatCodeAccount->setGroupCountryFromString('NL'); // string|null - $vatCodeAccount->setID(1); // int|null Line ID. - $vatCodeAccount->setLineType(\PhpTwinfield\Enums\LineType::VAT()); // LineType|null Is it a vat line or not detail. Use detail in case a part of the calculated vat value should be posted on a different general ledger account. - $vatCodeAccount->setLineTypeFromString('vat'); // string|null + $vatCodeAccount->setID(1); // int|null Line ID. + $vatCodeAccount->setLineType(\PhpTwinfield\Enums\LineType::VAT()); // LineType|null Is it a vat line or not detail. Use detail in case a part of the calculated vat value should be posted on a different general ledger account. + $vatCodeAccount->setLineTypeFromString('vat'); // string|null - $vatCodeAccount->setPercentage(100); // float|null Percentage of the VAT line. + $vatCodeAccount->setPercentage(100); // float|null Percentage of the VAT line. - $vatCodePercentage->addAccount($vatCodeAccount); // VatCodeAccount Add a VatCodeAccount object to the VatCodePercentage object - //$vatCodePercentage->removeAccount(1); // int Remove an account based on the id of the account + $vatCodePercentage->addAccount($vatCodeAccount); // VatCodeAccount Add a VatCodeAccount object to the VatCodePercentage object + //$vatCodePercentage->removeAccount(1); // int Remove an account based on the id of the account - $vatCode->addPercentage($vatCodePercentage); // VatCodePercentage Add a VatCodePercentage object to the VatCode object - //$vatCode->removePercentage(0); // int Remove a percentage based on the index of the percentage within the array + $vatCode->addPercentage($vatCodePercentage); // VatCodePercentage Add a VatCodePercentage object to the VatCode object + //$vatCode->removePercentage(0); // int Remove a percentage based on the index of the percentage within the array try { $vatCodeNew = $vatCodeApiConnector->send($vatCode); diff --git a/readme.md b/readme.md index a2920084..9e484f43 100644 --- a/readme.md +++ b/readme.md @@ -49,7 +49,7 @@ support for another resource. | [Projects](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Projects) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Project](examples/Project.php) | | [Rates](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Rates) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Rate](examples/Rate.php) | | [Sales Invoices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | [Sales Invoice](examples/Invoice.php) | -| [Sales Invoice Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices) | | :white_check_mark: | | | :white_check_mark: | [Sales Invoice Type](examples/InvoiceType.php) | +| Sales Invoice Types | | :white_check_mark: | | | :white_check_mark: | [Sales Invoice Type](examples/InvoiceType.php) | | [Suppliers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Supplier](examples/Supplier.php) | | | | | | | | | | Transactions | | | | | | | From 2b49268e6bde68756c6cdd72275f9e8a74b62189 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 23 May 2019 18:57:32 +0200 Subject: [PATCH 263/388] Upload --- examples/Activity.php | 2 +- examples/Article.php | 310 ++++++++++++++ examples/Invoice.php | 398 ++++++++++++++++++ examples/Project.php | 2 +- examples/VatCode.php | 2 +- .../Invoice/PeriodRaiseWarningField.php | 47 +++ src/Invoice.php | 2 + 7 files changed, 760 insertions(+), 3 deletions(-) create mode 100644 examples/Article.php create mode 100644 examples/Invoice.php create mode 100644 src/Fields/Invoice/PeriodRaiseWarningField.php diff --git a/examples/Activity.php b/examples/Activity.php index 169cc134..ef2f58c1 100644 --- a/examples/Activity.php +++ b/examples/Activity.php @@ -37,7 +37,7 @@ // Create a new Office object from the $officeCode $office = \PhpTwinfield\Office::fromCode($officeCode); -/* List all dimension groups +/* List all activities * @param string $pattern The search pattern. May contain wildcards * and ? * @param int $field The search field determines which field or fields will be searched. The available fields * depends on the finder type. Passing a value outside the specified values will cause an diff --git a/examples/Article.php b/examples/Article.php new file mode 100644 index 00000000..ebec6173 --- /dev/null +++ b/examples/Article.php @@ -0,0 +1,310 @@ + vat = 'inclusive' +if ($executeListAllWithFilter) { + $options = array('vat' => 'inclusive'); + + try { + $articles = $articleApiConnector->listAll("O*", 0, 1, 10, $options); + } catch (ResponseException $e) { + $articles = $e->getReturnedObject(); + } + + echo "
";
+    print_r($articles);
+    echo "
"; +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +if ($executeListAllWithoutFilter) { + try { + $articles = $articleApiConnector->listAll(); + } catch (ResponseException $e) { + $articles = $e->getReturnedObject(); + } + + echo "
";
+    print_r($articles);
+    echo "
"; +} + +/* Article + * \PhpTwinfield\Article + * Available getters: getAllowChangePerformanceType, getAllowChangePerformanceTypeToString, getAllowChangeUnitsPrice, getAllowChangeUnitsPriceToString, getAllowChangeVatCode, getAllowChangeVatCodeToString, getAllowDecimalQuantity, getAllowDecimalQuantityToString, getAllowDiscountOrPremium, + * getAllowDiscountOrPremiumToString, getCode, getMessages, getName, getOffice, getOfficeToString, getPercentage, getPercentageToString, getPerformanceType, getResult, getShortName, getStatus, getType, getUnitNamePlural, getUnitNameSingular, getVatCode, getVatCodeToString, hasMessages, getLines + * + * Available setters: setAllowChangePerformanceType, setAllowChangePerformanceTypeFromString, setAllowChangeUnitsPrice, setAllowChangeUnitsPriceFromString, setAllowChangeVatCode, setAllowChangeVatCodeFromString, setAllowDecimalQuantity, setAllowDecimalQuantityFromString, setAllowDiscountOrPremium, setAllowDiscountOrPremiumFromString, + * setCode, setName, setOffice, setOfficeFromString, setPercentage, setPercentageFromString, setPerformanceType, setPerformanceTypeFromString, setShortName, setStatus, setStatusFromString, setType, setTypeFromString, setUnitNamePlural, setUnitNameSingular, setVatCode, setVatCodeFromString, addLine, removeLine + * + */ + +/* ArticleLine + * \PhpTwinfield\ArticleLine + * Available getters: getFreeText1, getFreeText1ToString, getFreeText2, getFreeText2ToString, getFreetext3, getID, getInUse, getInUseToString, getMessages, getName, getResult, getShortName, getStatus, getSubCode, getUnits, getUnitsPriceExcl, getUnitsPriceExclToFloat, getUnitsPriceInc, getUnitsPriceIncToFloat, hasMessages + * Available setters: setFreeText1, setFreeText1FromString, setFreeText2, setFreeText2FromString, setFreetext3, setID, setName, setShortName, setStatus, setStatusFromString, setSubCode, setUnits, setUnitsPriceExcl, setUnitsPriceExclFromFloat, setUnitsPriceInc, setUnitsPriceIncFromFloat + */ + +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($articles as $key => $article) { + echo "Article {$key}
"; + echo "Code: {$article->getCode()}
"; + echo "Name: {$article->getName()}

"; + } +} + +// Read an Article based off the passed in code and optionally the office. +if ($executeRead) { + try { + $article = $articleApiConnector->get("9060", $office); + } catch (ResponseException $e) { + $article = $e->getReturnedObject(); + } + + echo "
";
+    print_r($article);
+    echo "
"; + + echo "Article
"; + echo "AllowChangePerformanceType (bool): {$article->getAllowChangePerformanceType()}
"; // bool|null Is it allowed to change the performance type. + echo "AllowChangePerformanceType (string): {$article->getAllowChangePerformanceTypeToString()}
"; // string|null + echo "AllowChangeUnitsPrice (bool): {$article->getAllowChangeUnitsPrice()}
"; // bool|null Is it allowed to change the units price. + echo "AllowChangeUnitsPrice (string): {$article->getAllowChangeUnitsPriceToString()}
"; // string|null + echo "AllowChangeVatCode (bool): {$article->getAllowChangeVatCode()}
"; // bool|null Is it allowed to change the VAT. + echo "AllowChangeVatCode (string): {$article->getAllowChangeVatCodeToString()}
"; // string|null + echo "AllowDecimalQuantity (bool): {$article->getAllowDecimalQuantity()}
"; // bool|null Are decimals allowed. + echo "AllowDecimalQuantity (string): {$article->getAllowDecimalQuantityToString()}
"; // string|null + echo "AllowDiscountOrPremium (bool): {$article->getAllowDiscountOrPremium()}
"; // bool|null Is discount or premium allowed. + echo "AllowDiscountOrPremium (string): {$article->getAllowDiscountOrPremiumToString()}
"; // string|null + echo "Code: {$article->getCode()}
"; // string|null Article code. + + if ($article->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($article->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Name: {$article->getName()}
"; // string|null Article description. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($article->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): {$article->getOfficeToString()}
"; // string|null + echo "Percentage (bool): {$article->getPercentage()}
"; // bool|null Only available when article type is discount or premium. + echo "Percentage (string): {$article->getPercentageToString()}
"; // string|null + echo "PerformanceType: {$article->getPerformanceType()}
"; // PerformanceType|null The performance type. + echo "Result: {$article->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$article->getShortName()}
"; // string|null Short article description. + echo "Status: {$article->getStatus()}
"; // Status|null Status of the article. + echo "Type: {$article->getType()}
"; // ArticleType|null Set to normal in case special item is none. Set to either discount or premium in case special item is deduction or premium respectively. + echo "UnitNamePlural: {$article->getUnitNamePlural()}
"; // string|null Unit name for multiple items. + echo "UnitNameSingular: {$article->getUnitNameSingular()}
"; // string|null Unit name for a single item. + echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($article->getVatCode(), true) . "

"; // VatCode|null Default VAT code. + echo "VatCode (string): {$article->getVatCodeToString()}
"; // string|null + + $articleLines = $article->getLines(); // array|null Array of ArticleLine objects. + + foreach ($articleLines as $key => $articleLine) { + echo "ArticleLine {$key}
"; + + echo "FreeText1 (\\PhpTwinfield\\GeneralLedger):
" . print_r($articleLine->getFreeText1(), true) . "

"; // GeneralLedger|null Mandatory. The general ledger code linked to the article. + echo "FreeText1 (string): {$articleLine->getFreeText1ToString()}
"; // string|null + echo "FreeText2 (\\PhpTwinfield\\CostCenter):
" . print_r($articleLine->getFreeText2(), true) . "

"; // CostCenter|null Optional. The cost center linked to the article. + echo "FreeText2 (string): {$articleLine->getFreeText2ToString()}
"; // string|null + echo "FreeText3: {$articleLine->getFreetext3()}
"; // string|null Free text element 3 + echo "ID: {$articleLine->getID()}
"; // int|null Line ID + echo "InUse (bool): {$articleLine->getInUse()}
"; // bool|null Read-only attribute. Indicates that the sub item has been used in an invoice. + echo "InUse (string): {$articleLine->getInUseToString()}
"; // string|null + + if ($articleLine->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($articleLine->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Name: {$articleLine->getName()}
"; // string|null Sub article name. + echo "Result: {$articleLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$articleLine->getShortName()}
"; // string|null Sub article short name. + echo "Status: {$articleLine->getStatus()}
"; // Status|null Status of the sub article. + echo "SubCode: {$articleLine->getSubCode()}
"; // string|null Can only be empty if there is just one sub article + echo "Units: {$articleLine->getUnits()}
"; // int|null The number of units of the article per quantity + echo "UnitsPriceExcl (\\Money\\Money):
" . print_r($articleLine->getUnitsPriceExcl(), true) . "

"; // Money|null Price excluding VAT + echo "UnitsPriceExcl (float): {$articleLine->getUnitsPriceExclToFloat()}
"; // float|null + echo "UnitsPriceInc (\\Money\\Money):
" . print_r($articleLine->getUnitsPriceInc(), true) . "

"; // Money|null Price including VAT + echo "UnitsPriceInc (float): {$articleLine->getUnitsPriceIncToFloat()}
"; // float|null + } +} + +// Copy an existing Article to a new entity +if ($executeCopy) { + try { + $article = $articleApiConnector->get("9060", $office); + } catch (ResponseException $e) { + $article = $e->getReturnedObject(); + } + + $article->setCode("9061"); + + try { + $articleCopy = $articleApiConnector->send($article); + } catch (ResponseException $e) { + $articleCopy = $e->getReturnedObject(); + } + + echo "
";
+    print_r($articleCopy);
+    echo "
"; + + echo "Result of copy process: {$articleCopy->getResult()}
"; + echo "Code of copied Article: {$articleCopy->getCode()}
"; +} + +// Create a new Article from scratch, alternatively read an existing Article as shown above and than modify the values in the same way as shown below +if ($executeNew) { + $article = new \PhpTwinfield\Article; + + // Required values for creating a new Article + $article->setCode('9061'); // string|null Article code. + $article->setName("Example Article"); // string|null Article description. + $article->setOffice($office); // Office|null Office code. + $article->setOfficeFromString($officeCode); // string|null + //$article->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. + //$article->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case an article is in use, its status has been changed into hide. Hidden articles can be activated by using active. + //$article->setStatusFromString('active'); // string|null + //$article->setStatusFromString('deleted'); // string|null + $article->setUnitNamePlural("Example Art Units"); // string|null Unit name for multiple items + $article->setUnitNameSingular("Example Art Unit"); // string|null Unit name for a single item + + // Optional values for creating a new Article + $article->setAllowChangePerformanceType(true); // bool|null Is it allowed to change the performance type. + $article->setAllowChangePerformanceTypeFromString('true'); // string|null + $article->setAllowChangeUnitsPrice(true); // bool|null Is it allowed to change the units price. + $article->setAllowChangeUnitsPriceFromString('true'); // string|null + $article->setAllowChangeVatCode(true); // bool|null Is it allowed to change the VAT. + $article->setAllowChangeVatCodeFromString('true'); // string|null + $article->setAllowDecimalQuantity(true); // bool|null Are decimals allowed. + $article->setAllowDecimalQuantityFromString('true'); // string|null + $article->setAllowDiscountOrPremium(true); // bool|null Is discount or premium allowed. + $article->setAllowDiscountOrPremiumFromString('true'); // string|null + //$article->setPercentage(true); // bool|null Only available when article type is discount or premium + //$article->setPercentageFromString('true'); // string|null + $article->setPerformanceType(\PhpTwinfield\Enums\PerformanceType::SERVICES()); // PerformanceType|null The performance type. + $article->setPerformanceTypeFromString('services'); // string|null + $article->setShortName("ExmplArt"); // string|null Short article description. + $article->setType(\PhpTwinfield\Enums\ArticleType::NORMAL()); // ArticleType|null Set to normal in case special item is none. Set to either discount or premium in case special item is deduction or premium respectively. + $article->setTypeFromString('normal'); // string|null + $vatCode = new \PhpTwinfield\VatCode; + $vatCode->setCode('VH'); + $article->setVatCode($vatCode); // VatCode|null Default VAT code + $article->setVatCodeFromString('VH'); // string|null + + // The minimum amount of ArticleLines linked to an Article object is 1 + $articleLine = new \PhpTwinfield\ArticleLine; + + $freeText1 = new \PhpTwinfield\GeneralLedger; + $freeText1->setCode('9060'); + $articleLine->setFreeText1($freeText1); // GeneralLedger|null Mandatory. The general ledger code linked to the article. + $articleLine->setFreeText1FromString('9060'); // string|null + $freeText2 = new \PhpTwinfield\CostCenter; + $freeText2->setCode('00000'); + //$articleLine->setFreeText2($freeText1); // CostCenter|null Mandatory. The general ledger code linked to the article. + //$articleLine->setFreeText2FromString('00000'); // string|null + //$articleLine->setFreetext3(""); // string|null Free text element 3 + $articleLine->setID(1); // int|null Line ID. + $articleLine->setName("Example Sub Article"); // string|null Sub article name. + $articleLine->setShortName("ExmplSubArt"); // string|null Sub article short name. + + $articleLine->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null Allows you to delete sub items and to recover them (if sub item is @inuse). + //$articleLine->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null + $articleLine->setStatusFromString('active'); // string|null + //$articleLine->setStatusFromString('deleted'); // string|null + $articleLine->setSubCode('9061'); // string|null Can only be empty if there is just one sub article + $articleLine->setUnits(1); // int|null The number of units of the article per quantity + $articleLine->setUnitsPriceExcl(\Money\Money::EUR(1000)); // Money|null Price excluding VAT + $articleLine->setUnitsPriceExclFromFloat(10); // float|null + //$articleLine->setUnitsPriceInc(\Money\Money::EUR(1210)); // Money|null Price including VAT + //$articleLine->setUnitsPriceIncFromFloat(12.10); // float|null + + $article->addLine($articleLine); // ArticleLine Add an ArticleLine object to the Article object + //$article->removeLine(1); // int Remove an article line based on the id of the article line + + try { + $articleNew = $articleApiConnector->send($article); + } catch (ResponseException $e) { + $articleNew = $e->getReturnedObject(); + } + + echo "
";
+    print_r($articleNew);
+    echo "
"; + + echo "Result of creation process: {$articleNew->getResult()}
"; + echo "Code of new Article: {$articleNew->getCode()}
"; +} + +// Delete a Article based off the passed in code and optionally the office. +if ($executeDelete) { + try { + $articleDeleted = $articleApiConnector->delete("9061", $office); + } catch (ResponseException $e) { + $articleDeleted = $e->getReturnedObject(); + } + + echo "
";
+    print_r($articleDeleted);
+    echo "
"; + + echo "Result of deletion process: {$articleDeleted->getResult()}
"; +} \ No newline at end of file diff --git a/examples/Invoice.php b/examples/Invoice.php new file mode 100644 index 00000000..0fc7391d --- /dev/null +++ b/examples/Invoice.php @@ -0,0 +1,398 @@ + openvalue = 50.25 +if ($executeListAllWithFilter) { + $options = array('openvalue' => 50.25); + + try { + $invoices = $invoiceApiConnector->listAll("2019*", 0, 1, 10, $options); + } catch (ResponseException $e) { + $invoices = $e->getReturnedObject(); + } + + echo "
";
+    print_r($invoices);
+    echo "
"; +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +if ($executeListAllWithoutFilter) { + try { + $invoices = $invoiceApiConnector->listAll(); + } catch (ResponseException $e) { + $invoices = $e->getReturnedObject(); + } + + echo "
";
+    print_r($invoices);
+    echo "
"; +} + +/* Invoice + * \PhpTwinfield\Invoice + * Available getters: getBank, getBankToString, getCalculateOnly, getCalculateOnlyToString, getCurrency, getCurrencyToString, getCustomer, getCustomerName, getCustomerToString, getDebitCredit, getDeliverAddressNumber, getDueDate, getDueDateToString, getFinancialCode, getFinancialNumber, + * getFooterText, getHeaderText, getInvoiceAddressNumber, getInvoiceAmount, getInvoiceAmountToFloat, getInvoiceDate, getInvoiceDateToString, getInvoiceNumber, getInvoiceType, getInvoiceTypeToString, getMessages, getOffice, getOfficeToString, getPaymentMethod, + * getPerformanceDate, getPerformanceDateToString, getPeriod, getPeriodRaiseWarning, getPeriodRaiseWarningToString, getRaiseWarning, getRaiseWarningToString, getResult, getStatus, hasMessages, getLines, getMatchReference, getTotals, getVatLines + * + * Available setters: setBank, setBankFromString, setCalculateOnly, setCalculateOnlyFromString, setCurrency, setCurrencyFromString, setCustomer, setCustomerFromString, setCustomerName, setDebitCredit, setDebitCreditFromString, setDeliverAddressNumber, setDueDate, setDueDateFromString, + * setFinancialCode, setFinancialNumber, setFooterText, setHeaderText, setInvoiceAddressNumber, setInvoiceAmount, setInvoiceAmountFromFloat, setInvoiceDate, setInvoiceDateFromString, setInvoiceNumber, setInvoiceType, setInvoiceTypeFromString, setOffice, + * setOfficeFromString, setPaymentMethod, setPaymentMethodFromString, setPerformanceDate, setPerformanceDateFromString, setPeriod, setPeriodRaiseWarning, setPeriodRaiseWarningFromString, setRaiseWarning, setRaiseWarningFromString, setStatus, setStatusFromString, setTotals, addLine, addVatLine, removeLine, removeVatLine + * + */ + +/* InvoiceTotals + * \PhpTwinfield\InvoiceTotals + * Available getters: getMessages, getResult, getValueExcl, getValueExclToFloat, getValueInc, getValueIncToFloat, hasMessages + * Available setters: setValueExcl, setValueExclFromFloat, setValueInc, setValueIncFromFloat + */ + +/* InvoiceLine + * \PhpTwinfield\InvoiceLine + * Available getters: getAllowDiscountOrPremium, getAllowDiscountOrPremiumToString, getArticle, getArticleToString, getDescription, getDim1, getDim1ToString, getFreetext1, getFreetext2, getFreetext3, getID, getMessages, getPerformanceDate, getPerformanceDateToString, getPerformanceType, + * getQuantity, getResult, getSubArticle, getSubArticleToString, getUnits, getUnitsPriceExcl, getUnitsPriceExclToFloat, getUnitsPriceInc, getUnitsPriceIncToFloat, getValueExcl, getValueExclToFloat, getValueInc, getValueIncToFloat, getVatCode, getVatCodeToString, getVatValue, getVatValueToFloat, hasMessages + * Available setters: setAllowDiscountOrPremium, setAllowDiscountOrPremiumFromString, setArticle, setArticleFromString, setDescription, setDim1, setDim1FromString, setFreetext1, setFreetext2, setFreetext3, setID, setPerformanceDate, setPerformanceDateFromString, setPerformanceType, setPerformanceTypeFromString, + * setQuantity, setSubArticle, setSubArticleFromString, setUnits, setUnitsPriceExcl, setUnitsPriceExclFromFloat, setUnitsPriceInc, setUnitsPriceIncFromFloat, setValueExcl, setValueExclFromFloat, setValueInc, setValueIncFromFloat, setVatCode, setVatCodeFromString, setVatValue, setVatValueFromFloat + */ + +/* InvoiceVatLine + * \PhpTwinfield\InvoiceVatLine + * Available getters: getMessages, getPerformanceDate, getPerformanceDateToString, getPerformanceType, getResult, getVatCode, getVatCodeToString, getVatValue, getVatValueToFloat, hasMessages + * Available setters: setPerformanceDate, setPerformanceDateFromString, setPerformanceType, setPerformanceTypeFromString, setVatCode, setVatCodeFromString, setVatValue, setVatValueFromFloat + */ + +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($invoices as $key => $invoice) { + echo "Invoice {$key}
"; + echo "InvoiceNumber: {$invoice->getInvoiceNumber()}
"; + echo "InvoiceAmount: {$invoice->getInvoiceAmountToFloat()}
"; + echo "Customer: {$invoice->getCustomerToString()}
"; + echo "CustomerName: {$invoice->getCustomerName()}
"; + echo "Debit/Credit: {$invoice->getDebitCredit()}

"; + } +} + +// Read an Invoice based off the passed in code and optionally the office. +if ($executeRead) { + try { + $invoice = $invoiceApiConnector->get("FACTUUR", "1", $office); + } catch (ResponseException $e) { + $invoice = $e->getReturnedObject(); + } + + echo "
";
+    print_r($invoice);
+    echo "
"; + + echo "Invoice
"; + echo "Bank (\\PhpTwinfield\\CashBankBook):
" . print_r($invoice->getBank(), true) . "

"; // CashBankBook|null Bank code. + echo "Bank (string): {$invoice->getBankToString()}
"; // string|null + echo "Currency (\\PhpTwinfield\\Currency):
" . print_r($invoice->getCurrency(), true) . "

"; // Currency|null Currency code. + echo "Currency (string): {$invoice->getCurrencyToString()}
"; // string|null + echo "Customer (\\PhpTwinfield\\Customer):
" . print_r($invoice->getCustomer(), true) . "

"; // Customer|null Customer code. + echo "Customer (string): {$invoice->getCustomerToString()}
"; // string|null + echo "DeliverAddressNumber: {$invoice->getDeliverAddressNumber()}
"; // int|null + echo "DueDate (\\DateTimeInterface):
" . print_r($invoice->getDueDate(), true) . "

"; // \DateTimeInterface|null Due date. + echo "DueDate (string): {$invoice->getDueDateToString()}
"; // string|null + echo "FinancialCode: {$invoice->getFinancialCode()}
"; // string|null The transaction type code. Read-only attribute. + echo "FinancialNumber: {$invoice->getFinancialNumber()}
"; // string|null The transaction number. Read-only attribute. + echo "FooterText: {$invoice->getFooterText()}
"; // string|null Footer text on the invoice. + echo "HeaderText: {$invoice->getHeaderText()}
"; // string|null Header text on the invoice. + echo "InvoiceAddressNumber: {$invoice->getInvoiceAddressNumber()}
"; // int|null + echo "InvoiceDate (\\DateTimeInterface):
" . print_r($invoice->getInvoiceDate(), true) . "

"; // \DateTimeInterface|null Invoice date. + echo "InvoiceDate (string): {$invoice->getInvoiceDateToString()}
"; // string|null + echo "InvoiceNumber: {$invoice->getInvoiceNumber()}
"; // string|null Invoice Number. + echo "InvoiceType (\\PhpTwinfield\\InvoiceType):
" . print_r($invoice->getInvoiceType(), true) . "

"; // InvoiceType|null Invoice type code. + echo "InvoiceType (string): {$invoice->getInvoiceTypeToString()}
"; // string|null + + if ($invoice->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($invoice->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "PaymentMethod: {$invoice->getPaymentMethod()}
"; // PaymentMethod|null The payment method. + echo "PerformanceDate (\\DateTimeInterface):
" . print_r($invoice->getPerformanceDate(), true) . "

"; // \DateTimeInterface|null Performance date, when set-up on the invoice header. + echo "PerformanceDate (string): {$invoice->getPerformanceDateToString()}
"; // string|null + echo "Period: {$invoice->getPeriod()}
"; // string|null Period in YYYY/PP format. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($invoice->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): {$invoice->getOfficeToString()}
"; // string|null + echo "Result: {$invoice->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Status: {$invoice->getStatus()}
"; // Status|null Status of the invoice. + + $invoiceTotals = $invoice->getTotals(); + + echo "InvoiceTotals
"; + + if ($invoiceTotals->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($invoiceTotals->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Result: {$invoiceTotals->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ValueExcl (\\Money\\Money):
" . print_r($invoiceTotals->getValueExcl(), true) . "

"; // Money|null Value without VAT. Read-only attribute. + echo "ValueExcl (string): {$invoiceTotals->getValueExclToFloat()}
"; // float|null + echo "ValueInc (\\Money\\Money):
" . print_r($invoiceTotals->getValueInc(), true) . "

"; // Money|null Value with VAT. Read-only attribute. + echo "ValueInc (string): {$invoiceTotals->getValueIncToFloat()}
"; // float|null + + if ($invoice->getFinancialCode() != null && $invoice->getFinancialNumber != null) { + $match = $invoice->getMatchReference(); + echo "Match (\\PhpTwinfield\\MatchReference):
" . print_r($match, true) . "

"; // MatchReference|null + } + + $invoiceLines = $invoice->getLines(); // array|null Array of InvoiceLine objects. + + foreach ($invoiceLines as $key => $invoiceLine) { + echo "InvoiceLine {$key}
"; + + echo "AllowDiscountOrPremium (bool): {$invoiceLine->getAllowDiscountOrPremium()}
"; // bool|null Calculate discount on this line. + echo "AllowDiscountOrPremium (string): {$invoiceLine->getAllowDiscountOrPremiumToString()}
"; // string|null + echo "Article (\\PhpTwinfield\\Article):
" . print_r($invoiceLine->getArticle(), true) . "

"; // Article|null Article code. + echo "Article (string): {$invoiceLine->getArticleToString()}
"; // string|null + echo "Description: {$invoiceLine->getDescription()}
"; // string|null Invoice line description, only on the lines with article ‘0’ or ‘-‘. + echo "Dim1 (\\PhpTwinfield\\GeneralLedger):
" . print_r($invoiceLine->getDim1(), true) . "

"; // GeneralLedger|null Balance account. + echo "Dim1 (string): {$invoiceLine->getDim1ToString()}
"; // string|null + echo "FreeText1: {$invoiceLine->getFreetext1()}
"; // string|null Free text field 1 as entered on the invoice type. + echo "FreeText2: {$invoiceLine->getFreetext2()}
"; // string|null Free text field 2 as entered on the invoice type. + echo "FreeText3: {$invoiceLine->getFreetext3()}
"; // string|null Free text field 3 as entered on the invoice type. + echo "ID: {$invoiceLine->getID()}
"; // int|null Line ID + + if ($invoiceLine->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($invoiceLine->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "PerformanceDate (\\DateTimeInterface):
" . print_r($invoiceLine->getPerformanceDate(), true) . "

"; // \DateTimeInterface|null Performance date, when set-up on invoice lines. + echo "PerformanceDate (string): {$invoiceLine->getPerformanceDateToString()}
"; // string|null + echo "PerformanceType: {$invoiceLine->getPerformanceType()}
"; // PerformanceType|null The performance type in case of an ICT sales invoice. + echo "Quantity: {$invoiceLine->getQuantity()}
"; // int|null The quantity on the sales invoice line. + echo "Result: {$invoiceLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "SubArticle (\\PhpTwinfield\\ArticleLine):
" . print_r($invoiceLine->getSubArticle(), true) . "

"; // ArticleLine|null Sub-article code. + echo "SubArticle (string): {$invoiceLine->getSubArticleToString()}
"; // string|null + echo "Units: {$invoiceLine->getUnits()}
"; // int|null The number of units per quantity. + echo "UnitsPriceExcl (\\Money\\Money):
" . print_r($invoiceLine->getUnitsPriceExcl(), true) . "

"; // Money|null Only valid for invoice types with VAT exclusive units prices. + echo "UnitsPriceExcl (string): {$invoiceLine->getUnitsPriceExclToFloat()}
"; // float|null Only add this tag to an XML request if the setting Prices can be changed on an item is set to true. Otherwise, the price will be determined by the system. + echo "UnitsPriceInc (\\Money\\Money):
" . print_r($invoiceLine->getUnitsPriceInc(), true) . "

"; // Money|null Only valid for invoice types with VAT inclusive units prices. + echo "UnitsPriceInc (string): {$invoiceLine->getUnitsPriceIncToFloat()}
"; // float|null Only add this tag to an XML request if the setting Prices can be changed on an item is set to true. Otherwise, the price will be determined by the system. + echo "ValueExcl (\\Money\\Money):
" . print_r($invoiceLine->getValueExcl(), true) . "

"; // Money|null Calculated element. Read-only attribute. + echo "ValueExcl (string): {$invoiceLine->getValueExclToFloat()}
"; // float|null + echo "ValueInc (\\Money\\Money):
" . print_r($invoiceLine->getValueInc(), true) . "

"; // Money|null Calculated element. Read-only attribute. + echo "ValueInc (string): {$invoiceLine->getValueIncToFloat()}
"; // float|null + echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($invoiceLine->getVatCode(), true) . "

"; // VatCode|null VAT code. + echo "VatCode (string): {$invoiceLine->getVatCodeToString()}
"; // string|null + echo "VatValue (\\Money\\Money):
" . print_r($invoiceLine->getVatValue(), true) . "

"; // Money|null Calculated element. Read-only attribute. + echo "VatValue (string): {$invoiceLine->getVatValueToFloat()}
"; // float|null + } + + $invoiceVatLines = $invoice->getVatLines(); // array|null Array of InvoiceVatLine objects. + + foreach ($invoiceVatLines as $key => $invoiceVatLine) { + echo "InvoiceVatLine {$key}
"; + + if ($invoiceVatLine->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($invoiceVatLine->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "PerformanceDate (\\DateTimeInterface):
" . print_r($invoiceVatLine->getPerformanceDate(), true) . "

"; // \DateTimeInterface|null The performance date. Only in case performancetype = services. Read-only attribute. + echo "PerformanceDate (string): {$invoiceVatLine->getPerformanceDateToString()}
"; // string|null + echo "PerformanceType: {$invoiceVatLine->getPerformanceType()}
"; // PerformanceType|null The performance type. Read-only attribute. + echo "Result: {$invoiceVatLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($invoiceVatLine->getVatCode(), true) . "

"; // VatCode|null VAT code. Read-only attribute. + echo "VatCode (string): {$invoiceVatLine->getVatCodeToString()}
"; // string|null + echo "VatValue (\\Money\\Money):
" . print_r($invoiceVatLine->getVatValue(), true) . "

"; // Money|null VAT amount. Read-only attribute. + echo "VatValue (string): {$invoiceVatLine->getVatValueToFloat()}
"; // float|null + } +} + +// Copy an existing Invoice to a new entity +if ($executeCopy) { + try { + $invoice = $invoiceApiConnector->get("FACTUUR", "1", $office); + } catch (ResponseException $e) { + $invoice = $e->getReturnedObject(); + } + + $invoice->setInvoiceNumber(null); + + //Optional, but recommended so your copy is not posted to final immediately + $invoice->setStatusFromString('concept'); + + try { + $invoiceCopy = $invoiceApiConnector->send($invoice); + } catch (ResponseException $e) { + $invoiceCopy = $e->getReturnedObject(); + } + + echo "
";
+    print_r($invoiceCopy);
+    echo "
"; + + echo "Result of copy process: {$invoiceCopy->getResult()}
"; + echo "Number of copied Invoice: {$invoiceCopy->getInvoiceNumber()}
"; +} + +// Create a new Invoice from scratch, alternatively read an existing Invoice as shown above and than modify the values in the same way as shown below +if ($executeNew) { + $invoice = new \PhpTwinfield\Invoice; + + // Required values for creating a new Invoice + $customer = new \PhpTwinfield\Customer; + $customer->setCode('1000'); + $invoice->setCustomer($customer); // Customer|null Customer code. + $invoice->setCustomerFromString("1000"); // string|null + $invoiceType = new \PhpTwinfield\InvoiceType; + $invoiceType->setCode('FACTUUR'); + $invoice->setInvoiceType($invoiceType); // InvoiceType|null Invoice type code. + $invoice->setInvoiceTypeFromString("FACTUUR"); // string|null + $invoice->setOffice($office); // Office|null Office code. + $invoice->setOfficeFromString($officeCode); // string|null + + // Optional values for creating a new Invoice + $invoice->setCalculateOnly(false); // bool|null Attribute to indicate that invoice should not be saved but only checked and calculated. @calculateonly must be true for that. + $invoice->setCalculateOnlyFromString('false'); // string|null + $invoice->setRaiseWarning(true); // bool|null Should warnings be given true or not false? Default true. + $invoice->setRaiseWarningFromString('true'); // string|null + $bank = new \PhpTwinfield\CashBankBook; + $bank->setCode('BNK'); + $invoice->setBank($bank); // CashBankBook|null Customer code. + $invoice->setBankFromString("BNK"); + $currency = new \PhpTwinfield\Currency; + $currency->setCode('EUR'); + $invoice->setCurrency($currency); // Currency|null Currency code. + $invoice->setCurrencyFromString("EUR"); + $invoice->setDeliverAddressNumber(1); // int|null If you want the default address, omit the tag or leave it empty. + $dueDate = \DateTime::createFromFormat('d-m-Y', '01-07-2019'); + $invoice->setDueDate($dueDate); // \DateTimeInterface|null Due date. + $invoice->setDueDateFromString("20190701"); // string|null + $invoice->setFooterText("Example Footer"); // string|null Footer text on the invoice. + $invoice->setHeaderText("Example Header"); // string|null Header text on the invoice. + $invoice->setInvoiceAddressNumber(1); // int|null If you want the default address, omit the tag or leave it empty. + $invoiceDate = \DateTime::createFromFormat('d-m-Y', '01-07-2019'); + $invoice->setInvoiceDate($invoiceDate); // \DateTimeInterface|null Optional; when the invoicedate is not supplied Twinfield uses the system date as the invoice date. + $invoice->setInvoiceDateFromString("20190701"); // string|null + $invoice->setPaymentMethod(\PhpTwinfield\Enums\PaymentMethod::BANK()); // PaymentMethod|null The payment method. + $invoice->setPaymentMethodFromString("bank"); // string|null + $performanceDate = \DateTime::createFromFormat('d-m-Y', '01-07-2019'); + $invoice->setPerformanceDate($performanceDate); // \DateTimeInterface|null Performance date, when set-up on the invoice header. + $invoice->setPerformanceDateFromString("20190701"); // string|null + $invoice->setPeriod("2019/07"); // string|null Period in YYYY/PP format. + $invoice->setPeriodRaiseWarning(false); // bool|null Optionally, it is possible to suppress warnings about 'date out of range for the given period' by adding the raisewarning attribute and set its value to false. + + $invoice->setPeriodRaiseWarningFromString('false'); // string|null This overwrites the value of the raisewarning attribute as set on the root element. + //$invoice->setStatus(\PhpTwinfield\Enums\InvoiceStatus::CONCEPT()); // InvoiceStatus|null default can only be returned when retrieving a sales invoice. + //$invoice->setStatus(\PhpTwinfield\Enums\InvoiceStatus::FINAL()); // InvoiceStatus|null You cannot use this status when creating or updating an invoice. + //$invoice->setStatusFromString('concept'); // string|null concept saves the invoice as provisional. After saving as final, no changes can be made anymore. + //$invoice->setStatusFromString('final'); // string|null When posting an invoice final, a financial transaction is generated and posted automatically. + + // The minimum amount of InvoiceLines linked to an Invoice object is 1 + $invoiceLine = new \PhpTwinfield\InvoiceLine; + + $invoiceLine->setAllowDiscountOrPremium(true); // bool|null Calculate discount on this line. + $invoiceLine->setAllowDiscountOrPremiumFromString('true'); // string|null + $article = new \PhpTwinfield\Article; + $article->setCode('9060'); + $invoiceLine->setArticle($article); // Article|null Article code. + $invoiceLine->setArticleFromString('9060'); // string|null + //$invoiceLine->setDescription('Example Description'); // string|null Invoice line description, only on the lines with article ‘0’ or ‘-‘. + $dim1 = new \PhpTwinfield\GeneralLedger; + $dim1->setCode('9060'); + $invoiceLine->setDim1($dim1); // GeneralLedger|null Balance account. + $invoiceLine->setDim1FromString('9060'); // string|null + //$invoiceLine->setFreeText1('Example Free Text 1'); // string|null Free text field 1 as entered on the invoice type. + //$invoiceLine->setFreeText2('Example Free Text 2'); // string|null Free text field 2 as entered on the invoice type. + //$invoiceLine->setFreetext3("Example Free Text 3"); // string|null Free text field 3 as entered on the invoice type. + $invoiceLine->setID(1); // int|null Line ID. + //$invoice->setPerformanceType(\PhpTwinfield\Enums\PerformanceType::SERVICES()); // PerformanceType|null The performance type in case of an ICT sales invoice. + //$invoice->setPerformanceTypeFromString("services"); // string|null + //$invoiceLine->setPerformanceDate($performanceDate); // \DateTimeInterface|null Performance date, when set-up on invoice lines. + //$invoiceLine->setPerformanceDateFromString("20190701"); // string|null + $invoiceLine->setQuantity(1); // int|null The quantity on the sales invoice line. + $subArticle = new \PhpTwinfield\ArticleLine; + $subArticle->setSubCode('9060'); + $invoiceLine->setSubArticle($subArticle); // ArticleLine|null Sub-article code. + $invoiceLine->setSubArticleFromString('9060'); // string|null + $invoiceLine->setUnits(1); // int|null The number of units per quantity. + $invoiceLine->setUnitsPriceExcl(\Money\Money::EUR(1000)); // Money|null Only valid for invoice types with VAT exclusive units prices. Only add this tag to an XML request if the setting Prices can be changed on an item is set to true. + $invoiceLine->setUnitsPriceExclFromFloat(10); // float|null Otherwise, the price will be determined by the system. + //$invoiceLine->setUnitsPriceInc(\Money\Money::EUR(1210)); // Money|null Only valid for invoice types with VAT inclusive units prices. Only add this tag to an XML request if the setting Prices can be changed on an item is set to true. + //$invoiceLine->setUnitsPriceIncFromFloat(12.10); // float|null Otherwise, the price will be determined by the system. + $vatCode = new \PhpTwinfield\VatCode; + $vatCode->setCode('VH'); + //$invoiceLine->getVatCode($vatCode); // VatCode|null VAT code. + //$invoiceLine->setVatCodeFromString('VH'); // string|null + + $invoice->addLine($invoiceLine); // InvoiceLine Add an InvoiceLine object to the Invoice object + //$invoice->removeLine(1); // int Remove an invoice line based on the id of the invoice line + + try { + $invoiceNew = $invoiceApiConnector->send($invoice); + } catch (ResponseException $e) { + $invoiceNew = $e->getReturnedObject(); + } + + echo "
";
+    print_r($invoiceNew);
+    echo "
"; + + echo "Result of creation process: {$invoiceNew->getResult()}
"; + echo "Number of new Invoice: {$invoiceNew->getInvoiceNumber()}
"; +} \ No newline at end of file diff --git a/examples/Project.php b/examples/Project.php index 56506eab..e769450c 100644 --- a/examples/Project.php +++ b/examples/Project.php @@ -271,7 +271,7 @@ $project->setTypeFromString('PRJ'); // string|null // Optional values for creating a new Project - $project->setShortName("ExmplAct"); // string|null Short project description. + $project->setShortName("ExmplPrj"); // string|null Short project description. $vatCode = new \PhpTwinfield\VatCode; $vatCode->setCode('VH'); $project->setVatCode($vatCode); // VatCode|null The VAT code if one code will apply for all projects within the project. Note that if any VAT codes are diff --git a/examples/VatCode.php b/examples/VatCode.php index c87b49e7..5bfa0c5b 100644 --- a/examples/VatCode.php +++ b/examples/VatCode.php @@ -37,7 +37,7 @@ // Create a new Office object from the $officeCode $office = \PhpTwinfield\Office::fromCode($officeCode); -/* List all vatCodes +/* List all VAT codes * @param string $pattern The search pattern. May contain wildcards * and ? * @param int $field The search field determines which field or fields will be searched. The available fields * depends on the finder type. Passing a value outside the specified values will cause an diff --git a/src/Fields/Invoice/PeriodRaiseWarningField.php b/src/Fields/Invoice/PeriodRaiseWarningField.php new file mode 100644 index 00000000..732a9e6b --- /dev/null +++ b/src/Fields/Invoice/PeriodRaiseWarningField.php @@ -0,0 +1,47 @@ +periodRaiseWarning; + } + + public function getPeriodRaiseWarningToString(): ?string + { + return ($this->getPeriodRaiseWarning()) ? 'true' : 'false'; + } + + /** + * @param bool $periodRaiseWarning + * @return $this + */ + public function setPeriodRaiseWarning(?bool $periodRaiseWarning): self + { + $this->periodRaiseWarning = $periodRaiseWarning; + return $this; + } + + /** + * @param string|null $periodRaiseWarningString + * @return $this + * @throws Exception + */ + public function setPeriodRaiseWarningFromString(?string $periodRaiseWarningString) + { + return $this->setPeriodRaiseWarning(filter_var($periodRaiseWarningString, FILTER_VALIDATE_BOOLEAN)); + } +} \ No newline at end of file diff --git a/src/Invoice.php b/src/Invoice.php index bbae0fc6..5771c268 100644 --- a/src/Invoice.php +++ b/src/Invoice.php @@ -19,6 +19,7 @@ use PhpTwinfield\Fields\Invoice\InvoiceNumberField; use PhpTwinfield\Fields\Invoice\InvoiceTypeField; use PhpTwinfield\Fields\Invoice\PaymentMethodField; +use PhpTwinfield\Fields\Invoice\PeriodRaiseWarningField; use PhpTwinfield\Fields\Invoice\RaiseWarningField; use PhpTwinfield\Fields\Invoice\StatusField; use PhpTwinfield\Fields\OfficeField; @@ -68,6 +69,7 @@ class Invoice extends BaseObject use PaymentMethodField; use PerformanceDateField; use PeriodField; + use PeriodRaiseWarningField; use RaiseWarningField; use StatusField; From 93710d3516ad551442d84f46dd235a318fa5eef1 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 2 Jun 2019 14:15:43 +0200 Subject: [PATCH 264/388] Upload --- examples/Activity.php | 2 +- examples/Article.php | 2 +- examples/CashBankBook.php | 2 +- examples/CostCenter.php | 2 +- examples/Country.php | 2 +- examples/Currency.php | 2 +- examples/DimensionGroup.php | 2 +- examples/DimensionType.php | 2 +- examples/Invoice.php | 2 +- examples/InvoiceType.php | 4 +- examples/Office.php | 157 +++++++++++++++ examples/PayCode.php | 2 +- examples/Project.php | 2 +- examples/Rate.php | 4 +- examples/UserRole.php | 2 +- examples/VatCode.php | 2 +- examples/VatGroup.php | 2 +- examples/VatGroupCountry.php | 2 +- .../{Invoice => }/InvoiceNumberField.php | 62 +++--- src/Fields/Transaction/InvoiceNumberField.php | 32 ---- src/Invoice.php | 2 +- src/JournalTransactionLine.php | 2 +- src/PurchaseTransaction.php | 2 +- src/SalesTransaction.php | 2 +- .../ActivityApiConnectorTest.php | 67 +++++++ .../ApiConnectors/ArticleApiConnectorTest.php | 67 +++++++ .../AssetMethodApiConnectorTest.php | 67 +++++++ .../CostCenterApiConnectorTest.php | 67 +++++++ .../CustomerApiConnectorTest.php | 2 +- .../DimensionGroupApiConnectorTest.php | 67 +++++++ .../DimensionTypeApiConnectorTest.php | 67 +++++++ .../FixedAssetApiConnectorTest.php | 67 +++++++ .../GeneralLedgerApiConnectorTest.php | 67 +++++++ .../ApiConnectors/InvoiceApiConnectorTest.php | 67 +++++++ .../ApiConnectors/ProjectApiConnectorTest.php | 67 +++++++ .../ApiConnectors/RateApiConnectorTest.php | 67 +++++++ .../SupplierApiConnectorTest.php | 67 +++++++ .../TransactionApiConnectorTest.php | 1 - .../ApiConnectors/UserApiConnectorTest.php | 67 +++++++ .../ApiConnectors/VatCodeApiConnectorTest.php | 67 +++++++ ...iled-and-1-successful-banktransactions.xml | 178 ------------------ .../resources/activity-response.xml | 63 +++++++ .../resources/article-response.xml | 36 ++++ .../resources/assetmethod-response.xml | 36 ++++ .../banktransaction-with-all-line-types.xml | 61 ------ .../resources/costcenter-response.xml | 50 +++++ .../resources/customer-response.xml | 80 ++++++++ .../resources/customers-response.xml | 82 -------- .../resources/dimensiongroup-response.xml | 18 ++ .../resources/dimensiontype-response.xml | 23 +++ .../failed-response-without-line-ids.xml | 29 --- .../resources/fixedasset-response.xml | 68 +++++++ .../resources/generalledger-response.xml | 53 ++++++ .../resources/invoice-response.xml | 51 +++++ .../resources/project-response.xml | 71 +++++++ .../ApiConnectors/resources/rate-response.xml | 22 +++ .../resources/supplier-response.xml | 116 ++++++++++++ .../ApiConnectors/resources/user-response.xml | 70 +++++++ .../resources/vatcode-response.xml | 33 ++++ .../CustomersDocumentUnitTest.php | 6 +- tests/UnitTests/Supplier/OfficeTest.php | 54 ------ .../ValueFieldsUnitTest.php | 2 +- 62 files changed, 1945 insertions(+), 495 deletions(-) create mode 100644 examples/Office.php rename src/Fields/{Invoice => }/InvoiceNumberField.php (81%) delete mode 100644 src/Fields/Transaction/InvoiceNumberField.php create mode 100644 tests/UnitTests/ApiConnectors/ActivityApiConnectorTest.php create mode 100644 tests/UnitTests/ApiConnectors/ArticleApiConnectorTest.php create mode 100644 tests/UnitTests/ApiConnectors/AssetMethodApiConnectorTest.php create mode 100644 tests/UnitTests/ApiConnectors/CostCenterApiConnectorTest.php create mode 100644 tests/UnitTests/ApiConnectors/DimensionGroupApiConnectorTest.php create mode 100644 tests/UnitTests/ApiConnectors/DimensionTypeApiConnectorTest.php create mode 100644 tests/UnitTests/ApiConnectors/FixedAssetApiConnectorTest.php create mode 100644 tests/UnitTests/ApiConnectors/GeneralLedgerApiConnectorTest.php create mode 100644 tests/UnitTests/ApiConnectors/InvoiceApiConnectorTest.php create mode 100644 tests/UnitTests/ApiConnectors/ProjectApiConnectorTest.php create mode 100644 tests/UnitTests/ApiConnectors/RateApiConnectorTest.php create mode 100644 tests/UnitTests/ApiConnectors/SupplierApiConnectorTest.php create mode 100644 tests/UnitTests/ApiConnectors/UserApiConnectorTest.php create mode 100644 tests/UnitTests/ApiConnectors/VatCodeApiConnectorTest.php delete mode 100644 tests/UnitTests/ApiConnectors/resources/2-failed-and-1-successful-banktransactions.xml create mode 100644 tests/UnitTests/ApiConnectors/resources/activity-response.xml create mode 100644 tests/UnitTests/ApiConnectors/resources/article-response.xml create mode 100644 tests/UnitTests/ApiConnectors/resources/assetmethod-response.xml delete mode 100644 tests/UnitTests/ApiConnectors/resources/banktransaction-with-all-line-types.xml create mode 100644 tests/UnitTests/ApiConnectors/resources/costcenter-response.xml create mode 100644 tests/UnitTests/ApiConnectors/resources/customer-response.xml delete mode 100644 tests/UnitTests/ApiConnectors/resources/customers-response.xml create mode 100644 tests/UnitTests/ApiConnectors/resources/dimensiongroup-response.xml create mode 100644 tests/UnitTests/ApiConnectors/resources/dimensiontype-response.xml delete mode 100644 tests/UnitTests/ApiConnectors/resources/failed-response-without-line-ids.xml create mode 100644 tests/UnitTests/ApiConnectors/resources/fixedasset-response.xml create mode 100644 tests/UnitTests/ApiConnectors/resources/generalledger-response.xml create mode 100644 tests/UnitTests/ApiConnectors/resources/invoice-response.xml create mode 100644 tests/UnitTests/ApiConnectors/resources/project-response.xml create mode 100644 tests/UnitTests/ApiConnectors/resources/rate-response.xml create mode 100644 tests/UnitTests/ApiConnectors/resources/supplier-response.xml create mode 100644 tests/UnitTests/ApiConnectors/resources/user-response.xml create mode 100644 tests/UnitTests/ApiConnectors/resources/vatcode-response.xml delete mode 100644 tests/UnitTests/Supplier/OfficeTest.php rename tests/UnitTests/Transactions/{TransactionLineFields => }/ValueFieldsUnitTest.php (99%) diff --git a/examples/Activity.php b/examples/Activity.php index ef2f58c1..3fc6453e 100644 --- a/examples/Activity.php +++ b/examples/Activity.php @@ -69,7 +69,7 @@ * */ -//List all with pattern "A*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> accessrules = 0 +//List all with pattern "A*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> accessrules = 0 if ($executeListAllWithFilter) { $options = array('accessrules' => 0); diff --git a/examples/Article.php b/examples/Article.php index ebec6173..da4679fb 100644 --- a/examples/Article.php +++ b/examples/Article.php @@ -60,7 +60,7 @@ * */ -//List all with pattern "O*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> vat = 'inclusive' +//List all with pattern "O*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> vat = 'inclusive' if ($executeListAllWithFilter) { $options = array('vat' => 'inclusive'); diff --git a/examples/CashBankBook.php b/examples/CashBankBook.php index 7423faf2..3bb1a3e2 100644 --- a/examples/CashBankBook.php +++ b/examples/CashBankBook.php @@ -45,7 +45,7 @@ * Usage: $options['banktype'] = -1; */ -//List all with pattern "BNK", field 0 (= search code or number), firstRow 1, maxRows 10, options -> banktype = 0 +//List all with pattern "BNK", field 0 (= search code or name), firstRow 1, maxRows 10, options -> banktype = 0 if ($executeListAllWithFilter) { $options = array('banktype' => 0); diff --git a/examples/CostCenter.php b/examples/CostCenter.php index 05e3756e..14f45fb5 100644 --- a/examples/CostCenter.php +++ b/examples/CostCenter.php @@ -65,7 +65,7 @@ * Usage: $options['group'] = 'DimensionGroup'; */ -//List all with pattern "Apeldoorn", field 0 (= search code or number), firstRow 1, maxRows 10, options -> modifiedsince = '20190101100000', group = 'DimensionGroup' +//List all with pattern "Apeldoorn", field 0 (= search code or name), firstRow 1, maxRows 10, options -> modifiedsince = '20190101100000', group = 'DimensionGroup' if ($executeListAllWithFilter) { $options = array('modifiedsince' => '20190101100000', 'group' => 'DimensionGroup'); diff --git a/examples/Country.php b/examples/Country.php index ed048ab0..ddd7769d 100644 --- a/examples/Country.php +++ b/examples/Country.php @@ -41,7 +41,7 @@ * Usage: $options['office'] = 'SomeOfficeCode'; */ -//List all with pattern "NL", field 0 (= search code or number), firstRow 1, maxRows 10 +//List all with pattern "NL", field 0 (= search code or name), firstRow 1, maxRows 10 if ($executeListAllWithFilter) { try { $countries = $countryApiConnector->listAll('NL', 0, 1, 10); diff --git a/examples/Currency.php b/examples/Currency.php index 938e8176..f714e86f 100644 --- a/examples/Currency.php +++ b/examples/Currency.php @@ -54,7 +54,7 @@ * Usage: $options['office'] = 'SomeOfficeCode'; */ -//List all with pattern "EUR", field 0 (= search code or number), firstRow 1, maxRows 10, options [] +//List all with pattern "EUR", field 0 (= search code or name), firstRow 1, maxRows 10, options [] if ($executeListAllWithFilter) { try { $currencies = $currencyApiConnector->listAll("EUR", 0, 1, 10); diff --git a/examples/DimensionGroup.php b/examples/DimensionGroup.php index 9a89942e..b7c20f78 100644 --- a/examples/DimensionGroup.php +++ b/examples/DimensionGroup.php @@ -62,7 +62,7 @@ * */ -//List all with pattern "*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> dimtype = 'BAS' +//List all with pattern "*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> dimtype = 'BAS' if ($executeListAllWithFilter) { $options = array('dimtype' => 'BAS'); diff --git a/examples/DimensionType.php b/examples/DimensionType.php index c299076d..0521dbd1 100644 --- a/examples/DimensionType.php +++ b/examples/DimensionType.php @@ -60,7 +60,7 @@ * */ -//List all with pattern "*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> finlevel = 2 +//List all with pattern "*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> finlevel = 2 if ($executeListAllWithFilter) { $options = array('finlevel' => 2); diff --git a/examples/Invoice.php b/examples/Invoice.php index 0fc7391d..2de30cee 100644 --- a/examples/Invoice.php +++ b/examples/Invoice.php @@ -64,7 +64,7 @@ * */ -//List all with pattern "2019*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> openvalue = 50.25 +//List all with pattern "2019*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> openvalue = 50.25 if ($executeListAllWithFilter) { $options = array('openvalue' => 50.25); diff --git a/examples/InvoiceType.php b/examples/InvoiceType.php index 1649ebfd..a77182a1 100644 --- a/examples/InvoiceType.php +++ b/examples/InvoiceType.php @@ -35,7 +35,7 @@ * to add multiple options. An option name may be used once, specifying an option multiple * times will cause an error. * - * Available options: office + * Available options: office, vat * * office Sets the office code. * Usage: $options['office'] = 'SomeOfficeCode'; @@ -45,7 +45,7 @@ * Usage: $options['vat'] = 'inclusive'; */ -//List all with pattern "INV*", field 0 (= search code or number), firstRow 1, maxRows 10, options, options -> vat = 'exclusive' +//List all with pattern "INV*", field 0 (= search code or name), firstRow 1, maxRows 10, options, options -> vat = 'exclusive' if ($executeListAllWithFilter) { $options = array('vat' => 'exclusive'); diff --git a/examples/Office.php b/examples/Office.php new file mode 100644 index 00000000..e7e706fa --- /dev/null +++ b/examples/Office.php @@ -0,0 +1,157 @@ +listAllWithoutOfficeCode(); + } catch (ResponseException $e) { + $offices = $e->getReturnedObject(); + } + + echo "
";
+    print_r($offices);
+    echo "
"; +} + +//List all with pattern "NL*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> consolidate = 0 +if ($executeListAllWithFilter) { + $options = array('consolidate' => 0); + + try { + $offices = $officeApiConnector->listAll("NL*", 0, 1, 10, $options); + } catch (ResponseException $e) { + $offices = $e->getReturnedObject(); + } + + echo "
";
+    print_r($offices);
+    echo "
"; +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +if ($executeListAllWithoutFilter) { + try { + $offices = $officeApiConnector->listAll(); + } catch (ResponseException $e) { + $offices = $e->getReturnedObject(); + } + + echo "
";
+    print_r($offices);
+    echo "
"; +} + +/* Office + * \PhpTwinfield\Office + * Available getters: __toString, getCode, getCountryCode, getCountryCodeToString, getCreated, getCreatedToString, getMessages, getModified, getModifiedToString, getName, getResult, getShortName, getStatus, getTouched, getUser, getUserToString, getVatFirstQuarterStartsIn, getVatPeriod, hasMessages + * Available setters: fromCode, setCode, setCountryCode, setCountryCodeFromString, setName, setShortName, setStatus, setStatusFromString, setVatFirstQuarterStartsIn,setVatPeriod + */ + +if ($executeListAllWithoutOfficeCode || $executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($offices as $key => $office) { + echo "Office {$key}
"; + echo "Code: {$office->getCode()}
"; + echo "Name: {$office->getName()}

"; + echo "CountryCode (\\PhpTwinfield\\Country):
" . print_r($office->getCountryCode(), true) . "

"; + echo "CountryCode (string): {$office->getCountryCodeToString()}
"; + echo "VatFirstQuarterStartsIn: {$office->getVatFirstQuarterStartsIn()}
"; + echo "VatPeriod: {$office->getVatPeriod()}
"; + } +} + +// Read an Office based off the passed in code and optionally the office. +if ($executeRead) { + try { + $office = $officeApiConnector->get("NLA000001", $defaultOffice); + } catch (ResponseException $e) { + $office = $e->getReturnedObject(); + } + + echo "
";
+    print_r($office);
+    echo "
"; + + echo "Office
"; + echo "Code: {$office}
"; // string|null + echo "Code: {$office->getCode()}
"; // string|null + //echo "CountryCode (\\PhpTwinfield\\Country):
" . print_r($office->getCountryCode(), true) . "

"; // Country|null + //echo "CountryCode (string): {$office->getCountryCodeToString()}
"; // string|null + echo "Created (\\DateTimeInterface):
" . print_r($office->getCreated(), true) . "

"; // \DateTimeInterface|null The date/time the office was created. + echo "Created (string): {$office->getCreatedToString()}
"; // string|null + + if ($office->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($office->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Modified (\\DateTimeInterface):
" . print_r($office->getModified(), true) . "

"; // \DateTimeInterface|null The date/time the office was modified. + echo "Modified (string): {$office->getModifiedToString()}
"; // string|null + echo "Name: {$office->getName()}
"; // string|null + echo "Result: {$office->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$office->getShortName()}
"; // string|null + echo "Status: {$office->getStatus()}
"; // Status|null + echo "Touched: {$office->getTouched()}
"; // int|null The number of times the office is modified. + echo "User (\\PhpTwinfield\\User):
" . print_r($office->getUser(), true) . "

"; // User|null The code of the user who created or modified the Office. + echo "User (string): {$office->getUserToString()}
"; // string|null + //echo "VatFirstQuarterStartsIn: {$office->getVatFirstQuarterStartsIn()}
"; // string|null + //echo "VatPeriod: {$office->getVatPeriod()}
"; // string|null +} \ No newline at end of file diff --git a/examples/PayCode.php b/examples/PayCode.php index 4456fd1f..d20efade 100644 --- a/examples/PayCode.php +++ b/examples/PayCode.php @@ -45,7 +45,7 @@ * Usage: $options['paytype'] = 'pay'; */ -//List all with pattern "SEPA*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> paytype = pay +//List all with pattern "SEPA*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> paytype = pay if ($executeListAllWithFilter) { $options = array('paytype' => 'pay'); diff --git a/examples/Project.php b/examples/Project.php index e769450c..7e4177cc 100644 --- a/examples/Project.php +++ b/examples/Project.php @@ -69,7 +69,7 @@ * */ -//List all with pattern "P*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> accessrules = 0 +//List all with pattern "P*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> accessrules = 0 if ($executeListAllWithFilter) { $options = array('accessrules' => 0); diff --git a/examples/Rate.php b/examples/Rate.php index 80fbeae4..13200e46 100644 --- a/examples/Rate.php +++ b/examples/Rate.php @@ -48,7 +48,7 @@ * to add multiple options. An option name may be used once, specifying an option multiple * times will cause an error. * - * Available options: office + * Available options: office, ratetype * * office Sets the office code. * Usage: $options['office'] = 'SomeOfficeCode'; @@ -58,7 +58,7 @@ * Usage: $options['ratetype'] = 'quantity'; */ -//List all with pattern "DIR*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> ratetype = 'quantity' +//List all with pattern "DIR*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> ratetype = 'quantity' if ($executeListAllWithFilter) { $options = array('ratetype' => 'time'); diff --git a/examples/UserRole.php b/examples/UserRole.php index dfb6f90c..845be5c8 100644 --- a/examples/UserRole.php +++ b/examples/UserRole.php @@ -41,7 +41,7 @@ * Usage: $options['office'] = 'SomeOfficeCode'; */ -//List all with pattern "LVL1*", field 0 (= search code or number), firstRow 1, maxRows 10 +//List all with pattern "LVL1*", field 0 (= search code or name), firstRow 1, maxRows 10 if ($executeListAllWithFilter) { try { $userRoles = $userRoleApiConnector->listAll("LVL1*", 0, 1, 10); diff --git a/examples/VatCode.php b/examples/VatCode.php index 5bfa0c5b..8a8659bc 100644 --- a/examples/VatCode.php +++ b/examples/VatCode.php @@ -59,7 +59,7 @@ * */ -//List all with pattern "V*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> vattype = 'sales' +//List all with pattern "V*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> vattype = 'sales' if ($executeListAllWithFilter) { $options = array('vattype' => 'sales'); diff --git a/examples/VatGroup.php b/examples/VatGroup.php index 8e3f705a..01cff0ee 100644 --- a/examples/VatGroup.php +++ b/examples/VatGroup.php @@ -41,7 +41,7 @@ * Usage: $options['office'] = 'SomeOfficeCode'; */ -//List all with pattern "1*", field 0 (= search code or number), firstRow 1, maxRows 10 +//List all with pattern "1*", field 0 (= search code or name), firstRow 1, maxRows 10 if ($executeListAllWithFilter) { try { $vatGroups = $vatGroupApiConnector->listAll("1*", 0, 1, 10); diff --git a/examples/VatGroupCountry.php b/examples/VatGroupCountry.php index c5f51535..e94dd500 100644 --- a/examples/VatGroupCountry.php +++ b/examples/VatGroupCountry.php @@ -44,7 +44,7 @@ * Usage: $options['country'] = 'NL'; */ -//List all with pattern "*", field 0 (= search code or number), firstRow 1, maxRows 10, options -> country = NL +//List all with pattern "*", field 0 (= search code or name), firstRow 1, maxRows 10, options -> country = NL if ($executeListAllWithFilter) { $options = array('country' => 'NL'); diff --git a/src/Fields/Invoice/InvoiceNumberField.php b/src/Fields/InvoiceNumberField.php similarity index 81% rename from src/Fields/Invoice/InvoiceNumberField.php rename to src/Fields/InvoiceNumberField.php index 5327a8c4..70d09bc5 100644 --- a/src/Fields/Invoice/InvoiceNumberField.php +++ b/src/Fields/InvoiceNumberField.php @@ -1,32 +1,32 @@ -invoiceNumber; - } - - /** - * @param null|string $invoiceNumber - * @return $this - */ - public function setInvoiceNumber(?string $invoiceNumber): self - { - $this->invoiceNumber = $invoiceNumber; - return $this; - } +invoiceNumber; + } + + /** + * @param null|string $invoiceNumber + * @return $this + */ + public function setInvoiceNumber(?string $invoiceNumber): self + { + $this->invoiceNumber = $invoiceNumber; + return $this; + } } \ No newline at end of file diff --git a/src/Fields/Transaction/InvoiceNumberField.php b/src/Fields/Transaction/InvoiceNumberField.php deleted file mode 100644 index e341d426..00000000 --- a/src/Fields/Transaction/InvoiceNumberField.php +++ /dev/null @@ -1,32 +0,0 @@ -invoiceNumber; - } - - /** - * @param null|string $invoiceNumber - * @return $this - */ - public function setInvoiceNumber(?string $invoiceNumber): self - { - $this->invoiceNumber = $invoiceNumber; - return $this; - } -} \ No newline at end of file diff --git a/src/Invoice.php b/src/Invoice.php index 5771c268..9466d44a 100644 --- a/src/Invoice.php +++ b/src/Invoice.php @@ -16,12 +16,12 @@ use PhpTwinfield\Fields\Invoice\InvoiceAddressNumberField; use PhpTwinfield\Fields\Invoice\InvoiceAmountField; use PhpTwinfield\Fields\Invoice\InvoiceDateField; -use PhpTwinfield\Fields\Invoice\InvoiceNumberField; use PhpTwinfield\Fields\Invoice\InvoiceTypeField; use PhpTwinfield\Fields\Invoice\PaymentMethodField; use PhpTwinfield\Fields\Invoice\PeriodRaiseWarningField; use PhpTwinfield\Fields\Invoice\RaiseWarningField; use PhpTwinfield\Fields\Invoice\StatusField; +use PhpTwinfield\Fields\InvoiceNumberField; use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PeriodField; diff --git a/src/JournalTransactionLine.php b/src/JournalTransactionLine.php index d3f73df5..3fe8e04b 100644 --- a/src/JournalTransactionLine.php +++ b/src/JournalTransactionLine.php @@ -6,9 +6,9 @@ use PhpTwinfield\Enums\LineType; use PhpTwinfield\Enums\PerformanceType; use PhpTwinfield\Enums\MatchStatus; +use PhpTwinfield\Fields\InvoiceNumberField; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PerformanceTypeField; -use PhpTwinfield\Fields\Transaction\InvoiceNumberField; use PhpTwinfield\Fields\Transaction\TransactionLine\BaselineField; use PhpTwinfield\Fields\Transaction\TransactionLine\CurrencyDateField; use PhpTwinfield\Fields\Transaction\TransactionLine\PerformanceCountryField; diff --git a/src/PurchaseTransaction.php b/src/PurchaseTransaction.php index 05f6d7fc..cda947ab 100644 --- a/src/PurchaseTransaction.php +++ b/src/PurchaseTransaction.php @@ -3,7 +3,7 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\DueDateField; -use PhpTwinfield\Fields\Transaction\InvoiceNumberField; +use PhpTwinfield\Fields\InvoiceNumberField; use PhpTwinfield\Fields\Transaction\InvoiceNumberRaiseWarningField; use PhpTwinfield\Fields\Transaction\PaymentReferenceField; diff --git a/src/SalesTransaction.php b/src/SalesTransaction.php index b1a547b4..c86d7cac 100644 --- a/src/SalesTransaction.php +++ b/src/SalesTransaction.php @@ -3,7 +3,7 @@ namespace PhpTwinfield; use PhpTwinfield\Fields\DueDateField; -use PhpTwinfield\Fields\Transaction\InvoiceNumberField; +use PhpTwinfield\Fields\InvoiceNumberField; use PhpTwinfield\Fields\Transaction\InvoiceNumberRaiseWarningField; use PhpTwinfield\Fields\Transaction\OriginReferenceField; use PhpTwinfield\Fields\Transaction\PaymentReferenceField; diff --git a/tests/UnitTests/ApiConnectors/ActivityApiConnectorTest.php b/tests/UnitTests/ApiConnectors/ActivityApiConnectorTest.php new file mode 100644 index 00000000..180800d4 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/ActivityApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new ActivityApiConnector($connection); + } + + private function createActivity(): Activity + { + $activity = new Activity(); + return $activity; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/activity-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $activity = $this->createActivity(); + + $mapped = $this->apiConnector->send($activity); + + $this->assertInstanceOf(Activity::class, $mapped); + $this->assertEquals("A001", $mapped->getCode()); + $this->assertEquals("Test Activity", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/ArticleApiConnectorTest.php b/tests/UnitTests/ApiConnectors/ArticleApiConnectorTest.php new file mode 100644 index 00000000..03f242f8 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/ArticleApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new ArticleApiConnector($connection); + } + + private function createArticle(): Article + { + $article = new Article(); + return $article; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/article-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $article = $this->createArticle(); + + $mapped = $this->apiConnector->send($article); + + $this->assertInstanceOf(Article::class, $mapped); + $this->assertEquals("9060", $mapped->getCode()); + $this->assertEquals("Test Article", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/AssetMethodApiConnectorTest.php b/tests/UnitTests/ApiConnectors/AssetMethodApiConnectorTest.php new file mode 100644 index 00000000..595b4e2f --- /dev/null +++ b/tests/UnitTests/ApiConnectors/AssetMethodApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new AssetMethodApiConnector($connection); + } + + private function createAssetMethod(): AssetMethod + { + $assetMethod = new AssetMethod(); + return $assetMethod; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/assetmethod-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $assetMethod = $this->createAssetMethod(); + + $mapped = $this->apiConnector->send($assetMethod); + + $this->assertInstanceOf(AssetMethod::class, $mapped); + $this->assertEquals("101", $mapped->getCode()); + $this->assertEquals("Inventaris", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/CostCenterApiConnectorTest.php b/tests/UnitTests/ApiConnectors/CostCenterApiConnectorTest.php new file mode 100644 index 00000000..eb9b071e --- /dev/null +++ b/tests/UnitTests/ApiConnectors/CostCenterApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new CostCenterApiConnector($connection); + } + + private function createCostCenter(): CostCenter + { + $costCenter = new CostCenter(); + return $costCenter; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/costcenter-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $costCenter = $this->createCostCenter(); + + $mapped = $this->apiConnector->send($costCenter); + + $this->assertInstanceOf(CostCenter::class, $mapped); + $this->assertEquals("00001", $mapped->getCode()); + $this->assertEquals("Hoevelaken", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php b/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php index eb7e875d..5ac98ae2 100644 --- a/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php @@ -49,7 +49,7 @@ private function createCustomer(): Customer public function testSendAllReturnsMappedObjects() { $response = Response::fromString(file_get_contents( - __DIR__."/resources/customers-response.xml" + __DIR__."/resources/customer-response.xml" )); $this->processXmlService->expects($this->once()) diff --git a/tests/UnitTests/ApiConnectors/DimensionGroupApiConnectorTest.php b/tests/UnitTests/ApiConnectors/DimensionGroupApiConnectorTest.php new file mode 100644 index 00000000..3b0eceb4 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/DimensionGroupApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new DimensionGroupApiConnector($connection); + } + + private function createDimensionGroup(): DimensionGroup + { + $dimensionGroup = new DimensionGroup(); + return $dimensionGroup; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/dimensiongroup-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $dimensionGroup = $this->createDimensionGroup(); + + $mapped = $this->apiConnector->send($dimensionGroup); + + $this->assertInstanceOf(DimensionGroup::class, $mapped); + $this->assertEquals("TSTDIMGRP", $mapped->getCode()); + $this->assertEquals("Test Dimension Group", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/DimensionTypeApiConnectorTest.php b/tests/UnitTests/ApiConnectors/DimensionTypeApiConnectorTest.php new file mode 100644 index 00000000..bd074fe0 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/DimensionTypeApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new DimensionTypeApiConnector($connection); + } + + private function createDimensionType(): DimensionType + { + $dimensionType = new DimensionType(); + return $dimensionType; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/dimensiontype-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $dimensionType = $this->createDimensionType(); + + $mapped = $this->apiConnector->send($dimensionType); + + $this->assertInstanceOf(DimensionType::class, $mapped); + $this->assertEquals("DEB", $mapped->getCode()); + $this->assertEquals("Debiteuren", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/FixedAssetApiConnectorTest.php b/tests/UnitTests/ApiConnectors/FixedAssetApiConnectorTest.php new file mode 100644 index 00000000..7fda71d7 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/FixedAssetApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new FixedAssetApiConnector($connection); + } + + private function createFixedAsset(): FixedAsset + { + $fixedAsset = new FixedAsset(); + return $fixedAsset; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/fixedasset-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $fixedAsset = $this->createFixedAsset(); + + $mapped = $this->apiConnector->send($fixedAsset); + + $this->assertInstanceOf(FixedAsset::class, $mapped); + $this->assertEquals("60000", $mapped->getCode()); + $this->assertEquals("Afschrijving Computer", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/GeneralLedgerApiConnectorTest.php b/tests/UnitTests/ApiConnectors/GeneralLedgerApiConnectorTest.php new file mode 100644 index 00000000..1329bca9 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/GeneralLedgerApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new GeneralLedgerApiConnector($connection); + } + + private function createGeneralLedger(): GeneralLedger + { + $generalLedger = new GeneralLedger(); + return $generalLedger; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/generalledger-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $generalLedger = $this->createGeneralLedger(); + + $mapped = $this->apiConnector->send($generalLedger); + + $this->assertInstanceOf(GeneralLedger::class, $mapped); + $this->assertEquals("4004", $mapped->getCode()); + $this->assertEquals("Bonussen/gratificaties", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/InvoiceApiConnectorTest.php b/tests/UnitTests/ApiConnectors/InvoiceApiConnectorTest.php new file mode 100644 index 00000000..9be43557 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/InvoiceApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new InvoiceApiConnector($connection); + } + + private function createInvoice(): Invoice + { + $invoice = new Invoice(); + return $invoice; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/invoice-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $invoice = $this->createInvoice(); + + $mapped = $this->apiConnector->send($invoice); + + $this->assertInstanceOf(Invoice::class, $mapped); + $this->assertEquals("10", $mapped->getInvoiceNumber()); + $this->assertEquals("20190410", $mapped->getInvoiceDateToString()); + } +} diff --git a/tests/UnitTests/ApiConnectors/ProjectApiConnectorTest.php b/tests/UnitTests/ApiConnectors/ProjectApiConnectorTest.php new file mode 100644 index 00000000..9d531398 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/ProjectApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new ProjectApiConnector($connection); + } + + private function createProject(): Project + { + $project = new Project(); + return $project; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/project-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $project = $this->createProject(); + + $mapped = $this->apiConnector->send($project); + + $this->assertInstanceOf(Project::class, $mapped); + $this->assertEquals("P0000", $mapped->getCode()); + $this->assertEquals("Project direct", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/RateApiConnectorTest.php b/tests/UnitTests/ApiConnectors/RateApiConnectorTest.php new file mode 100644 index 00000000..fc1025b0 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/RateApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new RateApiConnector($connection); + } + + private function createRate(): Rate + { + $rate = new Rate(); + return $rate; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/rate-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $rate = $this->createRate(); + + $mapped = $this->apiConnector->send($rate); + + $this->assertInstanceOf(Rate::class, $mapped); + $this->assertEquals("DIRECT", $mapped->getCode()); + $this->assertEquals("Direct rate", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/SupplierApiConnectorTest.php b/tests/UnitTests/ApiConnectors/SupplierApiConnectorTest.php new file mode 100644 index 00000000..8fb73c1c --- /dev/null +++ b/tests/UnitTests/ApiConnectors/SupplierApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new SupplierApiConnector($connection); + } + + private function createSupplier(): Supplier + { + $supplier = new Supplier(); + return $supplier; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/supplier-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $supplier = $this->createSupplier(); + + $mapped = $this->apiConnector->send($supplier); + + $this->assertInstanceOf(Supplier::class, $mapped); + $this->assertEquals("2000", $mapped->getCode()); + $this->assertEquals("Smits", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php b/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php index d4be823e..e6c7ba6a 100644 --- a/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php @@ -2,7 +2,6 @@ namespace PhpTwinfield\UnitTests; -use Money\Currency; use PhpTwinfield\ApiConnectors\TransactionApiConnector; use PhpTwinfield\BaseTransaction; use PhpTwinfield\Enums\Destiny; diff --git a/tests/UnitTests/ApiConnectors/UserApiConnectorTest.php b/tests/UnitTests/ApiConnectors/UserApiConnectorTest.php new file mode 100644 index 00000000..2de2182f --- /dev/null +++ b/tests/UnitTests/ApiConnectors/UserApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new UserApiConnector($connection); + } + + private function createUser(): User + { + $user = new User(); + return $user; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/user-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $user = $this->createUser(); + + $mapped = $this->apiConnector->send($user); + + $this->assertInstanceOf(User::class, $mapped); + $this->assertEquals("API000001", $mapped->getCode()); + $this->assertEquals("Test User", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/VatCodeApiConnectorTest.php b/tests/UnitTests/ApiConnectors/VatCodeApiConnectorTest.php new file mode 100644 index 00000000..cd63624b --- /dev/null +++ b/tests/UnitTests/ApiConnectors/VatCodeApiConnectorTest.php @@ -0,0 +1,67 @@ +processXmlService = $this->getMockBuilder(ProcessXmlService::class) + ->setMethods(["sendDocument"]) + ->disableOriginalConstructor() + ->getMock(); + + /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->createMock(AuthenticatedConnection::class); + $connection + ->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturn($this->processXmlService); + + $this->apiConnector = new VatCodeApiConnector($connection); + } + + private function createVatCode(): VatCode + { + $vatCode = new VatCode(); + return $vatCode; + } + + public function testSendAllReturnsMappedObjects() + { + $response = Response::fromString(file_get_contents( + __DIR__."/resources/vatcode-response.xml" + )); + + $this->processXmlService->expects($this->once()) + ->method("sendDocument") + ->willReturn($response); + + $vatCode = $this->createVatCode(); + + $mapped = $this->apiConnector->send($vatCode); + + $this->assertInstanceOf(VatCode::class, $mapped); + $this->assertEquals("VH", $mapped->getCode()); + $this->assertEquals("VAT Sales High", $mapped->getName()); + } +} diff --git a/tests/UnitTests/ApiConnectors/resources/2-failed-and-1-successful-banktransactions.xml b/tests/UnitTests/ApiConnectors/resources/2-failed-and-1-successful-banktransactions.xml deleted file mode 100644 index 848ba3d8..00000000 --- a/tests/UnitTests/ApiConnectors/resources/2-failed-and-1-successful-banktransactions.xml +++ /dev/null @@ -1,178 +0,0 @@ - - - -
- BNK - OFFICE001 - 2017/06 - 20170901 - EUR - 0.00 - 0.00 - import - CHUCK-NORRIS - generic - 0 -
- - - 1100 - credit - 0.01 - 2017.123456 - 2017.123456 - 2017.123456 - 1 - 0.01 - 1 - 0.01 - notmatchable - - - 1800 - credit - 12.90 - 2017.123456 - 2017.123456 - 2017.123456 - 1 - 12.90 - 1 - 12.90 - - notmatchable - - - 4700 - debit - 12.90 - 2017.123456 - Some description - Some comment - 1 - 12.90 - 1 - 12.90 - - notmatchable - - -
- -
- BNK - OFFICE001 - 2017/07 - 20170901 - EUR - 0.00 - 0.00 - import - CHUCK-NORRIS - generic - 0 -
- - - 1100 - credit - 0.01 - 2017.123456 - 2017.123456 - 2017.123456 - 1 - 0.01 - 1 - 0.01 - notmatchable - - - 1800 - credit - 5.15 - 2017.123456 - 2017.123456 - 2017.123456 - 1 - 5.15 - 1 - 5.15 - - notmatchable - - - 4700 - debit - 5.15 - 2017.123456 - Some other description - Some other comment - 1 - 5.15 - 1 - 5.15 - - notmatchable - - -
- -
- BNK - OFFICE001 - 2017/08 - 20170901 - EUR - 0.00 - 0.00 - import - CHUCK-NORRIS - generic - 0 - 201700334 -
- - - 1100 - debit - 0.00 - 2017.123456 - 2017.123456 - 2017.123456 - 1 - 0.00 - 1 - 0.00 - notmatchable - - - 1800 - debit - 0.87 - 2017.123456 - 2017.123456 - 2017.123456 - 1 - 0.87 - 1 - 0.87 - - notmatchable - - - 8000 - credit - 0.87 - 2017.123456 - Last description - Last comment - 1 - 0.87 - 1 - 0.87 - - notmatchable - - -
-
\ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/activity-response.xml b/tests/UnitTests/ApiConnectors/resources/activity-response.xml new file mode 100644 index 00000000..116f75d2 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/activity-response.xml @@ -0,0 +1,63 @@ + + + DEV1000 + ACT + A001 + 149e5dcb-8b37-446b-b865-f3928572618f + Test Activity + TstAct + falsenormal + 1 + 0 + 0 + 0 + 0 + + + + true + + notmatchable + inherit + false + 0 + 4 + false + none + + false + + 0 + + + + + false + + + A001 + + + + core + + PRJ + + + + ToFileManager + + + + + + + + + + true + + + + \ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/article-response.xml b/tests/UnitTests/ApiConnectors/resources/article-response.xml new file mode 100644 index 00000000..6de9f20f --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/article-response.xml @@ -0,0 +1,36 @@ + +
+
+ DEV1000 + 9060 + normal + Test Article + TstArt + Test Article + Test Articles + VN + false + + false + false + true + true + true +
+ + + 0.00 + 0.00 + 1 + Test SubArticle + TstSubArt + 9060 + 9060 + + + + + + + +
\ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/assetmethod-response.xml b/tests/UnitTests/ApiConnectors/resources/assetmethod-response.xml new file mode 100644 index 00000000..d4103ae9 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/assetmethod-response.xml @@ -0,0 +1,36 @@ + + + DEV1000 + 101 + Inventaris + Inv + 20190426120347 + 20190501092003 + 10 + API000001 + 0 + 10 + from_purchase_date + linearpercentage + + + 0155 + + 0150 + + + + + + 4750 + + + + + 1 + 2 + 3 + 4 + 5 + + \ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/banktransaction-with-all-line-types.xml b/tests/UnitTests/ApiConnectors/resources/banktransaction-with-all-line-types.xml deleted file mode 100644 index 7c03cb95..00000000 --- a/tests/UnitTests/ApiConnectors/resources/banktransaction-with-all-line-types.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - -
- BNK - OFFICE001 - 2017/09 - 20170901 - EUR - 0.00 - 121.00 - import - USER - generic - 0 - 201700001 -
- - - 1100 - debit - 121.00 - 1 - 121.00 - 1 - 121.00 - notmatchable - - - 2200 - credit - 100.00 - My transaction - VH - 21.00 - 1 - 100.00 - 1 - 100.00 - - - 21.00 - notmatchable - - - credit - 21.00 - VH - 1 - 21.00 - 1 - 21.00 - 1 - 100.00 - 100.00 - 1502 - notmatchable - - -
-
\ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/costcenter-response.xml b/tests/UnitTests/ApiConnectors/resources/costcenter-response.xml new file mode 100644 index 00000000..5e8782fe --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/costcenter-response.xml @@ -0,0 +1,50 @@ + + + DEV1000 + KPL + 00001 + 149e5dcb-8b37-446b-b865-f3928572618f + Hoevelaken + + false + normal + 0 + 0 + 0 + 0 + 0 + + + + true + + notmatchable + inherit + maybe + 0 + 2 + false + none + + false + + 0 + + + + + false + + + 00001 + + + + core + + + ToFileManager + + + + \ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/customer-response.xml b/tests/UnitTests/ApiConnectors/resources/customer-response.xml new file mode 100644 index 00000000..d60118e8 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/customer-response.xml @@ -0,0 +1,80 @@ + + + D1001 + Hr E G H Küppers en/of MW M.J. Küppers-Veeneman + DEB + DEV1000 + +
+ + + BE + + + + + + + + + BE0123456789 + + +
+
+ 149e5dcb-8b37-446b-b865-f3928572618f + true + + normal + 4 + 0 + 0 + 0 + 0 + + + + true + + customersupplier + inherit + false + 30 + 2 + false + none + + false + + 1 + + 130000 + + + + + false + + + D1001 + + + + core + + 130000 + + + + + 0.00 + true + + false + + + + + + +
\ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/customers-response.xml b/tests/UnitTests/ApiConnectors/resources/customers-response.xml deleted file mode 100644 index c1e8ae7b..00000000 --- a/tests/UnitTests/ApiConnectors/resources/customers-response.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - D1001 - Hr E G H Küppers en/of MW M.J. Küppers-Veeneman - DEB - DEV1000 - -
- - - BE - - - - - - - - - BE0123456789 - - -
-
- 149e5dcb-8b37-446b-b865-f3928572618f - true - - normal - 4 - 0 - 0 - 0 - 0 - - - - true - - customersupplier - inherit - false - 30 - 2 - false - none - - false - - 1 - - 130000 - - - - - false - - - D1001 - - - - core - - 130000 - - - - - 0.00 - true - - false - - - - - - -
-
\ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/dimensiongroup-response.xml b/tests/UnitTests/ApiConnectors/resources/dimensiongroup-response.xml new file mode 100644 index 00000000..c839dd4c --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/dimensiongroup-response.xml @@ -0,0 +1,18 @@ + + + DEV1000 + TSTDIMGRP + Test Dimension Group + TstDimGrp + 35 + + + BAS + 0100 + + + BAS + 0105 + + + \ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/dimensiontype-response.xml b/tests/UnitTests/ApiConnectors/resources/dimensiontype-response.xml new file mode 100644 index 00000000..a5f966ae --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/dimensiontype-response.xml @@ -0,0 +1,23 @@ + + + DEV1000 + DEB + Debiteuren + Debiteuren + 1[0-9][0-9][0-9] + 8 + + 2 + + 0 + 0 + +
+ Tav + Adres + Postadres + BTW nummer + KVK nummer + +
+
\ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/failed-response-without-line-ids.xml b/tests/UnitTests/ApiConnectors/resources/failed-response-without-line-ids.xml deleted file mode 100644 index 9e197dcd..00000000 --- a/tests/UnitTests/ApiConnectors/resources/failed-response-without-line-ids.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - -
- BNK_CODE_123 - 450 - 20170901 - 321 - EUR - 0.00 - 126.17 - import -
- - - 123456 - credit - 126.17 - - - 654321 - credit - 126.17 - description - comment - - -
-
\ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/fixedasset-response.xml b/tests/UnitTests/ApiConnectors/resources/fixedasset-response.xml new file mode 100644 index 00000000..113993d3 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/fixedasset-response.xml @@ -0,0 +1,68 @@ + + + DEV1000 + AST + 60000 + 149e5dcb-8b37-446b-b865-f3928572618f + Afschrijving Computer + + false + normal + 0 + 0 + 0 + 0 + 0 + + + + true + + notmatchable + inherit + false + 30 + 3 + false + none + + false + + 2 + 00001 + + + + false + + + 60000 + + + + core + + + ToFileManager + + + + + active + 500.00 + 0.00 + 100 + 2019/01 + 20180401 + + + + + + + + 0 + 10 + 2019/12 + + diff --git a/tests/UnitTests/ApiConnectors/resources/generalledger-response.xml b/tests/UnitTests/ApiConnectors/resources/generalledger-response.xml new file mode 100644 index 00000000..dc20cf53 --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/generalledger-response.xml @@ -0,0 +1,53 @@ + + + DEV1000 + PNL + 4004 + 149e5dcb-8b37-446b-b865-f3928572618f + Bonussen/gratificaties + Bonussen/gratificati + false + normal + 0 + 0 + 0 + 0 + 0 + + + + true + + notmatchable + profitandloss + maybe + 0 + 1 + false + none + + false + + 0 + + + + + false + + + + + + + core + + KPL + + + + ToFileManager + + + + diff --git a/tests/UnitTests/ApiConnectors/resources/invoice-response.xml b/tests/UnitTests/ApiConnectors/resources/invoice-response.xml new file mode 100644 index 00000000..5e4e710e --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/invoice-response.xml @@ -0,0 +1,51 @@ + + +
+ DEV1000 + INVOICE + 10 + 20190410 + 20190510 + BNK + 1 + 1 + 1000 + 2019/4 + EUR + concept + cash + Headertext + Footertext +
+ + +
9060
+ 9060 + 1 + 1 + true + Afronding + 0.00 + 0.00 + 0.00 + 0.00 + + + + 9060 + EXP-BUI-EU +
+
+ + + EXP-BUI-EU + 0.00 + + + + + + 0.00 + 0.00 + +
\ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/project-response.xml b/tests/UnitTests/ApiConnectors/resources/project-response.xml new file mode 100644 index 00000000..a15d3aee --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/project-response.xml @@ -0,0 +1,71 @@ + + + DEV1000 + <PRJ + P0000 + 149e5dcb-8b37-446b-b865-f3928572618f + Project direct + Project directK + false + normal + 0 + 0 + 0 + 0 + 0 + + + + true + + matchable + inherit + maybe + 0 + 3 + false + none + + false + + 2 + 09999 + + + + false + + + P0000 + + + + core + + KPL + ACT + + + + ToFileManager + + + + + Project direct invoice description + + + + + + + + + + KILOMETERS + true + false + + + + \ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/rate-response.xml b/tests/UnitTests/ApiConnectors/resources/rate-response.xml new file mode 100644 index 00000000..6b9dc82a --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/rate-response.xml @@ -0,0 +1,22 @@ + + + DEV1000 + DIRECT + Direct rate + DirectK + 20161223182142 + 20161223182142 + 0 + SUPER + time + 60 + EUR + + + 20100101 + 20991231 + 60.0000 + 120.0000 + + + diff --git a/tests/UnitTests/ApiConnectors/resources/supplier-response.xml b/tests/UnitTests/ApiConnectors/resources/supplier-response.xml new file mode 100644 index 00000000..cfd908da --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/supplier-response.xml @@ -0,0 +1,116 @@ + + + DEV1000 + CRD + 2000 + 149e5dcb-8b37-446b-b865-f3928572618f + Smits + + true + normal + 6 + 0 + 0 + 0 + 0 + http://www.test.com + + + true + + customersupplier + inherit + false + 30 + 2 + true + paymentfile + SEPANLCT + false + + 1 + 1600 + L2000 + + IH + false + + + 2000 + + + + core + + 1600 + + + + ByEmail + test@test.nl + + +
+ BDRNAAM + NL + Utrecht + Postcode + Telefoon + Fax + test@test.com + + TAV + ADRESRGL1 + ADRESRGL2 + NL854800219B01 + KVK + +
+
+ + + Smits + 417164300 +
+ Testadres + 10 +
+ ABN + ABNANL2A + Utrecht + NL + NL91ABNA0417164300 + NL + 1234AB + Teststraat +
+
+ + + EUR + 100.00 + Test + + + + 0100 + 00001 + 60010 + 23 + # + Test + + + + + + + 14 + 10.00 + + + + 20.00 + true + +
\ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/user-response.xml b/tests/UnitTests/ApiConnectors/resources/user-response.xml new file mode 100644 index 00000000..e8df076f --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/user-response.xml @@ -0,0 +1,70 @@ + + + API000001 + 2 + 20190410185142 + 20190416144139 + Test User + TstUsr + name + regular + true + false + nl-NL + test@example.com + LVL1-TRIAL + none + 0 + 5 + + + + + + 0 + + 2 + + + + + dropdown + false + + + + DEV1000 + + true + + DEV1000 + DEV1001 + + + + 0 + + 0 + False + + 20431130000000 + + + + false + + + + + + + + + 2 + 20190410185142 + 20190416144139 + API000001 + \ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/resources/vatcode-response.xml b/tests/UnitTests/ApiConnectors/resources/vatcode-response.xml new file mode 100644 index 00000000..9967ae7f --- /dev/null +++ b/tests/UnitTests/ApiConnectors/resources/vatcode-response.xml @@ -0,0 +1,33 @@ + + + VH + VAT Sales High + VATSlsHigh + 149e5dcb-8b37-446b-b865-f3928572618f + 20041027101342 + 20190410185128 + 0 + TWINAPPS + sales + + + 20121001 + 21.000000000 + 20171016135323 + VAT Sales High + VATSlsHigh + SUPER + + + + + 1530 + NL + NL1A + 100.0 + vat + + + + + diff --git a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php index d5923a2a..ece6f3dd 100644 --- a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php @@ -34,14 +34,14 @@ public function testXmlIsCreatedPerSpec() $customer->setOffice(Office::fromCode("DEV-10000")); $customer->setStatusFromString('active'); - $financials = new CustomerFinancials(); + $financials = new CustomerFinancials(); $financials->setDueDays(1); $financials->setPayAvailable(true); $financials->setPayCodeFromString('pay-code'); $financials->setVatCodeFromString('vat-code'); $financials->setEBilling(true); $financials->setEBillMail('ebillingmail@mail.com'); - $customer->setFinancials($financials); + $customer->setFinancials($financials); $customer->setCreditManagement( (new CustomerCreditManagement()) @@ -54,6 +54,7 @@ public function testXmlIsCreatedPerSpec() ->setFreeText2('free2') ->setComment('comment comment') ); + $customer->addAddress( (new CustomerAddress()) ->setDefault(true) @@ -72,6 +73,7 @@ public function testXmlIsCreatedPerSpec() ->setField5('field 5') ->setField6('field 6') ); + $customer->addBank( (new CustomerBank()) ->setDefault(true) diff --git a/tests/UnitTests/Supplier/OfficeTest.php b/tests/UnitTests/Supplier/OfficeTest.php deleted file mode 100644 index 98befed6..00000000 --- a/tests/UnitTests/Supplier/OfficeTest.php +++ /dev/null @@ -1,54 +0,0 @@ -office = Office::fromCode('TEST-001'); - } - - /** - * @covers \PhpTwinfield\Supplier::setOffice() - * @todo Implement testSetOffice(). - */ - public function testSetOffice() - { - $customer = new Supplier; - - $customer->setOffice($this->office); - - $this->assertEquals($this->office, $customer->getOffice()); - - return $customer; - } - - /** - * Checks if the office field is correctly serialized - * - * @depends testSetOffice - */ - public function testSetOfficeAndSerializes(Supplier $customer) - { - $document = new SuppliersDocument; - - $document->addSupplier($customer); - - $this->assertEquals($document->getElementsByTagName('office')->item(0)->nodeValue, $this->office); - } -} diff --git a/tests/UnitTests/Transactions/TransactionLineFields/ValueFieldsUnitTest.php b/tests/UnitTests/Transactions/ValueFieldsUnitTest.php similarity index 99% rename from tests/UnitTests/Transactions/TransactionLineFields/ValueFieldsUnitTest.php rename to tests/UnitTests/Transactions/ValueFieldsUnitTest.php index 9f32d6f7..f5d0275b 100644 --- a/tests/UnitTests/Transactions/TransactionLineFields/ValueFieldsUnitTest.php +++ b/tests/UnitTests/Transactions/ValueFieldsUnitTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\TestCase; /** - * @covers \PhpTwinfield\Transactions\TransactionLineFields\ValueFields + * @covers \PhpTwinfield\Fields\Transaction\TransactionLine\ValueFields */ class ValueFieldsUnitTest extends TestCase { From b8aa58d85ed95522c282f31d5297ffde652f268d Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 2 Jun 2019 14:19:35 +0200 Subject: [PATCH 265/388] Upload --- src/DomDocuments/TransactionsDocument.php | 2 +- src/Mappers/TransactionMapper.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DomDocuments/TransactionsDocument.php b/src/DomDocuments/TransactionsDocument.php index ca48eeba..db631c82 100644 --- a/src/DomDocuments/TransactionsDocument.php +++ b/src/DomDocuments/TransactionsDocument.php @@ -11,10 +11,10 @@ use PhpTwinfield\Fields\FreeText1Field; use PhpTwinfield\Fields\FreeText2Field; use PhpTwinfield\Fields\FreeText3Field; +use PhpTwinfield\Fields\InvoiceNumberField; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PerformanceTypeField; use PhpTwinfield\Fields\Transaction\CloseAndStartValueFields; -use PhpTwinfield\Fields\Transaction\InvoiceNumberField; use PhpTwinfield\Fields\Transaction\PaymentReferenceField; use PhpTwinfield\Fields\Transaction\RegimeField; use PhpTwinfield\Fields\Transaction\StatementNumberField; diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 10dd6b94..88595386 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -11,10 +11,10 @@ use PhpTwinfield\Fields\FreeText1Field; use PhpTwinfield\Fields\FreeText2Field; use PhpTwinfield\Fields\FreeText3Field; +use PhpTwinfield\Fields\InvoiceNumberField; use PhpTwinfield\Fields\PerformanceDateField; use PhpTwinfield\Fields\PerformanceTypeField; use PhpTwinfield\Fields\Transaction\CloseAndStartValueFields; -use PhpTwinfield\Fields\Transaction\InvoiceNumberField; use PhpTwinfield\Fields\Transaction\OriginReferenceField; use PhpTwinfield\Fields\Transaction\PaymentReferenceField; use PhpTwinfield\Fields\Transaction\RegimeField; From fdf088e817edded4c76805fe80453da729476de5 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 2 Jun 2019 14:20:33 +0200 Subject: [PATCH 266/388] UploaD --- .../ApiConnectors/UserApiConnectorTest.php | 67 ------------------ .../ApiConnectors/resources/user-response.xml | 70 ------------------- 2 files changed, 137 deletions(-) delete mode 100644 tests/UnitTests/ApiConnectors/UserApiConnectorTest.php delete mode 100644 tests/UnitTests/ApiConnectors/resources/user-response.xml diff --git a/tests/UnitTests/ApiConnectors/UserApiConnectorTest.php b/tests/UnitTests/ApiConnectors/UserApiConnectorTest.php deleted file mode 100644 index 2de2182f..00000000 --- a/tests/UnitTests/ApiConnectors/UserApiConnectorTest.php +++ /dev/null @@ -1,67 +0,0 @@ -processXmlService = $this->getMockBuilder(ProcessXmlService::class) - ->setMethods(["sendDocument"]) - ->disableOriginalConstructor() - ->getMock(); - - /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ - $connection = $this->createMock(AuthenticatedConnection::class); - $connection - ->expects($this->any()) - ->method("getAuthenticatedClient") - ->willReturn($this->processXmlService); - - $this->apiConnector = new UserApiConnector($connection); - } - - private function createUser(): User - { - $user = new User(); - return $user; - } - - public function testSendAllReturnsMappedObjects() - { - $response = Response::fromString(file_get_contents( - __DIR__."/resources/user-response.xml" - )); - - $this->processXmlService->expects($this->once()) - ->method("sendDocument") - ->willReturn($response); - - $user = $this->createUser(); - - $mapped = $this->apiConnector->send($user); - - $this->assertInstanceOf(User::class, $mapped); - $this->assertEquals("API000001", $mapped->getCode()); - $this->assertEquals("Test User", $mapped->getName()); - } -} diff --git a/tests/UnitTests/ApiConnectors/resources/user-response.xml b/tests/UnitTests/ApiConnectors/resources/user-response.xml deleted file mode 100644 index e8df076f..00000000 --- a/tests/UnitTests/ApiConnectors/resources/user-response.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - API000001 - 2 - 20190410185142 - 20190416144139 - Test User - TstUsr - name - regular - true - false - nl-NL - test@example.com - LVL1-TRIAL - none - 0 - 5 - - - - - - 0 - - 2 - - - - - dropdown - false - - - - DEV1000 - - true - - DEV1000 - DEV1001 - - - - 0 - - 0 - False - - 20431130000000 - - - - false - - - - - - - - - 2 - 20190410185142 - 20190416144139 - API000001 - \ No newline at end of file From ab4aed51bf751ded39f931ba3d6eaea8f9d9d5b1 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 2 Jun 2019 14:30:18 +0200 Subject: [PATCH 267/388] Update project-response.xml --- tests/UnitTests/ApiConnectors/resources/project-response.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/UnitTests/ApiConnectors/resources/project-response.xml b/tests/UnitTests/ApiConnectors/resources/project-response.xml index a15d3aee..6c501905 100644 --- a/tests/UnitTests/ApiConnectors/resources/project-response.xml +++ b/tests/UnitTests/ApiConnectors/resources/project-response.xml @@ -1,7 +1,7 @@ DEV1000 - <PRJ + PRJ P0000 149e5dcb-8b37-446b-b865-f3928572618f Project direct From 9cf8e77a2dcecd47db7d4c9a905e0d809db2fc15 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 2 Jun 2019 14:40:09 +0200 Subject: [PATCH 268/388] Delete ArticleApiConnectorTest.php --- .../ApiConnectors/ArticleApiConnectorTest.php | 67 ------------------- 1 file changed, 67 deletions(-) delete mode 100644 tests/UnitTests/ApiConnectors/ArticleApiConnectorTest.php diff --git a/tests/UnitTests/ApiConnectors/ArticleApiConnectorTest.php b/tests/UnitTests/ApiConnectors/ArticleApiConnectorTest.php deleted file mode 100644 index 03f242f8..00000000 --- a/tests/UnitTests/ApiConnectors/ArticleApiConnectorTest.php +++ /dev/null @@ -1,67 +0,0 @@ -processXmlService = $this->getMockBuilder(ProcessXmlService::class) - ->setMethods(["sendDocument"]) - ->disableOriginalConstructor() - ->getMock(); - - /** @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject $connection */ - $connection = $this->createMock(AuthenticatedConnection::class); - $connection - ->expects($this->any()) - ->method("getAuthenticatedClient") - ->willReturn($this->processXmlService); - - $this->apiConnector = new ArticleApiConnector($connection); - } - - private function createArticle(): Article - { - $article = new Article(); - return $article; - } - - public function testSendAllReturnsMappedObjects() - { - $response = Response::fromString(file_get_contents( - __DIR__."/resources/article-response.xml" - )); - - $this->processXmlService->expects($this->once()) - ->method("sendDocument") - ->willReturn($response); - - $article = $this->createArticle(); - - $mapped = $this->apiConnector->send($article); - - $this->assertInstanceOf(Article::class, $mapped); - $this->assertEquals("9060", $mapped->getCode()); - $this->assertEquals("Test Article", $mapped->getName()); - } -} From 68517e0ae998ed65a21832f2250443f44812ae37 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 5 Jun 2019 14:15:32 +0200 Subject: [PATCH 269/388] Upload --- ...tTest.php => CustomerDocumentUnitTest.php} | 2 +- .../DomDocuments/SupplierDocumentUnitTest.php | 254 ++++++++++++++++++ .../TransactionLine}/ValueFieldsUnitTest.php | 0 3 files changed, 255 insertions(+), 1 deletion(-) rename tests/UnitTests/DomDocuments/{CustomersDocumentUnitTest.php => CustomerDocumentUnitTest.php} (99%) create mode 100644 tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php rename tests/UnitTests/{Transactions => Fields/Transaction/TransactionLine}/ValueFieldsUnitTest.php (100%) diff --git a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php similarity index 99% rename from tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php rename to tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php index ece6f3dd..01e38938 100644 --- a/tests/UnitTests/DomDocuments/CustomersDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php @@ -11,7 +11,7 @@ use PhpTwinfield\Office; use PHPUnit\Framework\TestCase; -class CustomersDocumentUnitTest extends TestCase +class CustomerDocumentUnitTest extends TestCase { /** * @var CustomersDocument diff --git a/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php b/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php new file mode 100644 index 00000000..b9f1aff7 --- /dev/null +++ b/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php @@ -0,0 +1,254 @@ +document = new SuppliersDocument(); + } + + public function testXmlIsCreatedPerSpec() + { + $supplier = new Supplier(); + $supplier->setCode('D123456'); + $supplier->setName('Chuck Norris'); + $supplier->setWebsite('http://example.org'); + $supplier->setOffice(Office::fromCode("DEV-10000")); + $supplier->setStatusFromString('active'); + + $financials = new SupplierFinancials(); + $financials->setDueDays(1); + $financials->setPayAvailable(true); + $financials->setPayCodeFromString('pay-code'); + $financials->setVatCodeFromString('vat-code'); + $financials->setEBilling(true); + $financials->setEBillMail('ebillingmail@mail.com'); + $supplier->setFinancials($financials); + + $supplier->setCreditManagement( + (new SupplierCreditManagement()) + ->setResponsibleUserFromString('responsible-user') + ->setBaseCreditLimitFromFloat(50) + ->setSendReminderFromString('true') + ->setReminderEmail('reminderemail@mail.com') + ->setBlocked(false) + ->setFreeText1FromString('true') + ->setFreeText2('free2') + ->setComment('comment comment') + ); + + $supplier->addAddress( + (new SupplierAddress()) + ->setDefault(true) + ->setTypeFromString('invoice') + ->setName('My Address') + ->setCountryFromString('nl') + ->setCity('city') + ->setPostcode('postal code') + ->setTelephone('phone number') + ->setTelefax('fax number') + ->setEmail('email@mail.com') + ->setField1('field 1') + ->setField2('field 2') + ->setField3('field 3') + ->setField4('field 4') + ->setField5('field 5') + ->setField6('field 6') + ); + + $supplier->addBank( + (new SupplierBank()) + ->setDefault(true) + ->setAddressField2('address 2') + ->setAddressField3('address 3') + ->setAscription('ascriptor') + ->setAccountNumber('account number') + ->setBankName('bank name') + ->setBicCode('bic code') + ->setCity('city') + ->setCountryFromString('nl') + ->setIban('iban') + ->setNatBicCode('nat-bic') + ->setPostcode('postcode') + ->setState('state') + ); + + $this->document->addSupplier($supplier); + + $supplier = new Supplier(); + $supplier->setCode('D654321'); + $supplier->setName('Nuck Chorris'); + $supplier->setWebsite('http://example.org'); + $supplier->setOffice(Office::fromCode("DEV-00001")); + $supplier->setStatusFromString('deleted'); + + $this->document->addSupplier($supplier); + + $this->assertXmlStringEqualsXmlString( + << + + + 0 + 0 + D123456 + 0 + 0 + Chuck Norris + DEV-10000 + + DEB + http://example.org + + core + 1 + true + ebillingmail@mail.com + + true + pay-code + + vat-code + + + + + + + + 50 + false + comment comment + true + free2 + + reminderemail@mail.com + responsible-user + true + + + + + +
+ city + nl + email@mail.com + field 1 + field 2 + field 3 + field 4 + field 5 + field 6 + My Address + postal code + fax number + phone number +
+
+ + +
+ address 2 + address 3 +
+ ascriptor + account number + bank name + bic code + city + nl + iban + nat-bic + postcode + state +
+
+ + + + + + + + + + +
+ + 0 + 0 + D654321 + 0 + 0 + Nuck Chorris + DEV-00001 + + DEB + http://example.org + + core + 30 + false + + + false + + + + + + + + + + + 0 + false + + false + + + + + true + + + + + + + + + + + + + + + +
+XML + , + $this->document->saveXML() + ); + } +} diff --git a/tests/UnitTests/Transactions/ValueFieldsUnitTest.php b/tests/UnitTests/Fields/Transaction/TransactionLine/ValueFieldsUnitTest.php similarity index 100% rename from tests/UnitTests/Transactions/ValueFieldsUnitTest.php rename to tests/UnitTests/Fields/Transaction/TransactionLine/ValueFieldsUnitTest.php From 27c84943d3dcf4d157e1d4101b92a9c73aba822a Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 5 Jun 2019 14:17:49 +0200 Subject: [PATCH 270/388] Update SupplierDocumentUnitTest.php --- tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php b/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php index b9f1aff7..f729134c 100644 --- a/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php @@ -39,8 +39,6 @@ public function testXmlIsCreatedPerSpec() $financials->setPayAvailable(true); $financials->setPayCodeFromString('pay-code'); $financials->setVatCodeFromString('vat-code'); - $financials->setEBilling(true); - $financials->setEBillMail('ebillingmail@mail.com'); $supplier->setFinancials($financials); $supplier->setCreditManagement( From 5126e6f1e404355d519776d973d6bd554eff8e02 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 5 Jun 2019 14:18:09 +0200 Subject: [PATCH 271/388] Update SupplierDocumentUnitTest.php --- .../DomDocuments/SupplierDocumentUnitTest.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php b/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php index f729134c..d4ce5c40 100644 --- a/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php @@ -41,18 +41,6 @@ public function testXmlIsCreatedPerSpec() $financials->setVatCodeFromString('vat-code'); $supplier->setFinancials($financials); - $supplier->setCreditManagement( - (new SupplierCreditManagement()) - ->setResponsibleUserFromString('responsible-user') - ->setBaseCreditLimitFromFloat(50) - ->setSendReminderFromString('true') - ->setReminderEmail('reminderemail@mail.com') - ->setBlocked(false) - ->setFreeText1FromString('true') - ->setFreeText2('free2') - ->setComment('comment comment') - ); - $supplier->addAddress( (new SupplierAddress()) ->setDefault(true) From ca34d3b9a59bda09d4680d88b26c528675084fd5 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 5 Jun 2019 14:18:18 +0200 Subject: [PATCH 272/388] Update SupplierDocumentUnitTest.php --- tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php b/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php index d4ce5c40..ba00358f 100644 --- a/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php @@ -5,7 +5,6 @@ use PhpTwinfield\Supplier; use PhpTwinfield\SupplierAddress; use PhpTwinfield\SupplierBank; -use PhpTwinfield\SupplierCreditManagement; use PhpTwinfield\SupplierFinancials; use PhpTwinfield\DomDocuments\SuppliersDocument; use PhpTwinfield\Office; From 738c57427764a47974a1b6ab228013abfa7e5ddb Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 5 Jun 2019 14:25:20 +0200 Subject: [PATCH 273/388] Update SupplierDocumentUnitTest.php --- .../DomDocuments/SupplierDocumentUnitTest.php | 108 ++++++------------ 1 file changed, 37 insertions(+), 71 deletions(-) diff --git a/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php b/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php index ba00358f..dea71d83 100644 --- a/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php @@ -100,38 +100,17 @@ public function testXmlIsCreatedPerSpec() Chuck Norris DEV-10000 - DEB + CRD http://example.org - core 1 - true - ebillingmail@mail.com - + true pay-code - + + vat-code - - - - - - - - 50 - false - comment comment - true - free2 - - reminderemail@mail.com - responsible-user - true - - - - +
city @@ -144,14 +123,14 @@ public function testXmlIsCreatedPerSpec() field 5 field 6 My Address - postal code - fax number + postal code + fax number phone number
- -
+ +
address 2 address 3
@@ -167,16 +146,20 @@ public function testXmlIsCreatedPerSpec() state
- - + + - - - - + + + + + + + + 0 @@ -187,48 +170,31 @@ public function testXmlIsCreatedPerSpec() Nuck Chorris DEV-00001 - DEB + CRD http://example.org - core - 30 - false - - - false - - - - - - - - + 30 + + false + + + + - - 0 - false - - false - - - - - true - - - - - - + + - - - - + + + + + + + + XML From c2bb3385c423e8741f6981c989fa43e199b6fc50 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 7 Jun 2019 09:43:08 +0200 Subject: [PATCH 274/388] Upload --- src/DomDocuments/ActivitiesDocument.php | 5 ++++- src/DomDocuments/CostCentersDocument.php | 5 ++++- src/DomDocuments/CustomersDocument.php | 20 +++++++++++++------- src/DomDocuments/FixedAssetsDocument.php | 5 ++++- src/DomDocuments/GeneralLedgersDocument.php | 6 +++++- src/DomDocuments/InvoicesDocument.php | 6 +++++- src/DomDocuments/ProjectsDocument.php | 7 +++++-- src/DomDocuments/SuppliersDocument.php | 6 +++++- src/Secure/WebservicesAuthentication.php | 16 ++++++++-------- 9 files changed, 53 insertions(+), 23 deletions(-) diff --git a/src/DomDocuments/ActivitiesDocument.php b/src/DomDocuments/ActivitiesDocument.php index c2b49590..0ee0e432 100644 --- a/src/DomDocuments/ActivitiesDocument.php +++ b/src/DomDocuments/ActivitiesDocument.php @@ -41,8 +41,11 @@ public function addActivity(Activity $activity) if (!empty($status)) { $activityElement->setAttribute('status', $status); } + + if (!empty($activity->getCode())) { + $activityElement->appendChild($this->createNodeWithTextContent('code', $activity->getCode())); + } - $activityElement->appendChild($this->createNodeWithTextContent('code', $activity->getCode())); $activityElement->appendChild($this->createNodeWithTextContent('name', $activity->getName())); $activityElement->appendChild($this->createNodeWithTextContent('office', $activity->getOfficeToString())); $activityElement->appendChild($this->createNodeWithTextContent('shortname', $activity->getShortName())); diff --git a/src/DomDocuments/CostCentersDocument.php b/src/DomDocuments/CostCentersDocument.php index 81dc3d8d..d978ff26 100644 --- a/src/DomDocuments/CostCentersDocument.php +++ b/src/DomDocuments/CostCentersDocument.php @@ -41,8 +41,11 @@ public function addCostCenter(CostCenter $costCenter) if (!empty($status)) { $costCenterElement->setAttribute('status', $status); } + + if (!empty($costCenter->getCode())) { + $costCenterElement->appendChild($this->createNodeWithTextContent('code', $costCenter->getCode())); + } - $costCenterElement->appendChild($this->createNodeWithTextContent('code', $costCenter->getCode())); $costCenterElement->appendChild($this->createNodeWithTextContent('name', $costCenter->getName())); $costCenterElement->appendChild($this->createNodeWithTextContent('office', $costCenter->getOfficeToString())); $costCenterElement->appendChild($this->createNodeWithTextContent('type', $costCenter->getTypeToString())); diff --git a/src/DomDocuments/CustomersDocument.php b/src/DomDocuments/CustomersDocument.php index 2820abc4..086f67d6 100644 --- a/src/DomDocuments/CustomersDocument.php +++ b/src/DomDocuments/CustomersDocument.php @@ -44,7 +44,11 @@ public function addCustomer(Customer $customer) $customerElement->appendChild($this->createNodeWithTextContent('beginperiod', $customer->getBeginPeriod())); $customerElement->appendChild($this->createNodeWithTextContent('beginyear', $customer->getBeginYear())); - $customerElement->appendChild($this->createNodeWithTextContent('code', $customer->getCode())); + + if (!empty($customer->getCode())) { + $customerElement->appendChild($this->createNodeWithTextContent('code', $customer->getCode())); + } + $customerElement->appendChild($this->createNodeWithTextContent('endperiod', $customer->getEndPeriod())); $customerElement->appendChild($this->createNodeWithTextContent('endyear', $customer->getEndYear())); $customerElement->appendChild($this->createNodeWithTextContent('name', $customer->getName())); @@ -70,13 +74,15 @@ public function addCustomer(Customer $customer) $collectMandate = $financials->getCollectMandate(); - // Make collectmandate element - $collectMandateElement = $this->createElement('collectmandate'); - $financialsElement->appendChild($collectMandateElement); + if (!empty($collectMandate->getID())) { + // Make collectmandate element + $collectMandateElement = $this->createElement('collectmandate'); + $financialsElement->appendChild($collectMandateElement); - $collectMandateElement->appendChild($this->createNodeWithTextContent('firstrundate', $collectMandate->getFirstRunDateToString())); - $collectMandateElement->appendChild($this->createNodeWithTextContent('id', $collectMandate->getID())); - $collectMandateElement->appendChild($this->createNodeWithTextContent('signaturedate', $collectMandate->getSignatureDateToString())); + $collectMandateElement->appendChild($this->createNodeWithTextContent('firstrundate', $collectMandate->getFirstRunDateToString())); + $collectMandateElement->appendChild($this->createNodeWithTextContent('id', $collectMandate->getID())); + $collectMandateElement->appendChild($this->createNodeWithTextContent('signaturedate', $collectMandate->getSignatureDateToString())); + } $childValidations = $financials->getChildValidations(); diff --git a/src/DomDocuments/FixedAssetsDocument.php b/src/DomDocuments/FixedAssetsDocument.php index c0bb4449..8d88be51 100644 --- a/src/DomDocuments/FixedAssetsDocument.php +++ b/src/DomDocuments/FixedAssetsDocument.php @@ -42,7 +42,10 @@ public function addFixedAsset(FixedAsset $fixedAsset) $fixedAssetElement->setAttribute('status', $status); } - $fixedAssetElement->appendChild($this->createNodeWithTextContent('code', $fixedAsset->getCode())); + if (!empty($fixedAsset->getCode())) { + $fixedAssetElement->appendChild($this->createNodeWithTextContent('code', $fixedAsset->getCode())); + } + $fixedAssetElement->appendChild($this->createNodeWithTextContent('name', $fixedAsset->getName())); $fixedAssetElement->appendChild($this->createNodeWithTextContent('office', $fixedAsset->getOfficeToString())); $fixedAssetElement->appendChild($this->createNodeWithTextContent('type', $fixedAsset->getTypeToString())); diff --git a/src/DomDocuments/GeneralLedgersDocument.php b/src/DomDocuments/GeneralLedgersDocument.php index 3f3b1205..db9bb8fd 100644 --- a/src/DomDocuments/GeneralLedgersDocument.php +++ b/src/DomDocuments/GeneralLedgersDocument.php @@ -44,7 +44,11 @@ public function addGeneralLedger(GeneralLedger $generalLedger) $generalLedgerElement->appendChild($this->createNodeWithTextContent('beginperiod', $generalLedger->getBeginPeriod())); $generalLedgerElement->appendChild($this->createNodeWithTextContent('beginyear', $generalLedger->getBeginYear())); - $generalLedgerElement->appendChild($this->createNodeWithTextContent('code', $generalLedger->getCode())); + + if (!empty($generalLedger->getCode())) { + $generalLedgerElement->appendChild($this->createNodeWithTextContent('code', $generalLedger->getCode())); + } + $generalLedgerElement->appendChild($this->createNodeWithTextContent('endperiod', $generalLedger->getEndPeriod())); $generalLedgerElement->appendChild($this->createNodeWithTextContent('endyear', $generalLedger->getEndYear())); $generalLedgerElement->appendChild($this->createNodeWithTextContent('name', $generalLedger->getName())); diff --git a/src/DomDocuments/InvoicesDocument.php b/src/DomDocuments/InvoicesDocument.php index fbe1fd72..c9bbfd2f 100644 --- a/src/DomDocuments/InvoicesDocument.php +++ b/src/DomDocuments/InvoicesDocument.php @@ -66,7 +66,11 @@ public function addInvoice(Invoice $invoice, $connection) $headerElement->appendChild($this->createNodeWithTextContent('headertext', $invoice->getHeaderText())); $headerElement->appendChild($this->createNodeWithTextContent('invoiceaddressnumber', $invoice->getInvoiceAddressNumber())); $headerElement->appendChild($this->createNodeWithTextContent('invoicedate', $invoice->getInvoiceDateToString())); - $headerElement->appendChild($this->createNodeWithTextContent('invoicenumber', $invoice->getInvoiceNumber())); + + if (!empty($invoice->getInvoiceNumber())) { + $headerElement->appendChild($this->createNodeWithTextContent('invoicenumber', $invoice->getInvoiceNumber())); + } + $headerElement->appendChild($this->createNodeWithTextContent('invoicetype', $invoice->getInvoiceTypeToString())); $headerElement->appendChild($this->createNodeWithTextContent('office', $invoice->getOfficeToString())); $headerElement->appendChild($this->createNodeWithTextContent('paymentmethod', $invoice->getPaymentMethod())); diff --git a/src/DomDocuments/ProjectsDocument.php b/src/DomDocuments/ProjectsDocument.php index a526ecea..8405ef7d 100644 --- a/src/DomDocuments/ProjectsDocument.php +++ b/src/DomDocuments/ProjectsDocument.php @@ -41,8 +41,11 @@ public function addProject(Project $project) if (!empty($status)) { $projectElement->setAttribute('status', $status); } - - $projectElement->appendChild($this->createNodeWithTextContent('code', $project->getCode())); + + if (!empty($project->getCode())) { + $projectElement->appendChild($this->createNodeWithTextContent('code', $project->getCode())); + } + $projectElement->appendChild($this->createNodeWithTextContent('name', $project->getName())); $projectElement->appendChild($this->createNodeWithTextContent('office', $project->getOfficeToString())); $projectElement->appendChild($this->createNodeWithTextContent('shortname', $project->getShortName())); diff --git a/src/DomDocuments/SuppliersDocument.php b/src/DomDocuments/SuppliersDocument.php index 04804b5c..49a80e4b 100644 --- a/src/DomDocuments/SuppliersDocument.php +++ b/src/DomDocuments/SuppliersDocument.php @@ -44,7 +44,11 @@ public function addSupplier(Supplier $supplier) $supplierElement->appendChild($this->createNodeWithTextContent('beginperiod', $supplier->getBeginPeriod())); $supplierElement->appendChild($this->createNodeWithTextContent('beginyear', $supplier->getBeginYear())); - $supplierElement->appendChild($this->createNodeWithTextContent('code', $supplier->getCode())); + + if (!empty($supplier->getCode())) { + $supplierElement->appendChild($this->createNodeWithTextContent('code', $supplier->getCode())); + } + $supplierElement->appendChild($this->createNodeWithTextContent('endperiod', $supplier->getEndPeriod())); $supplierElement->appendChild($this->createNodeWithTextContent('endyear', $supplier->getEndYear())); $supplierElement->appendChild($this->createNodeWithTextContent('name', $supplier->getName())); diff --git a/src/Secure/WebservicesAuthentication.php b/src/Secure/WebservicesAuthentication.php index 40343880..eca9085c 100644 --- a/src/Secure/WebservicesAuthentication.php +++ b/src/Secure/WebservicesAuthentication.php @@ -10,7 +10,7 @@ class WebservicesAuthentication extends AuthenticatedConnection /** * @var string */ - private $userName; + private $username; /** * @var string */ @@ -37,15 +37,15 @@ class WebservicesAuthentication extends AuthenticatedConnection */ private $cluster = 'https://c3.twinfield.com'; - public function __construct(string $userName, string $password, string $organization) + public function __construct(string $username, string $password, string $organization) { - $this->userName = $userName; + $this->username = $username; $this->password = $password; $this->organization = $organization; } /** - * Login using userName / password / organization combo. + * Login using username / password / organization combo. * * @throws Exception */ @@ -60,16 +60,16 @@ protected function login(): void private const LOGIN_OK = "Ok"; /** - * @param string $userName + * @param string $username * @param string $password * @param string $organization * @return string[] * @throws Exception */ - public function getSessionIdAndCluster(string $userName, string $password, string $organization): array + public function getSessionIdAndCluster(string $username, string $password, string $organization): array { $response = $this->Logon([ - "user" => $userName, + "user" => $username, "password" => $password, "organisation" => $organization, ]); @@ -105,7 +105,7 @@ final protected function WSDL(): string } }; - [$this->sessionID, $this->cluster] = $loginService->getSessionIdAndCluster($this->userName, $this->password, $this->organization); + [$this->sessionID, $this->cluster] = $loginService->getSessionIdAndCluster($this->username, $this->password, $this->organization); } protected function getSoapHeaders() From 68c4a3b0e385a7186d045ef2a56ac6c12d04fed8 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 7 Jun 2019 09:48:27 +0200 Subject: [PATCH 275/388] Upload --- tests/IntegrationTests/resources/customerSendRequest.xml | 1 - tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php | 5 ----- 2 files changed, 6 deletions(-) diff --git a/tests/IntegrationTests/resources/customerSendRequest.xml b/tests/IntegrationTests/resources/customerSendRequest.xml index 46f74023..67aeb7bb 100644 --- a/tests/IntegrationTests/resources/customerSendRequest.xml +++ b/tests/IntegrationTests/resources/customerSendRequest.xml @@ -2,7 +2,6 @@ 0 0 - 0 0 Customer 0 diff --git a/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php index 01e38938..b2aa5eed 100644 --- a/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php @@ -214,11 +214,6 @@ public function testXmlIsCreatedPerSpec() - - - - - 0 From faf07f39e711fe83e8622d27f17c2eb9b9056a52 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 7 Jun 2019 09:52:43 +0200 Subject: [PATCH 276/388] Update CustomerDocumentUnitTest.php --- tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php index b2aa5eed..8c31c890 100644 --- a/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php @@ -127,11 +127,6 @@ public function testXmlIsCreatedPerSpec() pay-code vat-code - - - - - 50 From c0a7d5d1633a43cb5912aba7fa8dd895c069913b Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 9 Jun 2019 13:12:53 +0200 Subject: [PATCH 277/388] Upload --- examples/Activity.php | 27 +- examples/Article.php | 12 +- examples/CostCenter.php | 11 +- examples/Currency.php | 4 +- examples/Customer.php | 682 +++++++++++++++++++++++++++ examples/DimensionGroup.php | 5 +- examples/Invoice.php | 24 +- examples/Office.php | 4 +- examples/Project.php | 27 +- examples/Rate.php | 14 +- examples/Supplier.php | 580 +++++++++++++++++++++++ examples/VatCode.php | 4 +- src/Article.php | 8 +- src/AssetMethod.php | 8 +- src/Customer.php | 24 +- src/CustomerPostingRule.php | 5 + src/Fields/Invoice/QuantityField.php | 10 +- src/Invoice.php | 8 +- src/Rate.php | 8 +- src/Supplier.php | 24 +- src/VatCodePercentage.php | 8 +- 21 files changed, 1377 insertions(+), 120 deletions(-) create mode 100644 examples/Customer.php create mode 100644 examples/Supplier.php diff --git a/examples/Activity.php b/examples/Activity.php index 3fc6453e..9ec44626 100644 --- a/examples/Activity.php +++ b/examples/Activity.php @@ -158,7 +158,7 @@ echo "ShortName: {$activity->getShortName()}
"; // string|null Short activity description. echo "Status: {$activity->getStatus()}
"; // Status|null Status of the activity. echo "Touched: {$activity->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. - echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($activity->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is ACT. + echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($activity->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of activities is ACT. echo "Type (string): {$activity->getTypeToString()}
"; // string|null echo "UID: {$activity->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($activity->getVatCode(), true) . "

"; // VatCode|null The VAT code if one code will apply for all activities within the project. Note that if any VAT codes are @@ -199,9 +199,9 @@ echo "Rate Locked (bool): {$activityProjects->getRateLocked()}
"; // bool|null If "change" = disallow then locked = true and inherit = false echo "Rate Locked (string): {$activityProjects->getRateLockedToString()}
"; // string|null If "change" = inherit then locked = true and inherit = true echo "Result: {$activityProjects->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "Valid From (\\DateTimeInterface):
" . print_r($activityProjects->getValidFrom(), true) . "

"; // \DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. + echo "Valid From (\\DateTimeInterface):
" . print_r($activityProjects->getValidFrom(), true) . "

"; // DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. echo "Valid From (string): {$activityProjects->getValidFromToString()}
"; // string|null - echo "Valid Till (\\DateTimeInterface):
" . print_r($activityProjects->getValidTill(), true) . "

"; // \DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. + echo "Valid Till (\\DateTimeInterface):
" . print_r($activityProjects->getValidTill(), true) . "

"; // DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. echo "Valid Till (string): {$activityProjects->getValidTillToString()}
"; // string|null $activityQuantities = $activityProjects->getQuantities(); // array|null Array of ActivityQuantity objects. @@ -235,7 +235,8 @@ $activity = $e->getReturnedObject(); } - $activity->setCode("A100"); + $activity->setCode(null); // string|null Set to null to let Twinfield assign a Dimension code based on the Dimension type mask + //$activity->setCode('A100'); // string|null Dimension code, must be compliant with the mask of the ACT Dimension type. try { $activityCopy = $activityApiConnector->send($activity); @@ -256,21 +257,18 @@ $activity = new \PhpTwinfield\Activity; // Required values for creating a new Activity - $activity->setCode('A100'); // string|null Dimension code, must be compliant with the mask of the ACT Dimension type. + $activity->setCode(null); // string|null Set to null to let Twinfield assign a Dimension code based on the Dimension type mask + //$activity->setCode('A100'); // string|null Dimension code, must be compliant with the mask of the ACT Dimension type. $activity->setName("Example Activity"); // string|null Activity description. $activity->setOffice($office); // Office|null Office code. $activity->setOfficeFromString($officeCode); // string|null + + // Optional values for creating a new Activity + $activity->setShortName("ExmplAct"); // string|null Short activity description. //$activity->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. //$activity->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case an activity is in use, its status has been changed into hide. Hidden activities can be activated by using active. //$activity->setStatusFromString('active'); // string|null //$activity->setStatusFromString('deleted'); // string|null - $dimensionType = new \PhpTwinfield\DimensionType; - $dimensionType->setCode('ACT'); - $activity->setType($dimensionType); // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is ACT. - $activity->setTypeFromString('ACT'); // string|null - - // Optional values for creating a new Activity - $activity->setShortName("ExmplAct"); // string|null Short activity description. $vatCode = new \PhpTwinfield\VatCode; $vatCode->setCode('VH'); $activity->setVatCode($vatCode); // VatCode|null The VAT code if one code will apply for all activities within the project. Note that if any VAT codes are @@ -312,15 +310,14 @@ $activityProjects->setRateLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false $activityProjects->setRateLockedFromString('true'); // string|null If "change" = inherit then locked = true and inherit = true $validFrom = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); - $activityProjects->setValidFrom($validFrom); // \DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. + $activityProjects->setValidFrom($validFrom); // DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. $activityProjects->setValidFromFromString('20190101'); // string|null $validTill = \DateTime::createFromFormat('d-m-Y', '31-12-2019'); - $activityProjects->setValidTill($validTill); // \DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. + $activityProjects->setValidTill($validTill); // DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. $activityProjects->setValidTillFromString('20191231'); // string|null // The minimum amount of ActivityQuantities linked to a ActivityProjects object is 0, the maximum amount is 4 $activityQuantity = new \PhpTwinfield\ActivityQuantity; - $activityQuantity->setBillable(false); // bool|null Is the quantity line billable or not. $activityQuantity->setBillableFromString('false'); // string|null If "billable" = true and "change is not allowed" then locked = true $activityQuantity->setBillableLocked(false); // bool|null diff --git a/examples/Article.php b/examples/Article.php index da4679fb..ff619a00 100644 --- a/examples/Article.php +++ b/examples/Article.php @@ -220,10 +220,6 @@ $article->setName("Example Article"); // string|null Article description. $article->setOffice($office); // Office|null Office code. $article->setOfficeFromString($officeCode); // string|null - //$article->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. - //$article->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case an article is in use, its status has been changed into hide. Hidden articles can be activated by using active. - //$article->setStatusFromString('active'); // string|null - //$article->setStatusFromString('deleted'); // string|null $article->setUnitNamePlural("Example Art Units"); // string|null Unit name for multiple items $article->setUnitNameSingular("Example Art Unit"); // string|null Unit name for a single item @@ -243,6 +239,10 @@ $article->setPerformanceType(\PhpTwinfield\Enums\PerformanceType::SERVICES()); // PerformanceType|null The performance type. $article->setPerformanceTypeFromString('services'); // string|null $article->setShortName("ExmplArt"); // string|null Short article description. + //$article->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. + //$article->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case an article is in use, its status has been changed into hide. Hidden articles can be activated by using active. + //$article->setStatusFromString('active'); // string|null + //$article->setStatusFromString('deleted'); // string|null $article->setType(\PhpTwinfield\Enums\ArticleType::NORMAL()); // ArticleType|null Set to normal in case special item is none. Set to either discount or premium in case special item is deduction or premium respectively. $article->setTypeFromString('normal'); // string|null $vatCode = new \PhpTwinfield\VatCode; @@ -259,7 +259,7 @@ $articleLine->setFreeText1FromString('9060'); // string|null $freeText2 = new \PhpTwinfield\CostCenter; $freeText2->setCode('00000'); - //$articleLine->setFreeText2($freeText1); // CostCenter|null Mandatory. The general ledger code linked to the article. + //$articleLine->setFreeText2($freeText1); // CostCenter|null Optional. The cost center linked to the article. //$articleLine->setFreeText2FromString('00000'); // string|null //$articleLine->setFreetext3(""); // string|null Free text element 3 $articleLine->setID(1); // int|null Line ID. @@ -278,7 +278,7 @@ //$articleLine->setUnitsPriceIncFromFloat(12.10); // float|null $article->addLine($articleLine); // ArticleLine Add an ArticleLine object to the Article object - //$article->removeLine(1); // int Remove an article line based on the id of the article line + //$article->removeLine(0); // int Remove an article line based on the index of the article line try { $articleNew = $articleApiConnector->send($article); diff --git a/examples/CostCenter.php b/examples/CostCenter.php index 14f45fb5..bb187a55 100644 --- a/examples/CostCenter.php +++ b/examples/CostCenter.php @@ -150,7 +150,8 @@ $costCenter = $e->getReturnedObject(); } - $costCenter->setCode("00010"); // string|null Dimension code, must be compliant with the mask of the KPL Dimension type. + $costCenter->setCode(null); // string|null Set to null to let Twinfield assign a Dimension code based on the Dimension type mask + //$costCenter->setCode("00010"); // string|null Dimension code, must be compliant with the mask of the KPL Dimension type. try { $costCenterCopy = $costCenterApiConnector->send($costCenter); @@ -172,7 +173,8 @@ // Required values for creating a new CostCenter $costCenter->setName("CostCenterName"); // string|null Name of the dimension. - $costCenter->setCode('00020'); // string|null Dimension code, must be compliant with the mask of the KPL Dimension type. + $costCenter->setCode(null); // string|null Set to null to let Twinfield assign a Dimension code based on the Dimension type mask + //$costCenter->setCode('00020'); // string|null Dimension code, must be compliant with the mask of the KPL Dimension type. $costCenter->setOffice($office); // Office|null Office. $costCenter->setOfficeFromString($officeCode); // string|null @@ -183,11 +185,6 @@ $costCenter->setStatusFromString('active'); // string|null //$costCenter->setStatusFromString('deleted'); // string|null - $dimensionType = new \PhpTwinfield\DimensionType; - $dimensionType->setCode('KPL'); - $costCenter->setType($dimensionType); // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is KPL. - $costCenter->setTypeFromString('KPL'); // string|null - try { $costCenterNew = $costCenterApiConnector->send($costCenter); } catch (ResponseException $e) { diff --git a/examples/Currency.php b/examples/Currency.php index f714e86f..66a9d581 100644 --- a/examples/Currency.php +++ b/examples/Currency.php @@ -137,7 +137,7 @@ echo "Rate: {$currencyRate->getRate()}
"; // float|null Conversion rate to be used as of the start date. echo "Result: {$currencyRate->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "StartDate (\\DateTimeInterface):
" . print_r($currencyRate->getStartDate(), true) . "

"; // \DateTimeInterface|null Starting date of the rate. + echo "StartDate (\\DateTimeInterface):
" . print_r($currencyRate->getStartDate(), true) . "

"; // DateTimeInterface|null Starting date of the rate. echo "StartDate (string): {$currencyRate->getStartDateToString()}
"; // string|null echo "Status: {$currencyRate->getStatus()}
"; // Status|null Status of the currency rate. } @@ -190,7 +190,7 @@ $currencyRate = new \PhpTwinfield\CurrencyRate; $currencyRate->setRate(122.87); // float|null Conversion rate to be used as of the start date. $startDate = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); - $currencyRate->setStartDate($startDate); // \DateTimeInterface|null Starting date of the rate. + $currencyRate->setStartDate($startDate); // DateTimeInterface|null Starting date of the rate. $currencyRate->setStartDateFromString('20190101'); // string|null //$currencyRate->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null For creating and updating status may be left empty. NOTE: Do not use $currencyRate->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // For deleting deleted should be used. diff --git a/examples/Customer.php b/examples/Customer.php new file mode 100644 index 00000000..ea60155c --- /dev/null +++ b/examples/Customer.php @@ -0,0 +1,682 @@ + matchtype = 'relation' +if ($executeListAllWithFilter) { + $options = array('matchtype' => 'relation'); + + try { + $customers = $customerApiConnector->listAll("2*", 0, 1, 10, $options); + } catch (ResponseException $e) { + $customers = $e->getReturnedObject(); + } + + echo "
";
+    print_r($customers);
+    echo "
"; +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +if ($executeListAllWithoutFilter) { + try { + $customers = $customerApiConnector->listAll(); + } catch (ResponseException $e) { + $customers = $e->getReturnedObject(); + } + + echo "
";
+    print_r($customers);
+    echo "
"; +} + +/* Customer + * \PhpTwinfield\Customer + * Available getters: getBeginPeriod, getBeginYear, getBehaviour, getCode, getDiscountArticle, getDiscountArticleID, getDiscountArticleToString, getEndPeriod, getEndYear, getGroup, getGroupToString, getInUse, getInUseToString, getMessages, getName, getOffice, getOfficeToString, + * getPaymentConditionDiscountDays, getPaymentConditionDiscountPercentage, getRemittanceAdviceSendMail, getRemittanceAdviceSendType, getResult, getShortName, getStatus, getTouched, getType, getTypeToString, getUID, getWebsite, hasMessages, getAddresses, getBanks, getCreditManagement, getFinancials, getPostingRules + * + * Available setters: setBeginPeriod, setBeginYear, setBehaviour, setBehaviourFromString, setCode, setDiscountArticle, setDiscountArticleFromString, setDiscountArticleID, setEndPeriod, setEndYear, setGroup, setGroupFromString, setName, setOffice, setOfficeFromString, setPaymentConditionDiscountDays, + * setPaymentConditionDiscountPercentage, setRemittanceAdviceSendMail, setRemittanceAdviceSendType, setRemittanceAdviceSendTypeFromString, setShortName, setStatus, setStatusFromString, setType, setTypeFromString, setWebsite, setCreditManagement, setFinancials, addAddress, addBank, addPostingRule, removeAddress, removeBank, removePostingRule + * + */ + +/* CustomerFinancials + * \PhpTwinfield\CustomerFinancials + * Available getters: getAccountType, getCollectionSchema, getDueDays, getEBillMail, getEBilling, getEBillingToString, getLevel, getMatchType, getMeansOfPayment, getMessages, getPayAvailable, getPayAvailableToString, getPayCode, getPayCodeID, getPayCodeToString, + * getResult, getSubAnalyse, getSubstituteWith, getSubstituteWithID, getSubstituteWithToString, getSubstitutionLevel, getVatCode, getVatCodeFixed, getVatCodeFixedToString, getVatCodeToString, getChildValidations, getCollectMandate, hasMessages + * + * Available setters: setAccountType, setAccountTypeFromString, setCollectionSchema, setCollectionSchemaFromString, setDueDays, setEBillMail, setEBilling, setEBillingFromString, setLevel, setMatchType, setMatchTypeFromString, setMeansOfPayment, setMeansOfPaymentFromString, + * setPayAvailable, setPayAvailableFromString, setPayCode, setPayCodeFromString, setPayCodeID, setSubAnalyse, setSubAnalyseFromString, setSubstituteWith, setSubstituteWithFromString, setSubstituteWithID, setSubstitutionLevel, setVatCode, setVatCodeFixed, setVatCodeFixedFromString, setVatCodeFromString, setCollectMandate, addChildValidation, removeChildValidation + * + */ + +/* CustomerCollectMandate + * \PhpTwinfield\CustomerCollectMandate + * Available getters: getFirstRunDate, getFirstRunDateToString, getID, getMessages, getResult, getSignatureDate, getSignatureDateToString, hasMessages + * Available setters: setFirstRunDate, setFirstRunDateFromString, setID, setSignatureDate, setSignatureDateFromString + */ + +/* CustomerChildValidation + * \PhpTwinfield\CustomerChildValidation + * Available getters: getElementValue, getLevel, getMessages, getResult, getType, hasMessages + * Available setters: setElementValue, setLevel, setType, setTypeFromString + */ + +/* CustomerCreditManagement + * \PhpTwinfield\CustomerCreditManagement + * Available getters: getBaseCreditLimit, getBaseCreditLimitToFloat, getBlocked, getBlockedLocked, getBlockedLockedToString, getBlockedModified, getBlockedModifiedToString, getBlockedToString, getComment, getFreeText1, getFreeText1ToString, getFreetext2, getFreetext3, getMessages, getReminderEmail, getResponsibleUser, getResponsibleUserToString, getResult, getSendReminder, hasMessages + * Available setters: setBaseCreditLimit, setBaseCreditLimitFromFloat, setBlocked, setBlockedFromString, setBlockedLocked, setBlockedLockedFromString, setBlockedModified, setBlockedModifiedFromString, setComment, setFreeText1, setFreeText1FromString, setFreetext2, setFreetext3, setReminderEmail, setResponsibleUser, setResponsibleUserFromString, setSendReminder, setSendReminderFromString + */ + +/* CustomerAddress + * \PhpTwinfield\CustomerAddress + * Available getters: getCity, getCountry, getCountryToString, getDefault, getDefaultToString, getEmail, getField1, getField2, getField3, getField4, getField5, getField6, getID, getMessages, getName, getPostcode, getResult, getTelefax, getTelephone, getType, hasMessages + * Available setters: setCity, setCountry, setCountryFromString, setDefault, setDefaultFromString, setEmail, setField1, setField2, setField3, setField4, setField5, setField6, setID, setName, setPostcode, setTelefax, setTelephone, setType, setTypeFromString + */ + +/* CustomerBank + * \PhpTwinfield\CustomerBank + * Available getters: getAccountNumber, getAddressField2, getAddressField3, getAscription, getBankName, getBicCode, getBlocked, getBlockedToString, getCity, getCountry, getCountryToString, getDefault, getDefaultToString, getID, getIban, getMessages, getNatBicCode, getPostcode, getResult, getState, hasMessages + * Available setters: setAccountNumber, setAddressField2, setAddressField3, setAscription, setBankName, setBicCode, setBlocked, setBlockedFromString, setCity, setCountry, setCountryFromString, setDefault, setDefaultFromString, setID, setIban, setNatBicCode, setPostcode, setState + */ + +/* CustomerPostingRule + * \PhpTwinfield\CustomerPostingRule + * Available getters: getAmount, getAmountToFloat, getCurrency, getCurrencyToString, getDescription, getID, getMessages, getResult, getStatus, getLines, hasMessages + * Available setters: setAmount, setAmountFromFloat, setCurrency, setCurrencyFromString, setDescription, setID, setStatus, setStatusFromString, addLine, removeLine + */ + +/* CustomerLine + * \PhpTwinfield\CustomerLine + * Available getters: getDescription, getDimension1, getDimension1ID, getDimension1ToString, getDimension2, getDimension2ID, getDimension2ToString, getDimension3, getDimension3ID, getDimension3ToString, getMessages, getOffice, getOfficeToString, getRatio, getResult, getVatCode, getVatCodeToString, hasMessages + * Available setters: setDescription, setDimension1, setDimension1FromString, setDimension1ID, setDimension2, setDimension2FromString, setDimension2ID, setDimension3, setDimension3FromString, setDimension3ID, setOffice, setOfficeFromString, setRatio, setVatCode, setVatCodeFromString + */ + +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($customers as $key => $customer) { + echo "Customer {$key}
"; + echo "Code: {$customer->getCode()}
"; + echo "Name: {$customer->getName()}

"; + } +} + +// Read an Customer based off the passed in code and optionally the office. +if ($executeRead) { + try { + $customer = $customerApiConnector->get("1000", $office); + } catch (ResponseException $e) { + $customer = $e->getReturnedObject(); + } + + echo "
";
+    print_r($customer);
+    echo "
"; + + echo "Customer
"; + echo "BeginPeriod: {$customer->getBeginPeriod()}
"; // int|null Determines together with beginyear the period from which the dimension may be used. + echo "BeginYear: {$customer->getBeginYear()}
"; // int|null Determines together with beginperiod the period from which the dimension may be used. + echo "Behaviour: {$customer->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. + echo "Code: {$customer->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the DEB Dimension type. + echo "DiscountArticle (\\PhpTwinfield\\Article):
" . print_r($customer->getDiscountArticle(), true) . "

"; // Article|null The discount or premium article. + echo "DiscountArticle (string): {$customer->getDiscountArticleToString()}
"; // string|null + echo "DiscountArticleID: {$customer->getDiscountArticleID()}
"; // string|null + echo "EndPeriod: {$customer->getEndPeriod()}
"; // int|null Determines together with endyear the period till which the dimension may be used. + echo "EndYear: {$customer->getEndYear()}
"; // int|null Determines together with endperiod the period till which the dimension may be used. + echo "Group (\\PhpTwinfield\\DimensionGroup):
" . print_r($customer->getGroup(), true) . "

"; // DimensionGroup|null Sets the dimension group. See Dimension group. + echo "Group (string): {$customer->getGroupToString()}
"; // string|null + echo "InUse (bool): {$customer->getInUse()}
"; // bool|null Indicates whether the balancesheet is used in a financial transaction or not. Read-only attribute. + echo "InUse (string): {$customer->getInUseToString()}
"; // string|null + + if ($customer->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($customer->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Name: {$customer->getName()}
"; // string|null Name of the dimension. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($customer->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): {$customer->getOfficeToString()}
"; // string|null + echo "PaymentCondition:
"; // Sets the payment condition of a dimension. + echo "PaymentCondition DiscountDays: {$customer->getPaymentConditionDiscountDays()}
"; // int|null Number of discount days. + echo "PaymentCondition DiscountPercentage: {$customer->getPaymentConditionDiscountPercentage()}
"; // float|null Discount percentage. + echo "RemittanceAdvice:
"; // + echo "RemittanceAdvice SendMail: {$customer->getRemittanceAdviceSendMail()}
"; // string|null Mandatory if sendtype = ByEmail, remittance advice will be sent using this e-mail address. + echo "RemittanceAdvice SendType: {$customer->getRemittanceAdviceSendType()}
"; // RemittanceAdviceSendType|null To file manager, By e-mail + echo "Result: {$customer->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$customer->getShortName()}
"; // string|null Short name of the dimension. + echo "Status: {$customer->getStatus()}
"; // Status|null Status of the customer. + echo "Touched: {$customer->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. + echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($customer->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of customers is DEB. + echo "Type (string): {$customer->getTypeToString()}
"; // string|null + echo "UID: {$customer->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. + echo "Website: {$customer->getWebsite()}
"; // string|null Website of the dimension. + + $customerAddresses = $customer->getAddresses(); // array|null Array of CustomerAddress objects. + + foreach ($customerAddresses as $key => $customerAddress) { + echo "CustomerAddress {$key}
"; + + echo "City: {$customerAddress->getCity()}
"; // string|null City. + echo "Country (\\PhpTwinfield\\Country):
" . print_r($customerAddress->getCountry(), true) . "

"; // Country|null Country code. The ISO country codes are used. + echo "Country (string): {$customerAddress->getCountryToString()}
"; // string|null + echo "Default (bool): {$customerAddress->getDefault()}
"; // bool|null Is this the default address, only one default address is possible. + echo "Default (string): {$customerAddress->getDefaultToString()}
"; // string|null + echo "Email: {$customerAddress->getEmail()}
"; // string|null + echo "Field1: {$customerAddress->getField1()}
"; // string|null User defined fields, the labels are configured in the Dimension type. + echo "Field2: {$customerAddress->getField2()}
"; // string|null User defined fields, the labels are configured in the Dimension type. + echo "Field3: {$customerAddress->getField3()}
"; // string|null User defined fields, the labels are configured in the Dimension type. + echo "Field4: {$customerAddress->getField4()}
"; // string|null User defined fields, the labels are configured in the Dimension type. Currently, field4 is reserved for VAT numbers. So only valid VAT numbers may be filled in. + echo "Field5: {$customerAddress->getField5()}
"; // string|null User defined fields, the labels are configured in the Dimension type. + echo "Field6: {$customerAddress->getField6()}
"; // string|null User defined fields, the labels are configured in the Dimension type. + echo "ID: {$customerAddress->getID()}
"; // int|null Sequence number of the address line. + + if ($customerAddress->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($customerAddress->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Name: {$customerAddress->getName()}
"; // string|null Company name. + echo "Postcode: {$customerAddress->getPostcode()}
"; // string|null Postcode. + echo "Result: {$customerAddress->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Telefax: {$customerAddress->getTelefax()}
"; // string|null Fax number. + echo "Telephone: {$customerAddress->getTelephone()}
"; // string|null Telephone number. + echo "Type: {$customerAddress->getType()}
"; // AddressType|null The type of the address. + } + + $customerBanks = $customer->getBanks(); + + foreach ($customerBanks as $key => $customerBank) { + echo "CustomerBank {$key}
"; + + echo "AccountNumber: {$customerBank->getAccountNumber()}
"; // string|null Account number. + echo "AddressField2: {$customerBank->getAddressField2()}
"; // string|null Bank address. + echo "AddressField3: {$customerBank->getAddressField3()}
"; // string|null Bank address number. + echo "Ascription: {$customerBank->getAscription()}
"; // string|null Account holder. + echo "BankName: {$customerBank->getBankName()}
"; // string|null Bank name. + echo "BicCode: {$customerBank->getBicCode()}
"; // string|null BIC code. + + echo "Blocked (bool): {$customerBank->getBlocked()}
"; // bool|null + echo "Blocked (string): {$customerBank->getBlockedToString()}
"; // string|null + echo "City: {$customerBank->getCity()}
"; // string|null City. + echo "Country (\\PhpTwinfield\\Country):
" . print_r($customerBank->getCountry(), true) . "

"; // Country|null Bank country code. The ISO country codes are used. + echo "Country (string): {$customerBank->getCountryToString()}
"; // string|null + echo "Default (bool): {$customerBank->getDefault()}
"; // bool|null Is this the default bank account, only one default bank account is possible. + echo "Default (string): {$customerBank->getDefaultToString()}
"; // string|null + echo "ID: {$customerBank->getID()}
"; // int|null Sequence number of the bank account line. When adding a new bank, do not supply the @id. When changing a bank account, supply the corresponding @id. + echo "IBAN: {$customerBank->getIban()}
"; // string|null IBAN account number. + + if ($customerBank->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($customerBank->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "NatBicCode: {$customerBank->getNatBicCode()}
"; // string|null National bank code. + echo "Postcode: {$customerBank->getPostcode()}
"; // string|null Postcode. + echo "Result: {$customerBank->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "State: {$customerBank->getState()}
"; // string|null State. + } + + $customerCreditManagement = $customer->getCreditManagement(); // CustomerCreditManagement|null CustomerCreditManagement object. + + echo "CustomerCreditManagement
"; + echo "BaseCreditLimit (\\Money\\Money):
" . print_r($customerCreditManagement->getBaseCreditLimit(), true) . "

"; // Money|null The credit limit amount. + echo "BaseCreditLimit (float): {$customerCreditManagement->getBaseCreditLimitToFloat()}
"; // float|null + echo "Blocked (bool): {$customerCreditManagement->getBlocked()}
"; // bool|null Indicates if related projects for this customer are blocked in time & expenses. + echo "Blocked (string): {$customerCreditManagement->getBlockedToString()}
"; // string|null + echo "Blocked Locked (bool): {$customerCreditManagement->getBlockedLocked()}
"; // bool|null + echo "Blocked Locked (string): {$customerCreditManagement->getBlockedLockedToString()}
"; // string|null + echo "Blocked Modified (\\DateTimeInterface):
" . print_r($customerCreditManagement->getBlockedModified(), true) . "

"; // \DateTimeInterface|null + echo "Blocked Modified (string): {$customerCreditManagement->getBlockedModifiedToString()}
"; // string|null + echo "Comment: {$customerCreditManagement->getComment()}
"; // string|null Comment. + echo "Freetext1 (bool): {$customerCreditManagement->getFreeText1()}
"; // bool|null Right of use. + echo "Freetext1 (string): {$customerCreditManagement->getFreeText1ToString()}
"; // string|null + echo "Freetext2: {$customerCreditManagement->getFreetext2()}
"; // string|null Segment code. + echo "Freetext3: {$customerCreditManagement->getFreetext3()}
"; // string|null Not in use. + + if ($customerCreditManagement->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($customerCreditManagement->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "ReminderEmail: {$customerCreditManagement->getReminderEmail()}
"; // string|null Mandatory if sendreminder is email. + echo "ResponsibleUser (\\PhpTwinfield\\User):
" . print_r($customerCreditManagement->getResponsibleUser(), true) . "

"; // User|null The credit manager. + echo "ResponsibleUser (string): {$customerCreditManagement->getResponsibleUserToString()}
"; // string|null + echo "Result: {$customerCreditManagement->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "SendReminder: {$customerCreditManagement->getSendReminder()}
"; // SendReminder|null Determines if and how a customer will be reminded. + + echo "CustomerFinancials
"; + $customerFinancials = $customer->getFinancials(); // CustomerFinancials|null CustomerFinancials object. + + echo "AccountType: {$customerFinancials->getAccountType()}
"; // AccountType|null Fixed value inherit. + echo "CollectionSchema: {$customerFinancials->getCollectionSchema()}
"; // CollectionSchema|null Collection schema information. Apply this information only when the customer invoices are collected by SEPA direct debit. + echo "DueDays: {$customerFinancials->getDueDays()}
"; // int|null The number of due days. + echo "EBillMail: {$customerFinancials->getEBillMail()}
"; // string|null The mail address the electronic sales invoice is sent to. + echo "EBilling (bool): {$customerFinancials->getEBilling()}
"; // bool|null Determines if the sales invoices will be sent electronically to the customer. + echo "EBilling (string): {$customerFinancials->getEBillingToString()}
"; // string|null + echo "Level: {$customerFinancials->getLevel()}
"; // int|null Specifies the dimension level. Normally the level of customers is level 2. Read-only attribute. + echo "MatchType: {$customerFinancials->getMatchType()}
"; // MatchType|null Fixed value customersupplier. + echo "MeansOfPayment: {$customerFinancials->getMeansOfPayment()}
"; // MeansOfPayment|null The option none is only allowed in case payavailable is set to false. The option paymentfile is only allowed in case payavailable is set to true. + + if ($customerFinancials->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($customerFinancials->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "PayAvailable (bool): {$customerFinancials->getPayAvailable()}
"; // bool|null Determines if direct debit is possible. + echo "PayAvailable (string): {$customerFinancials->getPayAvailableToString()}
"; // string|null + echo "PayCode (\\PhpTwinfield\\PayCode):
" . print_r($customerFinancials->getPayCode(), true) . "

"; // PayCode|null The code of the payment type in case direct debit is possible. + echo "PayCode (string): {$customerFinancials->getPayCodeToString()}
"; // string|null + echo "PayCodeID: {$customerFinancials->getPayCodeID()}
"; // string|null + echo "Result: {$customerFinancials->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "SubAnalyse: {$customerFinancials->getSubAnalyse()}
"; // SubAnalyse|null Fixed value false. + echo "SubstituteWith (\\PhpTwinfield\\Dummy):
" . print_r($customerFinancials->getSubstituteWith(), true) . "

"; // Dummy|null Default customer balancesheet account. + echo "SubstituteWith (string): {$customerFinancials->getSubstituteWithToString()}
"; // string|null + echo "SubstituteWithID: {$customerFinancials->getSubstituteWithID()}
"; // string|null + echo "SubstitutionLevel: {$customerFinancials->getSubstitutionLevel()}
"; // int|null Level of the balancesheet account. Fixed value 1. + echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($customerFinancials->getVatCode(), true) . "

"; // VatCode|null Default VAT code. + echo "VatCode (string): {$customerFinancials->getVatCodeToString()}
"; // string|null + echo "VatCode Fixed (bool): {$customerFinancials->getVatCodeFixed()}
"; // bool|null + echo "VatCode Fixed (string): {$customerFinancials->getVatCodeFixedToString()}
"; // string|null + + $customerChildValidations = $customerFinancials->getChildValidations(); // array|null Array of CustomerChildValidations objects. + + foreach ($customerChildValidations as $key => $customerChildValidation) { + echo "CustomerChildValidation {$key}
"; + + echo "ElementValue: {$customerChildValidation->getElementValue()}
"; // string|null + echo "Level: {$customerChildValidation->getLevel()}
"; // int|null + + if ($customerChildValidation->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($customerChildValidation->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Result: {$customerChildValidation->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Type: {$customerChildValidation->getType()}
"; // ChildValidationType|null + } + + $customerCollectMandate = $customerFinancials->getCollectMandate(); // CollectMandate|null CollectMandate object. + + echo "CustomerCollectMandate
"; + echo "FirstRunDate (\\DateTimeInterface):
" . print_r($customerCollectMandate->getFirstRunDate(), true) . "

"; // \DateTimeInterface|null Date on which the first run was collected. + echo "FirstRunDate (string): {$customerCollectMandate->getFirstRunDateToString()}
"; // string|null + echo "ID: {$customerCollectMandate->getID()}
"; // string|null Mandate id which the debtor can collect with. + + if ($customerCollectMandate->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($customerCollectMandate->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "SignatureDate (\\DateTimeInterface):
" . print_r($customerCollectMandate->getSignatureDate(), true) . "

"; // \DateTimeInterface|null Date on which the mandate is signed. + echo "SignatureDate (string): {$customerCollectMandate->getSignatureDateToString()}
"; // string|null + + $customerPostingRules = $customer->getPostingRules(); // array|null Array of CustomerPostingRule objects. + + foreach ($customerPostingRules as $key => $customerPostingRule) { + echo "CustomerPostingRule {$key}
"; + + echo "Amount (\\Money\\Money):
" . print_r($customerPostingRule->getAmount(), true) . "

"; // Money|null Amount. + echo "Amount (float): {$customerPostingRule->getAmountToFloat()}
"; // float|null + echo "Currency (\\PhpTwinfield\\Currency):
" . print_r($customerPostingRule->getCurrency(), true) . "

"; // Currency|null Currency. + echo "Currency (string): {$customerPostingRule->getCurrencyToString()}
"; // string|null + echo "Description: {$customerPostingRule->getDescription()}
"; // string|null Description. + echo "ID: {$customerPostingRule->getID()}
"; // int|null Sequence number of the posting rule. Fixed value 1. + + if ($customerPostingRule->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($customerPostingRule->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Result: {$customerPostingRule->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Status: {$customerPostingRule->getStatus()}
"; // Status|null Status of the posting rule. + + $customerLines = $customerPostingRule->getLines(); // array|null Array of CustomerLine objects. + + foreach ($customerLines as $key => $customerLine) { + echo "CustomerLine {$key}
"; + + echo "Description: {$customerLine->getDescription()}
"; // string|null Description. + echo "Dimension1 (\\PhpTwinfield\\GeneralLedger):
" . print_r($customerLine->getDimension1(), true) . "

"; // GeneralLedger|null General ledger. + echo "Dimension1 (string): {$customerLine->getDimension1ToString()}
"; // string|null + echo "Dimension1ID: {$customerLine->getDimension1ID()}
"; // string|null + echo "Dimension2 (\\PhpTwinfield\\CostCenter):
" . print_r($customerLine->getDimension2(), true) . "

"; // CostCenter|null Cost center. + echo "Dimension2 (string): {$customerLine->getDimension2ToString()}
"; // string|null + echo "Dimension2ID: {$customerLine->getDimension2ID()}
"; // string|null + echo "Dimension3 (\\PhpTwinfield\\Dummy):
" . print_r($customerLine->getDimension3(), true) . "

"; // Dummy|null Project or asset. + echo "Dimension3 (string): {$customerLine->getDimension3ToString()}
"; // string|null + echo "Dimension3ID: {$customerLine->getDimension3ID()}
"; // string|null + + if ($customerLine->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($customerLine->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Office (\\PhpTwinfield\\Office):
" . print_r($customerLine->getOffice(), true) . "

"; // Office|null Destination company. + echo "Office (string): {$customerLine->getOfficeToString()}
"; // string|null + echo "Ratio: {$customerLine->getRatio()}
"; // float|null The ratio of the posting rule line. + echo "Result: {$customerLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($customerLine->getVatCode(), true) . "

"; // VatCode|null VAT code. + echo "VatCode (string): {$customerLine->getVatCodeToString()}
"; // string|null + } + } +} + +// Copy an existing Customer to a new entity +if ($executeCopy) { + try { + $customer = $customerApiConnector->get("1000", $office); + } catch (ResponseException $e) { + $customer = $e->getReturnedObject(); + } + + $customer->setCode(null); // string|null Set to null to let Twinfield assign a Dimension code based on the Dimension type mask + //$customer->setCode('1100'); // string|null Dimension code, must be compliant with the mask of the DEB Dimension type. + + //Twinfield does not accept BankID's on new entities + $customerBanks = $customer->getBanks(); + + foreach ($customerBanks as $customerBank) { + $customerBank->setID(null); + } + + try { + $customerCopy = $customerApiConnector->send($customer); + } catch (ResponseException $e) { + $customerCopy = $e->getReturnedObject(); + } + + echo "
";
+    print_r($customerCopy);
+    echo "
"; + + echo "Result of copy process: {$customerCopy->getResult()}
"; + echo "Code of copied Customer: {$customerCopy->getCode()}
"; +} + +// Create a new Customer from scratch, alternatively read an existing Customer as shown above and than modify the values in the same way as shown below +if ($executeNew) { + $customer = new \PhpTwinfield\Customer; + + // Required values for creating a new Customer + $customer->setCode(null); // string|null Set to null to let Twinfield assign a Dimension code based on the Dimension type mask + //$customer->setCode('1100'); // string|null Dimension code, must be compliant with the mask of the DEB Dimension type. + $customer->setName("Example Customer"); // string|null Name of the dimension. + $customer->setOffice($office); // Office|null Office code. + $customer->setOfficeFromString($officeCode); // string|null + + // Optional values for creating a new Customer + $customer->setBeginPeriod(0); // int|null Determines together with beginyear the period from which the dimension may be used. + $customer->setBeginYear(0); // int|null Determines together with beginperiod the period from which the dimension may be used. + $customer->setEndPeriod(0); // int|null Determines together with endyear the period till which the dimension may be used. + $customer->setEndYear(0); // int|null Determines together with endperiod the period till which the dimension may be used. + $customer->setShortName("ExmplCust"); // string|null Short name of the dimension. + //$customer->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. + //$customer->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case a dimension that is used in a transaction is deleted, its status has been changed into hide. Hidden dimensions can be activated by using active. + //$customer->setStatusFromString('active'); // string|null + //$customer->setStatusFromString('deleted'); // string|null + $customer->setWebsite("www.example.com"); // string|null Website of the dimension. + + $article = new \PhpTwinfield\Article; + $article->setCode('9060'); + $customer->setDiscountArticle($article); // Article|null The discount or premium article. + $customer->setDiscountArticleFromString("9060"); // string|null + + $dimensionGroup = new \PhpTwinfield\DimensionGroup; + $dimensionGroup->setCode('DIMGROUP'); + //$customer->setGroup($dimensionGroup); // DimensionGroup|null Sets the dimension group. See Dimension group. + //$customer->setGroupFromString("DIMGROUP"); // string|null + + $customer->setPaymentConditionDiscountDays(3); // int|null Number of discount days. + $customer->setPaymentConditionDiscountPercentage(25); // int|null Discount percentage. + + $customer->setRemittanceAdviceSendMail("test@example.com"); // string|null Mandatory if sendtype = ByEmail, remittance advice will be sent using this e-mail address. + $customer->setRemittanceAdviceSendType(\PhpTwinfield\Enums\RemittanceAdviceSendType::BYEMAIL()); // RemittanceAdviceSendMail|null To file manager, By e-mail + $customer->setRemittanceAdviceSendTypeFromString('ByEmail'); // string|null + + $customerCreditManagement = new \PhpTwinfield\CustomerCreditManagement; + $customerCreditManagement->setBaseCreditLimit(\Money\Money::EUR(1000000)); // Money|null The credit limit amount. + $customerCreditManagement->setBaseCreditLimitFromFloat(10000); // float|null + $customerCreditManagement->setBlocked(false); // bool|null Indicates if related projects for this customer are blocked in time & expenses. + $customerCreditManagement->setBlockedFromString('false'); // string|null + $customerCreditManagement->setBlockedLocked(false); // bool|null + $customerCreditManagement->setBlockedLockedFromString('false'); // string|null + $customerCreditManagement->setComment('Comment'); // string|null Comment. + $customerCreditManagement->setFreeText1(true); // bool|null Right of use. + $customerCreditManagement->setFreeText1FromString('true'); // string|null + $customerCreditManagement->setFreetext2(2); // string|null Segment code. + $customerCreditManagement->setFreetext3(''); // string|null + $customerCreditManagement->setReminderEmail('test@example.com'); // string|null Mandatory if sendreminder is email. + $user = new \PhpTwinfield\User; + $user->setCode('TWINAPPS'); + $customerCreditManagement->setResponsibleUser($user); // User|null The credit manager. + $customerCreditManagement->setResponsibleUserFromString('TWINAPPS'); // string|null + $customerCreditManagement->setSendReminder(\PhpTwinfield\Enums\SendReminder::EMAIL()); // SendReminder|null Determines if and how a customer will be reminded. + $customerCreditManagement->setSendReminderFromString('email'); // string|null + + $customer->setCreditManagement($customerCreditManagement); // CustomerCreditManagement Set the CustomerCreditManagement object tot the Customer object + + $customerFinancials = new \PhpTwinfield\CustomerFinancials; + $customerFinancials->setCollectionSchema(\PhpTwinfield\Enums\CollectionSchema::CORE()); + $customerFinancials->setCollectionSchemaFromString('core'); + $customerFinancials->setDueDays(14); // int|null The number of due days. + $customerFinancials->setEBillMail('test@example.com'); // string|null The mail address the electronic sales invoice is sent to. + $customerFinancials->setEBilling(true); // bool|null Determines if the sales invoices will be sent electronically to the customer. + $customerFinancials->setEBillingFromString('true'); // string|null + $customerFinancials->setMeansOfPayment(\PhpTwinfield\Enums\MeansOfPayment::PAYMENTFILE()); // MeansOfPayment|null The option none is only allowed in case payavailable is set to false. The option paymentfile is only allowed in case payavailable is set to true. + $customerFinancials->setMeansOfPaymentFromString('paymentfile'); // string|null + $customerFinancials->setPayAvailable(true); // bool|null Determines if direct debit is possible. + $customerFinancials->setPayAvailableFromString('true'); // string|null + $payCode = new \PhpTwinfield\PayCode; + $payCode->setCode('SEPANLCT'); + $customerFinancials->setPayCode($payCode); // PayCode|null The code of the payment type in case direct debit is possible. + $customerFinancials->setPayCodeFromString('SEPANLCT'); // string|null + $substituteWith = new \PhpTwinfield\GeneralLedger; + $substituteWith->getCode('1535'); + $customerFinancials->setSubstituteWith($substituteWith); // GeneralLedger|null Default customer balancesheet account. + $customerFinancials->setSubstituteWithFromString('1535'); // string|null + $vatCode = new \PhpTwinfield\VatCode; + $vatCode->setCode('VH'); + $customerFinancials->setVatCode($vatCode); // VatCode|null Default VAT code. + $customerFinancials->setVatCodeFromString('VH'); // string|null + + $customerCollectMandate = new \PhpTwinfield\CustomerCollectMandate; + $firstRunDate = \DateTime::createFromFormat('d-m-Y', '01-07-2019'); + $customerCollectMandate->setFirstRunDate($firstRunDate); // DateTimeInterface|null Date on which the first run was collected. + $customerCollectMandate->setFirstRunDateFromString('20190701'); // string|null + $customerCollectMandate->setID('1010'); // string|null Mandate id which the debtor can collect with. + $signatureDate = \DateTime::createFromFormat('d-m-Y', '01-07-2019'); + $customerCollectMandate->setSignatureDate($signatureDate); // DateTimeInterface|null Date on which the first run was collected. + $customerCollectMandate->setSignatureDateFromString('20190701'); // string|null + + $customerFinancials->setCollectMandate($customerCollectMandate); // CustomerCollectMandate Set the CustomerCollectMandate object tot the CustomerFinancials object + + $customer->setFinancials($customerFinancials); // CustomerFinancials Set the CustomerFinancials object tot the Customer object + + $customerAddress = new \PhpTwinfield\CustomerAddress; + $customerAddress->setCity('Amsterdam'); // string|null City. + $country = new \PhpTwinfield\Country; + $country->setCode('NL'); + $customerAddress->setCountry($country); // Country|null Country code. The ISO country codes are used. + $customerAddress->setCountryFromString('NL'); // string|null + $customerAddress->setDefault(true); // bool|null Is this the default address, only one default address is possible. + $customerAddress->setDefaultFromString('true'); // string|null + $customerAddress->setEmail('test@example.com'); // string|null + $customerAddress->setField1(''); // string|null User defined fields, the labels are configured in the Dimension type. + $customerAddress->setField2(''); // string|null User defined fields, the labels are configured in the Dimension type. + $customerAddress->setField3(''); // string|null User defined fields, the labels are configured in the Dimension type. + $customerAddress->setField4(null); // string|null User defined fields, the labels are configured in the Dimension type. Currently, field4 is reserved for VAT numbers. So only valid VAT numbers may be filled in. + $customerAddress->setField5(''); // string|null User defined fields, the labels are configured in the Dimension type. + $customerAddress->setField6(''); // string|null User defined fields, the labels are configured in the Dimension type. + $customerAddress->setID(1); // string|null Sequence number of the address line. + $customerAddress->setName('Example Customer'); // string|null Company name. + $customerAddress->setPostcode('9876YZ'); // string|null Postcode. + $customerAddress->setTelefax('012-3456789'); // string|null Fax number. + $customerAddress->setTelephone('987-654321'); // string|null Telephone number. + $customerAddress->setType(\PhpTwinfield\Enums\AddressType::INVOICE()); // AddressType|null The type of the address. + $customerAddress->setTypeFromString('invoice'); // string|null + + $customer->addAddress($customerAddress); // CustomerAddress Add a CustomerAddress object to the Customer object + //$customer->removeAddress(0); // int Remove an address based on the index of the address within the array + + $customerBank = new \PhpTwinfield\CustomerBank; + $customerBank->setAccountNumber('123456789'); // string|null Account number. + $customerBank->setAddressField2('Example Street'); // string|null Bank address. + $customerBank->setAddressField3('12'); // string|null Bank address number. + $customerBank->setAscription('Example Customer'); // string|null Account holder. + $customerBank->setBankName('Example Bank'); // string|null Bank name. + $customerBank->setBicCode('ABNANL2A'); // string|null BIC code. + $customerBank->setBlocked(false); // bool|null + $customerBank->setBlockedFromString('false'); // string|null + $customerBank->setCity('Amsterdam'); // string|null City. + $country = new \PhpTwinfield\Country; + $country->setCode('NL'); + $customerBank->setCountry($country); // Country|null Bank country code. The ISO country codes are used. + $customerBank->setCountryFromString('NL'); // string|null + $customerBank->setDefault(true); // bool|null Is this the default bank account, only one default bank account is possible. + $customerBank->setDefaultFromString('true'); // string|null + $customerBank->setID(null); // int|null Sequence number of the bank account line. When adding a new bank, do not supply the @id. When changing a bank account, supply the corresponding @id. + $customerBank->setIban(null); // string|null IBAN account number. + $customerBank->setNatBicCode('NL'); // string|null National bank code. + $customerBank->setPostcode('1234AB'); // string|null Postcode. + $customerBank->setState('Noord-Holland'); // string|null State. + + $customer->addBank($customerBank); // CustomerBank Add a CustomerBank object to the Customer object + //$customer->removeBank(0); // int Remove a bank based on the index of the bank within the array + + $customerPostingRule = new \PhpTwinfield\CustomerPostingRule; + $customerPostingRule->setAmount(\Money\Money::EUR(10000)); // Money|null Amount. + $customerPostingRule->setAmountFromFloat(100); // float|null + $currency = new \PhpTwinfield\Currency; + $currency->setCode('EUR'); + $customerPostingRule->setCurrency($currency); // Currency|null Currency. + $customerPostingRule->setCurrencyFromString('EUR'); // string|null + $customerPostingRule->setDescription('Example PostingRule'); // string|null Description. + $customerPostingRule->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating active should be used. For deleting deleted should be used. + //$customerPostingRule->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null + $customerPostingRule->setStatusFromString('active'); // string|null + //$customerPostingRule->setStatusFromString('deleted'); // string|null + + $customerLine = new \PhpTwinfield\CustomerLine; + $customerLine->setDescription('Example Line'); // string|null Description. + $dimension1 = new \PhpTwinfield\GeneralLedger; + $dimension1->setCode('1535'); + $customerLine->setDimension1($dimension1); // GeneralLedger|null General ledger. + $customerLine->setDimension1FromString('1535'); // string|null + $costCenter = new \PhpTwinfield\CostCenter; + $costCenter->setCode('00000'); + $customerLine->setDimension2($costCenter); // CostCenter|null Cost center. + $customerLine->setDimension2FromString ('00000'); // string|null + $activity = new \PhpTwinfield\Activity; + $activity->setCode('P0000'); + $customerLine->setDimension3($activity); // Dummy|null Project or asset. + $customerLine->setDimension3FromString('P0000'); // string|null + $destOffice = new \PhpTwinfield\Office; + $destOffice->setCode('NLA0000001'); + //$customerLine->setOffice($destOffice); // Office|null Destination company. + //$customerLine->setOfficeFromString('NLA0000001'); // string|null + $customerLine->setRatio(1); // float|null The ratio of the posting rule line. + $vatCode = new \PhpTwinfield\VatCode; + $vatCode->setCode('VH'); + $customerLine->setVatCode($vatCode); // VatCode|null Default VAT code. + $customerLine->setVatCodeFromString('VH'); // string|null + + $customerPostingRule->addLine($customerLine); // CustomerLine Add a CustomerLine object to the CustomerPostingRule object + //$customerPostingRule->removeLine(0); // int Remove a line based on the index of the line within the array + + $customer->addPostingRule($customerPostingRule); // CustomerPostingRule Add a CustomerPostingRule object to the Customer object + //$customer->removePostingRule(0); // int Remove a posting rule based on the index of the posting rule within the array + + try { + $customerNew = $customerApiConnector->send($customer); + } catch (ResponseException $e) { + $customerNew = $e->getReturnedObject(); + } + + echo "
";
+    print_r($customerNew);
+    echo "
"; + + echo "Result of creation process: {$customerNew->getResult()}
"; + echo "Code of new Customer: {$customerNew->getCode()}
"; +} + +// Delete a Customer based off the passed in code and optionally the office. +if ($executeDelete) { + try { + $customerDeleted = $customerApiConnector->delete("1003", $office); + } catch (ResponseException $e) { + $customerDeleted = $e->getReturnedObject(); + } + + echo "
";
+    print_r($customerDeleted);
+    echo "
"; + + echo "Result of deletion process: {$customerDeleted->getResult()}
"; +} \ No newline at end of file diff --git a/examples/DimensionGroup.php b/examples/DimensionGroup.php index b7c20f78..8046c18b 100644 --- a/examples/DimensionGroup.php +++ b/examples/DimensionGroup.php @@ -196,13 +196,12 @@ // The minimum amount of DimensionGroupDimensions linked to a DimensionGroup object is 0 $dimensionGroupDimension = new \PhpTwinfield\DimensionGroupDimension; - $type = new \PhpTwinfield\DimensionType; - $type->setCode('BAS'); $code = new \PhpTwinfield\GeneralLedger; - $code->setType($type); $code->setCode('1010'); $dimensionGroupDimension->setCode($code); // object|null Code of the dimension. $dimensionGroupDimension->setCodeFromString('1010'); // string|null + $type = new \PhpTwinfield\DimensionType; + $type->setCode('BAS'); $dimensionGroupDimension->setType($type); // DimensionType|null Dimension type. $dimensionGroupDimension->setTypeFromString('BAS'); // string|null diff --git a/examples/Invoice.php b/examples/Invoice.php index 2de30cee..f565ed6b 100644 --- a/examples/Invoice.php +++ b/examples/Invoice.php @@ -155,14 +155,14 @@ echo "Customer (\\PhpTwinfield\\Customer):
" . print_r($invoice->getCustomer(), true) . "

"; // Customer|null Customer code. echo "Customer (string): {$invoice->getCustomerToString()}
"; // string|null echo "DeliverAddressNumber: {$invoice->getDeliverAddressNumber()}
"; // int|null - echo "DueDate (\\DateTimeInterface):
" . print_r($invoice->getDueDate(), true) . "

"; // \DateTimeInterface|null Due date. + echo "DueDate (\\DateTimeInterface):
" . print_r($invoice->getDueDate(), true) . "

"; // DateTimeInterface|null Due date. echo "DueDate (string): {$invoice->getDueDateToString()}
"; // string|null echo "FinancialCode: {$invoice->getFinancialCode()}
"; // string|null The transaction type code. Read-only attribute. echo "FinancialNumber: {$invoice->getFinancialNumber()}
"; // string|null The transaction number. Read-only attribute. echo "FooterText: {$invoice->getFooterText()}
"; // string|null Footer text on the invoice. echo "HeaderText: {$invoice->getHeaderText()}
"; // string|null Header text on the invoice. echo "InvoiceAddressNumber: {$invoice->getInvoiceAddressNumber()}
"; // int|null - echo "InvoiceDate (\\DateTimeInterface):
" . print_r($invoice->getInvoiceDate(), true) . "

"; // \DateTimeInterface|null Invoice date. + echo "InvoiceDate (\\DateTimeInterface):
" . print_r($invoice->getInvoiceDate(), true) . "

"; // DateTimeInterface|null Invoice date. echo "InvoiceDate (string): {$invoice->getInvoiceDateToString()}
"; // string|null echo "InvoiceNumber: {$invoice->getInvoiceNumber()}
"; // string|null Invoice Number. echo "InvoiceType (\\PhpTwinfield\\InvoiceType):
" . print_r($invoice->getInvoiceType(), true) . "

"; // InvoiceType|null Invoice type code. @@ -173,7 +173,7 @@ } echo "PaymentMethod: {$invoice->getPaymentMethod()}
"; // PaymentMethod|null The payment method. - echo "PerformanceDate (\\DateTimeInterface):
" . print_r($invoice->getPerformanceDate(), true) . "

"; // \DateTimeInterface|null Performance date, when set-up on the invoice header. + echo "PerformanceDate (\\DateTimeInterface):
" . print_r($invoice->getPerformanceDate(), true) . "

"; // DateTimeInterface|null Performance date, when set-up on the invoice header. echo "PerformanceDate (string): {$invoice->getPerformanceDateToString()}
"; // string|null echo "Period: {$invoice->getPeriod()}
"; // string|null Period in YYYY/PP format. echo "Office (\\PhpTwinfield\\Office):
" . print_r($invoice->getOffice(), true) . "

"; // Office|null Office code. @@ -221,7 +221,7 @@ echo "Messages: " . print_r($invoiceLine->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "PerformanceDate (\\DateTimeInterface):
" . print_r($invoiceLine->getPerformanceDate(), true) . "

"; // \DateTimeInterface|null Performance date, when set-up on invoice lines. + echo "PerformanceDate (\\DateTimeInterface):
" . print_r($invoiceLine->getPerformanceDate(), true) . "

"; // DateTimeInterface|null Performance date, when set-up on invoice lines. echo "PerformanceDate (string): {$invoiceLine->getPerformanceDateToString()}
"; // string|null echo "PerformanceType: {$invoiceLine->getPerformanceType()}
"; // PerformanceType|null The performance type in case of an ICT sales invoice. echo "Quantity: {$invoiceLine->getQuantity()}
"; // int|null The quantity on the sales invoice line. @@ -252,7 +252,7 @@ echo "Messages: " . print_r($invoiceVatLine->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "PerformanceDate (\\DateTimeInterface):
" . print_r($invoiceVatLine->getPerformanceDate(), true) . "

"; // \DateTimeInterface|null The performance date. Only in case performancetype = services. Read-only attribute. + echo "PerformanceDate (\\DateTimeInterface):
" . print_r($invoiceVatLine->getPerformanceDate(), true) . "

"; // DateTimeInterface|null The performance date. Only in case performancetype = services. Read-only attribute. echo "PerformanceDate (string): {$invoiceVatLine->getPerformanceDateToString()}
"; // string|null echo "PerformanceType: {$invoiceVatLine->getPerformanceType()}
"; // PerformanceType|null The performance type. Read-only attribute. echo "Result: {$invoiceVatLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). @@ -321,18 +321,18 @@ $invoice->setCurrencyFromString("EUR"); $invoice->setDeliverAddressNumber(1); // int|null If you want the default address, omit the tag or leave it empty. $dueDate = \DateTime::createFromFormat('d-m-Y', '01-07-2019'); - $invoice->setDueDate($dueDate); // \DateTimeInterface|null Due date. + $invoice->setDueDate($dueDate); // DateTimeInterface|null Due date. $invoice->setDueDateFromString("20190701"); // string|null $invoice->setFooterText("Example Footer"); // string|null Footer text on the invoice. $invoice->setHeaderText("Example Header"); // string|null Header text on the invoice. $invoice->setInvoiceAddressNumber(1); // int|null If you want the default address, omit the tag or leave it empty. $invoiceDate = \DateTime::createFromFormat('d-m-Y', '01-07-2019'); - $invoice->setInvoiceDate($invoiceDate); // \DateTimeInterface|null Optional; when the invoicedate is not supplied Twinfield uses the system date as the invoice date. + $invoice->setInvoiceDate($invoiceDate); // DateTimeInterface|null Optional; when the invoicedate is not supplied Twinfield uses the system date as the invoice date. $invoice->setInvoiceDateFromString("20190701"); // string|null $invoice->setPaymentMethod(\PhpTwinfield\Enums\PaymentMethod::BANK()); // PaymentMethod|null The payment method. $invoice->setPaymentMethodFromString("bank"); // string|null $performanceDate = \DateTime::createFromFormat('d-m-Y', '01-07-2019'); - $invoice->setPerformanceDate($performanceDate); // \DateTimeInterface|null Performance date, when set-up on the invoice header. + $invoice->setPerformanceDate($performanceDate); // DateTimeInterface|null Performance date, when set-up on the invoice header. $invoice->setPerformanceDateFromString("20190701"); // string|null $invoice->setPeriod("2019/07"); // string|null Period in YYYY/PP format. $invoice->setPeriodRaiseWarning(false); // bool|null Optionally, it is possible to suppress warnings about 'date out of range for the given period' by adding the raisewarning attribute and set its value to false. @@ -361,9 +361,9 @@ //$invoiceLine->setFreeText2('Example Free Text 2'); // string|null Free text field 2 as entered on the invoice type. //$invoiceLine->setFreetext3("Example Free Text 3"); // string|null Free text field 3 as entered on the invoice type. $invoiceLine->setID(1); // int|null Line ID. - //$invoice->setPerformanceType(\PhpTwinfield\Enums\PerformanceType::SERVICES()); // PerformanceType|null The performance type in case of an ICT sales invoice. - //$invoice->setPerformanceTypeFromString("services"); // string|null - //$invoiceLine->setPerformanceDate($performanceDate); // \DateTimeInterface|null Performance date, when set-up on invoice lines. + //$invoiceLine->setPerformanceType(\PhpTwinfield\Enums\PerformanceType::SERVICES()); // PerformanceType|null The performance type in case of an ICT sales invoice. + //$invoiceLine->setPerformanceTypeFromString("services"); // string|null + //$invoiceLine->setPerformanceDate($performanceDate); // DateTimeInterface|null Performance date, when set-up on invoice lines. //$invoiceLine->setPerformanceDateFromString("20190701"); // string|null $invoiceLine->setQuantity(1); // int|null The quantity on the sales invoice line. $subArticle = new \PhpTwinfield\ArticleLine; @@ -381,7 +381,7 @@ //$invoiceLine->setVatCodeFromString('VH'); // string|null $invoice->addLine($invoiceLine); // InvoiceLine Add an InvoiceLine object to the Invoice object - //$invoice->removeLine(1); // int Remove an invoice line based on the id of the invoice line + //$invoice->removeLine(0); // int Remove an invoice line based on the index of the invoice line try { $invoiceNew = $invoiceApiConnector->send($invoice); diff --git a/examples/Office.php b/examples/Office.php index e7e706fa..f3cb55a4 100644 --- a/examples/Office.php +++ b/examples/Office.php @@ -136,14 +136,14 @@ echo "Code: {$office->getCode()}
"; // string|null //echo "CountryCode (\\PhpTwinfield\\Country):
" . print_r($office->getCountryCode(), true) . "

"; // Country|null //echo "CountryCode (string): {$office->getCountryCodeToString()}
"; // string|null - echo "Created (\\DateTimeInterface):
" . print_r($office->getCreated(), true) . "

"; // \DateTimeInterface|null The date/time the office was created. + echo "Created (\\DateTimeInterface):
" . print_r($office->getCreated(), true) . "

"; // DateTimeInterface|null The date/time the office was created. echo "Created (string): {$office->getCreatedToString()}
"; // string|null if ($office->hasMessages()) { // bool Object contains (error) messages true/false. echo "Messages: " . print_r($office->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Modified (\\DateTimeInterface):
" . print_r($office->getModified(), true) . "

"; // \DateTimeInterface|null The date/time the office was modified. + echo "Modified (\\DateTimeInterface):
" . print_r($office->getModified(), true) . "

"; // DateTimeInterface|null The date/time the office was modified. echo "Modified (string): {$office->getModifiedToString()}
"; // string|null echo "Name: {$office->getName()}
"; // string|null echo "Result: {$office->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). diff --git a/examples/Project.php b/examples/Project.php index 7e4177cc..1bb60f37 100644 --- a/examples/Project.php +++ b/examples/Project.php @@ -158,7 +158,7 @@ echo "ShortName: {$project->getShortName()}
"; // string|null Short project description. echo "Status: {$project->getStatus()}
"; // Status|null Status of the project. echo "Touched: {$project->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. - echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($project->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is PRJ. + echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($project->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of projects is PRJ. echo "Type (string): {$project->getTypeToString()}
"; // string|null echo "UID: {$project->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($project->getVatCode(), true) . "

"; // VatCode|null The VAT code if one code will apply for all projects within the project. Note that if any VAT codes are @@ -199,9 +199,9 @@ echo "Rate Locked (bool): {$projectProjects->getRateLocked()}
"; // bool|null If "change" = disallow then locked = true and inherit = false echo "Rate Locked (string): {$projectProjects->getRateLockedToString()}
"; // string|null If "change" = inherit then locked = true and inherit = true echo "Result: {$projectProjects->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "Valid From (\\DateTimeInterface):
" . print_r($projectProjects->getValidFrom(), true) . "

"; // \DateTimeInterface|null A project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. + echo "Valid From (\\DateTimeInterface):
" . print_r($projectProjects->getValidFrom(), true) . "

"; // DateTimeInterface|null A project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. echo "Valid From (string): {$projectProjects->getValidFromToString()}
"; // string|null - echo "Valid Till (\\DateTimeInterface):
" . print_r($projectProjects->getValidTill(), true) . "

"; // \DateTimeInterface|null A project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. + echo "Valid Till (\\DateTimeInterface):
" . print_r($projectProjects->getValidTill(), true) . "

"; // DateTimeInterface|null A project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. echo "Valid Till (string): {$projectProjects->getValidTillToString()}
"; // string|null $projectQuantities = $projectProjects->getQuantities(); // array|null Array of ProjectQuantity objects. @@ -235,7 +235,8 @@ $project = $e->getReturnedObject(); } - $project->setCode("P0100"); + $project->setCode(null); // string|null Set to null to let Twinfield assign a Dimension code based on the Dimension type mask + //$project->setCode('P0100'); // string|null Dimension code, must be compliant with the mask of the PRJ Dimension type. try { $projectCopy = $projectApiConnector->send($project); @@ -257,21 +258,18 @@ // Required values for creating a new Project // - $project->setCode('P0100'); // string|null Dimension code, must be compliant with the mask of the PRJ Dimension type. + $project->setCode(null); // string|null Set to null to let Twinfield assign a Dimension code based on the Dimension type mask + //$project->setCode('P0100'); // string|null Dimension code, must be compliant with the mask of the PRJ Dimension type. $project->setName("Example Project"); // string|null Project description. $project->setOffice($office); // Office|null Office code. $project->setOfficeFromString($officeCode); // string|null + + // Optional values for creating a new Project + $project->setShortName("ExmplPrj"); // string|null Short project description. //$project->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. //$project->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case a project is in use, its status has been changed into hide. Hidden projects can be activated by using active. //$project->setStatusFromString('active'); // string|null //$project->setStatusFromString('deleted'); // string|null - $dimensionType = new \PhpTwinfield\DimensionType; - $dimensionType->setCode('PRJ'); - $project->setType($dimensionType); // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is PRJ. - $project->setTypeFromString('PRJ'); // string|null - - // Optional values for creating a new Project - $project->setShortName("ExmplPrj"); // string|null Short project description. $vatCode = new \PhpTwinfield\VatCode; $vatCode->setCode('VH'); $project->setVatCode($vatCode); // VatCode|null The VAT code if one code will apply for all projects within the project. Note that if any VAT codes are @@ -313,15 +311,14 @@ $projectProjects->setRateLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false $projectProjects->setRateLockedFromString('true'); // string|null If "change" = inherit then locked = true and inherit = true $validFrom = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); - $projectProjects->setValidFrom($validFrom); // \DateTimeInterface|null A project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. + $projectProjects->setValidFrom($validFrom); // DateTimeInterface|null A project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. $projectProjects->setValidFromFromString('20190101'); // string|null $validTill = \DateTime::createFromFormat('d-m-Y', '31-12-2019'); - $projectProjects->setValidTill($validTill); // \DateTimeInterface|null A project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. + $projectProjects->setValidTill($validTill); // DateTimeInterface|null A project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. $projectProjects->setValidTillFromString('20191231'); // string|null // The minimum amount of ProjectQuantities linked to a ProjectProjects object is 0, the maximum amount is 4 $projectQuantity = new \PhpTwinfield\ProjectQuantity; - $projectQuantity->setBillable(false); // bool|null Is the quantity line billable or not. $projectQuantity->setBillableFromString('false'); // string|null If "billable" = true and "change is not allowed" then locked = true $projectQuantity->setBillableLocked(false); // bool|null diff --git a/examples/Rate.php b/examples/Rate.php index 13200e46..43862ea9 100644 --- a/examples/Rate.php +++ b/examples/Rate.php @@ -120,7 +120,7 @@ echo "Rate
"; echo "Code: {$rate->getCode()}
"; // string|null Rate code. - echo "Created (\\DateTimeInterface):
" . print_r($rate->getCreated(), true) . "

"; // \DateTimeInterface|null The date/time the rate was created. Read-only attribute. + echo "Created (\\DateTimeInterface):
" . print_r($rate->getCreated(), true) . "

"; // DateTimeInterface|null The date/time the rate was created. Read-only attribute. echo "Created (string): {$rate->getCreatedToString()}
"; // string|null echo "Currency (\\PhpTwinfield\\Currency):
" . print_r($rate->getCurrency(), true) . "

"; // Currency|null Currency code. echo "Currency (string): {$rate->getCurrencyToString()}
"; // string|null @@ -129,7 +129,7 @@ echo "Messages: " . print_r($rate->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Modified (\\DateTimeInterface):
" . print_r($rate->getModified(), true) . "

"; // \DateTimeInterface|null The date/time the rate was modified. Read-only attribute. + echo "Modified (\\DateTimeInterface):
" . print_r($rate->getModified(), true) . "

"; // DateTimeInterface|null The date/time the rate was modified. Read-only attribute. echo "Modified (string): {$rate->getModifiedToString()}
"; // string|null echo "Name: {$rate->getName()}
"; // string|null Rate description. echo "Office (\\PhpTwinfield\\Office):
" . print_r($rate->getOffice(), true) . "

"; // Office|null Office code. @@ -149,9 +149,9 @@ foreach ($rateRateChanges as $key => $rateRateChange) { echo "RateRateChange {$key}
"; - echo "BeginDate (\\DateTimeInterface):
" . print_r($rateRateChange->getBeginDate(), true) . "

"; // \DateTimeInterface|null Begin date of the rate. + echo "BeginDate (\\DateTimeInterface):
" . print_r($rateRateChange->getBeginDate(), true) . "

"; // DateTimeInterface|null Begin date of the rate. echo "BeginDate (string): {$rateRateChange->getBeginDateToString()}
"; // string|null - echo "EndDate (\\DateTimeInterface):
" . print_r($rateRateChange->getEndDate(), true) . "

"; // \DateTimeInterface|null End date of the rate. + echo "EndDate (\\DateTimeInterface):
" . print_r($rateRateChange->getEndDate(), true) . "

"; // DateTimeInterface|null End date of the rate. echo "EndDate (string): {$rateRateChange->getEndDateToString()}
"; // string|null echo "ExternalRate: {$rateRateChange->getExternalRate()}
"; // int|null The external rate e.g. the selling price per unit. echo "ID: {$rateRateChange->getID()}
"; // int|null Line ID. @@ -218,10 +218,10 @@ // The minimum amount of RateRateChanges linked to a Rate object is 0 $rateRateChange = new \PhpTwinfield\RateRateChange; $beginDate = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); - $rateRateChange->setBeginDate($beginDate); // \DateTimeInterface|null Begin date of the rate. + $rateRateChange->setBeginDate($beginDate); // DateTimeInterface|null Begin date of the rate. $rateRateChange->setBeginDateFromString('20190101'); // string|null $endDate = \DateTime::createFromFormat('d-m-Y', '31-12-2019'); - $rateRateChange->setEndDate($endDate); // \DateTimeInterface|null Begin date of the rate. + $rateRateChange->setEndDate($endDate); // DateTimeInterface|null Begin date of the rate. $rateRateChange->setEndDateFromString('20191231'); // string|null $rateRateChange->setExternalRate(60); // float|null The internal rate e.g. the cost price per unit. $rateRateChange->setID(2); // int|null Line ID. @@ -231,7 +231,7 @@ //$rateRateChange->setStatusFromString('deleted'); // string|null NOTE: Do not use $rateRateChange->setStatusFromString('active'); $rate->addRateChange($rateRateChange); // RateRateChange Add a RateRateChange object to the Rate object - //$rate->removeRateChange(2); // int Remove a rate change based on the id of the rate change + //$rate->removeRateChange(0); // int Remove a rate change based on the index of the rate change try { $rateNew = $rateApiConnector->send($rate); diff --git a/examples/Supplier.php b/examples/Supplier.php new file mode 100644 index 00000000..507f79e7 --- /dev/null +++ b/examples/Supplier.php @@ -0,0 +1,580 @@ + matchtype = 'relation' +if ($executeListAllWithFilter) { + $options = array('matchtype' => 'relation'); + + try { + $suppliers = $supplierApiConnector->listAll("2*", 0, 1, 10, $options); + } catch (ResponseException $e) { + $suppliers = $e->getReturnedObject(); + } + + echo "
";
+    print_r($suppliers);
+    echo "
"; +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +if ($executeListAllWithoutFilter) { + try { + $suppliers = $supplierApiConnector->listAll(); + } catch (ResponseException $e) { + $suppliers = $e->getReturnedObject(); + } + + echo "
";
+    print_r($suppliers);
+    echo "
"; +} + +/* Supplier + * \PhpTwinfield\Supplier + * Available getters: getBeginPeriod, getBeginYear, getBehaviour, getBlockedAccountPaymentConditionsIncludeVat, getBlockedAccountPaymentConditionsPercentage, getCode, getEndPeriod, getEndYear, getGroup, getGroupToString, getInUse, getInUseToString, getMessages, getName, getOffice, getOfficeToString, + * getPaymentConditionDiscountDays, getPaymentConditionDiscountPercentage, getRemittanceAdviceSendMail, getRemittanceAdviceSendType, getResult, getShortName, getStatus, getTouched, getType, getTypeToString, getUID, getWebsite, hasMessages, getAddresses, getBanks, getFinancials, getPostingRules + * + * Available setters: setBeginPeriod, setBeginYear, setBehaviour, setBehaviourFromString, setBlockedAccountPaymentConditionsIncludeVat, setBlockedAccountPaymentConditionsIncludeVatFromString, setBlockedAccountPaymentConditionsPercentage, setCode, setEndPeriod, setEndYear, setGroup, setGroupFromString, setName, setOffice, setOfficeFromString, + * setPaymentConditionDiscountDays, setPaymentConditionDiscountPercentage, setRemittanceAdviceSendMail, setRemittanceAdviceSendType, setRemittanceAdviceSendTypeFromString, setShortName, setStatus, setStatusFromString, setType, setTypeFromString, setWebsite, setFinancials, addAddress, removeAddress, addBank, removeBank, addPostingRule, removePostingRule + * + */ + +/* SupplierFinancials + * \PhpTwinfield\SupplierFinancials + * Available getters: getAccountType, getDueDays, getLevel, getMatchType, getMeansOfPayment, getMessages, getPayAvailable, getPayAvailableToString, getPayCode, getPayCodeID, getPayCodeToString, getRelationsReference, + * getResult, getSubAnalyse, getSubstituteWith, getSubstituteWithID, getSubstituteWithToString, getSubstitutionLevel, getVatCode, getVatCodeFixed, getVatCodeFixedToString, getVatCodeToString, getChildValidations, hasMessages + * + * Available setters: setAccountType, setAccountTypeFromString, setDueDays, setLevel, setMatchType, setMatchTypeFromString, setMeansOfPayment, setMeansOfPaymentFromString, setPayAvailable, setPayAvailableFromString, + * setPayCode, setPayCodeFromString, setPayCodeID, setRelationsReference, setSubAnalyse, setSubAnalyseFromString, setSubstituteWith, setSubstituteWithFromString, setSubstituteWithID, setSubstitutionLevel, setVatCode, setVatCodeFixed, setVatCodeFixedFromString, setVatCodeFromString, addChildValidation, removeChildValidation + * + */ + +/* SupplierChildValidation + * \PhpTwinfield\SupplierChildValidation + * Available getters: getElementValue, getLevel, getMessages, getResult, getType, hasMessages + * Available setters: setElementValue, setLevel, setType, setTypeFromString + */ + +/* SupplierAddress + * \PhpTwinfield\SupplierAddress + * Available getters: getCity, getCountry, getCountryToString, getDefault, getDefaultToString, getEmail, getField1, getField2, getField3, getField4, getField5, getField6, getID, getMessages, getName, getPostcode, getResult, getTelefax, getTelephone, getType, hasMessages + * Available setters: setCity, setCountry, setCountryFromString, setDefault, setDefaultFromString, setEmail, setField1, setField2, setField3, setField4, setField5, setField6, setID, setName, setPostcode, setTelefax, setTelephone, setType, setTypeFromString + */ + +/* SupplierBank + * \PhpTwinfield\SupplierBank + * Available getters: getAccountNumber, getAddressField2, getAddressField3, getAscription, getBankName, getBicCode, getBlocked, getBlockedToString, getCity, getCountry, getCountryToString, getDefault, getDefaultToString, getID, getIban, getMessages, getNatBicCode, getPostcode, getResult, getState, hasMessages + * Available setters: setAccountNumber, setAddressField2, setAddressField3, setAscription, setBankName, setBicCode, setBlocked, setBlockedFromString, setCity, setCountry, setCountryFromString, setDefault, setDefaultFromString, setID, setIban, setNatBicCode, setPostcode, setState + */ + +/* SupplierPostingRule + * \PhpTwinfield\SupplierPostingRule + * Available getters: getAmount, getAmountToFloat, getCurrency, getCurrencyToString, getDescription, getID, getMessages, getResult, getStatus, getLines, hasMessages + * Available setters: setAmount, setAmountFromFloat, setCurrency, setCurrencyFromString, setDescription, setID, setStatus, setStatusFromString, addLine, removeLine + */ + +/* SupplierLine + * \PhpTwinfield\SupplierLine + * Available getters: getDescription, getDimension1, getDimension1ID, getDimension1ToString, getDimension2, getDimension2ID, getDimension2ToString, getDimension3, getDimension3ID, getDimension3ToString, getMessages, getOffice, getOfficeToString, getRatio, getResult, getVatCode, getVatCodeToString, hasMessages + * Available setters: setDescription, setDimension1, setDimension1FromString, setDimension1ID, setDimension2, setDimension2FromString, setDimension2ID, setDimension3, setDimension3FromString, setDimension3ID, setOffice, setOfficeFromString, setRatio, setVatCode, setVatCodeFromString + */ + +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($suppliers as $key => $supplier) { + echo "Supplier {$key}
"; + echo "Code: {$supplier->getCode()}
"; + echo "Name: {$supplier->getName()}

"; + } +} + +// Read an Supplier based off the passed in code and optionally the office. +if ($executeRead) { + try { + $supplier = $supplierApiConnector->get("2000", $office); + } catch (ResponseException $e) { + $supplier = $e->getReturnedObject(); + } + + echo "
";
+    print_r($supplier);
+    echo "
"; + + echo "Supplier
"; + echo "BeginPeriod: {$supplier->getBeginPeriod()}
"; // int|null Determines together with beginyear the period from which the dimension may be used. + echo "BeginYear: {$supplier->getBeginYear()}
"; // int|null Determines together with beginperiod the period from which the dimension may be used. + echo "Behaviour: {$supplier->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. + echo "Code: {$supplier->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the DEB Dimension type. + echo "EndPeriod: {$supplier->getEndPeriod()}
"; // int|null Determines together with endyear the period till which the dimension may be used. + echo "EndYear: {$supplier->getEndYear()}
"; // int|null Determines together with endperiod the period till which the dimension may be used. + echo "Group (\\PhpTwinfield\\DimensionGroup):
" . print_r($supplier->getGroup(), true) . "

"; // DimensionGroup|null Sets the dimension group. See Dimension group. + echo "Group (string): {$supplier->getGroupToString()}
"; // string|null + echo "InUse (bool): {$supplier->getInUse()}
"; // bool|null Indicates whether the balancesheet is used in a financial transaction or not. Read-only attribute. + echo "InUse (string): {$supplier->getInUseToString()}
"; // string|null + + if ($supplier->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($supplier->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Name: {$supplier->getName()}
"; // string|null Name of the dimension. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($supplier->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): {$supplier->getOfficeToString()}
"; // string|null + echo "PaymentCondition:
"; // Sets the payment condition of a dimension. + echo "PaymentCondition DiscountDays: {$supplier->getPaymentConditionDiscountDays()}
"; // int|null Number of discount days. + echo "PaymentCondition DiscountPercentage: {$supplier->getPaymentConditionDiscountPercentage()}
"; // float|null Discount percentage. + echo "RemittanceAdvice:
"; // + echo "RemittanceAdvice SendMail: {$supplier->getRemittanceAdviceSendMail()}
"; // string|null Mandatory if sendtype = ByEmail, remittance advice will be sent using this e-mail address. + echo "RemittanceAdvice SendType: {$supplier->getRemittanceAdviceSendType()}
"; // RemittanceAdviceSendType|null To file manager, By e-mail + echo "Result: {$supplier->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$supplier->getShortName()}
"; // string|null Short name of the dimension. + echo "Status: {$supplier->getStatus()}
"; // Status|null Status of the supplier. + echo "Touched: {$supplier->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. + echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($supplier->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of suppliers is DEB. + echo "Type (string): {$supplier->getTypeToString()}
"; // string|null + echo "UID: {$supplier->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. + echo "Website: {$supplier->getWebsite()}
"; // string|null Website of the dimension. + + $supplierAddresses = $supplier->getAddresses(); // array|null Array of SupplierAddress objects. + + foreach ($supplierAddresses as $key => $supplierAddress) { + echo "SupplierAddress {$key}
"; + + echo "City: {$supplierAddress->getCity()}
"; // string|null City. + echo "Country (\\PhpTwinfield\\Country):
" . print_r($supplierAddress->getCountry(), true) . "

"; // Country|null Country code. The ISO country codes are used. + echo "Country (string): {$supplierAddress->getCountryToString()}
"; // string|null + echo "Default (bool): {$supplierAddress->getDefault()}
"; // bool|null Is this the default address, only one default address is possible. + echo "Default (string): {$supplierAddress->getDefaultToString()}
"; // string|null + echo "Email: {$supplierAddress->getEmail()}
"; // string|null + echo "Field1: {$supplierAddress->getField1()}
"; // string|null User defined fields, the labels are configured in the Dimension type. + echo "Field2: {$supplierAddress->getField2()}
"; // string|null User defined fields, the labels are configured in the Dimension type. + echo "Field3: {$supplierAddress->getField3()}
"; // string|null User defined fields, the labels are configured in the Dimension type. + echo "Field4: {$supplierAddress->getField4()}
"; // string|null User defined fields, the labels are configured in the Dimension type. Currently, field4 is reserved for VAT numbers. So only valid VAT numbers may be filled in. + echo "Field5: {$supplierAddress->getField5()}
"; // string|null User defined fields, the labels are configured in the Dimension type. + echo "Field6: {$supplierAddress->getField6()}
"; // string|null User defined fields, the labels are configured in the Dimension type. + echo "ID: {$supplierAddress->getID()}
"; // int|null Sequence number of the address line. + + if ($supplierAddress->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($supplierAddress->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Name: {$supplierAddress->getName()}
"; // string|null Company name. + echo "Postcode: {$supplierAddress->getPostcode()}
"; // string|null Postcode. + echo "Result: {$supplierAddress->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Telefax: {$supplierAddress->getTelefax()}
"; // string|null Fax number. + echo "Telephone: {$supplierAddress->getTelephone()}
"; // string|null Telephone number. + echo "Type: {$supplierAddress->getType()}
"; // AddressType|null The type of the address. + } + + $supplierBanks = $supplier->getBanks(); + + foreach ($supplierBanks as $key => $supplierBank) { + echo "SupplierBank {$key}
"; + + echo "AccountNumber: {$supplierBank->getAccountNumber()}
"; // string|null Account number. + echo "AddressField2: {$supplierBank->getAddressField2()}
"; // string|null Bank address. + echo "AddressField3: {$supplierBank->getAddressField3()}
"; // string|null Bank address number. + echo "Ascription: {$supplierBank->getAscription()}
"; // string|null Account holder. + echo "BankName: {$supplierBank->getBankName()}
"; // string|null Bank name. + echo "BicCode: {$supplierBank->getBicCode()}
"; // string|null BIC code. + + echo "Blocked (bool): {$supplierBank->getBlocked()}
"; // bool|null + echo "Blocked (string): {$supplierBank->getBlockedToString()}
"; // string|null + echo "City: {$supplierBank->getCity()}
"; // string|null City. + echo "Country (\\PhpTwinfield\\Country):
" . print_r($supplierBank->getCountry(), true) . "

"; // Country|null Bank country code. The ISO country codes are used. + echo "Country (string): {$supplierBank->getCountryToString()}
"; // string|null + echo "Default (bool): {$supplierBank->getDefault()}
"; // bool|null Is this the default bank account, only one default bank account is possible. + echo "Default (string): {$supplierBank->getDefaultToString()}
"; // string|null + echo "ID: {$supplierBank->getID()}
"; // int|null Sequence number of the bank account line. When adding a new bank, do not supply the @id. When changing a bank account, supply the corresponding @id. + echo "IBAN: {$supplierBank->getIban()}
"; // string|null IBAN account number. + + if ($supplierBank->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($supplierBank->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "NatBicCode: {$supplierBank->getNatBicCode()}
"; // string|null National bank code. + echo "Postcode: {$supplierBank->getPostcode()}
"; // string|null Postcode. + echo "Result: {$supplierBank->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "State: {$supplierBank->getState()}
"; // string|null State. + } + + echo "SupplierFinancials
"; + $supplierFinancials = $supplier->getFinancials(); // SupplierFinancials|null SupplierFinancials object. + + echo "AccountType: {$supplierFinancials->getAccountType()}
"; // AccountType|null Fixed value inherit. + echo "DueDays: {$supplierFinancials->getDueDays()}
"; // int|null The number of due days. + echo "Level: {$supplierFinancials->getLevel()}
"; // int|null Specifies the dimension level. Normally the level of suppliers is level 2. Read-only attribute. + echo "MatchType: {$supplierFinancials->getMatchType()}
"; // MatchType|null Fixed value suppliersupplier. + echo "MeansOfPayment: {$supplierFinancials->getMeansOfPayment()}
"; // MeansOfPayment|null The option none is only allowed in case payavailable is set to false. The option paymentfile is only allowed in case payavailable is set to true. + + if ($supplierFinancials->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($supplierFinancials->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "PayAvailable (bool): {$supplierFinancials->getPayAvailable()}
"; // bool|null Determines if direct debit is possible. + echo "PayAvailable (string): {$supplierFinancials->getPayAvailableToString()}
"; // string|null + echo "PayCode (\\PhpTwinfield\\PayCode):
" . print_r($supplierFinancials->getPayCode(), true) . "

"; // PayCode|null The code of the payment type in case direct debit is possible. + echo "PayCode (string): {$supplierFinancials->getPayCodeToString()}
"; // string|null + echo "PayCodeID: {$supplierFinancials->getPayCodeID()}
"; // string|null + echo "RelationsReference: {$supplierFinancials->getRelationsReference()}
"; // string|null External supplier number. + echo "Result: {$supplierFinancials->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "SubAnalyse: {$supplierFinancials->getSubAnalyse()}
"; // SubAnalyse|null Fixed value false. + echo "SubstituteWith (\\PhpTwinfield\\Dummy):
" . print_r($supplierFinancials->getSubstituteWith(), true) . "

"; // Dummy|null Default supplier balancesheet account. + echo "SubstituteWith (string): {$supplierFinancials->getSubstituteWithToString()}
"; // string|null + echo "SubstituteWithID: {$supplierFinancials->getSubstituteWithID()}
"; // string|null + echo "SubstitutionLevel: {$supplierFinancials->getSubstitutionLevel()}
"; // int|null Level of the balancesheet account. Fixed value 1. + echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($supplierFinancials->getVatCode(), true) . "

"; // VatCode|null Default VAT code. + echo "VatCode (string): {$supplierFinancials->getVatCodeToString()}
"; // string|null + echo "VatCode Fixed (bool): {$supplierFinancials->getVatCodeFixed()}
"; // bool|null + echo "VatCode Fixed (string): {$supplierFinancials->getVatCodeFixedToString()}
"; // string|null + + $supplierChildValidations = $supplierFinancials->getChildValidations(); // array|null Array of SupplierChildValidations objects. + + foreach ($supplierChildValidations as $key => $supplierChildValidation) { + echo "SupplierChildValidation {$key}
"; + + echo "ElementValue: {$supplierChildValidation->getElementValue()}
"; // string|null + echo "Level: {$supplierChildValidation->getLevel()}
"; // int|null + + if ($supplierChildValidation->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($supplierChildValidation->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Result: {$supplierChildValidation->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Type: {$supplierChildValidation->getType()}
"; // ChildValidationType|null + } + + $supplierPostingRules = $supplier->getPostingRules(); // array|null Array of SupplierPostingRule objects. + + foreach ($supplierPostingRules as $key => $supplierPostingRule) { + echo "SupplierPostingRule {$key}
"; + + echo "Amount (\\Money\\Money):
" . print_r($supplierPostingRule->getAmount(), true) . "

"; // Money|null Amount. + echo "Amount (float): {$supplierPostingRule->getAmountToFloat()}
"; // float|null + echo "Currency (\\PhpTwinfield\\Currency):
" . print_r($supplierPostingRule->getCurrency(), true) . "

"; // Currency|null Currency. + echo "Currency (string): {$supplierPostingRule->getCurrencyToString()}
"; // string|null + echo "Description: {$supplierPostingRule->getDescription()}
"; // string|null Description. + echo "ID: {$supplierPostingRule->getID()}
"; // int|null Sequence number of the posting rule. Fixed value 1. + + if ($supplierPostingRule->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($supplierPostingRule->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Result: {$supplierPostingRule->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Status: {$supplierPostingRule->getStatus()}
"; // Status|null Status of the posting rule. + + $supplierLines = $supplierPostingRule->getLines(); // array|null Array of SupplierLine objects. + + foreach ($supplierLines as $key => $supplierLine) { + echo "SupplierLine {$key}
"; + + echo "Description: {$supplierLine->getDescription()}
"; // string|null Description. + echo "Dimension1 (\\PhpTwinfield\\GeneralLedger):
" . print_r($supplierLine->getDimension1(), true) . "

"; // GeneralLedger|null General ledger. + echo "Dimension1 (string): {$supplierLine->getDimension1ToString()}
"; // string|null + echo "Dimension1ID: {$supplierLine->getDimension1ID()}
"; // string|null + echo "Dimension2 (\\PhpTwinfield\\CostCenter):
" . print_r($supplierLine->getDimension2(), true) . "

"; // CostCenter|null Cost center. + echo "Dimension2 (string): {$supplierLine->getDimension2ToString()}
"; // string|null + echo "Dimension2ID: {$supplierLine->getDimension2ID()}
"; // string|null + echo "Dimension3 (\\PhpTwinfield\\Dummy):
" . print_r($supplierLine->getDimension3(), true) . "

"; // Dummy|null Project or asset. + echo "Dimension3 (string): {$supplierLine->getDimension3ToString()}
"; // string|null + echo "Dimension3ID: {$supplierLine->getDimension3ID()}
"; // string|null + + if ($supplierLine->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($supplierLine->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Office (\\PhpTwinfield\\Office):
" . print_r($supplierLine->getOffice(), true) . "

"; // Office|null Destination company. + echo "Office (string): {$supplierLine->getOfficeToString()}
"; // string|null + echo "Ratio: {$supplierLine->getRatio()}
"; // float|null The ratio of the posting rule line. + echo "Result: {$supplierLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($supplierLine->getVatCode(), true) . "

"; // VatCode|null VAT code. + echo "VatCode (string): {$supplierLine->getVatCodeToString()}
"; // string|null + } + } +} + +// Copy an existing Supplier to a new entity +if ($executeCopy) { + try { + $supplier = $supplierApiConnector->get("2000", $office); + } catch (ResponseException $e) { + $supplier = $e->getReturnedObject(); + } + + $supplier->setCode(null); // string|null Set to null to let Twinfield assign a Dimension code based on the Dimension type mask + //$supplier->setCode('2100'); // string|null Dimension code, must be compliant with the mask of the DEB Dimension type. + + //Twinfield does not accept BankID's on new entities + $supplierBanks = $supplier->getBanks(); + + foreach ($supplierBanks as $supplierBank) { + $supplierBank->setID(null); + } + + try { + $supplierCopy = $supplierApiConnector->send($supplier); + } catch (ResponseException $e) { + $supplierCopy = $e->getReturnedObject(); + } + + echo "
";
+    print_r($supplierCopy);
+    echo "
"; + + echo "Result of copy process: {$supplierCopy->getResult()}
"; + echo "Code of copied Supplier: {$supplierCopy->getCode()}
"; +} + +// Create a new Supplier from scratch, alternatively read an existing Supplier as shown above and than modify the values in the same way as shown below +if ($executeNew) { + $supplier = new \PhpTwinfield\Supplier; + + // Required values for creating a new Supplier + $supplier->setCode(null); // string|null Set to null to let Twinfield assign a Dimension code based on the Dimension type mask + //$supplier->setCode('2100'); // string|null Dimension code, must be compliant with the mask of the DEB Dimension type. + $supplier->setName("Example Supplier"); // string|null Name of the dimension. + $supplier->setOffice($office); // Office|null Office code. + $supplier->setOfficeFromString($officeCode); // string|null + + // Optional values for creating a new Supplier + $supplier->setBeginPeriod(0); // int|null Determines together with beginyear the period from which the dimension may be used. + $supplier->setBeginYear(0); // int|null Determines together with beginperiod the period from which the dimension may be used. + $supplier->setEndPeriod(0); // int|null Determines together with endyear the period till which the dimension may be used. + $supplier->setEndYear(0); // int|null Determines together with endperiod the period till which the dimension may be used. + $supplier->setShortName("ExmplCust"); // string|null Short name of the dimension. + //$supplier->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. + //$supplier->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case a dimension that is used in a transaction is deleted, its status has been changed into hide. Hidden dimensions can be activated by using active. + //$supplier->setStatusFromString('active'); // string|null + //$supplier->setStatusFromString('deleted'); // string|null + $supplier->setWebsite("www.example.com"); // string|null Website of the dimension. + + $dimensionGroup = new \PhpTwinfield\DimensionGroup; + $dimensionGroup->setCode('DIMGROUP'); + //$supplier->setGroup($dimensionGroup); // DimensionGroup|null Sets the dimension group. See Dimension group. + //$supplier->setGroupFromString("DIMGROUP"); // string|null + + $supplier->setPaymentConditionDiscountDays(3); // int|null Number of discount days. + $supplier->setPaymentConditionDiscountPercentage(25); // int|null Discount percentage. + + $supplier->setRemittanceAdviceSendMail("test@example.com"); // string|null Mandatory if sendtype = ByEmail, remittance advice will be sent using this e-mail address. + $supplier->setRemittanceAdviceSendType(\PhpTwinfield\Enums\RemittanceAdviceSendType::BYEMAIL()); // RemittanceAdviceSendMail|null To file manager, By e-mail + $supplier->setRemittanceAdviceSendTypeFromString('ByEmail'); // string|null + + $supplierFinancials = new \PhpTwinfield\SupplierFinancials; + $supplierFinancials->setDueDays(14); // int|null The number of due days. + $supplierFinancials->setMeansOfPayment(\PhpTwinfield\Enums\MeansOfPayment::PAYMENTFILE()); // MeansOfPayment|null The option none is only allowed in case payavailable is set to false. The option paymentfile is only allowed in case payavailable is set to true. + $supplierFinancials->setMeansOfPaymentFromString('paymentfile'); // string|null + $supplierFinancials->setPayAvailable(true); // bool|null Determines if direct debit is possible. + $supplierFinancials->setPayAvailableFromString('true'); // string|null + $payCode = new \PhpTwinfield\PayCode; + $payCode->setCode('SEPANLCT'); + $supplierFinancials->setPayCode($payCode); // PayCode|null The code of the payment type in case direct debit is possible. + $supplierFinancials->setPayCodeFromString('SEPANLCT'); // string|null + $substituteWith = new \PhpTwinfield\GeneralLedger; + $substituteWith->getCode('1535'); + $supplierFinancials->setSubstituteWith($substituteWith); // GeneralLedger|null Default supplier balancesheet account. + $supplierFinancials->setSubstituteWithFromString('1535'); // string|null + $vatCode = new \PhpTwinfield\VatCode; + $vatCode->setCode('IH'); + $supplierFinancials->setVatCode($vatCode); // VatCode|null Default VAT code. + $supplierFinancials->setVatCodeFromString('IH'); // string|null + + $supplier->setFinancials($supplierFinancials); // SupplierFinancials Set the SupplierFinancials object tot the Supplier object + + $supplierAddress = new \PhpTwinfield\SupplierAddress; + $supplierAddress->setCity('Amsterdam'); // string|null City. + $country = new \PhpTwinfield\Country; + $country->setCode('NL'); + $supplierAddress->setCountry($country); // Country|null Country code. The ISO country codes are used. + $supplierAddress->setCountryFromString('NL'); // string|null + $supplierAddress->setDefault(true); // bool|null Is this the default address, only one default address is possible. + $supplierAddress->setDefaultFromString('true'); // string|null + $supplierAddress->setEmail('test@example.com'); // string|null + $supplierAddress->setField1(''); // string|null User defined fields, the labels are configured in the Dimension type. + $supplierAddress->setField2(''); // string|null User defined fields, the labels are configured in the Dimension type. + $supplierAddress->setField3(''); // string|null User defined fields, the labels are configured in the Dimension type. + $supplierAddress->setField4(null); // string|null User defined fields, the labels are configured in the Dimension type. Currently, field4 is reserved for VAT numbers. So only valid VAT numbers may be filled in. + $supplierAddress->setField5(''); // string|null User defined fields, the labels are configured in the Dimension type. + $supplierAddress->setField6(''); // string|null User defined fields, the labels are configured in the Dimension type. + $supplierAddress->setID(1); // string|null Sequence number of the address line. + $supplierAddress->setName('Example Supplier'); // string|null Company name. + $supplierAddress->setPostcode('9876YZ'); // string|null Postcode. + $supplierAddress->setTelefax('012-3456789'); // string|null Fax number. + $supplierAddress->setTelephone('987-654321'); // string|null Telephone number. + $supplierAddress->setType(\PhpTwinfield\Enums\AddressType::INVOICE()); // AddressType|null The type of the address. + $supplierAddress->setTypeFromString('invoice'); // string|null + + $supplier->addAddress($supplierAddress); // SupplierAddress Add a SupplierAddress object to the Supplier object + //$supplier->removeAddress(0); // int Remove an address based on the index of the address within the array + + $supplierBank = new \PhpTwinfield\SupplierBank; + $supplierBank->setAccountNumber('123456789'); // string|null Account number. + $supplierBank->setAddressField2('Example Street'); // string|null Bank address. + $supplierBank->setAddressField3('12'); // string|null Bank address number. + $supplierBank->setAscription('Example Supplier'); // string|null Account holder. + $supplierBank->setBankName('Example Bank'); // string|null Bank name. + $supplierBank->setBicCode('ABNANL2A'); // string|null BIC code. + $supplierBank->setBlocked(false); // bool|null + $supplierBank->setBlockedFromString('false'); // string|null + $supplierBank->setCity('Amsterdam'); // string|null City. + $country = new \PhpTwinfield\Country; + $country->setCode('NL'); + $supplierBank->setCountry($country); // Country|null Bank country code. The ISO country codes are used. + $supplierBank->setCountryFromString('NL'); // string|null + $supplierBank->setDefault(true); // bool|null Is this the default bank account, only one default bank account is possible. + $supplierBank->setDefaultFromString('true'); // string|null + $supplierBank->setID(null); // int|null Sequence number of the bank account line. When adding a new bank, do not supply the @id. When changing a bank account, supply the corresponding @id. + $supplierBank->setIban(null); // string|null IBAN account number. + $supplierBank->setNatBicCode('NL'); // string|null National bank code. + $supplierBank->setPostcode('1234AB'); // string|null Postcode. + $supplierBank->setState('Noord-Holland'); // string|null State. + + $supplier->addBank($supplierBank); // SupplierBank Add a SupplierBank object to the Supplier object + //$supplier->removeBank(0); // int Remove a bank based on the index of the bank within the array + + $supplierPostingRule = new \PhpTwinfield\SupplierPostingRule; + $supplierPostingRule->setAmount(\Money\Money::EUR(10000)); // Money|null Amount. + $supplierPostingRule->setAmountFromFloat(100); // float|null + $currency = new \PhpTwinfield\Currency; + $currency->setCode('EUR'); + $supplierPostingRule->setCurrency($currency); // Currency|null Currency. + $supplierPostingRule->setCurrencyFromString('EUR'); // string|null + $supplierPostingRule->setDescription('Example PostingRule'); // string|null Description. + $supplierPostingRule->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating active should be used. For deleting deleted should be used. + //$supplierPostingRule->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null + $supplierPostingRule->setStatusFromString('active'); // string|null + //$supplierPostingRule->setStatusFromString('deleted'); // string|null + + $supplierLine = new \PhpTwinfield\SupplierLine; + $supplierLine->setDescription('Example Line'); // string|null Description. + $dimension1 = new \PhpTwinfield\GeneralLedger; + $dimension1->setCode('1535'); + $supplierLine->setDimension1($dimension1); // GeneralLedger|null General ledger. + $supplierLine->setDimension1FromString('1535'); // string|null + $costCenter = new \PhpTwinfield\CostCenter; + $costCenter->setCode('00000'); + $supplierLine->setDimension2($costCenter); // CostCenter|null Cost center. + $supplierLine->setDimension2FromString ('00000'); // string|null + $activity = new \PhpTwinfield\Activity; + $activity->setCode('P0000'); + $supplierLine->setDimension3($activity); // Dummy|null Project or asset. + $supplierLine->setDimension3FromString('P0000'); // string|null + $destOffice = new \PhpTwinfield\Office; + $destOffice->setCode('NLA0000001'); + //$supplierLine->setOffice($destOffice); // Office|null Destination company. + //$supplierLine->setOfficeFromString('NLA0000001'); // string|null + $supplierLine->setRatio(1); // float|null The ratio of the posting rule line. + $vatCode = new \PhpTwinfield\VatCode; + $vatCode->setCode('IH'); + $supplierLine->setVatCode($vatCode); // VatCode|null Default VAT code. + $supplierLine->setVatCodeFromString('IH'); // string|null + + $supplierPostingRule->addLine($supplierLine); // SupplierLine Add a SupplierLine object to the SupplierPostingRule object + //$supplierPostingRule->removeLine(0); // int Remove a line based on the index of the line within the array + + $supplier->addPostingRule($supplierPostingRule); // SupplierPostingRule Add a SupplierPostingRule object to the Supplier object + //$supplier->removePostingRule(0); // int Remove a posting rule based on the index of the posting rule within the array + + try { + $supplierNew = $supplierApiConnector->send($supplier); + } catch (ResponseException $e) { + $supplierNew = $e->getReturnedObject(); + } + + echo "
";
+    print_r($supplierNew);
+    echo "
"; + + echo "Result of creation process: {$supplierNew->getResult()}
"; + echo "Code of new Supplier: {$supplierNew->getCode()}
"; +} + +// Delete a Supplier based off the passed in code and optionally the office. +if ($executeDelete) { + try { + $supplierDeleted = $supplierApiConnector->delete("2004", $office); + } catch (ResponseException $e) { + $supplierDeleted = $e->getReturnedObject(); + } + + echo "
";
+    print_r($supplierDeleted);
+    echo "
"; + + echo "Result of deletion process: {$supplierDeleted->getResult()}
"; +} \ No newline at end of file diff --git a/examples/VatCode.php b/examples/VatCode.php index 8a8659bc..3d2e4a80 100644 --- a/examples/VatCode.php +++ b/examples/VatCode.php @@ -238,7 +238,7 @@ // The minimum amount of VatCodePercentages linked to a VatCode object is 0 $vatCodePercentage = new \PhpTwinfield\VatCodePercentage; $date = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); - $vatCodePercentage->setDate($date); // \DateTimeInterface|null Effective date. + $vatCodePercentage->setDate($date); // DateTimeInterface|null Effective date. $vatCodePercentage->setDateFromString('20190101'); // string|null $vatCodePercentage->setName("BTW 21%"); // string|null Name of the VAT line. $vatCodePercentage->setPercentage(21); // float|null Percentage of the VAT line. @@ -266,7 +266,7 @@ $vatCodeAccount->setPercentage(100); // float|null Percentage of the VAT line. $vatCodePercentage->addAccount($vatCodeAccount); // VatCodeAccount Add a VatCodeAccount object to the VatCodePercentage object - //$vatCodePercentage->removeAccount(1); // int Remove an account based on the id of the account + //$vatCodePercentage->removeAccount(0); // int Remove an account based on the index of the account $vatCode->addPercentage($vatCodePercentage); // VatCodePercentage Add a VatCodePercentage object to the VatCode object //$vatCode->removePercentage(0); // int Remove a percentage based on the index of the percentage within the array diff --git a/src/Article.php b/src/Article.php index 783a5822..d4f9a740 100644 --- a/src/Article.php +++ b/src/Article.php @@ -60,14 +60,14 @@ public function getLines() public function addLine(ArticleLine $line) { - $this->lines[$line->getID()] = $line; + $this->lines[] = $line; return $this; } - public function removeLine($id) + public function removeLine($index) { - if (array_key_exists($id, $this->lines)) { - unset($this->lines[$id]); + if (array_key_exists($index, $this->lines)) { + unset($this->lines[$index]); return true; } else { return false; diff --git a/src/AssetMethod.php b/src/AssetMethod.php index 820b1923..df3789c1 100644 --- a/src/AssetMethod.php +++ b/src/AssetMethod.php @@ -78,14 +78,14 @@ public function getFreeTexts() public function addFreeText(AssetMethodFreeText $freeText) { - $this->freeTexts[$freeText->getID()] = $freeText; + $this->freeTexts[] = $freeText; return $this; } - public function removeFreeText($id) + public function removeFreeText($index) { - if (array_key_exists($id, $this->freeTexts)) { - unset($this->freeTexts[$id]); + if (array_key_exists($index, $this->freeTexts)) { + unset($this->freeTexts[$index]); return true; } else { return false; diff --git a/src/Customer.php b/src/Customer.php index 8f34ec8a..3d230f32 100644 --- a/src/Customer.php +++ b/src/Customer.php @@ -102,14 +102,14 @@ public function getAddresses() public function addAddress(CustomerAddress $address) { - $this->addresses[$address->getID()] = $address; + $this->addresses[] = $address; return $this; } - public function removeAddress($id) + public function removeAddress($index) { - if (array_key_exists($id, $this->addresses)) { - unset($this->addresses[$id]); + if (array_key_exists($index, $this->addresses)) { + unset($this->addresses[$index]); return true; } else { return false; @@ -123,14 +123,14 @@ public function getBanks() public function addBank(CustomerBank $bank) { - $this->banks[$bank->getID()] = $bank; + $this->banks[] = $bank; return $this; } - public function removeBank($id) + public function removeBank($index) { - if (array_key_exists($id, $this->banks)) { - unset($this->banks[$id]); + if (array_key_exists($index, $this->banks)) { + unset($this->banks[$index]); return true; } else { return false; @@ -144,14 +144,14 @@ public function getPostingRules() public function addPostingRule(CustomerPostingRule $postingRule) { - $this->postingRules[$postingRule->getID()] = $postingRule; + $this->postingRules[] = $postingRule; return $this; } - public function removePostingRule($id) + public function removePostingRule($index) { - if (array_key_exists($id, $this->postingRules)) { - unset($this->postingRules[$id]); + if (array_key_exists($index, $this->postingRules)) { + unset($this->postingRules[$index]); return true; } else { return false; diff --git a/src/CustomerPostingRule.php b/src/CustomerPostingRule.php index 3b37b448..ab7fa3a9 100644 --- a/src/CustomerPostingRule.php +++ b/src/CustomerPostingRule.php @@ -22,6 +22,11 @@ class CustomerPostingRule extends BaseObject private $lines = []; + public function __construct() + { + $this->setID(1); + } + public function getLines() { return $this->lines; diff --git a/src/Fields/Invoice/QuantityField.php b/src/Fields/Invoice/QuantityField.php index c601b209..cdcee930 100644 --- a/src/Fields/Invoice/QuantityField.php +++ b/src/Fields/Invoice/QuantityField.php @@ -8,23 +8,23 @@ trait QuantityField * Quantity field * Used by: InvoiceLine * - * @var int|null + * @var float|null */ private $quantity; /** - * @return null|int + * @return null|float */ - public function getQuantity(): ?int + public function getQuantity(): ?float { return $this->quantity; } /** - * @param null|int $quantity + * @param null|float $quantity * @return $this */ - public function setQuantity(?int $quantity): self + public function setQuantity(?float $quantity): self { $this->quantity = $quantity; return $this; diff --git a/src/Invoice.php b/src/Invoice.php index 9466d44a..4f8aa451 100644 --- a/src/Invoice.php +++ b/src/Invoice.php @@ -99,14 +99,14 @@ public function getLines(): array public function addLine(InvoiceLine $line) { - $this->lines[$line->getID()] = $line; + $this->lines[] = $line; return $this; } - public function removeLine($id) + public function removeLine($index) { - if (array_key_exists($id, $this->lines)) { - unset($this->lines[$id]); + if (array_key_exists($index, $this->lines)) { + unset($this->lines[$index]); return true; } else { return false; diff --git a/src/Rate.php b/src/Rate.php index 0d32f077..01e6ad7c 100644 --- a/src/Rate.php +++ b/src/Rate.php @@ -44,14 +44,14 @@ public function getRateChanges() public function addRateChange(RateRateChange $rateChange) { - $this->rateChanges[$rateChange->getID()] = $rateChange; + $this->rateChanges[] = $rateChange; return $this; } - public function removeRateChange($id) + public function removeRateChange($index) { - if (array_key_exists($id, $this->rateChanges)) { - unset($this->rateChanges[$id]); + if (array_key_exists($index, $this->rateChanges)) { + unset($this->rateChanges[$index]); return true; } else { return false; diff --git a/src/Supplier.php b/src/Supplier.php index c605763b..1c2e9c63 100644 --- a/src/Supplier.php +++ b/src/Supplier.php @@ -89,14 +89,14 @@ public function getAddresses() public function addAddress(SupplierAddress $address) { - $this->addresses[$address->getID()] = $address; + $this->addresses[] = $address; return $this; } - public function removeAddress($id) + public function removeAddress($index) { - if (array_key_exists($id, $this->addresses)) { - unset($this->addresses[$id]); + if (array_key_exists($index, $this->addresses)) { + unset($this->addresses[$index]); return true; } else { return false; @@ -110,14 +110,14 @@ public function getBanks() public function addBank(SupplierBank $bank) { - $this->banks[$bank->getID()] = $bank; + $this->banks[] = $bank; return $this; } - public function removeBank($id) + public function removeBank($index) { - if (array_key_exists($id, $this->banks)) { - unset($this->banks[$id]); + if (array_key_exists($index, $this->banks)) { + unset($this->banks[$index]); return true; } else { return false; @@ -131,14 +131,14 @@ public function getPostingRules() public function addPostingRule(SupplierPostingRule $postingRule) { - $this->postingRules[$postingRule->getID()] = $postingRule; + $this->postingRules[] = $postingRule; return $this; } - public function removePostingRule($id) + public function removePostingRule($index) { - if (array_key_exists($id, $this->postingRules)) { - unset($this->postingRules[$id]); + if (array_key_exists($index, $this->postingRules)) { + unset($this->postingRules[$index]); return true; } else { return false; diff --git a/src/VatCodePercentage.php b/src/VatCodePercentage.php index e99b78db..34dd28ae 100644 --- a/src/VatCodePercentage.php +++ b/src/VatCodePercentage.php @@ -31,14 +31,14 @@ public function getAccounts() public function addAccount(VatCodeAccount $account) { - $this->accounts[$account->getID()] = $account; + $this->accounts[] = $account; return $this; } - public function removeAccount($id) + public function removeAccount($index) { - if (array_key_exists($id, $this->accounts)) { - unset($this->accounts[$id]); + if (array_key_exists($index, $this->accounts)) { + unset($this->accounts[$index]); return true; } else { return false; From 9c32f2f0ccec0b7b89fb02320d53a2b43557e9b0 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 9 Jun 2019 13:18:51 +0200 Subject: [PATCH 278/388] Upload --- tests/IntegrationTests/CustomerIntegrationTest.php | 8 ++++---- tests/IntegrationTests/InvoiceIntegrationTest.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 4c4f5b46..3d9c5abd 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -74,10 +74,10 @@ public function testGetCustomerWorks() // Addresses $addresses = $customer->getAddresses(); $this->assertCount(1, $addresses); - $this->assertArrayHasKey('1', $addresses); + $this->assertArrayHasKey(0, $addresses); /** @var CustomerAddress $address */ - $address = $addresses['1']; + $address = $addresses[0]; $this->assertSame(1, $address->getID()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\AddressType'); @@ -100,10 +100,10 @@ public function testGetCustomerWorks() // Banks $banks = $customer->getBanks(); $this->assertCount(1, $banks); - $this->assertArrayHasKey('-1', $banks); + $this->assertArrayHasKey(0, $banks); /** @var CustomerBank $bank */ - $bank = $banks['-1']; + $bank = $banks[0]; $this->assertSame(-1, $bank->getID()); $this->assertSame(true, $bank->getDefault()); diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index cfc357e5..432e94c0 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -83,10 +83,10 @@ public function testGetConceptInvoiceWorks() $invoiceLines = $invoice->getLines(); $this->assertCount(1, $invoiceLines); - $this->assertArrayHasKey('1', $invoiceLines); + $this->assertArrayHasKey(0, $invoiceLines); /** @var InvoiceLine $invoiceLine */ - $invoiceLine = $invoiceLines['1']; + $invoiceLine = $invoiceLines[0]; $this->assertSame(1, $invoiceLine->getID()); $this->assertSame('0', $invoiceLine->getArticleToString()); @@ -151,10 +151,10 @@ public function testGetFinalInvoiceWorks() $invoiceLines = $invoice->getLines(); $this->assertCount(1, $invoiceLines); - $this->assertArrayHasKey('1', $invoiceLines); + $this->assertArrayHasKey(0, $invoiceLines); /** @var InvoiceLine $invoiceLine */ - $invoiceLine = $invoiceLines['1']; + $invoiceLine = $invoiceLines[0]; $this->assertSame(1, $invoiceLine->getID()); $this->assertSame('0', $invoiceLine->getArticleToString()); From 35dcfdce6da93dc590b07c9f9dfe5e1cf65a5ae0 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 9 Jun 2019 13:46:17 +0200 Subject: [PATCH 279/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 432e94c0..61d12b15 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -91,7 +91,7 @@ public function testGetConceptInvoiceWorks() $this->assertSame(1, $invoiceLine->getID()); $this->assertSame('0', $invoiceLine->getArticleToString()); $this->assertSame('118', $invoiceLine->getSubArticleToString()); - $this->assertSame(1, $invoiceLine->getQuantity()); + $this->assertSame(1.0, $invoiceLine->getQuantity()); $this->assertSame(1, $invoiceLine->getUnits()); $this->assertSame(true, $invoiceLine->getAllowDiscountOrPremium()); $this->assertSame('CoalesceFunctioningOnImpatienceTShirt', $invoiceLine->getDescription()); @@ -159,7 +159,7 @@ public function testGetFinalInvoiceWorks() $this->assertSame(1, $invoiceLine->getID()); $this->assertSame('0', $invoiceLine->getArticleToString()); $this->assertSame('118', $invoiceLine->getSubArticleToString()); - $this->assertSame(1, $invoiceLine->getQuantity()); + $this->assertSame(1.0, $invoiceLine->getQuantity()); $this->assertSame(1, $invoiceLine->getUnits()); $this->assertSame(true, $invoiceLine->getAllowDiscountOrPremium()); $this->assertSame('CoalesceFunctioningOnImpatienceTShirt', $invoiceLine->getDescription()); From b1ea92ff7398d40f1ece5e387d1bc9855e0a05be Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 10 Jun 2019 16:34:15 +0200 Subject: [PATCH 280/388] Upload --- examples/Customer.php | 2 +- examples/GeneralLedger.php | 292 +++++++++++++++++++++++++++++++++++++ examples/Supplier.php | 4 +- 3 files changed, 295 insertions(+), 3 deletions(-) create mode 100644 examples/GeneralLedger.php diff --git a/examples/Customer.php b/examples/Customer.php index ea60155c..c358fca3 100644 --- a/examples/Customer.php +++ b/examples/Customer.php @@ -176,7 +176,7 @@ } } -// Read an Customer based off the passed in code and optionally the office. +// Read a Customer based off the passed in code and optionally the office. if ($executeRead) { try { $customer = $customerApiConnector->get("1000", $office); diff --git a/examples/GeneralLedger.php b/examples/GeneralLedger.php new file mode 100644 index 00000000..cc91d78e --- /dev/null +++ b/examples/GeneralLedger.php @@ -0,0 +1,292 @@ + dimtype = 'BAS' +if ($executeListAllWithFilter) { + $options = array('dimtype' => 'BAS'); + + try { + $generalLedgers = $generalLedgerApiConnector->listAll("1*", 0, 1, 10, $options); + } catch (ResponseException $e) { + $generalLedgers = $e->getReturnedObject(); + } + + echo "
";
+    print_r($generalLedgers);
+    echo "
"; +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +if ($executeListAllWithoutFilter) { + try { + $generalLedgers = $generalLedgerApiConnector->listAll(); + } catch (ResponseException $e) { + $generalLedgers = $e->getReturnedObject(); + } + + echo "
";
+    print_r($generalLedgers);
+    echo "
"; +} + +/* GeneralLedger + * \PhpTwinfield\GeneralLedger + * Available getters: getBeginPeriod, getBeginYear, getBehaviour, getCode, getEndPeriod, getEndYear, getGroup, getGroupToString, getInUse, getInUseToString, getMessages, getName, getOffice, getOfficeToString, getResult, getShortName, getStatus, getTouched, getType, getTypeToString, getWebsite, hasMessages, getFinancials + * Available setters: setBeginPeriod, setBeginYear, setBehaviour, setBehaviourFromString, setCode, setEndPeriod, setEndYear, setGroup, setGroupFromString, setName, setOffice, setOfficeFromString, setShortName, setStatus, setStatusFromString, setType, setTypeFromString, setFinancials + */ + +/* GeneralLedgerFinancials + * \PhpTwinfield\GeneralLedgerFinancials + * Available getters: getAccountType, getLevel, getMatchType, getMessages, getResult, getSubAnalyse, getVatCode, getVatCodeFixed, getVatCodeFixedToString, getVatCodeToString, getChildValidations, hasMessages + * Available setters: setAccountType, setAccountTypeFromString, setLevel, setMatchType, setMatchTypeFromString, setSubAnalyse, setSubAnalyseFromString, setVatCode, setVatCodeFixed, setVatCodeFixedFromString, setVatCodeFromString, addChildValidation, removeChildValidation + */ + +/* GeneralLedgerChildValidation + * \PhpTwinfield\GeneralLedgerChildValidation + * Available getters: getElementValue, getLevel, getMessages, getResult, getType, hasMessages + * Available setters: setElementValue, setLevel, setType, setTypeFromString + */ + +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($generalLedgers as $key => $generalLedger) { + echo "GeneralLedger {$key}
"; + echo "Code: {$generalLedger->getCode()}
"; + echo "Name: {$generalLedger->getName()}

"; + } +} + +// Read a GeneralLedger based off the passed in code and optionally the office. +if ($executeRead) { + try { + $generalLedger = $generalLedgerApiConnector->get("1000", $office); + } catch (ResponseException $e) { + $generalLedger = $e->getReturnedObject(); + } + + echo "
";
+    print_r($generalLedger);
+    echo "
"; + + echo "GeneralLedger
"; + echo "BeginPeriod: {$generalLedger->getBeginPeriod()}
"; // int|null Determines together with beginyear the period from which the dimension may be used. + echo "BeginYear: {$generalLedger->getBeginYear()}
"; // int|null Determines together with beginperiod the period from which the dimension may be used. + echo "Behaviour: {$generalLedger->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. + echo "Code: {$generalLedger->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the BAS or PNL Dimension type. + echo "EndPeriod: {$generalLedger->getEndPeriod()}
"; // int|null Determines together with endyear the period till which the dimension may be used. + echo "EndYear: {$generalLedger->getEndYear()}
"; // int|null Determines together with endperiod the period till which the dimension may be used. + echo "Group (\\PhpTwinfield\\DimensionGroup):
" . print_r($generalLedger->getGroup(), true) . "

"; // DimensionGroup|null Sets the dimension group. See Dimension group. + echo "Group (string): {$generalLedger->getGroupToString()}
"; // string|null + echo "InUse (bool): {$generalLedger->getInUse()}
"; // bool|null Indicates if the balance or profit and loss account is used in a financial transaction or linked to a VAT code or linked to an article or not in use at all. Read-only attribute. + echo "InUse (string): {$generalLedger->getInUseToString()}
"; // string|null + + if ($generalLedger->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($generalLedger->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Name: {$generalLedger->getName()}
"; // string|null Name of the dimension. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($generalLedger->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): {$generalLedger->getOfficeToString()}
"; // string|null + echo "Result: {$generalLedger->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$generalLedger->getShortName()}
"; // string|null Short name of the dimension. + echo "Status: {$generalLedger->getStatus()}
"; // Status|null Status of the generalLedger. + echo "Touched: {$generalLedger->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. + echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($generalLedger->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of balance accounts is BAS and type of profit and loss is PNL. + echo "Type (string): {$generalLedger->getTypeToString()}
"; // string|null + echo "UID: {$generalLedger->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. + + echo "GeneralLedgerFinancials
"; + $generalLedgerFinancials = $generalLedger->getFinancials(); // GeneralLedgerFinancials|null GeneralLedgerFinancials object. + + echo "AccountType: {$generalLedgerFinancials->getAccountType()}
"; // AccountType|null Fixed value balance. + echo "Level: {$generalLedgerFinancials->getLevel()}
"; // int|null Specifies the dimension level. Normally the level of balance accounts is level 1. Read-only attribute. + echo "MatchType: {$generalLedgerFinancials->getMatchType()}
"; // MatchType|null Sets the matchable value of the balance account. + + if ($generalLedgerFinancials->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($generalLedgerFinancials->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Result: {$generalLedgerFinancials->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "SubAnalyse: {$generalLedgerFinancials->getSubAnalyse()}
"; // SubAnalyse|null Is subanalyses needed. + echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($generalLedgerFinancials->getVatCode(), true) . "

"; // VatCode|null Default VAT code. + echo "VatCode (string): {$generalLedgerFinancials->getVatCodeToString()}
"; // string|null + echo "VatCode Fixed (bool): {$generalLedgerFinancials->getVatCodeFixed()}
"; // bool|null + echo "VatCode Fixed (string): {$generalLedgerFinancials->getVatCodeFixedToString()}
"; // string|null + + $generalLedgerChildValidations = $generalLedgerFinancials->getChildValidations(); // array|null Array of GeneralLedgerChildValidations objects. Validation rule when subanalyses is needed. + + foreach ($generalLedgerChildValidations as $key => $generalLedgerChildValidation) { + echo "GeneralLedgerChildValidation {$key}
"; + + echo "ElementValue: {$generalLedgerChildValidation->getElementValue()}
"; // string|null + echo "Level: {$generalLedgerChildValidation->getLevel()}
"; // int|null + + if ($generalLedgerChildValidation->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($generalLedgerChildValidation->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Result: {$generalLedgerChildValidation->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Type: {$generalLedgerChildValidation->getType()}
"; // ChildValidationType|null + } +} + +// Copy an existing GeneralLedger to a new entity +if ($executeCopy) { + try { + $generalLedger = $generalLedgerApiConnector->get("1000", $office); + } catch (ResponseException $e) { + $generalLedger = $e->getReturnedObject(); + } + + $generalLedger->setCode(null); // string|null Set to null to let Twinfield assign a Dimension code based on the Dimension type mask + //$generalLedger->setCode('1100'); // string|null Dimension code, must be compliant with the mask of the BAS or PNL Dimension type. + + try { + $generalLedgerCopy = $generalLedgerApiConnector->send($generalLedger); + } catch (ResponseException $e) { + $generalLedgerCopy = $e->getReturnedObject(); + } + + echo "
";
+    print_r($generalLedgerCopy);
+    echo "
"; + + echo "Result of copy process: {$generalLedgerCopy->getResult()}
"; + echo "Code of copied GeneralLedger: {$generalLedgerCopy->getCode()}
"; +} + +// Create a new GeneralLedger from scratch, alternatively read an existing GeneralLedger as shown above and than modify the values in the same way as shown below +if ($executeNew) { + $generalLedger = new \PhpTwinfield\GeneralLedger; + + // Required values for creating a new GeneralLedger + $generalLedger->setCode(null); // string|null Set to null to let Twinfield assign a Dimension code based on the Dimension type mask + //$generalLedger->setCode('1100'); // string|null Dimension code, must be compliant with the mask of the BAS or PNL Dimension type. + $generalLedger->setName("Example GeneralLedger"); // string|null Name of the dimension. + $generalLedger->setOffice($office); // Office|null Office code. + $generalLedger->setOfficeFromString($officeCode); // string|null + + // Optional values for creating a new GeneralLedger + $generalLedger->setBeginPeriod(0); // int|null Determines together with beginyear the period from which the dimension may be used. + $generalLedger->setBeginYear(0); // int|null Determines together with beginperiod the period from which the dimension may be used. + $generalLedger->setEndPeriod(0); // int|null Determines together with endyear the period till which the dimension may be used. + $generalLedger->setEndYear(0); // int|null Determines together with endperiod the period till which the dimension may be used. + $generalLedger->setShortName("ExmplCust"); // string|null Short name of the dimension. + //$generalLedger->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. + //$generalLedger->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case a dimension that is used in a transaction is deleted, its status has been changed into hide. Hidden dimensions can be activated by using active. + //$generalLedger->setStatusFromString('active'); // string|null + //$generalLedger->setStatusFromString('deleted'); // string|null + + $dimensionGroup = new \PhpTwinfield\DimensionGroup; + $dimensionGroup->setCode('DIMGROUP'); + //$generalLedger->setGroup($dimensionGroup); // DimensionGroup|null Sets the dimension group. See Dimension group. + //$generalLedger->setGroupFromString("DIMGROUP"); // string|null + + $generalLedgerFinancials = new \PhpTwinfield\GeneralLedgerFinancials; + $vatCode = new \PhpTwinfield\VatCode; + $vatCode->setCode('VH'); + $generalLedgerFinancials->setVatCode($vatCode); // VatCode|null Default VAT code. + $generalLedgerFinancials->setVatCodeFromString('VH'); // string|null + + $generalLedger->setFinancials($generalLedgerFinancials); // GeneralLedgerFinancials Set the GeneralLedgerFinancials object tot the GeneralLedger object + + try { + $generalLedgerNew = $generalLedgerApiConnector->send($generalLedger); + } catch (ResponseException $e) { + $generalLedgerNew = $e->getReturnedObject(); + } + + echo "
";
+    print_r($generalLedgerNew);
+    echo "
"; + + echo "Result of creation process: {$generalLedgerNew->getResult()}
"; + echo "Code of new GeneralLedger: {$generalLedgerNew->getCode()}
"; +} + +// Delete a GeneralLedger based off the passed in code and optionally the office. +if ($executeDelete) { + try { + $generalLedgerDeleted = $generalLedgerApiConnector->delete("1003", $office); + } catch (ResponseException $e) { + $generalLedgerDeleted = $e->getReturnedObject(); + } + + echo "
";
+    print_r($generalLedgerDeleted);
+    echo "
"; + + echo "Result of deletion process: {$generalLedgerDeleted->getResult()}
"; +} \ No newline at end of file diff --git a/examples/Supplier.php b/examples/Supplier.php index 507f79e7..81efab14 100644 --- a/examples/Supplier.php +++ b/examples/Supplier.php @@ -164,7 +164,7 @@ } } -// Read an Supplier based off the passed in code and optionally the office. +// Read a Supplier based off the passed in code and optionally the office. if ($executeRead) { try { $supplier = $supplierApiConnector->get("2000", $office); @@ -279,7 +279,7 @@ echo "AccountType: {$supplierFinancials->getAccountType()}
"; // AccountType|null Fixed value inherit. echo "DueDays: {$supplierFinancials->getDueDays()}
"; // int|null The number of due days. echo "Level: {$supplierFinancials->getLevel()}
"; // int|null Specifies the dimension level. Normally the level of suppliers is level 2. Read-only attribute. - echo "MatchType: {$supplierFinancials->getMatchType()}
"; // MatchType|null Fixed value suppliersupplier. + echo "MatchType: {$supplierFinancials->getMatchType()}
"; // MatchType|null Fixed value customersupplier. echo "MeansOfPayment: {$supplierFinancials->getMeansOfPayment()}
"; // MeansOfPayment|null The option none is only allowed in case payavailable is set to false. The option paymentfile is only allowed in case payavailable is set to true. if ($supplierFinancials->hasMessages()) { // bool Object contains (error) messages true/false. From ca3f809dac8691612411371b32adaffa3e57e622 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 10 Jun 2019 18:06:18 +0200 Subject: [PATCH 281/388] Upload --- src/Mappers/ActivityMapper.php | 28 +++--- src/Mappers/ArticleMapper.php | 40 ++++---- src/Mappers/AssetMethodMapper.php | 20 ++-- src/Mappers/BrowseDataMapper.php | 8 +- src/Mappers/BrowseDefinitionMapper.php | 24 ++--- src/Mappers/BrowseFieldMapper.php | 8 +- src/Mappers/CashBankBookMapper.php | 6 +- src/Mappers/CostCenterMapper.php | 12 +-- src/Mappers/CurrencyMapper.php | 10 +- src/Mappers/CustomerMapper.php | 128 ++++++++++++------------- src/Mappers/DimensionGroupMapper.php | 6 +- src/Mappers/DimensionTypeMapper.php | 24 ++--- src/Mappers/FixedAssetMapper.php | 60 ++++++------ src/Mappers/GeneralLedgerMapper.php | 30 +++--- src/Mappers/InvoiceMapper.php | 66 ++++++------- src/Mappers/InvoiceTypeMapper.php | 6 +- src/Mappers/MatchSetMapper.php | 14 +-- src/Mappers/OfficeMapper.php | 12 +-- src/Mappers/PayCodeMapper.php | 6 +- src/Mappers/ProjectMapper.php | 28 +++--- src/Mappers/RateMapper.php | 24 ++--- src/Mappers/SupplierMapper.php | 106 ++++++++++---------- src/Mappers/TransactionMapper.php | 124 ++++++++++++------------ src/Mappers/UserMapper.php | 26 ++--- src/Mappers/UserRoleMapper.php | 6 +- src/Mappers/VatCodeMapper.php | 30 +++--- src/Mappers/VatGroupCountryMapper.php | 6 +- src/Mappers/VatGroupMapper.php | 6 +- src/Request/Read/Read.php | 2 +- src/Secure/Provider/OAuthProvider.php | 12 ++- 30 files changed, 442 insertions(+), 436 deletions(-) diff --git a/src/Mappers/ActivityMapper.php b/src/Mappers/ActivityMapper.php index 9ff007b7..d0481c44 100644 --- a/src/Mappers/ActivityMapper.php +++ b/src/Mappers/ActivityMapper.php @@ -41,15 +41,15 @@ public static function map(Response $response) ->setStatus(self::parseEnumAttribute('Status', $activityElement->getAttribute('status'))); // Set the activity elements from the activity element - $activity->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($activity, $activityElement, 'behaviour'))) - ->setCode(self::getField($activity, $activityElement, 'code')) - ->setInUse(self::parseBooleanAttribute(self::getField($activity, $activityElement, 'name'))) - ->setName(self::getField($activity, $activityElement, 'name')) + $activity->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($activityElement, 'behaviour', $activity))) + ->setCode(self::getField($activityElement, 'code', $activity)) + ->setInUse(self::parseBooleanAttribute(self::getField($activityElement, 'name', $activity))) + ->setName(self::getField($activityElement, 'name', $activity)) ->setOffice(self::parseObjectAttribute('Office', $activity, $activityElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setShortName(self::getField($activity, $activityElement, 'shortname')) - ->setTouched(self::getField($activity, $activityElement, 'touched')) + ->setShortName(self::getField($activityElement, 'shortname', $activity)) + ->setTouched(self::getField($activityElement, 'touched', $activity)) ->setType(self::parseObjectAttribute('DimensionType', $activity, $activityElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setUID(self::getField($activity, $activityElement, 'uid')) + ->setUID(self::getField($activityElement, 'uid', $activity)) ->setVatCode(self::parseObjectAttribute('VatCode', $activity, $activityElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); // Get the projects element @@ -61,12 +61,12 @@ public static function map(Response $response) // Set the projects elements from the projects element $activityProjects->setAuthoriser(self::parseObjectAttribute('User', $activityProjects, $projectsElement, 'authoriser')) - ->setBillable(self::parseBooleanAttribute(self::getField($activityProjects, $projectsElement, 'billable'))) + ->setBillable(self::parseBooleanAttribute(self::getField($projectsElement, 'billable', $activityProjects))) ->setCustomer(self::parseObjectAttribute('Customer', $activityProjects, $projectsElement, 'customer')) - ->setInvoiceDescription(self::getField($activityProjects, $projectsElement, 'invoicedescription')) + ->setInvoiceDescription(self::getField($projectsElement, 'invoicedescription', $activityProjects)) ->setRate(self::parseObjectAttribute('Rate', $activityProjects, $projectsElement, 'rate')) - ->setValidFrom(self::parseDateAttribute(self::getField($activityProjects, $projectsElement, 'validfrom'))) - ->setValidTill(self::parseDateAttribute(self::getField($activityProjects, $projectsElement, 'validtill'))); + ->setValidFrom(self::parseDateAttribute(self::getField($projectsElement, 'validfrom', $activityProjects))) + ->setValidTill(self::parseDateAttribute(self::getField($projectsElement, 'validtill', $activityProjects))); // Set the projects elements from the projects element attributes $activityProjects->setAuthoriserInherit(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'authoriser', 'inherit'))) @@ -93,9 +93,9 @@ public static function map(Response $response) $activityQuantity = new ActivityQuantity(); // Set the quantity elements from the quantity element - $activityQuantity->setBillable(self::parseBooleanAttribute(self::getField($activityQuantity, $quantityElement, 'billable'))) - ->setLabel(self::getField($activityQuantity, $quantityElement, 'label')) - ->setMandatory(self::parseBooleanAttribute(self::getField($activityQuantity, $quantityElement, 'mandatory'))) + $activityQuantity->setBillable(self::parseBooleanAttribute(self::getField($quantityElement, 'billable', $activityQuantity))) + ->setLabel(self::getField($quantityElement, 'label', $activityQuantity)) + ->setMandatory(self::parseBooleanAttribute(self::getField($quantityElement, 'mandatory', $activityQuantity))) ->setRate(self::parseObjectAttribute('Rate', $activityQuantity, $quantityElement, 'rate')); // Set the quantity elements from the quantity element attributes diff --git a/src/Mappers/ArticleMapper.php b/src/Mappers/ArticleMapper.php index 3df96711..540fbcf9 100644 --- a/src/Mappers/ArticleMapper.php +++ b/src/Mappers/ArticleMapper.php @@ -45,20 +45,20 @@ public static function map(Response $response) $article->setStatus(self::parseEnumAttribute('Status', $headerElement->getAttribute('status'))); // Set the article elements from the header - $article->setAllowChangePerformanceType(self::parseBooleanAttribute(self::getField($article, $headerElement, 'allowchangeperformancetype'))) - ->setAllowChangeUnitsPrice(self::parseBooleanAttribute(self::getField($article, $headerElement, 'allowchangeunitsprice'))) - ->setAllowChangeVatCode(self::parseBooleanAttribute(self::getField($article, $headerElement, 'allowchangevatcode'))) - ->setAllowDecimalQuantity(self::parseBooleanAttribute(self::getField($article, $headerElement, 'allowdecimalquantity'))) - ->setAllowDiscountOrPremium(self::parseBooleanAttribute(self::getField($article, $headerElement, 'allowdiscountorpremium'))) - ->setCode(self::getField($article, $headerElement, 'code')) - ->setName(self::getField($article, $headerElement, 'name')) + $article->setAllowChangePerformanceType(self::parseBooleanAttribute(self::getField($headerElement, 'allowchangeperformancetype', $article))) + ->setAllowChangeUnitsPrice(self::parseBooleanAttribute(self::getField($headerElement, 'allowchangeunitsprice', $article))) + ->setAllowChangeVatCode(self::parseBooleanAttribute(self::getField($headerElement, 'allowchangevatcode', $article))) + ->setAllowDecimalQuantity(self::parseBooleanAttribute(self::getField($headerElement, 'allowdecimalquantity', $article))) + ->setAllowDiscountOrPremium(self::parseBooleanAttribute(self::getField($headerElement, 'allowdiscountorpremium', $article))) + ->setCode(self::getField($headerElement, 'code', $article)) + ->setName(self::getField($headerElement, 'name', $article)) ->setOffice(self::parseObjectAttribute('Office', $article, $headerElement, 'office')) - ->setPercentage(self::parseBooleanAttribute(self::getField($article, $headerElement, 'percentage'))) - ->setPerformanceType(self::parseEnumAttribute('PerformanceType', self::getField($article, $headerElement, 'performancetype'))) - ->setShortName(self::getField($article, $headerElement, 'shortname')) - ->setType(self::parseEnumAttribute('ArticleType', self::getField($article, $headerElement, 'type'))) - ->setUnitNameSingular(self::getField($article, $headerElement, 'unitnamesingular')) - ->setUnitNamePlural(self::getField($article, $headerElement, 'unitnameplural')) + ->setPercentage(self::parseBooleanAttribute(self::getField($headerElement, 'percentage', $article))) + ->setPerformanceType(self::parseEnumAttribute('PerformanceType', self::getField($headerElement, 'performancetype', $article))) + ->setShortName(self::getField($headerElement, 'shortname', $article)) + ->setType(self::parseEnumAttribute('ArticleType', self::getField($headerElement, 'type', $article))) + ->setUnitNameSingular(self::getField($headerElement, 'unitnamesingular', $article)) + ->setUnitNamePlural(self::getField($headerElement, 'unitnameplural', $article)) ->setVatCode(self::parseObjectAttribute('VatCode', $article, $headerElement, 'vatcode')); // Get the lines element @@ -93,13 +93,13 @@ public static function map(Response $response) // Set the article line elements $articleLine->setFreeText1(self::parseObjectAttribute('GeneralLedger', $articleLine, $lineElement, 'freetext1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setFreeText2(self::parseObjectAttribute('CostCenter', $articleLine, $lineElement, 'freetext2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setFreeText3(self::getField($articleLine, $lineElement, 'freetext3')) - ->setUnits(self::getField($articleLine, $lineElement, 'units')) - ->setName(self::getField($articleLine, $lineElement, 'name')) - ->setShortName(self::getField($articleLine, $lineElement, 'shortname')) - ->setSubCode(self::getField($articleLine, $lineElement, 'subcode')) - ->setUnitsPriceExcl(self::parseMoneyAttribute(self::getField($articleLine, $lineElement, 'unitspriceexcl'))) - ->setUnitsPriceInc(self::parseMoneyAttribute(self::getField($articleLine, $lineElement, 'unitspriceinc'))); + ->setFreeText3(self::getField($lineElement, 'freetext3', $articleLine)) + ->setUnits(self::getField($lineElement, 'units', $articleLine)) + ->setName(self::getField($lineElement, 'name', $articleLine)) + ->setShortName(self::getField($lineElement, 'shortname', $articleLine)) + ->setSubCode(self::getField($lineElement, 'subcode', $articleLine)) + ->setUnitsPriceExcl(self::parseMoneyAttribute(self::getField($lineElement, 'unitspriceexcl', $articleLine))) + ->setUnitsPriceInc(self::parseMoneyAttribute(self::getField($lineElement, 'unitspriceinc', $articleLine))); // Add the line to the article $article->addLine($articleLine); diff --git a/src/Mappers/AssetMethodMapper.php b/src/Mappers/AssetMethodMapper.php index 6a88c8c6..17cafe94 100644 --- a/src/Mappers/AssetMethodMapper.php +++ b/src/Mappers/AssetMethodMapper.php @@ -43,17 +43,17 @@ public static function map(Response $response) ->setStatus(self::parseEnumAttribute('Status', $assetmethodElement->getAttribute('status'))); // Set the asset method elements from the asset method element - $assetmethod->setCalcMethod(self::parseEnumAttribute('CalcMethod', self::getField($assetmethod, $assetmethodElement, 'calcmethod'))) - ->setCode(self::getField($assetmethod, $assetmethodElement, 'code')) - ->setCreated(self::parseDateTimeAttribute(self::getField($assetmethod, $assetmethodElement, 'created'))) - ->setDepreciateReconciliation(self::parseEnumAttribute('DepreciateReconciliation', self::getField($assetmethod, $assetmethodElement, 'depreciatereconciliation'))) - ->setModified(self::parseDateTimeAttribute(self::getField($assetmethod, $assetmethodElement, 'modified'))) - ->setName(self::getField($assetmethod, $assetmethodElement, 'name')) - ->setNrOfPeriods(self::getField($assetmethod, $assetmethodElement, 'nrofperiods')) + $assetmethod->setCalcMethod(self::parseEnumAttribute('CalcMethod', self::getField($assetmethodElement, 'calcmethod', $assetmethod))) + ->setCode(self::getField($assetmethodElement, 'code', $assetmethod)) + ->setCreated(self::parseDateTimeAttribute(self::getField($assetmethodElement, 'created', $assetmethod))) + ->setDepreciateReconciliation(self::parseEnumAttribute('DepreciateReconciliation', self::getField($assetmethodElement, 'depreciatereconciliation', $assetmethod))) + ->setModified(self::parseDateTimeAttribute(self::getField($assetmethodElement, 'modified', $assetmethod))) + ->setName(self::getField($assetmethodElement, 'name', $assetmethod)) + ->setNrOfPeriods(self::getField($assetmethodElement, 'nrofperiods', $assetmethod)) ->setOffice(self::parseObjectAttribute('Office', $assetmethod, $assetmethodElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setPercentage(self::getField($assetmethod, $assetmethodElement, 'percentage')) - ->setShortName(self::getField($assetmethod, $assetmethodElement, 'shortname')) - ->setTouched(self::getField($assetmethod, $assetmethodElement, 'touched')) + ->setPercentage(self::getField($assetmethodElement, 'percentage', $assetmethod)) + ->setShortName(self::getField($assetmethodElement, 'shortname', $assetmethod)) + ->setTouched(self::getField($assetmethodElement, 'touched', $assetmethod)) ->setUser(self::parseObjectAttribute('User', $assetmethod, $assetmethodElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); // Get the balanceaccounts element diff --git a/src/Mappers/BrowseDataMapper.php b/src/Mappers/BrowseDataMapper.php index a8771381..e6b76fab 100644 --- a/src/Mappers/BrowseDataMapper.php +++ b/src/Mappers/BrowseDataMapper.php @@ -55,10 +55,10 @@ public static function map(Response $response) $keyElement = $rowElement->getElementsByTagName('key')[0]; $browseDataRow - ->setOffice(Office::fromCode(self::getField($browseDataRow, $keyElement, 'office'))) - ->setCode(self::getField($browseDataRow, $keyElement, 'code')) - ->setNumber(self::getField($browseDataRow, $keyElement, 'number')) - ->setLine(self::getField($browseDataRow, $keyElement, 'line')); + ->setOffice(Office::fromCode(self::getField($keyElement, 'office', $browseDataRow))) + ->setCode(self::getField($keyElement, 'code', $browseDataRow)) + ->setNumber(self::getField($keyElement, 'number', $browseDataRow)) + ->setLine(self::getField($keyElement, 'line', $browseDataRow)); $browseData->addRow($browseDataRow); diff --git a/src/Mappers/BrowseDefinitionMapper.php b/src/Mappers/BrowseDefinitionMapper.php index 06198d1e..469ecc05 100644 --- a/src/Mappers/BrowseDefinitionMapper.php +++ b/src/Mappers/BrowseDefinitionMapper.php @@ -29,32 +29,32 @@ public static function map(Response $response) $browseDefinitionElement = $document->documentElement; $browseDefinition - ->setOffice(Office::fromCode(self::getField($browseDefinition, $browseDefinitionElement, 'office'))) - ->setCode(self::getField($browseDefinition, $browseDefinitionElement, 'code')) - ->setName(self::getField($browseDefinition, $browseDefinitionElement, 'name')) - ->setShortName(self::getField($browseDefinition, $browseDefinitionElement, 'shortname')) - ->setVisible(self::getField($browseDefinition, $browseDefinitionElement, 'visible')); + ->setOffice(Office::fromCode(self::getField($browseDefinitionElement, 'office', $browseDefinition))) + ->setCode(self::getField($browseDefinitionElement, 'code', $browseDefinition)) + ->setName(self::getField($browseDefinitionElement, 'name', $browseDefinition)) + ->setShortName(self::getField($browseDefinitionElement, 'shortname', $browseDefinition)) + ->setVisible(self::getField($browseDefinitionElement, 'visible', $browseDefinition)); foreach ($browseDefinitionElement->getElementsByTagName('column') as $columnElement) { $browseColumn = new BrowseColumn(); $browseColumn ->setId($columnElement->getAttribute('id')) - ->setField(self::getField($browseColumn, $columnElement, 'field')) - ->setVisible(Util::parseBoolean(self::getField($browseColumn, $columnElement, 'visible'))) - ->setAsk(Util::parseBoolean(self::getField($browseColumn, $columnElement, 'ask'))) - ->setOperator(new BrowseColumnOperator(self::getField($browseColumn, $columnElement, 'operator'))); + ->setField(self::getField($columnElement, 'field', $browseColumn)) + ->setVisible(Util::parseBoolean(self::getField($columnElement, 'visible', $browseColumn))) + ->setAsk(Util::parseBoolean(self::getField($columnElement, 'ask', $browseColumn))) + ->setOperator(new BrowseColumnOperator(self::getField($columnElement, 'operator', $browseColumn))); - $label = self::getField($browseColumn, $columnElement, 'label'); + $label = self::getField($columnElement, 'label', $browseColumn); if (!empty($label)) { $browseColumn->setLabel($label); } - $from = self::getField($browseColumn, $columnElement, 'from'); + $from = self::getField($columnElement, 'from', $browseColumn); if (!empty($from)) { $browseColumn->setFrom($from); } - $to = self::getField($browseColumn, $columnElement, 'to'); + $to = self::getField($columnElement, 'to', $browseColumn); if (!empty($to)) { $browseColumn->setTo($to); } diff --git a/src/Mappers/BrowseFieldMapper.php b/src/Mappers/BrowseFieldMapper.php index b22482cd..ec593375 100644 --- a/src/Mappers/BrowseFieldMapper.php +++ b/src/Mappers/BrowseFieldMapper.php @@ -25,15 +25,15 @@ public static function map(Response $response) foreach ($browseFieldsElement->getElementsByTagName('browsefield') as $browseFieldElement) { $browseField = new BrowseField(); $browseField - ->setCode(self::getField($browseField, $browseFieldElement, 'code')) - ->setDataType(self::getField($browseField, $browseFieldElement, 'datatype')); + ->setCode(self::getField($browseFieldElement, 'code', $browseField)) + ->setDataType(self::getField($browseFieldElement, 'datatype', $browseField)); - $finder = self::getField($browseField, $browseFieldElement, 'finder'); + $finder = self::getField($browseFieldElement, 'finder', $browseField); if (!empty($finder)) { $browseField->setFinder($finder); } - $canOrder = self::getField($browseField, $browseFieldElement, 'canorder'); + $canOrder = self::getField($browseFieldElement, 'canorder', $browseField); if (!empty($canOrder)) { $browseField->setCanOrder($canOrder); } diff --git a/src/Mappers/CashBankBookMapper.php b/src/Mappers/CashBankBookMapper.php index 1e7578ad..92995029 100644 --- a/src/Mappers/CashBankBookMapper.php +++ b/src/Mappers/CashBankBookMapper.php @@ -35,9 +35,9 @@ public static function map(Response $response) $cashBankBookElement = $responseDOM->documentElement; // Set the cash or bank book elements from the cash or bank book element - $cashBankBook->setCode(self::getField($cashBankBook, $cashBankBookElement, 'code')) - ->setName(self::getField($cashBankBook, $cashBankBookElement, 'name')) - ->setShortName(self::getField($cashBankBook, $cashBankBookElement, 'shortname')); + $cashBankBook->setCode(self::getField($cashBankBookElement, 'code', $cashBankBook)) + ->setName(self::getField($cashBankBookElement, 'name', $cashBankBook)) + ->setShortName(self::getField($cashBankBookElement, 'shortname', $cashBankBook)); // Return the complete object return $cashBankBook; diff --git a/src/Mappers/CostCenterMapper.php b/src/Mappers/CostCenterMapper.php index 8120e9b7..12e91958 100644 --- a/src/Mappers/CostCenterMapper.php +++ b/src/Mappers/CostCenterMapper.php @@ -39,14 +39,14 @@ public static function map(Response $response) ->setStatus(self::parseEnumAttribute('Status', $costCenterElement->getAttribute('status'))); // Set the cost center elements from the cost center element - $costCenter->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($costCenter, $costCenterElement, 'behaviour'))) - ->setCode(self::getField($costCenter, $costCenterElement, 'code')) - ->setInUse(self::parseBooleanAttribute(self::getField($costCenter, $costCenterElement, 'name'))) - ->setName(self::getField($costCenter, $costCenterElement, 'name')) + $costCenter->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($costCenterElement, 'behaviour', $costCenter))) + ->setCode(self::getField($costCenterElement, 'code', $costCenter)) + ->setInUse(self::parseBooleanAttribute(self::getField($costCenterElement, 'name', $costCenter))) + ->setName(self::getField($costCenterElement, 'name', $costCenter)) ->setOffice(self::parseObjectAttribute('Office', $costCenter, $costCenterElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setTouched(self::getField($costCenter, $costCenterElement, 'touched')) + ->setTouched(self::getField($costCenterElement, 'touched', $costCenter)) ->setType(self::parseObjectAttribute('DimensionType', $costCenter, $costCenterElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setUID(self::getField($costCenter, $costCenterElement, 'uid')); + ->setUID(self::getField($costCenterElement, 'uid', $costCenter)); // Return the complete object return $costCenter; diff --git a/src/Mappers/CurrencyMapper.php b/src/Mappers/CurrencyMapper.php index 6bb88a39..403d3443 100644 --- a/src/Mappers/CurrencyMapper.php +++ b/src/Mappers/CurrencyMapper.php @@ -40,10 +40,10 @@ public static function map(Response $response) ->setStatus(self::parseEnumAttribute('Status', $currencyElement->getAttribute('status'))); // Set the currency elements from the currency element - $currency->setCode(self::getField($currency, $currencyElement, 'code')) - ->setName(self::getField($currency, $currencyElement, 'name')) + $currency->setCode(self::getField($currencyElement, 'code', $currency)) + ->setName(self::getField($currencyElement, 'name', $currency)) ->setOffice(self::parseObjectAttribute('Office', $currency, $currencyElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setShortName(self::getField($currency, $currencyElement, 'shortname')); + ->setShortName(self::getField($currencyElement, 'shortname', $currency)); // Get the rates element $ratesDOMTag = $responseDOM->getElementsByTagName('rates'); @@ -63,8 +63,8 @@ public static function map(Response $response) //$currencyRate->setStatus($rateElement->getAttribute('status')); // Set the currency rate elements from the rate element - $currencyRate->setRate(self::getField($currencyRate, $rateElement, 'rate')) - ->setStartDate(self::parseDateAttribute(self::getField($currencyRate, $rateElement, 'startdate'))); + $currencyRate->setRate(self::getField($rateElement, 'rate', $currencyRate)) + ->setStartDate(self::parseDateAttribute(self::getField($rateElement, 'startdate', $currencyRate))); // Add the rate to the currency $currency->addRate($currencyRate); diff --git a/src/Mappers/CustomerMapper.php b/src/Mappers/CustomerMapper.php index 24456def..47a7c636 100644 --- a/src/Mappers/CustomerMapper.php +++ b/src/Mappers/CustomerMapper.php @@ -46,21 +46,21 @@ public static function map(Response $response) ->setStatus(self::parseEnumAttribute('Status', $customerElement->getAttribute('status'))); // Set the customer elements from the customer element - $customer->setBeginPeriod(self::getField($customer, $customerElement, 'beginperiod')) - ->setBeginYear(self::getField($customer, $customerElement, 'beginyear')) - ->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($customer, $customerElement, 'behaviour'))) + $customer->setBeginPeriod(self::getField($customerElement, 'beginperiod', $customer)) + ->setBeginYear(self::getField($customerElement, 'beginyear', $customer)) + ->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($customerElement, 'behaviour', $customer))) ->setDiscountArticle(self::parseObjectAttribute('Article', $customer, $customerElement, 'discountarticle', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setCode(self::getField($customer, $customerElement, 'code')) - ->setEndPeriod(self::getField($customer, $customerElement, 'endperiod')) - ->setEndYear(self::getField($customer, $customerElement, 'endyear')) + ->setCode(self::getField($customerElement, 'code', $customer)) + ->setEndPeriod(self::getField($customerElement, 'endperiod', $customer)) + ->setEndYear(self::getField($customerElement, 'endyear', $customer)) ->setGroup(self::parseObjectAttribute('DimensionGroup', $customer, $customerElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setInUse(self::parseBooleanAttribute(self::getField($customer, $customerElement, 'name'))) - ->setName(self::getField($customer, $customerElement, 'name')) + ->setInUse(self::parseBooleanAttribute(self::getField($customerElement, 'name', $customer))) + ->setName(self::getField($customerElement, 'name', $customer)) ->setOffice(self::parseObjectAttribute('Office', $customer, $customerElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setTouched(self::getField($customer, $customerElement, 'touched')) + ->setTouched(self::getField($customerElement, 'touched', $customer)) ->setType(self::parseObjectAttribute('DimensionType', $customer, $customerElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setUID(self::getField($customer, $customerElement, 'uid')) - ->setWebsite(self::getField($customer, $customerElement, 'website')); + ->setUID(self::getField($customerElement, 'uid', $customer)) + ->setWebsite(self::getField($customerElement, 'website', $customer)); // Set the customer elements from the customer element attributes $customer->setDiscountArticleID(self::getAttribute($customerElement, 'discountarticle', 'id')); @@ -73,18 +73,18 @@ public static function map(Response $response) $customerFinancials = new CustomerFinancials(); // Set the financials elements from the financials element - $customerFinancials->setAccountType(self::parseEnumAttribute('AccountType', self::getField($customerFinancials, $financialsElement, 'accounttype'))) - ->setCollectionSchema(self::parseEnumAttribute('CollectionSchema', self::getField($customerFinancials, $financialsElement, 'collectionschema'))) - ->setDueDays(self::getField($customerFinancials, $financialsElement, 'duedays')) - ->setEBilling(self::parseBooleanAttribute(self::getField($customerFinancials, $financialsElement, 'ebilling'))) - ->setEBillMail(self::getField($customerFinancials, $financialsElement, 'ebillmail')) - ->setLevel(self::getField($customerFinancials, $financialsElement, 'level')) - ->setMatchType(self::parseEnumAttribute('MatchType', self::getField($customerFinancials, $financialsElement, 'matchtype'))) - ->setMeansOfPayment(self::parseEnumAttribute('MeansOfPayment', self::getField($customerFinancials, $financialsElement, 'meansofpayment'))) - ->setPayAvailable(self::parseBooleanAttribute(self::getField($customerFinancials, $financialsElement, 'payavailable'))) + $customerFinancials->setAccountType(self::parseEnumAttribute('AccountType', self::getField($financialsElement, 'accounttype', $customerFinancials))) + ->setCollectionSchema(self::parseEnumAttribute('CollectionSchema', self::getField($financialsElement, 'collectionschema', $customerFinancials))) + ->setDueDays(self::getField($financialsElement, 'duedays', $customerFinancials)) + ->setEBilling(self::parseBooleanAttribute(self::getField($financialsElement, 'ebilling', $customerFinancials))) + ->setEBillMail(self::getField($financialsElement, 'ebillmail', $customerFinancials)) + ->setLevel(self::getField($financialsElement, 'level', $customerFinancials)) + ->setMatchType(self::parseEnumAttribute('MatchType', self::getField($financialsElement, 'matchtype', $customerFinancials))) + ->setMeansOfPayment(self::parseEnumAttribute('MeansOfPayment', self::getField($financialsElement, 'meansofpayment', $customerFinancials))) + ->setPayAvailable(self::parseBooleanAttribute(self::getField($financialsElement, 'payavailable', $customerFinancials))) ->setPayCode(self::parseObjectAttribute('PayCode', $customerFinancials, $financialsElement, 'paycode', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setSubAnalyse(self::parseEnumAttribute('SubAnalyse', self::getField($customerFinancials, $financialsElement, 'subanalyse'))) - ->setSubstitutionLevel(self::getField($customerFinancials, $financialsElement, 'substitutionlevel')) + ->setSubAnalyse(self::parseEnumAttribute('SubAnalyse', self::getField($financialsElement, 'subanalyse', $customerFinancials))) + ->setSubstitutionLevel(self::getField($financialsElement, 'substitutionlevel', $customerFinancials)) ->setSubstituteWith(self::parseObjectAttribute('UnknownDimension', $customerFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setVatCode(self::parseObjectAttribute('VatCode', $customerFinancials, $financialsElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); @@ -101,9 +101,9 @@ public static function map(Response $response) $customerCollectMandate = new CustomerCollectMandate(); // Set the collect mandate elements from the collect mandate element - $customerCollectMandate->setFirstRunDate(self::parseDateAttribute(self::getField($customerCollectMandate, $collectMandateElement, 'firstrundate'))) - ->setID(self::getField($customerCollectMandate, $collectMandateElement, 'id')) - ->setSignatureDate(self::parseDateAttribute(self::getField($customerCollectMandate, $collectMandateElement, 'signaturedate'))); + $customerCollectMandate->setFirstRunDate(self::parseDateAttribute(self::getField($collectMandateElement, 'firstrundate', $customerCollectMandate))) + ->setID(self::getField($collectMandateElement, 'id', $customerCollectMandate)) + ->setSignatureDate(self::parseDateAttribute(self::getField($collectMandateElement, 'signaturedate', $customerCollectMandate))); // Add the collect mandate element to the customer financials class $customerFinancials->setCollectMandate($customerCollectMandate); @@ -150,15 +150,15 @@ public static function map(Response $response) $customerCreditManagement = new CustomerCreditManagement(); // Set the customer credit management elements from the creditmanagement element - $customerCreditManagement->setBaseCreditLimit(self::parseMoneyAttribute(self::getField($customerCreditManagement, $creditManagementElement, 'basecreditlimit'))) - ->setBlocked(self::parseBooleanAttribute(self::getField($customerCreditManagement, $creditManagementElement, 'blocked'))) - ->setComment(self::getField($customerCreditManagement, $creditManagementElement, 'comment')) - ->setFreeText1(self::parseBooleanAttribute(self::getField($customerCreditManagement, $creditManagementElement, 'freetext1'))) - ->setFreeText2(self::getField($customerCreditManagement, $creditManagementElement, 'freetext2')) - ->setFreeText3(self::getField($customerCreditManagement, $creditManagementElement, 'freetext3')) - ->setReminderEmail(self::getField($customerCreditManagement, $creditManagementElement, 'reminderemail')) + $customerCreditManagement->setBaseCreditLimit(self::parseMoneyAttribute(self::getField($creditManagementElement, 'basecreditlimit', $customerCreditManagement))) + ->setBlocked(self::parseBooleanAttribute(self::getField($creditManagementElement, 'blocked', $customerCreditManagement))) + ->setComment(self::getField($creditManagementElement, 'comment', $customerCreditManagement)) + ->setFreeText1(self::parseBooleanAttribute(self::getField($creditManagementElement, 'freetext1', $customerCreditManagement))) + ->setFreeText2(self::getField($creditManagementElement, 'freetext2', $customerCreditManagement)) + ->setFreeText3(self::getField($creditManagementElement, 'freetext3', $customerCreditManagement)) + ->setReminderEmail(self::getField($creditManagementElement, 'reminderemail', $customerCreditManagement)) ->setResponsibleUser(self::parseObjectAttribute('User', $customerCreditManagement, $creditManagementElement, 'responsibleuser', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setSendReminder(self::parseEnumAttribute('SendReminder', self::getField($customerCreditManagement, $creditManagementElement, 'sendreminder'))); + ->setSendReminder(self::parseEnumAttribute('SendReminder', self::getField($creditManagementElement, 'sendreminder', $customerCreditManagement))); // Set the customer credit management elements from the creditmanagement element attributes $customerCreditManagement->setBlockedLocked(self::parseBooleanAttribute(self::getAttribute($creditManagementElement, 'blocked', 'locked'))) @@ -173,8 +173,8 @@ public static function map(Response $response) if ($remittanceAdviceElement !== null) { // Set the customer elements from the remittanceadvice element - $customer->setRemittanceAdviceSendType(self::parseEnumAttribute('RemittanceAdviceSendType', self::getField($customer, $remittanceAdviceElement, 'sendtype'))) - ->setRemittanceAdviceSendMail(self::getField($customer, $remittanceAdviceElement, 'sendmail')); + $customer->setRemittanceAdviceSendType(self::parseEnumAttribute('RemittanceAdviceSendType', self::getField($remittanceAdviceElement, 'sendtype', $customer))) + ->setRemittanceAdviceSendMail(self::getField($remittanceAdviceElement, 'sendmail', $customer)); } // Get the addresses element @@ -196,19 +196,19 @@ public static function map(Response $response) ->setType(self::parseEnumAttribute('AddressType', $addressElement->getAttribute('type'))); // Set the address elements from the address element - $customerAddress->setCity(self::getField($customerAddress, $addressElement, 'city')) + $customerAddress->setCity(self::getField($addressElement, 'city', $customerAddress)) ->setCountry(self::parseObjectAttribute('Country', $customerAddress, $addressElement, 'country', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setEmail(self::getField($customerAddress, $addressElement, 'email')) - ->setField1(self::getField($customerAddress, $addressElement, 'field1')) - ->setField2(self::getField($customerAddress, $addressElement, 'field2')) - ->setField3(self::getField($customerAddress, $addressElement, 'field3')) - ->setField4(self::getField($customerAddress, $addressElement, 'field4')) - ->setField5(self::getField($customerAddress, $addressElement, 'field5')) - ->setField6(self::getField($customerAddress, $addressElement, 'field6')) - ->setName(self::getField($customerAddress, $addressElement, 'name')) - ->setPostcode(self::getField($customerAddress, $addressElement, 'postcode')) - ->setTelephone(self::getField($customerAddress, $addressElement, 'telephone')) - ->setTelefax(self::getField($customerAddress, $addressElement, 'telefax')); + ->setEmail(self::getField($addressElement, 'email', $customerAddress)) + ->setField1(self::getField($addressElement, 'field1', $customerAddress)) + ->setField2(self::getField($addressElement, 'field2', $customerAddress)) + ->setField3(self::getField($addressElement, 'field3', $customerAddress)) + ->setField4(self::getField($addressElement, 'field4', $customerAddress)) + ->setField5(self::getField($addressElement, 'field5', $customerAddress)) + ->setField6(self::getField($addressElement, 'field6', $customerAddress)) + ->setName(self::getField($addressElement, 'name', $customerAddress)) + ->setPostcode(self::getField($addressElement, 'postcode', $customerAddress)) + ->setTelephone(self::getField($addressElement, 'telephone', $customerAddress)) + ->setTelefax(self::getField($addressElement, 'telefax', $customerAddress)); // Add the address to the customer $customer->addAddress($customerAddress); @@ -237,18 +237,18 @@ public static function map(Response $response) ->setID($bankElement->getAttribute('id')); // Set the bank elements from the bank element - $customerBank->setAccountNumber(self::getField($customerBank, $bankElement, 'accountnumber')) - ->setAddressField2(self::getField($customerBank, $bankElement, 'field2')) - ->setAddressField3(self::getField($customerBank, $bankElement, 'field3')) - ->setAscription(self::getField($customerBank, $bankElement, 'ascription')) - ->setBankName(self::getField($customerBank, $bankElement, 'bankname')) - ->setBicCode(self::getField($customerBank, $bankElement, 'biccode')) - ->setCity(self::getField($customerBank, $bankElement, 'city')) + $customerBank->setAccountNumber(self::getField($bankElement, 'accountnumber', $customerBank)) + ->setAddressField2(self::getField($bankElement, 'field2', $customerBank)) + ->setAddressField3(self::getField($bankElement, 'field3', $customerBank)) + ->setAscription(self::getField($bankElement, 'ascription', $customerBank)) + ->setBankName(self::getField($bankElement, 'bankname', $customerBank)) + ->setBicCode(self::getField($bankElement, 'biccode', $customerBank)) + ->setCity(self::getField($bankElement, 'city', $customerBank)) ->setCountry(self::parseObjectAttribute('Country', $customerBank, $bankElement, 'country', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setIban(self::getField($customerBank, $bankElement, 'iban')) - ->setNatBicCode(self::getField($customerBank, $bankElement, 'natbiccode')) - ->setPostcode(self::getField($customerBank, $bankElement, 'postcode')) - ->setState(self::getField($customerBank, $bankElement, 'state')); + ->setIban(self::getField($bankElement, 'iban', $customerBank)) + ->setNatBicCode(self::getField($bankElement, 'natbiccode', $customerBank)) + ->setPostcode(self::getField($bankElement, 'postcode', $customerBank)) + ->setState(self::getField($bankElement, 'state', $customerBank)); // Add the bank to the customer $customer->addBank($customerBank); @@ -276,9 +276,9 @@ public static function map(Response $response) ->setStatus(self::parseEnumAttribute('Status', $postingruleElement->getAttribute('status'))); // Set the postingrule elements from the postingrule element - $customerPostingRule->setAmount(self::parseMoneyAttribute(self::getField($customerPostingRule, $postingruleElement, 'amount'))) + $customerPostingRule->setAmount(self::parseMoneyAttribute(self::getField($postingruleElement, 'amount', $customerPostingRule))) ->setCurrency(self::parseObjectAttribute('Currency', $customerPostingRule, $postingruleElement, 'currency', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setDescription(self::getField($customerPostingRule, $postingruleElement, 'description')); + ->setDescription(self::getField($postingruleElement, 'description', $customerPostingRule)); // Get the lines element $linesDOMTag = $postingruleElement->getElementsByTagName('lines'); @@ -294,12 +294,12 @@ public static function map(Response $response) $customerLine = new CustomerLine(); // Set the line elements from the line element - $customerLine->setDescription(self::getField($customerLine, $lineElement, 'description')) + $customerLine->setDescription(self::getField($lineElement, 'description', $customerLine)) ->setDimension1(self::parseObjectAttribute('GeneralLedger', $customerLine, $lineElement, 'dimension1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setDimension2(self::parseObjectAttribute('CostCenter', $customerLine, $lineElement, 'dimension2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setDimension3(self::parseObjectAttribute('UnknownDimension', $customerLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setOffice(self::parseObjectAttribute('Office', $customerLine, $lineElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setRatio(self::getField($customerLine, $lineElement, 'ratio')) + ->setRatio(self::getField($lineElement, 'ratio', $customerLine)) ->setVatCode(self::parseObjectAttribute('VatCode', $customerLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); // Set the line elements from the line element attributes @@ -328,8 +328,8 @@ public static function map(Response $response) if ($paymentConditionsElement !== null) { // Set the customer elements from the paymentconditions element - $customer->setPaymentConditionDiscountDays(self::getField($customer, $paymentConditionsElement, 'discountdays')) - ->setPaymentConditionDiscountPercentage(self::getField($customer, $paymentConditionsElement, 'discountpercentage')); + $customer->setPaymentConditionDiscountDays(self::getField($paymentConditionsElement, 'discountdays', $customer)) + ->setPaymentConditionDiscountPercentage(self::getField($paymentConditionsElement, 'discountpercentage', $customer)); } // Return the complete object diff --git a/src/Mappers/DimensionGroupMapper.php b/src/Mappers/DimensionGroupMapper.php index c10b503f..bdbfe444 100644 --- a/src/Mappers/DimensionGroupMapper.php +++ b/src/Mappers/DimensionGroupMapper.php @@ -41,10 +41,10 @@ public static function map(Response $response) ->setStatus(self::parseEnumAttribute('Status', $dimensiongroupElement->getAttribute('status'))); // Set the dimension group elements from the dimension group element - $dimensiongroup->setCode(self::getField($dimensiongroup, $dimensiongroupElement, 'code')) - ->setName(self::getField($dimensiongroup, $dimensiongroupElement, 'name')) + $dimensiongroup->setCode(self::getField($dimensiongroupElement, 'code', $dimensiongroup)) + ->setName(self::getField($dimensiongroupElement, 'name', $dimensiongroup)) ->setOffice(self::parseObjectAttribute('Office', $dimensiongroup, $dimensiongroupElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setShortName(self::getField($dimensiongroup, $dimensiongroupElement, 'shortname')); + ->setShortName(self::getField($dimensiongroupElement, 'shortname', $dimensiongroup)); // Get the dimensions element $dimensionsDOMTag = $responseDOM->getElementsByTagName('dimensions'); diff --git a/src/Mappers/DimensionTypeMapper.php b/src/Mappers/DimensionTypeMapper.php index 1d776cb3..ea4c691a 100644 --- a/src/Mappers/DimensionTypeMapper.php +++ b/src/Mappers/DimensionTypeMapper.php @@ -41,11 +41,11 @@ public static function map(Response $response) ->setStatus(self::parseEnumAttribute('Status', $dimensiontypeElement->getAttribute('status'))); // Set the dimension type elements from the dimension type element - $dimensiontype->setCode(self::getField($dimensiontype, $dimensiontypeElement, 'code')) - ->setMask(self::getField($dimensiontype, $dimensiontypeElement, 'mask')) - ->setName(self::getField($dimensiontype, $dimensiontypeElement, 'name')) + $dimensiontype->setCode(self::getField($dimensiontypeElement, 'code', $dimensiontype)) + ->setMask(self::getField($dimensiontypeElement, 'mask', $dimensiontype)) + ->setName(self::getField($dimensiontypeElement, 'name', $dimensiontype)) ->setOffice(self::parseObjectAttribute('Office', $dimensiontype, $dimensiontypeElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setShortName(self::getField($dimensiontype, $dimensiontypeElement, 'shortname')); + ->setShortName(self::getField($dimensiontypeElement, 'shortname', $dimensiontype)); // Get the levels element $levelsElement = $responseDOM->getElementsByTagName('levels')->item(0); @@ -55,8 +55,8 @@ public static function map(Response $response) $dimensionTypeLevels = new DimensionTypeLevels(); // Set the dimension type levels elements from the levels element - $dimensionTypeLevels->setFinancials(self::getField($dimensionTypeLevels, $levelsElement, 'financials')) - ->setTime(self::getField($dimensionTypeLevels, $levelsElement, 'time')); + $dimensionTypeLevels->setFinancials(self::getField($levelsElement, 'financials', $dimensionTypeLevels)) + ->setTime(self::getField($levelsElement, 'time', $dimensionTypeLevels)); // Set the custom class to the dimension type $dimensiontype->setLevels($dimensionTypeLevels); @@ -70,12 +70,12 @@ public static function map(Response $response) $dimensionTypeAddress = new DimensionTypeAddress(); // Set the dimension type address elements from the address element - $dimensionTypeAddress->setLabel1(self::getField($dimensionTypeAddress, $addressElement, 'label1')) - ->setLabel2(self::getField($dimensionTypeAddress, $addressElement, 'label2')) - ->setLabel3(self::getField($dimensionTypeAddress, $addressElement, 'label3')) - ->setLabel4(self::getField($dimensionTypeAddress, $addressElement, 'label4')) - ->setLabel5(self::getField($dimensionTypeAddress, $addressElement, 'label5')) - ->setLabel6(self::getField($dimensionTypeAddress, $addressElement, 'label6')); + $dimensionTypeAddress->setLabel1(self::getField($addressElement, 'label1', $dimensionTypeAddress)) + ->setLabel2(self::getField($addressElement, 'label2', $dimensionTypeAddress)) + ->setLabel3(self::getField($addressElement, 'label3', $dimensionTypeAddress)) + ->setLabel4(self::getField($addressElement, 'label4', $dimensionTypeAddress)) + ->setLabel5(self::getField($addressElement, 'label5', $dimensionTypeAddress)) + ->setLabel6(self::getField($addressElement, 'label6', $dimensionTypeAddress)); // Set the custom class to the dimensiontype $dimensiontype->setAddress($dimensionTypeAddress); diff --git a/src/Mappers/FixedAssetMapper.php b/src/Mappers/FixedAssetMapper.php index 1431327b..76d4d0e5 100644 --- a/src/Mappers/FixedAssetMapper.php +++ b/src/Mappers/FixedAssetMapper.php @@ -41,15 +41,15 @@ public static function map(Response $response) ->setStatus(self::parseEnumAttribute('Status', $fixedAssetElement->getAttribute('status'))); // Set the fixed asset elements from the fixed asset element - $fixedAsset->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($fixedAsset, $fixedAssetElement, 'behaviour'))) - ->setCode(self::getField($fixedAsset, $fixedAssetElement, 'code')) + $fixedAsset->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($fixedAssetElement, 'behaviour', $fixedAsset))) + ->setCode(self::getField($fixedAssetElement, 'code', $fixedAsset)) ->setGroup(self::parseObjectAttribute('DimensionGroup', $fixedAsset, $fixedAssetElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setInUse(self::parseBooleanAttribute(self::getField($fixedAsset, $fixedAssetElement, 'name'))) - ->setName(self::getField($fixedAsset, $fixedAssetElement, 'name')) + ->setInUse(self::parseBooleanAttribute(self::getField($fixedAssetElement, 'name', $fixedAsset))) + ->setName(self::getField($fixedAssetElement, 'name', $fixedAsset)) ->setOffice(self::parseObjectAttribute('Office', $fixedAsset, $fixedAssetElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setTouched(self::getField($fixedAsset, $fixedAssetElement, 'touched')) + ->setTouched(self::getField($fixedAssetElement, 'touched', $fixedAsset)) ->setType(self::parseObjectAttribute('DimensionType', $fixedAsset, $fixedAssetElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setUID(self::getField($fixedAsset, $fixedAssetElement, 'uid')); + ->setUID(self::getField($fixedAssetElement, 'uid', $fixedAsset)); // Get the financials element $financialsElement = $responseDOM->getElementsByTagName('financials')->item(0); @@ -59,11 +59,11 @@ public static function map(Response $response) $fixedAssetFinancials = new FixedAssetFinancials(); // Set the financials elements from the financials element - $fixedAssetFinancials->setAccountType(self::parseEnumAttribute('AccountType', self::getField($fixedAssetFinancials, $financialsElement, 'accounttype'))) - ->setLevel(self::getField($fixedAssetFinancials, $financialsElement, 'level')) - ->setMatchType(self::parseEnumAttribute('MatchType', self::getField($fixedAssetFinancials, $financialsElement, 'matchtype'))) - ->setSubAnalyse(self::parseEnumAttribute('SubAnalyse', self::getField($fixedAssetFinancials, $financialsElement, 'subanalyse'))) - ->setSubstitutionLevel(self::getField($fixedAssetFinancials, $financialsElement, 'substitutionlevel')) + $fixedAssetFinancials->setAccountType(self::parseEnumAttribute('AccountType', self::getField($financialsElement, 'accounttype', $fixedAssetFinancials))) + ->setLevel(self::getField($financialsElement, 'level', $fixedAssetFinancials)) + ->setMatchType(self::parseEnumAttribute('MatchType', self::getField($financialsElement, 'matchtype', $fixedAssetFinancials))) + ->setSubAnalyse(self::parseEnumAttribute('SubAnalyse', self::getField($financialsElement, 'subanalyse', $fixedAssetFinancials))) + ->setSubstitutionLevel(self::getField($financialsElement, 'substitutionlevel', $fixedAssetFinancials)) ->setSubstituteWith(self::parseObjectAttribute('CostCenter', $fixedAssetFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setVatCode(self::parseObjectAttribute('VatCode', $fixedAssetFinancials, $financialsElement, 'vatcode')); @@ -83,21 +83,21 @@ public static function map(Response $response) $fixedAssetFixedAssets = new FixedAssetFixedAssets(); // Set the fixed assets elements from the fixed assets element - $fixedAssetFixedAssets->setBeginPeriod(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'beginperiod')) - ->setFreeText1(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'freetext1')) - ->setFreeText2(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'freetext2')) - ->setFreeText3(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'freetext3')) - ->setFreeText4(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'freetext4')) - ->setFreeText5(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'freetext5')) - ->setLastDepreciation(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'lastdepreciation')) + $fixedAssetFixedAssets->setBeginPeriod(self::getField($fixedAssetsElement, 'beginperiod', $fixedAssetFixedAssets)) + ->setFreeText1(self::getField($fixedAssetsElement, 'freetext1', $fixedAssetFixedAssets)) + ->setFreeText2(self::getField($fixedAssetsElement, 'freetext2', $fixedAssetFixedAssets)) + ->setFreeText3(self::getField($fixedAssetsElement, 'freetext3', $fixedAssetFixedAssets)) + ->setFreeText4(self::getField($fixedAssetsElement, 'freetext4', $fixedAssetFixedAssets)) + ->setFreeText5(self::getField($fixedAssetsElement, 'freetext5', $fixedAssetFixedAssets)) + ->setLastDepreciation(self::getField($fixedAssetsElement, 'lastdepreciation', $fixedAssetFixedAssets)) ->setMethod(self::parseObjectAttribute('AssetMethod', $fixedAssetFixedAssets, $fixedAssetsElement, 'method', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setNrOfPeriods(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'nrofperiods')) - ->setPercentage(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'percentage')) - ->setPurchaseDate(self::parseDateAttribute(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'purchasedate'))) - ->setResidualValue(self::parseMoneyAttribute(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'residualvalue'))) - ->setSellDate(self::parseDateAttribute(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'selldate'))) - ->setStatus(self::parseEnumAttribute('FixedAssetsStatus', self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'status'))) - ->setStopValue(self::parseMoneyAttribute(self::getField($fixedAssetFixedAssets, $fixedAssetsElement, 'stopvalue'))); + ->setNrOfPeriods(self::getField($fixedAssetsElement, 'nrofperiods', $fixedAssetFixedAssets)) + ->setPercentage(self::getField($fixedAssetsElement, 'percentage', $fixedAssetFixedAssets)) + ->setPurchaseDate(self::parseDateAttribute(self::getField($fixedAssetsElement, 'purchasedate', $fixedAssetFixedAssets))) + ->setResidualValue(self::parseMoneyAttribute(self::getField($fixedAssetsElement, 'residualvalue', $fixedAssetFixedAssets))) + ->setSellDate(self::parseDateAttribute(self::getField($fixedAssetsElement, 'selldate', $fixedAssetFixedAssets))) + ->setStatus(self::parseEnumAttribute('FixedAssetsStatus', self::getField($fixedAssetsElement, 'status', $fixedAssetFixedAssets))) + ->setStopValue(self::parseMoneyAttribute(self::getField($fixedAssetsElement, 'stopvalue', $fixedAssetFixedAssets))); // Set the fixed assets elements from the fixed assets element attributes $fixedAssetFixedAssets->setBeginPeriodLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'beginperiod', 'locked'))) @@ -131,17 +131,17 @@ public static function map(Response $response) $fixedAssetTransactionLine = new FixedAssetTransactionLine(); // Set the fixed assets transaction line elements from the fixed assets transline element - $fixedAssetTransactionLine->setAmount(self::parseMoneyAttribute(self::getField($fixedAssetTransactionLine, $transactionLineElement, 'amount'))) - ->setCode(self::getField($fixedAssetTransactionLine, $transactionLineElement, 'code')) + $fixedAssetTransactionLine->setAmount(self::parseMoneyAttribute(self::getField($transactionLineElement, 'amount', $fixedAssetTransactionLine))) + ->setCode(self::getField($transactionLineElement, 'code', $fixedAssetTransactionLine)) ->setDim1(self::parseObjectAttribute('GeneralLedger', $fixedAssetTransactionLine, $transactionLineElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) ->setDim2(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) ->setDim3(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) ->setDim4(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim4', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) ->setDim5(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim5', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) ->setDim6(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim6', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) - ->setLine(self::getField($fixedAssetTransactionLine, $transactionLineElement, 'line')) - ->setNumber(self::getField($fixedAssetTransactionLine, $transactionLineElement, 'number')) - ->setPeriod(self::getField($fixedAssetTransactionLine, $transactionLineElement, 'period')); + ->setLine(self::getField($transactionLineElement, 'line', $fixedAssetTransactionLine)) + ->setNumber(self::getField($transactionLineElement, 'number', $fixedAssetTransactionLine)) + ->setPeriod(self::getField($transactionLineElement, 'period', $fixedAssetTransactionLine)); // Set the fixed assets transaction line elements from the fixed assets transline attributes $fixedAssetTransactionLine->setAmountLocked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'amount', 'locked'))) diff --git a/src/Mappers/GeneralLedgerMapper.php b/src/Mappers/GeneralLedgerMapper.php index db531390..4fc4f50b 100644 --- a/src/Mappers/GeneralLedgerMapper.php +++ b/src/Mappers/GeneralLedgerMapper.php @@ -41,20 +41,20 @@ public static function map(Response $response) ->setStatus(self::parseEnumAttribute('Status', $generalLedgerElement->getAttribute('status'))); // Set the general ledger elements from the general ledger element - $generalLedger->setBeginPeriod(self::getField($generalLedger, $generalLedgerElement, 'beginperiod')) - ->setBeginYear(self::getField($generalLedger, $generalLedgerElement, 'beginyear')) - ->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($generalLedger, $generalLedgerElement, 'behaviour'))) - ->setCode(self::getField($generalLedger, $generalLedgerElement, 'code')) - ->setEndPeriod(self::getField($generalLedger, $generalLedgerElement, 'endperiod')) - ->setEndYear(self::getField($generalLedger, $generalLedgerElement, 'endyear')) + $generalLedger->setBeginPeriod(self::getField($generalLedgerElement, 'beginperiod', $generalLedger)) + ->setBeginYear(self::getField($generalLedgerElement, 'beginyear', $generalLedger)) + ->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($generalLedgerElement, 'behaviour', $generalLedger))) + ->setCode(self::getField($generalLedgerElement, 'code', $generalLedger)) + ->setEndPeriod(self::getField($generalLedgerElement, 'endperiod', $generalLedger)) + ->setEndYear(self::getField($generalLedgerElement, 'endyear', $generalLedger)) ->setGroup(self::parseObjectAttribute('DimensionGroup', $generalLedger, $generalLedgerElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setInUse(self::parseBooleanAttribute(self::getField($generalLedger, $generalLedgerElement, 'inuse'))) - ->setName(self::getField($generalLedger, $generalLedgerElement, 'name')) + ->setInUse(self::parseBooleanAttribute(self::getField($generalLedgerElement, 'inuse', $generalLedger))) + ->setName(self::getField($generalLedgerElement, 'name', $generalLedger)) ->setOffice(self::parseObjectAttribute('Office', $generalLedger, $generalLedgerElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setShortName(self::getField($generalLedger, $generalLedgerElement, 'shortname')) - ->setTouched(self::getField($generalLedger, $generalLedgerElement, 'touched')) + ->setShortName(self::getField($generalLedgerElement, 'shortname', $generalLedger)) + ->setTouched(self::getField($generalLedgerElement, 'touched', $generalLedger)) ->setType(self::parseObjectAttribute('DimensionType', $generalLedger, $generalLedgerElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setUID(self::getField($generalLedger, $generalLedgerElement, 'uid')); + ->setUID(self::getField($generalLedgerElement, 'uid', $generalLedger)); // Get the financials element $financialsElement = $responseDOM->getElementsByTagName('financials')->item(0); @@ -64,10 +64,10 @@ public static function map(Response $response) $generalLedgerFinancials = new GeneralLedgerFinancials(); // Set the financials elements from the financials element - $generalLedgerFinancials->setAccountType(self::parseEnumAttribute('AccountType', self::getField($generalLedgerFinancials, $financialsElement, 'accounttype'))) - ->setLevel(self::getField($generalLedgerFinancials, $financialsElement, 'level')) - ->setMatchType(self::parseEnumAttribute('MatchType', self::getField($generalLedgerFinancials, $financialsElement, 'matchtype'))) - ->setSubAnalyse(self::parseEnumAttribute('SubAnalyse', self::getField($generalLedgerFinancials, $financialsElement, 'subanalyse'))) + $generalLedgerFinancials->setAccountType(self::parseEnumAttribute('AccountType', self::getField($financialsElement, 'accounttype', $generalLedgerFinancials))) + ->setLevel(self::getField($financialsElement, 'level', $generalLedgerFinancials)) + ->setMatchType(self::parseEnumAttribute('MatchType', self::getField($financialsElement, 'matchtype', $generalLedgerFinancials))) + ->setSubAnalyse(self::parseEnumAttribute('SubAnalyse', self::getField($financialsElement, 'subanalyse', $generalLedgerFinancials))) ->setVatCode(self::parseObjectAttribute('VatCode', $generalLedgerFinancials, $financialsElement, 'vatcode')); // Set the financials elements from the financials element attributes diff --git a/src/Mappers/InvoiceMapper.php b/src/Mappers/InvoiceMapper.php index 6cb896e7..5d564c8c 100644 --- a/src/Mappers/InvoiceMapper.php +++ b/src/Mappers/InvoiceMapper.php @@ -44,19 +44,19 @@ public static function map(Response $response) $invoice->setBank(self::parseObjectAttribute('CashBankBook', $invoice, $invoiceElement, 'bank')) ->setCurrency(self::parseObjectAttribute('Currency', $invoice, $invoiceElement, 'currency')) ->setCustomer(self::parseObjectAttribute('Customer', $invoice, $invoiceElement, 'customer')) - ->setDeliverAddressNumber(self::getField($invoice, $invoiceElement, 'deliveraddressnumber')) - ->setDueDate(self::parseDateAttribute(self::getField($invoice, $invoiceElement, 'duedate'))) - ->setFooterText(self::getField($invoice, $invoiceElement, 'footertext')) - ->setHeaderText(self::getField($invoice, $invoiceElement, 'headertext')) - ->setInvoiceAddressNumber(self::getField($invoice, $invoiceElement, 'invoiceaddressnumber')) - ->setInvoiceDate(self::parseDateAttribute(self::getField($invoice, $invoiceElement, 'invoicedate'))) - ->setInvoiceNumber(self::getField($invoice, $invoiceElement, 'invoicenumber')) + ->setDeliverAddressNumber(self::getField($invoiceElement, 'deliveraddressnumber', $invoice)) + ->setDueDate(self::parseDateAttribute(self::getField($invoiceElement, 'duedate', $invoice))) + ->setFooterText(self::getField($invoiceElement, 'footertext', $invoice)) + ->setHeaderText(self::getField($invoiceElement, 'headertext', $invoice)) + ->setInvoiceAddressNumber(self::getField($invoiceElement, 'invoiceaddressnumber', $invoice)) + ->setInvoiceDate(self::parseDateAttribute(self::getField($invoiceElement, 'invoicedate', $invoice))) + ->setInvoiceNumber(self::getField($invoiceElement, 'invoicenumber', $invoice)) ->setInvoiceType(self::parseObjectAttribute('InvoiceType', $invoice, $invoiceElement, 'invoicetype')) ->setOffice(self::parseObjectAttribute('Office', $invoice, $invoiceElement, 'office')) - ->setPaymentMethod(self::parseEnumAttribute('PaymentMethod', self::getField($invoice, $invoiceElement, 'paymentmethod'))) - ->setPeriod(self::getField($invoice, $invoiceElement, 'period')) - ->setPerformanceDate(self::parseDateAttribute(self::getField($invoice, $invoiceElement, 'performancedate'))) - ->setStatus(self::parseEnumAttribute('InvoiceStatus', self::getField($invoice, $invoiceElement, 'status'))); + ->setPaymentMethod(self::parseEnumAttribute('PaymentMethod', self::getField($invoiceElement, 'paymentmethod', $invoice))) + ->setPeriod(self::getField($invoiceElement, 'period', $invoice)) + ->setPerformanceDate(self::parseDateAttribute(self::getField($invoiceElement, 'performancedate', $invoice))) + ->setStatus(self::parseEnumAttribute('InvoiceStatus', self::getField($invoiceElement, 'status', $invoice))); // Get the totals element $totalsElement = $responseDOM->getElementsByTagName('totals')->item(0); @@ -66,8 +66,8 @@ public static function map(Response $response) $invoiceTotals = new InvoiceTotals(); // Set the invoice totals elements from the totals element - $invoiceTotals->setValueExcl(self::parseMoneyAttribute(self::getField($invoiceTotals, $totalsElement, 'valueexcl'))) - ->setValueInc(self::parseMoneyAttribute(self::getField($invoiceTotals, $totalsElement, 'valueinc'))); + $invoiceTotals->setValueExcl(self::parseMoneyAttribute(self::getField($totalsElement, 'valueexcl', $invoiceTotals))) + ->setValueInc(self::parseMoneyAttribute(self::getField($totalsElement, 'valueinc', $invoiceTotals))); // Set the custom class to the invoice $invoice->setTotals($invoiceTotals); @@ -90,24 +90,24 @@ public static function map(Response $response) $invoiceLine->setID($lineElement->getAttribute('id')); // Set the invoice line elements from the line element - $invoiceLine->setAllowDiscountOrPremium(self::parseBooleanAttribute(self::getField($invoiceLine, $lineElement, 'allowdiscountorpremium'))) + $invoiceLine->setAllowDiscountOrPremium(self::parseBooleanAttribute(self::getField($lineElement, 'allowdiscountorpremium', $invoiceLine))) ->setArticle(self::parseObjectAttribute('Article', $invoiceLine, $lineElement, 'article')) - ->setDescription(self::getField($invoiceLine, $lineElement, 'description')) + ->setDescription(self::getField($lineElement, 'description', $invoiceLine)) ->setDim1(self::parseObjectAttribute('GeneralLedger', $invoiceLine, $lineElement, 'dim1')) - ->setFreeText1(self::getField($invoiceLine, $lineElement, 'freetext1')) - ->setFreeText2(self::getField($invoiceLine, $lineElement, 'freetext2')) - ->setFreeText3(self::getField($invoiceLine, $lineElement, 'freetext3')) - ->setPerformanceDate(self::parseDateAttribute(self::getField($invoiceLine, $lineElement, 'performancedate'))) - ->setPerformanceType(self::parseEnumAttribute('PerformanceType', self::getField($invoiceLine, $lineElement, 'performancetype'))) - ->setQuantity(self::getField($invoiceLine, $lineElement, 'quantity')) - ->setSubArticleFromString(self::getField($invoiceLine, $lineElement, 'subarticle')) - ->setUnits(self::getField($invoiceLine, $lineElement, 'units')) - ->setUnitsPriceExcl(self::parseMoneyAttribute(self::getField($invoiceLine, $lineElement, 'unitspriceexcl'))) - ->setUnitsPriceInc(self::parseMoneyAttribute(self::getField($invoiceLine, $lineElement, 'unitspriceinc'))) - ->setValueExcl(self::parseMoneyAttribute(self::getField($invoiceLine, $lineElement, 'valueexcl'))) - ->setValueInc(self::parseMoneyAttribute(self::getField($invoiceLine, $lineElement, 'valueinc'))) + ->setFreeText1(self::getField($lineElement, 'freetext1', $invoiceLine)) + ->setFreeText2(self::getField($lineElement, 'freetext2', $invoiceLine)) + ->setFreeText3(self::getField($lineElement, 'freetext3', $invoiceLine)) + ->setPerformanceDate(self::parseDateAttribute(self::getField($lineElement, 'performancedate', $invoiceLine))) + ->setPerformanceType(self::parseEnumAttribute('PerformanceType', self::getField($lineElement, 'performancetype', $invoiceLine))) + ->setQuantity(self::getField($lineElement, 'quantity', $invoiceLine)) + ->setSubArticleFromString(self::getField($lineElement, 'subarticle', $invoiceLine)) + ->setUnits(self::getField($lineElement, 'units', $invoiceLine)) + ->setUnitsPriceExcl(self::parseMoneyAttribute(self::getField($lineElement, 'unitspriceexcl', $invoiceLine))) + ->setUnitsPriceInc(self::parseMoneyAttribute(self::getField($lineElement, 'unitspriceinc', $invoiceLine))) + ->setValueExcl(self::parseMoneyAttribute(self::getField($lineElement, 'valueexcl', $invoiceLine))) + ->setValueInc(self::parseMoneyAttribute(self::getField($lineElement, 'valueinc', $invoiceLine))) ->setVatCode(self::parseObjectAttribute('VatCode', $invoiceLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) - ->setVatValue(self::parseMoneyAttribute(self::getField($invoiceLine, $lineElement, 'vatvalue'))); + ->setVatValue(self::parseMoneyAttribute(self::getField($lineElement, 'vatvalue', $invoiceLine))); // Set the custom class to the invoice $invoice->addLine($invoiceLine); @@ -128,10 +128,10 @@ public static function map(Response $response) $invoiceVatLine = new InvoiceVatLine(); // Set the invoice vat line elements from the vat line element - $invoiceVatLine->setPerformanceDate(self::parseDateAttribute(self::getField($invoiceVatLine, $vatlineElement, 'performancedate'))) - ->setPerformanceType(self::parseEnumAttribute('PerformanceType', self::getField($invoiceVatLine, $vatlineElement, 'performancetype'))) + $invoiceVatLine->setPerformanceDate(self::parseDateAttribute(self::getField($vatlineElement, 'performancedate', $invoiceVatLine))) + ->setPerformanceType(self::parseEnumAttribute('PerformanceType', self::getField($vatlineElement, 'performancetype', $invoiceVatLine))) ->setVatCode(self::parseObjectAttribute('VatCode', $invoiceVatLine, $vatlineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) - ->setVatValue(self::parseMoneyAttribute(self::getField($invoiceVatLine, $vatlineElement, 'vatvalue'))); + ->setVatValue(self::parseMoneyAttribute(self::getField($vatlineElement, 'vatvalue', $invoiceVatLine))); // Set the custom class to the invoice $invoice->addVatLine($invoiceVatLine); @@ -143,8 +143,8 @@ public static function map(Response $response) if ($financialsElement !== null) { // Set the invoice elements from the financials element - $invoice->setFinancialCode(self::getField($invoice, $financialsElement, 'code')) - ->setFinancialNumber(self::getField($invoice, $financialsElement, 'number')); + $invoice->setFinancialCode(self::getField($financialsElement, 'code', $invoice)) + ->setFinancialNumber(self::getField($financialsElement, 'number', $invoice)); } //Return the complete object diff --git a/src/Mappers/InvoiceTypeMapper.php b/src/Mappers/InvoiceTypeMapper.php index 648bcd8e..51536d86 100644 --- a/src/Mappers/InvoiceTypeMapper.php +++ b/src/Mappers/InvoiceTypeMapper.php @@ -35,9 +35,9 @@ public static function map(Response $response) $invoiceTypeElement = $responseDOM->documentElement; // Set the invoice type elements from the invoice type element - $invoiceType->setCode(self::getField($invoiceType, $invoiceTypeElement, 'code')) - ->setName(self::getField($invoiceType, $invoiceTypeElement, 'name')) - ->setShortName(self::getField($invoiceType, $invoiceTypeElement, 'shortname')); + $invoiceType->setCode(self::getField($invoiceTypeElement, 'code', $invoiceType)) + ->setName(self::getField($invoiceTypeElement, 'name', $invoiceType)) + ->setShortName(self::getField($invoiceTypeElement, 'shortname', $invoiceType)); // Return the complete object return $invoiceType; diff --git a/src/Mappers/MatchSetMapper.php b/src/Mappers/MatchSetMapper.php index cb5daa35..5e4174f0 100644 --- a/src/Mappers/MatchSetMapper.php +++ b/src/Mappers/MatchSetMapper.php @@ -33,9 +33,9 @@ private static function createMatchSetFrom(\DOMDocument $document): MatchSet $matchSet = new MatchSet(); - $matchSet->setOffice(Office::fromCode(self::getField(null, $MatchSetElement, "office"))); - $matchSet->setMatchCode(new MatchCode(self::getField(null, $MatchSetElement, "matchcode"))); - $matchSet->setMatchDate(\DateTimeImmutable::createFromFormat("Ymd", self::getField(null, $MatchSetElement, "matchdate"))); + $matchSet->setOffice(Office::fromCode(self::getField($MatchSetElement, "office"))); + $matchSet->setMatchCode(new MatchCode(self::getField($MatchSetElement, "matchcode"))); + $matchSet->setMatchDate(\DateTimeImmutable::createFromFormat("Ymd", self::getField($MatchSetElement, "matchdate"))); return $matchSet; } @@ -57,15 +57,15 @@ private static function addLines(\DOMDocument $document, MatchSet $matchSet): vo private static function getMatchReferenceFrom(\DOMElement $lineElement, Office $office): MatchReferenceInterface { return new MatchReference( $office, - self::getField(null, $lineElement, 'transcode'), - self::getField(null, $lineElement, 'transnumber'), - self::getField(null, $lineElement, 'transline') + self::getField($lineElement, 'transcode'), + self::getField($lineElement, 'transnumber'), + self::getField($lineElement, 'transline') ); } private static function getMatchValueFrom(\DOMElement $lineElement): ?Money { - $matchValue = self::getField(null, $lineElement, 'matchvalue'); + $matchValue = self::getField($lineElement, 'matchvalue'); if ($matchValue === null) { return null; diff --git a/src/Mappers/OfficeMapper.php b/src/Mappers/OfficeMapper.php index aff5b756..d956e0fe 100644 --- a/src/Mappers/OfficeMapper.php +++ b/src/Mappers/OfficeMapper.php @@ -39,12 +39,12 @@ public static function map(Response $response) ->setStatus(self::parseEnumAttribute('Status', $officeElement->getAttribute('status'))); // Set the office elements from the office element - $office->setCode(self::getField($office, $officeElement, 'code')) - ->setCreated(self::parseDateTimeAttribute(self::getField($office, $officeElement, 'created'))) - ->setModified(self::parseDateTimeAttribute(self::getField($office, $officeElement, 'modified'))) - ->setName(self::getField($office, $officeElement, 'name')) - ->setShortName(self::getField($office, $officeElement, 'shortname')) - ->setTouched(self::getField($office, $officeElement, 'touched')) + $office->setCode(self::getField($officeElement, 'code', $office)) + ->setCreated(self::parseDateTimeAttribute(self::getField($officeElement, 'created', $office))) + ->setModified(self::parseDateTimeAttribute(self::getField($officeElement, 'modified', $office))) + ->setName(self::getField($officeElement, 'name', $office)) + ->setShortName(self::getField($officeElement, 'shortname', $office)) + ->setTouched(self::getField($officeElement, 'touched', $office)) ->setUser(self::parseObjectAttribute('User', $office, $officeElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); // Return the complete object diff --git a/src/Mappers/PayCodeMapper.php b/src/Mappers/PayCodeMapper.php index f56f9124..02ce3f9e 100644 --- a/src/Mappers/PayCodeMapper.php +++ b/src/Mappers/PayCodeMapper.php @@ -35,9 +35,9 @@ public static function map(Response $response) $payCodeElement = $responseDOM->documentElement; // Set the paycode elements from the paycode element - $payCode->setCode(self::getField($payCode, $payCodeElement, 'code')) - ->setName(self::getField($payCode, $payCodeElement, 'name')) - ->setShortName(self::getField($payCode, $payCodeElement, 'shortname')); + $payCode->setCode(self::getField($payCodeElement, 'code', $payCode)) + ->setName(self::getField($payCodeElement, 'name', $payCode)) + ->setShortName(self::getField($payCodeElement, 'shortname', $payCode)); // Return the complete object return $payCode; diff --git a/src/Mappers/ProjectMapper.php b/src/Mappers/ProjectMapper.php index 0dad3c87..4b8dd49e 100644 --- a/src/Mappers/ProjectMapper.php +++ b/src/Mappers/ProjectMapper.php @@ -41,15 +41,15 @@ public static function map(Response $response) ->setStatus(self::parseEnumAttribute('Status', $projectElement->getAttribute('status'))); // Set the project elements from the project element - $project->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($project, $projectElement, 'behaviour'))) - ->setCode(self::getField($project, $projectElement, 'code')) - ->setInUse(self::parseBooleanAttribute(self::getField($project, $projectElement, 'name'))) - ->setName(self::getField($project, $projectElement, 'name')) + $project->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($projectElement, 'behaviour', $project))) + ->setCode(self::getField($projectElement, 'code', $project)) + ->setInUse(self::parseBooleanAttribute(self::getField($projectElement, 'name', $project))) + ->setName(self::getField($projectElement, 'name', $project)) ->setOffice(self::parseObjectAttribute('Office', $project, $projectElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setShortName(self::getField($project, $projectElement, 'shortname')) - ->setTouched(self::getField($project, $projectElement, 'touched')) + ->setShortName(self::getField($projectElement, 'shortname', $project)) + ->setTouched(self::getField($projectElement, 'touched', $project)) ->setType(self::parseObjectAttribute('DimensionType', $project, $projectElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setUID(self::getField($project, $projectElement, 'uid')) + ->setUID(self::getField($projectElement, 'uid', $project)) ->setVatCode(self::parseObjectAttribute('VatCode', $project, $projectElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); // Get the projects element @@ -61,12 +61,12 @@ public static function map(Response $response) // Set the projects elements from the projects element $projectProjects->setAuthoriser(self::parseObjectAttribute('User', $projectProjects, $projectsElement, 'authoriser')) - ->setBillable(self::parseBooleanAttribute(self::getField($projectProjects, $projectsElement, 'billable'))) + ->setBillable(self::parseBooleanAttribute(self::getField($projectsElement, 'billable', $projectProjects))) ->setCustomer(self::parseObjectAttribute('Customer', $projectProjects, $projectsElement, 'customer')) - ->setInvoiceDescription(self::getField($projectProjects, $projectsElement, 'invoicedescription')) + ->setInvoiceDescription(self::getField($projectsElement, 'invoicedescription', $projectProjects)) ->setRate(self::parseObjectAttribute('Rate', $projectProjects, $projectsElement, 'rate')) - ->setValidFrom(self::parseDateAttribute(self::getField($projectProjects, $projectsElement, 'validfrom'))) - ->setValidTill(self::parseDateAttribute(self::getField($projectProjects, $projectsElement, 'validtill'))); + ->setValidFrom(self::parseDateAttribute(self::getField($projectsElement, 'validfrom', $projectProjects))) + ->setValidTill(self::parseDateAttribute(self::getField($projectsElement, 'validtill', $projectProjects))); // Set the projects elements from the projects element attributes $projectProjects->setAuthoriserInherit(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'authoriser', 'inherit'))) @@ -93,9 +93,9 @@ public static function map(Response $response) $projectQuantity = new ProjectQuantity(); // Set the quantity elements from the quantity element - $projectQuantity->setBillable(self::parseBooleanAttribute(self::getField($projectQuantity, $quantityElement, 'billable'))) - ->setLabel(self::getField($projectQuantity, $quantityElement, 'label')) - ->setMandatory(self::parseBooleanAttribute(self::getField($projectQuantity, $quantityElement, 'mandatory'))) + $projectQuantity->setBillable(self::parseBooleanAttribute(self::getField($quantityElement, 'billable', $projectQuantity))) + ->setLabel(self::getField($quantityElement, 'label', $projectQuantity)) + ->setMandatory(self::parseBooleanAttribute(self::getField($quantityElement, 'mandatory', $projectQuantity))) ->setRate(self::parseObjectAttribute('Rate', $projectQuantity, $quantityElement, 'rate')); // Set the quantity elements from the quantity element attributes diff --git a/src/Mappers/RateMapper.php b/src/Mappers/RateMapper.php index 47896275..1a62c59b 100644 --- a/src/Mappers/RateMapper.php +++ b/src/Mappers/RateMapper.php @@ -40,16 +40,16 @@ public static function map(Response $response) ->setStatus(self::parseEnumAttribute('Status', $rateElement->getAttribute('status'))); // Set the rate elements from the rate element - $rate->setCode(self::getField($rate, $rateElement, 'code')) - ->setCreated(self::parseDateTimeAttribute(self::getField($rate, $rateElement, 'created'))) + $rate->setCode(self::getField($rateElement, 'code', $rate)) + ->setCreated(self::parseDateTimeAttribute(self::getField($rateElement, 'created', $rate))) ->setCurrency(self::parseObjectAttribute('Currency', $rate, $rateElement, 'currency', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setModified(self::parseDateTimeAttribute(self::getField($rate, $rateElement, 'modified'))) - ->setName(self::getField($rate, $rateElement, 'name')) + ->setModified(self::parseDateTimeAttribute(self::getField($rateElement, 'modified', $rate))) + ->setName(self::getField($rateElement, 'name', $rate)) ->setOffice(self::parseObjectAttribute('Office', $rate, $rateElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setShortName(self::getField($rate, $rateElement, 'shortname')) - ->setTouched(self::getField($rate, $rateElement, 'touched')) - ->setType(self::parseEnumAttribute('RateType', self::getField($rate, $rateElement, 'type'))) - ->setUnit(self::getField($rate, $rateElement, 'unit')) + ->setShortName(self::getField($rateElement, 'shortname', $rate)) + ->setTouched(self::getField($rateElement, 'touched', $rate)) + ->setType(self::parseEnumAttribute('RateType', self::getField($rateElement, 'type', $rate))) + ->setUnit(self::getField($rateElement, 'unit', $rate)) ->setUser(self::parseObjectAttribute('User', $rate, $rateElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); // Get the ratechanges element @@ -69,10 +69,10 @@ public static function map(Response $response) ->setStatus(self::parseEnumAttribute('Status', $rateElement->getAttribute('status'))); // Set the project rate rate change elements from the ratechange element - $rateRateChange->setBeginDate(self::parseDateAttribute(self::getField($rateRateChange, $ratechangeElement, 'begindate'))) - ->setEndDate(self::parseDateAttribute(self::getField($rateRateChange, $ratechangeElement, 'enddate'))) - ->setExternalRate(self::getField($rateRateChange, $ratechangeElement, 'externalrate')) - ->setInternalRate(self::getField($rateRateChange, $ratechangeElement, 'internalrate')); + $rateRateChange->setBeginDate(self::parseDateAttribute(self::getField($ratechangeElement, 'begindate', $rateRateChange))) + ->setEndDate(self::parseDateAttribute(self::getField($ratechangeElement, 'enddate', $rateRateChange))) + ->setExternalRate(self::getField($ratechangeElement, 'externalrate', $rateRateChange)) + ->setInternalRate(self::getField($ratechangeElement, 'internalrate', $rateRateChange)); // Add the rate change to the project rate $rate->addRateChange($rateRateChange); diff --git a/src/Mappers/SupplierMapper.php b/src/Mappers/SupplierMapper.php index 5d0e4b41..480337a6 100644 --- a/src/Mappers/SupplierMapper.php +++ b/src/Mappers/SupplierMapper.php @@ -44,20 +44,20 @@ public static function map(Response $response) ->setStatus(self::parseEnumAttribute('Status', $supplierElement->getAttribute('status'))); // Set the supplier elements from the supplier element - $supplier->setBeginPeriod(self::getField($supplier, $supplierElement, 'beginperiod')) - ->setBeginYear(self::getField($supplier, $supplierElement, 'beginyear')) - ->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($supplier, $supplierElement, 'behaviour'))) - ->setCode(self::getField($supplier, $supplierElement, 'code')) - ->setEndPeriod(self::getField($supplier, $supplierElement, 'endperiod')) - ->setEndYear(self::getField($supplier, $supplierElement, 'endyear')) + $supplier->setBeginPeriod(self::getField($supplierElement, 'beginperiod', $supplier)) + ->setBeginYear(self::getField($supplierElement, 'beginyear', $supplier)) + ->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($supplierElement, 'behaviour', $supplier))) + ->setCode(self::getField($supplierElement, 'code', $supplier)) + ->setEndPeriod(self::getField($supplierElement, 'endperiod', $supplier)) + ->setEndYear(self::getField($supplierElement, 'endyear', $supplier)) ->setGroup(self::parseObjectAttribute('DimensionGroup', $supplier, $supplierElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setInUse(self::parseBooleanAttribute(self::getField($supplier, $supplierElement, 'name'))) - ->setName(self::getField($supplier, $supplierElement, 'name')) + ->setInUse(self::parseBooleanAttribute(self::getField($supplierElement, 'name', $supplier))) + ->setName(self::getField($supplierElement, 'name', $supplier)) ->setOffice(self::parseObjectAttribute('Office', $supplier, $supplierElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setTouched(self::getField($supplier, $supplierElement, 'touched')) + ->setTouched(self::getField($supplierElement, 'touched', $supplier)) ->setType(self::parseObjectAttribute('DimensionType', $supplier, $supplierElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setUID(self::getField($supplier, $supplierElement, 'uid')) - ->setWebsite(self::getField($supplier, $supplierElement, 'website')); + ->setUID(self::getField($supplierElement, 'uid', $supplier)) + ->setWebsite(self::getField($supplierElement, 'website', $supplier)); // Get the financials element $financialsElement = $responseDOM->getElementsByTagName('financials')->item(0); @@ -67,16 +67,16 @@ public static function map(Response $response) $supplierFinancials = new SupplierFinancials(); // Set the financials elements from the financials element - $supplierFinancials->setAccountType(self::parseEnumAttribute('AccountType', self::getField($supplierFinancials, $financialsElement, 'accounttype'))) - ->setDueDays(self::getField($supplierFinancials, $financialsElement, 'duedays')) - ->setLevel(self::getField($supplierFinancials, $financialsElement, 'level')) - ->setMatchType(self::parseEnumAttribute('MatchType', self::getField($supplierFinancials, $financialsElement, 'matchtype'))) - ->setMeansOfPayment(self::parseEnumAttribute('MeansOfPayment', self::getField($supplierFinancials, $financialsElement, 'meansofpayment'))) - ->setPayAvailable(self::parseBooleanAttribute(self::getField($supplierFinancials, $financialsElement, 'payavailable'))) + $supplierFinancials->setAccountType(self::parseEnumAttribute('AccountType', self::getField($financialsElement, 'accounttype', $supplierFinancials))) + ->setDueDays(self::getField($financialsElement, 'duedays', $supplierFinancials)) + ->setLevel(self::getField($financialsElement, 'level', $supplierFinancials)) + ->setMatchType(self::parseEnumAttribute('MatchType', self::getField($financialsElement, 'matchtype', $supplierFinancials))) + ->setMeansOfPayment(self::parseEnumAttribute('MeansOfPayment', self::getField($financialsElement, 'meansofpayment', $supplierFinancials))) + ->setPayAvailable(self::parseBooleanAttribute(self::getField($financialsElement, 'payavailable', $supplierFinancials))) ->setPayCode(self::parseObjectAttribute('PayCode', $supplierFinancials, $financialsElement, 'paycode', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setRelationsReference(self::getField($supplierFinancials, $financialsElement, 'relationsreference')) - ->setSubAnalyse(self::parseEnumAttribute('SubAnalyse', self::getField($supplierFinancials, $financialsElement, 'subanalyse'))) - ->setSubstitutionLevel(self::getField($supplierFinancials, $financialsElement, 'substitutionlevel')) + ->setRelationsReference(self::getField($financialsElement, 'relationsreference', $supplierFinancials)) + ->setSubAnalyse(self::parseEnumAttribute('SubAnalyse', self::getField($financialsElement, 'subanalyse', $supplierFinancials))) + ->setSubstitutionLevel(self::getField($financialsElement, 'substitutionlevel', $supplierFinancials)) ->setSubstituteWith(self::parseObjectAttribute('UnknownDimension', $supplierFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setVatCode(self::parseObjectAttribute('VatCode', $supplierFinancials, $financialsElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); @@ -120,8 +120,8 @@ public static function map(Response $response) if ($remittanceAdviceElement !== null) { // Set the supplier elements from the remittanceadvice element - $supplier->setRemittanceAdviceSendType(self::parseEnumAttribute('RemittanceAdviceSendType', self::getField($supplier, $remittanceAdviceElement, 'sendtype'))) - ->setRemittanceAdviceSendMail(self::getField($supplier, $remittanceAdviceElement, 'sendmail')); + $supplier->setRemittanceAdviceSendType(self::parseEnumAttribute('RemittanceAdviceSendType', self::getField($remittanceAdviceElement, 'sendtype', $supplier))) + ->setRemittanceAdviceSendMail(self::getField($remittanceAdviceElement, 'sendmail', $supplier)); } // Get the addresses element @@ -143,19 +143,19 @@ public static function map(Response $response) ->setType(self::parseEnumAttribute('AddressType', $addressElement->getAttribute('type'))); // Set the address elements from the address element - $supplierAddress->setCity(self::getField($supplierAddress, $addressElement, 'city')) + $supplierAddress->setCity(self::getField($addressElement, 'city', $supplierAddress)) ->setCountry(self::parseObjectAttribute('Country', $supplierAddress, $addressElement, 'country', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setEmail(self::getField($supplierAddress, $addressElement, 'email')) - ->setField1(self::getField($supplierAddress, $addressElement, 'field1')) - ->setField2(self::getField($supplierAddress, $addressElement, 'field2')) - ->setField3(self::getField($supplierAddress, $addressElement, 'field3')) - ->setField4(self::getField($supplierAddress, $addressElement, 'field4')) - ->setField5(self::getField($supplierAddress, $addressElement, 'field5')) - ->setField6(self::getField($supplierAddress, $addressElement, 'field6')) - ->setName(self::getField($supplierAddress, $addressElement, 'name')) - ->setPostcode(self::getField($supplierAddress, $addressElement, 'postcode')) - ->setTelephone(self::getField($supplierAddress, $addressElement, 'telephone')) - ->setTelefax(self::getField($supplierAddress, $addressElement, 'telefax')); + ->setEmail(self::getField($addressElement, 'email', $supplierAddress)) + ->setField1(self::getField($addressElement, 'field1', $supplierAddress)) + ->setField2(self::getField($addressElement, 'field2', $supplierAddress)) + ->setField3(self::getField($addressElement, 'field3', $supplierAddress)) + ->setField4(self::getField($addressElement, 'field4', $supplierAddress)) + ->setField5(self::getField($addressElement, 'field5', $supplierAddress)) + ->setField6(self::getField($addressElement, 'field6', $supplierAddress)) + ->setName(self::getField($addressElement, 'name', $supplierAddress)) + ->setPostcode(self::getField($addressElement, 'postcode', $supplierAddress)) + ->setTelephone(self::getField($addressElement, 'telephone', $supplierAddress)) + ->setTelefax(self::getField($addressElement, 'telefax', $supplierAddress)); // Add the address to the supplier $supplier->addAddress($supplierAddress); @@ -184,18 +184,18 @@ public static function map(Response $response) ->setID($bankElement->getAttribute('id')); // Set the bank elements from the bank element - $supplierBank->setAccountNumber(self::getField($supplierBank, $bankElement, 'accountnumber')) - ->setAddressField2(self::getField($supplierBank, $bankElement, 'field2')) - ->setAddressField3(self::getField($supplierBank, $bankElement, 'field3')) - ->setAscription(self::getField($supplierBank, $bankElement, 'ascription')) - ->setBankName(self::getField($supplierBank, $bankElement, 'bankname')) - ->setBicCode(self::getField($supplierBank, $bankElement, 'biccode')) - ->setCity(self::getField($supplierBank, $bankElement, 'city')) + $supplierBank->setAccountNumber(self::getField($bankElement, 'accountnumber', $supplierBank)) + ->setAddressField2(self::getField($bankElement, 'field2', $supplierBank)) + ->setAddressField3(self::getField($bankElement, 'field3', $supplierBank)) + ->setAscription(self::getField($bankElement, 'ascription', $supplierBank)) + ->setBankName(self::getField($bankElement, 'bankname', $supplierBank)) + ->setBicCode(self::getField($bankElement, 'biccode', $supplierBank)) + ->setCity(self::getField($bankElement, 'city', $supplierBank)) ->setCountry(self::parseObjectAttribute('Country', $supplierBank, $bankElement, 'country', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setIban(self::getField($supplierBank, $bankElement, 'iban')) - ->setNatBicCode(self::getField($supplierBank, $bankElement, 'natbiccode')) - ->setPostcode(self::getField($supplierBank, $bankElement, 'postcode')) - ->setState(self::getField($supplierBank, $bankElement, 'state')); + ->setIban(self::getField($bankElement, 'iban', $supplierBank)) + ->setNatBicCode(self::getField($bankElement, 'natbiccode', $supplierBank)) + ->setPostcode(self::getField($bankElement, 'postcode', $supplierBank)) + ->setState(self::getField($bankElement, 'state', $supplierBank)); // Add the bank to the supplier $supplier->addBank($supplierBank); @@ -223,9 +223,9 @@ public static function map(Response $response) ->setStatus(self::parseEnumAttribute('Status', $postingruleElement->getAttribute('status'))); // Set the postingrule elements from the postingrule element - $supplierPostingRule->setAmount(self::parseMoneyAttribute(self::getField($supplierPostingRule, $postingruleElement, 'amount'))) + $supplierPostingRule->setAmount(self::parseMoneyAttribute(self::getField($postingruleElement, 'amount', $supplierPostingRule))) ->setCurrency(self::parseObjectAttribute('Currency', $supplierPostingRule, $postingruleElement, 'currency', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setDescription(self::getField($supplierPostingRule, $postingruleElement, 'description')); + ->setDescription(self::getField($postingruleElement, 'description', $supplierPostingRule)); // Get the lines element $linesDOMTag = $postingruleElement->getElementsByTagName('lines'); @@ -241,12 +241,12 @@ public static function map(Response $response) $supplierLine = new SupplierLine(); // Set the line elements from the line element - $supplierLine->setDescription(self::getField($supplierLine, $lineElement, 'description')) + $supplierLine->setDescription(self::getField($lineElement, 'description', $supplierLine)) ->setDimension1(self::parseObjectAttribute('GeneralLedger', $supplierLine, $lineElement, 'dimension1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setDimension2(self::parseObjectAttribute('CostCenter', $supplierLine, $lineElement, 'dimension2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setDimension3(self::parseObjectAttribute('UnknownDimension', $supplierLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setOffice(self::parseObjectAttribute('Office', $supplierLine, $lineElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setRatio(self::getField($supplierLine, $lineElement, 'ratio')) + ->setRatio(self::getField($lineElement, 'ratio', $supplierLine)) ->setVatCode(self::parseObjectAttribute('VatCode', $supplierLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); // Set the line elements from the line element attributes @@ -275,8 +275,8 @@ public static function map(Response $response) if ($paymentConditionsElement !== null) { // Set the supplier elements from the paymentconditions element - $supplier->setPaymentConditionDiscountDays(self::getField($supplier, $paymentConditionsElement, 'discountdays')) - ->setPaymentConditionDiscountPercentage(self::getField($supplier, $paymentConditionsElement, 'discountpercentage')); + $supplier->setPaymentConditionDiscountDays(self::getField($paymentConditionsElement, 'discountdays', $supplier)) + ->setPaymentConditionDiscountPercentage(self::getField($paymentConditionsElement, 'discountpercentage', $supplier)); } // Get the blockedaccountpaymentconditions element @@ -284,8 +284,8 @@ public static function map(Response $response) if ($blockedAccountPaymentConditionsElement !== null) { // Set the supplier elements from the blockedaccountpaymentconditions element - $supplier->setBlockedAccountPaymentConditionsIncludeVat(self::parseEnumAttribute('BlockedAccountPaymentConditionsIncludeVat', self::getField($supplier, $blockedAccountPaymentConditionsElement, 'includevat'))) - ->setBlockedAccountPaymentConditionsPercentage(self::getField($supplier, $blockedAccountPaymentConditionsElement, 'percentage')); + $supplier->setBlockedAccountPaymentConditionsIncludeVat(self::parseEnumAttribute('BlockedAccountPaymentConditionsIncludeVat', self::getField($blockedAccountPaymentConditionsElement, 'includevat', $supplier))) + ->setBlockedAccountPaymentConditionsPercentage(self::getField($blockedAccountPaymentConditionsElement, 'percentage', $supplier)); } // Return the complete object diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 88595386..453fdc92 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -85,44 +85,44 @@ public static function map(string $transactionClassName, Response $response): Ba $transaction->setRaiseWarning(self::parseBooleanAttribute($raiseWarning)); } - $transaction->setCode(self::getField($transaction, $transactionElement, 'code')) - ->setCurrencyFromString(self::getField($transaction, $transactionElement, 'currency')) - ->setDateFromString(self::getField($transaction, $transactionElement, 'date')) - ->setFreetext1(self::getField($transaction, $transactionElement, 'freetext1')) - ->setFreetext2(self::getField($transaction, $transactionElement, 'freetext2')) - ->setFreetext3(self::getField($transaction, $transactionElement, 'freetext3')) - ->setOfficeFromString(self::getField($transaction, $transactionElement, 'office')) - ->setOrigin(self::getField($transaction, $transactionElement, 'origin')) - ->setNumber(self::getField($transaction, $transactionElement, 'number')) - ->setPeriod(self::getField($transaction, $transactionElement, 'period')); + $transaction->setCode(self::getField($transactionElement, 'code', $transaction)) + ->setCurrencyFromString(self::getField($transactionElement, 'currency', $transaction)) + ->setDateFromString(self::getField($transactionElement, 'date', $transaction)) + ->setFreetext1(self::getField($transactionElement, 'freetext1', $transaction)) + ->setFreetext2(self::getField($transactionElement, 'freetext2', $transaction)) + ->setFreetext3(self::getField($transactionElement, 'freetext3', $transaction)) + ->setOfficeFromString(self::getField($transactionElement, 'office', $transaction)) + ->setOrigin(self::getField($transactionElement, 'origin', $transaction)) + ->setNumber(self::getField($transactionElement, 'number', $transaction)) + ->setPeriod(self::getField($transactionElement, 'period', $transaction)); if (Util::objectUses(CloseAndStartValueFields::class, $transaction)) { - $transaction->setStartValueFromFloat(self::getField($transaction, $transactionElement, 'startvalue')); + $transaction->setStartValueFromFloat(self::getField($transactionElement, 'startvalue', $transaction)); } if (Util::objectUses(DueDateField::class, $transaction)) { - $transaction->setDueDateFromString(self::getField($transaction, $transactionElement, 'duedate')); + $transaction->setDueDateFromString(self::getField($transactionElement, 'duedate', $transaction)); } if (Util::objectUses(InvoiceNumberField::class, $transaction)) { - $transaction->setInvoiceNumber(self::getField($transaction, $transactionElement, 'invoicenumber')); + $transaction->setInvoiceNumber(self::getField($transactionElement, 'invoicenumber', $transaction)); $transaction->setInvoiceNumberRaiseWarning(self::parseBooleanAttribute(self::getAttribute($transactionElement, 'invoicenumber', 'raisewarning'))); } if (Util::objectUses(OriginReferenceField::class, $transaction)) { - $transaction->setOriginReference(self::getField($transaction, $transactionElement, 'originreference')); + $transaction->setOriginReference(self::getField($transactionElement, 'originreference', $transaction)); } if (Util::objectUses(PaymentReferenceField::class, $transaction)) { - $transaction->setPaymentReference(self::getField($transaction, $transactionElement, 'paymentreference')); + $transaction->setPaymentReference(self::getField($transactionElement, 'paymentreference', $transaction)); } if (Util::objectUses(RegimeField::class, $transaction)) { - $transaction->setRegime(self::getField($transaction, $transactionElement, 'regime')); + $transaction->setRegime(self::getField($transactionElement, 'regime', $transaction)); } if (Util::objectUses(StatementNumberField::class, $transaction)) { - $transaction->setStatementnumber(self::getField($transaction, $transactionElement, 'statementnumber')); + $transaction->setStatementnumber(self::getField($transactionElement, 'statementnumber', $transaction)); } // Parse the transaction lines @@ -144,21 +144,21 @@ public static function map(string $transactionClassName, Response $response): Ba $lineType = $lineElement->getAttribute('type'); $transactionLine - ->setBaseValueFromFloat(self::getField($transaction, $lineElement, 'basevalue')) - ->setComment(self::getField($transaction, $lineElement, 'comment')) - ->setValueFromFloat(self::getField($transaction, $lineElement, 'value')) - ->setDebitCredit(self::parseEnumAttribute('DebitCredit', self::getField($transaction, $lineElement, 'debitcredit'))) - ->setDescription(self::getField($transaction, $lineElement, 'description')) - ->setDestOfficeFromString(self::getField($transaction, $lineElement, 'destoffice')) - ->setDim1FromString(self::getField($transaction, $lineElement, 'dim1')) + ->setBaseValueFromFloat(self::getField($lineElement, 'basevalue', $transactionLine)) + ->setComment(self::getField($lineElement, 'comment', $transactionLine)) + ->setValueFromFloat(self::getField($lineElement, 'value', $transactionLine)) + ->setDebitCredit(self::parseEnumAttribute('DebitCredit', self::getField($lineElement, 'debitcredit', $transactionLine))) + ->setDescription(self::getField($lineElement, 'description', $transactionLine)) + ->setDestOfficeFromString(self::getField($lineElement, 'destoffice', $transactionLine)) + ->setDim1FromString(self::getField($lineElement, 'dim1', $transactionLine)) ->setId($lineElement->getAttribute('id')) ->setLineType(new LineType($lineType)) - ->setMatchStatus(self::parseEnumAttribute('MatchStatus', self::getField($transaction, $lineElement, 'matchstatus'))) - ->setRate(self::getField($transaction, $lineElement, 'rate')) - ->setRepRate(self::getField($transaction, $lineElement, 'reprate')) - ->setRepValueFromFloat(self::getField($transaction, $lineElement, 'repvalue')); + ->setMatchStatus(self::parseEnumAttribute('MatchStatus', self::getField($lineElement, 'matchstatus', $transactionLine))) + ->setRate(self::getField($lineElement, 'rate', $transactionLine)) + ->setRepRate(self::getField($lineElement, 'reprate', $transactionLine)) + ->setRepValueFromFloat(self::getField($lineElement, 'repvalue', $transactionLine)); - $freeChar = self::getField($transaction, $lineElement, 'freechar'); + $freeChar = self::getField($lineElement, 'freechar', $transactionLine); if ($freeChar !== null && strlen($freeChar) == 1) { $transactionLine->setFreeChar($freeChar); @@ -166,68 +166,68 @@ public static function map(string $transactionClassName, Response $response): Ba if ($transaction instanceof BankTransaction || $transaction instanceof CashTransaction || $transaction instanceof JournalTransaction) { if ($lineType == LineType::DETAIL()) { - $baseValueOpen = self::getField($transaction, $lineElement, 'basevalueopen') ?: self::getField($transaction, $lineElement, 'openbasevalue'); + $baseValueOpen = self::getField($lineElement, 'basevalueopen', $transactionLine) ?: self::getField($lineElement, 'openbasevalue', $transactionLine); if ($baseValueOpen) { $transactionLine->setBaseValueOpenFromFloat($baseValueOpen); } - $transactionLine->setDim2FromString(self::getField($transaction, $lineElement, 'dim2')); - $transactionLine->setDim3FromString(self::getField($transaction, $lineElement, 'dim3')); - $transactionLine->setMatchLevel(self::getField($transaction, $lineElement, 'matchlevel')); - $transactionLine->setRelation(self::getField($transaction, $lineElement, 'relation')); - $transactionLine->setRepValueOpenFromFloat(self::getField($transaction, $lineElement, 'repvalueopen')); + $transactionLine->setDim2FromString(self::getField($lineElement, 'dim2', $transactionLine)); + $transactionLine->setDim3FromString(self::getField($lineElement, 'dim3', $transactionLine)); + $transactionLine->setMatchLevel(self::getField($lineElement, 'matchlevel', $transactionLine)); + $transactionLine->setRelation(self::getField($lineElement, 'relation', $transactionLine)); + $transactionLine->setRepValueOpenFromFloat(self::getField($lineElement, 'repvalueopen', $transactionLine)); } } if ($transaction instanceof PurchaseTransaction || $transaction instanceof SalesTransaction) { if ($lineType == LineType::DETAIL()) { - $transactionLine->setDim2FromString(self::getField($transaction, $lineElement, 'dim2')); - $transactionLine->setDim3FromString(self::getField($transaction, $lineElement, 'dim3')); + $transactionLine->setDim2FromString(self::getField($lineElement, 'dim2', $transactionLine)); + $transactionLine->setDim3FromString(self::getField($lineElement, 'dim3', $transactionLine)); } elseif ($transaction instanceof PurchaseTransaction && $lineType == LineType::VAT()) { - $transactionLine->setDim3FromString(self::getField($transaction, $lineElement, 'dim3')); + $transactionLine->setDim3FromString(self::getField($lineElement, 'dim3', $transactionLine)); } elseif ($lineType == LineType::TOTAL()) { - $transactionLine->setDim2FromString(self::getField($transaction, $lineElement, 'dim2')); + $transactionLine->setDim2FromString(self::getField($lineElement, 'dim2', $transactionLine)); - $baseValueOpen = self::getField($transaction, $lineElement, 'basevalueopen') ?: self::getField($transaction, $lineElement, 'openbasevalue'); + $baseValueOpen = self::getField($lineElement, 'basevalueopen', $transactionLine) ?: self::getField($lineElement, 'openbasevalue', $transactionLine); if ($baseValueOpen) { $transactionLine->setBaseValueOpenFromFloat($baseValueOpen); } - $transactionLine->setMatchLevel(self::getField($transaction, $lineElement, 'matchlevel')); - $transactionLine->setRelation(self::getField($transaction, $lineElement, 'relation')); - $transactionLine->setRepValueOpenFromFloat(self::getField($transaction, $lineElement, 'repvalueopen')); + $transactionLine->setMatchLevel(self::getField($lineElement, 'matchlevel', $transactionLine)); + $transactionLine->setRelation(self::getField($lineElement, 'relation', $transactionLine)); + $transactionLine->setRepValueOpenFromFloat(self::getField($lineElement, 'repvalueopen', $transactionLine)); } } if ($lineType == LineType::DETAIL()) { if (Util::objectUses(CurrencyDateField::class, $transactionLine)) { - $transactionLine->setCurrencyDateFromString(self::getField($transaction, $lineElement, 'currencydate')); + $transactionLine->setCurrencyDateFromString(self::getField($lineElement, 'currencydate', $transactionLine)); } if (Util::objectUses(InvoiceNumberField::class, $transactionLine)) { - $transactionLine->setInvoiceNumber(self::getField($transaction, $lineElement, 'invoicenumber')); + $transactionLine->setInvoiceNumber(self::getField($lineElement, 'invoicenumber', $transactionLine)); } - $transactionLine->setVatBaseValueFromFloat(self::getField($transaction, $lineElement, 'vatbasevalue')); - $transactionLine->setVatRepValueFromFloat(self::getField($transaction, $lineElement, 'vatrepvalue')); - $transactionLine->setVatValueFromFloat(self::getField($transaction, $lineElement, 'vatvalue')); + $transactionLine->setVatBaseValueFromFloat(self::getField($lineElement, 'vatbasevalue', $transactionLine)); + $transactionLine->setVatRepValueFromFloat(self::getField($lineElement, 'vatrepvalue', $transactionLine)); + $transactionLine->setVatValueFromFloat(self::getField($lineElement, 'vatvalue', $transactionLine)); } elseif ($lineType == LineType::VAT()) { if (Util::objectUses(BaselineField::class, $transactionLine)) { - $transactionLine->setBaseline(self::getField($transaction, $lineElement, 'baseline')); + $transactionLine->setBaseline(self::getField($lineElement, 'baseline', $transactionLine)); } - $transactionLine->setVatBaseTurnoverFromFloat(self::getField($transaction, $lineElement, 'vatbaseturnover')); - $transactionLine->setVatRepTurnoverFromFloat(self::getField($transaction, $lineElement, 'vatrepturnover')); - $transactionLine->setVatTurnoverFromFloat(self::getField($transaction, $lineElement, 'vatturnover')); + $transactionLine->setVatBaseTurnoverFromFloat(self::getField($lineElement, 'vatbaseturnover', $transactionLine)); + $transactionLine->setVatRepTurnoverFromFloat(self::getField($lineElement, 'vatrepturnover', $transactionLine)); + $transactionLine->setVatTurnoverFromFloat(self::getField($lineElement, 'vatturnover', $transactionLine)); } elseif ($lineType == LineType::TOTAL()) { if (Util::objectUses(MatchDateField::class, $transactionLine)) { - $transactionLine->setMatchDateFromString(self::getField($transaction, $lineElement, 'matchdate')); + $transactionLine->setMatchDateFromString(self::getField($lineElement, 'matchdate', $transactionLine)); } if (Util::objectUses(ValueOpenField::class, $transactionLine)) { - $valueOpen = self::getField($transaction, $lineElement, 'valueopen') ?: self::getField($transaction, $lineElement, 'openvalue'); + $valueOpen = self::getField($lineElement, 'valueopen', $transactionLine) ?: self::getField($lineElement, 'openvalue', $transactionLine); if ($valueOpen) { $transactionLine->setValueOpenFromFloat($valueOpen); @@ -235,36 +235,36 @@ public static function map(string $transactionClassName, Response $response): Ba } if (Util::objectUses(VatBaseTotalField::class, $transactionLine)) { - $transactionLine->setVatBaseTotalFromFloat(self::getField($transaction, $lineElement, 'vatbasetotal')); + $transactionLine->setVatBaseTotalFromFloat(self::getField($lineElement, 'vatbasetotal', $transactionLine)); } if (Util::objectUses(VatRepTotalField::class, $transactionLine)) { - $transactionLine->setVatRepTotalFromFloat(self::getField($transaction, $lineElement, 'vatreptotal')); + $transactionLine->setVatRepTotalFromFloat(self::getField($lineElement, 'vatreptotal', $transactionLine)); } if (Util::objectUses(VatTotalField::class, $transactionLine)) { - $transactionLine->setVatTotalFromFloat(self::getField($transaction, $lineElement, 'vattotal')); + $transactionLine->setVatTotalFromFloat(self::getField($lineElement, 'vattotal', $transactionLine)); } } if ($lineType != LineType::TOTAL()) { if (Util::objectUses(PerformanceCountryField::class, $transactionLine)) { - $transactionLine->setPerformanceCountryFromString(self::getField($transaction, $lineElement, 'performancecountry')); + $transactionLine->setPerformanceCountryFromString(self::getField($lineElement, 'performancecountry', $transactionLine)); } if (Util::objectUses(PerformanceDateField::class, $transactionLine)) { - $transactionLine->setPerformanceDateFromString(self::getField($transaction, $lineElement, 'performancedate')); + $transactionLine->setPerformanceDateFromString(self::getField($lineElement, 'performancedate', $transactionLine)); } if (Util::objectUses(PerformanceTypeField::class, $transactionLine)) { - $transactionLine->setPerformanceTypeFromString(self::getField($transaction, $lineElement, 'performancetype')); + $transactionLine->setPerformanceTypeFromString(self::getField($lineElement, 'performancetype', $transactionLine)); } if (Util::objectUses(PerformanceVatNumberField::class, $transactionLine)) { - $transactionLine->setPerformanceVatNumber(self::getField($transaction, $lineElement, 'performancevatnumber')); + $transactionLine->setPerformanceVatNumber(self::getField($lineElement, 'performancevatnumber', $transactionLine)); } - $transactionLine->setVatCodeFromString(self::getField($transaction, $lineElement, 'vatcode')); + $transactionLine->setVatCodeFromString(self::getField($lineElement, 'vatcode', $transactionLine)); } $transaction->addLine($transactionLine); diff --git a/src/Mappers/UserMapper.php b/src/Mappers/UserMapper.php index 2095f76f..d7d28b06 100644 --- a/src/Mappers/UserMapper.php +++ b/src/Mappers/UserMapper.php @@ -43,20 +43,20 @@ public static function map(Response $response) $user->setStatus(self::parseEnumAttribute('Status', $userElement->getAttribute('status'))); // Set the user elements from the user element - $user->setAcceptExtraCostField(self::parseBooleanAttribute(self::getField($user, $userElement, 'acceptextracost'))) - ->setCulture(self::getField($user, $userElement, 'culture')) - ->setCode(self::getField($user, $userElement, 'code')) - ->setCreated(self::parseDateTimeAttribute(self::getField($user, $userElement, 'created'))) - ->setDemo(self::parseBooleanAttribute(self::getField($user, $userElement, 'demo'))) - ->setEmail(self::getField($user, $userElement, 'email')) - ->setExchangeQuota(self::getField($user, $userElement, 'exchangequota')) - ->setFileManagerQuota(self::getField($user, $userElement, 'filemanagerquota')) - ->setModified(self::parseDateTimeAttribute(self::getField($user, $userElement, 'modified'))) - ->setName(self::getField($user, $userElement, 'name')) + $user->setAcceptExtraCostField(self::parseBooleanAttribute(self::getField($userElement, 'acceptextracost', $user))) + ->setCulture(self::getField($userElement, 'culture', $user)) + ->setCode(self::getField($userElement, 'code', $user)) + ->setCreated(self::parseDateTimeAttribute(self::getField($userElement, 'created', $user))) + ->setDemo(self::parseBooleanAttribute(self::getField($userElement, 'demo', $user))) + ->setEmail(self::getField($userElement, 'email', $user)) + ->setExchangeQuota(self::getField($userElement, 'exchangequota', $user)) + ->setFileManagerQuota(self::getField($userElement, 'filemanagerquota', $user)) + ->setModified(self::parseDateTimeAttribute(self::getField($userElement, 'modified', $user))) + ->setName(self::getField($userElement, 'name', $user)) ->setRole(self::parseObjectAttribute('UserRole', $user, $userElement, 'method', array('level' => 'setLevel', 'name' => 'setName', 'shortname' => 'setShortName'))) - ->setShortName(self::getField($user, $userElement, 'shortname')) - ->setTouched(self::getField($user, $userElement, 'touched')) - ->setType(self::parseEnumAttribute('UserType', self::getField($user, $userElement, 'type'))); + ->setShortName(self::getField($userElement, 'shortname', $user)) + ->setTouched(self::getField($userElement, 'touched', $user)) + ->setType(self::parseEnumAttribute('UserType', self::getField($userElement, 'type', $user))); // Set the user elements from the user element attributes $user->setCultureName(self::getAttribute($userElement, 'culture', 'name')) diff --git a/src/Mappers/UserRoleMapper.php b/src/Mappers/UserRoleMapper.php index 810b5f41..a2d4aa9d 100644 --- a/src/Mappers/UserRoleMapper.php +++ b/src/Mappers/UserRoleMapper.php @@ -35,9 +35,9 @@ public static function map(Response $response) $userRoleElement = $responseDOM->documentElement; // Set the user role elements from the user role element - $userRole->setCode(self::getField($userRole, $userRoleElement, 'code')) - ->setName(self::getField($userRole, $userRoleElement, 'name')) - ->setShortName(self::getField($userRole, $userRoleElement, 'shortname')); + $userRole->setCode(self::getField($userRoleElement, 'code', $userRole)) + ->setName(self::getField($userRoleElement, 'name', $userRole)) + ->setShortName(self::getField($userRoleElement, 'shortname', $userRole)); // Return the complete object return $userRole; diff --git a/src/Mappers/VatCodeMapper.php b/src/Mappers/VatCodeMapper.php index e0f257a7..22dda6a4 100644 --- a/src/Mappers/VatCodeMapper.php +++ b/src/Mappers/VatCodeMapper.php @@ -41,14 +41,14 @@ public static function map(Response $response) ->setStatus(self::parseEnumAttribute('Status', $vatCodeElement->getAttribute('status'))); // Set the vat code elements from the vat element - $vatCode->setCode(self::getField($vatCode, $vatCodeElement, 'code')) - ->setCreated(self::parseDateTimeAttribute(self::getField($vatCode, $vatCodeElement, 'created'))) - ->setModified(self::parseDateTimeAttribute(self::getField($vatCode, $vatCodeElement, 'modified'))) - ->setName(self::getField($vatCode, $vatCodeElement, 'name')) - ->setShortName(self::getField($vatCode, $vatCodeElement, 'shortname')) - ->setTouched(self::getField($vatCode, $vatCodeElement, 'touched')) - ->setType(self::parseEnumAttribute('VatType', self::getField($vatCode, $vatCodeElement, 'type'))) - ->setUID(self::getField($vatCode, $vatCodeElement, 'uid')) + $vatCode->setCode(self::getField($vatCodeElement, 'code', $vatCode)) + ->setCreated(self::parseDateTimeAttribute(self::getField($vatCodeElement, 'created', $vatCode))) + ->setModified(self::parseDateTimeAttribute(self::getField($vatCodeElement, 'modified', $vatCode))) + ->setName(self::getField($vatCodeElement, 'name', $vatCode)) + ->setShortName(self::getField($vatCodeElement, 'shortname', $vatCode)) + ->setTouched(self::getField($vatCodeElement, 'touched', $vatCode)) + ->setType(self::parseEnumAttribute('VatType', self::getField($vatCodeElement, 'type', $vatCode))) + ->setUID(self::getField($vatCodeElement, 'uid', $vatCode)) ->setUser(self::parseObjectAttribute('User', $vatCode, $vatCodeElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); // Get the percentages element @@ -65,11 +65,11 @@ public static function map(Response $response) $vatCodePercentage = new VatCodePercentage(); // Set the vat code percentage elements from the percentage element - $vatCodePercentage->setCreated(self::parseDateTimeAttribute(self::getField($vatCodePercentage, $percentageElement, 'created'))) - ->setDate(self::parseDateAttribute(self::getField($vatCodePercentage, $percentageElement, 'date'))) - ->setName(self::getField($vatCodePercentage, $percentageElement, 'name')) - ->setPercentage(self::getField($vatCodePercentage, $percentageElement, 'percentage')) - ->setShortName(self::getField($vatCodePercentage, $percentageElement, 'shortname')) + $vatCodePercentage->setCreated(self::parseDateTimeAttribute(self::getField($percentageElement, 'created', $vatCodePercentage))) + ->setDate(self::parseDateAttribute(self::getField($percentageElement, 'date', $vatCodePercentage))) + ->setName(self::getField($percentageElement, 'name', $vatCodePercentage)) + ->setPercentage(self::getField($percentageElement, 'percentage', $vatCodePercentage)) + ->setShortName(self::getField($percentageElement, 'shortname', $vatCodePercentage)) ->setUser(self::parseObjectAttribute('User', $vatCodePercentage, $percentageElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); // Get the accounts element @@ -92,8 +92,8 @@ public static function map(Response $response) $vatCodeAccount->setDim1(self::parseObjectAttribute('GeneralLedger', $vatCodeAccount, $accountElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setGroup(self::parseObjectAttribute('VatGroup', $vatCodeAccount, $accountElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setGroupCountry(self::parseObjectAttribute('VatGroupCountry', $vatCodeAccount, $accountElement, 'groupcountry', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setLineType(self::parseEnumAttribute('LineType', self::getField($vatCodeAccount, $accountElement, 'linetype'))) - ->setPercentage(self::getField($vatCodeAccount, $accountElement, 'percentage')); + ->setLineType(self::parseEnumAttribute('LineType', self::getField($accountElement, 'linetype', $vatCodeAccount))) + ->setPercentage(self::getField($accountElement, 'percentage', $vatCodeAccount)); // Add the account to the percentage $vatCodePercentage->addAccount($vatCodeAccount); diff --git a/src/Mappers/VatGroupCountryMapper.php b/src/Mappers/VatGroupCountryMapper.php index 1145d0a4..4d2efce1 100644 --- a/src/Mappers/VatGroupCountryMapper.php +++ b/src/Mappers/VatGroupCountryMapper.php @@ -35,9 +35,9 @@ public static function map(Response $response) $vatGroupElement = $responseDOM->documentElement; // Set the vat group country elements from the vat group country element - $vatGroupCountry->setCode(self::getField($vatGroupCountry, $vatGroupElement, 'code')) - ->setName(self::getField($vatGroupCountry, $vatGroupElement, 'name')) - ->setShortName(self::getField($vatGroupCountry, $vatGroupElement, 'shortname')); + $vatGroupCountry->setCode(self::getField($vatGroupElement, 'code', $vatGroupCountry)) + ->setName(self::getField($vatGroupElement, 'name', $vatGroupCountry)) + ->setShortName(self::getField($vatGroupElement, 'shortname', $vatGroupCountry)); // Return the complete object return $vatGroupCountry; diff --git a/src/Mappers/VatGroupMapper.php b/src/Mappers/VatGroupMapper.php index aaf17c87..9af8f0e9 100644 --- a/src/Mappers/VatGroupMapper.php +++ b/src/Mappers/VatGroupMapper.php @@ -35,9 +35,9 @@ public static function map(Response $response) $vatGroupElement = $responseDOM->documentElement; // Set the vat group elements from the vat group element - $vatGroup->setCode(self::getField($vatGroup, $vatGroupElement, 'code')) - ->setName(self::getField($vatGroup, $vatGroupElement, 'name')) - ->setShortName(self::getField($vatGroup, $vatGroupElement, 'shortname')); + $vatGroup->setCode(self::getField($vatGroupElement, 'code', $vatGroup)) + ->setName(self::getField($vatGroupElement, 'name', $vatGroup)) + ->setShortName(self::getField($vatGroupElement, 'shortname', $vatGroup)); // Return the complete object return $vatGroup; diff --git a/src/Request/Read/Read.php b/src/Request/Read/Read.php index 7b2d1bc0..bd4054c7 100644 --- a/src/Request/Read/Read.php +++ b/src/Request/Read/Read.php @@ -63,7 +63,7 @@ protected function add($element, $value) * Sets the office code for this request. * * @access public - * @param int $office + * @param $office * @return \PhpTwinfield\Request\Read\Read */ public function setOffice($office) diff --git a/src/Secure/Provider/OAuthProvider.php b/src/Secure/Provider/OAuthProvider.php index 611d90fb..f4fc0478 100644 --- a/src/Secure/Provider/OAuthProvider.php +++ b/src/Secure/Provider/OAuthProvider.php @@ -88,12 +88,18 @@ public function getResourceOwnerDetailsUrl(AccessToken $token): string /** * Returns the default scopes used by this provider. * - * This should only be the scopes that are required to request the details of the resource owner, rather than all - * the available scopes. + * Besides the ORGANISATION_USER and OPEN_ID scopes, the OFFLINE_ACCESS and ORGANISATION scopes have to + * be used in order to receive a refresh token and cluster URL. These are necessary to refresh the access + * token and make requests to the correct endpoint. */ protected function getDefaultScopes(): array { - return [self::SCOPE_ORGANISATION_USER, self::SCOPE_OPEN_ID]; + return [ + self::SCOPE_ORGANISATION_USER, + self::SCOPE_OPEN_ID, + self::SCOPE_OFFLINE_ACCESS, + self::SCOPE_ORGANISATION + ]; } /** From 39a9221ed0f35cee6b9f4d2a6b5bb03ae99837b3 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 10 Jun 2019 18:06:49 +0200 Subject: [PATCH 282/388] Update BaseMapper.php --- src/Mappers/BaseMapper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index d4b73f4d..994926f8 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -37,7 +37,7 @@ protected static function getAttribute(\DOMElement $element, string $fieldTagNam return $fieldElement->getAttribute($attributeName); } - protected static function getField($object, \DOMElement $element, string $fieldTagName): ?string + protected static function getField(\DOMElement $element, string $fieldTagName, $object): ?string { $fieldElement = $element->getElementsByTagName($fieldTagName)->item(0); From e433224008b28f72f989a162f6172def29c42569 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 10 Jun 2019 18:07:06 +0200 Subject: [PATCH 283/388] Update BaseMapper.php --- src/Mappers/BaseMapper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index 994926f8..ffefd4ef 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -37,7 +37,7 @@ protected static function getAttribute(\DOMElement $element, string $fieldTagNam return $fieldElement->getAttribute($attributeName); } - protected static function getField(\DOMElement $element, string $fieldTagName, $object): ?string + protected static function getField(\DOMElement $element, string $fieldTagName, $object = null): ?string { $fieldElement = $element->getElementsByTagName($fieldTagName)->item(0); From fe189f9c8fa4db39ceb718f958cadbba4e9c8105 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 10 Jun 2019 18:10:03 +0200 Subject: [PATCH 284/388] Update BaseMapper.php --- src/Mappers/BaseMapper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index ffefd4ef..abbc5ad5 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -116,7 +116,7 @@ protected static function parseObjectAttribute(string $className, $object, \DOME { if ($className == "DimensionGroupDimension" || $className == "UnknownDimension") { if ($className == "DimensionGroupDimension") { - $type = self::getField($object, $element, "type"); + $type = self::getField($element, "type", $object); } elseif ($className == "UnknownDimension") { $type = self::getAttribute($element, $fieldTagName, "dimensiontype"); } @@ -154,7 +154,7 @@ protected static function parseObjectAttribute(string $className, $object, \DOME $class = "\\PhpTwinfield\\" . $className; $object2 = new $class(); - $object2->setCode(self::getField($object, $element, $fieldTagName)); + $object2->setCode(self::getField($element, $fieldTagName, $object)); if (isset($attributes)) { foreach ($attributes as $attributeName => $method) { From e6fc8b5cb1d91f0ed703e828b948b3ad4a02c407 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 10 Jun 2019 21:40:29 +0200 Subject: [PATCH 285/388] Upload --- src/ApiConnectors/BaseApiConnector.php | 39 +++++++------ src/DomDocuments/BaseDocument.php | 6 +- src/Mappers/ActivityMapper.php | 18 +++--- src/Mappers/ArticleMapper.php | 14 ++--- src/Mappers/AssetMethodMapper.php | 32 +++++------ src/Mappers/BaseMapper.php | 57 +++++++++---------- src/Mappers/CostCenterMapper.php | 8 +-- src/Mappers/CurrencyMapper.php | 4 +- src/Mappers/CustomerMapper.php | 56 +++++++++--------- src/Mappers/DimensionGroupMapper.php | 8 +-- src/Mappers/DimensionTypeMapper.php | 4 +- src/Mappers/FixedAssetMapper.php | 36 ++++++------ src/Mappers/GeneralLedgerMapper.php | 20 +++---- src/Mappers/InvoiceMapper.php | 26 ++++----- src/Mappers/OfficeMapper.php | 4 +- src/Mappers/ProjectMapper.php | 18 +++--- src/Mappers/RateMapper.php | 12 ++-- src/Mappers/SupplierMapper.php | 50 ++++++++-------- src/Mappers/TransactionMapper.php | 6 +- src/Mappers/UserMapper.php | 6 +- src/Mappers/VatCodeMapper.php | 16 +++--- src/Request/Read/Activity.php | 6 +- src/Request/Read/Article.php | 6 +- src/Request/Read/BrowseDefinition.php | 2 +- src/Request/Read/CostCenter.php | 6 +- src/Request/Read/Currency.php | 6 +- src/Request/Read/Customer.php | 6 +- src/Request/Read/FixedAsset.php | 6 +- src/Request/Read/GeneralLedger.php | 6 +- src/Request/Read/Invoice.php | 6 +- src/Request/Read/Office.php | 1 + src/Request/Read/Project.php | 6 +- src/Request/Read/Rate.php | 6 +- src/Request/Read/Read.php | 6 +- src/Request/Read/Supplier.php | 6 +- src/Request/Read/Transaction.php | 4 +- src/Request/Read/User.php | 6 +- src/Request/Read/VatCode.php | 6 +- .../CustomerIntegrationTest.php | 12 ++-- .../InvoiceIntegrationTest.php | 4 +- 40 files changed, 302 insertions(+), 245 deletions(-) diff --git a/src/ApiConnectors/BaseApiConnector.php b/src/ApiConnectors/BaseApiConnector.php index f613e40d..de8b08ef 100644 --- a/src/ApiConnectors/BaseApiConnector.php +++ b/src/ApiConnectors/BaseApiConnector.php @@ -47,7 +47,13 @@ public function __construct(AuthenticatedConnection $connection) $this->connection = $connection; } - public function getConnection() + /** + * Will return the current connection + * + * @return \PhpTwinfield\Secure\AuthenticatedConnection + * @throws Exception + */ + public function getConnection(): AuthenticatedConnection { return $this->connection; } @@ -169,31 +175,32 @@ protected function getFinderService(): FinderService /** * Convert options array to an ArrayOfString which is accepted by Twinfield. + * + * In some cases you are not allowed to change certain options (such as the dimtype, which should always be DEB when using CustomerApiConnector->ListAll()), + * in which case the $forcedOptions parameter will be set by the ApiConnector for this option, which will override any user settings in $options * * @param array $options - * @param array|null $forcedOptions + * @param array $forcedOptions * @return array * @throws Exception */ - public function convertOptionsToArrayOfString(array $options, array $forcedOptions = null): array { + public function convertOptionsToArrayOfString(array $options, array $forcedOptions = []): array { if (isset($options['ArrayOfString'])) { return $options; - } else { - $optionsArrayOfString = array('ArrayOfString' => array()); - - if (isset($forcedOptions)) { - foreach ($forcedOptions as $key => $value) { - unset($options[$key]); - $optionsArrayOfString['ArrayOfString'][] = array($key, $value); - } - } + } + + $optionsArrayOfString = ['ArrayOfString' => []]; - foreach ($options as $key => $value) { - $optionsArrayOfString['ArrayOfString'][] = array($key, $value); - } + foreach ($forcedOptions as $key => $value) { + unset($options[$key]); + $optionsArrayOfString['ArrayOfString'][] = array($key, $value); + } - return $optionsArrayOfString; + foreach ($options as $key => $value) { + $optionsArrayOfString['ArrayOfString'][] = array($key, $value); } + + return $optionsArrayOfString; } /** diff --git a/src/DomDocuments/BaseDocument.php b/src/DomDocuments/BaseDocument.php index 5e086465..64c16802 100644 --- a/src/DomDocuments/BaseDocument.php +++ b/src/DomDocuments/BaseDocument.php @@ -36,10 +36,10 @@ public function __construct($version = "1.0", $encoding = "UTF-8") * @param string $tag * @param string|null $textContent * @param $object - * @param array|null $attributes + * @param array $attributes * @return \DOMElement */ - final protected function createNodeWithTextContent(string $tag, ?string $textContent, $object = null, array $attributes = null): \DOMElement + final protected function createNodeWithTextContent(string $tag, ?string $textContent, $object = null, array $attributes = []): \DOMElement { $element = $this->createElement($tag); @@ -47,7 +47,7 @@ final protected function createNodeWithTextContent(string $tag, ?string $textCon $element->textContent = $textContent; } - if (isset($object) && isset($attributes)) { + if (isset($object)) { foreach ($attributes as $attributeName => $method) { $element->setAttribute($attributeName, $object->$method()); } diff --git a/src/Mappers/ActivityMapper.php b/src/Mappers/ActivityMapper.php index d0481c44..cb2e55ee 100644 --- a/src/Mappers/ActivityMapper.php +++ b/src/Mappers/ActivityMapper.php @@ -38,19 +38,19 @@ public static function map(Response $response) // Set the result and status attribute $activity->setResult($activityElement->getAttribute('result')) - ->setStatus(self::parseEnumAttribute('Status', $activityElement->getAttribute('status'))); + ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $activityElement->getAttribute('status'))); // Set the activity elements from the activity element - $activity->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($activityElement, 'behaviour', $activity))) + $activity->setBehaviour(self::parseEnumAttribute(\PhpTwinfield\Enums\Behaviour::class, self::getField($activityElement, 'behaviour', $activity))) ->setCode(self::getField($activityElement, 'code', $activity)) ->setInUse(self::parseBooleanAttribute(self::getField($activityElement, 'name', $activity))) ->setName(self::getField($activityElement, 'name', $activity)) - ->setOffice(self::parseObjectAttribute('Office', $activity, $activityElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $activity, $activityElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setShortName(self::getField($activityElement, 'shortname', $activity)) ->setTouched(self::getField($activityElement, 'touched', $activity)) - ->setType(self::parseObjectAttribute('DimensionType', $activity, $activityElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setType(self::parseObjectAttribute(\PhpTwinfield\DimensionType::class, $activity, $activityElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setUID(self::getField($activityElement, 'uid', $activity)) - ->setVatCode(self::parseObjectAttribute('VatCode', $activity, $activityElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); + ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $activity, $activityElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); // Get the projects element $projectsElement = $responseDOM->getElementsByTagName('projects')->item(0); @@ -60,11 +60,11 @@ public static function map(Response $response) $activityProjects = new ActivityProjects(); // Set the projects elements from the projects element - $activityProjects->setAuthoriser(self::parseObjectAttribute('User', $activityProjects, $projectsElement, 'authoriser')) + $activityProjects->setAuthoriser(self::parseObjectAttribute(\PhpTwinfield\User::class, $activityProjects, $projectsElement, 'authoriser')) ->setBillable(self::parseBooleanAttribute(self::getField($projectsElement, 'billable', $activityProjects))) - ->setCustomer(self::parseObjectAttribute('Customer', $activityProjects, $projectsElement, 'customer')) + ->setCustomer(self::parseObjectAttribute(\PhpTwinfield\Customer::class, $activityProjects, $projectsElement, 'customer')) ->setInvoiceDescription(self::getField($projectsElement, 'invoicedescription', $activityProjects)) - ->setRate(self::parseObjectAttribute('Rate', $activityProjects, $projectsElement, 'rate')) + ->setRate(self::parseObjectAttribute(\PhpTwinfield\Rate::class, $activityProjects, $projectsElement, 'rate')) ->setValidFrom(self::parseDateAttribute(self::getField($projectsElement, 'validfrom', $activityProjects))) ->setValidTill(self::parseDateAttribute(self::getField($projectsElement, 'validtill', $activityProjects))); @@ -96,7 +96,7 @@ public static function map(Response $response) $activityQuantity->setBillable(self::parseBooleanAttribute(self::getField($quantityElement, 'billable', $activityQuantity))) ->setLabel(self::getField($quantityElement, 'label', $activityQuantity)) ->setMandatory(self::parseBooleanAttribute(self::getField($quantityElement, 'mandatory', $activityQuantity))) - ->setRate(self::parseObjectAttribute('Rate', $activityQuantity, $quantityElement, 'rate')); + ->setRate(self::parseObjectAttribute(\PhpTwinfield\Rate::class, $activityQuantity, $quantityElement, 'rate')); // Set the quantity elements from the quantity element attributes $activityQuantity->setBillableLocked(self::parseBooleanAttribute(self::getAttribute($quantityElement, 'billable', 'locked'))); diff --git a/src/Mappers/ArticleMapper.php b/src/Mappers/ArticleMapper.php index 540fbcf9..65f4a37e 100644 --- a/src/Mappers/ArticleMapper.php +++ b/src/Mappers/ArticleMapper.php @@ -42,7 +42,7 @@ public static function map(Response $response) $headerElement = $articleElement->getElementsByTagName('header')->item(0); // Set the status attribute - $article->setStatus(self::parseEnumAttribute('Status', $headerElement->getAttribute('status'))); + $article->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $headerElement->getAttribute('status'))); // Set the article elements from the header $article->setAllowChangePerformanceType(self::parseBooleanAttribute(self::getField($headerElement, 'allowchangeperformancetype', $article))) @@ -52,14 +52,14 @@ public static function map(Response $response) ->setAllowDiscountOrPremium(self::parseBooleanAttribute(self::getField($headerElement, 'allowdiscountorpremium', $article))) ->setCode(self::getField($headerElement, 'code', $article)) ->setName(self::getField($headerElement, 'name', $article)) - ->setOffice(self::parseObjectAttribute('Office', $article, $headerElement, 'office')) + ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $article, $headerElement, 'office')) ->setPercentage(self::parseBooleanAttribute(self::getField($headerElement, 'percentage', $article))) - ->setPerformanceType(self::parseEnumAttribute('PerformanceType', self::getField($headerElement, 'performancetype', $article))) + ->setPerformanceType(self::parseEnumAttribute(\PhpTwinfield\Enums\PerformanceType::class, self::getField($headerElement, 'performancetype', $article))) ->setShortName(self::getField($headerElement, 'shortname', $article)) - ->setType(self::parseEnumAttribute('ArticleType', self::getField($headerElement, 'type', $article))) + ->setType(self::parseEnumAttribute(\PhpTwinfield\Enums\ArticleType::class, self::getField($headerElement, 'type', $article))) ->setUnitNameSingular(self::getField($headerElement, 'unitnamesingular', $article)) ->setUnitNamePlural(self::getField($headerElement, 'unitnameplural', $article)) - ->setVatCode(self::parseObjectAttribute('VatCode', $article, $headerElement, 'vatcode')); + ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $article, $headerElement, 'vatcode')); // Get the lines element $linesDOMTag = $responseDOM->getElementsByTagName('lines'); @@ -91,8 +91,8 @@ public static function map(Response $response) $articleLine->setStatusFromString($lineElement->getAttribute('status')); // Set the article line elements - $articleLine->setFreeText1(self::parseObjectAttribute('GeneralLedger', $articleLine, $lineElement, 'freetext1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setFreeText2(self::parseObjectAttribute('CostCenter', $articleLine, $lineElement, 'freetext2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + $articleLine->setFreeText1(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $articleLine, $lineElement, 'freetext1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setFreeText2(self::parseObjectAttribute(\PhpTwinfield\CostCenter::class, $articleLine, $lineElement, 'freetext2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setFreeText3(self::getField($lineElement, 'freetext3', $articleLine)) ->setUnits(self::getField($lineElement, 'units', $articleLine)) ->setName(self::getField($lineElement, 'name', $articleLine)) diff --git a/src/Mappers/AssetMethodMapper.php b/src/Mappers/AssetMethodMapper.php index 17cafe94..3981a623 100644 --- a/src/Mappers/AssetMethodMapper.php +++ b/src/Mappers/AssetMethodMapper.php @@ -40,21 +40,21 @@ public static function map(Response $response) // Set the inuse, result and status attribute $assetmethod->setInUse(self::parseBooleanAttribute($assetmethodElement->getAttribute('inuse'))) ->setResult($assetmethodElement->getAttribute('result')) - ->setStatus(self::parseEnumAttribute('Status', $assetmethodElement->getAttribute('status'))); + ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $assetmethodElement->getAttribute('status'))); // Set the asset method elements from the asset method element - $assetmethod->setCalcMethod(self::parseEnumAttribute('CalcMethod', self::getField($assetmethodElement, 'calcmethod', $assetmethod))) + $assetmethod->setCalcMethod(self::parseEnumAttribute(\PhpTwinfield\Enums\CalcMethod::class, self::getField($assetmethodElement, 'calcmethod', $assetmethod))) ->setCode(self::getField($assetmethodElement, 'code', $assetmethod)) ->setCreated(self::parseDateTimeAttribute(self::getField($assetmethodElement, 'created', $assetmethod))) - ->setDepreciateReconciliation(self::parseEnumAttribute('DepreciateReconciliation', self::getField($assetmethodElement, 'depreciatereconciliation', $assetmethod))) + ->setDepreciateReconciliation(self::parseEnumAttribute(\PhpTwinfield\Enums\DepreciateReconciliation::class, self::getField($assetmethodElement, 'depreciatereconciliation', $assetmethod))) ->setModified(self::parseDateTimeAttribute(self::getField($assetmethodElement, 'modified', $assetmethod))) ->setName(self::getField($assetmethodElement, 'name', $assetmethod)) ->setNrOfPeriods(self::getField($assetmethodElement, 'nrofperiods', $assetmethod)) - ->setOffice(self::parseObjectAttribute('Office', $assetmethod, $assetmethodElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $assetmethod, $assetmethodElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setPercentage(self::getField($assetmethodElement, 'percentage', $assetmethod)) ->setShortName(self::getField($assetmethodElement, 'shortname', $assetmethod)) ->setTouched(self::getField($assetmethodElement, 'touched', $assetmethod)) - ->setUser(self::parseObjectAttribute('User', $assetmethod, $assetmethodElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); + ->setUser(self::parseObjectAttribute(\PhpTwinfield\User::class, $assetmethod, $assetmethodElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); // Get the balanceaccounts element $balanceAccountsElement = $responseDOM->getElementsByTagName('balanceaccounts')->item(0); @@ -65,13 +65,13 @@ public static function map(Response $response) // Set the asset method balance account elements from the balance accounts element $assetMethodBalanceAccounts - ->setAssetsToActivate(self::parseObjectAttribute('GeneralLedger', $assetMethodBalanceAccounts, $balanceAccountsElement, 'assetstoactivate', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setDepreciation(self::parseObjectAttribute('GeneralLedger', $assetMethodBalanceAccounts, $balanceAccountsElement, 'depreciation', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setDepreciationGroup(self::parseObjectAttribute('DimensionGroup', $assetMethodBalanceAccounts, $balanceAccountsElement, 'depreciationgroup', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setPurchaseValue(self::parseObjectAttribute('GeneralLedger', $assetMethodBalanceAccounts, $balanceAccountsElement, 'purchasevalue', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setPurchaseValueGroup(self::parseObjectAttribute('DimensionGroup', $assetMethodBalanceAccounts, $balanceAccountsElement, 'purchasevaluegroup', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setReconciliation(self::parseObjectAttribute('GeneralLedger', $assetMethodBalanceAccounts, $balanceAccountsElement, 'reconciliation', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setToBeInvoiced(self::parseObjectAttribute('GeneralLedger', $assetMethodBalanceAccounts, $balanceAccountsElement, 'tobeinvoiced', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))); + ->setAssetsToActivate(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $assetMethodBalanceAccounts, $balanceAccountsElement, 'assetstoactivate', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setDepreciation(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $assetMethodBalanceAccounts, $balanceAccountsElement, 'depreciation', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setDepreciationGroup(self::parseObjectAttribute(\PhpTwinfield\DimensionGroup::class, $assetMethodBalanceAccounts, $balanceAccountsElement, 'depreciationgroup', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setPurchaseValue(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $assetMethodBalanceAccounts, $balanceAccountsElement, 'purchasevalue', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setPurchaseValueGroup(self::parseObjectAttribute(\PhpTwinfield\DimensionGroup::class, $assetMethodBalanceAccounts, $balanceAccountsElement, 'purchasevaluegroup', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setReconciliation(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $assetMethodBalanceAccounts, $balanceAccountsElement, 'reconciliation', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setToBeInvoiced(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $assetMethodBalanceAccounts, $balanceAccountsElement, 'tobeinvoiced', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))); // Set the custom class to the assetmethod $assetmethod->setBalanceAccounts($assetMethodBalanceAccounts); @@ -86,9 +86,9 @@ public static function map(Response $response) // Set the asset method profit loss account elements from the profit loss accounts element $assetMethodProfitLossAccounts - ->setDepreciation(self::parseObjectAttribute('GeneralLedger', $assetMethodProfitLossAccounts, $profitLossAccountsElement, 'depreciation', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setReconciliation(self::parseObjectAttribute('GeneralLedger', $assetMethodProfitLossAccounts, $profitLossAccountsElement, 'reconciliation', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setSales(self::parseObjectAttribute('GeneralLedger', $assetMethodProfitLossAccounts, $profitLossAccountsElement, 'sales', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))); + ->setDepreciation(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $assetMethodProfitLossAccounts, $profitLossAccountsElement, 'depreciation', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setReconciliation(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $assetMethodProfitLossAccounts, $profitLossAccountsElement, 'reconciliation', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setSales(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $assetMethodProfitLossAccounts, $profitLossAccountsElement, 'sales', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))); // Set the custom class to the assetmethod $assetmethod->setProfitLossAccounts($assetMethodProfitLossAccounts); @@ -109,7 +109,7 @@ public static function map(Response $response) // Set the attributes (id, type, value) $assetmethodFreeText->setID($freetextElement->getAttribute('id')) - ->setType(self::parseEnumAttribute('FreeTextType', $freetextElement->getAttribute('type'))) + ->setType(self::parseEnumAttribute(\PhpTwinfield\Enums\FreeTextType::class, $freetextElement->getAttribute('type'))) ->setElementValue($freetextElement->nodeValue); // Add the freetext to the assetmethod diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index abbc5ad5..921382b5 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -63,23 +63,23 @@ protected static function parseBooleanAttribute(?string $value): ?bool protected static function parseDateAttribute(?string $value): ?\DateTimeImmutable { - if ((bool)strtotime($value)) { + if (false !== strtotime($value)) { return Util::parseDate($value); - } else { - return null; } + + return null; } protected static function parseDateTimeAttribute(?string $value): ?\DateTimeImmutable { - if ((bool)strtotime($value)) { + if (false !== strtotime($value)) { return Util::parseDateTime($value); - } else { - return null; } + + return null; } - protected static function parseEnumAttribute(string $enumName, ?string $value) + protected static function parseEnumAttribute(string $enumClass, ?string $value) { if ($value === null) { return null; @@ -88,16 +88,16 @@ protected static function parseEnumAttribute(string $enumName, ?string $value) $enum = "\\PhpTwinfield\\Enums\\" . $enumName; try { - $classReflex = new \ReflectionClass($enum); + $classReflex = new \ReflectionClass($enumClass); $classConstants = $classReflex->getConstants(); foreach ($classConstants as $classConstant) { if ($value == $classConstant) { - return new $enum($value); + return new $enumClass($value); } } } catch (\ReflectionException $e) { - return null; + throw new Exception("Non existant Enum, got \"{$enumClass}\"."); } return null; @@ -112,54 +112,51 @@ protected static function parseMoneyAttribute(?float $value): ?Money return Util::parseMoney($value, new Currency('EUR')); } - protected static function parseObjectAttribute(string $className, $object, \DOMElement $element, string $fieldTagName, array $attributes = null) + /** @var SomeClassWithMethodsetCode $object2 */ + protected static function parseObjectAttribute(string $objectClass, $object, \DOMElement $element, string $fieldTagName, array $attributes = []) { - if ($className == "DimensionGroupDimension" || $className == "UnknownDimension") { - if ($className == "DimensionGroupDimension") { + if ($objectClass == "DimensionGroupDimension" || $objectClass == "UnknownDimension") { + if ($objectClass == "DimensionGroupDimension") { $type = self::getField($element, "type", $object); - } elseif ($className == "UnknownDimension") { + } elseif ($objectClass == "UnknownDimension") { $type = self::getAttribute($element, $fieldTagName, "dimensiontype"); } switch ($type) { case "ACT": - $className = "Activity"; + $objectClass = \PhpTwinfield\Activity::class; break; case "AST": - $className = "FixedAsset"; + $objectClass = \PhpTwinfield\FixedAsset::class; break; case "BAS": - $className = "GeneralLedger"; + $objectClass = \PhpTwinfield\GeneralLedger::class; break; case "CRD": - $className = "Supplier"; + $objectClass = \PhpTwinfield\Supplier::class; break; case "DEB": - $className = "Customer"; + $objectClass = \PhpTwinfield\Customer::class; break; case "KPL": - $className = "CostCenter"; + $objectClass = \PhpTwinfield\CostCenter::class; break; case "PNL": - $className = "GeneralLedger"; + $objectClass = \PhpTwinfield\GeneralLedger::class; break; case "PRJ": - $className = "Project"; + $objectClass = \PhpTwinfield\Project::class; break; default: - return null; + throw new InvalidArgumentException("parseObjectAttribute function does not accept \"{$objectClass}\" as valid input for the \$object argument"); } } - $class = "\\PhpTwinfield\\" . $className; - - $object2 = new $class(); + $object2 = new $objectClass(); $object2->setCode(self::getField($element, $fieldTagName, $object)); - if (isset($attributes)) { - foreach ($attributes as $attributeName => $method) { - $object2->$method(self::getAttribute($element, $fieldTagName, $attributeName)); - } + foreach ($attributes as $attributeName => $method) { + $object2->$method(self::getAttribute($element, $fieldTagName, $attributeName)); } return $object2; diff --git a/src/Mappers/CostCenterMapper.php b/src/Mappers/CostCenterMapper.php index 12e91958..1d4905f1 100644 --- a/src/Mappers/CostCenterMapper.php +++ b/src/Mappers/CostCenterMapper.php @@ -36,16 +36,16 @@ public static function map(Response $response) // Set the result and status attribute $costCenter->setResult($costCenterElement->getAttribute('result')) - ->setStatus(self::parseEnumAttribute('Status', $costCenterElement->getAttribute('status'))); + ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $costCenterElement->getAttribute('status'))); // Set the cost center elements from the cost center element - $costCenter->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($costCenterElement, 'behaviour', $costCenter))) + $costCenter->setBehaviour(self::parseEnumAttribute(\PhpTwinfield\Enums\Behaviour::class, self::getField($costCenterElement, 'behaviour', $costCenter))) ->setCode(self::getField($costCenterElement, 'code', $costCenter)) ->setInUse(self::parseBooleanAttribute(self::getField($costCenterElement, 'name', $costCenter))) ->setName(self::getField($costCenterElement, 'name', $costCenter)) - ->setOffice(self::parseObjectAttribute('Office', $costCenter, $costCenterElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $costCenter, $costCenterElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setTouched(self::getField($costCenterElement, 'touched', $costCenter)) - ->setType(self::parseObjectAttribute('DimensionType', $costCenter, $costCenterElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setType(self::parseObjectAttribute(\PhpTwinfield\DimensionType::class, $costCenter, $costCenterElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setUID(self::getField($costCenterElement, 'uid', $costCenter)); // Return the complete object diff --git a/src/Mappers/CurrencyMapper.php b/src/Mappers/CurrencyMapper.php index 403d3443..8a036424 100644 --- a/src/Mappers/CurrencyMapper.php +++ b/src/Mappers/CurrencyMapper.php @@ -37,12 +37,12 @@ public static function map(Response $response) // Set the result and status attribute $currency->setResult($currencyElement->getAttribute('result')) - ->setStatus(self::parseEnumAttribute('Status', $currencyElement->getAttribute('status'))); + ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $currencyElement->getAttribute('status'))); // Set the currency elements from the currency element $currency->setCode(self::getField($currencyElement, 'code', $currency)) ->setName(self::getField($currencyElement, 'name', $currency)) - ->setOffice(self::parseObjectAttribute('Office', $currency, $currencyElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $currency, $currencyElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setShortName(self::getField($currencyElement, 'shortname', $currency)); // Get the rates element diff --git a/src/Mappers/CustomerMapper.php b/src/Mappers/CustomerMapper.php index 47a7c636..d2694dcf 100644 --- a/src/Mappers/CustomerMapper.php +++ b/src/Mappers/CustomerMapper.php @@ -43,22 +43,22 @@ public static function map(Response $response) // Set the result and status attribute $customer->setResult($customerElement->getAttribute('result')) - ->setStatus(self::parseEnumAttribute('Status', $customerElement->getAttribute('status'))); + ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $customerElement->getAttribute('status'))); // Set the customer elements from the customer element $customer->setBeginPeriod(self::getField($customerElement, 'beginperiod', $customer)) ->setBeginYear(self::getField($customerElement, 'beginyear', $customer)) - ->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($customerElement, 'behaviour', $customer))) - ->setDiscountArticle(self::parseObjectAttribute('Article', $customer, $customerElement, 'discountarticle', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setBehaviour(self::parseEnumAttribute(\PhpTwinfield\Enums\Behaviour::class, self::getField($customerElement, 'behaviour', $customer))) + ->setDiscountArticle(self::parseObjectAttribute(\PhpTwinfield\Article::class, $customer, $customerElement, 'discountarticle', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setCode(self::getField($customerElement, 'code', $customer)) ->setEndPeriod(self::getField($customerElement, 'endperiod', $customer)) ->setEndYear(self::getField($customerElement, 'endyear', $customer)) - ->setGroup(self::parseObjectAttribute('DimensionGroup', $customer, $customerElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setGroup(self::parseObjectAttribute(\PhpTwinfield\DimensionGroup::class, $customer, $customerElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setInUse(self::parseBooleanAttribute(self::getField($customerElement, 'name', $customer))) ->setName(self::getField($customerElement, 'name', $customer)) - ->setOffice(self::parseObjectAttribute('Office', $customer, $customerElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $customer, $customerElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setTouched(self::getField($customerElement, 'touched', $customer)) - ->setType(self::parseObjectAttribute('DimensionType', $customer, $customerElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setType(self::parseObjectAttribute(\PhpTwinfield\DimensionType::class, $customer, $customerElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setUID(self::getField($customerElement, 'uid', $customer)) ->setWebsite(self::getField($customerElement, 'website', $customer)); @@ -73,20 +73,20 @@ public static function map(Response $response) $customerFinancials = new CustomerFinancials(); // Set the financials elements from the financials element - $customerFinancials->setAccountType(self::parseEnumAttribute('AccountType', self::getField($financialsElement, 'accounttype', $customerFinancials))) - ->setCollectionSchema(self::parseEnumAttribute('CollectionSchema', self::getField($financialsElement, 'collectionschema', $customerFinancials))) + $customerFinancials->setAccountType(self::parseEnumAttribute(\PhpTwinfield\Enums\AccountType::class, self::getField($financialsElement, 'accounttype', $customerFinancials))) + ->setCollectionSchema(self::parseEnumAttribute(\PhpTwinfield\Enums\CollectionSchema::class, self::getField($financialsElement, 'collectionschema', $customerFinancials))) ->setDueDays(self::getField($financialsElement, 'duedays', $customerFinancials)) ->setEBilling(self::parseBooleanAttribute(self::getField($financialsElement, 'ebilling', $customerFinancials))) ->setEBillMail(self::getField($financialsElement, 'ebillmail', $customerFinancials)) ->setLevel(self::getField($financialsElement, 'level', $customerFinancials)) - ->setMatchType(self::parseEnumAttribute('MatchType', self::getField($financialsElement, 'matchtype', $customerFinancials))) - ->setMeansOfPayment(self::parseEnumAttribute('MeansOfPayment', self::getField($financialsElement, 'meansofpayment', $customerFinancials))) + ->setMatchType(self::parseEnumAttribute(\PhpTwinfield\Enums\MatchType::class, self::getField($financialsElement, 'matchtype', $customerFinancials))) + ->setMeansOfPayment(self::parseEnumAttribute(\PhpTwinfield\Enums\MeansOfPayment::class, self::getField($financialsElement, 'meansofpayment', $customerFinancials))) ->setPayAvailable(self::parseBooleanAttribute(self::getField($financialsElement, 'payavailable', $customerFinancials))) - ->setPayCode(self::parseObjectAttribute('PayCode', $customerFinancials, $financialsElement, 'paycode', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setSubAnalyse(self::parseEnumAttribute('SubAnalyse', self::getField($financialsElement, 'subanalyse', $customerFinancials))) + ->setPayCode(self::parseObjectAttribute(\PhpTwinfield\PayCode::class, $customerFinancials, $financialsElement, 'paycode', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setSubAnalyse(self::parseEnumAttribute(\PhpTwinfield\Enums\SubAnalyse::class, self::getField($financialsElement, 'subanalyse', $customerFinancials))) ->setSubstitutionLevel(self::getField($financialsElement, 'substitutionlevel', $customerFinancials)) - ->setSubstituteWith(self::parseObjectAttribute('UnknownDimension', $customerFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setVatCode(self::parseObjectAttribute('VatCode', $customerFinancials, $financialsElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); + ->setSubstituteWith(self::parseObjectAttribute(\PhpTwinfield\UnknownDimension::class, $customerFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $customerFinancials, $financialsElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); // Set the financials elements from the financials element attributes $customerFinancials->setPayCodeID(self::getAttribute($financialsElement, 'paycode', 'id')) @@ -127,7 +127,7 @@ public static function map(Response $response) // Set the child validation elements from the child validation element en element attributes $customerChildValidation->setLevel($childValidationElement->getAttribute('level')) - ->setType(self::parseEnumAttribute('ChildValidationType', $childValidationElement->getAttribute('type'))) + ->setType(self::parseEnumAttribute(\PhpTwinfield\Enums\ChildValidationType::class, $childValidationElement->getAttribute('type'))) ->setElementValue($childValidationElement->textContent); // Add the child validation to the customer financials class @@ -157,8 +157,8 @@ public static function map(Response $response) ->setFreeText2(self::getField($creditManagementElement, 'freetext2', $customerCreditManagement)) ->setFreeText3(self::getField($creditManagementElement, 'freetext3', $customerCreditManagement)) ->setReminderEmail(self::getField($creditManagementElement, 'reminderemail', $customerCreditManagement)) - ->setResponsibleUser(self::parseObjectAttribute('User', $customerCreditManagement, $creditManagementElement, 'responsibleuser', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setSendReminder(self::parseEnumAttribute('SendReminder', self::getField($creditManagementElement, 'sendreminder', $customerCreditManagement))); + ->setResponsibleUser(self::parseObjectAttribute(\PhpTwinfield\User::class, $customerCreditManagement, $creditManagementElement, 'responsibleuser', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setSendReminder(self::parseEnumAttribute(\PhpTwinfield\Enums\SendReminder::class, self::getField($creditManagementElement, 'sendreminder', $customerCreditManagement))); // Set the customer credit management elements from the creditmanagement element attributes $customerCreditManagement->setBlockedLocked(self::parseBooleanAttribute(self::getAttribute($creditManagementElement, 'blocked', 'locked'))) @@ -173,7 +173,7 @@ public static function map(Response $response) if ($remittanceAdviceElement !== null) { // Set the customer elements from the remittanceadvice element - $customer->setRemittanceAdviceSendType(self::parseEnumAttribute('RemittanceAdviceSendType', self::getField($remittanceAdviceElement, 'sendtype', $customer))) + $customer->setRemittanceAdviceSendType(self::parseEnumAttribute(\PhpTwinfield\Enums\RemittanceAdviceSendType::class, self::getField($remittanceAdviceElement, 'sendtype', $customer))) ->setRemittanceAdviceSendMail(self::getField($remittanceAdviceElement, 'sendmail', $customer)); } @@ -193,11 +193,11 @@ public static function map(Response $response) // Set the default, id and type attribute $customerAddress->setDefault(self::parseBooleanAttribute($addressElement->getAttribute('default'))) ->setID($addressElement->getAttribute('id')) - ->setType(self::parseEnumAttribute('AddressType', $addressElement->getAttribute('type'))); + ->setType(self::parseEnumAttribute(\PhpTwinfield\Enums\AddressType::class, $addressElement->getAttribute('type'))); // Set the address elements from the address element $customerAddress->setCity(self::getField($addressElement, 'city', $customerAddress)) - ->setCountry(self::parseObjectAttribute('Country', $customerAddress, $addressElement, 'country', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setCountry(self::parseObjectAttribute(\PhpTwinfield\Country::class, $customerAddress, $addressElement, 'country', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setEmail(self::getField($addressElement, 'email', $customerAddress)) ->setField1(self::getField($addressElement, 'field1', $customerAddress)) ->setField2(self::getField($addressElement, 'field2', $customerAddress)) @@ -244,7 +244,7 @@ public static function map(Response $response) ->setBankName(self::getField($bankElement, 'bankname', $customerBank)) ->setBicCode(self::getField($bankElement, 'biccode', $customerBank)) ->setCity(self::getField($bankElement, 'city', $customerBank)) - ->setCountry(self::parseObjectAttribute('Country', $customerBank, $bankElement, 'country', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setCountry(self::parseObjectAttribute(\PhpTwinfield\Country::class, $customerBank, $bankElement, 'country', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setIban(self::getField($bankElement, 'iban', $customerBank)) ->setNatBicCode(self::getField($bankElement, 'natbiccode', $customerBank)) ->setPostcode(self::getField($bankElement, 'postcode', $customerBank)) @@ -273,11 +273,11 @@ public static function map(Response $response) // Set the id and status attribute $customerPostingRule->setID($postingruleElement->getAttribute('id')) - ->setStatus(self::parseEnumAttribute('Status', $postingruleElement->getAttribute('status'))); + ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $postingruleElement->getAttribute('status'))); // Set the postingrule elements from the postingrule element $customerPostingRule->setAmount(self::parseMoneyAttribute(self::getField($postingruleElement, 'amount', $customerPostingRule))) - ->setCurrency(self::parseObjectAttribute('Currency', $customerPostingRule, $postingruleElement, 'currency', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setCurrency(self::parseObjectAttribute(\PhpTwinfield\Currency::class, $customerPostingRule, $postingruleElement, 'currency', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setDescription(self::getField($postingruleElement, 'description', $customerPostingRule)); // Get the lines element @@ -295,12 +295,12 @@ public static function map(Response $response) // Set the line elements from the line element $customerLine->setDescription(self::getField($lineElement, 'description', $customerLine)) - ->setDimension1(self::parseObjectAttribute('GeneralLedger', $customerLine, $lineElement, 'dimension1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setDimension2(self::parseObjectAttribute('CostCenter', $customerLine, $lineElement, 'dimension2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setDimension3(self::parseObjectAttribute('UnknownDimension', $customerLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setOffice(self::parseObjectAttribute('Office', $customerLine, $lineElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setDimension1(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $customerLine, $lineElement, 'dimension1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setDimension2(self::parseObjectAttribute(\PhpTwinfield\CostCenter::class, $customerLine, $lineElement, 'dimension2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setDimension3(self::parseObjectAttribute(\PhpTwinfield\UnknownDimension::class, $customerLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $customerLine, $lineElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setRatio(self::getField($lineElement, 'ratio', $customerLine)) - ->setVatCode(self::parseObjectAttribute('VatCode', $customerLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); + ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $customerLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); // Set the line elements from the line element attributes $customerLine->setDimension1ID(self::getAttribute($lineElement, 'dimension1', 'id')) diff --git a/src/Mappers/DimensionGroupMapper.php b/src/Mappers/DimensionGroupMapper.php index bdbfe444..be9e4bc1 100644 --- a/src/Mappers/DimensionGroupMapper.php +++ b/src/Mappers/DimensionGroupMapper.php @@ -38,12 +38,12 @@ public static function map(Response $response) // Set the result and status attribute $dimensiongroup->setResult($dimensiongroupElement->getAttribute('result')) - ->setStatus(self::parseEnumAttribute('Status', $dimensiongroupElement->getAttribute('status'))); + ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $dimensiongroupElement->getAttribute('status'))); // Set the dimension group elements from the dimension group element $dimensiongroup->setCode(self::getField($dimensiongroupElement, 'code', $dimensiongroup)) ->setName(self::getField($dimensiongroupElement, 'name', $dimensiongroup)) - ->setOffice(self::parseObjectAttribute('Office', $dimensiongroup, $dimensiongroupElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $dimensiongroup, $dimensiongroupElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setShortName(self::getField($dimensiongroupElement, 'shortname', $dimensiongroup)); // Get the dimensions element @@ -60,8 +60,8 @@ public static function map(Response $response) $dimensionGroupDimension = new DimensionGroupDimension(); // Set the dimension group dimension elements from the dimension element - $dimensionGroupDimension->setType(self::parseObjectAttribute('DimensionType', $dimensionGroupDimension, $dimensionElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))); - $dimensionGroupDimension->setCode(self::parseObjectAttribute('DimensionGroupDimension', $dimensionGroupDimension, $dimensionElement, 'code', array('name' => 'setName', 'shortname' => 'setShortName'))); + $dimensionGroupDimension->setType(self::parseObjectAttribute(\PhpTwinfield\DimensionType::class, $dimensionGroupDimension, $dimensionElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))); + $dimensionGroupDimension->setCode(self::parseObjectAttribute(\PhpTwinfield\DimensionGroupDimension::class, $dimensionGroupDimension, $dimensionElement, 'code', array('name' => 'setName', 'shortname' => 'setShortName'))); // Add the dimension to the dimension group $dimensiongroup->addDimension($dimensionGroupDimension); diff --git a/src/Mappers/DimensionTypeMapper.php b/src/Mappers/DimensionTypeMapper.php index ea4c691a..8a725fc6 100644 --- a/src/Mappers/DimensionTypeMapper.php +++ b/src/Mappers/DimensionTypeMapper.php @@ -38,13 +38,13 @@ public static function map(Response $response) // Set the result and status attribute $dimensiontype->setResult($dimensiontypeElement->getAttribute('result')) - ->setStatus(self::parseEnumAttribute('Status', $dimensiontypeElement->getAttribute('status'))); + ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $dimensiontypeElement->getAttribute('status'))); // Set the dimension type elements from the dimension type element $dimensiontype->setCode(self::getField($dimensiontypeElement, 'code', $dimensiontype)) ->setMask(self::getField($dimensiontypeElement, 'mask', $dimensiontype)) ->setName(self::getField($dimensiontypeElement, 'name', $dimensiontype)) - ->setOffice(self::parseObjectAttribute('Office', $dimensiontype, $dimensiontypeElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $dimensiontype, $dimensiontypeElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setShortName(self::getField($dimensiontypeElement, 'shortname', $dimensiontype)); // Get the levels element diff --git a/src/Mappers/FixedAssetMapper.php b/src/Mappers/FixedAssetMapper.php index 76d4d0e5..721be092 100644 --- a/src/Mappers/FixedAssetMapper.php +++ b/src/Mappers/FixedAssetMapper.php @@ -38,17 +38,17 @@ public static function map(Response $response) // Set the result and status attribute $fixedAsset->setResult($fixedAssetElement->getAttribute('result')) - ->setStatus(self::parseEnumAttribute('Status', $fixedAssetElement->getAttribute('status'))); + ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $fixedAssetElement->getAttribute('status'))); // Set the fixed asset elements from the fixed asset element - $fixedAsset->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($fixedAssetElement, 'behaviour', $fixedAsset))) + $fixedAsset->setBehaviour(self::parseEnumAttribute(\PhpTwinfield\Enums\Behaviour::class, self::getField($fixedAssetElement, 'behaviour', $fixedAsset))) ->setCode(self::getField($fixedAssetElement, 'code', $fixedAsset)) - ->setGroup(self::parseObjectAttribute('DimensionGroup', $fixedAsset, $fixedAssetElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setGroup(self::parseObjectAttribute(\PhpTwinfield\DimensionGroup::class, $fixedAsset, $fixedAssetElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setInUse(self::parseBooleanAttribute(self::getField($fixedAssetElement, 'name', $fixedAsset))) ->setName(self::getField($fixedAssetElement, 'name', $fixedAsset)) - ->setOffice(self::parseObjectAttribute('Office', $fixedAsset, $fixedAssetElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $fixedAsset, $fixedAssetElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setTouched(self::getField($fixedAssetElement, 'touched', $fixedAsset)) - ->setType(self::parseObjectAttribute('DimensionType', $fixedAsset, $fixedAssetElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setType(self::parseObjectAttribute(\PhpTwinfield\DimensionType::class, $fixedAsset, $fixedAssetElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setUID(self::getField($fixedAssetElement, 'uid', $fixedAsset)); // Get the financials element @@ -59,13 +59,13 @@ public static function map(Response $response) $fixedAssetFinancials = new FixedAssetFinancials(); // Set the financials elements from the financials element - $fixedAssetFinancials->setAccountType(self::parseEnumAttribute('AccountType', self::getField($financialsElement, 'accounttype', $fixedAssetFinancials))) + $fixedAssetFinancials->setAccountType(self::parseEnumAttribute(\PhpTwinfield\Enums\AccountType::class, self::getField($financialsElement, 'accounttype', $fixedAssetFinancials))) ->setLevel(self::getField($financialsElement, 'level', $fixedAssetFinancials)) - ->setMatchType(self::parseEnumAttribute('MatchType', self::getField($financialsElement, 'matchtype', $fixedAssetFinancials))) - ->setSubAnalyse(self::parseEnumAttribute('SubAnalyse', self::getField($financialsElement, 'subanalyse', $fixedAssetFinancials))) + ->setMatchType(self::parseEnumAttribute(\PhpTwinfield\Enums\MatchType::class, self::getField($financialsElement, 'matchtype', $fixedAssetFinancials))) + ->setSubAnalyse(self::parseEnumAttribute(\PhpTwinfield\Enums\SubAnalyse::class, self::getField($financialsElement, 'subanalyse', $fixedAssetFinancials))) ->setSubstitutionLevel(self::getField($financialsElement, 'substitutionlevel', $fixedAssetFinancials)) - ->setSubstituteWith(self::parseObjectAttribute('CostCenter', $fixedAssetFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setVatCode(self::parseObjectAttribute('VatCode', $fixedAssetFinancials, $financialsElement, 'vatcode')); + ->setSubstituteWith(self::parseObjectAttribute(\PhpTwinfield\CostCenter::class, $fixedAssetFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $fixedAssetFinancials, $financialsElement, 'vatcode')); // Set the financials elements from the financials element attributes $fixedAssetFinancials->setSubstituteWithID(self::getAttribute($financialsElement, 'substitutewith', 'id')); @@ -90,13 +90,13 @@ public static function map(Response $response) ->setFreeText4(self::getField($fixedAssetsElement, 'freetext4', $fixedAssetFixedAssets)) ->setFreeText5(self::getField($fixedAssetsElement, 'freetext5', $fixedAssetFixedAssets)) ->setLastDepreciation(self::getField($fixedAssetsElement, 'lastdepreciation', $fixedAssetFixedAssets)) - ->setMethod(self::parseObjectAttribute('AssetMethod', $fixedAssetFixedAssets, $fixedAssetsElement, 'method', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setMethod(self::parseObjectAttribute(\PhpTwinfield\AssetMethod::class, $fixedAssetFixedAssets, $fixedAssetsElement, 'method', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setNrOfPeriods(self::getField($fixedAssetsElement, 'nrofperiods', $fixedAssetFixedAssets)) ->setPercentage(self::getField($fixedAssetsElement, 'percentage', $fixedAssetFixedAssets)) ->setPurchaseDate(self::parseDateAttribute(self::getField($fixedAssetsElement, 'purchasedate', $fixedAssetFixedAssets))) ->setResidualValue(self::parseMoneyAttribute(self::getField($fixedAssetsElement, 'residualvalue', $fixedAssetFixedAssets))) ->setSellDate(self::parseDateAttribute(self::getField($fixedAssetsElement, 'selldate', $fixedAssetFixedAssets))) - ->setStatus(self::parseEnumAttribute('FixedAssetsStatus', self::getField($fixedAssetsElement, 'status', $fixedAssetFixedAssets))) + ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\FixedAssetsStatus::class, self::getField($fixedAssetsElement, 'status', $fixedAssetFixedAssets))) ->setStopValue(self::parseMoneyAttribute(self::getField($fixedAssetsElement, 'stopvalue', $fixedAssetFixedAssets))); // Set the fixed assets elements from the fixed assets element attributes @@ -133,12 +133,12 @@ public static function map(Response $response) // Set the fixed assets transaction line elements from the fixed assets transline element $fixedAssetTransactionLine->setAmount(self::parseMoneyAttribute(self::getField($transactionLineElement, 'amount', $fixedAssetTransactionLine))) ->setCode(self::getField($transactionLineElement, 'code', $fixedAssetTransactionLine)) - ->setDim1(self::parseObjectAttribute('GeneralLedger', $fixedAssetTransactionLine, $transactionLineElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) - ->setDim2(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) - ->setDim3(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) - ->setDim4(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim4', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) - ->setDim5(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim5', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) - ->setDim6(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim6', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim1(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $fixedAssetTransactionLine, $transactionLineElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim2(self::parseObjectAttribute(\PhpTwinfield\UnknownDimension::class, $fixedAssetTransactionLine, $transactionLineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim3(self::parseObjectAttribute(\PhpTwinfield\UnknownDimension::class, $fixedAssetTransactionLine, $transactionLineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim4(self::parseObjectAttribute(\PhpTwinfield\UnknownDimension::class, $fixedAssetTransactionLine, $transactionLineElement, 'dim4', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim5(self::parseObjectAttribute(\PhpTwinfield\UnknownDimension::class, $fixedAssetTransactionLine, $transactionLineElement, 'dim5', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim6(self::parseObjectAttribute(\PhpTwinfield\UnknownDimension::class, $fixedAssetTransactionLine, $transactionLineElement, 'dim6', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) ->setLine(self::getField($transactionLineElement, 'line', $fixedAssetTransactionLine)) ->setNumber(self::getField($transactionLineElement, 'number', $fixedAssetTransactionLine)) ->setPeriod(self::getField($transactionLineElement, 'period', $fixedAssetTransactionLine)); diff --git a/src/Mappers/GeneralLedgerMapper.php b/src/Mappers/GeneralLedgerMapper.php index 4fc4f50b..d9bcf009 100644 --- a/src/Mappers/GeneralLedgerMapper.php +++ b/src/Mappers/GeneralLedgerMapper.php @@ -38,22 +38,22 @@ public static function map(Response $response) // Set the result and status attribute $generalLedger->setResult($generalLedgerElement->getAttribute('result')) - ->setStatus(self::parseEnumAttribute('Status', $generalLedgerElement->getAttribute('status'))); + ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $generalLedgerElement->getAttribute('status'))); // Set the general ledger elements from the general ledger element $generalLedger->setBeginPeriod(self::getField($generalLedgerElement, 'beginperiod', $generalLedger)) ->setBeginYear(self::getField($generalLedgerElement, 'beginyear', $generalLedger)) - ->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($generalLedgerElement, 'behaviour', $generalLedger))) + ->setBehaviour(self::parseEnumAttribute(\PhpTwinfield\Enums\Behaviour::class, self::getField($generalLedgerElement, 'behaviour', $generalLedger))) ->setCode(self::getField($generalLedgerElement, 'code', $generalLedger)) ->setEndPeriod(self::getField($generalLedgerElement, 'endperiod', $generalLedger)) ->setEndYear(self::getField($generalLedgerElement, 'endyear', $generalLedger)) - ->setGroup(self::parseObjectAttribute('DimensionGroup', $generalLedger, $generalLedgerElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setGroup(self::parseObjectAttribute(\PhpTwinfield\DimensionGroup::class, $generalLedger, $generalLedgerElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setInUse(self::parseBooleanAttribute(self::getField($generalLedgerElement, 'inuse', $generalLedger))) ->setName(self::getField($generalLedgerElement, 'name', $generalLedger)) - ->setOffice(self::parseObjectAttribute('Office', $generalLedger, $generalLedgerElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $generalLedger, $generalLedgerElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setShortName(self::getField($generalLedgerElement, 'shortname', $generalLedger)) ->setTouched(self::getField($generalLedgerElement, 'touched', $generalLedger)) - ->setType(self::parseObjectAttribute('DimensionType', $generalLedger, $generalLedgerElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setType(self::parseObjectAttribute(\PhpTwinfield\DimensionType::class, $generalLedger, $generalLedgerElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setUID(self::getField($generalLedgerElement, 'uid', $generalLedger)); // Get the financials element @@ -64,11 +64,11 @@ public static function map(Response $response) $generalLedgerFinancials = new GeneralLedgerFinancials(); // Set the financials elements from the financials element - $generalLedgerFinancials->setAccountType(self::parseEnumAttribute('AccountType', self::getField($financialsElement, 'accounttype', $generalLedgerFinancials))) + $generalLedgerFinancials->setAccountType(self::parseEnumAttribute(\PhpTwinfield\Enums\AccountType::class, self::getField($financialsElement, 'accounttype', $generalLedgerFinancials))) ->setLevel(self::getField($financialsElement, 'level', $generalLedgerFinancials)) - ->setMatchType(self::parseEnumAttribute('MatchType', self::getField($financialsElement, 'matchtype', $generalLedgerFinancials))) - ->setSubAnalyse(self::parseEnumAttribute('SubAnalyse', self::getField($financialsElement, 'subanalyse', $generalLedgerFinancials))) - ->setVatCode(self::parseObjectAttribute('VatCode', $generalLedgerFinancials, $financialsElement, 'vatcode')); + ->setMatchType(self::parseEnumAttribute(\PhpTwinfield\Enums\MatchType::class, self::getField($financialsElement, 'matchtype', $generalLedgerFinancials))) + ->setSubAnalyse(self::parseEnumAttribute(\PhpTwinfield\Enums\SubAnalyse::class, self::getField($financialsElement, 'subanalyse', $generalLedgerFinancials))) + ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $generalLedgerFinancials, $financialsElement, 'vatcode')); // Set the financials elements from the financials element attributes $generalLedgerFinancials->setVatCodeFixed(self::parseBooleanAttribute(self::getAttribute($financialsElement, 'vatcode', 'fixed'))); @@ -88,7 +88,7 @@ public static function map(Response $response) // Set the child validation elements from the child validation element en element attributes $generalLedgerChildValidation->setLevel($childValidationElement->getAttribute('level')); - $generalLedgerChildValidation->setType(self::parseEnumAttribute('ChildValidationType', $childValidationElement->getAttribute('type'))); + $generalLedgerChildValidation->setType(self::parseEnumAttribute(\PhpTwinfield\Enums\ChildValidationType::class, $childValidationElement->getAttribute('type'))); $generalLedgerChildValidation->setElementValue($childValidationElement->textContent); // Add the child validation to the general ledger financials class diff --git a/src/Mappers/InvoiceMapper.php b/src/Mappers/InvoiceMapper.php index 5d564c8c..ec8060ae 100644 --- a/src/Mappers/InvoiceMapper.php +++ b/src/Mappers/InvoiceMapper.php @@ -41,9 +41,9 @@ public static function map(Response $response) $invoice->setResult($invoiceElement->getAttribute('result')); // Set the invoice elements from the invoice element - $invoice->setBank(self::parseObjectAttribute('CashBankBook', $invoice, $invoiceElement, 'bank')) - ->setCurrency(self::parseObjectAttribute('Currency', $invoice, $invoiceElement, 'currency')) - ->setCustomer(self::parseObjectAttribute('Customer', $invoice, $invoiceElement, 'customer')) + $invoice->setBank(self::parseObjectAttribute(\PhpTwinfield\CashBankBook::class, $invoice, $invoiceElement, 'bank')) + ->setCurrency(self::parseObjectAttribute(\PhpTwinfield\Currency::class, $invoice, $invoiceElement, 'currency')) + ->setCustomer(self::parseObjectAttribute(\PhpTwinfield\Customer::class, $invoice, $invoiceElement, 'customer')) ->setDeliverAddressNumber(self::getField($invoiceElement, 'deliveraddressnumber', $invoice)) ->setDueDate(self::parseDateAttribute(self::getField($invoiceElement, 'duedate', $invoice))) ->setFooterText(self::getField($invoiceElement, 'footertext', $invoice)) @@ -51,12 +51,12 @@ public static function map(Response $response) ->setInvoiceAddressNumber(self::getField($invoiceElement, 'invoiceaddressnumber', $invoice)) ->setInvoiceDate(self::parseDateAttribute(self::getField($invoiceElement, 'invoicedate', $invoice))) ->setInvoiceNumber(self::getField($invoiceElement, 'invoicenumber', $invoice)) - ->setInvoiceType(self::parseObjectAttribute('InvoiceType', $invoice, $invoiceElement, 'invoicetype')) - ->setOffice(self::parseObjectAttribute('Office', $invoice, $invoiceElement, 'office')) - ->setPaymentMethod(self::parseEnumAttribute('PaymentMethod', self::getField($invoiceElement, 'paymentmethod', $invoice))) + ->setInvoiceType(self::parseObjectAttribute(\PhpTwinfield\InvoiceType::class, $invoice, $invoiceElement, 'invoicetype')) + ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $invoice, $invoiceElement, 'office')) + ->setPaymentMethod(self::parseEnumAttribute(\PhpTwinfield\Enums\PaymentMethod::class, self::getField($invoiceElement, 'paymentmethod', $invoice))) ->setPeriod(self::getField($invoiceElement, 'period', $invoice)) ->setPerformanceDate(self::parseDateAttribute(self::getField($invoiceElement, 'performancedate', $invoice))) - ->setStatus(self::parseEnumAttribute('InvoiceStatus', self::getField($invoiceElement, 'status', $invoice))); + ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\InvoiceStatus::class, self::getField($invoiceElement, 'status', $invoice))); // Get the totals element $totalsElement = $responseDOM->getElementsByTagName('totals')->item(0); @@ -91,14 +91,14 @@ public static function map(Response $response) // Set the invoice line elements from the line element $invoiceLine->setAllowDiscountOrPremium(self::parseBooleanAttribute(self::getField($lineElement, 'allowdiscountorpremium', $invoiceLine))) - ->setArticle(self::parseObjectAttribute('Article', $invoiceLine, $lineElement, 'article')) + ->setArticle(self::parseObjectAttribute(\PhpTwinfield\Article::class, $invoiceLine, $lineElement, 'article')) ->setDescription(self::getField($lineElement, 'description', $invoiceLine)) - ->setDim1(self::parseObjectAttribute('GeneralLedger', $invoiceLine, $lineElement, 'dim1')) + ->setDim1(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $invoiceLine, $lineElement, 'dim1')) ->setFreeText1(self::getField($lineElement, 'freetext1', $invoiceLine)) ->setFreeText2(self::getField($lineElement, 'freetext2', $invoiceLine)) ->setFreeText3(self::getField($lineElement, 'freetext3', $invoiceLine)) ->setPerformanceDate(self::parseDateAttribute(self::getField($lineElement, 'performancedate', $invoiceLine))) - ->setPerformanceType(self::parseEnumAttribute('PerformanceType', self::getField($lineElement, 'performancetype', $invoiceLine))) + ->setPerformanceType(self::parseEnumAttribute(\PhpTwinfield\Enums\PerformanceType::class, self::getField($lineElement, 'performancetype', $invoiceLine))) ->setQuantity(self::getField($lineElement, 'quantity', $invoiceLine)) ->setSubArticleFromString(self::getField($lineElement, 'subarticle', $invoiceLine)) ->setUnits(self::getField($lineElement, 'units', $invoiceLine)) @@ -106,7 +106,7 @@ public static function map(Response $response) ->setUnitsPriceInc(self::parseMoneyAttribute(self::getField($lineElement, 'unitspriceinc', $invoiceLine))) ->setValueExcl(self::parseMoneyAttribute(self::getField($lineElement, 'valueexcl', $invoiceLine))) ->setValueInc(self::parseMoneyAttribute(self::getField($lineElement, 'valueinc', $invoiceLine))) - ->setVatCode(self::parseObjectAttribute('VatCode', $invoiceLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) + ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $invoiceLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) ->setVatValue(self::parseMoneyAttribute(self::getField($lineElement, 'vatvalue', $invoiceLine))); // Set the custom class to the invoice @@ -129,8 +129,8 @@ public static function map(Response $response) // Set the invoice vat line elements from the vat line element $invoiceVatLine->setPerformanceDate(self::parseDateAttribute(self::getField($vatlineElement, 'performancedate', $invoiceVatLine))) - ->setPerformanceType(self::parseEnumAttribute('PerformanceType', self::getField($vatlineElement, 'performancetype', $invoiceVatLine))) - ->setVatCode(self::parseObjectAttribute('VatCode', $invoiceVatLine, $vatlineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) + ->setPerformanceType(self::parseEnumAttribute(\PhpTwinfield\Enums\PerformanceType::class, self::getField($vatlineElement, 'performancetype', $invoiceVatLine))) + ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $invoiceVatLine, $vatlineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) ->setVatValue(self::parseMoneyAttribute(self::getField($vatlineElement, 'vatvalue', $invoiceVatLine))); // Set the custom class to the invoice diff --git a/src/Mappers/OfficeMapper.php b/src/Mappers/OfficeMapper.php index d956e0fe..41d5aeef 100644 --- a/src/Mappers/OfficeMapper.php +++ b/src/Mappers/OfficeMapper.php @@ -36,7 +36,7 @@ public static function map(Response $response) // Set the result and status attribute $office->setResult($officeElement->getAttribute('result')) - ->setStatus(self::parseEnumAttribute('Status', $officeElement->getAttribute('status'))); + ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $officeElement->getAttribute('status'))); // Set the office elements from the office element $office->setCode(self::getField($officeElement, 'code', $office)) @@ -45,7 +45,7 @@ public static function map(Response $response) ->setName(self::getField($officeElement, 'name', $office)) ->setShortName(self::getField($officeElement, 'shortname', $office)) ->setTouched(self::getField($officeElement, 'touched', $office)) - ->setUser(self::parseObjectAttribute('User', $office, $officeElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); + ->setUser(self::parseObjectAttribute(\PhpTwinfield\User::class, $office, $officeElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); // Return the complete object return $office; diff --git a/src/Mappers/ProjectMapper.php b/src/Mappers/ProjectMapper.php index 4b8dd49e..e6636d71 100644 --- a/src/Mappers/ProjectMapper.php +++ b/src/Mappers/ProjectMapper.php @@ -38,19 +38,19 @@ public static function map(Response $response) // Set the result and status attribute $project->setResult($projectElement->getAttribute('result')) - ->setStatus(self::parseEnumAttribute('Status', $projectElement->getAttribute('status'))); + ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $projectElement->getAttribute('status'))); // Set the project elements from the project element - $project->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($projectElement, 'behaviour', $project))) + $project->setBehaviour(self::parseEnumAttribute(\PhpTwinfield\Enums\Behaviour::class, self::getField($projectElement, 'behaviour', $project))) ->setCode(self::getField($projectElement, 'code', $project)) ->setInUse(self::parseBooleanAttribute(self::getField($projectElement, 'name', $project))) ->setName(self::getField($projectElement, 'name', $project)) - ->setOffice(self::parseObjectAttribute('Office', $project, $projectElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $project, $projectElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setShortName(self::getField($projectElement, 'shortname', $project)) ->setTouched(self::getField($projectElement, 'touched', $project)) - ->setType(self::parseObjectAttribute('DimensionType', $project, $projectElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setType(self::parseObjectAttribute(\PhpTwinfield\DimensionType::class, $project, $projectElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setUID(self::getField($projectElement, 'uid', $project)) - ->setVatCode(self::parseObjectAttribute('VatCode', $project, $projectElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); + ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $project, $projectElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); // Get the projects element $projectsElement = $responseDOM->getElementsByTagName('projects')->item(0); @@ -60,11 +60,11 @@ public static function map(Response $response) $projectProjects = new ProjectProjects(); // Set the projects elements from the projects element - $projectProjects->setAuthoriser(self::parseObjectAttribute('User', $projectProjects, $projectsElement, 'authoriser')) + $projectProjects->setAuthoriser(self::parseObjectAttribute(\PhpTwinfield\User::class, $projectProjects, $projectsElement, 'authoriser')) ->setBillable(self::parseBooleanAttribute(self::getField($projectsElement, 'billable', $projectProjects))) - ->setCustomer(self::parseObjectAttribute('Customer', $projectProjects, $projectsElement, 'customer')) + ->setCustomer(self::parseObjectAttribute(\PhpTwinfield\Customer::class, $projectProjects, $projectsElement, 'customer')) ->setInvoiceDescription(self::getField($projectsElement, 'invoicedescription', $projectProjects)) - ->setRate(self::parseObjectAttribute('Rate', $projectProjects, $projectsElement, 'rate')) + ->setRate(self::parseObjectAttribute(\PhpTwinfield\Rate::class, $projectProjects, $projectsElement, 'rate')) ->setValidFrom(self::parseDateAttribute(self::getField($projectsElement, 'validfrom', $projectProjects))) ->setValidTill(self::parseDateAttribute(self::getField($projectsElement, 'validtill', $projectProjects))); @@ -96,7 +96,7 @@ public static function map(Response $response) $projectQuantity->setBillable(self::parseBooleanAttribute(self::getField($quantityElement, 'billable', $projectQuantity))) ->setLabel(self::getField($quantityElement, 'label', $projectQuantity)) ->setMandatory(self::parseBooleanAttribute(self::getField($quantityElement, 'mandatory', $projectQuantity))) - ->setRate(self::parseObjectAttribute('Rate', $projectQuantity, $quantityElement, 'rate')); + ->setRate(self::parseObjectAttribute(\PhpTwinfield\Rate::class, $projectQuantity, $quantityElement, 'rate')); // Set the quantity elements from the quantity element attributes $projectQuantity->setBillableLocked(self::parseBooleanAttribute(self::getAttribute($quantityElement, 'billable', 'locked'))); diff --git a/src/Mappers/RateMapper.php b/src/Mappers/RateMapper.php index 1a62c59b..2683a67b 100644 --- a/src/Mappers/RateMapper.php +++ b/src/Mappers/RateMapper.php @@ -37,20 +37,20 @@ public static function map(Response $response) // Set the result and status attribute $rate->setResult($rateElement->getAttribute('result')) - ->setStatus(self::parseEnumAttribute('Status', $rateElement->getAttribute('status'))); + ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $rateElement->getAttribute('status'))); // Set the rate elements from the rate element $rate->setCode(self::getField($rateElement, 'code', $rate)) ->setCreated(self::parseDateTimeAttribute(self::getField($rateElement, 'created', $rate))) - ->setCurrency(self::parseObjectAttribute('Currency', $rate, $rateElement, 'currency', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setCurrency(self::parseObjectAttribute(\PhpTwinfield\Currency::class, $rate, $rateElement, 'currency', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setModified(self::parseDateTimeAttribute(self::getField($rateElement, 'modified', $rate))) ->setName(self::getField($rateElement, 'name', $rate)) - ->setOffice(self::parseObjectAttribute('Office', $rate, $rateElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $rate, $rateElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setShortName(self::getField($rateElement, 'shortname', $rate)) ->setTouched(self::getField($rateElement, 'touched', $rate)) - ->setType(self::parseEnumAttribute('RateType', self::getField($rateElement, 'type', $rate))) + ->setType(self::parseEnumAttribute(\PhpTwinfield\Enums\RateType::class, self::getField($rateElement, 'type', $rate))) ->setUnit(self::getField($rateElement, 'unit', $rate)) - ->setUser(self::parseObjectAttribute('User', $rate, $rateElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); + ->setUser(self::parseObjectAttribute(\PhpTwinfield\User::class, $rate, $rateElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); // Get the ratechanges element $ratechangesDOMTag = $responseDOM->getElementsByTagName('ratechanges'); @@ -66,7 +66,7 @@ public static function map(Response $response) $rateRateChange = new RateRateChange(); $rateRateChange->setID($ratechangeElement->getAttribute('id')) - ->setStatus(self::parseEnumAttribute('Status', $rateElement->getAttribute('status'))); + ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $rateElement->getAttribute('status'))); // Set the project rate rate change elements from the ratechange element $rateRateChange->setBeginDate(self::parseDateAttribute(self::getField($ratechangeElement, 'begindate', $rateRateChange))) diff --git a/src/Mappers/SupplierMapper.php b/src/Mappers/SupplierMapper.php index 480337a6..e5de45b6 100644 --- a/src/Mappers/SupplierMapper.php +++ b/src/Mappers/SupplierMapper.php @@ -41,21 +41,21 @@ public static function map(Response $response) // Set the result and status attribute $supplier->setResult($supplierElement->getAttribute('result')) - ->setStatus(self::parseEnumAttribute('Status', $supplierElement->getAttribute('status'))); + ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $supplierElement->getAttribute('status'))); // Set the supplier elements from the supplier element $supplier->setBeginPeriod(self::getField($supplierElement, 'beginperiod', $supplier)) ->setBeginYear(self::getField($supplierElement, 'beginyear', $supplier)) - ->setBehaviour(self::parseEnumAttribute('Behaviour', self::getField($supplierElement, 'behaviour', $supplier))) + ->setBehaviour(self::parseEnumAttribute(\PhpTwinfield\Enums\Behaviour::class, self::getField($supplierElement, 'behaviour', $supplier))) ->setCode(self::getField($supplierElement, 'code', $supplier)) ->setEndPeriod(self::getField($supplierElement, 'endperiod', $supplier)) ->setEndYear(self::getField($supplierElement, 'endyear', $supplier)) - ->setGroup(self::parseObjectAttribute('DimensionGroup', $supplier, $supplierElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setGroup(self::parseObjectAttribute(\PhpTwinfield\DimensionGroup::class, $supplier, $supplierElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setInUse(self::parseBooleanAttribute(self::getField($supplierElement, 'name', $supplier))) ->setName(self::getField($supplierElement, 'name', $supplier)) - ->setOffice(self::parseObjectAttribute('Office', $supplier, $supplierElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $supplier, $supplierElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setTouched(self::getField($supplierElement, 'touched', $supplier)) - ->setType(self::parseObjectAttribute('DimensionType', $supplier, $supplierElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setType(self::parseObjectAttribute(\PhpTwinfield\DimensionType::class, $supplier, $supplierElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setUID(self::getField($supplierElement, 'uid', $supplier)) ->setWebsite(self::getField($supplierElement, 'website', $supplier)); @@ -67,18 +67,18 @@ public static function map(Response $response) $supplierFinancials = new SupplierFinancials(); // Set the financials elements from the financials element - $supplierFinancials->setAccountType(self::parseEnumAttribute('AccountType', self::getField($financialsElement, 'accounttype', $supplierFinancials))) + $supplierFinancials->setAccountType(self::parseEnumAttribute(\PhpTwinfield\Enums\AccountType::class, self::getField($financialsElement, 'accounttype', $supplierFinancials))) ->setDueDays(self::getField($financialsElement, 'duedays', $supplierFinancials)) ->setLevel(self::getField($financialsElement, 'level', $supplierFinancials)) - ->setMatchType(self::parseEnumAttribute('MatchType', self::getField($financialsElement, 'matchtype', $supplierFinancials))) - ->setMeansOfPayment(self::parseEnumAttribute('MeansOfPayment', self::getField($financialsElement, 'meansofpayment', $supplierFinancials))) + ->setMatchType(self::parseEnumAttribute(\PhpTwinfield\Enums\MatchType::class, self::getField($financialsElement, 'matchtype', $supplierFinancials))) + ->setMeansOfPayment(self::parseEnumAttribute(\PhpTwinfield\Enums\MeansOfPayment::class, self::getField($financialsElement, 'meansofpayment', $supplierFinancials))) ->setPayAvailable(self::parseBooleanAttribute(self::getField($financialsElement, 'payavailable', $supplierFinancials))) - ->setPayCode(self::parseObjectAttribute('PayCode', $supplierFinancials, $financialsElement, 'paycode', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setPayCode(self::parseObjectAttribute(\PhpTwinfield\PayCode::class, $supplierFinancials, $financialsElement, 'paycode', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setRelationsReference(self::getField($financialsElement, 'relationsreference', $supplierFinancials)) - ->setSubAnalyse(self::parseEnumAttribute('SubAnalyse', self::getField($financialsElement, 'subanalyse', $supplierFinancials))) + ->setSubAnalyse(self::parseEnumAttribute(\PhpTwinfield\Enums\SubAnalyse::class, self::getField($financialsElement, 'subanalyse', $supplierFinancials))) ->setSubstitutionLevel(self::getField($financialsElement, 'substitutionlevel', $supplierFinancials)) - ->setSubstituteWith(self::parseObjectAttribute('UnknownDimension', $supplierFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setVatCode(self::parseObjectAttribute('VatCode', $supplierFinancials, $financialsElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); + ->setSubstituteWith(self::parseObjectAttribute(\PhpTwinfield\UnknownDimension::class, $supplierFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $supplierFinancials, $financialsElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); // Set the financials elements from the financials element attributes $supplierFinancials->setPayCodeID(self::getAttribute($financialsElement, 'paycode', 'id')) @@ -100,7 +100,7 @@ public static function map(Response $response) // Set the child validation elements from the child validation element en element attributes $supplierChildValidation->setLevel($childValidationElement->getAttribute('level')) - ->setType(self::parseEnumAttribute('ChildValidationType', $childValidationElement->getAttribute('type'))) + ->setType(self::parseEnumAttribute(\PhpTwinfield\Enums\ChildValidationType::class, $childValidationElement->getAttribute('type'))) ->setElementValue($childValidationElement->textContent); // Add the child validation to the supplier financials class @@ -120,7 +120,7 @@ public static function map(Response $response) if ($remittanceAdviceElement !== null) { // Set the supplier elements from the remittanceadvice element - $supplier->setRemittanceAdviceSendType(self::parseEnumAttribute('RemittanceAdviceSendType', self::getField($remittanceAdviceElement, 'sendtype', $supplier))) + $supplier->setRemittanceAdviceSendType(self::parseEnumAttribute(\PhpTwinfield\Enums\RemittanceAdviceSendType::class, self::getField($remittanceAdviceElement, 'sendtype', $supplier))) ->setRemittanceAdviceSendMail(self::getField($remittanceAdviceElement, 'sendmail', $supplier)); } @@ -140,11 +140,11 @@ public static function map(Response $response) // Set the default, id and type attribute $supplierAddress->setDefault(self::parseBooleanAttribute($addressElement->getAttribute('default'))) ->setID($addressElement->getAttribute('id')) - ->setType(self::parseEnumAttribute('AddressType', $addressElement->getAttribute('type'))); + ->setType(self::parseEnumAttribute(\PhpTwinfield\Enums\AddressType::class, $addressElement->getAttribute('type'))); // Set the address elements from the address element $supplierAddress->setCity(self::getField($addressElement, 'city', $supplierAddress)) - ->setCountry(self::parseObjectAttribute('Country', $supplierAddress, $addressElement, 'country', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setCountry(self::parseObjectAttribute(\PhpTwinfield\Country::class, $supplierAddress, $addressElement, 'country', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setEmail(self::getField($addressElement, 'email', $supplierAddress)) ->setField1(self::getField($addressElement, 'field1', $supplierAddress)) ->setField2(self::getField($addressElement, 'field2', $supplierAddress)) @@ -191,7 +191,7 @@ public static function map(Response $response) ->setBankName(self::getField($bankElement, 'bankname', $supplierBank)) ->setBicCode(self::getField($bankElement, 'biccode', $supplierBank)) ->setCity(self::getField($bankElement, 'city', $supplierBank)) - ->setCountry(self::parseObjectAttribute('Country', $supplierBank, $bankElement, 'country', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setCountry(self::parseObjectAttribute(\PhpTwinfield\Country::class, $supplierBank, $bankElement, 'country', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setIban(self::getField($bankElement, 'iban', $supplierBank)) ->setNatBicCode(self::getField($bankElement, 'natbiccode', $supplierBank)) ->setPostcode(self::getField($bankElement, 'postcode', $supplierBank)) @@ -220,11 +220,11 @@ public static function map(Response $response) // Set the id and status attribute $supplierPostingRule->setID($postingruleElement->getAttribute('id')) - ->setStatus(self::parseEnumAttribute('Status', $postingruleElement->getAttribute('status'))); + ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $postingruleElement->getAttribute('status'))); // Set the postingrule elements from the postingrule element $supplierPostingRule->setAmount(self::parseMoneyAttribute(self::getField($postingruleElement, 'amount', $supplierPostingRule))) - ->setCurrency(self::parseObjectAttribute('Currency', $supplierPostingRule, $postingruleElement, 'currency', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setCurrency(self::parseObjectAttribute(\PhpTwinfield\Currency::class, $supplierPostingRule, $postingruleElement, 'currency', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setDescription(self::getField($postingruleElement, 'description', $supplierPostingRule)); // Get the lines element @@ -242,12 +242,12 @@ public static function map(Response $response) // Set the line elements from the line element $supplierLine->setDescription(self::getField($lineElement, 'description', $supplierLine)) - ->setDimension1(self::parseObjectAttribute('GeneralLedger', $supplierLine, $lineElement, 'dimension1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setDimension2(self::parseObjectAttribute('CostCenter', $supplierLine, $lineElement, 'dimension2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setDimension3(self::parseObjectAttribute('UnknownDimension', $supplierLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setOffice(self::parseObjectAttribute('Office', $supplierLine, $lineElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setDimension1(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $supplierLine, $lineElement, 'dimension1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setDimension2(self::parseObjectAttribute(\PhpTwinfield\CostCenter::class, $supplierLine, $lineElement, 'dimension2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setDimension3(self::parseObjectAttribute(\PhpTwinfield\UnknownDimension::class, $supplierLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $supplierLine, $lineElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setRatio(self::getField($lineElement, 'ratio', $supplierLine)) - ->setVatCode(self::parseObjectAttribute('VatCode', $supplierLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); + ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $supplierLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); // Set the line elements from the line element attributes $supplierLine->setDimension1ID(self::getAttribute($lineElement, 'dimension1', 'id')) @@ -284,7 +284,7 @@ public static function map(Response $response) if ($blockedAccountPaymentConditionsElement !== null) { // Set the supplier elements from the blockedaccountpaymentconditions element - $supplier->setBlockedAccountPaymentConditionsIncludeVat(self::parseEnumAttribute('BlockedAccountPaymentConditionsIncludeVat', self::getField($blockedAccountPaymentConditionsElement, 'includevat', $supplier))) + $supplier->setBlockedAccountPaymentConditionsIncludeVat(self::parseEnumAttribute(\PhpTwinfield\Enums\BlockedAccountPaymentConditionsIncludeVat::class, self::getField($blockedAccountPaymentConditionsElement, 'includevat', $supplier))) ->setBlockedAccountPaymentConditionsPercentage(self::getField($blockedAccountPaymentConditionsElement, 'percentage', $supplier)); } diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 453fdc92..7b2fbc42 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -76,7 +76,7 @@ public static function map(string $transactionClassName, Response $response): Ba } if (!empty($destiny)) { - $transaction->setDestiny(self::parseEnumAttribute('Destiny', $destiny)); + $transaction->setDestiny(self::parseEnumAttribute(\PhpTwinfield\Enums\Destiny::class, $destiny)); } $raiseWarning = $transactionElement->getAttribute('raisewarning'); @@ -147,13 +147,13 @@ public static function map(string $transactionClassName, Response $response): Ba ->setBaseValueFromFloat(self::getField($lineElement, 'basevalue', $transactionLine)) ->setComment(self::getField($lineElement, 'comment', $transactionLine)) ->setValueFromFloat(self::getField($lineElement, 'value', $transactionLine)) - ->setDebitCredit(self::parseEnumAttribute('DebitCredit', self::getField($lineElement, 'debitcredit', $transactionLine))) + ->setDebitCredit(self::parseEnumAttribute(\PhpTwinfield\Enums\DebitCredit::class, self::getField($lineElement, 'debitcredit', $transactionLine))) ->setDescription(self::getField($lineElement, 'description', $transactionLine)) ->setDestOfficeFromString(self::getField($lineElement, 'destoffice', $transactionLine)) ->setDim1FromString(self::getField($lineElement, 'dim1', $transactionLine)) ->setId($lineElement->getAttribute('id')) ->setLineType(new LineType($lineType)) - ->setMatchStatus(self::parseEnumAttribute('MatchStatus', self::getField($lineElement, 'matchstatus', $transactionLine))) + ->setMatchStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\MatchStatus::class, self::getField($lineElement, 'matchstatus', $transactionLine))) ->setRate(self::getField($lineElement, 'rate', $transactionLine)) ->setRepRate(self::getField($lineElement, 'reprate', $transactionLine)) ->setRepValueFromFloat(self::getField($lineElement, 'repvalue', $transactionLine)); diff --git a/src/Mappers/UserMapper.php b/src/Mappers/UserMapper.php index d7d28b06..199239e1 100644 --- a/src/Mappers/UserMapper.php +++ b/src/Mappers/UserMapper.php @@ -40,7 +40,7 @@ public static function map(Response $response) $user->setIsCurrentUser(self::parseBooleanAttribute($userElement->getAttribute('iscurrentuser'))); $user->setLevel($userElement->getAttribute('level')); $user->setResult($userElement->getAttribute('result')); - $user->setStatus(self::parseEnumAttribute('Status', $userElement->getAttribute('status'))); + $user->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $userElement->getAttribute('status'))); // Set the user elements from the user element $user->setAcceptExtraCostField(self::parseBooleanAttribute(self::getField($userElement, 'acceptextracost', $user))) @@ -53,10 +53,10 @@ public static function map(Response $response) ->setFileManagerQuota(self::getField($userElement, 'filemanagerquota', $user)) ->setModified(self::parseDateTimeAttribute(self::getField($userElement, 'modified', $user))) ->setName(self::getField($userElement, 'name', $user)) - ->setRole(self::parseObjectAttribute('UserRole', $user, $userElement, 'method', array('level' => 'setLevel', 'name' => 'setName', 'shortname' => 'setShortName'))) + ->setRole(self::parseObjectAttribute(\PhpTwinfield\UserRole::class, $user, $userElement, 'method', array('level' => 'setLevel', 'name' => 'setName', 'shortname' => 'setShortName'))) ->setShortName(self::getField($userElement, 'shortname', $user)) ->setTouched(self::getField($userElement, 'touched', $user)) - ->setType(self::parseEnumAttribute('UserType', self::getField($userElement, 'type', $user))); + ->setType(self::parseEnumAttribute(\PhpTwinfield\Enums\UserType::class, self::getField($userElement, 'type', $user))); // Set the user elements from the user element attributes $user->setCultureName(self::getAttribute($userElement, 'culture', 'name')) diff --git a/src/Mappers/VatCodeMapper.php b/src/Mappers/VatCodeMapper.php index 22dda6a4..c01c8a29 100644 --- a/src/Mappers/VatCodeMapper.php +++ b/src/Mappers/VatCodeMapper.php @@ -38,7 +38,7 @@ public static function map(Response $response) // Set the result and status attribute $vatCode->setResult($vatCodeElement->getAttribute('result')) - ->setStatus(self::parseEnumAttribute('Status', $vatCodeElement->getAttribute('status'))); + ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $vatCodeElement->getAttribute('status'))); // Set the vat code elements from the vat element $vatCode->setCode(self::getField($vatCodeElement, 'code', $vatCode)) @@ -47,9 +47,9 @@ public static function map(Response $response) ->setName(self::getField($vatCodeElement, 'name', $vatCode)) ->setShortName(self::getField($vatCodeElement, 'shortname', $vatCode)) ->setTouched(self::getField($vatCodeElement, 'touched', $vatCode)) - ->setType(self::parseEnumAttribute('VatType', self::getField($vatCodeElement, 'type', $vatCode))) + ->setType(self::parseEnumAttribute(\PhpTwinfield\Enums\VatType::class, self::getField($vatCodeElement, 'type', $vatCode))) ->setUID(self::getField($vatCodeElement, 'uid', $vatCode)) - ->setUser(self::parseObjectAttribute('User', $vatCode, $vatCodeElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); + ->setUser(self::parseObjectAttribute(\PhpTwinfield\User::class, $vatCode, $vatCodeElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); // Get the percentages element $percentagesDOMTag = $responseDOM->getElementsByTagName('percentages'); @@ -70,7 +70,7 @@ public static function map(Response $response) ->setName(self::getField($percentageElement, 'name', $vatCodePercentage)) ->setPercentage(self::getField($percentageElement, 'percentage', $vatCodePercentage)) ->setShortName(self::getField($percentageElement, 'shortname', $vatCodePercentage)) - ->setUser(self::parseObjectAttribute('User', $vatCodePercentage, $percentageElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); + ->setUser(self::parseObjectAttribute(\PhpTwinfield\User::class, $vatCodePercentage, $percentageElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); // Get the accounts element $accountsDOMTag = $percentageElement->getElementsByTagName('accounts'); @@ -89,10 +89,10 @@ public static function map(Response $response) $vatCodeAccount->setID($accountElement->getAttribute('id')); // Set the vat code percentage account elements from the account element - $vatCodeAccount->setDim1(self::parseObjectAttribute('GeneralLedger', $vatCodeAccount, $accountElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setGroup(self::parseObjectAttribute('VatGroup', $vatCodeAccount, $accountElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setGroupCountry(self::parseObjectAttribute('VatGroupCountry', $vatCodeAccount, $accountElement, 'groupcountry', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setLineType(self::parseEnumAttribute('LineType', self::getField($accountElement, 'linetype', $vatCodeAccount))) + $vatCodeAccount->setDim1(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $vatCodeAccount, $accountElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setGroup(self::parseObjectAttribute(\PhpTwinfield\VatGroup::class, $vatCodeAccount, $accountElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setGroupCountry(self::parseObjectAttribute(\PhpTwinfield\VatGroupCountry::class, $vatCodeAccount, $accountElement, 'groupcountry', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setLineType(self::parseEnumAttribute(\PhpTwinfield\Enums\LineType::class, self::getField($accountElement, 'linetype', $vatCodeAccount))) ->setPercentage(self::getField($accountElement, 'percentage', $vatCodeAccount)); // Add the account to the percentage diff --git a/src/Request/Read/Activity.php b/src/Request/Read/Activity.php index b8ba8532..50beb32d 100644 --- a/src/Request/Read/Activity.php +++ b/src/Request/Read/Activity.php @@ -1,6 +1,8 @@ add('office', $office); return $this; diff --git a/src/Request/Read/Supplier.php b/src/Request/Read/Supplier.php index 0fd9e75e..a6ba3d96 100644 --- a/src/Request/Read/Supplier.php +++ b/src/Request/Read/Supplier.php @@ -1,6 +1,8 @@ with($this->isInstanceOf(\PhpTwinfield\Request\Read\Customer::class)) ->willReturn($response); - $customer = $this->customerApiConnector->get('CODE', $this->office); + $customer = $this->customerApiConnector->get('CODE', Office::fromCode('001')); $this->assertInstanceOf(Customer::class, $customer); $this->assertSame('001', $customer->getOfficeToString()); @@ -58,7 +58,7 @@ public function testGetCustomerWorks() $this->assertSame('http://www.example.com', $customer->getWebsite()); // Financials - $financials = $customer->getFinancials(); + $financials = $customer->getFinancials(); $this->assertSame(30, $financials->getDueDays()); $this->assertSame(true, $financials->getPayAvailable()); $this->assertSame('SEPANLDD', $financials->getPayCodeToString()); @@ -164,7 +164,7 @@ public function testListAllCustomersWorks() $this->assertSame('D1001', $customers[1]->getCode()); $this->assertSame('B. Terwel', $customers[1]->getName()); - + $this->assertSame('D1002', $customers[2]->getCode()); $this->assertSame('Hr E G H Küppers en/of MW M.J. Küppers-Veeneman', $customers[2]->getName()); } @@ -174,18 +174,18 @@ public function testSendCustomerWorks() $customer = new Customer(); $customer->setOffice(Office::fromCode('001')); $customer->setName('Customer 0'); - + $financials = new CustomerFinancials(); $financials->setDueDays(30); $financials->setPayAvailable(true); $financials->setPayCodeFromString('SEPANLDD'); - + $collectMandate = new CustomerCollectMandate(); $collectMandate->setID(1); $collectMandate->setSignatureDateFromString('20180604'); $collectMandate->setFirstRunDateFromString('20180608'); $financials->setCollectMandate($collectMandate); - + $customer->setFinancials($financials); $address = new CustomerAddress(); diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 61d12b15..2ab2f5ea 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -61,7 +61,7 @@ public function testGetConceptInvoiceWorks() ->with($this->isInstanceOf(\PhpTwinfield\Request\Read\Invoice::class)) ->willReturn($response); - $invoice = $this->invoiceApiConnector->get('FACTUUR', '5', $this->office); + $invoice = $this->invoiceApiConnector->get('FACTUUR', '5', Office::fromCode('001')); $this->assertInstanceOf(Invoice::class, $invoice); $this->assertEquals(Office::fromCode("11024"), $invoice->getOffice()); @@ -129,7 +129,7 @@ public function testGetFinalInvoiceWorks() ->with($this->isInstanceOf(\PhpTwinfield\Request\Read\Invoice::class)) ->willReturn($response); - $invoice = $this->invoiceApiConnector->get('FACTUUR', '5', $this->office); + $invoice = $this->invoiceApiConnector->get('FACTUUR', '5', Office::fromCode('001')); $this->assertInstanceOf(Invoice::class, $invoice); $this->assertEquals(Office::fromCode("11024"), $invoice->getOffice()); From a6b6be99fe69154ee9d99dafeed566dd1e115f05 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 10 Jun 2019 21:49:56 +0200 Subject: [PATCH 286/388] Upload --- src/Mappers/BaseMapper.php | 6 ++---- src/Mappers/CustomerMapper.php | 4 ++-- src/Mappers/FixedAssetMapper.php | 10 +++++----- src/Mappers/SupplierMapper.php | 4 ++-- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index 921382b5..eb128ef7 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -85,8 +85,6 @@ protected static function parseEnumAttribute(string $enumClass, ?string $value) return null; } - $enum = "\\PhpTwinfield\\Enums\\" . $enumName; - try { $classReflex = new \ReflectionClass($enumClass); $classConstants = $classReflex->getConstants(); @@ -97,7 +95,7 @@ protected static function parseEnumAttribute(string $enumClass, ?string $value) } } } catch (\ReflectionException $e) { - throw new Exception("Non existant Enum, got \"{$enumClass}\"."); + throw new \Exception("Non existant Enum, got \"{$enumClass}\"."); } return null; @@ -148,7 +146,7 @@ protected static function parseObjectAttribute(string $objectClass, $object, \DO $objectClass = \PhpTwinfield\Project::class; break; default: - throw new InvalidArgumentException("parseObjectAttribute function does not accept \"{$objectClass}\" as valid input for the \$object argument"); + throw new \InvalidArgumentException("parseObjectAttribute function does not accept \"{$objectClass}\" as valid input for the \$object argument"); } } diff --git a/src/Mappers/CustomerMapper.php b/src/Mappers/CustomerMapper.php index d2694dcf..fdedf4e0 100644 --- a/src/Mappers/CustomerMapper.php +++ b/src/Mappers/CustomerMapper.php @@ -85,7 +85,7 @@ public static function map(Response $response) ->setPayCode(self::parseObjectAttribute(\PhpTwinfield\PayCode::class, $customerFinancials, $financialsElement, 'paycode', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setSubAnalyse(self::parseEnumAttribute(\PhpTwinfield\Enums\SubAnalyse::class, self::getField($financialsElement, 'subanalyse', $customerFinancials))) ->setSubstitutionLevel(self::getField($financialsElement, 'substitutionlevel', $customerFinancials)) - ->setSubstituteWith(self::parseObjectAttribute(\PhpTwinfield\UnknownDimension::class, $customerFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setSubstituteWith(self::parseObjectAttribute('UnknownDimension', $customerFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $customerFinancials, $financialsElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); // Set the financials elements from the financials element attributes @@ -297,7 +297,7 @@ public static function map(Response $response) $customerLine->setDescription(self::getField($lineElement, 'description', $customerLine)) ->setDimension1(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $customerLine, $lineElement, 'dimension1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setDimension2(self::parseObjectAttribute(\PhpTwinfield\CostCenter::class, $customerLine, $lineElement, 'dimension2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setDimension3(self::parseObjectAttribute(\PhpTwinfield\UnknownDimension::class, $customerLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setDimension3(self::parseObjectAttribute('UnknownDimension', $customerLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $customerLine, $lineElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setRatio(self::getField($lineElement, 'ratio', $customerLine)) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $customerLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); diff --git a/src/Mappers/FixedAssetMapper.php b/src/Mappers/FixedAssetMapper.php index 721be092..34034aea 100644 --- a/src/Mappers/FixedAssetMapper.php +++ b/src/Mappers/FixedAssetMapper.php @@ -134,11 +134,11 @@ public static function map(Response $response) $fixedAssetTransactionLine->setAmount(self::parseMoneyAttribute(self::getField($transactionLineElement, 'amount', $fixedAssetTransactionLine))) ->setCode(self::getField($transactionLineElement, 'code', $fixedAssetTransactionLine)) ->setDim1(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $fixedAssetTransactionLine, $transactionLineElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) - ->setDim2(self::parseObjectAttribute(\PhpTwinfield\UnknownDimension::class, $fixedAssetTransactionLine, $transactionLineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) - ->setDim3(self::parseObjectAttribute(\PhpTwinfield\UnknownDimension::class, $fixedAssetTransactionLine, $transactionLineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) - ->setDim4(self::parseObjectAttribute(\PhpTwinfield\UnknownDimension::class, $fixedAssetTransactionLine, $transactionLineElement, 'dim4', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) - ->setDim5(self::parseObjectAttribute(\PhpTwinfield\UnknownDimension::class, $fixedAssetTransactionLine, $transactionLineElement, 'dim5', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) - ->setDim6(self::parseObjectAttribute(\PhpTwinfield\UnknownDimension::class, $fixedAssetTransactionLine, $transactionLineElement, 'dim6', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim2(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim3(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim4(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim4', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim5(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim5', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim6(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim6', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) ->setLine(self::getField($transactionLineElement, 'line', $fixedAssetTransactionLine)) ->setNumber(self::getField($transactionLineElement, 'number', $fixedAssetTransactionLine)) ->setPeriod(self::getField($transactionLineElement, 'period', $fixedAssetTransactionLine)); diff --git a/src/Mappers/SupplierMapper.php b/src/Mappers/SupplierMapper.php index e5de45b6..c8c269cb 100644 --- a/src/Mappers/SupplierMapper.php +++ b/src/Mappers/SupplierMapper.php @@ -77,7 +77,7 @@ public static function map(Response $response) ->setRelationsReference(self::getField($financialsElement, 'relationsreference', $supplierFinancials)) ->setSubAnalyse(self::parseEnumAttribute(\PhpTwinfield\Enums\SubAnalyse::class, self::getField($financialsElement, 'subanalyse', $supplierFinancials))) ->setSubstitutionLevel(self::getField($financialsElement, 'substitutionlevel', $supplierFinancials)) - ->setSubstituteWith(self::parseObjectAttribute(\PhpTwinfield\UnknownDimension::class, $supplierFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setSubstituteWith(self::parseObjectAttribute('UnknownDimension', $supplierFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $supplierFinancials, $financialsElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); // Set the financials elements from the financials element attributes @@ -244,7 +244,7 @@ public static function map(Response $response) $supplierLine->setDescription(self::getField($lineElement, 'description', $supplierLine)) ->setDimension1(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $supplierLine, $lineElement, 'dimension1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setDimension2(self::parseObjectAttribute(\PhpTwinfield\CostCenter::class, $supplierLine, $lineElement, 'dimension2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setDimension3(self::parseObjectAttribute(\PhpTwinfield\UnknownDimension::class, $supplierLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setDimension3(self::parseObjectAttribute('UnknownDimension', $supplierLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $supplierLine, $lineElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setRatio(self::getField($lineElement, 'ratio', $supplierLine)) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $supplierLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); From 12c2fb4b737765b89e8c53a1475151f68f638fb4 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 10 Jun 2019 22:08:56 +0200 Subject: [PATCH 287/388] Upload --- src/ApiConnectors/ActivityApiConnector.php | 4 ++-- src/ApiConnectors/ArticleApiConnector.php | 4 ++-- src/ApiConnectors/AssetMethodApiConnector.php | 4 ++-- src/ApiConnectors/BaseApiConnector.php | 8 +++----- src/ApiConnectors/CashBankBookApiConnector.php | 2 +- src/ApiConnectors/CostCenterApiConnector.php | 4 ++-- src/ApiConnectors/CountryApiConnector.php | 2 +- src/ApiConnectors/CurrencyApiConnector.php | 2 +- src/ApiConnectors/CustomerApiConnector.php | 4 ++-- src/ApiConnectors/DimensionGroupApiConnector.php | 4 ++-- src/ApiConnectors/DimensionTypeApiConnector.php | 4 ++-- src/ApiConnectors/FixedAssetApiConnector.php | 4 ++-- src/ApiConnectors/GeneralLedgerApiConnector.php | 4 ++-- src/ApiConnectors/InvoiceApiConnector.php | 4 ++-- src/ApiConnectors/InvoiceTypeApiConnector.php | 2 +- src/ApiConnectors/OfficeApiConnector.php | 2 +- src/ApiConnectors/PayCodeApiConnector.php | 2 +- src/ApiConnectors/ProjectApiConnector.php | 4 ++-- src/ApiConnectors/RateApiConnector.php | 4 ++-- src/ApiConnectors/SupplierApiConnector.php | 4 ++-- src/ApiConnectors/UserApiConnector.php | 4 ++-- src/ApiConnectors/UserRoleApiConnector.php | 2 +- src/ApiConnectors/VatCodeApiConnector.php | 4 ++-- src/ApiConnectors/VatGroupApiConnector.php | 2 +- src/ApiConnectors/VatGroupCountryApiConnector.php | 2 +- 25 files changed, 42 insertions(+), 44 deletions(-) diff --git a/src/ApiConnectors/ActivityApiConnector.php b/src/ApiConnectors/ActivityApiConnector.php index 5bf1cc77..2fae6c4c 100644 --- a/src/ApiConnectors/ActivityApiConnector.php +++ b/src/ApiConnectors/ActivityApiConnector.php @@ -39,7 +39,7 @@ public function get(string $code, Office $office): Activity // Make a request to read a single Activity. Set the required values $request_activity = new Request\Read\Activity(); $request_activity - ->setOffice($office->getCode()) + ->setOffice($office) ->setCode($code); // Send the Request document and set the response to this instance. @@ -122,7 +122,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("Activity", $response->data, $activityArrayListAllTags); + return $this->mapListAll(\PhpTwinfield\Activity::class, $response->data, $activityArrayListAllTags); } /** diff --git a/src/ApiConnectors/ArticleApiConnector.php b/src/ApiConnectors/ArticleApiConnector.php index 5c19cd23..47174504 100644 --- a/src/ApiConnectors/ArticleApiConnector.php +++ b/src/ApiConnectors/ArticleApiConnector.php @@ -39,7 +39,7 @@ public function get(string $code, Office $office): Article // Make a request to read a single Article. Set the required values $request_article = new Request\Read\Article(); $request_article - ->setOffice($office->getCode()) + ->setOffice($office) ->setCode($code); // Send the Request document and set the response to this instance. @@ -120,7 +120,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("Article", $response->data, $articleArrayListAllTags); + return $this->mapListAll(\PhpTwinfield\Article::class, $response->data, $articleArrayListAllTags); } /** diff --git a/src/ApiConnectors/AssetMethodApiConnector.php b/src/ApiConnectors/AssetMethodApiConnector.php index cdf6372d..35348c9e 100644 --- a/src/ApiConnectors/AssetMethodApiConnector.php +++ b/src/ApiConnectors/AssetMethodApiConnector.php @@ -39,7 +39,7 @@ public function get(string $code, Office $office): AssetMethod // Make a request to read a single AssetMethod. Set the required values $request_assetMethod = new Request\AssetMethod(); $request_assetMethod - ->setOffice($office->getCode()) + ->setOffice($office) ->setCode($code); // Send the Request document and set the response to this instance. @@ -121,7 +121,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("AssetMethod", $response->data, $assetMethodArrayListAllTags); + return $this->mapListAll(\PhpTwinfield\AssetMethod::class, $response->data, $assetMethodArrayListAllTags); } /** diff --git a/src/ApiConnectors/BaseApiConnector.php b/src/ApiConnectors/BaseApiConnector.php index de8b08ef..b1b78db7 100644 --- a/src/ApiConnectors/BaseApiConnector.php +++ b/src/ApiConnectors/BaseApiConnector.php @@ -206,13 +206,13 @@ public function convertOptionsToArrayOfString(array $options, array $forcedOptio /** * Map the response of a listAll to an array of the requested class * - * @param string $className + * @param string $objectClass * @param $data * @param array $objectListAllTags * @return array * @throws Exception */ - public function mapListAll(string $className, $data, array $objectListAllTags): array { + public function mapListAll(string $objectClass, $data, array $objectListAllTags): array { if ($data->TotalRows == 0) { return []; } @@ -220,9 +220,7 @@ public function mapListAll(string $className, $data, array $objectListAllTags): $objects = []; foreach ($data->Items->ArrayOfString as $responseArrayElement) { - $class = "\\PhpTwinfield\\" . $className; - - $object = new $class(); + $object = new $objectClass(); if (isset($responseArrayElement->string[0])) { $elementArray = $responseArrayElement->string; diff --git a/src/ApiConnectors/CashBankBookApiConnector.php b/src/ApiConnectors/CashBankBookApiConnector.php index 1381897c..f21fc1f4 100644 --- a/src/ApiConnectors/CashBankBookApiConnector.php +++ b/src/ApiConnectors/CashBankBookApiConnector.php @@ -48,6 +48,6 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("CashBankBook", $response->data, $cashBankBookListAllTags); + return $this->mapListAll(\PhpTwinfield\CashBankBook::class, $response->data, $cashBankBookListAllTags); } } \ No newline at end of file diff --git a/src/ApiConnectors/CostCenterApiConnector.php b/src/ApiConnectors/CostCenterApiConnector.php index cf46c073..c4ea6cb9 100644 --- a/src/ApiConnectors/CostCenterApiConnector.php +++ b/src/ApiConnectors/CostCenterApiConnector.php @@ -39,7 +39,7 @@ public function get(string $code, Office $office): CostCenter // Make a request to read a single CostCenter. Set the required values $request_costCenter = new Request\Read\CostCenter(); $request_costCenter - ->setOffice($office->getCode()) + ->setOffice($office) ->setCode($code); // Send the Request document and set the response to this instance. @@ -122,7 +122,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("CostCenter", $response->data, $costCenterArrayListAllTags); + return $this->mapListAll(\PhpTwinfield\CostCenter::class, $response->data, $costCenterArrayListAllTags); } /** diff --git a/src/ApiConnectors/CountryApiConnector.php b/src/ApiConnectors/CountryApiConnector.php index e3c67634..80fcf044 100644 --- a/src/ApiConnectors/CountryApiConnector.php +++ b/src/ApiConnectors/CountryApiConnector.php @@ -48,6 +48,6 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("Country", $response->data, $countryListAllTags); + return $this->mapListAll(\PhpTwinfield\Country::class, $response->data, $countryListAllTags); } } \ No newline at end of file diff --git a/src/ApiConnectors/CurrencyApiConnector.php b/src/ApiConnectors/CurrencyApiConnector.php index 1ebdc64e..6f29a9b4 100644 --- a/src/ApiConnectors/CurrencyApiConnector.php +++ b/src/ApiConnectors/CurrencyApiConnector.php @@ -148,7 +148,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("Currency", $response->data, $currencyArrayListAllTags); + return $this->mapListAll(\PhpTwinfield\Currency::class, $response->data, $currencyArrayListAllTags); } /** diff --git a/src/ApiConnectors/CustomerApiConnector.php b/src/ApiConnectors/CustomerApiConnector.php index 9b459383..24a16dfb 100644 --- a/src/ApiConnectors/CustomerApiConnector.php +++ b/src/ApiConnectors/CustomerApiConnector.php @@ -40,7 +40,7 @@ public function get(string $code, Office $office): Customer // Make a request to read a single customer. Set the required values $request_customer = new Request\Read\Customer(); $request_customer - ->setOffice($office->getCode()) + ->setOffice($office) ->setCode($code); // Send the Request document and set the response to this instance. @@ -122,7 +122,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("Customer", $response->data, $customerListAllTags); + return $this->mapListAll(\PhpTwinfield\Customer::class, $response->data, $customerListAllTags); } /** diff --git a/src/ApiConnectors/DimensionGroupApiConnector.php b/src/ApiConnectors/DimensionGroupApiConnector.php index a87299dc..93906c17 100644 --- a/src/ApiConnectors/DimensionGroupApiConnector.php +++ b/src/ApiConnectors/DimensionGroupApiConnector.php @@ -39,7 +39,7 @@ public function get(string $code, Office $office): DimensionGroup // Make a request to read a single DimensionGroup. Set the required values $request_dimensionGroup = new Request\DimensionGroup(); $request_dimensionGroup - ->setOffice($office->getCode()) + ->setOffice($office) ->setCode($code); // Send the Request document and set the response to this instance. @@ -121,7 +121,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("DimensionGroup", $response->data, $dimensionGroupListAllTags); + return $this->mapListAll(\PhpTwinfield\DimensionGroup::class, $response->data, $dimensionGroupListAllTags); } /** diff --git a/src/ApiConnectors/DimensionTypeApiConnector.php b/src/ApiConnectors/DimensionTypeApiConnector.php index a32eaf77..bb9c1539 100644 --- a/src/ApiConnectors/DimensionTypeApiConnector.php +++ b/src/ApiConnectors/DimensionTypeApiConnector.php @@ -38,7 +38,7 @@ public function get(string $code, Office $office): DimensionType // Make a request to read a single DimensionType. Set the required values $request_dimensionType = new Request\DimensionType(); $request_dimensionType - ->setOffice($office->getCode()) + ->setOffice($office) ->setCode($code); // Send the Request document and set the response to this instance. @@ -120,6 +120,6 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("DimensionType", $response->data, $dimensionTypeListAllTags); + return $this->mapListAll(\PhpTwinfield\DimensionType::class, $response->data, $dimensionTypeListAllTags); } } \ No newline at end of file diff --git a/src/ApiConnectors/FixedAssetApiConnector.php b/src/ApiConnectors/FixedAssetApiConnector.php index 0196b0ea..cf1eb741 100644 --- a/src/ApiConnectors/FixedAssetApiConnector.php +++ b/src/ApiConnectors/FixedAssetApiConnector.php @@ -39,7 +39,7 @@ public function get(string $code, Office $office): FixedAsset // Make a request to read a single FixedAsset. Set the required values $request_fixedAsset = new Request\Read\FixedAsset(); $request_fixedAsset - ->setOffice($office->getCode()) + ->setOffice($office) ->setCode($code); // Send the Request document and set the response to this instance. @@ -121,7 +121,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("FixedAsset", $response->data, $fixedAssetListAllTags); + return $this->mapListAll(\PhpTwinfield\FixedAsset::class, $response->data, $fixedAssetListAllTags); } /** diff --git a/src/ApiConnectors/GeneralLedgerApiConnector.php b/src/ApiConnectors/GeneralLedgerApiConnector.php index 33941cc4..926575d1 100644 --- a/src/ApiConnectors/GeneralLedgerApiConnector.php +++ b/src/ApiConnectors/GeneralLedgerApiConnector.php @@ -40,7 +40,7 @@ public function get(string $code, string $dimType, Office $office): GeneralLedge // Make a request to read a single GeneralLedger. Set the required values $request_generalLedger = new Request\Read\GeneralLedger(); $request_generalLedger - ->setOffice($office->getCode()) + ->setOffice($office) ->setDimType($dimType) ->setCode($code); @@ -123,7 +123,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("GeneralLedger", $response->data, $generalLedgerListAllTags); + return $this->mapListAll(\PhpTwinfield\GeneralLedger::class, $response->data, $generalLedgerListAllTags); } /** diff --git a/src/ApiConnectors/InvoiceApiConnector.php b/src/ApiConnectors/InvoiceApiConnector.php index 5012bbdf..0c2c9a6c 100644 --- a/src/ApiConnectors/InvoiceApiConnector.php +++ b/src/ApiConnectors/InvoiceApiConnector.php @@ -41,7 +41,7 @@ public function get(string $code, string $invoiceNumber, Office $office) $request_invoice ->setCode($code) ->setInvoiceNumber($invoiceNumber) - ->setOffice($office->getCode()); + ->setOffice($office); // Send the Request document and set the response to this instance $response = $this->sendXmlDocument($request_invoice); @@ -124,6 +124,6 @@ public function listAll( 4 => 'setDebitCreditFromString', ); - return $this->mapListAll("Invoice", $response->data, $invoiceListAllTags); + return $this->mapListAll(\PhpTwinfield\Invoice::class, $response->data, $invoiceListAllTags); } } diff --git a/src/ApiConnectors/InvoiceTypeApiConnector.php b/src/ApiConnectors/InvoiceTypeApiConnector.php index e1ab7606..cc5b9bd5 100644 --- a/src/ApiConnectors/InvoiceTypeApiConnector.php +++ b/src/ApiConnectors/InvoiceTypeApiConnector.php @@ -48,7 +48,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("InvoiceType", $response->data, $invoiceTypeListAllTags); + return $this->mapListAll(\PhpTwinfield\InvoiceType::class, $response->data, $invoiceTypeListAllTags); } /** diff --git a/src/ApiConnectors/OfficeApiConnector.php b/src/ApiConnectors/OfficeApiConnector.php index 7c7798db..fa8e055a 100644 --- a/src/ApiConnectors/OfficeApiConnector.php +++ b/src/ApiConnectors/OfficeApiConnector.php @@ -97,6 +97,6 @@ public function listAll( 4 => 'setVatFirstQuarterStartsIn', ); - return $this->mapListAll("Office", $response->data, $officeListAllTags); + return $this->mapListAll(\PhpTwinfield\Office::class, $response->data, $officeListAllTags); } } diff --git a/src/ApiConnectors/PayCodeApiConnector.php b/src/ApiConnectors/PayCodeApiConnector.php index 84938793..11c511e6 100644 --- a/src/ApiConnectors/PayCodeApiConnector.php +++ b/src/ApiConnectors/PayCodeApiConnector.php @@ -48,6 +48,6 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("PayCode", $response->data, $payCodeListAllTags); + return $this->mapListAll(\PhpTwinfield\PayCode::class, $response->data, $payCodeListAllTags); } } \ No newline at end of file diff --git a/src/ApiConnectors/ProjectApiConnector.php b/src/ApiConnectors/ProjectApiConnector.php index 8d62dc81..9c936d0c 100644 --- a/src/ApiConnectors/ProjectApiConnector.php +++ b/src/ApiConnectors/ProjectApiConnector.php @@ -39,7 +39,7 @@ public function get(string $code, Office $office): Project // Make a request to read a single Project. Set the required values $request_project = new Request\Read\Project(); $request_project - ->setOffice($office->getCode()) + ->setOffice($office) ->setCode($code); // Send the Request document and set the response to this instance. @@ -122,7 +122,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("Project", $response->data, $projectListAllTags); + return $this->mapListAll(\PhpTwinfield\Project::class, $response->data, $projectListAllTags); } /** diff --git a/src/ApiConnectors/RateApiConnector.php b/src/ApiConnectors/RateApiConnector.php index 8859ace7..6f57a299 100644 --- a/src/ApiConnectors/RateApiConnector.php +++ b/src/ApiConnectors/RateApiConnector.php @@ -39,7 +39,7 @@ public function get(string $code, Office $office): Rate // Make a request to read a single Rate. Set the required values $request_rate = new Request\Read\Rate(); $request_rate - ->setOffice($office->getCode()) + ->setOffice($office) ->setCode($code); // Send the Request document and set the response to this instance. @@ -121,7 +121,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("Rate", $response->data, $rateListAllTags); + return $this->mapListAll(\PhpTwinfield\Rate::class, $response->data, $rateListAllTags); } /** diff --git a/src/ApiConnectors/SupplierApiConnector.php b/src/ApiConnectors/SupplierApiConnector.php index 6a0b18b1..fb5d7b4c 100644 --- a/src/ApiConnectors/SupplierApiConnector.php +++ b/src/ApiConnectors/SupplierApiConnector.php @@ -40,7 +40,7 @@ public function get(string $code, Office $office): Supplier // Make a request to read a single supplier. Set the required values $request_supplier = new Request\Read\Supplier(); $request_supplier - ->setOffice($office->getCode()) + ->setOffice($office) ->setCode($code); // Send the Request document and set the response to this instance. @@ -122,7 +122,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("Supplier", $response->data, $supplierListAllTags); + return $this->mapListAll(\PhpTwinfield\Supplier::class, $response->data, $supplierListAllTags); } /** diff --git a/src/ApiConnectors/UserApiConnector.php b/src/ApiConnectors/UserApiConnector.php index 1a8c735a..1376d683 100644 --- a/src/ApiConnectors/UserApiConnector.php +++ b/src/ApiConnectors/UserApiConnector.php @@ -37,7 +37,7 @@ public function get(string $code, Office $office): User // Make a request to read a single User. Set the required values $request_user = new Request\Read\User(); $request_user - ->setOffice($office->getCode()) + ->setOffice($office) ->setCode($code); // Send the Request document and set the response to this instance. @@ -77,6 +77,6 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("User", $response->data, $userListAllTags); + return $this->mapListAll(\PhpTwinfield\User::class, $response->data, $userListAllTags); } } diff --git a/src/ApiConnectors/UserRoleApiConnector.php b/src/ApiConnectors/UserRoleApiConnector.php index 9e72ede0..494076af 100644 --- a/src/ApiConnectors/UserRoleApiConnector.php +++ b/src/ApiConnectors/UserRoleApiConnector.php @@ -48,6 +48,6 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("UserRole", $response->data, $userRoleListAllTags); + return $this->mapListAll(\PhpTwinfield\UserRole::class, $response->data, $userRoleListAllTags); } } \ No newline at end of file diff --git a/src/ApiConnectors/VatCodeApiConnector.php b/src/ApiConnectors/VatCodeApiConnector.php index 56403556..d58466f3 100644 --- a/src/ApiConnectors/VatCodeApiConnector.php +++ b/src/ApiConnectors/VatCodeApiConnector.php @@ -39,7 +39,7 @@ public function get(string $code, Office $office): VatCode // Make a request to read a single VatCode. Set the required values $request_vatCode = new Request\Read\VatCode(); $request_vatCode - ->setOffice($office->getCode()) + ->setOffice($office) ->setCode($code); // Send the Request document and set the response to this instance. @@ -121,7 +121,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("VatCode", $response->data, $vatCodeListAllTags); + return $this->mapListAll(\PhpTwinfield\VatCode::class, $response->data, $vatCodeListAllTags); } /** diff --git a/src/ApiConnectors/VatGroupApiConnector.php b/src/ApiConnectors/VatGroupApiConnector.php index 3a9d802c..adbe1dce 100644 --- a/src/ApiConnectors/VatGroupApiConnector.php +++ b/src/ApiConnectors/VatGroupApiConnector.php @@ -48,6 +48,6 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("VatGroup", $response->data, $vatGroupListAllTags); + return $this->mapListAll(\PhpTwinfield\VatGroup::class, $response->data, $vatGroupListAllTags); } } \ No newline at end of file diff --git a/src/ApiConnectors/VatGroupCountryApiConnector.php b/src/ApiConnectors/VatGroupCountryApiConnector.php index 99d4a703..ee5a3c7b 100644 --- a/src/ApiConnectors/VatGroupCountryApiConnector.php +++ b/src/ApiConnectors/VatGroupCountryApiConnector.php @@ -48,6 +48,6 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll("VatGroupCountry", $response->data, $vatGroupCountryListAllTags); + return $this->mapListAll(\PhpTwinfield\VatGroupCountry::class, $response->data, $vatGroupCountryListAllTags); } } \ No newline at end of file From 074f843dc9d07c4f51e92875bb22224a0278ae9a Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 10 Jun 2019 22:18:47 +0200 Subject: [PATCH 288/388] Upload --- src/Mappers/DimensionGroupMapper.php | 2 +- tests/IntegrationTests/resources/customerGetResponse.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mappers/DimensionGroupMapper.php b/src/Mappers/DimensionGroupMapper.php index be9e4bc1..15d86a54 100644 --- a/src/Mappers/DimensionGroupMapper.php +++ b/src/Mappers/DimensionGroupMapper.php @@ -61,7 +61,7 @@ public static function map(Response $response) // Set the dimension group dimension elements from the dimension element $dimensionGroupDimension->setType(self::parseObjectAttribute(\PhpTwinfield\DimensionType::class, $dimensionGroupDimension, $dimensionElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))); - $dimensionGroupDimension->setCode(self::parseObjectAttribute(\PhpTwinfield\DimensionGroupDimension::class, $dimensionGroupDimension, $dimensionElement, 'code', array('name' => 'setName', 'shortname' => 'setShortName'))); + $dimensionGroupDimension->setCode(self::parseObjectAttribute('DimensionGroupDimension', $dimensionGroupDimension, $dimensionElement, 'code', array('name' => 'setName', 'shortname' => 'setShortName'))); // Add the dimension to the dimension group $dimensiongroup->addDimension($dimensionGroupDimension); diff --git a/tests/IntegrationTests/resources/customerGetResponse.xml b/tests/IntegrationTests/resources/customerGetResponse.xml index 29aff77b..dccdd2cf 100644 --- a/tests/IntegrationTests/resources/customerGetResponse.xml +++ b/tests/IntegrationTests/resources/customerGetResponse.xml @@ -18,7 +18,7 @@ false 1 - 1300 + 1300 false From 9d92c98c8d0bad867c3447036e60e0344499fc17 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 10 Jun 2019 22:53:20 +0200 Subject: [PATCH 289/388] Upload --- src/DomDocuments/BaseDocument.php | 6 +++--- src/Mappers/BaseMapper.php | 15 +++------------ 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/DomDocuments/BaseDocument.php b/src/DomDocuments/BaseDocument.php index 64c16802..24232fd1 100644 --- a/src/DomDocuments/BaseDocument.php +++ b/src/DomDocuments/BaseDocument.php @@ -36,10 +36,10 @@ public function __construct($version = "1.0", $encoding = "UTF-8") * @param string $tag * @param string|null $textContent * @param $object - * @param array $attributes + * @param array $methodToAttributeMap * @return \DOMElement */ - final protected function createNodeWithTextContent(string $tag, ?string $textContent, $object = null, array $attributes = []): \DOMElement + final protected function createNodeWithTextContent(string $tag, ?string $textContent, $object = null, array $methodToAttributeMap = []): \DOMElement { $element = $this->createElement($tag); @@ -48,7 +48,7 @@ final protected function createNodeWithTextContent(string $tag, ?string $textCon } if (isset($object)) { - foreach ($attributes as $attributeName => $method) { + foreach ($methodToAttributeMap as $attributeName => $method) { $element->setAttribute($attributeName, $object->$method()); } } diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index eb128ef7..c3d69697 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -86,19 +86,10 @@ protected static function parseEnumAttribute(string $enumClass, ?string $value) } try { - $classReflex = new \ReflectionClass($enumClass); - $classConstants = $classReflex->getConstants(); - - foreach ($classConstants as $classConstant) { - if ($value == $classConstant) { - return new $enumClass($value); - } - } - } catch (\ReflectionException $e) { - throw new \Exception("Non existant Enum, got \"{$enumClass}\"."); + return new $enumClass($value); + } catch (\Exception $e) { + return null; } - - return null; } protected static function parseMoneyAttribute(?float $value): ?Money From 2437fa32ae3b2c7158b0ce66bf35f4abb9ea9ead Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 10 Jun 2019 23:07:26 +0200 Subject: [PATCH 290/388] Update BaseMapper.php --- src/Mappers/BaseMapper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index c3d69697..6061934e 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -4,13 +4,14 @@ use Money\Currency; use Money\Money; +use PhpTwinfield\BaseObject; use PhpTwinfield\Message\Message; use PhpTwinfield\Util; use Webmozart\Assert\Assert; abstract class BaseMapper { - protected static function checkForMessage($object, \DOMElement $element): void + protected static function checkForMessage(BaseObject $object, \DOMElement $element): void { if ($element->hasAttribute('msg')) { $message = new Message(); From 19556788ab8ea11ee3eaf2c49e1212be21e28714 Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 10 Jun 2019 23:18:18 +0200 Subject: [PATCH 291/388] Update BaseMapper.php --- src/Mappers/BaseMapper.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index 6061934e..c3d69697 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -4,14 +4,13 @@ use Money\Currency; use Money\Money; -use PhpTwinfield\BaseObject; use PhpTwinfield\Message\Message; use PhpTwinfield\Util; use Webmozart\Assert\Assert; abstract class BaseMapper { - protected static function checkForMessage(BaseObject $object, \DOMElement $element): void + protected static function checkForMessage($object, \DOMElement $element): void { if ($element->hasAttribute('msg')) { $message = new Message(); From bb9ee1f0b44db75d4254b59dac02e234da597e97 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 11 Jun 2019 12:53:40 +0200 Subject: [PATCH 292/388] Base Modifications Change Requests 2 --- src/Mappers/BaseMapper.php | 5 ----- src/Util.php | 14 +++----------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index c3d69697..2de5a3f1 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -56,11 +56,6 @@ protected static function getField(\DOMElement $element, string $fieldTagName, $ return $fieldElement->textContent; } - protected static function parseBooleanAttribute(?string $value): ?bool - { - return filter_var($value, FILTER_VALIDATE_BOOLEAN); - } - protected static function parseDateAttribute(?string $value): ?\DateTimeImmutable { if (false !== strtotime($value)) { diff --git a/src/Util.php b/src/Util.php index 636f9ee8..0af1dea9 100644 --- a/src/Util.php +++ b/src/Util.php @@ -92,20 +92,12 @@ public static function formatBoolean(bool $boolean): string } /** - * @param string $input + * @param string|null $input * @return bool - * @throws Exception */ - public static function parseBoolean(string $input): bool + protected static function parseBoolean(?string $value): bool { - switch ($input) { - case "true": - return true; - case "false": - return false; - } - - throw new Exception("Unknown boolean value \"{$input}\"."); + return filter_var($value, FILTER_VALIDATE_BOOLEAN); } /** From 800546c84b80ca34778d63124bf5a4898f3ecc6b Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 11 Jun 2019 12:57:15 +0200 Subject: [PATCH 293/388] Upload --- src/BaseObject.php | 2 +- src/HasMessageInterface.php | 20 ++++++++++ src/Mappers/ActivityMapper.php | 29 +++++++------- src/Mappers/ArticleMapper.php | 13 ++++--- src/Mappers/AssetMethodMapper.php | 3 +- src/Mappers/BaseMapper.php | 3 +- src/Mappers/CostCenterMapper.php | 3 +- src/Mappers/CustomerMapper.php | 21 +++++----- src/Mappers/FixedAssetMapper.php | 59 +++++++++++++++-------------- src/Mappers/GeneralLedgerMapper.php | 5 ++- src/Mappers/InvoiceMapper.php | 3 +- src/Mappers/ProjectMapper.php | 29 +++++++------- src/Mappers/SupplierMapper.php | 13 ++++--- src/Mappers/TransactionMapper.php | 6 +-- src/Mappers/UserMapper.php | 7 ++-- 15 files changed, 124 insertions(+), 92 deletions(-) create mode 100644 src/HasMessageInterface.php diff --git a/src/BaseObject.php b/src/BaseObject.php index d7db7e72..4c71e555 100644 --- a/src/BaseObject.php +++ b/src/BaseObject.php @@ -9,7 +9,7 @@ * * @author Jop peters */ -abstract class BaseObject +abstract class BaseObject implements HasMessageInterface { private $result; private $messages; diff --git a/src/HasMessageInterface.php b/src/HasMessageInterface.php new file mode 100644 index 00000000..06a00241 --- /dev/null +++ b/src/HasMessageInterface.php @@ -0,0 +1,20 @@ +setBehaviour(self::parseEnumAttribute(\PhpTwinfield\Enums\Behaviour::class, self::getField($activityElement, 'behaviour', $activity))) ->setCode(self::getField($activityElement, 'code', $activity)) - ->setInUse(self::parseBooleanAttribute(self::getField($activityElement, 'name', $activity))) + ->setInUse(Util::parseBoolean(self::getField($activityElement, 'name', $activity))) ->setName(self::getField($activityElement, 'name', $activity)) ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $activity, $activityElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setShortName(self::getField($activityElement, 'shortname', $activity)) @@ -61,7 +62,7 @@ public static function map(Response $response) // Set the projects elements from the projects element $activityProjects->setAuthoriser(self::parseObjectAttribute(\PhpTwinfield\User::class, $activityProjects, $projectsElement, 'authoriser')) - ->setBillable(self::parseBooleanAttribute(self::getField($projectsElement, 'billable', $activityProjects))) + ->setBillable(Util::parseBoolean(self::getField($projectsElement, 'billable', $activityProjects))) ->setCustomer(self::parseObjectAttribute(\PhpTwinfield\Customer::class, $activityProjects, $projectsElement, 'customer')) ->setInvoiceDescription(self::getField($projectsElement, 'invoicedescription', $activityProjects)) ->setRate(self::parseObjectAttribute(\PhpTwinfield\Rate::class, $activityProjects, $projectsElement, 'rate')) @@ -69,15 +70,15 @@ public static function map(Response $response) ->setValidTill(self::parseDateAttribute(self::getField($projectsElement, 'validtill', $activityProjects))); // Set the projects elements from the projects element attributes - $activityProjects->setAuthoriserInherit(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'authoriser', 'inherit'))) - ->setAuthoriserLocked(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'authoriser', 'locked'))) - ->setBillableForRatio(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'billable', 'forratio'))) - ->setBillableInherit(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'billable', 'inherit'))) - ->setBillableLocked(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'billable', 'locked'))) - ->setCustomerInherit(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'customer', 'inherit'))) - ->setCustomerLocked(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'customer', 'locked'))) - ->setRateInherit(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'rate', 'inherit'))) - ->setRateLocked(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'rate', 'locked'))); + $activityProjects->setAuthoriserInherit(Util::parseBoolean(self::getAttribute($projectsElement, 'authoriser', 'inherit'))) + ->setAuthoriserLocked(Util::parseBoolean(self::getAttribute($projectsElement, 'authoriser', 'locked'))) + ->setBillableForRatio(Util::parseBoolean(self::getAttribute($projectsElement, 'billable', 'forratio'))) + ->setBillableInherit(Util::parseBoolean(self::getAttribute($projectsElement, 'billable', 'inherit'))) + ->setBillableLocked(Util::parseBoolean(self::getAttribute($projectsElement, 'billable', 'locked'))) + ->setCustomerInherit(Util::parseBoolean(self::getAttribute($projectsElement, 'customer', 'inherit'))) + ->setCustomerLocked(Util::parseBoolean(self::getAttribute($projectsElement, 'customer', 'locked'))) + ->setRateInherit(Util::parseBoolean(self::getAttribute($projectsElement, 'rate', 'inherit'))) + ->setRateLocked(Util::parseBoolean(self::getAttribute($projectsElement, 'rate', 'locked'))); // Get the quantities element $quantitiesDOMTag = $projectsElement->getElementsByTagName('quantities'); @@ -93,13 +94,13 @@ public static function map(Response $response) $activityQuantity = new ActivityQuantity(); // Set the quantity elements from the quantity element - $activityQuantity->setBillable(self::parseBooleanAttribute(self::getField($quantityElement, 'billable', $activityQuantity))) + $activityQuantity->setBillable(Util::parseBoolean(self::getField($quantityElement, 'billable', $activityQuantity))) ->setLabel(self::getField($quantityElement, 'label', $activityQuantity)) - ->setMandatory(self::parseBooleanAttribute(self::getField($quantityElement, 'mandatory', $activityQuantity))) + ->setMandatory(Util::parseBoolean(self::getField($quantityElement, 'mandatory', $activityQuantity))) ->setRate(self::parseObjectAttribute(\PhpTwinfield\Rate::class, $activityQuantity, $quantityElement, 'rate')); // Set the quantity elements from the quantity element attributes - $activityQuantity->setBillableLocked(self::parseBooleanAttribute(self::getAttribute($quantityElement, 'billable', 'locked'))); + $activityQuantity->setBillableLocked(Util::parseBoolean(self::getAttribute($quantityElement, 'billable', 'locked'))); // Add the quantity to the project $activityProjects->addQuantity($activityQuantity); diff --git a/src/Mappers/ArticleMapper.php b/src/Mappers/ArticleMapper.php index 65f4a37e..4586c1e4 100644 --- a/src/Mappers/ArticleMapper.php +++ b/src/Mappers/ArticleMapper.php @@ -4,6 +4,7 @@ use PhpTwinfield\Article; use PhpTwinfield\ArticleLine; use PhpTwinfield\Response\Response; +use PhpTwinfield\Util; /** * Maps a response DOMDocument to the corresponding entity. @@ -45,15 +46,15 @@ public static function map(Response $response) $article->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $headerElement->getAttribute('status'))); // Set the article elements from the header - $article->setAllowChangePerformanceType(self::parseBooleanAttribute(self::getField($headerElement, 'allowchangeperformancetype', $article))) - ->setAllowChangeUnitsPrice(self::parseBooleanAttribute(self::getField($headerElement, 'allowchangeunitsprice', $article))) - ->setAllowChangeVatCode(self::parseBooleanAttribute(self::getField($headerElement, 'allowchangevatcode', $article))) - ->setAllowDecimalQuantity(self::parseBooleanAttribute(self::getField($headerElement, 'allowdecimalquantity', $article))) - ->setAllowDiscountOrPremium(self::parseBooleanAttribute(self::getField($headerElement, 'allowdiscountorpremium', $article))) + $article->setAllowChangePerformanceType(Util::parseBoolean(self::getField($headerElement, 'allowchangeperformancetype', $article))) + ->setAllowChangeUnitsPrice(Util::parseBoolean(self::getField($headerElement, 'allowchangeunitsprice', $article))) + ->setAllowChangeVatCode(Util::parseBoolean(self::getField($headerElement, 'allowchangevatcode', $article))) + ->setAllowDecimalQuantity(Util::parseBoolean(self::getField($headerElement, 'allowdecimalquantity', $article))) + ->setAllowDiscountOrPremium(Util::parseBoolean(self::getField($headerElement, 'allowdiscountorpremium', $article))) ->setCode(self::getField($headerElement, 'code', $article)) ->setName(self::getField($headerElement, 'name', $article)) ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $article, $headerElement, 'office')) - ->setPercentage(self::parseBooleanAttribute(self::getField($headerElement, 'percentage', $article))) + ->setPercentage(Util::parseBoolean(self::getField($headerElement, 'percentage', $article))) ->setPerformanceType(self::parseEnumAttribute(\PhpTwinfield\Enums\PerformanceType::class, self::getField($headerElement, 'performancetype', $article))) ->setShortName(self::getField($headerElement, 'shortname', $article)) ->setType(self::parseEnumAttribute(\PhpTwinfield\Enums\ArticleType::class, self::getField($headerElement, 'type', $article))) diff --git a/src/Mappers/AssetMethodMapper.php b/src/Mappers/AssetMethodMapper.php index 3981a623..445c7380 100644 --- a/src/Mappers/AssetMethodMapper.php +++ b/src/Mappers/AssetMethodMapper.php @@ -6,6 +6,7 @@ use PhpTwinfield\AssetMethodFreeText; use PhpTwinfield\AssetMethodProfitLossAccounts; use PhpTwinfield\Response\Response; +use PhpTwinfield\Util; /** * Maps a response DOMDocument to the corresponding entity. @@ -38,7 +39,7 @@ public static function map(Response $response) $assetmethodElement = $responseDOM->documentElement; // Set the inuse, result and status attribute - $assetmethod->setInUse(self::parseBooleanAttribute($assetmethodElement->getAttribute('inuse'))) + $assetmethod->setInUse(Util::parseBoolean($assetmethodElement->getAttribute('inuse'))) ->setResult($assetmethodElement->getAttribute('result')) ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $assetmethodElement->getAttribute('status'))); diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index 2de5a3f1..16f9a42b 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -4,13 +4,14 @@ use Money\Currency; use Money\Money; +use PhpTwinfield\HasMessageInterface; use PhpTwinfield\Message\Message; use PhpTwinfield\Util; use Webmozart\Assert\Assert; abstract class BaseMapper { - protected static function checkForMessage($object, \DOMElement $element): void + protected static function checkForMessage(HasMessageInterface $object, \DOMElement $element): void { if ($element->hasAttribute('msg')) { $message = new Message(); diff --git a/src/Mappers/CostCenterMapper.php b/src/Mappers/CostCenterMapper.php index 1d4905f1..2ec2f81f 100644 --- a/src/Mappers/CostCenterMapper.php +++ b/src/Mappers/CostCenterMapper.php @@ -3,6 +3,7 @@ use PhpTwinfield\CostCenter; use PhpTwinfield\Response\Response; +use PhpTwinfield\Util; /** * Maps a response DOMDocument to the corresponding entity. @@ -41,7 +42,7 @@ public static function map(Response $response) // Set the cost center elements from the cost center element $costCenter->setBehaviour(self::parseEnumAttribute(\PhpTwinfield\Enums\Behaviour::class, self::getField($costCenterElement, 'behaviour', $costCenter))) ->setCode(self::getField($costCenterElement, 'code', $costCenter)) - ->setInUse(self::parseBooleanAttribute(self::getField($costCenterElement, 'name', $costCenter))) + ->setInUse(Util::parseBoolean(self::getField($costCenterElement, 'name', $costCenter))) ->setName(self::getField($costCenterElement, 'name', $costCenter)) ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $costCenter, $costCenterElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setTouched(self::getField($costCenterElement, 'touched', $costCenter)) diff --git a/src/Mappers/CustomerMapper.php b/src/Mappers/CustomerMapper.php index fdedf4e0..237869f0 100644 --- a/src/Mappers/CustomerMapper.php +++ b/src/Mappers/CustomerMapper.php @@ -11,6 +11,7 @@ use PhpTwinfield\CustomerLine; use PhpTwinfield\CustomerPostingRule; use PhpTwinfield\Response\Response; +use PhpTwinfield\Util; /** * Maps a response DOMDocument to the corresponding entity. @@ -54,7 +55,7 @@ public static function map(Response $response) ->setEndPeriod(self::getField($customerElement, 'endperiod', $customer)) ->setEndYear(self::getField($customerElement, 'endyear', $customer)) ->setGroup(self::parseObjectAttribute(\PhpTwinfield\DimensionGroup::class, $customer, $customerElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setInUse(self::parseBooleanAttribute(self::getField($customerElement, 'name', $customer))) + ->setInUse(Util::parseBoolean(self::getField($customerElement, 'name', $customer))) ->setName(self::getField($customerElement, 'name', $customer)) ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $customer, $customerElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setTouched(self::getField($customerElement, 'touched', $customer)) @@ -76,12 +77,12 @@ public static function map(Response $response) $customerFinancials->setAccountType(self::parseEnumAttribute(\PhpTwinfield\Enums\AccountType::class, self::getField($financialsElement, 'accounttype', $customerFinancials))) ->setCollectionSchema(self::parseEnumAttribute(\PhpTwinfield\Enums\CollectionSchema::class, self::getField($financialsElement, 'collectionschema', $customerFinancials))) ->setDueDays(self::getField($financialsElement, 'duedays', $customerFinancials)) - ->setEBilling(self::parseBooleanAttribute(self::getField($financialsElement, 'ebilling', $customerFinancials))) + ->setEBilling(Util::parseBoolean(self::getField($financialsElement, 'ebilling', $customerFinancials))) ->setEBillMail(self::getField($financialsElement, 'ebillmail', $customerFinancials)) ->setLevel(self::getField($financialsElement, 'level', $customerFinancials)) ->setMatchType(self::parseEnumAttribute(\PhpTwinfield\Enums\MatchType::class, self::getField($financialsElement, 'matchtype', $customerFinancials))) ->setMeansOfPayment(self::parseEnumAttribute(\PhpTwinfield\Enums\MeansOfPayment::class, self::getField($financialsElement, 'meansofpayment', $customerFinancials))) - ->setPayAvailable(self::parseBooleanAttribute(self::getField($financialsElement, 'payavailable', $customerFinancials))) + ->setPayAvailable(Util::parseBoolean(self::getField($financialsElement, 'payavailable', $customerFinancials))) ->setPayCode(self::parseObjectAttribute(\PhpTwinfield\PayCode::class, $customerFinancials, $financialsElement, 'paycode', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setSubAnalyse(self::parseEnumAttribute(\PhpTwinfield\Enums\SubAnalyse::class, self::getField($financialsElement, 'subanalyse', $customerFinancials))) ->setSubstitutionLevel(self::getField($financialsElement, 'substitutionlevel', $customerFinancials)) @@ -91,7 +92,7 @@ public static function map(Response $response) // Set the financials elements from the financials element attributes $customerFinancials->setPayCodeID(self::getAttribute($financialsElement, 'paycode', 'id')) ->setSubstituteWithID(self::getAttribute($financialsElement, 'substitutewith', 'id')) - ->setVatCodeFixed(self::parseBooleanAttribute(self::getAttribute($financialsElement, 'vatcode', 'fixed'))); + ->setVatCodeFixed(Util::parseBoolean(self::getAttribute($financialsElement, 'vatcode', 'fixed'))); // Get the collectmandate element $collectMandateElement = $financialsElement->getElementsByTagName('collectmandate')->item(0); @@ -151,9 +152,9 @@ public static function map(Response $response) // Set the customer credit management elements from the creditmanagement element $customerCreditManagement->setBaseCreditLimit(self::parseMoneyAttribute(self::getField($creditManagementElement, 'basecreditlimit', $customerCreditManagement))) - ->setBlocked(self::parseBooleanAttribute(self::getField($creditManagementElement, 'blocked', $customerCreditManagement))) + ->setBlocked(Util::parseBoolean(self::getField($creditManagementElement, 'blocked', $customerCreditManagement))) ->setComment(self::getField($creditManagementElement, 'comment', $customerCreditManagement)) - ->setFreeText1(self::parseBooleanAttribute(self::getField($creditManagementElement, 'freetext1', $customerCreditManagement))) + ->setFreeText1(Util::parseBoolean(self::getField($creditManagementElement, 'freetext1', $customerCreditManagement))) ->setFreeText2(self::getField($creditManagementElement, 'freetext2', $customerCreditManagement)) ->setFreeText3(self::getField($creditManagementElement, 'freetext3', $customerCreditManagement)) ->setReminderEmail(self::getField($creditManagementElement, 'reminderemail', $customerCreditManagement)) @@ -161,7 +162,7 @@ public static function map(Response $response) ->setSendReminder(self::parseEnumAttribute(\PhpTwinfield\Enums\SendReminder::class, self::getField($creditManagementElement, 'sendreminder', $customerCreditManagement))); // Set the customer credit management elements from the creditmanagement element attributes - $customerCreditManagement->setBlockedLocked(self::parseBooleanAttribute(self::getAttribute($creditManagementElement, 'blocked', 'locked'))) + $customerCreditManagement->setBlockedLocked(Util::parseBoolean(self::getAttribute($creditManagementElement, 'blocked', 'locked'))) ->setBlockedModified(self::parseDateTimeAttribute(self::getAttribute($creditManagementElement, 'blocked', 'modified'))); // Set the custom class to the customer @@ -191,7 +192,7 @@ public static function map(Response $response) $customerAddress = new CustomerAddress(); // Set the default, id and type attribute - $customerAddress->setDefault(self::parseBooleanAttribute($addressElement->getAttribute('default'))) + $customerAddress->setDefault(Util::parseBoolean($addressElement->getAttribute('default'))) ->setID($addressElement->getAttribute('id')) ->setType(self::parseEnumAttribute(\PhpTwinfield\Enums\AddressType::class, $addressElement->getAttribute('type'))); @@ -232,8 +233,8 @@ public static function map(Response $response) $customerBank = new CustomerBank(); // Set the default and id attribute - $customerBank->setBlocked(self::parseBooleanAttribute($bankElement->getAttribute('blocked'))) - ->setDefault(self::parseBooleanAttribute($bankElement->getAttribute('default'))) + $customerBank->setBlocked(Util::parseBoolean($bankElement->getAttribute('blocked'))) + ->setDefault(Util::parseBoolean($bankElement->getAttribute('default'))) ->setID($bankElement->getAttribute('id')); // Set the bank elements from the bank element diff --git a/src/Mappers/FixedAssetMapper.php b/src/Mappers/FixedAssetMapper.php index 34034aea..8a2ae839 100644 --- a/src/Mappers/FixedAssetMapper.php +++ b/src/Mappers/FixedAssetMapper.php @@ -6,6 +6,7 @@ use PhpTwinfield\FixedAssetFixedAssets; use PhpTwinfield\FixedAssetTransactionLine; use PhpTwinfield\Response\Response; +use PhpTwinfield\Util; /** * Maps a response DOMDocument to the corresponding entity. @@ -44,7 +45,7 @@ public static function map(Response $response) $fixedAsset->setBehaviour(self::parseEnumAttribute(\PhpTwinfield\Enums\Behaviour::class, self::getField($fixedAssetElement, 'behaviour', $fixedAsset))) ->setCode(self::getField($fixedAssetElement, 'code', $fixedAsset)) ->setGroup(self::parseObjectAttribute(\PhpTwinfield\DimensionGroup::class, $fixedAsset, $fixedAssetElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setInUse(self::parseBooleanAttribute(self::getField($fixedAssetElement, 'name', $fixedAsset))) + ->setInUse(Util::parseBoolean(self::getField($fixedAssetElement, 'name', $fixedAsset))) ->setName(self::getField($fixedAssetElement, 'name', $fixedAsset)) ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $fixedAsset, $fixedAssetElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setTouched(self::getField($fixedAssetElement, 'touched', $fixedAsset)) @@ -69,7 +70,7 @@ public static function map(Response $response) // Set the financials elements from the financials element attributes $fixedAssetFinancials->setSubstituteWithID(self::getAttribute($financialsElement, 'substitutewith', 'id')); - $fixedAssetFinancials->setVatCodeFixed(self::parseBooleanAttribute(self::getAttribute($financialsElement, 'vatcode', 'fixed'))); + $fixedAssetFinancials->setVatCodeFixed(Util::parseBoolean(self::getAttribute($financialsElement, 'vatcode', 'fixed'))); // Set the custom class to the fixedAsset $fixedAsset->setFinancials($fixedAssetFinancials); @@ -100,22 +101,22 @@ public static function map(Response $response) ->setStopValue(self::parseMoneyAttribute(self::getField($fixedAssetsElement, 'stopvalue', $fixedAssetFixedAssets))); // Set the fixed assets elements from the fixed assets element attributes - $fixedAssetFixedAssets->setBeginPeriodLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'beginperiod', 'locked'))) - ->setMethodLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'method', 'locked'))) - ->setStatusLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'status', 'locked'))) - ->setFreeText1Locked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'freetext1', 'locked'))) - ->setFreeText2Locked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'freetext2', 'locked'))) - ->setFreeText3Locked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'freetext3', 'locked'))) - ->setFreeText4Locked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'freetext4', 'locked'))) - ->setFreeText5Locked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'freetext5', 'locked'))) - ->setLastDepreciationLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'lastdepreciation', 'locked'))) - ->setNrOfPeriodsInherited(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'nrofperiods', 'inherited'))) - ->setNrOfPeriodsLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'nrofperiods', 'locked'))) - ->setPercentageLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'percentage', 'locked'))) - ->setPurchaseDateLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'purchasedate', 'locked'))) - ->setResidualValueLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'residualvalue', 'locked'))) - ->setSellDateLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'selldate', 'locked'))) - ->setStopValueLocked(self::parseBooleanAttribute(self::getAttribute($fixedAssetsElement, 'stopvalue', 'locked'))); + $fixedAssetFixedAssets->setBeginPeriodLocked(Util::parseBoolean(self::getAttribute($fixedAssetsElement, 'beginperiod', 'locked'))) + ->setMethodLocked(Util::parseBoolean(self::getAttribute($fixedAssetsElement, 'method', 'locked'))) + ->setStatusLocked(Util::parseBoolean(self::getAttribute($fixedAssetsElement, 'status', 'locked'))) + ->setFreeText1Locked(Util::parseBoolean(self::getAttribute($fixedAssetsElement, 'freetext1', 'locked'))) + ->setFreeText2Locked(Util::parseBoolean(self::getAttribute($fixedAssetsElement, 'freetext2', 'locked'))) + ->setFreeText3Locked(Util::parseBoolean(self::getAttribute($fixedAssetsElement, 'freetext3', 'locked'))) + ->setFreeText4Locked(Util::parseBoolean(self::getAttribute($fixedAssetsElement, 'freetext4', 'locked'))) + ->setFreeText5Locked(Util::parseBoolean(self::getAttribute($fixedAssetsElement, 'freetext5', 'locked'))) + ->setLastDepreciationLocked(Util::parseBoolean(self::getAttribute($fixedAssetsElement, 'lastdepreciation', 'locked'))) + ->setNrOfPeriodsInherited(Util::parseBoolean(self::getAttribute($fixedAssetsElement, 'nrofperiods', 'inherited'))) + ->setNrOfPeriodsLocked(Util::parseBoolean(self::getAttribute($fixedAssetsElement, 'nrofperiods', 'locked'))) + ->setPercentageLocked(Util::parseBoolean(self::getAttribute($fixedAssetsElement, 'percentage', 'locked'))) + ->setPurchaseDateLocked(Util::parseBoolean(self::getAttribute($fixedAssetsElement, 'purchasedate', 'locked'))) + ->setResidualValueLocked(Util::parseBoolean(self::getAttribute($fixedAssetsElement, 'residualvalue', 'locked'))) + ->setSellDateLocked(Util::parseBoolean(self::getAttribute($fixedAssetsElement, 'selldate', 'locked'))) + ->setStopValueLocked(Util::parseBoolean(self::getAttribute($fixedAssetsElement, 'stopvalue', 'locked'))); // Get the translines element $transactionLinesDOMTag = $fixedAssetsElement->getElementsByTagName('translines'); @@ -144,17 +145,17 @@ public static function map(Response $response) ->setPeriod(self::getField($transactionLineElement, 'period', $fixedAssetTransactionLine)); // Set the fixed assets transaction line elements from the fixed assets transline attributes - $fixedAssetTransactionLine->setAmountLocked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'amount', 'locked'))) - ->setCodeLocked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'code', 'locked'))) - ->setDim1Locked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'dim1', 'locked'))) - ->setDim2Locked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'dim2', 'locked'))) - ->setDim3Locked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'dim3', 'locked'))) - ->setDim4Locked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'dim4', 'locked'))) - ->setDim5Locked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'dim5', 'locked'))) - ->setDim6Locked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'dim6', 'locked'))) - ->setLineLocked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'line', 'locked'))) - ->setNumberLocked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'number', 'locked'))) - ->setPeriodLocked(self::parseBooleanAttribute(self::getAttribute($transactionLineElement, 'period', 'locked'))); + $fixedAssetTransactionLine->setAmountLocked(Util::parseBoolean(self::getAttribute($transactionLineElement, 'amount', 'locked'))) + ->setCodeLocked(Util::parseBoolean(self::getAttribute($transactionLineElement, 'code', 'locked'))) + ->setDim1Locked(Util::parseBoolean(self::getAttribute($transactionLineElement, 'dim1', 'locked'))) + ->setDim2Locked(Util::parseBoolean(self::getAttribute($transactionLineElement, 'dim2', 'locked'))) + ->setDim3Locked(Util::parseBoolean(self::getAttribute($transactionLineElement, 'dim3', 'locked'))) + ->setDim4Locked(Util::parseBoolean(self::getAttribute($transactionLineElement, 'dim4', 'locked'))) + ->setDim5Locked(Util::parseBoolean(self::getAttribute($transactionLineElement, 'dim5', 'locked'))) + ->setDim6Locked(Util::parseBoolean(self::getAttribute($transactionLineElement, 'dim6', 'locked'))) + ->setLineLocked(Util::parseBoolean(self::getAttribute($transactionLineElement, 'line', 'locked'))) + ->setNumberLocked(Util::parseBoolean(self::getAttribute($transactionLineElement, 'number', 'locked'))) + ->setPeriodLocked(Util::parseBoolean(self::getAttribute($transactionLineElement, 'period', 'locked'))); // Add the transactionLine to the fixedAsset $fixedAssetFixedAssets->addTransactionLine($fixedAssetTransactionLine); diff --git a/src/Mappers/GeneralLedgerMapper.php b/src/Mappers/GeneralLedgerMapper.php index d9bcf009..62a0a78e 100644 --- a/src/Mappers/GeneralLedgerMapper.php +++ b/src/Mappers/GeneralLedgerMapper.php @@ -5,6 +5,7 @@ use PhpTwinfield\GeneralLedgerChildValidation; use PhpTwinfield\GeneralLedgerFinancials; use PhpTwinfield\Response\Response; +use PhpTwinfield\Util; /** * Maps a response DOMDocument to the corresponding entity. @@ -48,7 +49,7 @@ public static function map(Response $response) ->setEndPeriod(self::getField($generalLedgerElement, 'endperiod', $generalLedger)) ->setEndYear(self::getField($generalLedgerElement, 'endyear', $generalLedger)) ->setGroup(self::parseObjectAttribute(\PhpTwinfield\DimensionGroup::class, $generalLedger, $generalLedgerElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setInUse(self::parseBooleanAttribute(self::getField($generalLedgerElement, 'inuse', $generalLedger))) + ->setInUse(Util::parseBoolean(self::getField($generalLedgerElement, 'inuse', $generalLedger))) ->setName(self::getField($generalLedgerElement, 'name', $generalLedger)) ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $generalLedger, $generalLedgerElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setShortName(self::getField($generalLedgerElement, 'shortname', $generalLedger)) @@ -71,7 +72,7 @@ public static function map(Response $response) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $generalLedgerFinancials, $financialsElement, 'vatcode')); // Set the financials elements from the financials element attributes - $generalLedgerFinancials->setVatCodeFixed(self::parseBooleanAttribute(self::getAttribute($financialsElement, 'vatcode', 'fixed'))); + $generalLedgerFinancials->setVatCodeFixed(Util::parseBoolean(self::getAttribute($financialsElement, 'vatcode', 'fixed'))); // Get the childvalidations element $childValidationsDOMTag = $financialsElement->getElementsByTagName('childvalidations'); diff --git a/src/Mappers/InvoiceMapper.php b/src/Mappers/InvoiceMapper.php index ec8060ae..a592fbfd 100644 --- a/src/Mappers/InvoiceMapper.php +++ b/src/Mappers/InvoiceMapper.php @@ -6,6 +6,7 @@ use PhpTwinfield\InvoiceTotals; use PhpTwinfield\InvoiceVatLine; use PhpTwinfield\Response\Response; +use PhpTwinfield\Util; /** * Maps a response DOMDocument to the corresponding entity. @@ -90,7 +91,7 @@ public static function map(Response $response) $invoiceLine->setID($lineElement->getAttribute('id')); // Set the invoice line elements from the line element - $invoiceLine->setAllowDiscountOrPremium(self::parseBooleanAttribute(self::getField($lineElement, 'allowdiscountorpremium', $invoiceLine))) + $invoiceLine->setAllowDiscountOrPremium(Util::parseBoolean(self::getField($lineElement, 'allowdiscountorpremium', $invoiceLine))) ->setArticle(self::parseObjectAttribute(\PhpTwinfield\Article::class, $invoiceLine, $lineElement, 'article')) ->setDescription(self::getField($lineElement, 'description', $invoiceLine)) ->setDim1(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $invoiceLine, $lineElement, 'dim1')) diff --git a/src/Mappers/ProjectMapper.php b/src/Mappers/ProjectMapper.php index e6636d71..06f2bf8a 100644 --- a/src/Mappers/ProjectMapper.php +++ b/src/Mappers/ProjectMapper.php @@ -5,6 +5,7 @@ use PhpTwinfield\ProjectProjects; use PhpTwinfield\ProjectQuantity; use PhpTwinfield\Response\Response; +use PhpTwinfield\Util; /** * Maps a response DOMDocument to the corresponding entity. @@ -43,7 +44,7 @@ public static function map(Response $response) // Set the project elements from the project element $project->setBehaviour(self::parseEnumAttribute(\PhpTwinfield\Enums\Behaviour::class, self::getField($projectElement, 'behaviour', $project))) ->setCode(self::getField($projectElement, 'code', $project)) - ->setInUse(self::parseBooleanAttribute(self::getField($projectElement, 'name', $project))) + ->setInUse(Util::parseBoolean(self::getField($projectElement, 'name', $project))) ->setName(self::getField($projectElement, 'name', $project)) ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $project, $projectElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setShortName(self::getField($projectElement, 'shortname', $project)) @@ -61,7 +62,7 @@ public static function map(Response $response) // Set the projects elements from the projects element $projectProjects->setAuthoriser(self::parseObjectAttribute(\PhpTwinfield\User::class, $projectProjects, $projectsElement, 'authoriser')) - ->setBillable(self::parseBooleanAttribute(self::getField($projectsElement, 'billable', $projectProjects))) + ->setBillable(Util::parseBoolean(self::getField($projectsElement, 'billable', $projectProjects))) ->setCustomer(self::parseObjectAttribute(\PhpTwinfield\Customer::class, $projectProjects, $projectsElement, 'customer')) ->setInvoiceDescription(self::getField($projectsElement, 'invoicedescription', $projectProjects)) ->setRate(self::parseObjectAttribute(\PhpTwinfield\Rate::class, $projectProjects, $projectsElement, 'rate')) @@ -69,15 +70,15 @@ public static function map(Response $response) ->setValidTill(self::parseDateAttribute(self::getField($projectsElement, 'validtill', $projectProjects))); // Set the projects elements from the projects element attributes - $projectProjects->setAuthoriserInherit(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'authoriser', 'inherit'))) - ->setAuthoriserLocked(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'authoriser', 'locked'))) - ->setBillableForRatio(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'billable', 'forratio'))) - ->setBillableInherit(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'billable', 'inherit'))) - ->setBillableLocked(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'billable', 'locked'))) - ->setCustomerInherit(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'customer', 'inherit'))) - ->setCustomerLocked(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'customer', 'locked'))) - ->setRateInherit(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'rate', 'inherit'))) - ->setRateLocked(self::parseBooleanAttribute(self::getAttribute($projectsElement, 'rate', 'locked'))); + $projectProjects->setAuthoriserInherit(Util::parseBoolean(self::getAttribute($projectsElement, 'authoriser', 'inherit'))) + ->setAuthoriserLocked(Util::parseBoolean(self::getAttribute($projectsElement, 'authoriser', 'locked'))) + ->setBillableForRatio(Util::parseBoolean(self::getAttribute($projectsElement, 'billable', 'forratio'))) + ->setBillableInherit(Util::parseBoolean(self::getAttribute($projectsElement, 'billable', 'inherit'))) + ->setBillableLocked(Util::parseBoolean(self::getAttribute($projectsElement, 'billable', 'locked'))) + ->setCustomerInherit(Util::parseBoolean(self::getAttribute($projectsElement, 'customer', 'inherit'))) + ->setCustomerLocked(Util::parseBoolean(self::getAttribute($projectsElement, 'customer', 'locked'))) + ->setRateInherit(Util::parseBoolean(self::getAttribute($projectsElement, 'rate', 'inherit'))) + ->setRateLocked(Util::parseBoolean(self::getAttribute($projectsElement, 'rate', 'locked'))); // Get the quantities element $quantitiesDOMTag = $projectsElement->getElementsByTagName('quantities'); @@ -93,13 +94,13 @@ public static function map(Response $response) $projectQuantity = new ProjectQuantity(); // Set the quantity elements from the quantity element - $projectQuantity->setBillable(self::parseBooleanAttribute(self::getField($quantityElement, 'billable', $projectQuantity))) + $projectQuantity->setBillable(Util::parseBoolean(self::getField($quantityElement, 'billable', $projectQuantity))) ->setLabel(self::getField($quantityElement, 'label', $projectQuantity)) - ->setMandatory(self::parseBooleanAttribute(self::getField($quantityElement, 'mandatory', $projectQuantity))) + ->setMandatory(Util::parseBoolean(self::getField($quantityElement, 'mandatory', $projectQuantity))) ->setRate(self::parseObjectAttribute(\PhpTwinfield\Rate::class, $projectQuantity, $quantityElement, 'rate')); // Set the quantity elements from the quantity element attributes - $projectQuantity->setBillableLocked(self::parseBooleanAttribute(self::getAttribute($quantityElement, 'billable', 'locked'))); + $projectQuantity->setBillableLocked(Util::parseBoolean(self::getAttribute($quantityElement, 'billable', 'locked'))); // Add the quantity to the project $projectProjects->addQuantity($projectQuantity); diff --git a/src/Mappers/SupplierMapper.php b/src/Mappers/SupplierMapper.php index c8c269cb..84f24e8f 100644 --- a/src/Mappers/SupplierMapper.php +++ b/src/Mappers/SupplierMapper.php @@ -9,6 +9,7 @@ use PhpTwinfield\SupplierFinancials; use PhpTwinfield\SupplierLine; use PhpTwinfield\SupplierPostingRule; +use PhpTwinfield\Util; /** * Maps a response DOMDocument to the corresponding entity. @@ -51,7 +52,7 @@ public static function map(Response $response) ->setEndPeriod(self::getField($supplierElement, 'endperiod', $supplier)) ->setEndYear(self::getField($supplierElement, 'endyear', $supplier)) ->setGroup(self::parseObjectAttribute(\PhpTwinfield\DimensionGroup::class, $supplier, $supplierElement, 'group', array('name' => 'setName', 'shortname' => 'setShortName'))) - ->setInUse(self::parseBooleanAttribute(self::getField($supplierElement, 'name', $supplier))) + ->setInUse(Util::parseBoolean(self::getField($supplierElement, 'name', $supplier))) ->setName(self::getField($supplierElement, 'name', $supplier)) ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $supplier, $supplierElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setTouched(self::getField($supplierElement, 'touched', $supplier)) @@ -72,7 +73,7 @@ public static function map(Response $response) ->setLevel(self::getField($financialsElement, 'level', $supplierFinancials)) ->setMatchType(self::parseEnumAttribute(\PhpTwinfield\Enums\MatchType::class, self::getField($financialsElement, 'matchtype', $supplierFinancials))) ->setMeansOfPayment(self::parseEnumAttribute(\PhpTwinfield\Enums\MeansOfPayment::class, self::getField($financialsElement, 'meansofpayment', $supplierFinancials))) - ->setPayAvailable(self::parseBooleanAttribute(self::getField($financialsElement, 'payavailable', $supplierFinancials))) + ->setPayAvailable(Util::parseBoolean(self::getField($financialsElement, 'payavailable', $supplierFinancials))) ->setPayCode(self::parseObjectAttribute(\PhpTwinfield\PayCode::class, $supplierFinancials, $financialsElement, 'paycode', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setRelationsReference(self::getField($financialsElement, 'relationsreference', $supplierFinancials)) ->setSubAnalyse(self::parseEnumAttribute(\PhpTwinfield\Enums\SubAnalyse::class, self::getField($financialsElement, 'subanalyse', $supplierFinancials))) @@ -83,7 +84,7 @@ public static function map(Response $response) // Set the financials elements from the financials element attributes $supplierFinancials->setPayCodeID(self::getAttribute($financialsElement, 'paycode', 'id')) ->setSubstituteWithID(self::getAttribute($financialsElement, 'substitutewith', 'id')) - ->setVatCodeFixed(self::parseBooleanAttribute(self::getAttribute($financialsElement, 'vatcode', 'fixed'))); + ->setVatCodeFixed(Util::parseBoolean(self::getAttribute($financialsElement, 'vatcode', 'fixed'))); // Get the childvalidations element $childValidationsDOMTag = $financialsElement->getElementsByTagName('childvalidations'); @@ -138,7 +139,7 @@ public static function map(Response $response) $supplierAddress = new SupplierAddress(); // Set the default, id and type attribute - $supplierAddress->setDefault(self::parseBooleanAttribute($addressElement->getAttribute('default'))) + $supplierAddress->setDefault(Util::parseBoolean($addressElement->getAttribute('default'))) ->setID($addressElement->getAttribute('id')) ->setType(self::parseEnumAttribute(\PhpTwinfield\Enums\AddressType::class, $addressElement->getAttribute('type'))); @@ -179,8 +180,8 @@ public static function map(Response $response) $supplierBank = new SupplierBank(); // Set the default and id attribute - $supplierBank->setBlocked(self::parseBooleanAttribute($bankElement->getAttribute('blocked'))) - ->setDefault(self::parseBooleanAttribute($bankElement->getAttribute('default'))) + $supplierBank->setBlocked(Util::parseBoolean($bankElement->getAttribute('blocked'))) + ->setDefault(Util::parseBoolean($bankElement->getAttribute('default'))) ->setID($bankElement->getAttribute('id')); // Set the bank elements from the bank element diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 7b2fbc42..7ede2f09 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -66,7 +66,7 @@ public static function map(string $transactionClassName, Response $response): Ba $autoBalanceVat = $transactionElement->getAttribute('autobalancevat'); if (!empty($autoBalanceVat)) { - $transaction->setAutoBalanceVat(self::parseBooleanAttribute($autoBalanceVat)); + $transaction->setAutoBalanceVat(Util::parseBoolean($autoBalanceVat)); } $destiny = $transactionElement->getAttribute('location'); @@ -82,7 +82,7 @@ public static function map(string $transactionClassName, Response $response): Ba $raiseWarning = $transactionElement->getAttribute('raisewarning'); if (!empty($raiseWarning)) { - $transaction->setRaiseWarning(self::parseBooleanAttribute($raiseWarning)); + $transaction->setRaiseWarning(Util::parseBoolean($raiseWarning)); } $transaction->setCode(self::getField($transactionElement, 'code', $transaction)) @@ -106,7 +106,7 @@ public static function map(string $transactionClassName, Response $response): Ba if (Util::objectUses(InvoiceNumberField::class, $transaction)) { $transaction->setInvoiceNumber(self::getField($transactionElement, 'invoicenumber', $transaction)); - $transaction->setInvoiceNumberRaiseWarning(self::parseBooleanAttribute(self::getAttribute($transactionElement, 'invoicenumber', 'raisewarning'))); + $transaction->setInvoiceNumberRaiseWarning(Util::parseBoolean(self::getAttribute($transactionElement, 'invoicenumber', 'raisewarning'))); } if (Util::objectUses(OriginReferenceField::class, $transaction)) { diff --git a/src/Mappers/UserMapper.php b/src/Mappers/UserMapper.php index 199239e1..5e17a250 100644 --- a/src/Mappers/UserMapper.php +++ b/src/Mappers/UserMapper.php @@ -5,6 +5,7 @@ use PhpTwinfield\User; use PhpTwinfield\UserAccount; use PhpTwinfield\UserPercentage; +use PhpTwinfield\Util; /** * Maps a response DOMDocument to the corresponding entity. @@ -37,17 +38,17 @@ public static function map(Response $response) $userElement = $responseDOM->documentElement; // Set the iscurrentuser, level, result and status attribute - $user->setIsCurrentUser(self::parseBooleanAttribute($userElement->getAttribute('iscurrentuser'))); + $user->setIsCurrentUser(Util::parseBoolean($userElement->getAttribute('iscurrentuser'))); $user->setLevel($userElement->getAttribute('level')); $user->setResult($userElement->getAttribute('result')); $user->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $userElement->getAttribute('status'))); // Set the user elements from the user element - $user->setAcceptExtraCostField(self::parseBooleanAttribute(self::getField($userElement, 'acceptextracost', $user))) + $user->setAcceptExtraCostField(Util::parseBoolean(self::getField($userElement, 'acceptextracost', $user))) ->setCulture(self::getField($userElement, 'culture', $user)) ->setCode(self::getField($userElement, 'code', $user)) ->setCreated(self::parseDateTimeAttribute(self::getField($userElement, 'created', $user))) - ->setDemo(self::parseBooleanAttribute(self::getField($userElement, 'demo', $user))) + ->setDemo(Util::parseBoolean(self::getField($userElement, 'demo', $user))) ->setEmail(self::getField($userElement, 'email', $user)) ->setExchangeQuota(self::getField($userElement, 'exchangequota', $user)) ->setFileManagerQuota(self::getField($userElement, 'filemanagerquota', $user)) From fbe5d884bbe3c58a65e9c588dca7c5cb832627bd Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 11 Jun 2019 13:03:59 +0200 Subject: [PATCH 294/388] Upload --- src/HasMessageInterface.php | 2 +- src/Util.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/HasMessageInterface.php b/src/HasMessageInterface.php index 06a00241..4da62e58 100644 --- a/src/HasMessageInterface.php +++ b/src/HasMessageInterface.php @@ -16,5 +16,5 @@ interface HasMessageInterface /** * Adds an error message to an object */ - public function addMessage(Message $message): void + public function addMessage(Message $message): void; } \ No newline at end of file diff --git a/src/Util.php b/src/Util.php index 0af1dea9..44e2bca8 100644 --- a/src/Util.php +++ b/src/Util.php @@ -95,7 +95,7 @@ public static function formatBoolean(bool $boolean): string * @param string|null $input * @return bool */ - protected static function parseBoolean(?string $value): bool + public static function parseBoolean(?string $value): bool { return filter_var($value, FILTER_VALIDATE_BOOLEAN); } From 531bfa777822f286b606741a53f6f9df412863ec Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 11 Jun 2019 13:13:06 +0200 Subject: [PATCH 295/388] Update BaseObject.php --- src/BaseObject.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/BaseObject.php b/src/BaseObject.php index 4c71e555..424be098 100644 --- a/src/BaseObject.php +++ b/src/BaseObject.php @@ -31,12 +31,11 @@ public function getMessages() return $this->messages; } - public function addMessage(Message $message) + public function addMessage(Message $message): void { $this->messages[] = $message; - - return $this; } + public function setMessages($messages) { $this->messages = $messages; From 121cf6c62b1207f08d3c4f3e49d7ec4febac7006 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 11 Jun 2019 13:23:43 +0200 Subject: [PATCH 296/388] Update BaseMapper.php --- src/Mappers/BaseMapper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index 16f9a42b..16f547db 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -4,14 +4,14 @@ use Money\Currency; use Money\Money; -use PhpTwinfield\HasMessageInterface; +use PhpTwinfield\BaseObject; use PhpTwinfield\Message\Message; use PhpTwinfield\Util; use Webmozart\Assert\Assert; abstract class BaseMapper { - protected static function checkForMessage(HasMessageInterface $object, \DOMElement $element): void + protected static function checkForMessage(BaseObject $object, \DOMElement $element): void { if ($element->hasAttribute('msg')) { $message = new Message(); From f509f4fecacb1891ede38981213716ea30673595 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 11 Jun 2019 13:33:07 +0200 Subject: [PATCH 297/388] Upload --- src/ApiConnectors/BaseApiConnector.php | 9 ++++++--- src/BaseTransactionLine.php | 2 +- src/BrowseColumn.php | 2 +- src/BrowseData.php | 2 +- src/BrowseDataCell.php | 2 +- src/BrowseDataHeader.php | 2 +- src/BrowseDataRow.php | 2 +- src/BrowseDefinition.php | 2 +- src/BrowseField.php | 2 +- src/BrowseFieldOption.php | 2 +- src/BrowseSortField.php | 2 +- src/Mappers/BaseMapper.php | 4 ++-- 12 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/ApiConnectors/BaseApiConnector.php b/src/ApiConnectors/BaseApiConnector.php index b1b78db7..c007426a 100644 --- a/src/ApiConnectors/BaseApiConnector.php +++ b/src/ApiConnectors/BaseApiConnector.php @@ -206,13 +206,16 @@ public function convertOptionsToArrayOfString(array $options, array $forcedOptio /** * Map the response of a listAll to an array of the requested class * + * Is used by child ApiConnectors to map a $data object received by the FinderService to one or more new entities of $objectClass + * using the methods and attributes in $methodToAttributeMap. Returns an array of $objectClass objects + * * @param string $objectClass * @param $data - * @param array $objectListAllTags + * @param array $methodToAttributeMap * @return array * @throws Exception */ - public function mapListAll(string $objectClass, $data, array $objectListAllTags): array { + public function mapListAll(string $objectClass, $data, array $methodToAttributeMap): array { if ($data->TotalRows == 0) { return []; } @@ -228,7 +231,7 @@ public function mapListAll(string $objectClass, $data, array $objectListAllTags) $elementArray = $responseArrayElement; } - foreach ($objectListAllTags as $key => $method) { + foreach ($methodToAttributeMap as $key => $method) { $object->$method($elementArray[$key]); } diff --git a/src/BaseTransactionLine.php b/src/BaseTransactionLine.php index 8a1c73eb..f8dbcb6f 100644 --- a/src/BaseTransactionLine.php +++ b/src/BaseTransactionLine.php @@ -32,7 +32,7 @@ use PhpTwinfield\Fields\VatCodeField; use PhpTwinfield\Fields\VatValueField; -abstract class BaseTransactionLine implements TransactionLineInterface +abstract class BaseTransactionLine extends BaseObject implements TransactionLineInterface { use BaseValueField; use BaseValueOpenField; diff --git a/src/BrowseColumn.php b/src/BrowseColumn.php index e8ed6a8a..0b757e3e 100644 --- a/src/BrowseColumn.php +++ b/src/BrowseColumn.php @@ -4,7 +4,7 @@ use PhpTwinfield\Enums\BrowseColumnOperator; -class BrowseColumn +class BrowseColumn extends BaseObject { /** @var int */ private $id; diff --git a/src/BrowseData.php b/src/BrowseData.php index 9329ba1d..e11364af 100644 --- a/src/BrowseData.php +++ b/src/BrowseData.php @@ -2,7 +2,7 @@ namespace PhpTwinfield; -class BrowseData +class BrowseData extends BaseObject { /** @var int */ private $first; diff --git a/src/BrowseDataCell.php b/src/BrowseDataCell.php index 91cdb9d0..f28baff5 100644 --- a/src/BrowseDataCell.php +++ b/src/BrowseDataCell.php @@ -2,7 +2,7 @@ namespace PhpTwinfield; -class BrowseDataCell +class BrowseDataCell extends BaseObject { /** @var string */ private $field; diff --git a/src/BrowseDataHeader.php b/src/BrowseDataHeader.php index 7838f9ad..30df037c 100644 --- a/src/BrowseDataHeader.php +++ b/src/BrowseDataHeader.php @@ -4,7 +4,7 @@ use PhpTwinfield\Fields\CodeField; -class BrowseDataHeader +class BrowseDataHeader extends BaseObject { use CodeField; diff --git a/src/BrowseDataRow.php b/src/BrowseDataRow.php index bb831a76..41a8e470 100644 --- a/src/BrowseDataRow.php +++ b/src/BrowseDataRow.php @@ -5,7 +5,7 @@ use PhpTwinfield\Fields\CodeField; use PhpTwinfield\Fields\OfficeField; -class BrowseDataRow +class BrowseDataRow extends BaseObject { use CodeField; use OfficeField; diff --git a/src/BrowseDefinition.php b/src/BrowseDefinition.php index 3ba4ecea..f757a5f6 100644 --- a/src/BrowseDefinition.php +++ b/src/BrowseDefinition.php @@ -7,7 +7,7 @@ use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\ShortNameField; -class BrowseDefinition +class BrowseDefinition extends BaseObject { use CodeField; use NameField; diff --git a/src/BrowseField.php b/src/BrowseField.php index 81b54e5a..57651d64 100644 --- a/src/BrowseField.php +++ b/src/BrowseField.php @@ -4,7 +4,7 @@ use PhpTwinfield\Fields\CodeField; -class BrowseField +class BrowseField extends BaseObject { use CodeField; diff --git a/src/BrowseFieldOption.php b/src/BrowseFieldOption.php index 0adf734c..2d7f6c0a 100644 --- a/src/BrowseFieldOption.php +++ b/src/BrowseFieldOption.php @@ -5,7 +5,7 @@ use PhpTwinfield\Fields\CodeField; use PhpTwinfield\Fields\NameField; -class BrowseFieldOption +class BrowseFieldOption extends BaseObject { use CodeField; use NameField; diff --git a/src/BrowseSortField.php b/src/BrowseSortField.php index 09cdcded..9af8d5fe 100644 --- a/src/BrowseSortField.php +++ b/src/BrowseSortField.php @@ -5,7 +5,7 @@ use PhpTwinfield\Enums\Order; use PhpTwinfield\Fields\CodeField; -class BrowseSortField +class BrowseSortField extends BaseObject { use CodeField; diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index 16f547db..16f9a42b 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -4,14 +4,14 @@ use Money\Currency; use Money\Money; -use PhpTwinfield\BaseObject; +use PhpTwinfield\HasMessageInterface; use PhpTwinfield\Message\Message; use PhpTwinfield\Util; use Webmozart\Assert\Assert; abstract class BaseMapper { - protected static function checkForMessage(BaseObject $object, \DOMElement $element): void + protected static function checkForMessage(HasMessageInterface $object, \DOMElement $element): void { if ($element->hasAttribute('msg')) { $message = new Message(); From 18e9f2c39515ea9ba4195352a25e08ce5cd25adb Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 11 Jun 2019 13:50:45 +0200 Subject: [PATCH 298/388] Update Util.php --- src/Util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Util.php b/src/Util.php index 44e2bca8..93d56507 100644 --- a/src/Util.php +++ b/src/Util.php @@ -92,7 +92,7 @@ public static function formatBoolean(bool $boolean): string } /** - * @param string|null $input + * @param string|null $value * @return bool */ public static function parseBoolean(?string $value): bool From 468c1a93ce6b70987e28d12cad70b29becd5df44 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 16 Jun 2019 22:18:59 +0200 Subject: [PATCH 299/388] Update BaseMapper.php --- src/Mappers/BaseMapper.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index 16f9a42b..7d82a82d 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -62,7 +62,7 @@ protected static function parseDateAttribute(?string $value): ?\DateTimeImmutabl if (false !== strtotime($value)) { return Util::parseDate($value); } - + return null; } @@ -71,7 +71,7 @@ protected static function parseDateTimeAttribute(?string $value): ?\DateTimeImmu if (false !== strtotime($value)) { return Util::parseDateTime($value); } - + return null; } @@ -88,13 +88,13 @@ protected static function parseEnumAttribute(string $enumClass, ?string $value) } } - protected static function parseMoneyAttribute(?float $value): ?Money + protected static function parseMoneyAttribute(?float $value, ?string $currency): ?Money { - if ($value === null) { + if ($value === null || $currency === null) { return null; } - return Util::parseMoney($value, new Currency('EUR')); + return Util::parseMoney($value, new Currency($currency)); } /** @var SomeClassWithMethodsetCode $object2 */ From b8fc6dc87c19fbf82ef09a222fc4e42a9fe1ab8e Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 16 Jun 2019 23:20:08 +0200 Subject: [PATCH 300/388] Upload --- src/ApiConnectors/ArticleApiConnector.php | 4 +- src/ApiConnectors/CustomerApiConnector.php | 4 +- src/ApiConnectors/FixedAssetApiConnector.php | 4 +- src/ApiConnectors/TransactionApiConnector.php | 4 +- src/DomDocuments/InvoicesDocument.php | 2 +- src/Fields/Office/BaseCurrencyField.php | 54 +++++++++++++ src/Fields/Office/ReportingCurrencyField.php | 54 +++++++++++++ src/Mappers/ArticleMapper.php | 10 ++- src/Mappers/BaseMapper.php | 18 +++++ src/Mappers/CustomerMapper.php | 13 ++- src/Mappers/FixedAssetMapper.php | 12 ++- src/Mappers/InvoiceMapper.php | 16 ++-- src/Mappers/OfficeMapper.php | 4 +- src/Mappers/SupplierMapper.php | 5 +- src/Mappers/TransactionMapper.php | 81 ++++++++++--------- src/Office.php | 4 + 16 files changed, 219 insertions(+), 70 deletions(-) create mode 100644 src/Fields/Office/BaseCurrencyField.php create mode 100644 src/Fields/Office/ReportingCurrencyField.php diff --git a/src/ApiConnectors/ArticleApiConnector.php b/src/ApiConnectors/ArticleApiConnector.php index 47174504..25cbb1f8 100644 --- a/src/ApiConnectors/ArticleApiConnector.php +++ b/src/ApiConnectors/ArticleApiConnector.php @@ -45,7 +45,7 @@ public function get(string $code, Office $office): Article // Send the Request document and set the response to this instance. $response = $this->sendXmlDocument($request_article); - return ArticleMapper::map($response); + return ArticleMapper::map($response, $this->getConnection()); } /** @@ -85,7 +85,7 @@ public function sendAll(array $articles): MappedResponseCollection } return $this->getProcessXmlService()->mapAll($responses, "article", function(Response $response): Article { - return ArticleMapper::map($response); + return ArticleMapper::map($response, $this->getConnection()); }); } diff --git a/src/ApiConnectors/CustomerApiConnector.php b/src/ApiConnectors/CustomerApiConnector.php index 24a16dfb..ac9b9801 100644 --- a/src/ApiConnectors/CustomerApiConnector.php +++ b/src/ApiConnectors/CustomerApiConnector.php @@ -46,7 +46,7 @@ public function get(string $code, Office $office): Customer // Send the Request document and set the response to this instance. $response = $this->sendXmlDocument($request_customer); - return CustomerMapper::map($response); + return CustomerMapper::map($response, $this->getConnection()); } /** @@ -86,7 +86,7 @@ public function sendAll(array $customers): MappedResponseCollection } return $this->getProcessXmlService()->mapAll($responses, "dimension", function(Response $response): Customer { - return CustomerMapper::map($response); + return CustomerMapper::map($response, $this->getConnection()); }); } diff --git a/src/ApiConnectors/FixedAssetApiConnector.php b/src/ApiConnectors/FixedAssetApiConnector.php index cf1eb741..ebe4adb2 100644 --- a/src/ApiConnectors/FixedAssetApiConnector.php +++ b/src/ApiConnectors/FixedAssetApiConnector.php @@ -45,7 +45,7 @@ public function get(string $code, Office $office): FixedAsset // Send the Request document and set the response to this instance. $response = $this->sendXmlDocument($request_fixedAsset); - return FixedAssetMapper::map($response); + return FixedAssetMapper::map($response, $this->getConnection()); } /** @@ -85,7 +85,7 @@ public function sendAll(array $fixedAssets): MappedResponseCollection } return $this->getProcessXmlService()->mapAll($responses, "dimension", function(Response $response): FixedAsset { - return FixedAssetMapper::map($response); + return FixedAssetMapper::map($response, $this->getConnection()); }); } diff --git a/src/ApiConnectors/TransactionApiConnector.php b/src/ApiConnectors/TransactionApiConnector.php index b953363f..af7fbd8a 100644 --- a/src/ApiConnectors/TransactionApiConnector.php +++ b/src/ApiConnectors/TransactionApiConnector.php @@ -44,7 +44,7 @@ public function get(string $transactionClassName, string $code, string $transact // Send the Request document and set the response to this instance $response = $this->sendXmlDocument($request_transaction); - return TransactionMapper::map($transactionClassName, $response); + return TransactionMapper::map($transactionClassName, $response, $this->getConnection()); } /** @@ -86,7 +86,7 @@ public function sendAll(array $transactions): MappedResponseCollection } return $this->getProcessXmlService()->mapAll($responses, "transaction", function (Response $subresponse) use ($classname): BaseTransaction { - return TransactionMapper::map($classname, $subresponse); + return TransactionMapper::map($classname, $subresponse, $this->getConnection()); }); } } \ No newline at end of file diff --git a/src/DomDocuments/InvoicesDocument.php b/src/DomDocuments/InvoicesDocument.php index c9bbfd2f..520991c6 100644 --- a/src/DomDocuments/InvoicesDocument.php +++ b/src/DomDocuments/InvoicesDocument.php @@ -36,7 +36,7 @@ final protected function getRootTagName(): string * @param AuthenticatedConnection $connection * @return void | [Adds to this instance] */ - public function addInvoice(Invoice $invoice, $connection) + public function addInvoice(Invoice $invoice, AuthenticatedConnection $connection) { $invoiceElement = $this->createElement('salesinvoice'); $this->rootElement->appendChild($invoiceElement); diff --git a/src/Fields/Office/BaseCurrencyField.php b/src/Fields/Office/BaseCurrencyField.php new file mode 100644 index 00000000..e429ddea --- /dev/null +++ b/src/Fields/Office/BaseCurrencyField.php @@ -0,0 +1,54 @@ +baseCurrency; + } + + public function getBaseCurrencyToString(): ?string + { + if ($this->getBaseCurrency() != null) { + return $this->baseCurrency->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setBaseCurrency(?Currency $baseCurrency): self + { + $this->baseCurrency = $baseCurrency; + return $this; + } + + /** + * @param string|null $baseCurrencyString + * @return $this + * @throws Exception + */ + public function setBaseCurrencyFromString(?string $baseCurrencyString) + { + $baseCurrency = new Currency(); + $baseCurrency->setCode($baseCurrencyString); + return $this->setBaseCurrency($baseCurrency); + } +} \ No newline at end of file diff --git a/src/Fields/Office/ReportingCurrencyField.php b/src/Fields/Office/ReportingCurrencyField.php new file mode 100644 index 00000000..34d35557 --- /dev/null +++ b/src/Fields/Office/ReportingCurrencyField.php @@ -0,0 +1,54 @@ +reportingCurrency; + } + + public function getReportingCurrencyToString(): ?string + { + if ($this->getReportingCurrency() != null) { + return $this->reportingCurrency->getCode(); + } else { + return null; + } + } + + /** + * @return $this + */ + public function setReportingCurrency(?Currency $reportingCurrency): self + { + $this->reportingCurrency = $reportingCurrency; + return $this; + } + + /** + * @param string|null $reportingCurrencyString + * @return $this + * @throws Exception + */ + public function setReportingCurrencyFromString(?string $reportingCurrencyString) + { + $reportingCurrency = new Currency(); + $reportingCurrency->setCode($reportingCurrencyString); + return $this->setReportingCurrency($reportingCurrency); + } +} \ No newline at end of file diff --git a/src/Mappers/ArticleMapper.php b/src/Mappers/ArticleMapper.php index 4586c1e4..4676288b 100644 --- a/src/Mappers/ArticleMapper.php +++ b/src/Mappers/ArticleMapper.php @@ -4,6 +4,7 @@ use PhpTwinfield\Article; use PhpTwinfield\ArticleLine; use PhpTwinfield\Response\Response; +use PhpTwinfield\Secure\AuthenticatedConnection; use PhpTwinfield\Util; /** @@ -21,11 +22,12 @@ class ArticleMapper extends BaseMapper * @access public * * @param \PhpTwinfield\Response\Response $response + * @param \PhpTwinfield\Secure\AuthenticatedConnection $connection * * @return Article * @throws \PhpTwinfield\Exception */ - public static function map(Response $response) + public static function map(Response $response, AuthenticatedConnection $connection) { // Generate new Article object $article = new Article(); @@ -61,6 +63,8 @@ public static function map(Response $response) ->setUnitNameSingular(self::getField($headerElement, 'unitnamesingular', $article)) ->setUnitNamePlural(self::getField($headerElement, 'unitnameplural', $article)) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $article, $headerElement, 'vatcode')); + + $currencies = self::getOfficeCurrencies($connection, $article->getOffice()); // Get the lines element $linesDOMTag = $responseDOM->getElementsByTagName('lines'); @@ -99,8 +103,8 @@ public static function map(Response $response) ->setName(self::getField($lineElement, 'name', $articleLine)) ->setShortName(self::getField($lineElement, 'shortname', $articleLine)) ->setSubCode(self::getField($lineElement, 'subcode', $articleLine)) - ->setUnitsPriceExcl(self::parseMoneyAttribute(self::getField($lineElement, 'unitspriceexcl', $articleLine))) - ->setUnitsPriceInc(self::parseMoneyAttribute(self::getField($lineElement, 'unitspriceinc', $articleLine))); + ->setUnitsPriceExcl(self::parseMoneyAttribute(self::getField($lineElement, 'unitspriceexcl', $articleLine), $currencies['base'])) + ->setUnitsPriceInc(self::parseMoneyAttribute(self::getField($lineElement, 'unitspriceinc', $articleLine), $currencies['base'])); // Add the line to the article $article->addLine($articleLine); diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index 7d82a82d..5cf15e7d 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -4,9 +4,12 @@ use Money\Currency; use Money\Money; +use PhpTwinfield\ApiConnectors\OfficeApiConnector; use PhpTwinfield\HasMessageInterface; use PhpTwinfield\Message\Message; +use PhpTwinfield\Office; use PhpTwinfield\Util; +use PhpTwinfield\Secure\AuthenticatedConnection; use Webmozart\Assert\Assert; abstract class BaseMapper @@ -56,6 +59,21 @@ protected static function getField(\DOMElement $element, string $fieldTagName, $ return $fieldElement->textContent; } + + protected static function getOfficeCurrencies(AuthenticatedConnection $connection, Office $office): array + { + $currencies = ["base" => '', "reporting" => '']; + + $officeApiConnector = new OfficeApiConnector($connection); + $office = $officeApiConnector->get($office->getCode()); + + if ($office->getResult() == 1) { + $currencies['base'] = $office->getBaseCurrencyToString(); + $currencies['reporting'] = $office->getReportingCurrencyToString(); + } + + return $currencies; + } protected static function parseDateAttribute(?string $value): ?\DateTimeImmutable { diff --git a/src/Mappers/CustomerMapper.php b/src/Mappers/CustomerMapper.php index 237869f0..a848c2d5 100644 --- a/src/Mappers/CustomerMapper.php +++ b/src/Mappers/CustomerMapper.php @@ -11,6 +11,7 @@ use PhpTwinfield\CustomerLine; use PhpTwinfield\CustomerPostingRule; use PhpTwinfield\Response\Response; +use PhpTwinfield\Secure\AuthenticatedConnection; use PhpTwinfield\Util; /** @@ -28,10 +29,11 @@ class CustomerMapper extends BaseMapper * * @access public * @param \PhpTwinfield\Response\Response $response + * @param \PhpTwinfield\Secure\AuthenticatedConnection $connection * @return Customer * @throws \PhpTwinfield\Exception */ - public static function map(Response $response) + public static function map(Response $response, AuthenticatedConnection $connection) { // Generate new Customer object $customer = new Customer(); @@ -62,6 +64,8 @@ public static function map(Response $response) ->setType(self::parseObjectAttribute(\PhpTwinfield\DimensionType::class, $customer, $customerElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setUID(self::getField($customerElement, 'uid', $customer)) ->setWebsite(self::getField($customerElement, 'website', $customer)); + + $currencies = self::getOfficeCurrencies($connection, $customer->getOffice()); // Set the customer elements from the customer element attributes $customer->setDiscountArticleID(self::getAttribute($customerElement, 'discountarticle', 'id')); @@ -151,7 +155,7 @@ public static function map(Response $response) $customerCreditManagement = new CustomerCreditManagement(); // Set the customer credit management elements from the creditmanagement element - $customerCreditManagement->setBaseCreditLimit(self::parseMoneyAttribute(self::getField($creditManagementElement, 'basecreditlimit', $customerCreditManagement))) + $customerCreditManagement->setBaseCreditLimit(self::parseMoneyAttribute(self::getField($creditManagementElement, 'basecreditlimit', $customerCreditManagement), $currencies['base'])) ->setBlocked(Util::parseBoolean(self::getField($creditManagementElement, 'blocked', $customerCreditManagement))) ->setComment(self::getField($creditManagementElement, 'comment', $customerCreditManagement)) ->setFreeText1(Util::parseBoolean(self::getField($creditManagementElement, 'freetext1', $customerCreditManagement))) @@ -277,9 +281,10 @@ public static function map(Response $response) ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $postingruleElement->getAttribute('status'))); // Set the postingrule elements from the postingrule element - $customerPostingRule->setAmount(self::parseMoneyAttribute(self::getField($postingruleElement, 'amount', $customerPostingRule))) - ->setCurrency(self::parseObjectAttribute(\PhpTwinfield\Currency::class, $customerPostingRule, $postingruleElement, 'currency', array('name' => 'setName', 'shortname' => 'setShortName'))) + $customerPostingRule->setCurrency(self::parseObjectAttribute(\PhpTwinfield\Currency::class, $customerPostingRule, $postingruleElement, 'currency', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setDescription(self::getField($postingruleElement, 'description', $customerPostingRule)); + + $customerPostingRule->setAmount(self::parseMoneyAttribute(self::getField($postingruleElement, 'amount', $customerPostingRule), $customerPostingRule->getCurrencyToString())); // Get the lines element $linesDOMTag = $postingruleElement->getElementsByTagName('lines'); diff --git a/src/Mappers/FixedAssetMapper.php b/src/Mappers/FixedAssetMapper.php index 8a2ae839..37fc0b9a 100644 --- a/src/Mappers/FixedAssetMapper.php +++ b/src/Mappers/FixedAssetMapper.php @@ -6,6 +6,7 @@ use PhpTwinfield\FixedAssetFixedAssets; use PhpTwinfield\FixedAssetTransactionLine; use PhpTwinfield\Response\Response; +use PhpTwinfield\Secure\AuthenticatedConnection; use PhpTwinfield\Util; /** @@ -23,11 +24,12 @@ class FixedAssetMapper extends BaseMapper * @access public * * @param \PhpTwinfield\Response\Response $response + * @param \PhpTwinfield\Secure\AuthenticatedConnection $connection * * @return FixedAsset * @throws \PhpTwinfield\Exception */ - public static function map(Response $response) + public static function map(Response $response, AuthenticatedConnection $connection) { // Generate new FixedAsset object $fixedAsset = new FixedAsset(); @@ -51,6 +53,8 @@ public static function map(Response $response) ->setTouched(self::getField($fixedAssetElement, 'touched', $fixedAsset)) ->setType(self::parseObjectAttribute(\PhpTwinfield\DimensionType::class, $fixedAsset, $fixedAssetElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setUID(self::getField($fixedAssetElement, 'uid', $fixedAsset)); + + $currencies = self::getOfficeCurrencies($connection, $fixedAsset->getOffice()); // Get the financials element $financialsElement = $responseDOM->getElementsByTagName('financials')->item(0); @@ -95,10 +99,10 @@ public static function map(Response $response) ->setNrOfPeriods(self::getField($fixedAssetsElement, 'nrofperiods', $fixedAssetFixedAssets)) ->setPercentage(self::getField($fixedAssetsElement, 'percentage', $fixedAssetFixedAssets)) ->setPurchaseDate(self::parseDateAttribute(self::getField($fixedAssetsElement, 'purchasedate', $fixedAssetFixedAssets))) - ->setResidualValue(self::parseMoneyAttribute(self::getField($fixedAssetsElement, 'residualvalue', $fixedAssetFixedAssets))) + ->setResidualValue(self::parseMoneyAttribute(self::getField($fixedAssetsElement, 'residualvalue', $fixedAssetFixedAssets), $currencies['base'])) ->setSellDate(self::parseDateAttribute(self::getField($fixedAssetsElement, 'selldate', $fixedAssetFixedAssets))) ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\FixedAssetsStatus::class, self::getField($fixedAssetsElement, 'status', $fixedAssetFixedAssets))) - ->setStopValue(self::parseMoneyAttribute(self::getField($fixedAssetsElement, 'stopvalue', $fixedAssetFixedAssets))); + ->setStopValue(self::parseMoneyAttribute(self::getField($fixedAssetsElement, 'stopvalue', $fixedAssetFixedAssets), $currencies['base'])); // Set the fixed assets elements from the fixed assets element attributes $fixedAssetFixedAssets->setBeginPeriodLocked(Util::parseBoolean(self::getAttribute($fixedAssetsElement, 'beginperiod', 'locked'))) @@ -132,7 +136,7 @@ public static function map(Response $response) $fixedAssetTransactionLine = new FixedAssetTransactionLine(); // Set the fixed assets transaction line elements from the fixed assets transline element - $fixedAssetTransactionLine->setAmount(self::parseMoneyAttribute(self::getField($transactionLineElement, 'amount', $fixedAssetTransactionLine))) + $fixedAssetTransactionLine->setAmount(self::parseMoneyAttribute(self::getField($transactionLineElement, 'amount', $fixedAssetTransactionLine), $currencies['base'])) ->setCode(self::getField($transactionLineElement, 'code', $fixedAssetTransactionLine)) ->setDim1(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $fixedAssetTransactionLine, $transactionLineElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) ->setDim2(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) diff --git a/src/Mappers/InvoiceMapper.php b/src/Mappers/InvoiceMapper.php index a592fbfd..0bdc4070 100644 --- a/src/Mappers/InvoiceMapper.php +++ b/src/Mappers/InvoiceMapper.php @@ -67,8 +67,8 @@ public static function map(Response $response) $invoiceTotals = new InvoiceTotals(); // Set the invoice totals elements from the totals element - $invoiceTotals->setValueExcl(self::parseMoneyAttribute(self::getField($totalsElement, 'valueexcl', $invoiceTotals))) - ->setValueInc(self::parseMoneyAttribute(self::getField($totalsElement, 'valueinc', $invoiceTotals))); + $invoiceTotals->setValueExcl(self::parseMoneyAttribute(self::getField($totalsElement, 'valueexcl', $invoiceTotals), $invoice->getCurrencyToString())) + ->setValueInc(self::parseMoneyAttribute(self::getField($totalsElement, 'valueinc', $invoiceTotals), $invoice->getCurrencyToString())); // Set the custom class to the invoice $invoice->setTotals($invoiceTotals); @@ -103,12 +103,12 @@ public static function map(Response $response) ->setQuantity(self::getField($lineElement, 'quantity', $invoiceLine)) ->setSubArticleFromString(self::getField($lineElement, 'subarticle', $invoiceLine)) ->setUnits(self::getField($lineElement, 'units', $invoiceLine)) - ->setUnitsPriceExcl(self::parseMoneyAttribute(self::getField($lineElement, 'unitspriceexcl', $invoiceLine))) - ->setUnitsPriceInc(self::parseMoneyAttribute(self::getField($lineElement, 'unitspriceinc', $invoiceLine))) - ->setValueExcl(self::parseMoneyAttribute(self::getField($lineElement, 'valueexcl', $invoiceLine))) - ->setValueInc(self::parseMoneyAttribute(self::getField($lineElement, 'valueinc', $invoiceLine))) + ->setUnitsPriceExcl(self::parseMoneyAttribute(self::getField($lineElement, 'unitspriceexcl', $invoiceLine), $invoice->getCurrencyToString())) + ->setUnitsPriceInc(self::parseMoneyAttribute(self::getField($lineElement, 'unitspriceinc', $invoiceLine), $invoice->getCurrencyToString())) + ->setValueExcl(self::parseMoneyAttribute(self::getField($lineElement, 'valueexcl', $invoiceLine), $invoice->getCurrencyToString())) + ->setValueInc(self::parseMoneyAttribute(self::getField($lineElement, 'valueinc', $invoiceLine), $invoice->getCurrencyToString())) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $invoiceLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) - ->setVatValue(self::parseMoneyAttribute(self::getField($lineElement, 'vatvalue', $invoiceLine))); + ->setVatValue(self::parseMoneyAttribute(self::getField($lineElement, 'vatvalue', $invoiceLine), $invoice->getCurrencyToString())); // Set the custom class to the invoice $invoice->addLine($invoiceLine); @@ -132,7 +132,7 @@ public static function map(Response $response) $invoiceVatLine->setPerformanceDate(self::parseDateAttribute(self::getField($vatlineElement, 'performancedate', $invoiceVatLine))) ->setPerformanceType(self::parseEnumAttribute(\PhpTwinfield\Enums\PerformanceType::class, self::getField($vatlineElement, 'performancetype', $invoiceVatLine))) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $invoiceVatLine, $vatlineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) - ->setVatValue(self::parseMoneyAttribute(self::getField($vatlineElement, 'vatvalue', $invoiceVatLine))); + ->setVatValue(self::parseMoneyAttribute(self::getField($vatlineElement, 'vatvalue', $invoiceVatLine), $invoice->getCurrencyToString())); // Set the custom class to the invoice $invoice->addVatLine($invoiceVatLine); diff --git a/src/Mappers/OfficeMapper.php b/src/Mappers/OfficeMapper.php index 41d5aeef..71dddcaa 100644 --- a/src/Mappers/OfficeMapper.php +++ b/src/Mappers/OfficeMapper.php @@ -39,10 +39,12 @@ public static function map(Response $response) ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $officeElement->getAttribute('status'))); // Set the office elements from the office element - $office->setCode(self::getField($officeElement, 'code', $office)) + $office->setBaseCurrency(self::parseObjectAttribute(\PhpTwinfield\Currency::class, $office, $officeElement, 'basecurrency', array('name' => 'setName', 'shortname' => 'setShortName'))) + ->setCode(self::getField($officeElement, 'code', $office)) ->setCreated(self::parseDateTimeAttribute(self::getField($officeElement, 'created', $office))) ->setModified(self::parseDateTimeAttribute(self::getField($officeElement, 'modified', $office))) ->setName(self::getField($officeElement, 'name', $office)) + ->setReportingCurrency(self::parseObjectAttribute(\PhpTwinfield\Currency::class, $office, $officeElement, 'reportingcurrency', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setShortName(self::getField($officeElement, 'shortname', $office)) ->setTouched(self::getField($officeElement, 'touched', $office)) ->setUser(self::parseObjectAttribute(\PhpTwinfield\User::class, $office, $officeElement, 'user', array('name' => 'setName', 'shortname' => 'setShortName'))); diff --git a/src/Mappers/SupplierMapper.php b/src/Mappers/SupplierMapper.php index 84f24e8f..a6be92ef 100644 --- a/src/Mappers/SupplierMapper.php +++ b/src/Mappers/SupplierMapper.php @@ -224,10 +224,11 @@ public static function map(Response $response) ->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $postingruleElement->getAttribute('status'))); // Set the postingrule elements from the postingrule element - $supplierPostingRule->setAmount(self::parseMoneyAttribute(self::getField($postingruleElement, 'amount', $supplierPostingRule))) - ->setCurrency(self::parseObjectAttribute(\PhpTwinfield\Currency::class, $supplierPostingRule, $postingruleElement, 'currency', array('name' => 'setName', 'shortname' => 'setShortName'))) + $supplierPostingRule->setCurrency(self::parseObjectAttribute(\PhpTwinfield\Currency::class, $supplierPostingRule, $postingruleElement, 'currency', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setDescription(self::getField($postingruleElement, 'description', $supplierPostingRule)); + $supplierPostingRule->setAmount(self::parseMoneyAttribute(self::getField($postingruleElement, 'amount', $supplierPostingRule), $supplierPostingRule->getCurrencyToString())); + // Get the lines element $linesDOMTag = $postingruleElement->getElementsByTagName('lines'); diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 7ede2f09..49dc85e5 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -5,7 +5,6 @@ use PhpTwinfield\BankTransaction; use PhpTwinfield\BaseTransaction; use PhpTwinfield\CashTransaction; -use PhpTwinfield\Enums\LineType; use PhpTwinfield\Exception; use PhpTwinfield\Fields\DueDateField; use PhpTwinfield\Fields\FreeText1Field; @@ -32,6 +31,7 @@ use PhpTwinfield\Message\Message; use PhpTwinfield\PurchaseTransaction; use PhpTwinfield\SalesTransaction; +use PhpTwinfield\Secure\AuthenticatedConnection; use PhpTwinfield\Response\Response; use PhpTwinfield\Util; @@ -40,18 +40,19 @@ class TransactionMapper extends BaseMapper /** * @param string $transactionClassName * @param Response $response + * @param AuthenticatedConnection $connection * * @return iterable|BaseTransaction[] * @throws Exception */ - public static function mapAll(string $transactionClassName, Response $response): iterable + public static function mapAll(string $transactionClassName, Response $response, AuthenticatedConnection $connection): iterable { foreach ($response->getResponseDocument()->getElementsByTagName('transaction') as $transactionElement) { - yield self::map($transactionClassName, $transactionElement); + yield self::map($transactionClassName, $transactionElement, $connection); } } - public static function map(string $transactionClassName, Response $response): BaseTransaction + public static function map(string $transactionClassName, Response $response, AuthenticatedConnection $connection): BaseTransaction { if (!is_a($transactionClassName, BaseTransaction::class, true)) { throw Exception::invalidTransactionClassName($transactionClassName); @@ -86,15 +87,17 @@ public static function map(string $transactionClassName, Response $response): Ba } $transaction->setCode(self::getField($transactionElement, 'code', $transaction)) - ->setCurrencyFromString(self::getField($transactionElement, 'currency', $transaction)) - ->setDateFromString(self::getField($transactionElement, 'date', $transaction)) + ->setCurrency(self::parseObjectAttribute(\PhpTwinfield\Currency::class, $transaction, $transactionElement, 'currency')) + ->setDate(self::parseDateAttribute(self::getField($transactionElement, 'date', $transaction))) ->setFreetext1(self::getField($transactionElement, 'freetext1', $transaction)) ->setFreetext2(self::getField($transactionElement, 'freetext2', $transaction)) ->setFreetext3(self::getField($transactionElement, 'freetext3', $transaction)) - ->setOfficeFromString(self::getField($transactionElement, 'office', $transaction)) + ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $transaction, $transactionElement, 'office')) ->setOrigin(self::getField($transactionElement, 'origin', $transaction)) ->setNumber(self::getField($transactionElement, 'number', $transaction)) ->setPeriod(self::getField($transactionElement, 'period', $transaction)); + + $currencies = self::getOfficeCurrencies($connection, $transaction->getOffice()); if (Util::objectUses(CloseAndStartValueFields::class, $transaction)) { $transaction->setStartValueFromFloat(self::getField($transactionElement, 'startvalue', $transaction)); @@ -144,19 +147,19 @@ public static function map(string $transactionClassName, Response $response): Ba $lineType = $lineElement->getAttribute('type'); $transactionLine - ->setBaseValueFromFloat(self::getField($lineElement, 'basevalue', $transactionLine)) + ->setBaseValue(self::parseMoneyAttribute(self::getField($lineElement, 'basevalue', $transactionLine), $currencies['base'])) ->setComment(self::getField($lineElement, 'comment', $transactionLine)) - ->setValueFromFloat(self::getField($lineElement, 'value', $transactionLine)) + ->setValue(self::parseMoneyAttribute(self::getField($lineElement, 'value', $transactionLine), $transaction->getCurrencyToString())) ->setDebitCredit(self::parseEnumAttribute(\PhpTwinfield\Enums\DebitCredit::class, self::getField($lineElement, 'debitcredit', $transactionLine))) ->setDescription(self::getField($lineElement, 'description', $transactionLine)) - ->setDestOfficeFromString(self::getField($lineElement, 'destoffice', $transactionLine)) - ->setDim1FromString(self::getField($lineElement, 'dim1', $transactionLine)) + ->setDestOfficeFromString(self::parseObjectAttribute(\PhpTwinfield\Office::class, $transactionLine, $lineElement, 'destoffice')) + ->setDim1(self::parseObjectAttribute(\PhpTwinfield\Dummy::class, $transactionLine, $lineElement, 'dim1')) ->setId($lineElement->getAttribute('id')) - ->setLineType(new LineType($lineType)) + ->setLineType(self::parseEnumAttribute(\PhpTwinfield\Enums\LineType::class, $lineType)) ->setMatchStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\MatchStatus::class, self::getField($lineElement, 'matchstatus', $transactionLine))) ->setRate(self::getField($lineElement, 'rate', $transactionLine)) ->setRepRate(self::getField($lineElement, 'reprate', $transactionLine)) - ->setRepValueFromFloat(self::getField($lineElement, 'repvalue', $transactionLine)); + ->setRepValue(self::parseMoneyAttribute(self::getField($lineElement, 'repvalue', $transactionLine), $currencies['reporting'])); $freeChar = self::getField($lineElement, 'freechar', $transactionLine); @@ -169,102 +172,102 @@ public static function map(string $transactionClassName, Response $response): Ba $baseValueOpen = self::getField($lineElement, 'basevalueopen', $transactionLine) ?: self::getField($lineElement, 'openbasevalue', $transactionLine); if ($baseValueOpen) { - $transactionLine->setBaseValueOpenFromFloat($baseValueOpen); + $transactionLine->setBaseValueOpen(self::parseMoneyAttribute($baseValueOpen, $currencies['base'])); } - $transactionLine->setDim2FromString(self::getField($lineElement, 'dim2', $transactionLine)); - $transactionLine->setDim3FromString(self::getField($lineElement, 'dim3', $transactionLine)); + $transactionLine->setDim2(self::parseObjectAttribute(\PhpTwinfield\Dummy::class, $transactionLine, $lineElement, 'dim2')); + $transactionLine->setDim3(self::parseObjectAttribute(\PhpTwinfield\Dummy::class, $transactionLine, $lineElement, 'dim3')); $transactionLine->setMatchLevel(self::getField($lineElement, 'matchlevel', $transactionLine)); $transactionLine->setRelation(self::getField($lineElement, 'relation', $transactionLine)); - $transactionLine->setRepValueOpenFromFloat(self::getField($lineElement, 'repvalueopen', $transactionLine)); + $transactionLine->setRepValueOpen(self::parseMoneyAttribute(self::getField($lineElement, 'repvalueopen', $transactionLine), $currencies['reporting'])); } } if ($transaction instanceof PurchaseTransaction || $transaction instanceof SalesTransaction) { if ($lineType == LineType::DETAIL()) { - $transactionLine->setDim2FromString(self::getField($lineElement, 'dim2', $transactionLine)); - $transactionLine->setDim3FromString(self::getField($lineElement, 'dim3', $transactionLine)); + $transactionLine->setDim2(self::parseObjectAttribute(\PhpTwinfield\Dummy::class, $transactionLine, $lineElement, 'dim2')); + $transactionLine->setDim3(self::parseObjectAttribute(\PhpTwinfield\Dummy::class, $transactionLine, $lineElement, 'dim3')); } elseif ($transaction instanceof PurchaseTransaction && $lineType == LineType::VAT()) { - $transactionLine->setDim3FromString(self::getField($lineElement, 'dim3', $transactionLine)); + $transactionLine->setDim3(self::parseObjectAttribute(\PhpTwinfield\Dummy::class, $transactionLine, $lineElement, 'dim3')); } elseif ($lineType == LineType::TOTAL()) { - $transactionLine->setDim2FromString(self::getField($lineElement, 'dim2', $transactionLine)); + $transactionLine->setDim2(self::parseObjectAttribute(\PhpTwinfield\Dummy::class, $transactionLine, $lineElement, 'dim2')); $baseValueOpen = self::getField($lineElement, 'basevalueopen', $transactionLine) ?: self::getField($lineElement, 'openbasevalue', $transactionLine); if ($baseValueOpen) { - $transactionLine->setBaseValueOpenFromFloat($baseValueOpen); + $transactionLine->setBaseValueOpen(self::parseMoneyAttribute($baseValueOpen, $currencies['base'])); } $transactionLine->setMatchLevel(self::getField($lineElement, 'matchlevel', $transactionLine)); $transactionLine->setRelation(self::getField($lineElement, 'relation', $transactionLine)); - $transactionLine->setRepValueOpenFromFloat(self::getField($lineElement, 'repvalueopen', $transactionLine)); + $transactionLine->setRepValueOpen(self::parseMoneyAttribute(self::getField($lineElement, 'repvalueopen', $transactionLine), $currencies['reporting'])); } } if ($lineType == LineType::DETAIL()) { if (Util::objectUses(CurrencyDateField::class, $transactionLine)) { - $transactionLine->setCurrencyDateFromString(self::getField($lineElement, 'currencydate', $transactionLine)); + $transactionLine->setCurrencyDate(self::parseDateAttribute(self::getField($lineElement, 'currencydate', $transactionLine))); } if (Util::objectUses(InvoiceNumberField::class, $transactionLine)) { $transactionLine->setInvoiceNumber(self::getField($lineElement, 'invoicenumber', $transactionLine)); } - $transactionLine->setVatBaseValueFromFloat(self::getField($lineElement, 'vatbasevalue', $transactionLine)); - $transactionLine->setVatRepValueFromFloat(self::getField($lineElement, 'vatrepvalue', $transactionLine)); - $transactionLine->setVatValueFromFloat(self::getField($lineElement, 'vatvalue', $transactionLine)); + $transactionLine->setVatBaseValue(self::parseMoneyAttribute(self::getField($lineElement, 'vatbasevalue', $transactionLine), $currencies['base'])); + $transactionLine->setVatRepValue(self::parseMoneyAttribute(self::getField($lineElement, 'vatrepvalue', $transactionLine), $currencies['reporting'])); + $transactionLine->setVatValue(self::parseMoneyAttribute(self::getField($lineElement, 'vatvalue', $transactionLine), $transaction->getCurrencyToString())); } elseif ($lineType == LineType::VAT()) { if (Util::objectUses(BaselineField::class, $transactionLine)) { $transactionLine->setBaseline(self::getField($lineElement, 'baseline', $transactionLine)); } - $transactionLine->setVatBaseTurnoverFromFloat(self::getField($lineElement, 'vatbaseturnover', $transactionLine)); - $transactionLine->setVatRepTurnoverFromFloat(self::getField($lineElement, 'vatrepturnover', $transactionLine)); - $transactionLine->setVatTurnoverFromFloat(self::getField($lineElement, 'vatturnover', $transactionLine)); + $transactionLine->setVatBaseTurnover(self::parseMoneyAttribute(self::getField($lineElement, 'vatbaseturnover', $transactionLine), $currencies['base'])); + $transactionLine->setVatRepTurnover(self::parseMoneyAttribute(self::getField($lineElement, 'vatrepturnover', $transactionLine), $currencies['reporting'])); + $transactionLine->setVatTurnover(self::parseMoneyAttribute(self::getField($lineElement, 'vatturnover', $transactionLine), $transaction->getCurrencyToString())); } elseif ($lineType == LineType::TOTAL()) { if (Util::objectUses(MatchDateField::class, $transactionLine)) { - $transactionLine->setMatchDateFromString(self::getField($lineElement, 'matchdate', $transactionLine)); + $transactionLine->setMatchDate(self::parseDateAttribute(self::getField($lineElement, 'matchdate', $transactionLine))); } if (Util::objectUses(ValueOpenField::class, $transactionLine)) { $valueOpen = self::getField($lineElement, 'valueopen', $transactionLine) ?: self::getField($lineElement, 'openvalue', $transactionLine); if ($valueOpen) { - $transactionLine->setValueOpenFromFloat($valueOpen); + $transactionLine->setValueOpen(self::parseMoneyAttribute($valueOpen, $transaction->getCurrencyToString())); } } if (Util::objectUses(VatBaseTotalField::class, $transactionLine)) { - $transactionLine->setVatBaseTotalFromFloat(self::getField($lineElement, 'vatbasetotal', $transactionLine)); + $transactionLine->setVatBaseTotal(self::parseMoneyAttribute(self::getField($lineElement, 'vatbasetotal', $transactionLine), $currencies['base'])); } if (Util::objectUses(VatRepTotalField::class, $transactionLine)) { - $transactionLine->setVatRepTotalFromFloat(self::getField($lineElement, 'vatreptotal', $transactionLine)); + $transactionLine->setVatRepTotal(self::parseMoneyAttribute(self::getField($lineElement, 'vatreptotal', $transactionLine), $currencies['reporting'])); } if (Util::objectUses(VatTotalField::class, $transactionLine)) { - $transactionLine->setVatTotalFromFloat(self::getField($lineElement, 'vattotal', $transactionLine)); + $transactionLine->setVatTotal(self::parseMoneyAttribute(self::getField($lineElement, 'vattotal', $transactionLine), $transaction->getCurrencyToString())); } } if ($lineType != LineType::TOTAL()) { if (Util::objectUses(PerformanceCountryField::class, $transactionLine)) { - $transactionLine->setPerformanceCountryFromString(self::getField($lineElement, 'performancecountry', $transactionLine)); + $transactionLine->setPerformanceCountry(self::parseObjectAttribute(\PhpTwinfield\Country::class, $transactionLine, $lineElement, 'performancecountry')); } if (Util::objectUses(PerformanceDateField::class, $transactionLine)) { - $transactionLine->setPerformanceDateFromString(self::getField($lineElement, 'performancedate', $transactionLine)); + $transactionLine->setPerformanceDate(self::parseDateAttribute(self::getField($lineElement, 'performancedate', $transactionLine))); } if (Util::objectUses(PerformanceTypeField::class, $transactionLine)) { - $transactionLine->setPerformanceTypeFromString(self::getField($lineElement, 'performancetype', $transactionLine)); + $transactionLine->setPerformanceType(self::parseEnumAttribute(\PhpTwinfield\Enums\PerformanceType::class, self::getField($lineElement, 'performancetype', $transactionLine))); } if (Util::objectUses(PerformanceVatNumberField::class, $transactionLine)) { $transactionLine->setPerformanceVatNumber(self::getField($lineElement, 'performancevatnumber', $transactionLine)); } - $transactionLine->setVatCodeFromString(self::getField($lineElement, 'vatcode', $transactionLine)); + $transactionLine->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $transactionLine, $lineElement, 'vatcode')); } $transaction->addLine($transactionLine); diff --git a/src/Office.php b/src/Office.php index c8839810..59380bcb 100644 --- a/src/Office.php +++ b/src/Office.php @@ -6,7 +6,9 @@ use PhpTwinfield\Fields\CreatedField; use PhpTwinfield\Fields\ModifiedField; use PhpTwinfield\Fields\NameField; +use PhpTwinfield\Fields\Office\BaseCurrencyField; use PhpTwinfield\Fields\Office\CountryCodeField; +use PhpTwinfield\Fields\Office\ReportingCurrencyField; use PhpTwinfield\Fields\Office\VatFirstQuarterStartsInField; use PhpTwinfield\Fields\Office\VatPeriodField; use PhpTwinfield\Fields\ShortNameField; @@ -16,11 +18,13 @@ class Office extends BaseObject { + use BaseCurrencyField; use CodeField; use CountryCodeField; use CreatedField; use ModifiedField; use NameField; + use ReportingCurrencyField; use ShortNameField; use StatusField; use TouchedField; From 66fa961ac8056c483f3171706c630c1be9f31e2f Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 16 Jun 2019 23:26:45 +0200 Subject: [PATCH 301/388] Upload --- src/Fields/Office/BaseCurrencyField.php | 2 +- src/Fields/Office/ReportingCurrencyField.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Fields/Office/BaseCurrencyField.php b/src/Fields/Office/BaseCurrencyField.php index e429ddea..5804e061 100644 --- a/src/Fields/Office/BaseCurrencyField.php +++ b/src/Fields/Office/BaseCurrencyField.php @@ -1,6 +1,6 @@ Date: Wed, 19 Jun 2019 20:49:26 +0200 Subject: [PATCH 302/388] Update BankTransactionIntegrationTest.php --- .../BankTransactionIntegrationTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index 4d33c48e..2f424793 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -7,6 +7,7 @@ use PhpTwinfield\ApiConnectors\TransactionApiConnector; use PhpTwinfield\BankTransaction; use PhpTwinfield\BankTransactionLine; +use PhpTwinfield\Currency; use PhpTwinfield\DomDocuments\TransactionsDocument; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\Destiny; @@ -35,6 +36,19 @@ protected function setUp() parent::setUp(); $this->transactionApiConnector = new TransactionApiConnector($this->connection); + + $baseCurrency = new Currency; + $baseCurrency->setCode('EUR'); + $reportingCurrency = new Currency; + $reportingCurrency->setCode('USD'); + + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class); + $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { + $office = new Office; + $office->setBaseCurrency($baseCurrency); + $office->setReportingCurrency($reportingCurrency); + return $office; + }); } public function testGetBankTransactionWorks() From 3270e40c598ab2da3cf8215048effdc84a11c604 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 19 Jun 2019 21:00:43 +0200 Subject: [PATCH 303/388] Update BankTransactionIntegrationTest.php --- .../BankTransactionIntegrationTest.php | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index 2f424793..afd8bf41 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -37,17 +37,9 @@ protected function setUp() $this->transactionApiConnector = new TransactionApiConnector($this->connection); - $baseCurrency = new Currency; - $baseCurrency->setCode('EUR'); - $reportingCurrency = new Currency; - $reportingCurrency->setCode('USD'); - - $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class); - $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { - $office = new Office; - $office->setBaseCurrency($baseCurrency); - $office->setReportingCurrency($reportingCurrency); - return $office; + $mockBaseMapper = \Mockery::mock('overload:'.BaseMapper::class); + $mockBaseMapper->shouldReceive('getOfficeCurrencies')->andReturnUsing(function() { + return ["base" => 'EUR', "reporting" => 'USD']; }); } From 477919d6fdb51678b2629b4991b129d7650484eb Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 19 Jun 2019 21:10:42 +0200 Subject: [PATCH 304/388] Upload --- src/Mappers/TransactionMapper.php | 1 + tests/IntegrationTests/BankTransactionIntegrationTest.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 49dc85e5..ebbd4786 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -5,6 +5,7 @@ use PhpTwinfield\BankTransaction; use PhpTwinfield\BaseTransaction; use PhpTwinfield\CashTransaction; +use PhpTwinfield\Enums\LineType; use PhpTwinfield\Exception; use PhpTwinfield\Fields\DueDateField; use PhpTwinfield\Fields\FreeText1Field; diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index afd8bf41..03f17397 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -7,7 +7,7 @@ use PhpTwinfield\ApiConnectors\TransactionApiConnector; use PhpTwinfield\BankTransaction; use PhpTwinfield\BankTransactionLine; -use PhpTwinfield\Currency; +use PhpTwinfield\BaseMapper; use PhpTwinfield\DomDocuments\TransactionsDocument; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\Destiny; From 1898b761b8cb1cc3da658001c83c4cdf9cb4c585 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 19 Jun 2019 21:27:25 +0200 Subject: [PATCH 305/388] Update BankTransactionIntegrationTest.php --- tests/IntegrationTests/BankTransactionIntegrationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index 03f17397..d2736759 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -7,12 +7,12 @@ use PhpTwinfield\ApiConnectors\TransactionApiConnector; use PhpTwinfield\BankTransaction; use PhpTwinfield\BankTransactionLine; -use PhpTwinfield\BaseMapper; use PhpTwinfield\DomDocuments\TransactionsDocument; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\Destiny; use PhpTwinfield\Enums\LineType; use PhpTwinfield\Enums\MatchStatus; +use PhpTwinfield\Mappers\BaseMapper; use PhpTwinfield\Mappers\TransactionMapper; use PhpTwinfield\Office; use PhpTwinfield\Response\Response; From 3d5afdaeb1371033c74b368d8a1f86059608d912 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 19 Jun 2019 21:30:30 +0200 Subject: [PATCH 306/388] Update BankTransactionIntegrationTest.php --- tests/IntegrationTests/BankTransactionIntegrationTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index d2736759..ea19dee5 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -37,7 +37,7 @@ protected function setUp() $this->transactionApiConnector = new TransactionApiConnector($this->connection); - $mockBaseMapper = \Mockery::mock('overload:'.BaseMapper::class); + $mockBaseMapper = \Mockery::mock('overload:'.BaseMapper::class)->shouldIgnoreMissing(); $mockBaseMapper->shouldReceive('getOfficeCurrencies')->andReturnUsing(function() { return ["base" => 'EUR', "reporting" => 'USD']; }); From c4221e943a22092ca59419319f5c01b3219c329d Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 19 Jun 2019 21:42:42 +0200 Subject: [PATCH 307/388] Update CustomerIntegrationTest.php --- tests/IntegrationTests/CustomerIntegrationTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index c95465ab..1dde47fc 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -9,6 +9,7 @@ use PhpTwinfield\CustomerCollectMandate; use PhpTwinfield\CustomerFinancials; use PhpTwinfield\DomDocuments\CustomersDocument; +use PhpTwinfield\Mappers\BaseMapper; use PhpTwinfield\Mappers\CustomerMapper; use PhpTwinfield\Office; use PhpTwinfield\Response\Response; @@ -37,6 +38,11 @@ protected function setUp() parent::setUp(); $this->customerApiConnector = new CustomerApiConnector($this->connection); + + $mockBaseMapper = \Mockery::mock('overload:'.BaseMapper::class)->shouldIgnoreMissing(); + $mockBaseMapper->shouldReceive('getOfficeCurrencies')->andReturnUsing(function() { + return ["base" => 'EUR', "reporting" => 'USD']; + }); } public function testGetCustomerWorks() From 8a5cf0804f3438f7c3799a070c933c638aa7eb2d Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 19 Jun 2019 21:50:45 +0200 Subject: [PATCH 308/388] Upload --- tests/IntegrationTests/BankTransactionIntegrationTest.php | 2 +- tests/IntegrationTests/CustomerIntegrationTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index ea19dee5..ae29a5a4 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -40,7 +40,7 @@ protected function setUp() $mockBaseMapper = \Mockery::mock('overload:'.BaseMapper::class)->shouldIgnoreMissing(); $mockBaseMapper->shouldReceive('getOfficeCurrencies')->andReturnUsing(function() { return ["base" => 'EUR', "reporting" => 'USD']; - }); + })->once(); } public function testGetBankTransactionWorks() diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 1dde47fc..2788a95f 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -42,7 +42,7 @@ protected function setUp() $mockBaseMapper = \Mockery::mock('overload:'.BaseMapper::class)->shouldIgnoreMissing(); $mockBaseMapper->shouldReceive('getOfficeCurrencies')->andReturnUsing(function() { return ["base" => 'EUR', "reporting" => 'USD']; - }); + })->once(); } public function testGetCustomerWorks() From 63f9ac071456b4080f75d7d96e23baa149868173 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 19 Jun 2019 21:59:44 +0200 Subject: [PATCH 309/388] Upload --- tests/IntegrationTests/BankTransactionIntegrationTest.php | 4 ++-- tests/IntegrationTests/CustomerIntegrationTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index ae29a5a4..d3d3dd3d 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -37,10 +37,10 @@ protected function setUp() $this->transactionApiConnector = new TransactionApiConnector($this->connection); - $mockBaseMapper = \Mockery::mock('overload:'.BaseMapper::class)->shouldIgnoreMissing(); + $mockBaseMapper = \Mockery::mock(BaseMapper::class)->makePartial(); $mockBaseMapper->shouldReceive('getOfficeCurrencies')->andReturnUsing(function() { return ["base" => 'EUR', "reporting" => 'USD']; - })->once(); + }); } public function testGetBankTransactionWorks() diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 2788a95f..fdbafe51 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -39,10 +39,10 @@ protected function setUp() $this->customerApiConnector = new CustomerApiConnector($this->connection); - $mockBaseMapper = \Mockery::mock('overload:'.BaseMapper::class)->shouldIgnoreMissing(); + $mockBaseMapper = \Mockery::mock(BaseMapper::class)->makePartial(); $mockBaseMapper->shouldReceive('getOfficeCurrencies')->andReturnUsing(function() { return ["base" => 'EUR', "reporting" => 'USD']; - })->once(); + }); } public function testGetCustomerWorks() From b3c534150ab60200e6bb07445f1de7b379e546c1 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 19 Jun 2019 22:02:46 +0200 Subject: [PATCH 310/388] Upload --- tests/IntegrationTests/BankTransactionIntegrationTest.php | 2 +- tests/IntegrationTests/CustomerIntegrationTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index d3d3dd3d..4f121008 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -37,7 +37,7 @@ protected function setUp() $this->transactionApiConnector = new TransactionApiConnector($this->connection); - $mockBaseMapper = \Mockery::mock(BaseMapper::class)->makePartial(); + $mockBaseMapper = \Mockery::mock(BaseMapper::class)->makePartial()->shouldAllowMockingProtectedMethods(); $mockBaseMapper->shouldReceive('getOfficeCurrencies')->andReturnUsing(function() { return ["base" => 'EUR', "reporting" => 'USD']; }); diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index fdbafe51..f389d41d 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -39,7 +39,7 @@ protected function setUp() $this->customerApiConnector = new CustomerApiConnector($this->connection); - $mockBaseMapper = \Mockery::mock(BaseMapper::class)->makePartial(); + $mockBaseMapper = \Mockery::mock(BaseMapper::class)->makePartial()->shouldAllowMockingProtectedMethods(); $mockBaseMapper->shouldReceive('getOfficeCurrencies')->andReturnUsing(function() { return ["base" => 'EUR', "reporting" => 'USD']; }); From 1c9d8d047dde791096f7797129b9c7bd791fc17e Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 19 Jun 2019 22:12:15 +0200 Subject: [PATCH 311/388] Upload --- src/Mappers/BaseMapper.php | 8 ++++---- .../BankTransactionIntegrationTest.php | 17 +++++++++++++---- .../CustomerIntegrationTest.php | 6 ------ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index 5cf15e7d..20565d17 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -65,11 +65,11 @@ protected static function getOfficeCurrencies(AuthenticatedConnection $connectio $currencies = ["base" => '', "reporting" => '']; $officeApiConnector = new OfficeApiConnector($connection); - $office = $officeApiConnector->get($office->getCode()); + $fullOffice = $officeApiConnector->get($office->getCode()); - if ($office->getResult() == 1) { - $currencies['base'] = $office->getBaseCurrencyToString(); - $currencies['reporting'] = $office->getReportingCurrencyToString(); + if ($fullOffice->getResult() == 1) { + $currencies['base'] = $fullOffice->getBaseCurrencyToString(); + $currencies['reporting'] = $fullOffice->getReportingCurrencyToString(); } return $currencies; diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index 4f121008..6edc0615 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -4,15 +4,16 @@ use DateTimeImmutable; use Money\Money; +use PhpTwinfield\ApiConnectors\OfficeApiConnector; use PhpTwinfield\ApiConnectors\TransactionApiConnector; use PhpTwinfield\BankTransaction; use PhpTwinfield\BankTransactionLine; +use PhpTwinfield\Currency; use PhpTwinfield\DomDocuments\TransactionsDocument; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\Destiny; use PhpTwinfield\Enums\LineType; use PhpTwinfield\Enums\MatchStatus; -use PhpTwinfield\Mappers\BaseMapper; use PhpTwinfield\Mappers\TransactionMapper; use PhpTwinfield\Office; use PhpTwinfield\Response\Response; @@ -37,9 +38,17 @@ protected function setUp() $this->transactionApiConnector = new TransactionApiConnector($this->connection); - $mockBaseMapper = \Mockery::mock(BaseMapper::class)->makePartial()->shouldAllowMockingProtectedMethods(); - $mockBaseMapper->shouldReceive('getOfficeCurrencies')->andReturnUsing(function() { - return ["base" => 'EUR', "reporting" => 'USD']; + $baseCurrency = new Currency; + $baseCurrency->setCode('EUR'); + $reportingCurrency = new Currency; + $reportingCurrency->setCode('USD'); + + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class); + $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { + $office = new Office; + $office->setBaseCurrency($baseCurrency); + $office->setReportingCurrency($reportingCurrency); + return $office; }); } diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index f389d41d..c95465ab 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -9,7 +9,6 @@ use PhpTwinfield\CustomerCollectMandate; use PhpTwinfield\CustomerFinancials; use PhpTwinfield\DomDocuments\CustomersDocument; -use PhpTwinfield\Mappers\BaseMapper; use PhpTwinfield\Mappers\CustomerMapper; use PhpTwinfield\Office; use PhpTwinfield\Response\Response; @@ -38,11 +37,6 @@ protected function setUp() parent::setUp(); $this->customerApiConnector = new CustomerApiConnector($this->connection); - - $mockBaseMapper = \Mockery::mock(BaseMapper::class)->makePartial()->shouldAllowMockingProtectedMethods(); - $mockBaseMapper->shouldReceive('getOfficeCurrencies')->andReturnUsing(function() { - return ["base" => 'EUR', "reporting" => 'USD']; - }); } public function testGetCustomerWorks() From 62ec81780c1e8677e727bd8be8ead4a334c47215 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 19 Jun 2019 22:22:27 +0200 Subject: [PATCH 312/388] Update BankTransactionIntegrationTest.php --- .../BankTransactionIntegrationTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index 6edc0615..3cd57cf1 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -38,13 +38,13 @@ protected function setUp() $this->transactionApiConnector = new TransactionApiConnector($this->connection); - $baseCurrency = new Currency; - $baseCurrency->setCode('EUR'); - $reportingCurrency = new Currency; - $reportingCurrency->setCode('USD'); - $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class); $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { + $baseCurrency = new Currency; + $baseCurrency->setCode('EUR'); + $reportingCurrency = new Currency; + $reportingCurrency->setCode('USD'); + $office = new Office; $office->setBaseCurrency($baseCurrency); $office->setReportingCurrency($reportingCurrency); From 85545934103a51604ba47edb9002c8b7462c7b5a Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 19 Jun 2019 22:27:14 +0200 Subject: [PATCH 313/388] Upload --- tests/IntegrationTests/BankTransactionIntegrationTest.php | 5 +++++ tests/IntegrationTests/InvoiceIntegrationTest.php | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index 3cd57cf1..b1704998 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -46,6 +46,7 @@ protected function setUp() $reportingCurrency->setCode('USD'); $office = new Office; + $office->setResult(1); $office->setBaseCurrency($baseCurrency); $office->setReportingCurrency($reportingCurrency); return $office; @@ -207,4 +208,8 @@ protected function getSuccessfulResponse(): Response ' ); } + + public function tearDown() { + \Mockery::close(); + } } diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 2ab2f5ea..4d24ef0b 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -248,4 +248,8 @@ protected function getSuccessfulResponse(): Response ' ); } + + public function tearDown() { + \Mockery::close(); + } } From 1d431050f384e605ea68cdab292bfca8902d5c1c Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 19 Jun 2019 22:36:25 +0200 Subject: [PATCH 314/388] Upload --- src/Mappers/TransactionMapper.php | 2 +- .../BankTransactionIntegrationTest.php | 4 ---- .../CashTransactionIntegrationTest.php | 16 ++++++++++++++++ .../IntegrationTests/CustomerIntegrationTest.php | 15 +++++++++++++++ .../JournalTransactionIntegrationTest.php | 16 ++++++++++++++++ .../PurchaseTransactionIntegrationTest.php | 16 ++++++++++++++++ .../SalesTransactionIntegrationTest.php | 16 ++++++++++++++++ 7 files changed, 80 insertions(+), 5 deletions(-) diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index ebbd4786..6498b7c6 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -153,7 +153,7 @@ public static function map(string $transactionClassName, Response $response, Aut ->setValue(self::parseMoneyAttribute(self::getField($lineElement, 'value', $transactionLine), $transaction->getCurrencyToString())) ->setDebitCredit(self::parseEnumAttribute(\PhpTwinfield\Enums\DebitCredit::class, self::getField($lineElement, 'debitcredit', $transactionLine))) ->setDescription(self::getField($lineElement, 'description', $transactionLine)) - ->setDestOfficeFromString(self::parseObjectAttribute(\PhpTwinfield\Office::class, $transactionLine, $lineElement, 'destoffice')) + ->setDestOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $transactionLine, $lineElement, 'destoffice')) ->setDim1(self::parseObjectAttribute(\PhpTwinfield\Dummy::class, $transactionLine, $lineElement, 'dim1')) ->setId($lineElement->getAttribute('id')) ->setLineType(self::parseEnumAttribute(\PhpTwinfield\Enums\LineType::class, $lineType)) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index b1704998..62d5401b 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -208,8 +208,4 @@ protected function getSuccessfulResponse(): Response ' ); } - - public function tearDown() { - \Mockery::close(); - } } diff --git a/tests/IntegrationTests/CashTransactionIntegrationTest.php b/tests/IntegrationTests/CashTransactionIntegrationTest.php index 1d09e509..db059cb7 100644 --- a/tests/IntegrationTests/CashTransactionIntegrationTest.php +++ b/tests/IntegrationTests/CashTransactionIntegrationTest.php @@ -4,9 +4,11 @@ use DateTimeImmutable; use Money\Money; +use PhpTwinfield\ApiConnectors\OfficeApiConnector; use PhpTwinfield\ApiConnectors\TransactionApiConnector; use PhpTwinfield\CashTransaction; use PhpTwinfield\CashTransactionLine; +use PhpTwinfield\Currency; use PhpTwinfield\DomDocuments\TransactionsDocument; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\Destiny; @@ -35,6 +37,20 @@ protected function setUp() parent::setUp(); $this->transactionApiConnector = new TransactionApiConnector($this->connection); + + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class); + $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { + $baseCurrency = new Currency; + $baseCurrency->setCode('EUR'); + $reportingCurrency = new Currency; + $reportingCurrency->setCode('USD'); + + $office = new Office; + $office->setResult(1); + $office->setBaseCurrency($baseCurrency); + $office->setReportingCurrency($reportingCurrency); + return $office; + }); } public function testGetCashTransactionWorks() diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index c95465ab..30316bae 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\IntegrationTests; use PhpTwinfield\ApiConnectors\CustomerApiConnector; +use PhpTwinfield\ApiConnectors\OfficeApiConnector; use PhpTwinfield\Customer; use PhpTwinfield\CustomerAddress; use PhpTwinfield\CustomerBank; @@ -37,6 +38,20 @@ protected function setUp() parent::setUp(); $this->customerApiConnector = new CustomerApiConnector($this->connection); + + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class); + $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { + $baseCurrency = new Currency; + $baseCurrency->setCode('EUR'); + $reportingCurrency = new Currency; + $reportingCurrency->setCode('USD'); + + $office = new Office; + $office->setResult(1); + $office->setBaseCurrency($baseCurrency); + $office->setReportingCurrency($reportingCurrency); + return $office; + }); } public function testGetCustomerWorks() diff --git a/tests/IntegrationTests/JournalTransactionIntegrationTest.php b/tests/IntegrationTests/JournalTransactionIntegrationTest.php index 11c77efb..cb8dab64 100644 --- a/tests/IntegrationTests/JournalTransactionIntegrationTest.php +++ b/tests/IntegrationTests/JournalTransactionIntegrationTest.php @@ -3,7 +3,9 @@ namespace PhpTwinfield\IntegrationTests; use Money\Money; +use PhpTwinfield\ApiConnectors\OfficeApiConnector; use PhpTwinfield\ApiConnectors\TransactionApiConnector; +use PhpTwinfield\Currency; use PhpTwinfield\DomDocuments\TransactionsDocument; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\Destiny; @@ -34,6 +36,20 @@ protected function setUp() parent::setUp(); $this->transactionApiConnector = new TransactionApiConnector($this->connection); + + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class); + $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { + $baseCurrency = new Currency; + $baseCurrency->setCode('EUR'); + $reportingCurrency = new Currency; + $reportingCurrency->setCode('USD'); + + $office = new Office; + $office->setResult(1); + $office->setBaseCurrency($baseCurrency); + $office->setReportingCurrency($reportingCurrency); + return $office; + }); } public function testGetJournalTransactionWorks() diff --git a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php index bfb9bfee..0902c9a7 100644 --- a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php +++ b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php @@ -3,7 +3,9 @@ namespace PhpTwinfield\IntegrationTests; use Money\Money; +use PhpTwinfield\ApiConnectors\OfficeApiConnector; use PhpTwinfield\ApiConnectors\TransactionApiConnector; +use PhpTwinfield\Currency; use PhpTwinfield\DomDocuments\TransactionsDocument; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\Destiny; @@ -33,6 +35,20 @@ protected function setUp() { parent::setUp(); $this->transactionApiConnector = new TransactionApiConnector($this->connection); + + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class); + $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { + $baseCurrency = new Currency; + $baseCurrency->setCode('EUR'); + $reportingCurrency = new Currency; + $reportingCurrency->setCode('USD'); + + $office = new Office; + $office->setResult(1); + $office->setBaseCurrency($baseCurrency); + $office->setReportingCurrency($reportingCurrency); + return $office; + }); } public function testGetPurchaseTransactionWorks() diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index c6dcec13..e4d5cd30 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -3,7 +3,9 @@ namespace PhpTwinfield\IntegrationTests; use Money\Money; +use PhpTwinfield\ApiConnectors\OfficeApiConnector; use PhpTwinfield\ApiConnectors\TransactionApiConnector; +use PhpTwinfield\Currency; use PhpTwinfield\DomDocuments\TransactionsDocument; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\Destiny; @@ -34,6 +36,20 @@ protected function setUp() parent::setUp(); $this->transactionApiConnector = new TransactionApiConnector($this->connection); + + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class); + $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { + $baseCurrency = new Currency; + $baseCurrency->setCode('EUR'); + $reportingCurrency = new Currency; + $reportingCurrency->setCode('USD'); + + $office = new Office; + $office->setResult(1); + $office->setBaseCurrency($baseCurrency); + $office->setReportingCurrency($reportingCurrency); + return $office; + }); } public function testGetSalesTransactionWorks() From 3f6603b2b8e63d1a9c0f7c79c24e8d42d77e849f Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 19 Jun 2019 22:44:35 +0200 Subject: [PATCH 315/388] Upload --- tests/IntegrationTests/BankTransactionIntegrationTest.php | 6 +++--- tests/IntegrationTests/CashTransactionIntegrationTest.php | 6 +++--- tests/IntegrationTests/CustomerIntegrationTest.php | 1 + tests/IntegrationTests/InvoiceIntegrationTest.php | 4 ---- .../IntegrationTests/JournalTransactionIntegrationTest.php | 4 ++-- tests/IntegrationTests/OfficeIntegrationTest.php | 2 ++ .../IntegrationTests/PurchaseTransactionIntegrationTest.php | 6 +++--- tests/IntegrationTests/SalesTransactionIntegrationTest.php | 6 +++--- 8 files changed, 17 insertions(+), 18 deletions(-) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index 62d5401b..e69084f7 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -96,7 +96,7 @@ public function testGetBankTransactionWorks() $this->assertEquals(Money::EUR(43555), $totalLine->getValue()); $this->assertEquals(Money::EUR(43555), $totalLine->getBaseValue()); $this->assertSame(1.0, $totalLine->getRate()); - $this->assertEquals(Money::EUR(65333), $totalLine->getRepValue()); + $this->assertEquals(Money::USD(65333), $totalLine->getRepValue()); $this->assertSame(1.500000000, $totalLine->getRepRate()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); $this->assertSame($ReflectObject->getConstant('NOTMATCHABLE'), (string)$totalLine->getMatchStatus()); @@ -119,14 +119,14 @@ public function testGetBankTransactionWorks() $this->assertEquals(Money::EUR(43555), $detailLine->getValue()); $this->assertEquals(Money::EUR(43555), $totalLine->getBaseValue()); $this->assertSame(1.0, $totalLine->getRate()); - $this->assertEquals(Money::EUR(65333), $totalLine->getRepValue()); + $this->assertEquals(Money::USD(65333), $totalLine->getRepValue()); $this->assertSame(1.500000000, $totalLine->getRepRate()); $this->assertSame('Invoice paid', $detailLine->getDescription()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); $this->assertSame($ReflectObject->getConstant('AVAILABLE'), (string)$detailLine->getMatchStatus()); $this->assertSame(2, $detailLine->getMatchLevel()); $this->assertEquals(Money::EUR(43555), $detailLine->getBaseValueOpen()); - $this->assertEquals(Money::EUR(65333), $detailLine->getRepValue()); + $this->assertEquals(Money::USD(65333), $detailLine->getRepValue()); $this->assertNull($detailLine->getVatCodeToString()); $this->assertEquals(Money::EUR(0), $detailLine->getVatValue()); $this->assertNull($detailLine->getVatTotal()); diff --git a/tests/IntegrationTests/CashTransactionIntegrationTest.php b/tests/IntegrationTests/CashTransactionIntegrationTest.php index db059cb7..aefbf87d 100644 --- a/tests/IntegrationTests/CashTransactionIntegrationTest.php +++ b/tests/IntegrationTests/CashTransactionIntegrationTest.php @@ -96,7 +96,7 @@ public function testGetCashTransactionWorks() $this->assertEquals(Money::EUR(43555), $totalLine->getValue()); $this->assertEquals(Money::EUR(43555), $totalLine->getBaseValue()); $this->assertSame(1.0, $totalLine->getRate()); - $this->assertEquals(Money::EUR(65333), $totalLine->getRepValue()); + $this->assertEquals(Money::USD(65333), $totalLine->getRepValue()); $this->assertSame(1.500000000, $totalLine->getRepRate()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); $this->assertSame($ReflectObject->getConstant('NOTMATCHABLE'), (string)$totalLine->getMatchStatus()); @@ -119,14 +119,14 @@ public function testGetCashTransactionWorks() $this->assertEquals(Money::EUR(43555), $detailLine->getValue()); $this->assertEquals(Money::EUR(43555), $totalLine->getBaseValue()); $this->assertSame(1.0, $totalLine->getRate()); - $this->assertEquals(Money::EUR(65333), $totalLine->getRepValue()); + $this->assertEquals(Money::USD(65333), $totalLine->getRepValue()); $this->assertSame(1.500000000, $totalLine->getRepRate()); $this->assertSame('Invoice paid', $detailLine->getDescription()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); $this->assertSame($ReflectObject->getConstant('AVAILABLE'), (string)$detailLine->getMatchStatus()); $this->assertSame(2, $detailLine->getMatchLevel()); $this->assertEquals(Money::EUR(43555), $detailLine->getBaseValueOpen()); - $this->assertEquals(Money::EUR(65333), $detailLine->getRepValue()); + $this->assertEquals(Money::USD(65333), $detailLine->getRepValue()); $this->assertNull($detailLine->getVatCodeToString()); $this->assertEquals(Money::EUR(0), $detailLine->getVatValue()); $this->assertNull($detailLine->getVatTotal()); diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 30316bae..4c9c9828 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -4,6 +4,7 @@ use PhpTwinfield\ApiConnectors\CustomerApiConnector; use PhpTwinfield\ApiConnectors\OfficeApiConnector; +use PhpTwinfield\Currency; use PhpTwinfield\Customer; use PhpTwinfield\CustomerAddress; use PhpTwinfield\CustomerBank; diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 4d24ef0b..2ab2f5ea 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -248,8 +248,4 @@ protected function getSuccessfulResponse(): Response ' ); } - - public function tearDown() { - \Mockery::close(); - } } diff --git a/tests/IntegrationTests/JournalTransactionIntegrationTest.php b/tests/IntegrationTests/JournalTransactionIntegrationTest.php index cb8dab64..4bc6dc66 100644 --- a/tests/IntegrationTests/JournalTransactionIntegrationTest.php +++ b/tests/IntegrationTests/JournalTransactionIntegrationTest.php @@ -94,7 +94,7 @@ public function testGetJournalTransactionWorks() $this->assertEquals(Money::EUR(43555), $detailLine1->getValue()); $this->assertEquals(Money::EUR(43555), $detailLine1->getBaseValue()); $this->assertSame(1.0, $detailLine1->getRate()); - $this->assertEquals(Money::EUR(65333), $detailLine1->getRepValue()); + $this->assertEquals(Money::USD(65333), $detailLine1->getRepValue()); $this->assertSame(1.500000000, $detailLine1->getRepRate()); $this->assertNull($detailLine1->getDescription()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); @@ -117,7 +117,7 @@ public function testGetJournalTransactionWorks() $this->assertEquals(Money::EUR(43555), $detailLine2->getValue()); $this->assertEquals(Money::EUR(43555), $detailLine2->getBaseValue()); $this->assertSame(1.0, $detailLine2->getRate()); - $this->assertEquals(Money::EUR(65333), $detailLine2->getRepValue()); + $this->assertEquals(Money::USD(65333), $detailLine2->getRepValue()); $this->assertSame(1.500000000, $detailLine2->getRepRate()); $this->assertSame('Invoice paid', $detailLine2->getDescription()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); diff --git a/tests/IntegrationTests/OfficeIntegrationTest.php b/tests/IntegrationTests/OfficeIntegrationTest.php index f35e08f3..ab2d3081 100644 --- a/tests/IntegrationTests/OfficeIntegrationTest.php +++ b/tests/IntegrationTests/OfficeIntegrationTest.php @@ -15,6 +15,8 @@ class OfficeIntegrationTest extends BaseIntegrationTest protected function setUp() { parent::setUp(); + + unset($mockOfficeApiConnector); $this->officeApiConnector = new OfficeApiConnector($this->connection); } diff --git a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php index 0902c9a7..7bc14aeb 100644 --- a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php +++ b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php @@ -95,7 +95,7 @@ public function testGetPurchaseTransactionWorks() $this->assertEquals(Money::EUR(12100), $totalLine->getValue()); $this->assertEquals(Money::EUR(12100), $totalLine->getBaseValue()); $this->assertSame(1.0, $totalLine->getRate()); - $this->assertEquals(Money::EUR(15653), $totalLine->getRepValue()); + $this->assertEquals(Money::USD(15653), $totalLine->getRepValue()); $this->assertSame(1.293600000, $totalLine->getRepRate()); $this->assertNull($totalLine->getDescription()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); @@ -116,7 +116,7 @@ public function testGetPurchaseTransactionWorks() $this->assertEquals(Money::EUR(10000), $detailLine->getValue()); $this->assertEquals(Money::EUR(10000), $detailLine->getBaseValue()); $this->assertSame(1.0, $detailLine->getRate()); - $this->assertEquals(Money::EUR(12936), $detailLine->getRepValue()); + $this->assertEquals(Money::USD(12936), $detailLine->getRepValue()); $this->assertSame(1.293600000, $detailLine->getRepRate()); $this->assertSame('Outfit', $detailLine->getDescription()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); @@ -137,7 +137,7 @@ public function testGetPurchaseTransactionWorks() $this->assertEquals(Money::EUR(2100), $vatLine->getValue()); $this->assertEquals(Money::EUR(2100), $vatLine->getBaseValue()); $this->assertSame(1.0, $vatLine->getRate()); - $this->assertEquals(Money::EUR(2717), $vatLine->getRepValue()); + $this->assertEquals(Money::USD(2717), $vatLine->getRepValue()); $this->assertSame(1.293600000, $vatLine->getRepRate()); $this->assertNull($vatLine->getDescription()); $this->assertNull($vatLine->getMatchStatus()); diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index e4d5cd30..70a87620 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -96,7 +96,7 @@ public function testGetSalesTransactionWorks() $this->assertEquals(Money::EUR(12100), $totalLine->getValue()); $this->assertEquals(Money::EUR(12100), $totalLine->getBaseValue()); $this->assertSame(1.0, $totalLine->getRate()); - $this->assertEquals(Money::EUR(15653), $totalLine->getRepValue()); + $this->assertEquals(Money::USD(15653), $totalLine->getRepValue()); $this->assertSame(1.293600000, $totalLine->getRepRate()); $this->assertNull($totalLine->getDescription()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); @@ -121,7 +121,7 @@ public function testGetSalesTransactionWorks() $this->assertEquals(Money::EUR(10000), $detailLine->getValue()); $this->assertEquals(Money::EUR(10000), $detailLine->getBaseValue()); $this->assertSame(1.0, $detailLine->getRate()); - $this->assertEquals(Money::EUR(12936), $detailLine->getRepValue()); + $this->assertEquals(Money::USD(12936), $detailLine->getRepValue()); $this->assertSame(1.293600000, $detailLine->getRepRate()); $this->assertSame('Outfit', $detailLine->getDescription()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\MatchStatus'); @@ -147,7 +147,7 @@ public function testGetSalesTransactionWorks() $this->assertEquals(Money::EUR(2100), $vatLine->getValue()); $this->assertEquals(Money::EUR(2100), $vatLine->getBaseValue()); $this->assertSame(1.0, $vatLine->getRate()); - $this->assertEquals(Money::EUR(2717), $vatLine->getRepValue()); + $this->assertEquals(Money::USD(2717), $vatLine->getRepValue()); $this->assertSame(1.293600000, $vatLine->getRepRate()); $this->assertNull($vatLine->getDescription()); $this->assertNull($vatLine->getMatchStatus()); From ac1f183ae9ba91e741965a3eaeae4f48758c1d31 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 19 Jun 2019 22:54:52 +0200 Subject: [PATCH 316/388] Upload --- tests/IntegrationTests/BankTransactionIntegrationTest.php | 4 ++-- tests/IntegrationTests/CashTransactionIntegrationTest.php | 4 ++-- tests/IntegrationTests/JournalTransactionIntegrationTest.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index e69084f7..40cb3c34 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -104,7 +104,7 @@ public function testGetBankTransactionWorks() $this->assertNull($totalLine->getBaseValueOpen()); $this->assertNull($totalLine->getVatCode()); $this->assertNull($totalLine->getVatValue()); - $this->assertEquals(Money::EUR(0), $totalLine->getVatTotal()); + $this->assertNull($totalLine->getVatTotal()); $this->assertEquals(Money::EUR(0), $totalLine->getVatBaseTotal()); $this->assertNull($totalLine->getPerformanceType()); $this->assertNull($totalLine->getPerformanceCountry()); @@ -128,7 +128,7 @@ public function testGetBankTransactionWorks() $this->assertEquals(Money::EUR(43555), $detailLine->getBaseValueOpen()); $this->assertEquals(Money::USD(65333), $detailLine->getRepValue()); $this->assertNull($detailLine->getVatCodeToString()); - $this->assertEquals(Money::EUR(0), $detailLine->getVatValue()); + $this->assertNull($detailLine->getVatValue()); $this->assertNull($detailLine->getVatTotal()); $this->assertNull($detailLine->getVatBaseTotal()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); diff --git a/tests/IntegrationTests/CashTransactionIntegrationTest.php b/tests/IntegrationTests/CashTransactionIntegrationTest.php index aefbf87d..2a88be57 100644 --- a/tests/IntegrationTests/CashTransactionIntegrationTest.php +++ b/tests/IntegrationTests/CashTransactionIntegrationTest.php @@ -104,7 +104,7 @@ public function testGetCashTransactionWorks() $this->assertNull($totalLine->getBaseValueOpen()); $this->assertNull($totalLine->getVatCode()); $this->assertNull($totalLine->getVatValue()); - $this->assertEquals(Money::EUR(0), $totalLine->getVatTotal()); + $this->assertNull($totalLine->getVatTotal()); $this->assertEquals(Money::EUR(0), $totalLine->getVatBaseTotal()); $this->assertNull($totalLine->getPerformanceType()); $this->assertNull($totalLine->getPerformanceCountry()); @@ -128,7 +128,7 @@ public function testGetCashTransactionWorks() $this->assertEquals(Money::EUR(43555), $detailLine->getBaseValueOpen()); $this->assertEquals(Money::USD(65333), $detailLine->getRepValue()); $this->assertNull($detailLine->getVatCodeToString()); - $this->assertEquals(Money::EUR(0), $detailLine->getVatValue()); + $this->assertNull($detailLine->getVatValue()); $this->assertNull($detailLine->getVatTotal()); $this->assertNull($detailLine->getVatBaseTotal()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); diff --git a/tests/IntegrationTests/JournalTransactionIntegrationTest.php b/tests/IntegrationTests/JournalTransactionIntegrationTest.php index 4bc6dc66..54703410 100644 --- a/tests/IntegrationTests/JournalTransactionIntegrationTest.php +++ b/tests/IntegrationTests/JournalTransactionIntegrationTest.php @@ -102,7 +102,7 @@ public function testGetJournalTransactionWorks() $this->assertNull($detailLine1->getMatchLevel()); $this->assertNull($detailLine1->getBaseValueOpen()); $this->assertNull($detailLine1->getVatCodeToString()); - $this->assertEquals(Money::EUR(0), $detailLine1->getVatValue()); + $this->assertNull($detailLine1->getVatValue()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); $this->assertSame($ReflectObject->getConstant('EMPTY'), (string)$detailLine1->getPerformanceType()); $this->assertNull($detailLine1->getPerformanceCountryToString()); @@ -125,7 +125,7 @@ public function testGetJournalTransactionWorks() $this->assertSame(2, $detailLine2->getMatchLevel()); $this->assertEquals(Money::EUR(43555), $detailLine2->getBaseValueOpen()); $this->assertNull($detailLine2->getVatCodeToString()); - $this->assertEquals(Money::EUR(0), $detailLine2->getVatValue()); + $this->assertNull($detailLine2->getVatValue()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); $this->assertSame($ReflectObject->getConstant('EMPTY'), (string)$detailLine2->getPerformanceType()); $this->assertNull($detailLine2->getPerformanceCountryToString()); From 87d83a9fc69fcccc2ec5ddcb4f6e8be0f3ac6f52 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 19 Jun 2019 22:57:14 +0200 Subject: [PATCH 317/388] Upload --- tests/IntegrationTests/BankTransactionIntegrationTest.php | 2 +- tests/IntegrationTests/CashTransactionIntegrationTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index 40cb3c34..1e842192 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -105,7 +105,7 @@ public function testGetBankTransactionWorks() $this->assertNull($totalLine->getVatCode()); $this->assertNull($totalLine->getVatValue()); $this->assertNull($totalLine->getVatTotal()); - $this->assertEquals(Money::EUR(0), $totalLine->getVatBaseTotal()); + $this->assertNull($totalLine->getVatBaseTotal()); $this->assertNull($totalLine->getPerformanceType()); $this->assertNull($totalLine->getPerformanceCountry()); $this->assertNull($totalLine->getPerformanceVatNumber()); diff --git a/tests/IntegrationTests/CashTransactionIntegrationTest.php b/tests/IntegrationTests/CashTransactionIntegrationTest.php index 2a88be57..3d834de7 100644 --- a/tests/IntegrationTests/CashTransactionIntegrationTest.php +++ b/tests/IntegrationTests/CashTransactionIntegrationTest.php @@ -105,7 +105,7 @@ public function testGetCashTransactionWorks() $this->assertNull($totalLine->getVatCode()); $this->assertNull($totalLine->getVatValue()); $this->assertNull($totalLine->getVatTotal()); - $this->assertEquals(Money::EUR(0), $totalLine->getVatBaseTotal()); + $this->assertNull($totalLine->getVatBaseTotal()); $this->assertNull($totalLine->getPerformanceType()); $this->assertNull($totalLine->getPerformanceCountry()); $this->assertNull($totalLine->getPerformanceVatNumber()); From edca44c50d5df11c9c5d57a17eb127b5a12df9e7 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 19 Jun 2019 23:05:38 +0200 Subject: [PATCH 318/388] Upload --- tests/IntegrationTests/BankTransactionIntegrationTest.php | 2 +- tests/IntegrationTests/CashTransactionIntegrationTest.php | 2 +- tests/IntegrationTests/CustomerIntegrationTest.php | 2 +- tests/IntegrationTests/InvoiceIntegrationTest.php | 4 ++-- tests/IntegrationTests/JournalTransactionIntegrationTest.php | 2 +- tests/IntegrationTests/OfficeIntegrationTest.php | 2 -- tests/IntegrationTests/PurchaseTransactionIntegrationTest.php | 2 +- tests/IntegrationTests/SalesTransactionIntegrationTest.php | 2 +- 8 files changed, 8 insertions(+), 10 deletions(-) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index 1e842192..2eead671 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -38,7 +38,7 @@ protected function setUp() $this->transactionApiConnector = new TransactionApiConnector($this->connection); - $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class); + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { $baseCurrency = new Currency; $baseCurrency->setCode('EUR'); diff --git a/tests/IntegrationTests/CashTransactionIntegrationTest.php b/tests/IntegrationTests/CashTransactionIntegrationTest.php index 3d834de7..e3db21fb 100644 --- a/tests/IntegrationTests/CashTransactionIntegrationTest.php +++ b/tests/IntegrationTests/CashTransactionIntegrationTest.php @@ -38,7 +38,7 @@ protected function setUp() $this->transactionApiConnector = new TransactionApiConnector($this->connection); - $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class); + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { $baseCurrency = new Currency; $baseCurrency->setCode('EUR'); diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 4c9c9828..65d5beeb 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -40,7 +40,7 @@ protected function setUp() $this->customerApiConnector = new CustomerApiConnector($this->connection); - $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class); + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { $baseCurrency = new Currency; $baseCurrency->setCode('EUR'); diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 2ab2f5ea..a52f1b95 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -38,12 +38,12 @@ protected function setUp() $this->invoiceApiConnector = new InvoiceApiConnector($this->connection); - $mockInvoiceTypeApiConnector = \Mockery::mock('overload:'.InvoiceTypeApiConnector::class); + $mockInvoiceTypeApiConnector = \Mockery::mock('overload:'.InvoiceTypeApiConnector::class)->makePartial(); $mockInvoiceTypeApiConnector->shouldReceive('getInvoiceTypeVatType')->andReturnUsing(function() { return 'exclusive'; }); - $mockArticleApiConnector = \Mockery::mock('overload:'.ArticleApiConnector::class); + $mockArticleApiConnector = \Mockery::mock('overload:'.ArticleApiConnector::class)->makePartial(); $mockArticleApiConnector->shouldReceive('get')->andReturnUsing(function() { $article = new Article; $article->setAllowChangeVatCode(true); diff --git a/tests/IntegrationTests/JournalTransactionIntegrationTest.php b/tests/IntegrationTests/JournalTransactionIntegrationTest.php index 54703410..28b941af 100644 --- a/tests/IntegrationTests/JournalTransactionIntegrationTest.php +++ b/tests/IntegrationTests/JournalTransactionIntegrationTest.php @@ -37,7 +37,7 @@ protected function setUp() $this->transactionApiConnector = new TransactionApiConnector($this->connection); - $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class); + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { $baseCurrency = new Currency; $baseCurrency->setCode('EUR'); diff --git a/tests/IntegrationTests/OfficeIntegrationTest.php b/tests/IntegrationTests/OfficeIntegrationTest.php index ab2d3081..f35e08f3 100644 --- a/tests/IntegrationTests/OfficeIntegrationTest.php +++ b/tests/IntegrationTests/OfficeIntegrationTest.php @@ -15,8 +15,6 @@ class OfficeIntegrationTest extends BaseIntegrationTest protected function setUp() { parent::setUp(); - - unset($mockOfficeApiConnector); $this->officeApiConnector = new OfficeApiConnector($this->connection); } diff --git a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php index 7bc14aeb..39ff8b36 100644 --- a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php +++ b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php @@ -36,7 +36,7 @@ protected function setUp() parent::setUp(); $this->transactionApiConnector = new TransactionApiConnector($this->connection); - $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class); + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { $baseCurrency = new Currency; $baseCurrency->setCode('EUR'); diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index 70a87620..603d7ca4 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -37,7 +37,7 @@ protected function setUp() $this->transactionApiConnector = new TransactionApiConnector($this->connection); - $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class); + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { $baseCurrency = new Currency; $baseCurrency->setCode('EUR'); From ecd678e3e9e7bc81dbe94167366abdc79aa7f548 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 19 Jun 2019 23:26:33 +0200 Subject: [PATCH 319/388] Upload --- src/Mappers/BaseMapper.php | 71 +++++++++++++--------------- src/Mappers/CustomerMapper.php | 4 +- src/Mappers/DimensionGroupMapper.php | 2 +- src/Mappers/FixedAssetMapper.php | 10 ++-- src/Mappers/SupplierMapper.php | 4 +- 5 files changed, 44 insertions(+), 47 deletions(-) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index 20565d17..5f27322a 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -115,46 +115,43 @@ protected static function parseMoneyAttribute(?float $value, ?string $currency): return Util::parseMoney($value, new Currency($currency)); } - /** @var SomeClassWithMethodsetCode $object2 */ - protected static function parseObjectAttribute(string $objectClass, $object, \DOMElement $element, string $fieldTagName, array $attributes = []) + protected static function parseUnknownEntity(bool $unknown, $object, \DOMElement $element, string $fieldTagName): string { - if ($objectClass == "DimensionGroupDimension" || $objectClass == "UnknownDimension") { - if ($objectClass == "DimensionGroupDimension") { - $type = self::getField($element, "type", $object); - } elseif ($objectClass == "UnknownDimension") { - $type = self::getAttribute($element, $fieldTagName, "dimensiontype"); - } - - switch ($type) { - case "ACT": - $objectClass = \PhpTwinfield\Activity::class; - break; - case "AST": - $objectClass = \PhpTwinfield\FixedAsset::class; - break; - case "BAS": - $objectClass = \PhpTwinfield\GeneralLedger::class; - break; - case "CRD": - $objectClass = \PhpTwinfield\Supplier::class; - break; - case "DEB": - $objectClass = \PhpTwinfield\Customer::class; - break; - case "KPL": - $objectClass = \PhpTwinfield\CostCenter::class; - break; - case "PNL": - $objectClass = \PhpTwinfield\GeneralLedger::class; - break; - case "PRJ": - $objectClass = \PhpTwinfield\Project::class; - break; - default: - throw new \InvalidArgumentException("parseObjectAttribute function does not accept \"{$objectClass}\" as valid input for the \$object argument"); - } + if ($unknown) { + $type = self::getAttribute($element, $fieldTagName, "dimensiontype"); + } else { + $type = self::getField($element, "type", $object); + } + + switch ($type) { + case "ACT": + return \PhpTwinfield\Activity::class; + case "AST": + return \PhpTwinfield\FixedAsset::class; + case "BAS": + return \PhpTwinfield\GeneralLedger::class; + case "CRD": + return \PhpTwinfield\Supplier::class; + case "DEB": + return \PhpTwinfield\Customer::class; + case "KPL": + return \PhpTwinfield\CostCenter::class; + case "PNL": + return \PhpTwinfield\GeneralLedger::class; + case "PRJ": + return \PhpTwinfield\Project::class; + default: + throw new \InvalidArgumentException("parseUnknownEntity function was unable to determine class name from \"{$type}\""); } + } + /** @var SomeClassWithMethodsetCode $object2 */ + protected static function parseObjectAttribute(string $objectClass, $object, \DOMElement $element, string $fieldTagName, array $attributes = [], ?bool $unknown = null) + { + if ($unknown !== null) { + $objectClass = self::parseUnknownEntity($unknown, $object, $element, $fieldTagName); + } + $object2 = new $objectClass(); $object2->setCode(self::getField($element, $fieldTagName, $object)); diff --git a/src/Mappers/CustomerMapper.php b/src/Mappers/CustomerMapper.php index a848c2d5..edad45ee 100644 --- a/src/Mappers/CustomerMapper.php +++ b/src/Mappers/CustomerMapper.php @@ -90,7 +90,7 @@ public static function map(Response $response, AuthenticatedConnection $connecti ->setPayCode(self::parseObjectAttribute(\PhpTwinfield\PayCode::class, $customerFinancials, $financialsElement, 'paycode', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setSubAnalyse(self::parseEnumAttribute(\PhpTwinfield\Enums\SubAnalyse::class, self::getField($financialsElement, 'subanalyse', $customerFinancials))) ->setSubstitutionLevel(self::getField($financialsElement, 'substitutionlevel', $customerFinancials)) - ->setSubstituteWith(self::parseObjectAttribute('UnknownDimension', $customerFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setSubstituteWith(self::parseObjectAttribute('UnknownDimension', $customerFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'), true)) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $customerFinancials, $financialsElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); // Set the financials elements from the financials element attributes @@ -303,7 +303,7 @@ public static function map(Response $response, AuthenticatedConnection $connecti $customerLine->setDescription(self::getField($lineElement, 'description', $customerLine)) ->setDimension1(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $customerLine, $lineElement, 'dimension1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setDimension2(self::parseObjectAttribute(\PhpTwinfield\CostCenter::class, $customerLine, $lineElement, 'dimension2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setDimension3(self::parseObjectAttribute('UnknownDimension', $customerLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setDimension3(self::parseObjectAttribute('UnknownDimension', $customerLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'), true)) ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $customerLine, $lineElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setRatio(self::getField($lineElement, 'ratio', $customerLine)) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $customerLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); diff --git a/src/Mappers/DimensionGroupMapper.php b/src/Mappers/DimensionGroupMapper.php index 15d86a54..757b6d96 100644 --- a/src/Mappers/DimensionGroupMapper.php +++ b/src/Mappers/DimensionGroupMapper.php @@ -61,7 +61,7 @@ public static function map(Response $response) // Set the dimension group dimension elements from the dimension element $dimensionGroupDimension->setType(self::parseObjectAttribute(\PhpTwinfield\DimensionType::class, $dimensionGroupDimension, $dimensionElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))); - $dimensionGroupDimension->setCode(self::parseObjectAttribute('DimensionGroupDimension', $dimensionGroupDimension, $dimensionElement, 'code', array('name' => 'setName', 'shortname' => 'setShortName'))); + $dimensionGroupDimension->setCode(self::parseObjectAttribute('DimensionGroupDimension', $dimensionGroupDimension, $dimensionElement, 'code', array('name' => 'setName', 'shortname' => 'setShortName'), false)); // Add the dimension to the dimension group $dimensiongroup->addDimension($dimensionGroupDimension); diff --git a/src/Mappers/FixedAssetMapper.php b/src/Mappers/FixedAssetMapper.php index 37fc0b9a..f12a71bd 100644 --- a/src/Mappers/FixedAssetMapper.php +++ b/src/Mappers/FixedAssetMapper.php @@ -139,11 +139,11 @@ public static function map(Response $response, AuthenticatedConnection $connecti $fixedAssetTransactionLine->setAmount(self::parseMoneyAttribute(self::getField($transactionLineElement, 'amount', $fixedAssetTransactionLine), $currencies['base'])) ->setCode(self::getField($transactionLineElement, 'code', $fixedAssetTransactionLine)) ->setDim1(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $fixedAssetTransactionLine, $transactionLineElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) - ->setDim2(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) - ->setDim3(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) - ->setDim4(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim4', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) - ->setDim5(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim5', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) - ->setDim6(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim6', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim2(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'), true)) + ->setDim3(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'), true)) + ->setDim4(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim4', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'), true)) + ->setDim5(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim5', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'), true)) + ->setDim6(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim6', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'), true)) ->setLine(self::getField($transactionLineElement, 'line', $fixedAssetTransactionLine)) ->setNumber(self::getField($transactionLineElement, 'number', $fixedAssetTransactionLine)) ->setPeriod(self::getField($transactionLineElement, 'period', $fixedAssetTransactionLine)); diff --git a/src/Mappers/SupplierMapper.php b/src/Mappers/SupplierMapper.php index a6be92ef..dba6f353 100644 --- a/src/Mappers/SupplierMapper.php +++ b/src/Mappers/SupplierMapper.php @@ -78,7 +78,7 @@ public static function map(Response $response) ->setRelationsReference(self::getField($financialsElement, 'relationsreference', $supplierFinancials)) ->setSubAnalyse(self::parseEnumAttribute(\PhpTwinfield\Enums\SubAnalyse::class, self::getField($financialsElement, 'subanalyse', $supplierFinancials))) ->setSubstitutionLevel(self::getField($financialsElement, 'substitutionlevel', $supplierFinancials)) - ->setSubstituteWith(self::parseObjectAttribute('UnknownDimension', $supplierFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setSubstituteWith(self::parseObjectAttribute('UnknownDimension', $supplierFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'), true)) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $supplierFinancials, $financialsElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); // Set the financials elements from the financials element attributes @@ -246,7 +246,7 @@ public static function map(Response $response) $supplierLine->setDescription(self::getField($lineElement, 'description', $supplierLine)) ->setDimension1(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $supplierLine, $lineElement, 'dimension1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setDimension2(self::parseObjectAttribute(\PhpTwinfield\CostCenter::class, $supplierLine, $lineElement, 'dimension2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setDimension3(self::parseObjectAttribute('UnknownDimension', $supplierLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setDimension3(self::parseObjectAttribute('UnknownDimension', $supplierLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'), true)) ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $supplierLine, $lineElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setRatio(self::getField($lineElement, 'ratio', $supplierLine)) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $supplierLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); From 1db8b4e9597f32e0a012396bf2049f8ae768567a Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 20 Jun 2019 21:47:25 +0200 Subject: [PATCH 320/388] Upload --- src/Mappers/BaseMapper.php | 14 +++++++------- src/Mappers/CustomerMapper.php | 4 ++-- src/Mappers/DimensionGroupMapper.php | 2 +- src/Mappers/FixedAssetMapper.php | 10 +++++----- src/Mappers/SupplierMapper.php | 4 ++-- .../BankTransactionIntegrationTest.php | 2 ++ .../CashTransactionIntegrationTest.php | 2 ++ tests/IntegrationTests/CustomerIntegrationTest.php | 2 ++ tests/IntegrationTests/InvoiceIntegrationTest.php | 2 ++ .../JournalTransactionIntegrationTest.php | 2 ++ .../PurchaseTransactionIntegrationTest.php | 2 ++ .../SalesTransactionIntegrationTest.php | 2 ++ 12 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index 5f27322a..f5737ba2 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -115,12 +115,12 @@ protected static function parseMoneyAttribute(?float $value, ?string $currency): return Util::parseMoney($value, new Currency($currency)); } - protected static function parseUnknownEntity(bool $unknown, $object, \DOMElement $element, string $fieldTagName): string + protected static function parseUnknownEntity($object, \DOMElement $element, string $fieldTagName): string { - if ($unknown) { - $type = self::getAttribute($element, $fieldTagName, "dimensiontype"); - } else { + if (is_a($object, \PhpTwinfield\DimensionGroupDimension::class)) { $type = self::getField($element, "type", $object); + } else { + $type = self::getAttribute($element, $fieldTagName, "dimensiontype"); } switch ($type) { @@ -146,10 +146,10 @@ protected static function parseUnknownEntity(bool $unknown, $object, \DOMElement } /** @var SomeClassWithMethodsetCode $object2 */ - protected static function parseObjectAttribute(string $objectClass, $object, \DOMElement $element, string $fieldTagName, array $attributes = [], ?bool $unknown = null) + protected static function parseObjectAttribute(?string $objectClass, $object, \DOMElement $element, string $fieldTagName, array $attributes = []) { - if ($unknown !== null) { - $objectClass = self::parseUnknownEntity($unknown, $object, $element, $fieldTagName); + if ($objectClass === null) { + $objectClass = self::parseUnknownEntity($object, $element, $fieldTagName); } $object2 = new $objectClass(); diff --git a/src/Mappers/CustomerMapper.php b/src/Mappers/CustomerMapper.php index edad45ee..6e5b8ab9 100644 --- a/src/Mappers/CustomerMapper.php +++ b/src/Mappers/CustomerMapper.php @@ -90,7 +90,7 @@ public static function map(Response $response, AuthenticatedConnection $connecti ->setPayCode(self::parseObjectAttribute(\PhpTwinfield\PayCode::class, $customerFinancials, $financialsElement, 'paycode', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setSubAnalyse(self::parseEnumAttribute(\PhpTwinfield\Enums\SubAnalyse::class, self::getField($financialsElement, 'subanalyse', $customerFinancials))) ->setSubstitutionLevel(self::getField($financialsElement, 'substitutionlevel', $customerFinancials)) - ->setSubstituteWith(self::parseObjectAttribute('UnknownDimension', $customerFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'), true)) + ->setSubstituteWith(self::parseObjectAttribute(null, $customerFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $customerFinancials, $financialsElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); // Set the financials elements from the financials element attributes @@ -303,7 +303,7 @@ public static function map(Response $response, AuthenticatedConnection $connecti $customerLine->setDescription(self::getField($lineElement, 'description', $customerLine)) ->setDimension1(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $customerLine, $lineElement, 'dimension1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setDimension2(self::parseObjectAttribute(\PhpTwinfield\CostCenter::class, $customerLine, $lineElement, 'dimension2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setDimension3(self::parseObjectAttribute('UnknownDimension', $customerLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'), true)) + ->setDimension3(self::parseObjectAttribute(null, $customerLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $customerLine, $lineElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setRatio(self::getField($lineElement, 'ratio', $customerLine)) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $customerLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); diff --git a/src/Mappers/DimensionGroupMapper.php b/src/Mappers/DimensionGroupMapper.php index 757b6d96..9412c539 100644 --- a/src/Mappers/DimensionGroupMapper.php +++ b/src/Mappers/DimensionGroupMapper.php @@ -61,7 +61,7 @@ public static function map(Response $response) // Set the dimension group dimension elements from the dimension element $dimensionGroupDimension->setType(self::parseObjectAttribute(\PhpTwinfield\DimensionType::class, $dimensionGroupDimension, $dimensionElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))); - $dimensionGroupDimension->setCode(self::parseObjectAttribute('DimensionGroupDimension', $dimensionGroupDimension, $dimensionElement, 'code', array('name' => 'setName', 'shortname' => 'setShortName'), false)); + $dimensionGroupDimension->setCode(self::parseObjectAttribute(null, $dimensionGroupDimension, $dimensionElement, 'code', array('name' => 'setName', 'shortname' => 'setShortName'))); // Add the dimension to the dimension group $dimensiongroup->addDimension($dimensionGroupDimension); diff --git a/src/Mappers/FixedAssetMapper.php b/src/Mappers/FixedAssetMapper.php index f12a71bd..d73fe0e2 100644 --- a/src/Mappers/FixedAssetMapper.php +++ b/src/Mappers/FixedAssetMapper.php @@ -139,11 +139,11 @@ public static function map(Response $response, AuthenticatedConnection $connecti $fixedAssetTransactionLine->setAmount(self::parseMoneyAttribute(self::getField($transactionLineElement, 'amount', $fixedAssetTransactionLine), $currencies['base'])) ->setCode(self::getField($transactionLineElement, 'code', $fixedAssetTransactionLine)) ->setDim1(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $fixedAssetTransactionLine, $transactionLineElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) - ->setDim2(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'), true)) - ->setDim3(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'), true)) - ->setDim4(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim4', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'), true)) - ->setDim5(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim5', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'), true)) - ->setDim6(self::parseObjectAttribute('UnknownDimension', $fixedAssetTransactionLine, $transactionLineElement, 'dim6', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'), true)) + ->setDim2(self::parseObjectAttribute(null, $fixedAssetTransactionLine, $transactionLineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim3(self::parseObjectAttribute(null, $fixedAssetTransactionLine, $transactionLineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim4(self::parseObjectAttribute(null, $fixedAssetTransactionLine, $transactionLineElement, 'dim4', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim5(self::parseObjectAttribute(null, $fixedAssetTransactionLine, $transactionLineElement, 'dim5', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) + ->setDim6(self::parseObjectAttribute(null, $fixedAssetTransactionLine, $transactionLineElement, 'dim6', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setType'))) ->setLine(self::getField($transactionLineElement, 'line', $fixedAssetTransactionLine)) ->setNumber(self::getField($transactionLineElement, 'number', $fixedAssetTransactionLine)) ->setPeriod(self::getField($transactionLineElement, 'period', $fixedAssetTransactionLine)); diff --git a/src/Mappers/SupplierMapper.php b/src/Mappers/SupplierMapper.php index dba6f353..e6375519 100644 --- a/src/Mappers/SupplierMapper.php +++ b/src/Mappers/SupplierMapper.php @@ -78,7 +78,7 @@ public static function map(Response $response) ->setRelationsReference(self::getField($financialsElement, 'relationsreference', $supplierFinancials)) ->setSubAnalyse(self::parseEnumAttribute(\PhpTwinfield\Enums\SubAnalyse::class, self::getField($financialsElement, 'subanalyse', $supplierFinancials))) ->setSubstitutionLevel(self::getField($financialsElement, 'substitutionlevel', $supplierFinancials)) - ->setSubstituteWith(self::parseObjectAttribute('UnknownDimension', $supplierFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'), true)) + ->setSubstituteWith(self::parseObjectAttribute(null, $supplierFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $supplierFinancials, $financialsElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); // Set the financials elements from the financials element attributes @@ -246,7 +246,7 @@ public static function map(Response $response) $supplierLine->setDescription(self::getField($lineElement, 'description', $supplierLine)) ->setDimension1(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $supplierLine, $lineElement, 'dimension1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setDimension2(self::parseObjectAttribute(\PhpTwinfield\CostCenter::class, $supplierLine, $lineElement, 'dimension2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) - ->setDimension3(self::parseObjectAttribute('UnknownDimension', $supplierLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'), true)) + ->setDimension3(self::parseObjectAttribute(null, $supplierLine, $lineElement, 'dimension3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $supplierLine, $lineElement, 'office', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setRatio(self::getField($lineElement, 'ratio', $supplierLine)) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $supplierLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index 2eead671..b8aa0c6b 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -19,6 +19,8 @@ use PhpTwinfield\Response\Response; /** + * @runTestsInSeparateProcesses + * @preserveGlobalState disabled * @covers BankTransaction * @covers BankTransactionLine * @covers TransactionsDocument diff --git a/tests/IntegrationTests/CashTransactionIntegrationTest.php b/tests/IntegrationTests/CashTransactionIntegrationTest.php index e3db21fb..955e144e 100644 --- a/tests/IntegrationTests/CashTransactionIntegrationTest.php +++ b/tests/IntegrationTests/CashTransactionIntegrationTest.php @@ -19,6 +19,8 @@ use PhpTwinfield\Response\Response; /** + * @runTestsInSeparateProcesses + * @preserveGlobalState disabled * @covers SalesTransaction * @covers SalesTransactionLine * @covers TransactionsDocument diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 65d5beeb..f535a097 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -16,6 +16,8 @@ use PhpTwinfield\Response\Response; /** + * @runTestsInSeparateProcesses + * @preserveGlobalState disabled * @covers Customer * @covers CustomerAddress * @covers CustomerBank diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index a52f1b95..6fc331ad 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -17,6 +17,8 @@ use PhpTwinfield\Response\Response; /** + * @runTestsInSeparateProcesses + * @preserveGlobalState disabled * @covers Invoice * @covers InvoiceLine * @covers InvoiceTotals diff --git a/tests/IntegrationTests/JournalTransactionIntegrationTest.php b/tests/IntegrationTests/JournalTransactionIntegrationTest.php index 28b941af..33ebc23d 100644 --- a/tests/IntegrationTests/JournalTransactionIntegrationTest.php +++ b/tests/IntegrationTests/JournalTransactionIntegrationTest.php @@ -18,6 +18,8 @@ use PhpTwinfield\Response\Response; /** + * @runTestsInSeparateProcesses + * @preserveGlobalState disabled * @covers JournalTransaction * @covers JournalTransactionLine * @covers TransactionsDocument diff --git a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php index 39ff8b36..f340130d 100644 --- a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php +++ b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php @@ -18,6 +18,8 @@ use PhpTwinfield\Response\Response; /** + * @runTestsInSeparateProcesses + * @preserveGlobalState disabled * @covers PurchaseTransaction * @covers PurchaseTransactionLine * @covers TransactionsDocument diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index 603d7ca4..7efc3954 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -18,6 +18,8 @@ use PhpTwinfield\SalesTransactionLine; /** + * @runTestsInSeparateProcesses + * @preserveGlobalState disabled * @covers SalesTransaction * @covers SalesTransactionLine * @covers TransactionsDocument From 79636ebe69f8044d00d0363a552ce82b926c6209 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 20 Jun 2019 21:55:36 +0200 Subject: [PATCH 321/388] Upload --- .../CustomerApiConnectorTest.php | 21 +++++++++++++++++++ .../FixedAssetApiConnectorTest.php | 21 +++++++++++++++++++ .../ApiConnectors/InvoiceApiConnectorTest.php | 19 +++++++++++++++++ .../TransactionApiConnectorTest.php | 20 ++++++++++++++++++ 4 files changed, 81 insertions(+) diff --git a/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php b/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php index 5ac98ae2..efa407ab 100644 --- a/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php @@ -3,12 +3,19 @@ namespace PhpTwinfield\UnitTests; use PhpTwinfield\ApiConnectors\CustomerApiConnector; +use PhpTwinfield\ApiConnectors\OfficeApiConnector; +use PhpTwinfield\Currency; use PhpTwinfield\Customer; +use PhpTwinfield\Office; use PhpTwinfield\Response\Response; use PhpTwinfield\Secure\AuthenticatedConnection; use PhpTwinfield\Services\ProcessXmlService; use PHPUnit\Framework\TestCase; +/** + * @runTestsInSeparateProcesses + * @preserveGlobalState disabled + */ class CustomerApiConnectorTest extends TestCase { /** @@ -38,6 +45,20 @@ protected function setUp() ->willReturn($this->processXmlService); $this->apiConnector = new CustomerApiConnector($connection); + + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); + $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { + $baseCurrency = new Currency; + $baseCurrency->setCode('EUR'); + $reportingCurrency = new Currency; + $reportingCurrency->setCode('USD'); + + $office = new Office; + $office->setResult(1); + $office->setBaseCurrency($baseCurrency); + $office->setReportingCurrency($reportingCurrency); + return $office; + }); } private function createCustomer(): Customer diff --git a/tests/UnitTests/ApiConnectors/FixedAssetApiConnectorTest.php b/tests/UnitTests/ApiConnectors/FixedAssetApiConnectorTest.php index 7fda71d7..a42233cb 100644 --- a/tests/UnitTests/ApiConnectors/FixedAssetApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/FixedAssetApiConnectorTest.php @@ -3,12 +3,19 @@ namespace PhpTwinfield\UnitTests; use PhpTwinfield\ApiConnectors\FixedAssetApiConnector; +use PhpTwinfield\ApiConnectors\OfficeApiConnector; +use PhpTwinfield\Currency; use PhpTwinfield\FixedAsset; +use PhpTwinfield\Office; use PhpTwinfield\Response\Response; use PhpTwinfield\Secure\AuthenticatedConnection; use PhpTwinfield\Services\ProcessXmlService; use PHPUnit\Framework\TestCase; +/** + * @runTestsInSeparateProcesses + * @preserveGlobalState disabled + */ class FixedAssetApiConnectorTest extends TestCase { /** @@ -38,6 +45,20 @@ protected function setUp() ->willReturn($this->processXmlService); $this->apiConnector = new FixedAssetApiConnector($connection); + + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); + $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { + $baseCurrency = new Currency; + $baseCurrency->setCode('EUR'); + $reportingCurrency = new Currency; + $reportingCurrency->setCode('USD'); + + $office = new Office; + $office->setResult(1); + $office->setBaseCurrency($baseCurrency); + $office->setReportingCurrency($reportingCurrency); + return $office; + }); } private function createFixedAsset(): FixedAsset diff --git a/tests/UnitTests/ApiConnectors/InvoiceApiConnectorTest.php b/tests/UnitTests/ApiConnectors/InvoiceApiConnectorTest.php index 9be43557..f615eb7b 100644 --- a/tests/UnitTests/ApiConnectors/InvoiceApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/InvoiceApiConnectorTest.php @@ -2,13 +2,20 @@ namespace PhpTwinfield\UnitTests; +use PhpTwinfield\ApiConnectors\ArticleApiConnector; use PhpTwinfield\ApiConnectors\InvoiceApiConnector; +use PhpTwinfield\ApiConnectors\InvoiceTypeApiConnector; +use PhpTwinfield\Article; use PhpTwinfield\Invoice; use PhpTwinfield\Response\Response; use PhpTwinfield\Secure\AuthenticatedConnection; use PhpTwinfield\Services\ProcessXmlService; use PHPUnit\Framework\TestCase; +/** + * @runTestsInSeparateProcesses + * @preserveGlobalState disabled + */ class InvoiceApiConnectorTest extends TestCase { /** @@ -38,6 +45,18 @@ protected function setUp() ->willReturn($this->processXmlService); $this->apiConnector = new InvoiceApiConnector($connection); + + $mockInvoiceTypeApiConnector = \Mockery::mock('overload:'.InvoiceTypeApiConnector::class)->makePartial(); + $mockInvoiceTypeApiConnector->shouldReceive('getInvoiceTypeVatType')->andReturnUsing(function() { + return 'exclusive'; + }); + + $mockArticleApiConnector = \Mockery::mock('overload:'.ArticleApiConnector::class)->makePartial(); + $mockArticleApiConnector->shouldReceive('get')->andReturnUsing(function() { + $article = new Article; + $article->setAllowChangeVatCode(true); + return $article; + }); } private function createInvoice(): Invoice diff --git a/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php b/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php index e6c7ba6a..ee278d06 100644 --- a/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php @@ -2,8 +2,10 @@ namespace PhpTwinfield\UnitTests; +use PhpTwinfield\ApiConnectors\OfficeApiConnector; use PhpTwinfield\ApiConnectors\TransactionApiConnector; use PhpTwinfield\BaseTransaction; +use PhpTwinfield\Currency; use PhpTwinfield\Enums\Destiny; use PhpTwinfield\Office; use PhpTwinfield\Response\Response; @@ -12,6 +14,10 @@ use PhpTwinfield\Services\ProcessXmlService; use PHPUnit\Framework\TestCase; +/** + * @runTestsInSeparateProcesses + * @preserveGlobalState disabled + */ class TransactionApiConnectorTest extends TestCase { /** @@ -41,6 +47,20 @@ protected function setUp() ->willReturn($this->processXmlService); $this->apiConnector = new TransactionApiConnector($connection); + + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); + $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { + $baseCurrency = new Currency; + $baseCurrency->setCode('EUR'); + $reportingCurrency = new Currency; + $reportingCurrency->setCode('USD'); + + $office = new Office; + $office->setResult(1); + $office->setBaseCurrency($baseCurrency); + $office->setReportingCurrency($reportingCurrency); + return $office; + }); } private function createTransaction(string $transactionClassName): BaseTransaction From a1431de313a9d3c03f84c1eb35ee1156f87150b3 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 22 Jun 2019 12:02:15 +0200 Subject: [PATCH 322/388] Upload --- src/Activity.php | 7 ++- src/ApiConnectors/ActivityApiConnector.php | 4 +- src/ApiConnectors/ArticleApiConnector.php | 4 +- src/ApiConnectors/AssetMethodApiConnector.php | 4 +- .../CashBankBookApiConnector.php | 2 +- src/ApiConnectors/CostCenterApiConnector.php | 4 +- src/ApiConnectors/CountryApiConnector.php | 2 +- src/ApiConnectors/CurrencyApiConnector.php | 4 +- src/ApiConnectors/CustomerApiConnector.php | 4 +- .../DimensionGroupApiConnector.php | 4 +- .../DimensionTypeApiConnector.php | 2 +- src/ApiConnectors/FixedAssetApiConnector.php | 4 +- .../GeneralLedgerApiConnector.php | 4 +- src/ApiConnectors/InvoiceApiConnector.php | 2 +- src/ApiConnectors/InvoiceTypeApiConnector.php | 2 +- src/ApiConnectors/OfficeApiConnector.php | 2 +- src/ApiConnectors/PayCodeApiConnector.php | 2 +- src/ApiConnectors/ProjectApiConnector.php | 4 +- src/ApiConnectors/RateApiConnector.php | 4 +- src/ApiConnectors/SupplierApiConnector.php | 4 +- src/ApiConnectors/UserApiConnector.php | 2 +- src/ApiConnectors/UserRoleApiConnector.php | 2 +- src/ApiConnectors/VatCodeApiConnector.php | 4 +- src/ApiConnectors/VatGroupApiConnector.php | 2 +- .../VatGroupCountryApiConnector.php | 2 +- src/Article.php | 4 +- src/AssetMethod.php | 2 +- src/BankTransaction.php | 5 -- src/BaseTransaction.php | 2 +- src/BrowseDataHeader.php | 2 +- src/BrowseDataRow.php | 2 +- src/BrowseDefinition.php | 2 +- src/BrowseField.php | 2 +- src/BrowseFieldOption.php | 2 +- src/BrowseSortField.php | 2 +- src/CashBankBook.php | 2 +- src/CashTransaction.php | 5 -- src/CostCenter.php | 6 +- src/Country.php | 2 +- src/Currency.php | 2 +- src/Customer.php | 7 ++- src/CustomerCreditManagement.php | 2 +- src/CustomerFinancials.php | 8 +-- src/DimensionGroup.php | 2 +- src/DimensionType.php | 2 +- src/DomDocuments/ActivitiesDocument.php | 17 ++--- src/DomDocuments/ArticlesDocument.php | 25 ++++---- src/DomDocuments/AssetMethodsDocument.php | 23 +++---- .../BookingReferenceDeletionDocument.php | 3 +- src/DomDocuments/CostCentersDocument.php | 4 +- src/DomDocuments/CurrenciesDocument.php | 5 +- src/DomDocuments/CustomersDocument.php | 53 ++++++++-------- src/DomDocuments/DimensionGroupsDocument.php | 7 ++- src/DomDocuments/DimensionTypesDocument.php | 3 +- .../ElectronicBankStatementDocument.php | 13 ++-- src/DomDocuments/FixedAssetsDocument.php | 37 +++++------ src/DomDocuments/GeneralLedgersDocument.php | 9 +-- src/DomDocuments/InvoicesDocument.php | 35 ++++++----- src/DomDocuments/MatchDocument.php | 4 +- src/DomDocuments/ProjectsDocument.php | 17 ++--- src/DomDocuments/RatesDocument.php | 9 +-- src/DomDocuments/SuppliersDocument.php | 39 ++++++------ src/DomDocuments/TransactionsDocument.php | 56 ++++++++--------- src/DomDocuments/VatCodesDocument.php | 9 +-- src/Dummy.php | 20 ------ src/ElectronicBankStatement.php | 8 --- .../AssetMethod/AssetsToActivateField.php | 21 ------- src/Fields/AssetMethod/CalcMethodField.php | 10 --- .../DepreciateReconciliationField.php | 10 --- src/Fields/AssetMethod/DepreciationField.php | 23 +------ .../AssetMethod/DepreciationGroupField.php | 21 ------- src/Fields/AssetMethod/FreeTextTypeField.php | 10 --- src/Fields/AssetMethod/PurchaseValueField.php | 21 ------- .../AssetMethod/PurchaseValueGroupField.php | 21 ------- .../AssetMethod/ReconciliationField.php | 21 ------- src/Fields/AssetMethod/SalesField.php | 23 +------ src/Fields/AssetMethod/ToBeInvoicedField.php | 23 +------ src/Fields/BehaviourField.php | 10 --- src/Fields/CreatedField.php | 31 ---------- src/Fields/Currency/StartDateField.php | 31 ---------- src/Fields/CurrencyField.php | 21 ------- src/Fields/DateField.php | 29 --------- src/Fields/Dim1Field.php | 21 ------- src/Fields/Dim2Field.php | 23 ------- src/Fields/Dim3Field.php | 23 ------- src/Fields/Dim4Field.php | 25 +------- src/Fields/Dimensions/AccountTypeField.php | 10 --- src/Fields/Dimensions/AmountField.php | 27 -------- .../Dimensions/DimensionGroup/CodeField.php | 25 +------- .../Dimensions/DimensionGroup/GroupField.php | 21 ------- .../Dimensions/DimensionType/TypeField.php | 9 --- .../Dimensions/Level2/BankBlockedField.php | 15 ----- src/Fields/Dimensions/Level2/CountryField.php | 21 ------- .../Level2/Customer/BaseCreditLimitField.php | 27 -------- .../Level2/Customer/BlockedField.php | 17 +---- .../Level2/Customer/BlockedLockedField.php | 15 ----- .../Level2/Customer/BlockedModifiedField.php | 31 ---------- .../Level2/Customer/CollectionSchemaField.php | 10 --- .../Level2/Customer/DiscountArticleField.php | 21 ------- .../Level2/Customer/EBillingField.php | 15 ----- .../Level2/Customer/FirstRunDateField.php | 31 ---------- .../Level2/Customer/FreeText1Field.php | 15 ----- .../Level2/Customer/ResponsibleUserField.php | 21 ------- .../Level2/Customer/SendReminderField.php | 10 --- .../Level2/Customer/SignatureDateField.php | 31 ---------- src/Fields/Dimensions/Level2/DefaultField.php | 15 ----- .../Dimensions/Level2/Dimension1Field.php | 21 ------- .../Dimensions/Level2/Dimension2Field.php | 21 ------- .../Dimensions/Level2/Dimension3Field.php | 23 ------- .../Dimensions/Level2/MeansOfPaymentField.php | 10 --- .../Dimensions/Level2/PayAvailableField.php | 15 ----- src/Fields/Dimensions/Level2/PayCodeField.php | 21 ------- .../Level2/RemittanceAdviceSendTypeField.php | 10 --- ...ccountPaymentConditionsIncludeVatField.php | 10 --- src/Fields/Dimensions/Level2/TypeField.php | 10 --- .../Dimensions/Level34/AuthoriserField.php | 12 ---- .../Level34/AuthoriserInheritField.php | 10 --- .../Level34/AuthoriserLockedField.php | 10 --- .../Dimensions/Level34/BillableField.php | 10 --- .../Level34/BillableForRatioField.php | 10 --- .../Level34/BillableInheritField.php | 10 --- .../Level34/BillableLockedField.php | 10 --- .../Level34/CustomerInheritField.php | 10 --- .../Level34/CustomerLockedField.php | 10 --- .../Level34/FixedAsset/AmountLockedField.php | 15 ----- .../FixedAsset/BeginPeriodLockedField.php | 15 ----- .../Level34/FixedAsset/CodeField.php | 9 --- .../Level34/FixedAsset/CodeLockedField.php | 15 ----- .../Level34/FixedAsset/Dim1LockedField.php | 17 +---- .../Level34/FixedAsset/Dim2LockedField.php | 15 ----- .../Level34/FixedAsset/Dim3LockedField.php | 15 ----- .../Level34/FixedAsset/Dim4LockedField.php | 15 ----- .../Level34/FixedAsset/Dim5Field.php | 23 ------- .../Level34/FixedAsset/Dim5LockedField.php | 17 +---- .../Level34/FixedAsset/Dim6Field.php | 23 ------- .../Level34/FixedAsset/Dim6LockedField.php | 15 ----- .../FixedAsset/FreeText1LockedField.php | 15 ----- .../FixedAsset/FreeText2LockedField.php | 15 ----- .../FixedAsset/FreeText3LockedField.php | 17 +---- .../FixedAsset/FreeText4LockedField.php | 15 ----- .../FixedAsset/FreeText5LockedField.php | 15 ----- .../LastDepreciationLockedField.php | 15 ----- .../Level34/FixedAsset/LineLockedField.php | 15 ----- .../Level34/FixedAsset/MethodField.php | 21 ------- .../Level34/FixedAsset/MethodLockedField.php | 15 ----- .../FixedAsset/NrOfPeriodsInheritedField.php | 15 ----- .../FixedAsset/NrOfPeriodsLockedField.php | 15 ----- .../Level34/FixedAsset/NumberLockedField.php | 15 ----- .../FixedAsset/PercentageLockedField.php | 15 ----- .../Level34/FixedAsset/PeriodLockedField.php | 15 ----- .../Level34/FixedAsset/PurchaseDateField.php | 31 ---------- .../FixedAsset/PurchaseDateLockedField.php | 15 ----- .../Level34/FixedAsset/ResidualValueField.php | 27 -------- .../FixedAsset/ResidualValueLockedField.php | 15 ----- .../Level34/FixedAsset/SellDateField.php | 31 ---------- .../FixedAsset/SellDateLockedField.php | 15 ----- .../Level34/FixedAsset/StatusField.php | 10 --- .../Level34/FixedAsset/StatusLockedField.php | 15 ----- .../Level34/FixedAsset/StopValueField.php | 27 -------- .../FixedAsset/StopValueLockedField.php | 15 ----- .../TransactionLinesLockedField.php | 15 ----- .../Dimensions/Level34/MandatoryField.php | 15 ----- .../Dimensions/Level34/RateInheritField.php | 10 --- .../Dimensions/Level34/RateLockedField.php | 10 --- .../Dimensions/Level34/ValidFromField.php | 31 ---------- .../Dimensions/Level34/ValidTillField.php | 31 ---------- src/Fields/Dimensions/MatchTypeField.php | 10 --- src/Fields/Dimensions/SubAnalyseField.php | 10 --- src/Fields/Dimensions/SubstituteWithField.php | 23 ------- src/Fields/Dimensions/TypeField.php | 10 --- src/Fields/Dimensions/VatCodeFixedField.php | 15 ----- src/Fields/DueDateField.php | 31 ---------- src/Fields/InUseField.php | 15 ----- .../Invoice/AllowDiscountOrPremiumField.php | 17 +---- .../AllowChangePerformanceTypeField.php | 15 ----- .../Article/AllowChangeUnitsPriceField.php | 17 +---- .../Article/AllowChangeVatCodeField.php | 15 ----- .../Article/AllowDecimalQuantityField.php | 17 +---- src/Fields/Invoice/Article/FreeText1Field.php | 21 ------- src/Fields/Invoice/Article/FreeText2Field.php | 21 ------- .../Invoice/Article/PercentageField.php | 15 ----- src/Fields/Invoice/Article/TypeField.php | 10 --- src/Fields/Invoice/ArticleField.php | 21 ------- src/Fields/Invoice/BankField.php | 21 ------- src/Fields/Invoice/CalculateOnlyField.php | 15 ----- src/Fields/Invoice/InvoiceAmountField.php | 27 -------- src/Fields/Invoice/InvoiceDateField.php | 31 ---------- src/Fields/Invoice/InvoiceTypeField.php | 21 ------- src/Fields/Invoice/PaymentMethodField.php | 10 --- .../Invoice/PeriodRaiseWarningField.php | 17 +---- src/Fields/Invoice/RaiseWarningField.php | 15 ----- src/Fields/Invoice/StatusField.php | 10 --- src/Fields/Invoice/SubArticleField.php | 12 ---- src/Fields/Invoice/UnitsPriceExclField.php | 29 +-------- src/Fields/Invoice/UnitsPriceIncField.php | 27 -------- src/Fields/Invoice/ValueExclField.php | 27 -------- src/Fields/Invoice/ValueIncField.php | 27 -------- src/Fields/LineTypeField.php | 10 --- src/Fields/ModifiedField.php | 31 ---------- src/Fields/Office/BaseCurrencyField.php | 21 ------- src/Fields/Office/CountryCodeField.php | 11 +--- src/Fields/Office/ReportingCurrencyField.php | 23 +------ src/Fields/OfficeField.php | 21 ------- src/Fields/PerformanceDateField.php | 29 --------- src/Fields/PerformanceTypeField.php | 10 --- src/Fields/Rate/BeginDateField.php | 30 --------- src/Fields/Rate/EndDateField.php | 33 +--------- src/Fields/Rate/TypeField.php | 10 --- src/Fields/RateField.php | 12 ---- src/Fields/StatusField.php | 10 --- .../Transaction/AutoBalanceVatField.php | 15 ----- .../Transaction/CloseAndStartValueFields.php | 62 +------------------ .../Transaction/DateRaiseWarningField.php | 10 --- src/Fields/Transaction/DestinyField.php | 10 --- src/Fields/Transaction/InputDateField.php | 31 ---------- .../InvoiceNumberRaiseWarningField.php | 10 --- .../Transaction/ModificationDateField.php | 31 ---------- src/Fields/Transaction/RaiseWarningField.php | 15 ----- src/Fields/Transaction/RegimeField.php | 10 --- .../TransactionLine/BaseValueField.php | 27 -------- .../TransactionLine/BaseValueOpenField.php | 29 +-------- .../TransactionLine/CurrencyDateField.php | 31 ---------- .../TransactionLine/DestOfficeField.php | 21 ------- .../Transaction/TransactionLine/Dim1Field.php | 23 ------- .../TransactionLine/MatchDateField.php | 31 ---------- .../TransactionLine/MatchStatusField.php | 10 --- .../PerformanceCountryField.php | 21 ------- .../TransactionLine/RepValueField.php | 27 -------- .../TransactionLine/RepValueOpenField.php | 27 -------- .../TransactionLine/ValueFields.php | 27 -------- .../TransactionLine/ValueOpenField.php | 27 -------- .../TransactionLine/VatBaseTotalField.php | 27 -------- .../TransactionLine/VatBaseTurnoverField.php | 27 -------- .../TransactionLine/VatBaseValueField.php | 29 +-------- .../TransactionLine/VatRepTotalField.php | 27 -------- .../TransactionLine/VatRepTurnoverField.php | 27 -------- .../TransactionLine/VatRepValueField.php | 27 -------- .../TransactionLine/VatTotalField.php | 27 -------- .../TransactionLine/VatTurnoverField.php | 27 -------- src/Fields/User/AcceptExtraCostField.php | 15 ----- src/Fields/User/CultureField.php | 10 --- src/Fields/User/DemoField.php | 15 ----- src/Fields/User/DemoLockedField.php | 17 +---- src/Fields/User/ExchangeQuotaLockedField.php | 15 ----- .../User/FileManagerQuotaLockedField.php | 15 ----- src/Fields/User/IsCurrentUserField.php | 15 ----- src/Fields/User/RoleField.php | 21 ------- src/Fields/User/RoleLockedField.php | 17 +---- src/Fields/User/TypeField.php | 10 --- src/Fields/User/TypeLockedField.php | 15 ----- src/Fields/UserField.php | 21 ------- src/Fields/VatCode/GroupCountryField.php | 21 ------- src/Fields/VatCode/GroupField.php | 21 ------- src/Fields/VatCode/TypeField.php | 10 --- src/Fields/VatCodeField.php | 23 +------ src/Fields/VatValueField.php | 27 -------- src/FixedAsset.php | 7 ++- src/GeneralLedger.php | 2 +- src/GeneralLedgerFinancials.php | 4 +- src/HasCodeInterface.php | 16 +++++ src/InvoiceType.php | 2 +- src/Mappers/ArticleMapper.php | 2 +- src/Mappers/BaseMapper.php | 6 +- src/Mappers/CustomerMapper.php | 2 +- src/Mappers/InvoiceMapper.php | 18 +++--- src/Mappers/SupplierMapper.php | 2 +- src/Mappers/TransactionMapper.php | 28 ++++----- src/Office.php | 2 +- src/PayCode.php | 2 +- src/Project.php | 7 ++- src/Rate.php | 2 +- src/Supplier.php | 7 ++- src/SupplierFinancials.php | 6 +- src/User.php | 2 +- src/UserRole.php | 2 +- src/Util.php | 13 ++++ src/VatCode.php | 2 +- src/VatGroup.php | 2 +- src/VatGroupCountry.php | 2 +- 279 files changed, 374 insertions(+), 3891 deletions(-) delete mode 100644 src/Dummy.php create mode 100644 src/HasCodeInterface.php diff --git a/src/Activity.php b/src/Activity.php index a4744cad..b4c2e375 100644 --- a/src/Activity.php +++ b/src/Activity.php @@ -19,7 +19,7 @@ * * @author Yannick Aerssens */ -class Activity extends BaseObject +class Activity extends BaseObject implements HasCodeInterface { use BehaviourField; use CodeField; @@ -37,7 +37,10 @@ class Activity extends BaseObject public function __construct() { - $this->setTypeFromString('ACT'); + $dimensionType = new \PhpTwinfield\DimensionType; + $dimensionType->setCode('ACT'); + $this->setType($dimensionType); + $this->setProjects(new ActivityProjects); } diff --git a/src/ApiConnectors/ActivityApiConnector.php b/src/ApiConnectors/ActivityApiConnector.php index 2fae6c4c..aec4fdf6 100644 --- a/src/ApiConnectors/ActivityApiConnector.php +++ b/src/ApiConnectors/ActivityApiConnector.php @@ -122,7 +122,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\Activity::class, $response->data, $activityArrayListAllTags); + return $this->mapListAll(Activity::class, $response->data, $activityArrayListAllTags); } /** @@ -139,7 +139,7 @@ public function delete(string $code, Office $office): Activity $activity = self::get($code, $office); if ($activity->getResult() == 1) { - $activity->setStatusFromString("deleted"); + $activity->setStatus(\PhpTwinfield\Enums\Status::DELETED()); try { $activityDeleted = self::send($activity); diff --git a/src/ApiConnectors/ArticleApiConnector.php b/src/ApiConnectors/ArticleApiConnector.php index 25cbb1f8..8cf1247b 100644 --- a/src/ApiConnectors/ArticleApiConnector.php +++ b/src/ApiConnectors/ArticleApiConnector.php @@ -120,7 +120,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\Article::class, $response->data, $articleArrayListAllTags); + return $this->mapListAll(Article::class, $response->data, $articleArrayListAllTags); } /** @@ -137,7 +137,7 @@ public function delete(string $code, Office $office): Article $article = self::get($code, $office); if ($article->getResult() == 1) { - $article->setStatusFromString("deleted"); + $article->setStatus(\PhpTwinfield\Enums\Status::DELETED()); try { $articleDeleted = self::send($article); diff --git a/src/ApiConnectors/AssetMethodApiConnector.php b/src/ApiConnectors/AssetMethodApiConnector.php index 35348c9e..7b114ccd 100644 --- a/src/ApiConnectors/AssetMethodApiConnector.php +++ b/src/ApiConnectors/AssetMethodApiConnector.php @@ -121,7 +121,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\AssetMethod::class, $response->data, $assetMethodArrayListAllTags); + return $this->mapListAll(AssetMethod::class, $response->data, $assetMethodArrayListAllTags); } /** @@ -138,7 +138,7 @@ public function delete(string $code, Office $office): AssetMethod $assetMethod = self::get($code, $office); if ($assetMethod->getResult() == 1) { - $assetMethod->setStatusFromString("deleted"); + $assetMethod->setStatus(\PhpTwinfield\Enums\Status::DELETED()); try { $assetMethodDeleted = self::send($assetMethod); diff --git a/src/ApiConnectors/CashBankBookApiConnector.php b/src/ApiConnectors/CashBankBookApiConnector.php index f21fc1f4..d3a22f24 100644 --- a/src/ApiConnectors/CashBankBookApiConnector.php +++ b/src/ApiConnectors/CashBankBookApiConnector.php @@ -48,6 +48,6 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\CashBankBook::class, $response->data, $cashBankBookListAllTags); + return $this->mapListAll(CashBankBook::class, $response->data, $cashBankBookListAllTags); } } \ No newline at end of file diff --git a/src/ApiConnectors/CostCenterApiConnector.php b/src/ApiConnectors/CostCenterApiConnector.php index c4ea6cb9..c777b97e 100644 --- a/src/ApiConnectors/CostCenterApiConnector.php +++ b/src/ApiConnectors/CostCenterApiConnector.php @@ -122,7 +122,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\CostCenter::class, $response->data, $costCenterArrayListAllTags); + return $this->mapListAll(CostCenter::class, $response->data, $costCenterArrayListAllTags); } /** @@ -139,7 +139,7 @@ public function delete(string $code, Office $office): CostCenter $costCenter = self::get($code, $office); if ($costCenter->getResult() == 1) { - $costCenter->setStatusFromString("deleted"); + $costCenter->setStatus(\PhpTwinfield\Enums\Status::DELETED()); try { $costCenterDeleted = self::send($costCenter); diff --git a/src/ApiConnectors/CountryApiConnector.php b/src/ApiConnectors/CountryApiConnector.php index 80fcf044..b2f89b97 100644 --- a/src/ApiConnectors/CountryApiConnector.php +++ b/src/ApiConnectors/CountryApiConnector.php @@ -48,6 +48,6 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\Country::class, $response->data, $countryListAllTags); + return $this->mapListAll(Country::class, $response->data, $countryListAllTags); } } \ No newline at end of file diff --git a/src/ApiConnectors/CurrencyApiConnector.php b/src/ApiConnectors/CurrencyApiConnector.php index 6f29a9b4..336e0853 100644 --- a/src/ApiConnectors/CurrencyApiConnector.php +++ b/src/ApiConnectors/CurrencyApiConnector.php @@ -148,7 +148,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\Currency::class, $response->data, $currencyArrayListAllTags); + return $this->mapListAll(Currency::class, $response->data, $currencyArrayListAllTags); } /** @@ -165,7 +165,7 @@ public function delete(string $code, Office $office): Currency $currency = self::get($code, $office); if ($currency->getResult() == 1) { - $currency->setStatusFromString("deleted"); + $currency->setStatus(\PhpTwinfield\Enums\Status::DELETED()); try { $currencyDeleted = self::send($currency); diff --git a/src/ApiConnectors/CustomerApiConnector.php b/src/ApiConnectors/CustomerApiConnector.php index ac9b9801..06003075 100644 --- a/src/ApiConnectors/CustomerApiConnector.php +++ b/src/ApiConnectors/CustomerApiConnector.php @@ -122,7 +122,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\Customer::class, $response->data, $customerListAllTags); + return $this->mapListAll(Customer::class, $response->data, $customerListAllTags); } /** @@ -139,7 +139,7 @@ public function delete(string $code, Office $office): Customer $customer = self::get($code, $office); if ($customer->getResult() == 1) { - $customer->setStatusFromString("deleted"); + $customer->setStatus(\PhpTwinfield\Enums\Status::DELETED()); try { $customerDeleted = self::send($customer); diff --git a/src/ApiConnectors/DimensionGroupApiConnector.php b/src/ApiConnectors/DimensionGroupApiConnector.php index 93906c17..476f4ba3 100644 --- a/src/ApiConnectors/DimensionGroupApiConnector.php +++ b/src/ApiConnectors/DimensionGroupApiConnector.php @@ -121,7 +121,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\DimensionGroup::class, $response->data, $dimensionGroupListAllTags); + return $this->mapListAll(DimensionGroup::class, $response->data, $dimensionGroupListAllTags); } /** @@ -138,7 +138,7 @@ public function delete(string $code, Office $office): DimensionGroup $dimensionGroup = self::get($code, $office); if ($dimensionGroup->getResult() == 1) { - $dimensionGroup->setStatusFromString("deleted"); + $dimensionGroup->setStatus(\PhpTwinfield\Enums\Status::DELETED()); try { $dimensionGroupDeleted = self::send($dimensionGroup); diff --git a/src/ApiConnectors/DimensionTypeApiConnector.php b/src/ApiConnectors/DimensionTypeApiConnector.php index bb9c1539..2c51cc80 100644 --- a/src/ApiConnectors/DimensionTypeApiConnector.php +++ b/src/ApiConnectors/DimensionTypeApiConnector.php @@ -120,6 +120,6 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\DimensionType::class, $response->data, $dimensionTypeListAllTags); + return $this->mapListAll(DimensionType::class, $response->data, $dimensionTypeListAllTags); } } \ No newline at end of file diff --git a/src/ApiConnectors/FixedAssetApiConnector.php b/src/ApiConnectors/FixedAssetApiConnector.php index ebe4adb2..61c173b3 100644 --- a/src/ApiConnectors/FixedAssetApiConnector.php +++ b/src/ApiConnectors/FixedAssetApiConnector.php @@ -121,7 +121,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\FixedAsset::class, $response->data, $fixedAssetListAllTags); + return $this->mapListAll(FixedAsset::class, $response->data, $fixedAssetListAllTags); } /** @@ -138,7 +138,7 @@ public function delete(string $code, Office $office): FixedAsset $fixedAsset = self::get($code, $office); if ($fixedAsset->getResult() == 1) { - $fixedAsset->setStatusFromString("deleted"); + $fixedAsset->setStatus(\PhpTwinfield\Enums\Status::DELETED()); try { $fixedAssetDeleted = self::send($fixedAsset); diff --git a/src/ApiConnectors/GeneralLedgerApiConnector.php b/src/ApiConnectors/GeneralLedgerApiConnector.php index 926575d1..e6130b16 100644 --- a/src/ApiConnectors/GeneralLedgerApiConnector.php +++ b/src/ApiConnectors/GeneralLedgerApiConnector.php @@ -123,7 +123,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\GeneralLedger::class, $response->data, $generalLedgerListAllTags); + return $this->mapListAll(GeneralLedger::class, $response->data, $generalLedgerListAllTags); } /** @@ -141,7 +141,7 @@ public function delete(string $code, string $dimType, Office $office): GeneralLe $generalLedger = self::get($code, $dimType, $office); if ($generalLedger->getResult() == 1) { - $generalLedger->setStatusFromString("deleted"); + $generalLedger->setStatus(\PhpTwinfield\Enums\Status::DELETED()); try { $generalLedgerDeleted = self::send($generalLedger); diff --git a/src/ApiConnectors/InvoiceApiConnector.php b/src/ApiConnectors/InvoiceApiConnector.php index 0c2c9a6c..43eb77cb 100644 --- a/src/ApiConnectors/InvoiceApiConnector.php +++ b/src/ApiConnectors/InvoiceApiConnector.php @@ -124,6 +124,6 @@ public function listAll( 4 => 'setDebitCreditFromString', ); - return $this->mapListAll(\PhpTwinfield\Invoice::class, $response->data, $invoiceListAllTags); + return $this->mapListAll(Invoice::class, $response->data, $invoiceListAllTags); } } diff --git a/src/ApiConnectors/InvoiceTypeApiConnector.php b/src/ApiConnectors/InvoiceTypeApiConnector.php index cc5b9bd5..4f47e8c6 100644 --- a/src/ApiConnectors/InvoiceTypeApiConnector.php +++ b/src/ApiConnectors/InvoiceTypeApiConnector.php @@ -48,7 +48,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\InvoiceType::class, $response->data, $invoiceTypeListAllTags); + return $this->mapListAll(InvoiceType::class, $response->data, $invoiceTypeListAllTags); } /** diff --git a/src/ApiConnectors/OfficeApiConnector.php b/src/ApiConnectors/OfficeApiConnector.php index fa8e055a..bc0d9968 100644 --- a/src/ApiConnectors/OfficeApiConnector.php +++ b/src/ApiConnectors/OfficeApiConnector.php @@ -97,6 +97,6 @@ public function listAll( 4 => 'setVatFirstQuarterStartsIn', ); - return $this->mapListAll(\PhpTwinfield\Office::class, $response->data, $officeListAllTags); + return $this->mapListAll(Office::class, $response->data, $officeListAllTags); } } diff --git a/src/ApiConnectors/PayCodeApiConnector.php b/src/ApiConnectors/PayCodeApiConnector.php index 11c511e6..c437dcb9 100644 --- a/src/ApiConnectors/PayCodeApiConnector.php +++ b/src/ApiConnectors/PayCodeApiConnector.php @@ -48,6 +48,6 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\PayCode::class, $response->data, $payCodeListAllTags); + return $this->mapListAll(PayCode::class, $response->data, $payCodeListAllTags); } } \ No newline at end of file diff --git a/src/ApiConnectors/ProjectApiConnector.php b/src/ApiConnectors/ProjectApiConnector.php index 9c936d0c..bfb00e30 100644 --- a/src/ApiConnectors/ProjectApiConnector.php +++ b/src/ApiConnectors/ProjectApiConnector.php @@ -122,7 +122,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\Project::class, $response->data, $projectListAllTags); + return $this->mapListAll(Project::class, $response->data, $projectListAllTags); } /** @@ -139,7 +139,7 @@ public function delete(string $code, Office $office): Project $project = self::get($code, $office); if ($project->getResult() == 1) { - $project->setStatusFromString("deleted"); + $project->setStatus(\PhpTwinfield\Enums\Status::DELETED()); try { $projectDeleted = self::send($project); diff --git a/src/ApiConnectors/RateApiConnector.php b/src/ApiConnectors/RateApiConnector.php index 6f57a299..d6ac3d22 100644 --- a/src/ApiConnectors/RateApiConnector.php +++ b/src/ApiConnectors/RateApiConnector.php @@ -121,7 +121,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\Rate::class, $response->data, $rateListAllTags); + return $this->mapListAll(Rate::class, $response->data, $rateListAllTags); } /** @@ -138,7 +138,7 @@ public function delete(string $code, Office $office): Rate $rate = self::get($code, $office); if ($rate->getResult() == 1) { - $rate->setStatusFromString("deleted"); + $rate->setStatus(\PhpTwinfield\Enums\Status::DELETED()); try { $rateDeleted = self::send($rate); diff --git a/src/ApiConnectors/SupplierApiConnector.php b/src/ApiConnectors/SupplierApiConnector.php index fb5d7b4c..b638ba6f 100644 --- a/src/ApiConnectors/SupplierApiConnector.php +++ b/src/ApiConnectors/SupplierApiConnector.php @@ -122,7 +122,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\Supplier::class, $response->data, $supplierListAllTags); + return $this->mapListAll(Supplier::class, $response->data, $supplierListAllTags); } /** @@ -139,7 +139,7 @@ public function delete(string $code, Office $office): Supplier $supplier = self::get($code, $office); if ($supplier->getResult() == 1) { - $supplier->setStatusFromString("deleted"); + $supplier->setStatus(\PhpTwinfield\Enums\Status::DELETED()); try { $supplierDeleted = self::send($supplier); diff --git a/src/ApiConnectors/UserApiConnector.php b/src/ApiConnectors/UserApiConnector.php index 1376d683..5f56be0a 100644 --- a/src/ApiConnectors/UserApiConnector.php +++ b/src/ApiConnectors/UserApiConnector.php @@ -77,6 +77,6 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\User::class, $response->data, $userListAllTags); + return $this->mapListAll(User::class, $response->data, $userListAllTags); } } diff --git a/src/ApiConnectors/UserRoleApiConnector.php b/src/ApiConnectors/UserRoleApiConnector.php index 494076af..cbbb395b 100644 --- a/src/ApiConnectors/UserRoleApiConnector.php +++ b/src/ApiConnectors/UserRoleApiConnector.php @@ -48,6 +48,6 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\UserRole::class, $response->data, $userRoleListAllTags); + return $this->mapListAll(UserRole::class, $response->data, $userRoleListAllTags); } } \ No newline at end of file diff --git a/src/ApiConnectors/VatCodeApiConnector.php b/src/ApiConnectors/VatCodeApiConnector.php index d58466f3..f7f2e6f4 100644 --- a/src/ApiConnectors/VatCodeApiConnector.php +++ b/src/ApiConnectors/VatCodeApiConnector.php @@ -121,7 +121,7 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\VatCode::class, $response->data, $vatCodeListAllTags); + return $this->mapListAll(VatCode::class, $response->data, $vatCodeListAllTags); } /** @@ -138,7 +138,7 @@ public function delete(string $code, Office $office): VatCode $vatCode = self::get($code, $office); if ($vatCode->getResult() == 1) { - $vatCode->setStatusFromString("deleted"); + $vatCode->setStatus(\PhpTwinfield\Enums\Status::DELETED()); try { $vatCodeDeleted = self::send($vatCode); diff --git a/src/ApiConnectors/VatGroupApiConnector.php b/src/ApiConnectors/VatGroupApiConnector.php index adbe1dce..4de5923c 100644 --- a/src/ApiConnectors/VatGroupApiConnector.php +++ b/src/ApiConnectors/VatGroupApiConnector.php @@ -48,6 +48,6 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\VatGroup::class, $response->data, $vatGroupListAllTags); + return $this->mapListAll(VatGroup::class, $response->data, $vatGroupListAllTags); } } \ No newline at end of file diff --git a/src/ApiConnectors/VatGroupCountryApiConnector.php b/src/ApiConnectors/VatGroupCountryApiConnector.php index ee5a3c7b..3431380a 100644 --- a/src/ApiConnectors/VatGroupCountryApiConnector.php +++ b/src/ApiConnectors/VatGroupCountryApiConnector.php @@ -48,6 +48,6 @@ public function listAll( 1 => 'setName', ); - return $this->mapListAll(\PhpTwinfield\VatGroupCountry::class, $response->data, $vatGroupCountryListAllTags); + return $this->mapListAll(VatGroupCountry::class, $response->data, $vatGroupCountryListAllTags); } } \ No newline at end of file diff --git a/src/Article.php b/src/Article.php index d4f9a740..b58db15b 100644 --- a/src/Article.php +++ b/src/Article.php @@ -23,7 +23,7 @@ * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Articles * @todo Add documentation and typehints to all properties. */ -class Article extends BaseObject +class Article extends BaseObject implements HasCodeInterface { use AllowChangePerformanceTypeField; use AllowChangeUnitsPriceField; @@ -50,7 +50,7 @@ public function __construct() $this->setAllowChangeVatCode(false); $this->setAllowDecimalQuantity(false); $this->setAllowDiscountorPremium(true); - $this->setTypeFromString('normal'); + $this->setType(\PhpTwinfield\Enums\ArticleType::NORMAL()); } public function getLines() diff --git a/src/AssetMethod.php b/src/AssetMethod.php index df3789c1..243abbe1 100644 --- a/src/AssetMethod.php +++ b/src/AssetMethod.php @@ -21,7 +21,7 @@ * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/AssetMethods * @todo Add documentation and typehints to all properties. */ -class AssetMethod extends BaseObject +class AssetMethod extends BaseObject implements HasCodeInterface { use CalcMethodField; use CodeField; diff --git a/src/BankTransaction.php b/src/BankTransaction.php index 53601db3..b0baac8c 100644 --- a/src/BankTransaction.php +++ b/src/BankTransaction.php @@ -19,11 +19,6 @@ class BankTransaction extends BaseTransaction use StatementNumberField; - public function __construct() - { - $this->startValue = new \Money\Money(0, new \Money\Currency('EUR')); - } - /* * @return string */ diff --git a/src/BaseTransaction.php b/src/BaseTransaction.php index 8e7b4847..9490f81c 100644 --- a/src/BaseTransaction.php +++ b/src/BaseTransaction.php @@ -23,7 +23,7 @@ use PhpTwinfield\Fields\UserField; use PhpTwinfield\MatchReferenceInterface; -abstract class BaseTransaction extends BaseObject +abstract class BaseTransaction extends BaseObject implements HasCodeInterface { use AutoBalanceVatField; use CodeField; diff --git a/src/BrowseDataHeader.php b/src/BrowseDataHeader.php index 30df037c..2444280f 100644 --- a/src/BrowseDataHeader.php +++ b/src/BrowseDataHeader.php @@ -4,7 +4,7 @@ use PhpTwinfield\Fields\CodeField; -class BrowseDataHeader extends BaseObject +class BrowseDataHeader extends BaseObject implements HasCodeInterface { use CodeField; diff --git a/src/BrowseDataRow.php b/src/BrowseDataRow.php index 41a8e470..985218c4 100644 --- a/src/BrowseDataRow.php +++ b/src/BrowseDataRow.php @@ -5,7 +5,7 @@ use PhpTwinfield\Fields\CodeField; use PhpTwinfield\Fields\OfficeField; -class BrowseDataRow extends BaseObject +class BrowseDataRow extends BaseObject implements HasCodeInterface { use CodeField; use OfficeField; diff --git a/src/BrowseDefinition.php b/src/BrowseDefinition.php index f757a5f6..9bb2b4b0 100644 --- a/src/BrowseDefinition.php +++ b/src/BrowseDefinition.php @@ -7,7 +7,7 @@ use PhpTwinfield\Fields\OfficeField; use PhpTwinfield\Fields\ShortNameField; -class BrowseDefinition extends BaseObject +class BrowseDefinition extends BaseObject implements HasCodeInterface { use CodeField; use NameField; diff --git a/src/BrowseField.php b/src/BrowseField.php index 57651d64..a8d9fdc9 100644 --- a/src/BrowseField.php +++ b/src/BrowseField.php @@ -4,7 +4,7 @@ use PhpTwinfield\Fields\CodeField; -class BrowseField extends BaseObject +class BrowseField extends BaseObject implements HasCodeInterface { use CodeField; diff --git a/src/BrowseFieldOption.php b/src/BrowseFieldOption.php index 2d7f6c0a..a8466110 100644 --- a/src/BrowseFieldOption.php +++ b/src/BrowseFieldOption.php @@ -5,7 +5,7 @@ use PhpTwinfield\Fields\CodeField; use PhpTwinfield\Fields\NameField; -class BrowseFieldOption extends BaseObject +class BrowseFieldOption extends BaseObject implements HasCodeInterface { use CodeField; use NameField; diff --git a/src/BrowseSortField.php b/src/BrowseSortField.php index 9af8d5fe..0a3036b9 100644 --- a/src/BrowseSortField.php +++ b/src/BrowseSortField.php @@ -5,7 +5,7 @@ use PhpTwinfield\Enums\Order; use PhpTwinfield\Fields\CodeField; -class BrowseSortField extends BaseObject +class BrowseSortField extends BaseObject implements HasCodeInterface { use CodeField; diff --git a/src/CashBankBook.php b/src/CashBankBook.php index f49b9ea2..1649185b 100644 --- a/src/CashBankBook.php +++ b/src/CashBankBook.php @@ -11,7 +11,7 @@ * * @author Yannick Aerssens */ -class CashBankBook +class CashBankBook extends BaseObject implements HasCodeInterface { use CodeField; use NameField; diff --git a/src/CashTransaction.php b/src/CashTransaction.php index 6df540b2..78057b25 100644 --- a/src/CashTransaction.php +++ b/src/CashTransaction.php @@ -19,11 +19,6 @@ class CashTransaction extends BaseTransaction use StatementNumberField; - public function __construct() - { - $this->startValue = new \Money\Money(0, new \Money\Currency('EUR')); - } - /* * @return string */ diff --git a/src/CostCenter.php b/src/CostCenter.php index f4b0e545..0e761d4c 100644 --- a/src/CostCenter.php +++ b/src/CostCenter.php @@ -18,7 +18,7 @@ * * @author Yannick Aerssens */ -class CostCenter extends BaseObject +class CostCenter extends BaseObject implements HasCodeInterface { use BehaviourField; use CodeField; @@ -33,6 +33,8 @@ class CostCenter extends BaseObject public function __construct() { - $this->setTypeFromString('KPL'); + $dimensionType = new \PhpTwinfield\DimensionType; + $dimensionType->setCode('KPL'); + $this->setType($dimensionType); } } diff --git a/src/Country.php b/src/Country.php index d53b923f..6fddc5f7 100644 --- a/src/Country.php +++ b/src/Country.php @@ -11,7 +11,7 @@ * * @author Yannick Aerssens */ -class Country +class Country extends BaseObject implements HasCodeInterface { use CodeField; use NameField; diff --git a/src/Currency.php b/src/Currency.php index 682c2459..6d4eb6c6 100644 --- a/src/Currency.php +++ b/src/Currency.php @@ -12,7 +12,7 @@ * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Currencies * @todo Add documentation and typehints to all properties. */ -class Currency extends BaseObject +class Currency extends BaseObject implements HasCodeInterface { use CodeField; use NameField; diff --git a/src/Customer.php b/src/Customer.php index 3d230f32..55dbb5e5 100644 --- a/src/Customer.php +++ b/src/Customer.php @@ -29,7 +29,7 @@ * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers * @todo Add documentation and typehints to all properties. */ -class Customer extends BaseObject +class Customer extends BaseObject implements HasCodeInterface { use BeginPeriodField; use BeginYearField; @@ -67,7 +67,10 @@ public function __construct() $this->setBeginYear(0); $this->setEndPeriod(0); $this->setEndYear(0); - $this->setTypeFromString('DEB'); + + $dimensionType = new \PhpTwinfield\DimensionType; + $dimensionType->setCode('DEB'); + $this->setType($dimensionType); $this->setCreditManagement(new CustomerCreditManagement); $this->setFinancials(new CustomerFinancials); diff --git a/src/CustomerCreditManagement.php b/src/CustomerCreditManagement.php index 5299df62..270539c3 100644 --- a/src/CustomerCreditManagement.php +++ b/src/CustomerCreditManagement.php @@ -34,6 +34,6 @@ class CustomerCreditManagement extends BaseObject public function __construct() { - $this->setSendReminderFromString('true'); + $this->setSendReminder(\PhpTwinfield\Enums\SendReminder::TRUE()); } } diff --git a/src/CustomerFinancials.php b/src/CustomerFinancials.php index aebd3dfc..5295c211 100644 --- a/src/CustomerFinancials.php +++ b/src/CustomerFinancials.php @@ -50,11 +50,11 @@ class CustomerFinancials extends BaseObject public function __construct() { - $this->setAccountTypeFromString('inherit'); - $this->setCollectionSchemaFromString('core'); + $this->setAccountType(\PhpTwinfield\Enums\AccountType::INHERIT()); + $this->setCollectionSchema(\PhpTwinfield\Enums\CollectionSchema::CORE()); $this->setDueDays(30); - $this->setMatchTypeFromString('customersupplier'); - $this->setSubAnalyseFromString('false'); + $this->setMatchType(\PhpTwinfield\Enums\MatchType::CUSTOMERSUPPLIER()); + $this->setSubAnalyse(\PhpTwinfield\Enums\SubAnalyse::FALSE()); $this->setSubstitutionLevel(1); $this->setCollectMandate(new CustomerCollectMandate); diff --git a/src/DimensionGroup.php b/src/DimensionGroup.php index 4d48ff7a..a5c685bd 100644 --- a/src/DimensionGroup.php +++ b/src/DimensionGroup.php @@ -12,7 +12,7 @@ * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionGroups * @todo Add documentation and typehints to all properties. */ -class DimensionGroup extends BaseObject +class DimensionGroup extends BaseObject implements HasCodeInterface { use CodeField; use NameField; diff --git a/src/DimensionType.php b/src/DimensionType.php index b29b2374..47de4228 100644 --- a/src/DimensionType.php +++ b/src/DimensionType.php @@ -13,7 +13,7 @@ * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionTypes * @todo Add documentation and typehints to all properties. */ -class DimensionType extends BaseObject +class DimensionType extends BaseObject implements HasCodeInterface { use CodeField; use MaskField; diff --git a/src/DomDocuments/ActivitiesDocument.php b/src/DomDocuments/ActivitiesDocument.php index 0ee0e432..24d7d3e8 100644 --- a/src/DomDocuments/ActivitiesDocument.php +++ b/src/DomDocuments/ActivitiesDocument.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\DomDocuments; use PhpTwinfield\Activity; +use PhpTwinfield\Util; /** * The Document Holder for making new XML Activity. Is a child class @@ -47,14 +48,14 @@ public function addActivity(Activity $activity) } $activityElement->appendChild($this->createNodeWithTextContent('name', $activity->getName())); - $activityElement->appendChild($this->createNodeWithTextContent('office', $activity->getOfficeToString())); + $activityElement->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($activity->getOffice()))); $activityElement->appendChild($this->createNodeWithTextContent('shortname', $activity->getShortName())); - $activityElement->appendChild($this->createNodeWithTextContent('type', $activity->getTypeToString())); + $activityElement->appendChild($this->createNodeWithTextContent('type', Util::objectToStr($activity->getType()))); $financialsElement = $this->createElement('financials'); $activityElement->appendChild($financialsElement); - $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $activity->getVatCodeToString())); + $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', Util::objectToStr($activity->getVatCode()))); $projects = $activity->getProjects(); @@ -86,8 +87,8 @@ public function addActivity(Activity $activity) } $projectsElement->appendChild($this->createNodeWithTextContent('invoicedescription', $projects->getInvoiceDescription())); - $projectsElement->appendChild($this->createNodeWithTextContent('validfrom', $projects->getValidFromToString())); - $projectsElement->appendChild($this->createNodeWithTextContent('validtill', $projects->getValidTillToString())); + $projectsElement->appendChild($this->createNodeWithTextContent('validfrom', Util::formatDate($projects->getValidFrom()))); + $projectsElement->appendChild($this->createNodeWithTextContent('validtill', Util::formatDate($projects->getValidTill()))); $quantities = $projects->getQuantities(); @@ -103,9 +104,9 @@ public function addActivity(Activity $activity) $quantitiesElement->appendChild($quantityElement); $quantityElement->appendChild($this->createNodeWithTextContent('label', $quantity->getLabel())); - $quantityElement->appendChild($this->createNodeWithTextContent('rate', $quantity->getRateToString())); - $quantityElement->appendChild($this->createNodeWithTextContent('billable', $quantity->getBillableToString(), $quantity, array('locked' => 'getBillableLockedToString'))); - $quantityElement->appendChild($this->createNodeWithTextContent('mandatory', $quantity->getMandatoryToString())); + $quantityElement->appendChild($this->createNodeWithTextContent('rate', Util::objectToStr($quantity->getRate()))); + $quantityElement->appendChild($this->createNodeWithTextContent('billable', Util::formatBoolean($quantity->getBillable()), $quantity, array('locked' => 'getBillableLockedToString'))); + $quantityElement->appendChild($this->createNodeWithTextContent('mandatory', Util::formatBoolean($quantity->getMandatory()))); } } } diff --git a/src/DomDocuments/ArticlesDocument.php b/src/DomDocuments/ArticlesDocument.php index a3c2f39b..88367196 100644 --- a/src/DomDocuments/ArticlesDocument.php +++ b/src/DomDocuments/ArticlesDocument.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\DomDocuments; use PhpTwinfield\Article; +use PhpTwinfield\Util; /** * The Document Holder for making new XML Article. Is a child class @@ -46,21 +47,21 @@ public function addArticle(Article $article) $headerElement->setAttribute('status', $status); } - $headerElement->appendChild($this->createNodeWithTextContent('allowchangeperformancetype', $article->getAllowChangePerformanceTypeToString())); - $headerElement->appendChild($this->createNodeWithTextContent('allowchangeunitsprice', $article->getAllowChangeUnitsPriceToString())); - $headerElement->appendChild($this->createNodeWithTextContent('allowchangevatcode', $article->getAllowChangeVatCodeToString())); - $headerElement->appendChild($this->createNodeWithTextContent('allowdecimalquantity', $article->getAllowDecimalQuantityToString())); - $headerElement->appendChild($this->createNodeWithTextContent('allowdiscountorpremium', $article->getAllowDiscountOrPremiumToString())); + $headerElement->appendChild($this->createNodeWithTextContent('allowchangeperformancetype', Util::formatBoolean($article->getAllowChangePerformanceType()))); + $headerElement->appendChild($this->createNodeWithTextContent('allowchangeunitsprice', Util::formatBoolean($article->getAllowChangeUnitsPrice()))); + $headerElement->appendChild($this->createNodeWithTextContent('allowchangevatcode', Util::formatBoolean($article->getAllowChangeVatCode()))); + $headerElement->appendChild($this->createNodeWithTextContent('allowdecimalquantity', Util::formatBoolean($article->getAllowDecimalQuantity()))); + $headerElement->appendChild($this->createNodeWithTextContent('allowdiscountorpremium', Util::formatBoolean($article->getAllowDiscountOrPremium()))); $headerElement->appendChild($this->createNodeWithTextContent('code', $article->getCode())); - $headerElement->appendChild($this->createNodeWithTextContent('office', $article->getOfficeToString())); + $headerElement->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($article->getOffice()))); $headerElement->appendChild($this->createNodeWithTextContent('name', $article->getName())); - $headerElement->appendChild($this->createNodeWithTextContent('percentage', $article->getPercentageToString())); + $headerElement->appendChild($this->createNodeWithTextContent('percentage', Util::formatBoolean($article->getPercentage()))); $headerElement->appendChild($this->createNodeWithTextContent('performancetype', $article->getPerformanceType())); $headerElement->appendChild($this->createNodeWithTextContent('shortname', $article->getShortName())); $headerElement->appendChild($this->createNodeWithTextContent('type', $article->getType())); $headerElement->appendChild($this->createNodeWithTextContent('unitnameplural', $article->getUnitNamePlural())); $headerElement->appendChild($this->createNodeWithTextContent('unitnamesingular', $article->getUnitNameSingular())); - $headerElement->appendChild($this->createNodeWithTextContent('vatcode', $article->getVatCodeToString())); + $headerElement->appendChild($this->createNodeWithTextContent('vatcode', Util::objectToStr($article->getVatCode()))); //Clear VAT code in case of a discount/premium article with percentage set to true to prevent errors if ($article->getType() != "normal" && $article->getPercentage() == true) { @@ -92,15 +93,15 @@ public function addArticle(Article $article) $lineElement->setAttribute('status', $status); } - $lineElement->appendChild($this->createNodeWithTextContent('freetext1', $line->getFreeText1ToString())); - $lineElement->appendChild($this->createNodeWithTextContent('freetext2', $line->getFreeText2ToString())); + $lineElement->appendChild($this->createNodeWithTextContent('freetext1', Util::objectToStr($line->getFreeText1()))); + $lineElement->appendChild($this->createNodeWithTextContent('freetext2', Util::objectToStr($line->getFreeText2()))); $lineElement->appendChild($this->createNodeWithTextContent('freetext3', $line->getFreeText3())); $lineElement->appendChild($this->createNodeWithTextContent('name', $line->getName())); $lineElement->appendChild($this->createNodeWithTextContent('shortname', $line->getShortName())); $lineElement->appendChild($this->createNodeWithTextContent('subcode', $line->getSubCode())); $lineElement->appendChild($this->createNodeWithTextContent('units', $line->getUnits())); - $lineElement->appendChild($this->createNodeWithTextContent('unitspriceexcl', $line->getUnitsPriceExclToFloat())); - $lineElement->appendChild($this->createNodeWithTextContent('unitspriceinc', $line->getUnitsPriceIncToFloat())); + $lineElement->appendChild($this->createNodeWithTextContent('unitspriceexcl', Util::formatMoney($line->getUnitsPriceExcl()))); + $lineElement->appendChild($this->createNodeWithTextContent('unitspriceinc', Util::formatMoney($line->getUnitsPriceInc()))); } } } diff --git a/src/DomDocuments/AssetMethodsDocument.php b/src/DomDocuments/AssetMethodsDocument.php index b0f3dff5..e5e5a255 100644 --- a/src/DomDocuments/AssetMethodsDocument.php +++ b/src/DomDocuments/AssetMethodsDocument.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\DomDocuments; use PhpTwinfield\AssetMethod; +use PhpTwinfield\Util; /** * The Document Holder for making new XML AssetMethod. Is a child class @@ -47,7 +48,7 @@ public function addAssetMethod(AssetMethod $assetMethod) $assetMethodElement->appendChild($this->createNodeWithTextContent('depreciatereconciliation', $assetMethod->getDepreciateReconciliation())); $assetMethodElement->appendChild($this->createNodeWithTextContent('name', $assetMethod->getName())); $assetMethodElement->appendChild($this->createNodeWithTextContent('nrofperiods', $assetMethod->getNrOfPeriods())); - $assetMethodElement->appendChild($this->createNodeWithTextContent('office', $assetMethod->getOfficeToString())); + $assetMethodElement->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($assetMethod->getOffice()))); $assetMethodElement->appendChild($this->createNodeWithTextContent('percentage', $assetMethod->getPercentage())); $assetMethodElement->appendChild($this->createNodeWithTextContent('shortname', $assetMethod->getShortName())); @@ -56,22 +57,22 @@ public function addAssetMethod(AssetMethod $assetMethod) $balanceAccountsElement = $this->createElement('balanceaccounts'); $assetMethodElement->appendChild($balanceAccountsElement); - $balanceAccountsElement->appendChild($this->createNodeWithTextContent('assetstoactivate', $balanceAccounts->getAssetsToActivateToString())); - $balanceAccountsElement->appendChild($this->createNodeWithTextContent('depreciation', $balanceAccounts->getDepreciationToString())); - $balanceAccountsElement->appendChild($this->createNodeWithTextContent('depreciationgroup', $balanceAccounts->getDepreciationGroupToString())); - $balanceAccountsElement->appendChild($this->createNodeWithTextContent('purchasevalue', $balanceAccounts->getPurchaseValueToString())); - $balanceAccountsElement->appendChild($this->createNodeWithTextContent('purchasevaluegroup', $balanceAccounts->getPurchaseValueGroupToString())); - $balanceAccountsElement->appendChild($this->createNodeWithTextContent('reconciliation', $balanceAccounts->getReconciliationToString())); - $balanceAccountsElement->appendChild($this->createNodeWithTextContent('tobeinvoiced', $balanceAccounts->getToBeInvoicedToString())); + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('assetstoactivate', Util::objectToStr($balanceAccounts->getAssetsToActivate()))); + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('depreciation', Util::objectToStr($balanceAccounts->getDepreciation()))); + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('depreciationgroup', Util::objectToStr($balanceAccounts->getDepreciationGroup()))); + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('purchasevalue', Util::objectToStr($balanceAccounts->getPurchaseValue()))); + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('purchasevaluegroup', Util::objectToStr($balanceAccounts->getPurchaseValueGroup()))); + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('reconciliation', Util::objectToStr($balanceAccounts->getReconciliation()))); + $balanceAccountsElement->appendChild($this->createNodeWithTextContent('tobeinvoiced', Util::objectToStr($balanceAccounts->getToBeInvoiced()))); $profitLossAccounts = $assetMethod->getProfitLossAccounts(); $profitLossAccountsElement = $this->createElement('profitlossaccounts'); $assetMethodElement->appendChild($profitLossAccountsElement); - $profitLossAccountsElement->appendChild($this->createNodeWithTextContent('depreciation', $profitLossAccounts->getDepreciationToString())); - $profitLossAccountsElement->appendChild($this->createNodeWithTextContent('reconciliation', $profitLossAccounts->getReconciliationToString())); - $profitLossAccountsElement->appendChild($this->createNodeWithTextContent('sales', $profitLossAccounts->getSalesToString())); + $profitLossAccountsElement->appendChild($this->createNodeWithTextContent('depreciation', Util::objectToStr($profitLossAccounts->getDepreciation()))); + $profitLossAccountsElement->appendChild($this->createNodeWithTextContent('reconciliation', Util::objectToStr($profitLossAccounts->getReconciliation()))); + $profitLossAccountsElement->appendChild($this->createNodeWithTextContent('sales', Util::objectToStr($profitLossAccounts->getSales()))); $freeTexts = $assetMethod->getFreeTexts(); diff --git a/src/DomDocuments/BookingReferenceDeletionDocument.php b/src/DomDocuments/BookingReferenceDeletionDocument.php index 4282ddb4..839b43b5 100644 --- a/src/DomDocuments/BookingReferenceDeletionDocument.php +++ b/src/DomDocuments/BookingReferenceDeletionDocument.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\DomDocuments; use PhpTwinfield\BookingReference; +use PhpTwinfield\Util; class BookingReferenceDeletionDocument extends BaseDocument { @@ -18,7 +19,7 @@ public function __construct(BookingReference $bookingReference, string $reason) $this->rootElement->setAttribute("action", "delete"); $this->rootElement->setAttribute("reason", $reason); - $this->rootElement->appendChild($this->createNodeWithTextContent('office', $bookingReference->getOfficeToString())); + $this->rootElement->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($bookingReference->getOffice()))); $this->rootElement->appendChild( $this->createNodeWithTextContent("code", $bookingReference->getCode()) diff --git a/src/DomDocuments/CostCentersDocument.php b/src/DomDocuments/CostCentersDocument.php index d978ff26..7f6097db 100644 --- a/src/DomDocuments/CostCentersDocument.php +++ b/src/DomDocuments/CostCentersDocument.php @@ -47,7 +47,7 @@ public function addCostCenter(CostCenter $costCenter) } $costCenterElement->appendChild($this->createNodeWithTextContent('name', $costCenter->getName())); - $costCenterElement->appendChild($this->createNodeWithTextContent('office', $costCenter->getOfficeToString())); - $costCenterElement->appendChild($this->createNodeWithTextContent('type', $costCenter->getTypeToString())); + $costCenterElement->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($costCenter->getOffice()))); + $costCenterElement->appendChild($this->createNodeWithTextContent('type', Util::objectToStr($costCenter->getType()))); } } diff --git a/src/DomDocuments/CurrenciesDocument.php b/src/DomDocuments/CurrenciesDocument.php index a92ec65f..2c3ff9bd 100644 --- a/src/DomDocuments/CurrenciesDocument.php +++ b/src/DomDocuments/CurrenciesDocument.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\DomDocuments; use PhpTwinfield\Currency; +use PhpTwinfield\Util; /** * The Document Holder for making new XML Currency. Is a child class @@ -44,7 +45,7 @@ public function addCurrency(Currency $currency) $currencyElement->appendChild($this->createNodeWithTextContent('code', $currency->getCode())); $currencyElement->appendChild($this->createNodeWithTextContent('name', $currency->getName())); - $currencyElement->appendChild($this->createNodeWithTextContent('office', $currency->getOfficeToString())); + $currencyElement->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($currency->getOffice()))); $currencyElement->appendChild($this->createNodeWithTextContent('shortname', $currency->getShortName())); $rates = $currency->getRates(); @@ -67,7 +68,7 @@ public function addCurrency(Currency $currency) } $rateElement->appendChild($this->createNodeWithTextContent('rate', $rate->getRate())); - $rateElement->appendChild($this->createNodeWithTextContent('startdate', $rate->getStartDateToString())); + $rateElement->appendChild($this->createNodeWithTextContent('startdate', Util::formatDate($rate->getStartDate()))); } } } diff --git a/src/DomDocuments/CustomersDocument.php b/src/DomDocuments/CustomersDocument.php index 086f67d6..a6ef0058 100644 --- a/src/DomDocuments/CustomersDocument.php +++ b/src/DomDocuments/CustomersDocument.php @@ -2,6 +2,7 @@ namespace PhpTwinfield\DomDocuments; use PhpTwinfield\Customer; +use PhpTwinfield\Util; /** * The Document Holder for making new XML Customer. Is a child class @@ -52,9 +53,9 @@ public function addCustomer(Customer $customer) $customerElement->appendChild($this->createNodeWithTextContent('endperiod', $customer->getEndPeriod())); $customerElement->appendChild($this->createNodeWithTextContent('endyear', $customer->getEndYear())); $customerElement->appendChild($this->createNodeWithTextContent('name', $customer->getName())); - $customerElement->appendChild($this->createNodeWithTextContent('office', $customer->getOfficeToString())); + $customerElement->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($customer->getOffice()))); $customerElement->appendChild($this->createNodeWithTextContent('shortname', $customer->getShortName())); - $customerElement->appendChild($this->createNodeWithTextContent('type', $customer->getTypeToString())); + $customerElement->appendChild($this->createNodeWithTextContent('type', Util::objectToStr($customer->getType()))); $customerElement->appendChild($this->createNodeWithTextContent('website', $customer->getWebsite())); $financials = $customer->getFinancials(); @@ -64,13 +65,13 @@ public function addCustomer(Customer $customer) $financialsElement->appendChild($this->createNodeWithTextContent('collectionschema', $financials->getCollectionSchema())); $financialsElement->appendChild($this->createNodeWithTextContent('duedays', $financials->getDueDays())); - $financialsElement->appendChild($this->createNodeWithTextContent('ebilling', $financials->getEBillingToString())); + $financialsElement->appendChild($this->createNodeWithTextContent('ebilling', Util::formatBoolean($financials->getEBilling()))); $financialsElement->appendChild($this->createNodeWithTextContent('ebillmail', $financials->getEBillMail())); $financialsElement->appendChild($this->createNodeWithTextContent('meansofpayment', $financials->getMeansOfPayment())); - $financialsElement->appendChild($this->createNodeWithTextContent('payavailable', $financials->getPayAvailableToString())); - $financialsElement->appendChild($this->createNodeWithTextContent('paycode', $financials->getPayCodeToString())); - $financialsElement->appendChild($this->createNodeWithTextContent('substitutewith', $financials->getSubstituteWithToString())); - $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $financials->getVatCodeToString())); + $financialsElement->appendChild($this->createNodeWithTextContent('payavailable', Util::formatBoolean($financials->getPayAvailable()))); + $financialsElement->appendChild($this->createNodeWithTextContent('paycode', Util::objectToStr($financials->getPayCode()))); + $financialsElement->appendChild($this->createNodeWithTextContent('substitutewith', Util::objectToStr($financials->getSubstituteWith()))); + $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', Util::objectToStr($financials->getVatCode()))); $collectMandate = $financials->getCollectMandate(); @@ -79,9 +80,9 @@ public function addCustomer(Customer $customer) $collectMandateElement = $this->createElement('collectmandate'); $financialsElement->appendChild($collectMandateElement); - $collectMandateElement->appendChild($this->createNodeWithTextContent('firstrundate', $collectMandate->getFirstRunDateToString())); + $collectMandateElement->appendChild($this->createNodeWithTextContent('firstrundate', Util::formatDate($collectMandate->getFirstRunDate()))); $collectMandateElement->appendChild($this->createNodeWithTextContent('id', $collectMandate->getID())); - $collectMandateElement->appendChild($this->createNodeWithTextContent('signaturedate', $collectMandate->getSignatureDateToString())); + $collectMandateElement->appendChild($this->createNodeWithTextContent('signaturedate', Util::formatDate($collectMandate->getSignatureDate()))); } $childValidations = $financials->getChildValidations(); @@ -104,21 +105,21 @@ public function addCustomer(Customer $customer) $creditManagementElement = $this->createElement('creditmanagement'); $customerElement->appendChild($creditManagementElement); - $creditManagementElement->appendChild($this->createNodeWithTextContent('basecreditlimit', $creditManagement->getBaseCreditLimitToFloat())); - $creditManagementElement->appendChild($this->createNodeWithTextContent('blocked', $creditManagement->getBlockedToString())); + $creditManagementElement->appendChild($this->createNodeWithTextContent('basecreditlimit', Util::formatMoney($creditManagement->getBaseCreditLimit()))); + $creditManagementElement->appendChild($this->createNodeWithTextContent('blocked', Util::formatBoolean($creditManagement->getBlocked()))); $creditManagementElement->appendChild($this->createNodeWithTextContent('comment', $creditManagement->getComment())); - $creditManagementElement->appendChild($this->createNodeWithTextContent('freetext1', $creditManagement->getFreeText1ToString())); + $creditManagementElement->appendChild($this->createNodeWithTextContent('freetext1', Util::formatBoolean($creditManagement->getFreeText1()))); $creditManagementElement->appendChild($this->createNodeWithTextContent('freetext2', $creditManagement->getFreeText2())); $creditManagementElement->appendChild($this->createNodeWithTextContent('freetext3', $creditManagement->getFreeText3())); $creditManagementElement->appendChild($this->createNodeWithTextContent('reminderemail', $creditManagement->getReminderEmail())); - $creditManagementElement->appendChild($this->createNodeWithTextContent('responsibleuser', $creditManagement->getResponsibleUserToString())); + $creditManagementElement->appendChild($this->createNodeWithTextContent('responsibleuser', Util::objectToStr($creditManagement->getResponsibleUser()))); $creditManagementElement->appendChild($this->createNodeWithTextContent('sendreminder', $creditManagement->getSendReminder())); // Make invoicing element $invoicingElement = $this->createElement('invoicing'); $customerElement->appendChild($invoicingElement); - $invoicingElement->appendChild($this->createNodeWithTextContent('discountarticle', $customer->getDiscountArticleToString())); + $invoicingElement->appendChild($this->createNodeWithTextContent('discountarticle', Util::objectToStr($customer->getDiscountArticle()))); $addresses = $customer->getAddresses(); @@ -133,7 +134,7 @@ public function addCustomer(Customer $customer) $addressElement = $this->createElement('address'); $addressesElement->appendChild($addressElement); - $default = $address->getDefaultToString(); + $default = Util::formatBoolean($address->getDefault()); if (!empty($default)) { $addressElement->setAttribute('default', $default); @@ -152,7 +153,7 @@ public function addCustomer(Customer $customer) } $addressElement->appendChild($this->createNodeWithTextContent('city', $address->getCity())); - $addressElement->appendChild($this->createNodeWithTextContent('country', $address->getCountryToString())); + $addressElement->appendChild($this->createNodeWithTextContent('country', Util::objectToStr($address->getCountry()))); $addressElement->appendChild($this->createNodeWithTextContent('email', $address->getEmail())); $addressElement->appendChild($this->createNodeWithTextContent('field1', $address->getField1())); $addressElement->appendChild($this->createNodeWithTextContent('field2', $address->getField2())); @@ -180,7 +181,7 @@ public function addCustomer(Customer $customer) $bankElement = $this->createElement('bank'); $banksElement->appendChild($bankElement); - $default = $bank->getDefaultToString(); + $default = Util::formatBoolean($bank->getDefault()); if (!empty($default)) { $bankElement->setAttribute('default', $default); @@ -202,7 +203,7 @@ public function addCustomer(Customer $customer) $bankElement->appendChild($this->createNodeWithTextContent('bankname', $bank->getBankName())); $bankElement->appendChild($this->createNodeWithTextContent('biccode', $bank->getBicCode())); $bankElement->appendChild($this->createNodeWithTextContent('city', $bank->getCity())); - $bankElement->appendChild($this->createNodeWithTextContent('country', $bank->getCountryToString())); + $bankElement->appendChild($this->createNodeWithTextContent('country', Util::objectToStr($bank->getCountry()))); $bankElement->appendChild($this->createNodeWithTextContent('iban', $bank->getIban())); $bankElement->appendChild($this->createNodeWithTextContent('natbiccode', $bank->getNatBicCode())); $bankElement->appendChild($this->createNodeWithTextContent('postcode', $bank->getPostcode())); @@ -216,7 +217,7 @@ public function addCustomer(Customer $customer) $remittanceAdviceElement->appendChild($this->createNodeWithTextContent('sendmail', $customer->getRemittanceAdviceSendMail())); $remittanceAdviceElement->appendChild($this->createNodeWithTextContent('sendtype', $customer->getRemittanceAdviceSendType())); - $group = $customer->getGroupToString(); + $group = Util::objectToStr($customer->getGroup()); if (!empty($group)) { $groupsElement = $this->createElement('groups'); @@ -249,8 +250,8 @@ public function addCustomer(Customer $customer) $postingRuleElement->setAttribute('status', $status); } - $postingRuleElement->appendChild($this->createNodeWithTextContent('amount', $postingRule->getAmountToFloat())); - $postingRuleElement->appendChild($this->createNodeWithTextContent('currency', $postingRule->getCurrencyToString())); + $postingRuleElement->appendChild($this->createNodeWithTextContent('amount', Util::formatMoney($postingRule->getAmount()))); + $postingRuleElement->appendChild($this->createNodeWithTextContent('currency', Util::objectToStr($postingRule->getCurrency()))); $postingRuleElement->appendChild($this->createNodeWithTextContent('description', $postingRule->getDescription())); $postingRuleLines = $postingRule->getLines(); @@ -266,13 +267,13 @@ public function addCustomer(Customer $customer) $postingRuleLineElement = $this->createElement('line'); $postingRuleLinesElement->appendChild($postingRuleLineElement); - $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension1', $postingRuleLine->getDimension1ToString())); - $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension2', $postingRuleLine->getDimension2ToString())); - $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension3', $postingRuleLine->getDimension3ToString())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension1', Util::objectToStr($postingRuleLine->getDimension1()))); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension2', Util::objectToStr($postingRuleLine->getDimension2()))); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension3', Util::objectToStr($postingRuleLine->getDimension3()))); $postingRuleLineElement->appendChild($this->createNodeWithTextContent('description', $postingRuleLine->getDescription())); - $postingRuleLineElement->appendChild($this->createNodeWithTextContent('office', $postingRuleLine->getOfficeToString())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($postingRuleLine->getOffice()))); $postingRuleLineElement->appendChild($this->createNodeWithTextContent('ratio', $postingRuleLine->getRatio())); - $postingRuleLineElement->appendChild($this->createNodeWithTextContent('vatcode', $postingRuleLine->getVatCodeToString())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('vatcode', Util::objectToStr($postingRuleLine->getVatCode()))); } } } diff --git a/src/DomDocuments/DimensionGroupsDocument.php b/src/DomDocuments/DimensionGroupsDocument.php index c33ebae9..d0308a63 100644 --- a/src/DomDocuments/DimensionGroupsDocument.php +++ b/src/DomDocuments/DimensionGroupsDocument.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\DomDocuments; use PhpTwinfield\DimensionGroup; +use PhpTwinfield\Util; /** * The Document Holder for making new XML DimensionGroup. Is a child class @@ -44,7 +45,7 @@ public function addDimensionGroup(DimensionGroup $dimensionGroup) $dimensionGroupElement->appendChild($this->createNodeWithTextContent('code', $dimensionGroup->getCode())); $dimensionGroupElement->appendChild($this->createNodeWithTextContent('name', $dimensionGroup->getName())); - $dimensionGroupElement->appendChild($this->createNodeWithTextContent('office', $dimensionGroup->getOfficeToString())); + $dimensionGroupElement->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($dimensionGroup->getOffice()))); $dimensionGroupElement->appendChild($this->createNodeWithTextContent('shortname', $dimensionGroup->getShortName())); $dimensions = $dimensionGroup->getDimensions(); @@ -60,8 +61,8 @@ public function addDimensionGroup(DimensionGroup $dimensionGroup) $dimensionElement = $this->createElement('dimension'); $dimensionsElement->appendChild($dimensionElement); - $dimensionElement->appendChild($this->createNodeWithTextContent('code', $dimension->getCodeToString())); - $dimensionElement->appendChild($this->createNodeWithTextContent('type', $dimension->getTypeToString())); + $dimensionElement->appendChild($this->createNodeWithTextContent('code', Util::objectToStr($dimension->getCode()))); + $dimensionElement->appendChild($this->createNodeWithTextContent('type', Util::objectToStr($dimension->getType()))); } } } diff --git a/src/DomDocuments/DimensionTypesDocument.php b/src/DomDocuments/DimensionTypesDocument.php index 4b46bb4a..c1e2a8bc 100644 --- a/src/DomDocuments/DimensionTypesDocument.php +++ b/src/DomDocuments/DimensionTypesDocument.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\DomDocuments; use PhpTwinfield\DimensionType; +use PhpTwinfield\Util; /** * The Document Holder for making new XML DimensionType. Is a child class @@ -39,7 +40,7 @@ public function addDimensionType(DimensionType $dimensionType) $dimensionTypeElement->appendChild($this->createNodeWithTextContent('code', $dimensionType->getCode())); $dimensionTypeElement->appendChild($this->createNodeWithTextContent('mask', $dimensionType->getMask())); $dimensionTypeElement->appendChild($this->createNodeWithTextContent('name', $dimensionType->getName())); - $dimensionTypeElement->appendChild($this->createNodeWithTextContent('office', $dimensionType->getOfficeToString())); + $dimensionTypeElement->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($dimensionType->getOffice()))); $dimensionTypeElement->appendChild($this->createNodeWithTextContent('shortname', $dimensionType->getShortName())); $address = $dimensionType->getAddress(); diff --git a/src/DomDocuments/ElectronicBankStatementDocument.php b/src/DomDocuments/ElectronicBankStatementDocument.php index 6a16f9b7..b805dd27 100644 --- a/src/DomDocuments/ElectronicBankStatementDocument.php +++ b/src/DomDocuments/ElectronicBankStatementDocument.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\DomDocuments; use PhpTwinfield\ElectronicBankStatement; +use PhpTwinfield\Util; class ElectronicBankStatementDocument extends BaseDocument { @@ -28,14 +29,14 @@ public function addStatement(ElectronicBankStatement $electronicBankStatement) $statement->appendChild($this->createNodeWithTextContent("code", $electronicBankStatement->getCode())); } - $statement->appendChild($this->createNodeWithTextContent("date", $electronicBankStatement->getDateToString())); - $statement->appendChild($this->createNodeWithTextContent("currency", $electronicBankStatement->getCurrencyToString())); - $statement->appendChild($this->createNodeWithTextContent("startvalue", $electronicBankStatement->getStartValueToFloat())); - $statement->appendChild($this->createNodeWithTextContent("closevalue", $electronicBankStatement->getCloseValueToFloat())); + $statement->appendChild($this->createNodeWithTextContent("date", Util::formatDate($electronicBankStatement->getDate()))); + $statement->appendChild($this->createNodeWithTextContent("currency", Util::objectToStr($electronicBankStatement->getCurrency()))); + $statement->appendChild($this->createNodeWithTextContent("startvalue", Util::formatMoney($electronicBankStatement->getStartValue()))); + $statement->appendChild($this->createNodeWithTextContent("closevalue", Util::formatMoney($electronicBankStatement->getCloseValue()))); $statement->appendChild($this->createNodeWithTextContent("statementnumber", $electronicBankStatement->getStatementnumber())); if ($electronicBankStatement->getOffice()) { - $statement->appendChild($this->createNodeWithTextContent("office", $electronicBankStatement->getOfficeToString())); + $statement->appendChild($this->createNodeWithTextContent("office", Util::objectToStr($electronicBankStatement->getOffice()))); } $transactions = $this->createElement("transactions"); @@ -57,7 +58,7 @@ public function addStatement(ElectronicBankStatement $electronicBankStatement) } $node->appendChild($this->createNodeWithTextContent('debitcredit', $transaction->getDebitCredit())); - $node->appendChild($this->createNodeWithTextContent('value', $transaction->getValueToFloat())); + $node->appendChild($this->createNodeWithTextContent('value', Util::formatMoney($transaction->getValue()))); $node->appendChild($this->createNodeWithTextContent("description", $transaction->getDescription())); $transactions->appendChild($node); diff --git a/src/DomDocuments/FixedAssetsDocument.php b/src/DomDocuments/FixedAssetsDocument.php index 8d88be51..24180c3c 100644 --- a/src/DomDocuments/FixedAssetsDocument.php +++ b/src/DomDocuments/FixedAssetsDocument.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\DomDocuments; use PhpTwinfield\FixedAsset; +use PhpTwinfield\Util; /** * The Document Holder for making new XML FixedAsset. Is a child class @@ -47,8 +48,8 @@ public function addFixedAsset(FixedAsset $fixedAsset) } $fixedAssetElement->appendChild($this->createNodeWithTextContent('name', $fixedAsset->getName())); - $fixedAssetElement->appendChild($this->createNodeWithTextContent('office', $fixedAsset->getOfficeToString())); - $fixedAssetElement->appendChild($this->createNodeWithTextContent('type', $fixedAsset->getTypeToString())); + $fixedAssetElement->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($fixedAsset->getOffice()))); + $fixedAssetElement->appendChild($this->createNodeWithTextContent('type', Util::objectToStr($fixedAsset->getType()))); $financials = $fixedAsset->getFinancials(); @@ -56,8 +57,8 @@ public function addFixedAsset(FixedAsset $fixedAsset) $fixedAssetElement->appendChild($financialsElement); $financialsElement->appendChild($this->createNodeWithTextContent('substitutionlevel', $financials->getSubstitutionLevel())); - $financialsElement->appendChild($this->createNodeWithTextContent('substitutewith', $financials->getSubstituteWithToString())); - $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $financials->getVatCodeToString())); + $financialsElement->appendChild($this->createNodeWithTextContent('substitutewith', Util::objectToStr($financials->getSubstituteWith()))); + $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', Util::objectToStr($financials->getVatCode()))); $fixedAssets = $fixedAsset->getFixedAssets(); @@ -71,13 +72,13 @@ public function addFixedAsset(FixedAsset $fixedAsset) $fixedAssetsElement->appendChild($this->createNodeWithTextContent('freetext4', $fixedAssets->getFreeText4())); $fixedAssetsElement->appendChild($this->createNodeWithTextContent('freetext5', $fixedAssets->getFreeText5())); $fixedAssetsElement->appendChild($this->createNodeWithTextContent('lastdepreciation', $fixedAssets->getLastDepreciation())); - $fixedAssetsElement->appendChild($this->createNodeWithTextContent('method', $fixedAssets->getMethodToString())); + $fixedAssetsElement->appendChild($this->createNodeWithTextContent('method', Util::objectToStr($fixedAssets->getMethod()))); $fixedAssetsElement->appendChild($this->createNodeWithTextContent('nrofperiods', $fixedAssets->getNrOfPeriods())); $fixedAssetsElement->appendChild($this->createNodeWithTextContent('percentage', $fixedAssets->getPercentage())); - $fixedAssetsElement->appendChild($this->createNodeWithTextContent('purchasedate', $fixedAssets->getPurchaseDateToString())); - $fixedAssetsElement->appendChild($this->createNodeWithTextContent('residualvalue', $fixedAssets->getResidualValueToFloat())); - $fixedAssetsElement->appendChild($this->createNodeWithTextContent('selldate', $fixedAssets->getSellDateToString())); - $fixedAssetsElement->appendChild($this->createNodeWithTextContent('stopvalue', $fixedAssets->getStopValueToFloat())); + $fixedAssetsElement->appendChild($this->createNodeWithTextContent('purchasedate', Util::formatDate($fixedAssets->getPurchaseDate()))); + $fixedAssetsElement->appendChild($this->createNodeWithTextContent('residualvalue', Util::formatMoney($fixedAssets->getResidualValue()))); + $fixedAssetsElement->appendChild($this->createNodeWithTextContent('selldate', Util::formatDate($fixedAssets->getSellDate()))); + $fixedAssetsElement->appendChild($this->createNodeWithTextContent('stopvalue', Util::formatMoney($fixedAssets->getStopValue()))); $transactionLines = $fixedAssets->getTransactionLines(); @@ -92,21 +93,21 @@ public function addFixedAsset(FixedAsset $fixedAsset) $transactionLineElement = $this->createElement('transline'); $transactionLinesElement->appendChild($transactionLineElement); - $transactionLineElement->appendChild($this->createNodeWithTextContent('amount', $transactionLine->getAmountToFloat())); - $transactionLineElement->appendChild($this->createNodeWithTextContent('code', $transactionLine->getCodeToString())); - $transactionLineElement->appendChild($this->createNodeWithTextContent('dim1', $transactionLine->getDim1ToString())); - $transactionLineElement->appendChild($this->createNodeWithTextContent('dim2', $transactionLine->getDim2ToString())); - $transactionLineElement->appendChild($this->createNodeWithTextContent('dim3', $transactionLine->getDim3ToString())); - $transactionLineElement->appendChild($this->createNodeWithTextContent('dim4', $transactionLine->getDim4ToString())); - $transactionLineElement->appendChild($this->createNodeWithTextContent('dim5', $transactionLine->getDim5ToString())); - $transactionLineElement->appendChild($this->createNodeWithTextContent('dim6', $transactionLine->getDim6ToString())); + $transactionLineElement->appendChild($this->createNodeWithTextContent('amount', Util::formatMoney($transactionLine->getAmount()))); + $transactionLineElement->appendChild($this->createNodeWithTextContent('code', Util::objectToStr($transactionLine->getCode()))); + $transactionLineElement->appendChild($this->createNodeWithTextContent('dim1', Util::objectToStr($transactionLine->getDim1()))); + $transactionLineElement->appendChild($this->createNodeWithTextContent('dim2', Util::objectToStr($transactionLine->getDim2()))); + $transactionLineElement->appendChild($this->createNodeWithTextContent('dim3', Util::objectToStr($transactionLine->getDim3()))); + $transactionLineElement->appendChild($this->createNodeWithTextContent('dim4', Util::objectToStr($transactionLine->getDim4()))); + $transactionLineElement->appendChild($this->createNodeWithTextContent('dim5', Util::objectToStr($transactionLine->getDim5()))); + $transactionLineElement->appendChild($this->createNodeWithTextContent('dim6', Util::objectToStr($transactionLine->getDim6()))); $transactionLineElement->appendChild($this->createNodeWithTextContent('line', $transactionLine->getLine())); $transactionLineElement->appendChild($this->createNodeWithTextContent('number', $transactionLine->getNumber())); $transactionLineElement->appendChild($this->createNodeWithTextContent('period', $transactionLine->getPeriod())); } } - $group = $fixedAsset->getGroupToString(); + $group = Util::objectToStr($fixedAsset->getGroup()); if (!empty($group)) { $groupsElement = $this->createElement('groups'); diff --git a/src/DomDocuments/GeneralLedgersDocument.php b/src/DomDocuments/GeneralLedgersDocument.php index db9bb8fd..9b10f1a7 100644 --- a/src/DomDocuments/GeneralLedgersDocument.php +++ b/src/DomDocuments/GeneralLedgersDocument.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\DomDocuments; use PhpTwinfield\GeneralLedger; +use PhpTwinfield\Util; /** * The Document Holder for making new XML GeneralLedger. Is a child class @@ -52,9 +53,9 @@ public function addGeneralLedger(GeneralLedger $generalLedger) $generalLedgerElement->appendChild($this->createNodeWithTextContent('endperiod', $generalLedger->getEndPeriod())); $generalLedgerElement->appendChild($this->createNodeWithTextContent('endyear', $generalLedger->getEndYear())); $generalLedgerElement->appendChild($this->createNodeWithTextContent('name', $generalLedger->getName())); - $generalLedgerElement->appendChild($this->createNodeWithTextContent('office', $generalLedger->getOfficeToString())); + $generalLedgerElement->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($generalLedger->getOffice()))); $generalLedgerElement->appendChild($this->createNodeWithTextContent('shortname', $generalLedger->getShortName())); - $generalLedgerElement->appendChild($this->createNodeWithTextContent('type', $generalLedger->getTypeToString())); + $generalLedgerElement->appendChild($this->createNodeWithTextContent('type', Util::objectToStr($generalLedger->getType()))); $financials = $generalLedger->getFinancials(); @@ -64,7 +65,7 @@ public function addGeneralLedger(GeneralLedger $generalLedger) $financialsElement->appendChild($this->createNodeWithTextContent('accounttype', $financials->getAccountType())); $financialsElement->appendChild($this->createNodeWithTextContent('matchtype', $financials->getMatchType())); $financialsElement->appendChild($this->createNodeWithTextContent('subanalyse', $financials->getSubAnalyse())); - $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $financials->getVatCodeToString())); + $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', Util::objectToStr($financials->getVatCode()))); $childValidations = $financials->getChildValidations(); @@ -80,7 +81,7 @@ public function addGeneralLedger(GeneralLedger $generalLedger) } } - $group = $generalLedger->getGroupToString(); + $group = Util::objectToStr($generalLedger->getGroup()); if (!empty($group)) { $groupsElement = $this->createElement('groups'); diff --git a/src/DomDocuments/InvoicesDocument.php b/src/DomDocuments/InvoicesDocument.php index 520991c6..4f767f56 100644 --- a/src/DomDocuments/InvoicesDocument.php +++ b/src/DomDocuments/InvoicesDocument.php @@ -7,6 +7,7 @@ use PhpTwinfield\Article; use PhpTwinfield\Invoice; use PhpTwinfield\Secure\AuthenticatedConnection; +use PhpTwinfield\Util; /** * The Document Holder for making new XML Invoice. Is a child class @@ -57,28 +58,28 @@ public function addInvoice(Invoice $invoice, AuthenticatedConnection $connection $headerElement->setAttribute('raisewarning', $raiseWarning); } - $headerElement->appendChild($this->createNodeWithTextContent('bank', $invoice->getBankToString())); - $headerElement->appendChild($this->createNodeWithTextContent('currency', $invoice->getCurrencyToString())); - $headerElement->appendChild($this->createNodeWithTextContent('customer', $invoice->getCustomerToString())); + $headerElement->appendChild($this->createNodeWithTextContent('bank', Util::objectToStr($invoice->getBank()))); + $headerElement->appendChild($this->createNodeWithTextContent('currency', Util::objectToStr($invoice->getCurrency()))); + $headerElement->appendChild($this->createNodeWithTextContent('customer', Util::objectToStr($invoice->getCustomer()))); $headerElement->appendChild($this->createNodeWithTextContent('deliveraddressnumber', $invoice->getDeliverAddressNumber())); - $headerElement->appendChild($this->createNodeWithTextContent('duedate', $invoice->getDueDateToString())); + $headerElement->appendChild($this->createNodeWithTextContent('duedate', Util::formatDate($invoice->getDueDate()))); $headerElement->appendChild($this->createNodeWithTextContent('footertext', $invoice->getFooterText())); $headerElement->appendChild($this->createNodeWithTextContent('headertext', $invoice->getHeaderText())); $headerElement->appendChild($this->createNodeWithTextContent('invoiceaddressnumber', $invoice->getInvoiceAddressNumber())); - $headerElement->appendChild($this->createNodeWithTextContent('invoicedate', $invoice->getInvoiceDateToString())); + $headerElement->appendChild($this->createNodeWithTextContent('invoicedate', Util::formatDate($invoice->getInvoiceDate()))); if (!empty($invoice->getInvoiceNumber())) { $headerElement->appendChild($this->createNodeWithTextContent('invoicenumber', $invoice->getInvoiceNumber())); } - $headerElement->appendChild($this->createNodeWithTextContent('invoicetype', $invoice->getInvoiceTypeToString())); - $headerElement->appendChild($this->createNodeWithTextContent('office', $invoice->getOfficeToString())); + $headerElement->appendChild($this->createNodeWithTextContent('invoicetype', Util::objectToStr($invoice->getInvoiceType()))); + $headerElement->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($invoice->getOffice()))); $headerElement->appendChild($this->createNodeWithTextContent('paymentmethod', $invoice->getPaymentMethod())); $headerElement->appendChild($this->createNodeWithTextContent('period', $invoice->getPeriod())); $headerElement->appendChild($this->createNodeWithTextContent('status', $invoice->getStatus())); $invoiceTypeApiConnector = new InvoiceTypeApiConnector($connection); - $invoiceVatType = $invoiceTypeApiConnector->getInvoiceTypeVatType($invoice->getInvoiceTypeToString()); + $invoiceVatType = $invoiceTypeApiConnector->getInvoiceTypeVatType(Util::objectToStr($invoice->getInvoiceType())); $articleApiConnector = new ArticleApiConnector($connection); @@ -101,34 +102,34 @@ public function addInvoice(Invoice $invoice, AuthenticatedConnection $connection $lineElement->setAttribute('id', $id); } - $lineElement->appendChild($this->createNodeWithTextContent('allowdiscountorpremium', $line->getAllowDiscountOrPremiumToString())); - $lineElement->appendChild($this->createNodeWithTextContent('article', $line->getArticleToString())); + $lineElement->appendChild($this->createNodeWithTextContent('allowdiscountorpremium', Util::formatBoolean($line->getAllowDiscountOrPremium()))); + $lineElement->appendChild($this->createNodeWithTextContent('article', Util::objectToStr($line->getArticle()))); $lineElement->appendChild($this->createNodeWithTextContent('description', $line->getDescription())); - $lineElement->appendChild($this->createNodeWithTextContent('dim1', $line->getDim1ToString())); + $lineElement->appendChild($this->createNodeWithTextContent('dim1', Util::objectToStr($line->getDim1()))); $lineElement->appendChild($this->createNodeWithTextContent('freetext1', $line->getFreeText1())); $lineElement->appendChild($this->createNodeWithTextContent('freetext2', $line->getFreeText2())); $lineElement->appendChild($this->createNodeWithTextContent('freetext3', $line->getFreeText3())); - $lineElement->appendChild($this->createNodeWithTextContent('performancedate', $line->getPerformanceDateToString())); + $lineElement->appendChild($this->createNodeWithTextContent('performancedate', Util::formatDate($line->getPerformanceDate()))); $lineElement->appendChild($this->createNodeWithTextContent('performancetype', $line->getPerformanceType())); $lineElement->appendChild($this->createNodeWithTextContent('quantity', $line->getQuantity())); $lineElement->appendChild($this->createNodeWithTextContent('subarticle', $line->getSubArticleToString())); $lineElement->appendChild($this->createNodeWithTextContent('units', $line->getUnits())); if ($invoiceVatType == 'inclusive') { - $lineElement->appendChild($this->createNodeWithTextContent('unitspriceinc', $line->getUnitsPriceIncToFloat())); + $lineElement->appendChild($this->createNodeWithTextContent('unitspriceinc', Util::formatMoney($line->getUnitsPriceInc()))); } else { - $lineElement->appendChild($this->createNodeWithTextContent('unitspriceexcl', $line->getUnitsPriceExclToFloat())); + $lineElement->appendChild($this->createNodeWithTextContent('unitspriceexcl', Util::formatMoney($line->getUnitsPriceExcl()))); } - if ($line->getArticleToString() != '0') { - $article = $articleApiConnector->get($line->getArticleToString(), $invoice->getOffice()); + if (Util::objectToStr($line->getArticle()) != '0') { + $article = $articleApiConnector->get(Util::objectToStr($line->getArticle()), $invoice->getOffice()); } else { $article = new Article; $article->setAllowChangeVatCode(true); } if ($article->getAllowChangeVatCode() == true) { - $lineElement->appendChild($this->createNodeWithTextContent('vatcode', $line->getVatCodeToString())); + $lineElement->appendChild($this->createNodeWithTextContent('vatcode', Util::objectToStr($line->getVatCode()))); } } } diff --git a/src/DomDocuments/MatchDocument.php b/src/DomDocuments/MatchDocument.php index 5c682b3d..4108b116 100644 --- a/src/DomDocuments/MatchDocument.php +++ b/src/DomDocuments/MatchDocument.php @@ -12,11 +12,11 @@ public function addMatchSet(MatchSet $matchSet) { $set = $this->createElement("set"); - $set->appendChild($this->createNodeWithTextContent('office', $matchSet->getOfficeToString())); + $set->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($matchSet->getOffice()))); $set->appendChild($this->createNodeWithTextContent("matchcode", $matchSet->getMatchCode()->getValue())); - $set->appendChild($this->createNodeWithTextContent("matchdate", $matchSet->getMatchDateToString())); + $set->appendChild($this->createNodeWithTextContent("matchdate", Util::formatDate($matchSet->getMatchDate()))); $lines = $this->createElement("lines"); diff --git a/src/DomDocuments/ProjectsDocument.php b/src/DomDocuments/ProjectsDocument.php index 8405ef7d..5036a927 100644 --- a/src/DomDocuments/ProjectsDocument.php +++ b/src/DomDocuments/ProjectsDocument.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\DomDocuments; use PhpTwinfield\Project; +use PhpTwinfield\Util; /** * The Document Holder for making new XML Project. Is a child class @@ -47,14 +48,14 @@ public function addProject(Project $project) } $projectElement->appendChild($this->createNodeWithTextContent('name', $project->getName())); - $projectElement->appendChild($this->createNodeWithTextContent('office', $project->getOfficeToString())); + $projectElement->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($project->getOffice()))); $projectElement->appendChild($this->createNodeWithTextContent('shortname', $project->getShortName())); - $projectElement->appendChild($this->createNodeWithTextContent('type', $project->getTypeToString())); + $projectElement->appendChild($this->createNodeWithTextContent('type', Util::objectToStr($project->getType()))); $financialsElement = $this->createElement('financials'); $projectElement->appendChild($financialsElement); - $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $project->getVatCodeToString())); + $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', Util::objectToStr($project->getVatCode()))); $projects = $project->getProjects(); @@ -86,8 +87,8 @@ public function addProject(Project $project) } $projectsElement->appendChild($this->createNodeWithTextContent('invoicedescription', $projects->getInvoiceDescription())); - $projectsElement->appendChild($this->createNodeWithTextContent('validfrom', $projects->getValidFromToString())); - $projectsElement->appendChild($this->createNodeWithTextContent('validtill', $projects->getValidTillToString())); + $projectsElement->appendChild($this->createNodeWithTextContent('validfrom', Util::formatDate($projects->getValidFrom()))); + $projectsElement->appendChild($this->createNodeWithTextContent('validtill', Util::formatDate($projects->getValidTill()))); $quantities = $projects->getQuantities(); @@ -103,9 +104,9 @@ public function addProject(Project $project) $quantitiesElement->appendChild($quantityElement); $quantityElement->appendChild($this->createNodeWithTextContent('label', $quantity->getLabel())); - $quantityElement->appendChild($this->createNodeWithTextContent('rate', $quantity->getRateToString())); - $quantityElement->appendChild($this->createNodeWithTextContent('billable', $quantity->getBillableToString(), $quantity, array('locked' => 'getBillableLockedToString'))); - $quantityElement->appendChild($this->createNodeWithTextContent('mandatory', $quantity->getMandatoryToString())); + $quantityElement->appendChild($this->createNodeWithTextContent('rate', Util::objectToStr($quantity->getRate()))); + $quantityElement->appendChild($this->createNodeWithTextContent('billable', Util::formatBoolean($quantity->getBillable()), $quantity, array('locked' => 'getBillableLockedToString'))); + $quantityElement->appendChild($this->createNodeWithTextContent('mandatory', Util::formatBoolean($quantity->getMandatory()))); } } } diff --git a/src/DomDocuments/RatesDocument.php b/src/DomDocuments/RatesDocument.php index 4ca1346f..2681cac8 100644 --- a/src/DomDocuments/RatesDocument.php +++ b/src/DomDocuments/RatesDocument.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\DomDocuments; use PhpTwinfield\Rate; +use PhpTwinfield\Util; /** * The Document Holder for making new XML Rate. Is a child class @@ -43,9 +44,9 @@ public function addRate(Rate $rate) } $rateElement->appendChild($this->createNodeWithTextContent('code', $rate->getCode())); - $rateElement->appendChild($this->createNodeWithTextContent('currency', $rate->getCurrencyToString())); + $rateElement->appendChild($this->createNodeWithTextContent('currency', Util::objectToStr($rate->getCurrency()))); $rateElement->appendChild($this->createNodeWithTextContent('name', $rate->getName())); - $rateElement->appendChild($this->createNodeWithTextContent('office', $rate->getOfficeToString())); + $rateElement->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($rate->getOffice()))); $rateElement->appendChild($this->createNodeWithTextContent('shortname', $rate->getShortName())); $rateElement->appendChild($this->createNodeWithTextContent('type', $rate->getType())); $rateElement->appendChild($this->createNodeWithTextContent('unit', $rate->getUnit())); @@ -75,8 +76,8 @@ public function addRate(Rate $rate) $rateChangeElement->setAttribute('status', $status); } - $rateChangeElement->appendChild($this->createNodeWithTextContent('begindate', $rateChange->getBeginDateToString())); - $rateChangeElement->appendChild($this->createNodeWithTextContent('enddate', $rateChange->getEndDateToString())); + $rateChangeElement->appendChild($this->createNodeWithTextContent('begindate', Util::formatDate($rateChange->getBeginDate()))); + $rateChangeElement->appendChild($this->createNodeWithTextContent('enddate', Util::formatDate($rateChange->getEndDate()))); $rateChangeElement->appendChild($this->createNodeWithTextContent('externalrate', $rateChange->getExternalRate())); $rateChangeElement->appendChild($this->createNodeWithTextContent('internalrate', $rateChange->getInternalRate())); } diff --git a/src/DomDocuments/SuppliersDocument.php b/src/DomDocuments/SuppliersDocument.php index 49a80e4b..bdf3885e 100644 --- a/src/DomDocuments/SuppliersDocument.php +++ b/src/DomDocuments/SuppliersDocument.php @@ -2,6 +2,7 @@ namespace PhpTwinfield\DomDocuments; use PhpTwinfield\Supplier; +use PhpTwinfield\Util; /** * The Document Holder for making new XML Supplier. Is a child class @@ -52,9 +53,9 @@ public function addSupplier(Supplier $supplier) $supplierElement->appendChild($this->createNodeWithTextContent('endperiod', $supplier->getEndPeriod())); $supplierElement->appendChild($this->createNodeWithTextContent('endyear', $supplier->getEndYear())); $supplierElement->appendChild($this->createNodeWithTextContent('name', $supplier->getName())); - $supplierElement->appendChild($this->createNodeWithTextContent('office', $supplier->getOfficeToString())); + $supplierElement->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($supplier->getOffice()))); $supplierElement->appendChild($this->createNodeWithTextContent('shortname', $supplier->getShortName())); - $supplierElement->appendChild($this->createNodeWithTextContent('type', $supplier->getTypeToString())); + $supplierElement->appendChild($this->createNodeWithTextContent('type', Util::objectToStr($supplier->getType()))); $supplierElement->appendChild($this->createNodeWithTextContent('website', $supplier->getWebsite())); $financials = $supplier->getFinancials(); @@ -64,11 +65,11 @@ public function addSupplier(Supplier $supplier) $financialsElement->appendChild($this->createNodeWithTextContent('duedays', $financials->getDueDays())); $financialsElement->appendChild($this->createNodeWithTextContent('meansofpayment', $financials->getMeansOfPayment())); - $financialsElement->appendChild($this->createNodeWithTextContent('payavailable', $financials->getPayAvailableToString())); - $financialsElement->appendChild($this->createNodeWithTextContent('paycode', $financials->getPayCodeToString())); + $financialsElement->appendChild($this->createNodeWithTextContent('payavailable', Util::formatBoolean($financials->getPayAvailable()))); + $financialsElement->appendChild($this->createNodeWithTextContent('paycode', Util::objectToStr($financials->getPayCode()))); $financialsElement->appendChild($this->createNodeWithTextContent('relationsreference', $financials->getRelationsReference())); - $financialsElement->appendChild($this->createNodeWithTextContent('substitutewith', $financials->getSubstituteWithToString())); - $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', $financials->getVatCodeToString())); + $financialsElement->appendChild($this->createNodeWithTextContent('substitutewith', Util::objectToStr($financials->getSubstituteWith()))); + $financialsElement->appendChild($this->createNodeWithTextContent('vatcode', Util::objectToStr($financials->getVatCode()))); $childValidations = $financials->getChildValidations(); @@ -97,7 +98,7 @@ public function addSupplier(Supplier $supplier) $addressElement = $this->createElement('address'); $addressesElement->appendChild($addressElement); - $default = $address->getDefaultToString(); + $default = Util::formatBoolean($address->getDefault()); if (!empty($default)) { $addressElement->setAttribute('default', $default); @@ -116,7 +117,7 @@ public function addSupplier(Supplier $supplier) } $addressElement->appendChild($this->createNodeWithTextContent('city', $address->getCity())); - $addressElement->appendChild($this->createNodeWithTextContent('country', $address->getCountryToString())); + $addressElement->appendChild($this->createNodeWithTextContent('country', Util::objectToStr($address->getCountry()))); $addressElement->appendChild($this->createNodeWithTextContent('email', $address->getEmail())); $addressElement->appendChild($this->createNodeWithTextContent('field1', $address->getField1())); $addressElement->appendChild($this->createNodeWithTextContent('field2', $address->getField2())); @@ -144,13 +145,13 @@ public function addSupplier(Supplier $supplier) $bankElement = $this->createElement('bank'); $banksElement->appendChild($bankElement); - $blocked = $bank->getBlockedToString(); + $blocked = Util::formatBoolean($bank->getBlocked()); if (!empty($blocked)) { $bankElement->setAttribute('blocked', $blocked); } - $default = $bank->getDefaultToString(); + $default = Util::formatBoolean($bank->getDefault()); if (!empty($default)) { $bankElement->setAttribute('default', $default); @@ -172,7 +173,7 @@ public function addSupplier(Supplier $supplier) $bankElement->appendChild($this->createNodeWithTextContent('bankname', $bank->getBankName())); $bankElement->appendChild($this->createNodeWithTextContent('biccode', $bank->getBicCode())); $bankElement->appendChild($this->createNodeWithTextContent('city', $bank->getCity())); - $bankElement->appendChild($this->createNodeWithTextContent('country', $bank->getCountryToString())); + $bankElement->appendChild($this->createNodeWithTextContent('country', Util::objectToStr($bank->getCountry()))); $bankElement->appendChild($this->createNodeWithTextContent('iban', $bank->getIban())); $bankElement->appendChild($this->createNodeWithTextContent('natbiccode', $bank->getNatBicCode())); $bankElement->appendChild($this->createNodeWithTextContent('postcode', $bank->getPostcode())); @@ -186,7 +187,7 @@ public function addSupplier(Supplier $supplier) $remittanceAdviceElement->appendChild($this->createNodeWithTextContent('sendmail', $supplier->getRemittanceAdviceSendMail())); $remittanceAdviceElement->appendChild($this->createNodeWithTextContent('sendtype', $supplier->getRemittanceAdviceSendType())); - $group = $supplier->getGroupToString(); + $group = Util::objectToStr($supplier->getGroup()); if (!empty($group)) { $groupsElement = $this->createElement('groups'); @@ -219,8 +220,8 @@ public function addSupplier(Supplier $supplier) $postingRuleElement->setAttribute('status', $status); } - $postingRuleElement->appendChild($this->createNodeWithTextContent('amount', $postingRule->getAmountToFloat())); - $postingRuleElement->appendChild($this->createNodeWithTextContent('currency', $postingRule->getCurrencyToString())); + $postingRuleElement->appendChild($this->createNodeWithTextContent('amount', Util::formatMoney($postingRule->getAmount()))); + $postingRuleElement->appendChild($this->createNodeWithTextContent('currency', Util::objectToStr($postingRule->getCurrency()))); $postingRuleElement->appendChild($this->createNodeWithTextContent('description', $postingRule->getDescription())); $postingRuleLines = $postingRule->getLines(); @@ -236,13 +237,13 @@ public function addSupplier(Supplier $supplier) $postingRuleLineElement = $this->createElement('line'); $postingRuleLinesElement->appendChild($postingRuleLineElement); - $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension1', $postingRuleLine->getDimension1ToString())); - $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension2', $postingRuleLine->getDimension2ToString())); - $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension3', $postingRuleLine->getDimension3ToString())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension1', Util::objectToStr($postingRuleLine->getDimension1()))); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension2', Util::objectToStr($postingRuleLine->getDimension2()))); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('dimension3', Util::objectToStr($postingRuleLine->getDimension3()))); $postingRuleLineElement->appendChild($this->createNodeWithTextContent('description', $postingRuleLine->getDescription())); - $postingRuleLineElement->appendChild($this->createNodeWithTextContent('office', $postingRuleLine->getOfficeToString())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($postingRuleLine->getOffice()))); $postingRuleLineElement->appendChild($this->createNodeWithTextContent('ratio', $postingRuleLine->getRatio())); - $postingRuleLineElement->appendChild($this->createNodeWithTextContent('vatcode', $postingRuleLine->getVatCodeToString())); + $postingRuleLineElement->appendChild($this->createNodeWithTextContent('vatcode', Util::objectToStr($postingRuleLine->getVatCode()))); } } } diff --git a/src/DomDocuments/TransactionsDocument.php b/src/DomDocuments/TransactionsDocument.php index db631c82..702433e9 100644 --- a/src/DomDocuments/TransactionsDocument.php +++ b/src/DomDocuments/TransactionsDocument.php @@ -58,10 +58,10 @@ public function addTransaction(BaseTransaction $transaction) $transactionElement->setAttribute('destiny', $transaction->getDestiny()); if ($transaction->getRaiseWarning() !== null) { - $transactionElement->setAttribute('raisewarning', $transaction->getRaiseWarningToString()); + $transactionElement->setAttribute('raisewarning', Util::formatBoolean($transaction->getRaiseWarning())); } if ($transaction->getAutoBalanceVat() !== null) { - $transactionElement->setAttribute('autobalancevat', $transaction->getAutoBalanceVatToString()); + $transactionElement->setAttribute('autobalancevat', Util::formatBoolean($transaction->getAutoBalanceVat())); } $this->rootElement->appendChild($transactionElement); @@ -70,7 +70,7 @@ public function addTransaction(BaseTransaction $transaction) $headerElement = $this->createElement('header'); $transactionElement->appendChild($headerElement); - $headerElement->appendChild($this->createNodeWithTextContent('office', $transaction->getOfficeToString())); + $headerElement->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($transaction->getOffice()))); $headerElement->appendChild($this->createNodeWithTextContent('code', $transaction->getCode())); if ($transaction->getNumber() !== null) { @@ -82,26 +82,26 @@ public function addTransaction(BaseTransaction $transaction) } if ($transaction->getCurrency() !== null) { - $headerElement->appendChild($this->createNodeWithTextContent('currency', $transaction->getCurrencyToString())); + $headerElement->appendChild($this->createNodeWithTextContent('currency', Util::objectToStr($transaction->getCurrency()))); } if (Util::objectUses(RegimeField::class, $transaction) && $transaction->getRegime() !== null) { $headerElement->appendChild($this->createNodeWithTextContent('regime', $transaction->getRegime())); } - $headerElement->appendChild($this->createNodeWithTextContent("date", $transaction->getDateToString(), $transaction, array('raisewarning' => 'getDateRaiseWarningToString'))); + $headerElement->appendChild($this->createNodeWithTextContent("date", Util::formatDate($transaction->getDate()), $transaction, array('raisewarning' => 'getDateRaiseWarningToString'))); if (Util::objectUses(StatementNumberField::class, $transaction) && $transaction->getStatementnumber() !== null) { $headerElement->appendChild($this->createNodeWithTextContent('statementnumber', $transaction->getStatementnumber())); } if (Util::objectUses(CloseAndStartValueFields::class, $transaction)) { - $headerElement->appendChild($this->createNodeWithTextContent('startvalue', $transaction->getStartValueToFloat())); - $headerElement->appendChild($this->createNodeWithTextContent('closevalue', $transaction->getCloseValueToFloat())); + $headerElement->appendChild($this->createNodeWithTextContent('startvalue', Util::formatMoney($transaction->getStartValue()))); + $headerElement->appendChild($this->createNodeWithTextContent('closevalue', Util::formatMoney($transaction->getCloseValue()))); } if (Util::objectUses(DueDateField::class, $transaction) && $transaction->getDueDate() !== null) { - $headerElement->appendChild($this->createNodeWithTextContent("duedate", $transaction->getDueDateToString())); + $headerElement->appendChild($this->createNodeWithTextContent("duedate", Util::formatDate($transaction->getDueDate()))); } if (Util::objectUses(InvoiceNumberField::class, $transaction) && $transaction->getInvoiceNumber() !== null) { @@ -135,19 +135,19 @@ public function addTransaction(BaseTransaction $transaction) $lineElement->setAttribute('id', $transactionLine->getId()); $linesElement->appendChild($lineElement); - $lineElement->appendChild($this->createNodeWithTextContent('dim1', $transactionLine->getDim1ToString())); + $lineElement->appendChild($this->createNodeWithTextContent('dim1', Util::objectToStr($transactionLine->getDim1()))); if (!empty($transactionLine->getDim2())) { - $lineElement->appendChild($this->createNodeWithTextContent('dim2', $transactionLine->getDim2ToString())); + $lineElement->appendChild($this->createNodeWithTextContent('dim2', Util::objectToStr($transactionLine->getDim2()))); } if (!empty($transactionLine->getDim3())) { - $lineElement->appendChild($this->createNodeWithTextContent('dim3', $transactionLine->getDim3ToString())); + $lineElement->appendChild($this->createNodeWithTextContent('dim3', Util::objectToStr($transactionLine->getDim3()))); } if (Util::objectUses(ValueFields::class, $transactionLine)) { $lineElement->appendChild($this->createNodeWithTextContent('debitcredit', $transactionLine->getDebitCredit())); - $lineElement->appendChild($this->createNodeWithTextContent('value', $transactionLine->getValueToFloat())); + $lineElement->appendChild($this->createNodeWithTextContent('value', Util::formatMoney($transactionLine->getValue()))); } if (Util::objectUses(BaselineField::class, $transactionLine) && !empty($transactionLine->getBaseline())) { @@ -155,7 +155,7 @@ public function addTransaction(BaseTransaction $transaction) } if (!empty($transactionLine->getBaseValue())) { - $lineElement->appendChild($this->createNodeWithTextContent('basevalue', $transactionLine->getBaseValueToFloat())); + $lineElement->appendChild($this->createNodeWithTextContent('basevalue', Util::formatMoney($transactionLine->getBaseValue()))); } if (!empty($transactionLine->getComment())) { @@ -163,7 +163,7 @@ public function addTransaction(BaseTransaction $transaction) } if (Util::objectUses(CurrencyDateField::class, $transactionLine) && !empty($transactionLine->getCurrencyDate())) { - $lineElement->appendChild($this->createNodeWithTextContent("currencydate", $transactionLine->getCurrencyDateToString())); + $lineElement->appendChild($this->createNodeWithTextContent("currencydate", Util::formatDate($transactionLine->getCurrencyDate()))); } if (!empty($transactionLine->getDescription())) { @@ -171,7 +171,7 @@ public function addTransaction(BaseTransaction $transaction) } if (!empty($transactionLine->getDestOffice())) { - $lineElement->appendChild($this->createNodeWithTextContent('destoffice', $transactionLine->getDestOfficeToString())); + $lineElement->appendChild($this->createNodeWithTextContent('destoffice', Util::objectToStr($transactionLine->getDestOffice()))); } if (Util::objectUses(FreeCharField::class, $transactionLine) && !empty($transactionLine->getFreeChar())) { @@ -183,11 +183,11 @@ public function addTransaction(BaseTransaction $transaction) } if (Util::objectUses(PerformanceCountryField::class, $transactionLine) && !empty($transactionLine->getPerformanceCountry())) { - $lineElement->appendChild($this->createNodeWithTextContent('performancecountry', $transactionLine->getPerformanceCountryToString())); + $lineElement->appendChild($this->createNodeWithTextContent('performancecountry', Util::objectToStr($transactionLine->getPerformanceCountry()))); } if (Util::objectUses(PerformanceDateField::class, $transactionLine) && !empty($transactionLine->getPerformanceDate())) { - $lineElement->appendChild($this->createNodeWithTextContent("performancedate", $transactionLine->getPerformanceDateToString())); + $lineElement->appendChild($this->createNodeWithTextContent("performancedate", Util::formatDate($transactionLine->getPerformanceDate()))); } if (Util::objectUses(PerformanceTypeField::class, $transactionLine) && !empty($transactionLine->getPerformanceType())) { @@ -207,47 +207,47 @@ public function addTransaction(BaseTransaction $transaction) } if (!empty($transactionLine->getRepValue())) { - $lineElement->appendChild($this->createNodeWithTextContent('repvalue', $transactionLine->getRepValueToFloat())); + $lineElement->appendChild($this->createNodeWithTextContent('repvalue', Util::formatMoney($transactionLine->getRepValue()))); } if (Util::objectUses(VatBaseTotalField::class, $transactionLine) && !empty($transactionLine->getVatBaseTotal())) { - $lineElement->appendChild($this->createNodeWithTextContent('vatbasetotal', $transactionLine->getVatBaseTotalToFloat())); + $lineElement->appendChild($this->createNodeWithTextContent('vatbasetotal', Util::formatMoney($transactionLine->getVatBaseTotal()))); } if (!empty($transactionLine->getVatBaseTurnover())) { - $lineElement->appendChild($this->createNodeWithTextContent('vatbaseturnover', $transactionLine->getVatBaseTurnoverToFloat())); + $lineElement->appendChild($this->createNodeWithTextContent('vatbaseturnover', Util::formatMoney($transactionLine->getVatBaseTurnover()))); } if (!empty($transactionLine->getVatBaseValue())) { - $lineElement->appendChild($this->createNodeWithTextContent('vatbasevalue', $transactionLine->getVatBaseValueToFloat())); + $lineElement->appendChild($this->createNodeWithTextContent('vatbasevalue', Util::formatMoney($transactionLine->getVatBaseValue()))); } if (!empty($transactionLine->getVatCode())) { - $lineElement->appendChild($this->createNodeWithTextContent('vatcode', $transactionLine->getVatCodeToString())); + $lineElement->appendChild($this->createNodeWithTextContent('vatcode', Util::objectToStr($transactionLine->getVatCode()))); } if (Util::objectUses(VatRepTotalField::class, $transactionLine) && !empty($transactionLine->getVatRepTotal())) { - $lineElement->appendChild($this->createNodeWithTextContent('vatreptotal', $transactionLine->getVatRepTotalToFloat())); + $lineElement->appendChild($this->createNodeWithTextContent('vatreptotal', Util::formatMoney($transactionLine->getVatRepTotal()))); } if (!empty($transactionLine->getVatRepValue())) { - $lineElement->appendChild($this->createNodeWithTextContent('vatrepvalue', $transactionLine->getVatRepValueToFloat())); + $lineElement->appendChild($this->createNodeWithTextContent('vatrepvalue', Util::formatMoney($transactionLine->getVatRepValue()))); } if (!empty($transactionLine->getVatRepTurnover())) { - $lineElement->appendChild($this->createNodeWithTextContent('vatrepturnover', $transactionLine->getVatRepTurnoverToFloat())); + $lineElement->appendChild($this->createNodeWithTextContent('vatrepturnover', Util::formatMoney($transactionLine->getVatRepTurnover()))); } if (Util::objectUses(VatTotalField::class, $transactionLine) && !empty($transactionLine->getVatTotal())) { - $lineElement->appendChild($this->createNodeWithTextContent('vattotal', $transactionLine->getVatTotalToFloat())); + $lineElement->appendChild($this->createNodeWithTextContent('vattotal', Util::formatMoney($transactionLine->getVatTotal()))); } if (!empty($transactionLine->getVatTurnover())) { - $lineElement->appendChild($this->createNodeWithTextContent('vatturnover', $transactionLine->getVatTurnoverToFloat())); + $lineElement->appendChild($this->createNodeWithTextContent('vatturnover', Util::formatMoney($transactionLine->getVatTurnover()))); } if (!empty($transactionLine->getVatValue())) { - $lineElement->appendChild($this->createNodeWithTextContent('vatvalue', $transactionLine->getVatValueToFloat())); + $lineElement->appendChild($this->createNodeWithTextContent('vatvalue', Util::formatMoney($transactionLine->getVatValue()))); } } } diff --git a/src/DomDocuments/VatCodesDocument.php b/src/DomDocuments/VatCodesDocument.php index f2573a0a..1200eddc 100644 --- a/src/DomDocuments/VatCodesDocument.php +++ b/src/DomDocuments/VatCodesDocument.php @@ -2,6 +2,7 @@ namespace PhpTwinfield\DomDocuments; +use PhpTwinfield\Util; use PhpTwinfield\VatCode; /** @@ -59,7 +60,7 @@ public function addVatCode(VatCode $vatCode) $percentageElement = $this->createElement('percentage'); $percentagesElement->appendChild($percentageElement); - $percentageElement->appendChild($this->createNodeWithTextContent('date', $percentage->getDateToString())); + $percentageElement->appendChild($this->createNodeWithTextContent('date', Util::formatDate($percentage->getDate()))); $percentageElement->appendChild($this->createNodeWithTextContent('name', $percentage->getName())); $percentageElement->appendChild($this->createNodeWithTextContent('percentage', $percentage->getPercentage())); $percentageElement->appendChild($this->createNodeWithTextContent('shortname', $percentage->getShortName())); @@ -83,9 +84,9 @@ public function addVatCode(VatCode $vatCode) $accountElement->setAttribute('id', $id); } - $accountElement->appendChild($this->createNodeWithTextContent('dim1', $account->getDim1ToString())); - $accountElement->appendChild($this->createNodeWithTextContent('group', $account->getGroupToString())); - $accountElement->appendChild($this->createNodeWithTextContent('groupcountry', $account->getGroupCountryToString())); + $accountElement->appendChild($this->createNodeWithTextContent('dim1', Util::objectToStr($account->getDim1()))); + $accountElement->appendChild($this->createNodeWithTextContent('group', Util::objectToStr($account->getGroup()))); + $accountElement->appendChild($this->createNodeWithTextContent('groupcountry', Util::objectToStr($account->getGroupCountry()))); $accountElement->appendChild($this->createNodeWithTextContent('linetype', $account->getLineType())); $accountElement->appendChild($this->createNodeWithTextContent('percentage', $account->getPercentage())); } diff --git a/src/Dummy.php b/src/Dummy.php deleted file mode 100644 index 26ce361b..00000000 --- a/src/Dummy.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ -class Dummy -{ - use CodeField; - use NameField; - use ShortNameField; -} \ No newline at end of file diff --git a/src/ElectronicBankStatement.php b/src/ElectronicBankStatement.php index d132c3ea..d2e14fd1 100644 --- a/src/ElectronicBankStatement.php +++ b/src/ElectronicBankStatement.php @@ -56,14 +56,6 @@ class ElectronicBankStatement */ private $transactions = []; - public function __construct() - { - $currency = new \PhpTwinfield\Currency; - $currency->setCode('EUR'); - $this->currency = $currency; - $this->startValue = new \Money\Money(0, new \Money\Currency($currency->getCode())); - } - public function getAccount(): ?string { return $this->account; diff --git a/src/Fields/AssetMethod/AssetsToActivateField.php b/src/Fields/AssetMethod/AssetsToActivateField.php index 21c6c25a..857542ab 100644 --- a/src/Fields/AssetMethod/AssetsToActivateField.php +++ b/src/Fields/AssetMethod/AssetsToActivateField.php @@ -22,15 +22,6 @@ public function getAssetsToActivate(): ?GeneralLedger return $this->assetsToActivate; } - public function getAssetsToActivateToString(): ?string - { - if ($this->getAssetsToActivate() != null) { - return $this->assetsToActivate->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setAssetsToActivate(?GeneralLedger $assetsToActivate): self $this->assetsToActivate = $assetsToActivate; return $this; } - - /** - * @param string|null $assetsToActivateString - * @return $this - * @throws Exception - */ - public function setAssetsToActivateFromString(?string $assetsToActivateString) - { - $assetsToActivate = new GeneralLedger(); - $assetsToActivate->setCode($assetsToActivateString); - return $this->setAssetsToActivate($assetsToActivate); - } } \ No newline at end of file diff --git a/src/Fields/AssetMethod/CalcMethodField.php b/src/Fields/AssetMethod/CalcMethodField.php index f88e05ba..b69ad1e1 100644 --- a/src/Fields/AssetMethod/CalcMethodField.php +++ b/src/Fields/AssetMethod/CalcMethodField.php @@ -28,14 +28,4 @@ public function setCalcMethod(?CalcMethod $calcMethod): self $this->calcMethod = $calcMethod; return $this; } - - /** - * @param string|null $calcMethodString - * @return $this - * @throws Exception - */ - public function setCalcMethodFromString(?string $calcMethodString) - { - return $this->setCalcMethod(new CalcMethod((string)$calcMethodString)); - } } \ No newline at end of file diff --git a/src/Fields/AssetMethod/DepreciateReconciliationField.php b/src/Fields/AssetMethod/DepreciateReconciliationField.php index 63000ee8..54fe2dee 100644 --- a/src/Fields/AssetMethod/DepreciateReconciliationField.php +++ b/src/Fields/AssetMethod/DepreciateReconciliationField.php @@ -28,14 +28,4 @@ public function setDepreciateReconciliation(?DepreciateReconciliation $depreciat $this->depreciateReconciliation = $depreciateReconciliation; return $this; } - - /** - * @param string|null $depreciateReconciliationString - * @return $this - * @throws Exception - */ - public function setDepreciateReconciliationFromString(?string $depreciateReconciliationString) - { - return $this->setDepreciateReconciliation(new DepreciateReconciliation((string)$depreciateReconciliationString)); - } } \ No newline at end of file diff --git a/src/Fields/AssetMethod/DepreciationField.php b/src/Fields/AssetMethod/DepreciationField.php index 44495fe9..a190ec72 100644 --- a/src/Fields/AssetMethod/DepreciationField.php +++ b/src/Fields/AssetMethod/DepreciationField.php @@ -21,16 +21,7 @@ public function getDepreciation(): ?GeneralLedger { return $this->depreciation; } - - public function getDepreciationToString(): ?string - { - if ($this->getDepreciation() != null) { - return $this->depreciation->getCode(); - } else { - return null; - } - } - + /** * @return $this */ @@ -39,16 +30,4 @@ public function setDepreciation(?GeneralLedger $depreciation): self $this->depreciation = $depreciation; return $this; } - - /** - * @param string|null $depreciationString - * @return $this - * @throws Exception - */ - public function setDepreciationFromString(?string $depreciationString) - { - $depreciation = new GeneralLedger(); - $depreciation->setCode($depreciationString); - return $this->setDepreciation($depreciation); - } } \ No newline at end of file diff --git a/src/Fields/AssetMethod/DepreciationGroupField.php b/src/Fields/AssetMethod/DepreciationGroupField.php index 919217fe..d2e7288e 100644 --- a/src/Fields/AssetMethod/DepreciationGroupField.php +++ b/src/Fields/AssetMethod/DepreciationGroupField.php @@ -22,15 +22,6 @@ public function getDepreciationGroup(): ?DimensionGroup return $this->depreciationGroup; } - public function getDepreciationGroupToString(): ?string - { - if ($this->getDepreciationGroup() != null) { - return $this->depreciationGroup->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setDepreciationGroup(?DimensionGroup $depreciationGroup): self $this->depreciationGroup = $depreciationGroup; return $this; } - - /** - * @param string|null $depreciationGroupString - * @return $this - * @throws Exception - */ - public function setDepreciationGroupFromString(?string $depreciationGroupString) - { - $depreciationGroup = new DimensionGroup(); - $depreciationGroup->setCode($depreciationGroupString); - return $this->setDepreciationGroup($depreciationGroup); - } } \ No newline at end of file diff --git a/src/Fields/AssetMethod/FreeTextTypeField.php b/src/Fields/AssetMethod/FreeTextTypeField.php index ba4ed360..eeb316eb 100644 --- a/src/Fields/AssetMethod/FreeTextTypeField.php +++ b/src/Fields/AssetMethod/FreeTextTypeField.php @@ -28,14 +28,4 @@ public function setType(?FreeTextType $type): self $this->type = $type; return $this; } - - /** - * @param string|null $typeString - * @return $this - * @throws Exception - */ - public function setTypeFromString(?string $typeString) - { - return $this->setType(new FreeTextType((string)$typeString)); - } } \ No newline at end of file diff --git a/src/Fields/AssetMethod/PurchaseValueField.php b/src/Fields/AssetMethod/PurchaseValueField.php index 5fa689c6..e7477279 100644 --- a/src/Fields/AssetMethod/PurchaseValueField.php +++ b/src/Fields/AssetMethod/PurchaseValueField.php @@ -22,15 +22,6 @@ public function getPurchaseValue(): ?GeneralLedger return $this->purchaseValue; } - public function getPurchaseValueToString(): ?string - { - if ($this->getPurchaseValue() != null) { - return $this->purchaseValue->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setPurchaseValue(?GeneralLedger $purchaseValue): self $this->purchaseValue = $purchaseValue; return $this; } - - /** - * @param string|null $purchaseValueString - * @return $this - * @throws Exception - */ - public function setPurchaseValueFromString(?string $purchaseValueString) - { - $purchaseValue = new GeneralLedger(); - $purchaseValue->setCode($purchaseValueString); - return $this->setPurchaseValue($purchaseValue); - } } \ No newline at end of file diff --git a/src/Fields/AssetMethod/PurchaseValueGroupField.php b/src/Fields/AssetMethod/PurchaseValueGroupField.php index 02dcd3f9..68747bfe 100644 --- a/src/Fields/AssetMethod/PurchaseValueGroupField.php +++ b/src/Fields/AssetMethod/PurchaseValueGroupField.php @@ -22,15 +22,6 @@ public function getPurchaseValueGroup(): ?DimensionGroup return $this->purchaseValueGroup; } - public function getPurchaseValueGroupToString(): ?string - { - if ($this->getPurchaseValueGroup() != null) { - return $this->purchaseValueGroup->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setPurchaseValueGroup(?DimensionGroup $purchaseValueGroup): self $this->purchaseValueGroup = $purchaseValueGroup; return $this; } - - /** - * @param string|null $purchaseValueGroupString - * @return $this - * @throws Exception - */ - public function setPurchaseValueGroupFromString(?string $purchaseValueGroupString) - { - $purchaseValueGroup = new DimensionGroup(); - $purchaseValueGroup->setCode($purchaseValueGroupString); - return $this->setPurchaseValueGroup($purchaseValueGroup); - } } \ No newline at end of file diff --git a/src/Fields/AssetMethod/ReconciliationField.php b/src/Fields/AssetMethod/ReconciliationField.php index d5c5bdcd..5514acab 100644 --- a/src/Fields/AssetMethod/ReconciliationField.php +++ b/src/Fields/AssetMethod/ReconciliationField.php @@ -22,15 +22,6 @@ public function getReconciliation(): ?GeneralLedger return $this->reconciliation; } - public function getReconciliationToString(): ?string - { - if ($this->getReconciliation() != null) { - return $this->reconciliation->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setReconciliation(?GeneralLedger $reconciliation): self $this->reconciliation = $reconciliation; return $this; } - - /** - * @param string|null $reconciliationString - * @return $this - * @throws Exception - */ - public function setReconciliationFromString(?string $reconciliationString) - { - $reconciliation = new GeneralLedger(); - $reconciliation->setCode($reconciliationString); - return $this->setReconciliation($reconciliation); - } } \ No newline at end of file diff --git a/src/Fields/AssetMethod/SalesField.php b/src/Fields/AssetMethod/SalesField.php index 1345e3f3..032dbf4b 100644 --- a/src/Fields/AssetMethod/SalesField.php +++ b/src/Fields/AssetMethod/SalesField.php @@ -21,16 +21,7 @@ public function getSales(): ?GeneralLedger { return $this->sales; } - - public function getSalesToString(): ?string - { - if ($this->getSales() != null) { - return $this->sales->getCode(); - } else { - return null; - } - } - + /** * @return $this */ @@ -39,16 +30,4 @@ public function setSales(?GeneralLedger $sales): self $this->sales = $sales; return $this; } - - /** - * @param string|null $salesString - * @return $this - * @throws Exception - */ - public function setSalesFromString(?string $salesString) - { - $sales = new GeneralLedger(); - $sales->setCode($salesString); - return $this->setSales($sales); - } } \ No newline at end of file diff --git a/src/Fields/AssetMethod/ToBeInvoicedField.php b/src/Fields/AssetMethod/ToBeInvoicedField.php index ff9f2760..6c1d5c24 100644 --- a/src/Fields/AssetMethod/ToBeInvoicedField.php +++ b/src/Fields/AssetMethod/ToBeInvoicedField.php @@ -21,16 +21,7 @@ public function getToBeInvoiced(): ?GeneralLedger { return $this->toBeInvoiced; } - - public function getToBeInvoicedToString(): ?string - { - if ($this->getToBeInvoiced() != null) { - return $this->toBeInvoiced->getCode(); - } else { - return null; - } - } - + /** * @return $this */ @@ -39,16 +30,4 @@ public function setToBeInvoiced(?GeneralLedger $toBeInvoiced): self $this->toBeInvoiced = $toBeInvoiced; return $this; } - - /** - * @param string|null $toBeInvoicedString - * @return $this - * @throws Exception - */ - public function setToBeInvoicedFromString(?string $toBeInvoicedString) - { - $toBeInvoiced = new GeneralLedger(); - $toBeInvoiced->setCode($toBeInvoicedString); - return $this->setToBeInvoiced($toBeInvoiced); - } } \ No newline at end of file diff --git a/src/Fields/BehaviourField.php b/src/Fields/BehaviourField.php index 6be80ced..ade7885a 100644 --- a/src/Fields/BehaviourField.php +++ b/src/Fields/BehaviourField.php @@ -28,14 +28,4 @@ public function setBehaviour(?Behaviour $behaviour): self $this->behaviour = $behaviour; return $this; } - - /** - * @param string|null $behaviourString - * @return $this - * @throws Exception - */ - public function setBehaviourFromString(?string $behaviourString) - { - return $this->setBehaviour(new Behaviour((string)$behaviourString)); - } } \ No newline at end of file diff --git a/src/Fields/CreatedField.php b/src/Fields/CreatedField.php index 72470fdc..67417b14 100644 --- a/src/Fields/CreatedField.php +++ b/src/Fields/CreatedField.php @@ -2,16 +2,11 @@ namespace PhpTwinfield\Fields; -use PhpTwinfield\Exception; -use PhpTwinfield\Util; - /** * Created field * Used by: AssetMethod, Office, Rate, User, VatCode, VatCodePercentage * * @package PhpTwinfield\Traits - * @see Util::formatDateTime() - * @see Util::parseDateTime() */ trait CreatedField { @@ -28,18 +23,6 @@ public function getCreated(): ?\DateTimeInterface return $this->created; } - /** - * @return string|null - */ - public function getCreatedToString(): ?string - { - if ($this->getCreated() != null) { - return Util::formatDateTime($this->getCreated()); - } else { - return null; - } - } - /** * @param \DateTimeInterface|null $created * @return $this @@ -49,18 +32,4 @@ public function setCreated(?\DateTimeInterface $created) $this->created = $created; return $this; } - - /** - * @param string|null $createdString - * @return $this - * @throws Exception - */ - public function setCreatedFromString(?string $createdString) - { - if ((bool)strtotime($createdString)) { - return $this->setCreated(Util::parseDateTime($createdString)); - } else { - return $this->setCreated(null); - } - } } \ No newline at end of file diff --git a/src/Fields/Currency/StartDateField.php b/src/Fields/Currency/StartDateField.php index ffc7b1b0..26986f4a 100644 --- a/src/Fields/Currency/StartDateField.php +++ b/src/Fields/Currency/StartDateField.php @@ -2,15 +2,10 @@ namespace PhpTwinfield\Fields\Currency; -use PhpTwinfield\Exception; -use PhpTwinfield\Util; - /** * Start date field * Used by: CurrencyRate * @package PhpTwinfield\Traits - * @see Util::formatDate() - * @see Util::parseDate() */ trait StartDateField { @@ -27,18 +22,6 @@ public function getStartDate(): ?\DateTimeInterface return $this->startDate; } - /** - * @return string|null - */ - public function getStartDateToString(): ?string - { - if ($this->getStartDate() != null) { - return Util::formatDate($this->getStartDate()); - } else { - return null; - } - } - /** * @param \DateTimeInterface|null $startDate * @return $this @@ -48,18 +31,4 @@ public function setStartDate(?\DateTimeInterface $startDate) $this->startDate = $startDate; return $this; } - - /** - * @param string|null $startDateString - * @return $this - * @throws Exception - */ - public function setStartDateFromString(?string $startDateString) - { - if ((bool)strtotime($startDateString)) { - return $this->setStartDate(Util::parseDate($startDateString)); - } else { - return $this->setStartDate(null); - } - } } \ No newline at end of file diff --git a/src/Fields/CurrencyField.php b/src/Fields/CurrencyField.php index 489a1eec..797a5c5c 100644 --- a/src/Fields/CurrencyField.php +++ b/src/Fields/CurrencyField.php @@ -22,15 +22,6 @@ public function getCurrency(): ?Currency return $this->currency; } - public function getCurrencyToString(): ?string - { - if ($this->getCurrency() != null) { - return $this->currency->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setCurrency(?Currency $currency): self $this->currency = $currency; return $this; } - - /** - * @param string|null $currencyString - * @return $this - * @throws Exception - */ - public function setCurrencyFromString(?string $currencyString) - { - $currency = new Currency(); - $currency->setCode($currencyString); - return $this->setCurrency($currency); - } } \ No newline at end of file diff --git a/src/Fields/DateField.php b/src/Fields/DateField.php index f05e93eb..f9229554 100644 --- a/src/Fields/DateField.php +++ b/src/Fields/DateField.php @@ -3,15 +3,12 @@ namespace PhpTwinfield\Fields; use PhpTwinfield\Exception; -use PhpTwinfield\Util; /** * Date field * Used by: BaseTransaction, ElectronicBankStatement, VatCodePercentage * * @package PhpTwinfield\Traits - * @see Util::formatDate() - * @see Util::parseDate() */ trait DateField { @@ -28,18 +25,6 @@ public function getDate(): ?\DateTimeInterface return $this->date; } - /** - * @return string|null - */ - public function getDateToString(): ?string - { - if ($this->getDate() != null) { - return Util::formatDate($this->getDate()); - } else { - return null; - } - } - /** * @param \DateTimeInterface|null $date * @return $this @@ -49,18 +34,4 @@ public function setDate(?\DateTimeInterface $date) $this->date = $date; return $this; } - - /** - * @param string|null $dateString - * @return $this - * @throws Exception - */ - public function setDateFromString(?string $dateString) - { - if ((bool)strtotime($dateString)) { - return $this->setDate(Util::parseDate($dateString)); - } else { - return $this->setDate(null); - } - } } \ No newline at end of file diff --git a/src/Fields/Dim1Field.php b/src/Fields/Dim1Field.php index 1822133e..f4856b4e 100644 --- a/src/Fields/Dim1Field.php +++ b/src/Fields/Dim1Field.php @@ -22,15 +22,6 @@ public function getDim1(): ?GeneralLedger return $this->dim1; } - public function getDim1ToString(): ?string - { - if ($this->getDim1() != null) { - return $this->dim1->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setDim1(?GeneralLedger $dim1): self $this->dim1 = $dim1; return $this; } - - /** - * @param string|null $dim1String - * @return $this - * @throws Exception - */ - public function setDim1FromString(?string $dim1String) - { - $dim1 = new GeneralLedger(); - $dim1->setCode($dim1String); - return $this->setDim1($dim1); - } } \ No newline at end of file diff --git a/src/Fields/Dim2Field.php b/src/Fields/Dim2Field.php index 7f0d5870..02d221bd 100644 --- a/src/Fields/Dim2Field.php +++ b/src/Fields/Dim2Field.php @@ -2,8 +2,6 @@ namespace PhpTwinfield\Fields; -use PhpTwinfield\Dummy; - /** * The dimension * Used by: BaseTransactionLine, FixedAssetTransactionLine @@ -22,15 +20,6 @@ public function getDim2() return $this->dim2; } - public function getDim2ToString(): ?string - { - if ($this->getDim2() != null) { - return $this->dim2->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +28,4 @@ public function setDim2($dim2): self $this->dim2 = $dim2; return $this; } - - /** - * @param string|null $dim2String - * @return $this - * @throws Exception - */ - public function setDim2FromString(?string $dim2String) - { - $dim2 = new Dummy(); - $dim2->setCode($dim2String); - return $this->setDim2($dim2); - } } diff --git a/src/Fields/Dim3Field.php b/src/Fields/Dim3Field.php index a304594c..b1b08ed8 100644 --- a/src/Fields/Dim3Field.php +++ b/src/Fields/Dim3Field.php @@ -2,8 +2,6 @@ namespace PhpTwinfield\Fields; -use PhpTwinfield\Dummy; - /** * The dimension * Used by: BaseTransactionLine, FixedAssetTransactionLine @@ -22,15 +20,6 @@ public function getDim3() return $this->dim3; } - public function getDim3ToString(): ?string - { - if ($this->getDim3() != null) { - return $this->dim3->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +28,4 @@ public function setDim3($dim3): self $this->dim3 = $dim3; return $this; } - - /** - * @param string|null $dim3String - * @return $this - * @throws Exception - */ - public function setDim3FromString(?string $dim3String) - { - $dim3 = new Dummy(); - $dim3->setCode($dim3String); - return $this->setDim3($dim3); - } } diff --git a/src/Fields/Dim4Field.php b/src/Fields/Dim4Field.php index 14251b3e..6c8f213d 100644 --- a/src/Fields/Dim4Field.php +++ b/src/Fields/Dim4Field.php @@ -2,8 +2,6 @@ namespace PhpTwinfield\Fields; -use PhpTwinfield\Dummy; - /** * The dimension * Used by: ElectronicBankStatementTransaction, FixedAssetTransactionLine @@ -21,16 +19,7 @@ public function getDim4() { return $this->dim4; } - - public function getDim4ToString(): ?string - { - if ($this->getDim4() != null) { - return $this->dim4->getCode(); - } else { - return null; - } - } - + /** * @return $this */ @@ -39,16 +28,4 @@ public function setDim4($dim4): self $this->dim4 = $dim4; return $this; } - - /** - * @param string|null $dim4String - * @return $this - * @throws Exception - */ - public function setDim4FromString(?string $dim4String) - { - $dim4 = new Dummy(); - $dim4->setCode($dim4String); - return $this->setDim4($dim4); - } } diff --git a/src/Fields/Dimensions/AccountTypeField.php b/src/Fields/Dimensions/AccountTypeField.php index d2b58400..1a1be04a 100644 --- a/src/Fields/Dimensions/AccountTypeField.php +++ b/src/Fields/Dimensions/AccountTypeField.php @@ -28,14 +28,4 @@ public function setAccountType(?AccountType $accountType): self $this->accountType = $accountType; return $this; } - - /** - * @param string|null $accountTypeString - * @return $this - * @throws Exception - */ - public function setAccountTypeFromString(?string $accountTypeString) - { - return $this->setAccountType(new AccountType((string)$accountTypeString)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/AmountField.php b/src/Fields/Dimensions/AmountField.php index a51baad4..e8de6f50 100644 --- a/src/Fields/Dimensions/AmountField.php +++ b/src/Fields/Dimensions/AmountField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Dimensions; use Money\Money; -use PhpTwinfield\Util; trait AmountField { @@ -23,18 +22,6 @@ public function getAmount(): ?Money return $this->amount; } - /** - * @return float|null - */ - public function getAmountToFloat(): ?float - { - if ($this->getAmount() != null) { - return Util::formatMoney($this->getAmount()); - } else { - return 0; - } - } - /** * @param Money|null $amount * @return $this @@ -45,18 +32,4 @@ public function setAmount(?Money $amount) return $this; } - - /** - * @param float|null $amountFloat - * @return $this - * @throws Exception - */ - public function setAmountFromFloat(?float $amountFloat) - { - if ((float)$amountFloat) { - return $this->setAmount(Money::EUR(100 * $amountFloat)); - } else { - return $this->setAmount(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/DimensionGroup/CodeField.php b/src/Fields/Dimensions/DimensionGroup/CodeField.php index 80f3e9ac..9920bba6 100644 --- a/src/Fields/Dimensions/DimensionGroup/CodeField.php +++ b/src/Fields/Dimensions/DimensionGroup/CodeField.php @@ -2,8 +2,6 @@ namespace PhpTwinfield\Fields\Dimensions\DimensionGroup; -use PhpTwinfield\Dummy; - /** * The dimension * Used by: DimensionGroupDimension @@ -21,16 +19,7 @@ public function getCode() { return $this->code; } - - public function getCodeToString(): ?string - { - if ($this->getCode() != null) { - return $this->code->getCode(); - } else { - return null; - } - } - + /** * @return $this */ @@ -39,16 +28,4 @@ public function setCode($code): self $this->code = $code; return $this; } - - /** - * @param string|null $codeString - * @return $this - * @throws Exception - */ - public function setCodeFromString(?string $codeString) - { - $code = new Dummy(); - $code->setCode($codeString); - return $this->setCode($code); - } } diff --git a/src/Fields/Dimensions/DimensionGroup/GroupField.php b/src/Fields/Dimensions/DimensionGroup/GroupField.php index 438efd60..c1c5b630 100644 --- a/src/Fields/Dimensions/DimensionGroup/GroupField.php +++ b/src/Fields/Dimensions/DimensionGroup/GroupField.php @@ -22,15 +22,6 @@ public function getGroup(): ?DimensionGroup return $this->group; } - public function getGroupToString(): ?string - { - if ($this->getGroup() != null) { - return $this->group->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setGroup(?DimensionGroup $group): self $this->group = $group; return $this; } - - /** - * @param string|null $groupString - * @return $this - * @throws Exception - */ - public function setGroupFromString(?string $groupString) - { - $group = new DimensionGroup(); - $group->setCode($groupString); - return $this->setGroup($group); - } } diff --git a/src/Fields/Dimensions/DimensionType/TypeField.php b/src/Fields/Dimensions/DimensionType/TypeField.php index 81c5b837..27886c65 100644 --- a/src/Fields/Dimensions/DimensionType/TypeField.php +++ b/src/Fields/Dimensions/DimensionType/TypeField.php @@ -22,15 +22,6 @@ public function getType(): ?DimensionType return $this->type; } - public function getTypeToString(): ?string - { - if ($this->getType() != null) { - return $this->type->getCode(); - } else { - return null; - } - } - /** * @return $this */ diff --git a/src/Fields/Dimensions/Level2/BankBlockedField.php b/src/Fields/Dimensions/Level2/BankBlockedField.php index e2b13728..d1dc7a06 100644 --- a/src/Fields/Dimensions/Level2/BankBlockedField.php +++ b/src/Fields/Dimensions/Level2/BankBlockedField.php @@ -20,11 +20,6 @@ public function getBlocked(): ?bool return $this->blocked; } - public function getBlockedToString(): ?string - { - return ($this->getBlocked()) ? 'true' : 'false'; - } - /** * @param bool $blocked * @return $this @@ -34,14 +29,4 @@ public function setBlocked(?bool $blocked): self $this->blocked = $blocked; return $this; } - - /** - * @param string|null $blockedString - * @return $this - * @throws Exception - */ - public function setBlockedFromString(?string $blockedString) - { - return $this->setBlocked(filter_var($blockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/CountryField.php b/src/Fields/Dimensions/Level2/CountryField.php index 31935a3d..2b6366cf 100644 --- a/src/Fields/Dimensions/Level2/CountryField.php +++ b/src/Fields/Dimensions/Level2/CountryField.php @@ -22,15 +22,6 @@ public function getCountry(): ?Country return $this->country; } - public function getCountryToString(): ?string - { - if ($this->getCountry() != null) { - return $this->country->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setCountry(?Country $country): self $this->country = $country; return $this; } - - /** - * @param string|null $countryString - * @return $this - * @throws Exception - */ - public function setCountryFromString(?string $countryString) - { - $country = new Country(); - $country->setCode($countryString); - return $this->setCountry($country); - } } diff --git a/src/Fields/Dimensions/Level2/Customer/BaseCreditLimitField.php b/src/Fields/Dimensions/Level2/Customer/BaseCreditLimitField.php index 57764742..6e64c32d 100644 --- a/src/Fields/Dimensions/Level2/Customer/BaseCreditLimitField.php +++ b/src/Fields/Dimensions/Level2/Customer/BaseCreditLimitField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Dimensions\Level2\Customer; use Money\Money; -use PhpTwinfield\Util; trait BaseCreditLimitField { @@ -23,18 +22,6 @@ public function getBaseCreditLimit(): ?Money return $this->baseCreditLimit; } - /** - * @return float|null - */ - public function getBaseCreditLimitToFloat(): ?float - { - if ($this->getBaseCreditLimit() != null) { - return Util::formatMoney($this->getBaseCreditLimit()); - } else { - return 0; - } - } - /** * @param Money|null $baseCreditLimit * @return $this @@ -45,18 +32,4 @@ public function setBaseCreditLimit(?Money $baseCreditLimit) return $this; } - - /** - * @param float|null $baseCreditLimitFloat - * @return $this - * @throws Exception - */ - public function setBaseCreditLimitFromFloat(?float $baseCreditLimitFloat) - { - if ((float)$baseCreditLimitFloat) { - return $this->setBaseCreditLimit(Money::EUR(100 * $baseCreditLimitFloat)); - } else { - return $this->setBaseCreditLimit(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/Customer/BlockedField.php b/src/Fields/Dimensions/Level2/Customer/BlockedField.php index 8b313f3f..a2c566c7 100644 --- a/src/Fields/Dimensions/Level2/Customer/BlockedField.php +++ b/src/Fields/Dimensions/Level2/Customer/BlockedField.php @@ -19,12 +19,7 @@ public function getBlocked(): ?bool { return $this->blocked; } - - public function getBlockedToString(): ?string - { - return ($this->getBlocked()) ? 'true' : 'false'; - } - + /** * @param bool $blocked * @return $this @@ -34,14 +29,4 @@ public function setBlocked(?bool $blocked): self $this->blocked = $blocked; return $this; } - - /** - * @param string|null $blockedString - * @return $this - * @throws Exception - */ - public function setBlockedFromString(?string $blockedString) - { - return $this->setBlocked(filter_var($blockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/Customer/BlockedLockedField.php b/src/Fields/Dimensions/Level2/Customer/BlockedLockedField.php index 23aa08c5..82ad1a65 100644 --- a/src/Fields/Dimensions/Level2/Customer/BlockedLockedField.php +++ b/src/Fields/Dimensions/Level2/Customer/BlockedLockedField.php @@ -20,11 +20,6 @@ public function getBlockedLocked(): ?bool return $this->blockedLocked; } - public function getBlockedLockedToString(): ?string - { - return ($this->getBlockedLocked()) ? 'true' : 'false'; - } - /** * @param bool $blockedLocked * @return $this @@ -34,14 +29,4 @@ public function setBlockedLocked(?bool $blockedLocked): self $this->blockedLocked = $blockedLocked; return $this; } - - /** - * @param string|null $blockedLockedString - * @return $this - * @throws Exception - */ - public function setBlockedLockedFromString(?string $blockedLockedString) - { - return $this->setBlockedLocked(filter_var($blockedLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/Customer/BlockedModifiedField.php b/src/Fields/Dimensions/Level2/Customer/BlockedModifiedField.php index a99dabdf..f22f643a 100644 --- a/src/Fields/Dimensions/Level2/Customer/BlockedModifiedField.php +++ b/src/Fields/Dimensions/Level2/Customer/BlockedModifiedField.php @@ -2,16 +2,11 @@ namespace PhpTwinfield\Fields\Dimensions\Level2\Customer; -use PhpTwinfield\Exception; -use PhpTwinfield\Util; - /** * Blocked modified field * Used by: CustomerCreditManagement * * @package PhpTwinfield\Traits - * @see Util::formatDateTime() - * @see Util::parseDateTime() */ trait BlockedModifiedField { @@ -28,18 +23,6 @@ public function getBlockedModified(): ?\DateTimeInterface return $this->blockedModified; } - /** - * @return string|null - */ - public function getBlockedModifiedToString(): ?string - { - if ($this->getBlockedModified() != null) { - return Util::formatDateTime($this->getBlockedModified()); - } else { - return null; - } - } - /** * @param \DateTimeInterface|null $blockedModified * @return $this @@ -49,18 +32,4 @@ public function setBlockedModified(?\DateTimeInterface $blockedModified) $this->blockedModified = $blockedModified; return $this; } - - /** - * @param string|null $blockedModifiedString - * @return $this - * @throws Exception - */ - public function setBlockedModifiedFromString(?string $blockedModifiedString) - { - if ((bool)strtotime($blockedModifiedString)) { - return $this->setBlockedModified(Util::parseDateTime($blockedModifiedString)); - } else { - return $this->setBlockedModified(null); - } - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/Customer/CollectionSchemaField.php b/src/Fields/Dimensions/Level2/Customer/CollectionSchemaField.php index b19012df..e3e72d79 100644 --- a/src/Fields/Dimensions/Level2/Customer/CollectionSchemaField.php +++ b/src/Fields/Dimensions/Level2/Customer/CollectionSchemaField.php @@ -28,14 +28,4 @@ public function setCollectionSchema(?CollectionSchema $collectionSchema): self $this->collectionSchema = $collectionSchema; return $this; } - - /** - * @param string|null $collectionSchemaString - * @return $this - * @throws Exception - */ - public function setCollectionSchemaFromString(?string $collectionSchemaString) - { - return $this->setCollectionSchema(new CollectionSchema((string)$collectionSchemaString)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/Customer/DiscountArticleField.php b/src/Fields/Dimensions/Level2/Customer/DiscountArticleField.php index ad1e97e6..ed0a16c9 100644 --- a/src/Fields/Dimensions/Level2/Customer/DiscountArticleField.php +++ b/src/Fields/Dimensions/Level2/Customer/DiscountArticleField.php @@ -22,15 +22,6 @@ public function getDiscountArticle(): ?Article return $this->discountArticle; } - public function getDiscountArticleToString(): ?string - { - if ($this->getDiscountArticle() != null) { - return $this->discountArticle->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setDiscountArticle(?Article $discountArticle): self $this->discountArticle = $discountArticle; return $this; } - - /** - * @param string|null $discountArticleString - * @return $this - * @throws Exception - */ - public function setDiscountArticleFromString(?string $discountArticleString) - { - $discountArticle = new Article(); - $discountArticle->setCode($discountArticleString); - return $this->setDiscountArticle($discountArticle); - } } diff --git a/src/Fields/Dimensions/Level2/Customer/EBillingField.php b/src/Fields/Dimensions/Level2/Customer/EBillingField.php index 26e4eb3d..63ad2de5 100644 --- a/src/Fields/Dimensions/Level2/Customer/EBillingField.php +++ b/src/Fields/Dimensions/Level2/Customer/EBillingField.php @@ -20,11 +20,6 @@ public function getEBilling(): ?bool return $this->eBilling; } - public function getEBillingToString(): ?string - { - return ($this->getEBilling()) ? 'true' : 'false'; - } - /** * @param bool $eBilling * @return $this @@ -34,14 +29,4 @@ public function setEBilling(?bool $eBilling): self $this->eBilling = $eBilling; return $this; } - - /** - * @param string|null $eBillingString - * @return $this - * @throws Exception - */ - public function setEBillingFromString(?string $eBillingString) - { - return $this->setEBilling(filter_var($eBillingString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/Customer/FirstRunDateField.php b/src/Fields/Dimensions/Level2/Customer/FirstRunDateField.php index c1ff1f75..c8507066 100644 --- a/src/Fields/Dimensions/Level2/Customer/FirstRunDateField.php +++ b/src/Fields/Dimensions/Level2/Customer/FirstRunDateField.php @@ -2,16 +2,11 @@ namespace PhpTwinfield\Fields\Dimensions\Level2\Customer; -use PhpTwinfield\Exception; -use PhpTwinfield\Util; - /** * First run date field * Used by: CustomerCollectMandate * * @package PhpTwinfield\Traits - * @see Util::formatDate() - * @see Util::parseDate() */ trait FirstRunDateField { @@ -28,18 +23,6 @@ public function getFirstRunDate(): ?\DateTimeInterface return $this->firstRunDate; } - /** - * @return string|null - */ - public function getFirstRunDateToString(): ?string - { - if ($this->getFirstRunDate() != null) { - return Util::formatDate($this->getFirstRunDate()); - } else { - return null; - } - } - /** * @param \DateTimeInterface|null $firstRunDate * @return $this @@ -49,18 +32,4 @@ public function setFirstRunDate(?\DateTimeInterface $firstRunDate) $this->firstRunDate = $firstRunDate; return $this; } - - /** - * @param string|null $firstRunDateString - * @return $this - * @throws Exception - */ - public function setFirstRunDateFromString(?string $firstRunDateString) - { - if ((bool)strtotime($firstRunDateString)) { - return $this->setFirstRunDate(Util::parseDate($firstRunDateString)); - } else { - return $this->setFirstRunDate(null); - } - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/Customer/FreeText1Field.php b/src/Fields/Dimensions/Level2/Customer/FreeText1Field.php index 4977d30b..e8d2ebf9 100644 --- a/src/Fields/Dimensions/Level2/Customer/FreeText1Field.php +++ b/src/Fields/Dimensions/Level2/Customer/FreeText1Field.php @@ -20,11 +20,6 @@ public function getFreeText1(): ?bool return $this->freeText1; } - public function getFreeText1ToString(): ?string - { - return ($this->getFreeText1()) ? 'true' : 'false'; - } - /** * @param bool $freeText1 * @return $this @@ -34,14 +29,4 @@ public function setFreeText1(?bool $freeText1): self $this->freeText1 = $freeText1; return $this; } - - /** - * @param string|null $freeText1String - * @return $this - * @throws Exception - */ - public function setFreeText1FromString(?string $freeText1String) - { - return $this->setFreeText1(filter_var($freeText1String, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/Customer/ResponsibleUserField.php b/src/Fields/Dimensions/Level2/Customer/ResponsibleUserField.php index e1e54a24..726ec441 100644 --- a/src/Fields/Dimensions/Level2/Customer/ResponsibleUserField.php +++ b/src/Fields/Dimensions/Level2/Customer/ResponsibleUserField.php @@ -22,15 +22,6 @@ public function getResponsibleUser(): ?User return $this->responsibleUser; } - public function getResponsibleUserToString(): ?string - { - if ($this->getResponsibleUser() != null) { - return $this->responsibleUser->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,17 +30,5 @@ public function setResponsibleUser(?User $responsibleUser): self $this->responsibleUser = $responsibleUser; return $this; } - - /** - * @param string|null $responsibleUserString - * @return $this - * @throws Exception - */ - public function setResponsibleUserFromString(?string $responsibleUserString) - { - $responsibleUser = new User(); - $responsibleUser->setCode($responsibleUserString); - return $this->setResponsibleUser($responsibleUser); - } } diff --git a/src/Fields/Dimensions/Level2/Customer/SendReminderField.php b/src/Fields/Dimensions/Level2/Customer/SendReminderField.php index 20ed5b77..640db04a 100644 --- a/src/Fields/Dimensions/Level2/Customer/SendReminderField.php +++ b/src/Fields/Dimensions/Level2/Customer/SendReminderField.php @@ -28,14 +28,4 @@ public function setSendReminder(?SendReminder $sendReminder): self $this->sendReminder = $sendReminder; return $this; } - - /** - * @param string|null $sendReminderString - * @return $this - * @throws Exception - */ - public function setSendReminderFromString(?string $sendReminderString) - { - return $this->setSendReminder(new SendReminder((string)$sendReminderString)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/Customer/SignatureDateField.php b/src/Fields/Dimensions/Level2/Customer/SignatureDateField.php index 0a4fe3f4..6612d932 100644 --- a/src/Fields/Dimensions/Level2/Customer/SignatureDateField.php +++ b/src/Fields/Dimensions/Level2/Customer/SignatureDateField.php @@ -2,16 +2,11 @@ namespace PhpTwinfield\Fields\Dimensions\Level2\Customer; -use PhpTwinfield\Exception; -use PhpTwinfield\Util; - /** * Signature date field * Used by: CustomerCollectMandate * * @package PhpTwinfield\Traits - * @see Util::formatDate() - * @see Util::parseDate() */ trait SignatureDateField { @@ -28,18 +23,6 @@ public function getSignatureDate(): ?\DateTimeInterface return $this->signatureDate; } - /** - * @return string|null - */ - public function getSignatureDateToString(): ?string - { - if ($this->getSignatureDate() != null) { - return Util::formatDate($this->getSignatureDate()); - } else { - return null; - } - } - /** * @param \DateTimeInterface|null $signatureDate * @return $this @@ -49,18 +32,4 @@ public function setSignatureDate(?\DateTimeInterface $signatureDate) $this->signatureDate = $signatureDate; return $this; } - - /** - * @param string|null $signatureDateString - * @return $this - * @throws Exception - */ - public function setSignatureDateFromString(?string $signatureDateString) - { - if ((bool)strtotime($signatureDateString)) { - return $this->setSignatureDate(Util::parseDate($signatureDateString)); - } else { - return $this->setSignatureDate(null); - } - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/DefaultField.php b/src/Fields/Dimensions/Level2/DefaultField.php index 85dc56c7..3c319698 100644 --- a/src/Fields/Dimensions/Level2/DefaultField.php +++ b/src/Fields/Dimensions/Level2/DefaultField.php @@ -20,11 +20,6 @@ public function getDefault(): ?bool return $this->default; } - public function getDefaultToString(): ?string - { - return ($this->getDefault()) ? 'true' : 'false'; - } - /** * @param bool $default * @return $this @@ -34,14 +29,4 @@ public function setDefault(?bool $default): self $this->default = $default; return $this; } - - /** - * @param string|null $defaultString - * @return $this - * @throws Exception - */ - public function setDefaultFromString(?string $defaultString) - { - return $this->setDefault(filter_var($defaultString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/Dimension1Field.php b/src/Fields/Dimensions/Level2/Dimension1Field.php index 791402bd..5bb875ac 100644 --- a/src/Fields/Dimensions/Level2/Dimension1Field.php +++ b/src/Fields/Dimensions/Level2/Dimension1Field.php @@ -22,15 +22,6 @@ public function getDimension1(): ?GeneralLedger return $this->dimension1; } - public function getDimension1ToString(): ?string - { - if ($this->getDimension1() != null) { - return $this->dimension1->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setDimension1(?GeneralLedger $dimension1): self $this->dimension1 = $dimension1; return $this; } - - /** - * @param string|null $dimension1String - * @return $this - * @throws Exception - */ - public function setDimension1FromString(?string $dimension1String) - { - $dimension1 = new GeneralLedger(); - $dimension1->setCode($dimension1String); - return $this->setDimension1($dimension1); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/Dimension2Field.php b/src/Fields/Dimensions/Level2/Dimension2Field.php index 7a6515dc..75c75ed4 100644 --- a/src/Fields/Dimensions/Level2/Dimension2Field.php +++ b/src/Fields/Dimensions/Level2/Dimension2Field.php @@ -22,15 +22,6 @@ public function getDimension2(): ?CostCenter return $this->dimension2; } - public function getDimension2ToString(): ?string - { - if ($this->getDimension2() != null) { - return $this->dimension2->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setDimension2(?CostCenter $dimension2): self $this->dimension2 = $dimension2; return $this; } - - /** - * @param string|null $dimension2String - * @return $this - * @throws Exception - */ - public function setDimension2FromString(?string $dimension2String) - { - $dimension2 = new CostCenter(); - $dimension2->setCode($dimension2String); - return $this->setDimension2($dimension2); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/Dimension3Field.php b/src/Fields/Dimensions/Level2/Dimension3Field.php index 7ecc0e79..3f7a1369 100644 --- a/src/Fields/Dimensions/Level2/Dimension3Field.php +++ b/src/Fields/Dimensions/Level2/Dimension3Field.php @@ -2,8 +2,6 @@ namespace PhpTwinfield\Fields\Dimensions\Level2; -use PhpTwinfield\Dummy; - /** * The dimension * Used by: CustomerLine, SupplierLine @@ -22,15 +20,6 @@ public function getDimension3() return $this->dimension3; } - public function getDimension3ToString(): ?string - { - if ($this->getDimension3() != null) { - return $this->dimension3->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +28,4 @@ public function setDimension3($dimension3): self $this->dimension3 = $dimension3; return $this; } - - /** - * @param string|null $dimension3String - * @return $this - * @throws Exception - */ - public function setDimension3FromString(?string $dimension3String) - { - $dimension3 = new Dummy(); - $dimension3->setCode($dimension3String); - return $this->setDimension3($dimension3); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/MeansOfPaymentField.php b/src/Fields/Dimensions/Level2/MeansOfPaymentField.php index 5c72ccf8..7c11d8c6 100644 --- a/src/Fields/Dimensions/Level2/MeansOfPaymentField.php +++ b/src/Fields/Dimensions/Level2/MeansOfPaymentField.php @@ -28,14 +28,4 @@ public function setMeansOfPayment(?MeansOfPayment $meansOfPayment): self $this->meansOfPayment = $meansOfPayment; return $this; } - - /** - * @param string|null $meansOfPaymentString - * @return $this - * @throws Exception - */ - public function setMeansOfPaymentFromString(?string $meansOfPaymentString) - { - return $this->setMeansOfPayment(new MeansOfPayment((string)$meansOfPaymentString)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/PayAvailableField.php b/src/Fields/Dimensions/Level2/PayAvailableField.php index 19d21afe..0843d454 100644 --- a/src/Fields/Dimensions/Level2/PayAvailableField.php +++ b/src/Fields/Dimensions/Level2/PayAvailableField.php @@ -20,11 +20,6 @@ public function getPayAvailable(): ?bool return $this->payAvailable; } - public function getPayAvailableToString(): ?string - { - return ($this->getPayAvailable()) ? 'true' : 'false'; - } - /** * @param bool $payAvailable * @return $this @@ -34,14 +29,4 @@ public function setPayAvailable(?bool $payAvailable): self $this->payAvailable = $payAvailable; return $this; } - - /** - * @param string|null $payAvailableString - * @return $this - * @throws Exception - */ - public function setPayAvailableFromString(?string $payAvailableString) - { - return $this->setPayAvailable(filter_var($payAvailableString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/PayCodeField.php b/src/Fields/Dimensions/Level2/PayCodeField.php index 03976736..77fd15e1 100644 --- a/src/Fields/Dimensions/Level2/PayCodeField.php +++ b/src/Fields/Dimensions/Level2/PayCodeField.php @@ -22,15 +22,6 @@ public function getPayCode(): ?PayCode return $this->payCode; } - public function getPayCodeToString(): ?string - { - if ($this->getPayCode() != null) { - return $this->payCode->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setPayCode(?PayCode $payCode): self $this->payCode = $payCode; return $this; } - - /** - * @param string|null $payCodeString - * @return $this - * @throws Exception - */ - public function setPayCodeFromString(?string $payCodeString) - { - $payCode = new PayCode(); - $payCode->setCode($payCodeString); - return $this->setPayCode($payCode); - } } diff --git a/src/Fields/Dimensions/Level2/RemittanceAdviceSendTypeField.php b/src/Fields/Dimensions/Level2/RemittanceAdviceSendTypeField.php index 48fda613..d23e8e85 100644 --- a/src/Fields/Dimensions/Level2/RemittanceAdviceSendTypeField.php +++ b/src/Fields/Dimensions/Level2/RemittanceAdviceSendTypeField.php @@ -28,14 +28,4 @@ public function setRemittanceAdviceSendType(?RemittanceAdviceSendType $remittanc $this->remittanceAdviceSendType = $remittanceAdviceSendType; return $this; } - - /** - * @param string|null $remittanceAdviceSendTypeString - * @return $this - * @throws Exception - */ - public function setRemittanceAdviceSendTypeFromString(?string $remittanceAdviceSendTypeString) - { - return $this->setRemittanceAdviceSendType(new RemittanceAdviceSendType((string)$remittanceAdviceSendTypeString)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/Supplier/BlockedAccountPaymentConditionsIncludeVatField.php b/src/Fields/Dimensions/Level2/Supplier/BlockedAccountPaymentConditionsIncludeVatField.php index f99bbbd3..b0092ac0 100644 --- a/src/Fields/Dimensions/Level2/Supplier/BlockedAccountPaymentConditionsIncludeVatField.php +++ b/src/Fields/Dimensions/Level2/Supplier/BlockedAccountPaymentConditionsIncludeVatField.php @@ -28,14 +28,4 @@ public function setBlockedAccountPaymentConditionsIncludeVat(?BlockedAccountPaym $this->blockedAccountPaymentConditionsIncludeVat = $blockedAccountPaymentConditionsIncludeVat; return $this; } - - /** - * @param string|null $blockedAccountPaymentConditionsIncludeVatString - * @return $this - * @throws Exception - */ - public function setBlockedAccountPaymentConditionsIncludeVatFromString(?string $blockedAccountPaymentConditionsIncludeVatString) - { - return $this->setBlockedAccountPaymentConditionsIncludeVat(new BlockedAccountPaymentConditionsIncludeVat((string)$blockedAccountPaymentConditionsIncludeVatString)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level2/TypeField.php b/src/Fields/Dimensions/Level2/TypeField.php index 51c7ed1d..3d935c3f 100644 --- a/src/Fields/Dimensions/Level2/TypeField.php +++ b/src/Fields/Dimensions/Level2/TypeField.php @@ -28,14 +28,4 @@ public function setType(?AddressType $type): self $this->type = $type; return $this; } - - /** - * @param string|null $typeString - * @return $this - * @throws Exception - */ - public function setTypeFromString(?string $typeString) - { - return $this->setType(new AddressType((string)$typeString)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/AuthoriserField.php b/src/Fields/Dimensions/Level34/AuthoriserField.php index a0fdced8..0c93ce31 100644 --- a/src/Fields/Dimensions/Level34/AuthoriserField.php +++ b/src/Fields/Dimensions/Level34/AuthoriserField.php @@ -39,16 +39,4 @@ public function setAuthoriser(?User $authoriser): self $this->authoriser = $authoriser; return $this; } - - /** - * @param string|null $authoriserString - * @return $this - * @throws Exception - */ - public function setAuthoriserFromString(?string $authoriserString) - { - $authoriser = new User(); - $authoriser->setCode($authoriserString); - return $this->setAuthoriser($authoriser); - } } diff --git a/src/Fields/Dimensions/Level34/AuthoriserInheritField.php b/src/Fields/Dimensions/Level34/AuthoriserInheritField.php index 4a985fd8..298ce24f 100644 --- a/src/Fields/Dimensions/Level34/AuthoriserInheritField.php +++ b/src/Fields/Dimensions/Level34/AuthoriserInheritField.php @@ -34,14 +34,4 @@ public function setAuthoriserInherit(?bool $authoriserInherit): self $this->authoriserInherit = $authoriserInherit; return $this; } - - /** - * @param string|null $authoriserInheritString - * @return $this - * @throws Exception - */ - public function setAuthoriserInheritFromString(?string $authoriserInheritString) - { - return $this->setAuthoriserInherit(filter_var($authoriserInheritString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/AuthoriserLockedField.php b/src/Fields/Dimensions/Level34/AuthoriserLockedField.php index 3c10b1cd..4e5a63b4 100644 --- a/src/Fields/Dimensions/Level34/AuthoriserLockedField.php +++ b/src/Fields/Dimensions/Level34/AuthoriserLockedField.php @@ -34,14 +34,4 @@ public function setAuthoriserLocked(?bool $authoriserLocked): self $this->authoriserLocked = $authoriserLocked; return $this; } - - /** - * @param string|null $authoriserLockedString - * @return $this - * @throws Exception - */ - public function setAuthoriserLockedFromString(?string $authoriserLockedString) - { - return $this->setAuthoriserLocked(filter_var($authoriserLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/BillableField.php b/src/Fields/Dimensions/Level34/BillableField.php index ed5d5b20..9680c836 100644 --- a/src/Fields/Dimensions/Level34/BillableField.php +++ b/src/Fields/Dimensions/Level34/BillableField.php @@ -34,14 +34,4 @@ public function setBillable(?bool $billable): self $this->billable = $billable; return $this; } - - /** - * @param string|null $billableString - * @return $this - * @throws Exception - */ - public function setBillableFromString(?string $billableString) - { - return $this->setBillable(filter_var($billableString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/BillableForRatioField.php b/src/Fields/Dimensions/Level34/BillableForRatioField.php index 600c9309..b23f5cee 100644 --- a/src/Fields/Dimensions/Level34/BillableForRatioField.php +++ b/src/Fields/Dimensions/Level34/BillableForRatioField.php @@ -34,14 +34,4 @@ public function setBillableForRatio(?bool $billableForRatio): self $this->billableForRatio = $billableForRatio; return $this; } - - /** - * @param string|null $billableForRatioString - * @return $this - * @throws Exception - */ - public function setBillableForRatioFromString(?string $billableForRatioString) - { - return $this->setBillableForRatio(filter_var($billableForRatioString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/BillableInheritField.php b/src/Fields/Dimensions/Level34/BillableInheritField.php index 7a1c9daf..1c3329ce 100644 --- a/src/Fields/Dimensions/Level34/BillableInheritField.php +++ b/src/Fields/Dimensions/Level34/BillableInheritField.php @@ -34,14 +34,4 @@ public function setBillableInherit(?bool $billableInherit): self $this->billableInherit = $billableInherit; return $this; } - - /** - * @param string|null $billableInheritString - * @return $this - * @throws Exception - */ - public function setBillableInheritFromString(?string $billableInheritString) - { - return $this->setBillableInherit(filter_var($billableInheritString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/BillableLockedField.php b/src/Fields/Dimensions/Level34/BillableLockedField.php index 80f313f8..b05162ce 100644 --- a/src/Fields/Dimensions/Level34/BillableLockedField.php +++ b/src/Fields/Dimensions/Level34/BillableLockedField.php @@ -34,14 +34,4 @@ public function setBillableLocked(?bool $billableLocked): self $this->billableLocked = $billableLocked; return $this; } - - /** - * @param string|null $billableLockedString - * @return $this - * @throws Exception - */ - public function setBillableLockedFromString(?string $billableLockedString) - { - return $this->setBillableLocked(filter_var($billableLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/CustomerInheritField.php b/src/Fields/Dimensions/Level34/CustomerInheritField.php index b974b8b9..60ece07f 100644 --- a/src/Fields/Dimensions/Level34/CustomerInheritField.php +++ b/src/Fields/Dimensions/Level34/CustomerInheritField.php @@ -34,14 +34,4 @@ public function setCustomerInherit(?bool $customerInherit): self $this->customerInherit = $customerInherit; return $this; } - - /** - * @param string|null $customerInheritString - * @return $this - * @throws Exception - */ - public function setCustomerInheritFromString(?string $customerInheritString) - { - return $this->setCustomerInherit(filter_var($customerInheritString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/CustomerLockedField.php b/src/Fields/Dimensions/Level34/CustomerLockedField.php index f7940452..a6a8f22f 100644 --- a/src/Fields/Dimensions/Level34/CustomerLockedField.php +++ b/src/Fields/Dimensions/Level34/CustomerLockedField.php @@ -34,14 +34,4 @@ public function setCustomerLocked(?bool $customerLocked): self $this->customerLocked = $customerLocked; return $this; } - - /** - * @param string|null $customerLockedString - * @return $this - * @throws Exception - */ - public function setCustomerLockedFromString(?string $customerLockedString) - { - return $this->setCustomerLocked(filter_var($customerLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/AmountLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/AmountLockedField.php index 470b92d7..12a1c033 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/AmountLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/AmountLockedField.php @@ -20,11 +20,6 @@ public function getAmountLocked(): ?bool return $this->amountLocked; } - public function getAmountLockedToString(): ?string - { - return ($this->getAmountLocked()) ? 'true' : 'false'; - } - /** * @param bool $amountLocked * @return $this @@ -34,14 +29,4 @@ public function setAmountLocked(?bool $amountLocked): self $this->amountLocked = $amountLocked; return $this; } - - /** - * @param string|null $amountLockedString - * @return $this - * @throws Exception - */ - public function setAmountLockedFromString(?string $amountLockedString) - { - return $this->setAmountLocked(filter_var($amountLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/BeginPeriodLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/BeginPeriodLockedField.php index d6e66eb3..a02e3bc4 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/BeginPeriodLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/BeginPeriodLockedField.php @@ -20,11 +20,6 @@ public function getBeginPeriodLocked(): ?bool return $this->beginPeriodLocked; } - public function getBeginPeriodLockedToString(): ?string - { - return ($this->getBeginPeriodLocked()) ? 'true' : 'false'; - } - /** * @param bool $beginPeriodLocked * @return $this @@ -34,14 +29,4 @@ public function setBeginPeriodLocked(?bool $beginPeriodLocked): self $this->beginPeriodLocked = $beginPeriodLocked; return $this; } - - /** - * @param string|null $beginPeriodLockedString - * @return $this - * @throws Exception - */ - public function setBeginPeriodLockedFromString(?string $beginPeriodLockedString) - { - return $this->setBeginPeriodLocked(filter_var($beginPeriodLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/CodeField.php b/src/Fields/Dimensions/Level34/FixedAsset/CodeField.php index 1959c885..70e57d88 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/CodeField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/CodeField.php @@ -20,15 +20,6 @@ public function getCode() return $this->code; } - public function getCodeToString(): ?string - { - if ($this->getCode() != null) { - return $this->code->getCode(); - } else { - return null; - } - } - /** * @return $this */ diff --git a/src/Fields/Dimensions/Level34/FixedAsset/CodeLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/CodeLockedField.php index 785835d0..b0302a3d 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/CodeLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/CodeLockedField.php @@ -20,11 +20,6 @@ public function getCodeLocked(): ?bool return $this->codeLocked; } - public function getCodeLockedToString(): ?string - { - return ($this->getCodeLocked()) ? 'true' : 'false'; - } - /** * @param bool $codeLocked * @return $this @@ -34,14 +29,4 @@ public function setCodeLocked(?bool $codeLocked): self $this->codeLocked = $codeLocked; return $this; } - - /** - * @param string|null $codeLockedString - * @return $this - * @throws Exception - */ - public function setCodeLockedFromString(?string $codeLockedString) - { - return $this->setCodeLocked(filter_var($codeLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/Dim1LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim1LockedField.php index cf92b052..fe12dc9e 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/Dim1LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim1LockedField.php @@ -19,12 +19,7 @@ public function getDim1Locked(): ?bool { return $this->dim1Locked; } - - public function getDim1LockedToString(): ?string - { - return ($this->getDim1Locked()) ? 'true' : 'false'; - } - + /** * @param bool $dim1Locked * @return $this @@ -34,14 +29,4 @@ public function setDim1Locked(?bool $dim1Locked): self $this->dim1Locked = $dim1Locked; return $this; } - - /** - * @param string|null $dim1LockedString - * @return $this - * @throws Exception - */ - public function setDim1LockedFromString(?string $dim1LockedString) - { - return $this->setDim1Locked(filter_var($dim1LockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/Dim2LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim2LockedField.php index b2712b10..34bb7ad8 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/Dim2LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim2LockedField.php @@ -20,11 +20,6 @@ public function getDim2Locked(): ?bool return $this->dim2Locked; } - public function getDim2LockedToString(): ?string - { - return ($this->getDim2Locked()) ? 'true' : 'false'; - } - /** * @param bool $dim2Locked * @return $this @@ -34,14 +29,4 @@ public function setDim2Locked(?bool $dim2Locked): self $this->dim2Locked = $dim2Locked; return $this; } - - /** - * @param string|null $dim2LockedString - * @return $this - * @throws Exception - */ - public function setDim2LockedFromString(?string $dim2LockedString) - { - return $this->setDim2Locked(filter_var($dim2LockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/Dim3LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim3LockedField.php index b11c51fc..6323bf2b 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/Dim3LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim3LockedField.php @@ -20,11 +20,6 @@ public function getDim3Locked(): ?bool return $this->dim3Locked; } - public function getDim3LockedToString(): ?string - { - return ($this->getDim3Locked()) ? 'true' : 'false'; - } - /** * @param bool $dim3Locked * @return $this @@ -34,14 +29,4 @@ public function setDim3Locked(?bool $dim3Locked): self $this->dim3Locked = $dim3Locked; return $this; } - - /** - * @param string|null $dim3LockedString - * @return $this - * @throws Exception - */ - public function setDim3LockedFromString(?string $dim3LockedString) - { - return $this->setDim3Locked(filter_var($dim3LockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/Dim4LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim4LockedField.php index f384f956..a734225b 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/Dim4LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim4LockedField.php @@ -20,11 +20,6 @@ public function getDim4Locked(): ?bool return $this->dim4Locked; } - public function getDim4LockedToString(): ?string - { - return ($this->getDim4Locked()) ? 'true' : 'false'; - } - /** * @param bool $dim4Locked * @return $this @@ -34,14 +29,4 @@ public function setDim4Locked(?bool $dim4Locked): self $this->dim4Locked = $dim4Locked; return $this; } - - /** - * @param string|null $dim4LockedString - * @return $this - * @throws Exception - */ - public function setDim4LockedFromString(?string $dim4LockedString) - { - return $this->setDim4Locked(filter_var($dim4LockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/Dim5Field.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim5Field.php index 0a6615a4..910827d7 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/Dim5Field.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim5Field.php @@ -2,8 +2,6 @@ namespace PhpTwinfield\Fields\Dimensions\Level34\FixedAsset; -use PhpTwinfield\Dummy; - /** * The dimension * Used by: FixedAssetTransactionLine @@ -22,15 +20,6 @@ public function getDim5() return $this->dim5; } - public function getDim5ToString(): ?string - { - if ($this->getDim5() != null) { - return $this->dim5->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +28,4 @@ public function setDim5($dim5): self $this->dim5 = $dim5; return $this; } - - /** - * @param string|null $dim5String - * @return $this - * @throws Exception - */ - public function setDim5FromString(?string $dim5String) - { - $dim5 = new Dummy(); - $dim5->setCode($dim5String); - return $this->setDim5($dim5); - } } diff --git a/src/Fields/Dimensions/Level34/FixedAsset/Dim5LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim5LockedField.php index fce648f0..a9677d69 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/Dim5LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim5LockedField.php @@ -19,12 +19,7 @@ public function getDim5Locked(): ?bool { return $this->dim5Locked; } - - public function getDim5LockedToString(): ?string - { - return ($this->getDim5Locked()) ? 'true' : 'false'; - } - + /** * @param bool $dim5Locked * @return $this @@ -34,14 +29,4 @@ public function setDim5Locked(?bool $dim5Locked): self $this->dim5Locked = $dim5Locked; return $this; } - - /** - * @param string|null $dim5LockedString - * @return $this - * @throws Exception - */ - public function setDim5LockedFromString(?string $dim5LockedString) - { - return $this->setDim5Locked(filter_var($dim5LockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/Dim6Field.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim6Field.php index 6ab99d32..b3ddd90d 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/Dim6Field.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim6Field.php @@ -2,8 +2,6 @@ namespace PhpTwinfield\Fields\Dimensions\Level34\FixedAsset; -use PhpTwinfield\Dummy; - /** * The dimension * Used by: FixedAssetTransactionLine @@ -22,15 +20,6 @@ public function getDim6() return $this->dim6; } - public function getDim6ToString(): ?string - { - if ($this->getDim6() != null) { - return $this->dim6->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +28,4 @@ public function setDim6($dim6): self $this->dim6 = $dim6; return $this; } - - /** - * @param string|null $dim6String - * @return $this - * @throws Exception - */ - public function setDim6FromString(?string $dim6String) - { - $dim6 = new Dummy(); - $dim6->setCode($dim6String); - return $this->setDim6($dim6); - } } diff --git a/src/Fields/Dimensions/Level34/FixedAsset/Dim6LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim6LockedField.php index d6b9408c..724103ba 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/Dim6LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim6LockedField.php @@ -20,11 +20,6 @@ public function getDim6Locked(): ?bool return $this->dim6Locked; } - public function getDim6LockedToString(): ?string - { - return ($this->getDim6Locked()) ? 'true' : 'false'; - } - /** * @param bool $dim6Locked * @return $this @@ -34,14 +29,4 @@ public function setDim6Locked(?bool $dim6Locked): self $this->dim6Locked = $dim6Locked; return $this; } - - /** - * @param string|null $dim6LockedString - * @return $this - * @throws Exception - */ - public function setDim6LockedFromString(?string $dim6LockedString) - { - return $this->setDim6Locked(filter_var($dim6LockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/FreeText1LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText1LockedField.php index 670505ee..a3080d23 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/FreeText1LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText1LockedField.php @@ -20,11 +20,6 @@ public function getFreeText1Locked(): ?bool return $this->freeText1Locked; } - public function getFreeText1LockedToString(): ?string - { - return ($this->getFreeText1Locked()) ? 'true' : 'false'; - } - /** * @param bool $freeText1Locked * @return $this @@ -34,14 +29,4 @@ public function setFreeText1Locked(?bool $freeText1Locked): self $this->freeText1Locked = $freeText1Locked; return $this; } - - /** - * @param string|null $freeText1LockedString - * @return $this - * @throws Exception - */ - public function setFreeText1LockedFromString(?string $freeText1LockedString) - { - return $this->setFreeText1Locked(filter_var($freeText1LockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/FreeText2LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText2LockedField.php index 80ad63c9..ac0d012c 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/FreeText2LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText2LockedField.php @@ -20,11 +20,6 @@ public function getFreeText2Locked(): ?bool return $this->freeText2Locked; } - public function getFreeText2LockedToString(): ?string - { - return ($this->getFreeText2Locked()) ? 'true' : 'false'; - } - /** * @param bool $freeText2Locked * @return $this @@ -34,14 +29,4 @@ public function setFreeText2Locked(?bool $freeText2Locked): self $this->freeText2Locked = $freeText2Locked; return $this; } - - /** - * @param string|null $freeText2LockedString - * @return $this - * @throws Exception - */ - public function setFreeText2LockedFromString(?string $freeText2LockedString) - { - return $this->setFreeText2Locked(filter_var($freeText2LockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/FreeText3LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText3LockedField.php index b4f4ae36..23704b29 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/FreeText3LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText3LockedField.php @@ -19,12 +19,7 @@ public function getFreeText3Locked(): ?bool { return $this->freeText3Locked; } - - public function getFreeText3LockedToString(): ?string - { - return ($this->getFreeText3Locked()) ? 'true' : 'false'; - } - + /** * @param bool $freeText3Locked * @return $this @@ -34,14 +29,4 @@ public function setFreeText3Locked(?bool $freeText3Locked): self $this->freeText3Locked = $freeText3Locked; return $this; } - - /** - * @param string|null $freeText3LockedString - * @return $this - * @throws Exception - */ - public function setFreeText3LockedFromString(?string $freeText3LockedString) - { - return $this->setFreeText3Locked(filter_var($freeText3LockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/FreeText4LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText4LockedField.php index 1294c5fc..8cbf120f 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/FreeText4LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText4LockedField.php @@ -20,11 +20,6 @@ public function getFreeText4Locked(): ?bool return $this->freeText4Locked; } - public function getFreeText4LockedToString(): ?string - { - return ($this->getFreeText4Locked()) ? 'true' : 'false'; - } - /** * @param bool $freeText4Locked * @return $this @@ -34,14 +29,4 @@ public function setFreeText4Locked(?bool $freeText4Locked): self $this->freeText4Locked = $freeText4Locked; return $this; } - - /** - * @param string|null $freeText4LockedString - * @return $this - * @throws Exception - */ - public function setFreeText4LockedFromString(?string $freeText4LockedString) - { - return $this->setFreeText4Locked(filter_var($freeText4LockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/FreeText5LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText5LockedField.php index 88e2345f..ac201b00 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/FreeText5LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText5LockedField.php @@ -20,11 +20,6 @@ public function getFreeText5Locked(): ?bool return $this->freeText5Locked; } - public function getFreeText5LockedToString(): ?string - { - return ($this->getFreeText5Locked()) ? 'true' : 'false'; - } - /** * @param bool $freeText5Locked * @return $this @@ -34,14 +29,4 @@ public function setFreeText5Locked(?bool $freeText5Locked): self $this->freeText5Locked = $freeText5Locked; return $this; } - - /** - * @param string|null $freeText5LockedString - * @return $this - * @throws Exception - */ - public function setFreeText5LockedFromString(?string $freeText5LockedString) - { - return $this->setFreeText5Locked(filter_var($freeText5LockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/LastDepreciationLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/LastDepreciationLockedField.php index af28d925..86729e17 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/LastDepreciationLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/LastDepreciationLockedField.php @@ -20,11 +20,6 @@ public function getLastDepreciationLocked(): ?bool return $this->lastDepreciationLocked; } - public function getLastDepreciationLockedToString(): ?string - { - return ($this->getLastDepreciationLocked()) ? 'true' : 'false'; - } - /** * @param bool $lastDepreciationLocked * @return $this @@ -34,14 +29,4 @@ public function setLastDepreciationLocked(?bool $lastDepreciationLocked): self $this->lastDepreciationLocked = $lastDepreciationLocked; return $this; } - - /** - * @param string|null $lastDepreciationLockedString - * @return $this - * @throws Exception - */ - public function setLastDepreciationLockedFromString(?string $lastDepreciationLockedString) - { - return $this->setLastDepreciationLocked(filter_var($lastDepreciationLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/LineLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/LineLockedField.php index 0e0ee9d2..8ab29e02 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/LineLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/LineLockedField.php @@ -20,11 +20,6 @@ public function getLineLocked(): ?bool return $this->lineLocked; } - public function getLineLockedToString(): ?string - { - return ($this->getLineLocked()) ? 'true' : 'false'; - } - /** * @param bool $lineLocked * @return $this @@ -34,14 +29,4 @@ public function setLineLocked(?bool $lineLocked): self $this->lineLocked = $lineLocked; return $this; } - - /** - * @param string|null $lineLockedString - * @return $this - * @throws Exception - */ - public function setLineLockedFromString(?string $lineLockedString) - { - return $this->setLineLocked(filter_var($lineLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/MethodField.php b/src/Fields/Dimensions/Level34/FixedAsset/MethodField.php index 0575071d..4fd36b54 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/MethodField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/MethodField.php @@ -22,15 +22,6 @@ public function getMethod(): ?AssetMethod return $this->method; } - public function getMethodToString(): ?string - { - if ($this->getMethod() != null) { - return $this->method->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setMethod(?AssetMethod $method): self $this->method = $method; return $this; } - - /** - * @param string|null $methodString - * @return $this - * @throws Exception - */ - public function setMethodFromString(?string $methodString) - { - $method = new AssetMethod(); - $method->setCode($methodString); - return $this->setMethod($method); - } } diff --git a/src/Fields/Dimensions/Level34/FixedAsset/MethodLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/MethodLockedField.php index f873af58..1415ca53 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/MethodLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/MethodLockedField.php @@ -20,11 +20,6 @@ public function getMethodLocked(): ?bool return $this->methodLocked; } - public function getMethodLockedToString(): ?string - { - return ($this->getMethodLocked()) ? 'true' : 'false'; - } - /** * @param bool $methodLocked * @return $this @@ -34,14 +29,4 @@ public function setMethodLocked(?bool $methodLocked): self $this->methodLocked = $methodLocked; return $this; } - - /** - * @param string|null $methodLockedString - * @return $this - * @throws Exception - */ - public function setMethodLockedFromString(?string $methodLockedString) - { - return $this->setMethodLocked(filter_var($methodLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/NrOfPeriodsInheritedField.php b/src/Fields/Dimensions/Level34/FixedAsset/NrOfPeriodsInheritedField.php index 93cdd6c2..8425748a 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/NrOfPeriodsInheritedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/NrOfPeriodsInheritedField.php @@ -20,11 +20,6 @@ public function getNrOfPeriodsInherited(): ?bool return $this->nrOfPeriodsInherited; } - public function getNrOfPeriodsInheritedToString(): ?string - { - return ($this->getNrOfPeriodsInherited()) ? 'true' : 'false'; - } - /** * @param bool $nrOfPeriodsInherited * @return $this @@ -34,14 +29,4 @@ public function setNrOfPeriodsInherited(?bool $nrOfPeriodsInherited): self $this->nrOfPeriodsInherited = $nrOfPeriodsInherited; return $this; } - - /** - * @param string|null $nrOfPeriodsInheritedString - * @return $this - * @throws Exception - */ - public function setNrOfPeriodsInheritedFromString(?string $nrOfPeriodsInheritedString) - { - return $this->setNrOfPeriodsInherited(filter_var($nrOfPeriodsInheritedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/NrOfPeriodsLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/NrOfPeriodsLockedField.php index c55b251a..a3efe6d3 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/NrOfPeriodsLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/NrOfPeriodsLockedField.php @@ -20,11 +20,6 @@ public function getNrOfPeriodsLocked(): ?bool return $this->nrOfPeriodsLocked; } - public function getNrOfPeriodsLockedToString(): ?string - { - return ($this->getNrOfPeriodsLocked()) ? 'true' : 'false'; - } - /** * @param bool $nrOfPeriodsLocked * @return $this @@ -34,14 +29,4 @@ public function setNrOfPeriodsLocked(?bool $nrOfPeriodsLocked): self $this->nrOfPeriodsLocked = $nrOfPeriodsLocked; return $this; } - - /** - * @param string|null $nrOfPeriodsLockedString - * @return $this - * @throws Exception - */ - public function setNrOfPeriodsLockedFromString(?string $nrOfPeriodsLockedString) - { - return $this->setNrOfPeriodsLocked(filter_var($nrOfPeriodsLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/NumberLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/NumberLockedField.php index 7283a73e..39c65f3c 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/NumberLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/NumberLockedField.php @@ -20,11 +20,6 @@ public function getNumberLocked(): ?bool return $this->numberLocked; } - public function getNumberLockedToString(): ?string - { - return ($this->getNumberLocked()) ? 'true' : 'false'; - } - /** * @param bool $numberLocked * @return $this @@ -34,14 +29,4 @@ public function setNumberLocked(?bool $numberLocked): self $this->numberLocked = $numberLocked; return $this; } - - /** - * @param string|null $numberLockedString - * @return $this - * @throws Exception - */ - public function setNumberLockedFromString(?string $numberLockedString) - { - return $this->setNumberLocked(filter_var($numberLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/PercentageLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/PercentageLockedField.php index aeae43a8..2355f0ec 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/PercentageLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/PercentageLockedField.php @@ -20,11 +20,6 @@ public function getPercentageLocked(): ?bool return $this->percentageLocked; } - public function getPercentageLockedToString(): ?string - { - return ($this->getPercentageLocked()) ? 'true' : 'false'; - } - /** * @param bool $percentageLocked * @return $this @@ -34,14 +29,4 @@ public function setPercentageLocked(?bool $percentageLocked): self $this->percentageLocked = $percentageLocked; return $this; } - - /** - * @param string|null $percentageLockedString - * @return $this - * @throws Exception - */ - public function setPercentageLockedFromString(?string $percentageLockedString) - { - return $this->setPercentageLocked(filter_var($percentageLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/PeriodLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/PeriodLockedField.php index 8ddfbead..c00f98d9 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/PeriodLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/PeriodLockedField.php @@ -20,11 +20,6 @@ public function getPeriodLocked(): ?bool return $this->periodLocked; } - public function getPeriodLockedToString(): ?string - { - return ($this->getPeriodLocked()) ? 'true' : 'false'; - } - /** * @param bool $periodLocked * @return $this @@ -34,14 +29,4 @@ public function setPeriodLocked(?bool $periodLocked): self $this->periodLocked = $periodLocked; return $this; } - - /** - * @param string|null $periodLockedString - * @return $this - * @throws Exception - */ - public function setPeriodLockedFromString(?string $periodLockedString) - { - return $this->setPeriodLocked(filter_var($periodLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateField.php b/src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateField.php index f5582ab6..5b10e6fd 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateField.php @@ -2,16 +2,11 @@ namespace PhpTwinfield\Fields\Dimensions\Level34\FixedAsset; -use PhpTwinfield\Exception; -use PhpTwinfield\Util; - /** * Purchase date field * Used by: FixedAssetFixedAssets * * @package PhpTwinfield\Traits - * @see Util::formatDate() - * @see Util::parseDate() */ trait PurchaseDateField { @@ -28,18 +23,6 @@ public function getPurchaseDate(): ?\DateTimeInterface return $this->purchaseDate; } - /** - * @return string|null - */ - public function getPurchaseDateToString(): ?string - { - if ($this->getPurchaseDate() != null) { - return Util::formatDate($this->getPurchaseDate()); - } else { - return null; - } - } - /** * @param \DateTimeInterface|null $purchaseDate * @return $this @@ -49,18 +32,4 @@ public function setPurchaseDate(?\DateTimeInterface $purchaseDate) $this->purchaseDate = $purchaseDate; return $this; } - - /** - * @param string|null $purchaseDateString - * @return $this - * @throws Exception - */ - public function setPurchaseDateFromString(?string $purchaseDateString) - { - if ((bool)strtotime($purchaseDateString)) { - return $this->setPurchaseDate(Util::parseDate($purchaseDateString)); - } else { - return $this->setPurchaseDate(null); - } - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateLockedField.php index 9e674ae0..e900b818 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateLockedField.php @@ -20,11 +20,6 @@ public function getPurchaseDateLocked(): ?bool return $this->purchaseDateLocked; } - public function getPurchaseDateLockedToString(): ?string - { - return ($this->getPurchaseDateLocked()) ? 'true' : 'false'; - } - /** * @param bool $purchaseDateLocked * @return $this @@ -34,14 +29,4 @@ public function setPurchaseDateLocked(?bool $purchaseDateLocked): self $this->purchaseDateLocked = $purchaseDateLocked; return $this; } - - /** - * @param string|null $purchaseDateLockedString - * @return $this - * @throws Exception - */ - public function setPurchaseDateLockedFromString(?string $purchaseDateLockedString) - { - return $this->setPurchaseDateLocked(filter_var($purchaseDateLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/ResidualValueField.php b/src/Fields/Dimensions/Level34/FixedAsset/ResidualValueField.php index ff935bb2..0beac05f 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/ResidualValueField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/ResidualValueField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Dimensions\Level34\FixedAsset; use Money\Money; -use PhpTwinfield\Util; trait ResidualValueField { @@ -23,18 +22,6 @@ public function getResidualValue(): ?Money return $this->residualValue; } - /** - * @return float|null - */ - public function getResidualValueToFloat(): ?float - { - if ($this->getResidualValue() != null) { - return Util::formatMoney($this->getResidualValue()); - } else { - return 0; - } - } - /** * @param Money|null $residualValue * @return $this @@ -45,18 +32,4 @@ public function setResidualValue(?Money $residualValue) return $this; } - - /** - * @param float|null $residualValueFloat - * @return $this - * @throws Exception - */ - public function setResidualValueFromFloat(?float $residualValueFloat) - { - if ((float)$residualValueFloat) { - return $this->setResidualValue(Money::EUR(100 * $residualValueFloat)); - } else { - return $this->setResidualValue(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/ResidualValueLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/ResidualValueLockedField.php index 2bc7719f..dd11abb7 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/ResidualValueLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/ResidualValueLockedField.php @@ -20,11 +20,6 @@ public function getResidualValueLocked(): ?bool return $this->residualValueLocked; } - public function getResidualValueLockedToString(): ?string - { - return ($this->getResidualValueLocked()) ? 'true' : 'false'; - } - /** * @param bool $residualValueLocked * @return $this @@ -34,14 +29,4 @@ public function setResidualValueLocked(?bool $residualValueLocked): self $this->residualValueLocked = $residualValueLocked; return $this; } - - /** - * @param string|null $residualValueLockedString - * @return $this - * @throws Exception - */ - public function setResidualValueLockedFromString(?string $residualValueLockedString) - { - return $this->setResidualValueLocked(filter_var($residualValueLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/SellDateField.php b/src/Fields/Dimensions/Level34/FixedAsset/SellDateField.php index 3de24d08..a215b7c0 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/SellDateField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/SellDateField.php @@ -2,16 +2,11 @@ namespace PhpTwinfield\Fields\Dimensions\Level34\FixedAsset; -use PhpTwinfield\Exception; -use PhpTwinfield\Util; - /** * Sell date field * Used by: FixedAssetFixedAssets * * @package PhpTwinfield\Traits - * @see Util::formatDate() - * @see Util::parseDate() */ trait SellDateField { @@ -28,18 +23,6 @@ public function getSellDate(): ?\DateTimeInterface return $this->sellDate; } - /** - * @return string|null - */ - public function getSellDateToString(): ?string - { - if ($this->getSellDate() != null) { - return Util::formatDate($this->getSellDate()); - } else { - return null; - } - } - /** * @param \DateTimeInterface|null $sellDate * @return $this @@ -49,18 +32,4 @@ public function setSellDate(?\DateTimeInterface $sellDate) $this->sellDate = $sellDate; return $this; } - - /** - * @param string|null $sellDateString - * @return $this - * @throws Exception - */ - public function setSellDateFromString(?string $sellDateString) - { - if ((bool)strtotime($sellDateString)) { - return $this->setSellDate(Util::parseDate($sellDateString)); - } else { - return $this->setSellDate(null); - } - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/SellDateLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/SellDateLockedField.php index eaf131da..3edb4417 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/SellDateLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/SellDateLockedField.php @@ -20,11 +20,6 @@ public function getSellDateLocked(): ?bool return $this->sellDateLocked; } - public function getSellDateLockedToString(): ?string - { - return ($this->getSellDateLocked()) ? 'true' : 'false'; - } - /** * @param bool $sellDateLocked * @return $this @@ -34,14 +29,4 @@ public function setSellDateLocked(?bool $sellDateLocked): self $this->sellDateLocked = $sellDateLocked; return $this; } - - /** - * @param string|null $sellDateLockedString - * @return $this - * @throws Exception - */ - public function setSellDateLockedFromString(?string $sellDateLockedString) - { - return $this->setSellDateLocked(filter_var($sellDateLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/StatusField.php b/src/Fields/Dimensions/Level34/FixedAsset/StatusField.php index 1f649405..3ea16c66 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/StatusField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/StatusField.php @@ -28,14 +28,4 @@ public function setStatus(?FixedAssetsStatus $status): self $this->status = $status; return $this; } - - /** - * @param string|null $statusString - * @return $this - * @throws Exception - */ - public function setStatusFromString(?string $statusString) - { - return $this->setStatus(new FixedAssetsStatus((string)$statusString)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/StatusLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/StatusLockedField.php index 66adacf4..6f5739e1 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/StatusLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/StatusLockedField.php @@ -20,11 +20,6 @@ public function getStatusLocked(): ?bool return $this->statusLocked; } - public function getStatusLockedToString(): ?string - { - return ($this->getStatusLocked()) ? 'true' : 'false'; - } - /** * @param bool $statusLocked * @return $this @@ -34,14 +29,4 @@ public function setStatusLocked(?bool $statusLocked): self $this->statusLocked = $statusLocked; return $this; } - - /** - * @param string|null $statusLockedString - * @return $this - * @throws Exception - */ - public function setStatusLockedFromString(?string $statusLockedString) - { - return $this->setStatusLocked(filter_var($statusLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/StopValueField.php b/src/Fields/Dimensions/Level34/FixedAsset/StopValueField.php index 5d78b5bd..839368f3 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/StopValueField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/StopValueField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Dimensions\Level34\FixedAsset; use Money\Money; -use PhpTwinfield\Util; trait StopValueField { @@ -23,18 +22,6 @@ public function getStopValue(): ?Money return $this->stopValue; } - /** - * @return float|null - */ - public function getStopValueToFloat(): ?float - { - if ($this->getStopValue() != null) { - return Util::formatMoney($this->getStopValue()); - } else { - return 0; - } - } - /** * @param Money|null $stopValue * @return $this @@ -45,18 +32,4 @@ public function setStopValue(?Money $stopValue) return $this; } - - /** - * @param float|null $stopValueFloat - * @return $this - * @throws Exception - */ - public function setStopValueFromFloat(?float $stopValueFloat) - { - if ((float)$stopValueFloat) { - return $this->setStopValue(Money::EUR(100 * $stopValueFloat)); - } else { - return $this->setStopValue(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/StopValueLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/StopValueLockedField.php index 30972e2e..a3e5f779 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/StopValueLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/StopValueLockedField.php @@ -20,11 +20,6 @@ public function getStopValueLocked(): ?bool return $this->stopValueLocked; } - public function getStopValueLockedToString(): ?string - { - return ($this->getStopValueLocked()) ? 'true' : 'false'; - } - /** * @param bool $stopValueLocked * @return $this @@ -34,14 +29,4 @@ public function setStopValueLocked(?bool $stopValueLocked): self $this->stopValueLocked = $stopValueLocked; return $this; } - - /** - * @param string|null $stopValueLockedString - * @return $this - * @throws Exception - */ - public function setStopValueLockedFromString(?string $stopValueLockedString) - { - return $this->setStopValueLocked(filter_var($stopValueLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/FixedAsset/TransactionLinesLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/TransactionLinesLockedField.php index cee0d7f0..e2ae86be 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/TransactionLinesLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/TransactionLinesLockedField.php @@ -20,11 +20,6 @@ public function getTransactionLinesLocked(): ?bool return $this->transactionLinesLocked; } - public function getTransactionLinesLockedToString(): ?string - { - return ($this->getTransactionLinesLocked()) ? 'true' : 'false'; - } - /** * @param bool $transactionLinesLocked * @return $this @@ -34,14 +29,4 @@ public function setTransactionLinesLocked(?bool $transactionLinesLocked): self $this->transactionLinesLocked = $transactionLinesLocked; return $this; } - - /** - * @param string|null $transactionLinesLockedString - * @return $this - * @throws Exception - */ - public function setTransactionLinesLockedFromString(?string $transactionLinesLockedString) - { - return $this->setTransactionLinesLocked(filter_var($transactionLinesLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/MandatoryField.php b/src/Fields/Dimensions/Level34/MandatoryField.php index 42c13032..02117d04 100644 --- a/src/Fields/Dimensions/Level34/MandatoryField.php +++ b/src/Fields/Dimensions/Level34/MandatoryField.php @@ -20,11 +20,6 @@ public function getMandatory(): ?bool return $this->mandatory; } - public function getMandatoryToString(): ?string - { - return ($this->getMandatory()) ? 'true' : 'false'; - } - /** * @param bool $mandatory * @return $this @@ -34,14 +29,4 @@ public function setMandatory(?bool $mandatory): self $this->mandatory = $mandatory; return $this; } - - /** - * @param string|null $mandatoryString - * @return $this - * @throws Exception - */ - public function setMandatoryFromString(?string $mandatoryString) - { - return $this->setMandatory(filter_var($mandatoryString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/RateInheritField.php b/src/Fields/Dimensions/Level34/RateInheritField.php index 8cd538c2..a1ce65e3 100644 --- a/src/Fields/Dimensions/Level34/RateInheritField.php +++ b/src/Fields/Dimensions/Level34/RateInheritField.php @@ -34,14 +34,4 @@ public function setRateInherit(?bool $rateInherit): self $this->rateInherit = $rateInherit; return $this; } - - /** - * @param string|null $rateInheritString - * @return $this - * @throws Exception - */ - public function setRateInheritFromString(?string $rateInheritString) - { - return $this->setRateInherit(filter_var($rateInheritString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/RateLockedField.php b/src/Fields/Dimensions/Level34/RateLockedField.php index 5926ccfa..78ab4832 100644 --- a/src/Fields/Dimensions/Level34/RateLockedField.php +++ b/src/Fields/Dimensions/Level34/RateLockedField.php @@ -34,14 +34,4 @@ public function setRateLocked(?bool $rateLocked): self $this->rateLocked = $rateLocked; return $this; } - - /** - * @param string|null $rateLockedString - * @return $this - * @throws Exception - */ - public function setRateLockedFromString(?string $rateLockedString) - { - return $this->setRateLocked(filter_var($rateLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/ValidFromField.php b/src/Fields/Dimensions/Level34/ValidFromField.php index c143d7fc..f971670e 100644 --- a/src/Fields/Dimensions/Level34/ValidFromField.php +++ b/src/Fields/Dimensions/Level34/ValidFromField.php @@ -2,16 +2,11 @@ namespace PhpTwinfield\Fields\Dimensions\Level34; -use PhpTwinfield\Exception; -use PhpTwinfield\Util; - /** * Valid from field * Used by: ActivityProjects, ProjectProjects * * @package PhpTwinfield\Traits - * @see Util::formatDate() - * @see Util::parseDate() */ trait ValidFromField { @@ -28,18 +23,6 @@ public function getValidFrom(): ?\DateTimeInterface return $this->validFrom; } - /** - * @return string|null - */ - public function getValidFromToString(): ?string - { - if ($this->getValidFrom() != null) { - return Util::formatDate($this->getValidFrom()); - } else { - return null; - } - } - /** * @param \DateTimeInterface|null $validFrom * @return $this @@ -49,18 +32,4 @@ public function setValidFrom(?\DateTimeInterface $validFrom) $this->validFrom = $validFrom; return $this; } - - /** - * @param string|null $validFromString - * @return $this - * @throws Exception - */ - public function setValidFromFromString(?string $validFromString) - { - if ((bool)strtotime($validFromString)) { - return $this->setValidFrom(Util::parseDate($validFromString)); - } else { - return $this->setValidFrom(null); - } - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/Level34/ValidTillField.php b/src/Fields/Dimensions/Level34/ValidTillField.php index f2114aa9..f81452c1 100644 --- a/src/Fields/Dimensions/Level34/ValidTillField.php +++ b/src/Fields/Dimensions/Level34/ValidTillField.php @@ -2,16 +2,11 @@ namespace PhpTwinfield\Fields\Dimensions\Level34; -use PhpTwinfield\Exception; -use PhpTwinfield\Util; - /** * Valid till field * Used by: ActivityProjects, ProjectProjects * * @package PhpTwinfield\Traits - * @see Util::formatDate() - * @see Util::parseDate() */ trait ValidTillField { @@ -28,18 +23,6 @@ public function getValidTill(): ?\DateTimeInterface return $this->validTill; } - /** - * @return string|null - */ - public function getValidTillToString(): ?string - { - if ($this->getValidTill() != null) { - return Util::formatDate($this->getValidTill()); - } else { - return null; - } - } - /** * @param \DateTimeInterface|null $validTill * @return $this @@ -49,18 +32,4 @@ public function setValidTill(?\DateTimeInterface $validTill) $this->validTill = $validTill; return $this; } - - /** - * @param string|null $validTillString - * @return $this - * @throws Exception - */ - public function setValidTillFromString(?string $validTillString) - { - if ((bool)strtotime($validTillString)) { - return $this->setValidTill(Util::parseDate($validTillString)); - } else { - return $this->setValidTill(null); - } - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/MatchTypeField.php b/src/Fields/Dimensions/MatchTypeField.php index 1c2c91c4..22d1c8d2 100644 --- a/src/Fields/Dimensions/MatchTypeField.php +++ b/src/Fields/Dimensions/MatchTypeField.php @@ -28,14 +28,4 @@ public function setMatchType(?MatchType $matchType): self $this->matchType = $matchType; return $this; } - - /** - * @param string|null $matchTypeString - * @return $this - * @throws Exception - */ - public function setMatchTypeFromString(?string $matchTypeString) - { - return $this->setMatchType(new MatchType((string)$matchTypeString)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/SubAnalyseField.php b/src/Fields/Dimensions/SubAnalyseField.php index 213203e6..994382ff 100644 --- a/src/Fields/Dimensions/SubAnalyseField.php +++ b/src/Fields/Dimensions/SubAnalyseField.php @@ -28,14 +28,4 @@ public function setSubAnalyse(?SubAnalyse $subAnalyse): self $this->subAnalyse = $subAnalyse; return $this; } - - /** - * @param string|null $subAnalyseString - * @return $this - * @throws Exception - */ - public function setSubAnalyseFromString(?string $subAnalyseString) - { - return $this->setSubAnalyse(new SubAnalyse((string)$subAnalyseString)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/SubstituteWithField.php b/src/Fields/Dimensions/SubstituteWithField.php index 34b83f0d..7850b4c2 100644 --- a/src/Fields/Dimensions/SubstituteWithField.php +++ b/src/Fields/Dimensions/SubstituteWithField.php @@ -2,8 +2,6 @@ namespace PhpTwinfield\Fields\Dimensions; -use PhpTwinfield\Dummy; - /** * The dimension * Used by: CustomerFinancials, FixedAssetFinancials, SupplierFinancials @@ -22,15 +20,6 @@ public function getSubstituteWith() return $this->substituteWith; } - public function getSubstituteWithToString(): ?string - { - if ($this->getSubstituteWith() != null) { - return $this->substituteWith->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +28,4 @@ public function setSubstituteWith($substituteWith): self $this->substituteWith = $substituteWith; return $this; } - - /** - * @param string|null $substituteWithString - * @return $this - * @throws Exception - */ - public function setSubstituteWithFromString(?string $substituteWithString) - { - $substituteWith = new Dummy(); - $substituteWith->setCode($substituteWithString); - return $this->setSubstituteWith($substituteWith); - } } diff --git a/src/Fields/Dimensions/TypeField.php b/src/Fields/Dimensions/TypeField.php index 2bf3e5d7..648c80ae 100644 --- a/src/Fields/Dimensions/TypeField.php +++ b/src/Fields/Dimensions/TypeField.php @@ -28,14 +28,4 @@ public function setType(?ChildValidationType $type): self $this->type = $type; return $this; } - - /** - * @param string|null $typeString - * @return $this - * @throws Exception - */ - public function setTypeFromString(?string $typeString) - { - return $this->setType(new ChildValidationType((string)$typeString)); - } } \ No newline at end of file diff --git a/src/Fields/Dimensions/VatCodeFixedField.php b/src/Fields/Dimensions/VatCodeFixedField.php index 060a4403..7282343c 100644 --- a/src/Fields/Dimensions/VatCodeFixedField.php +++ b/src/Fields/Dimensions/VatCodeFixedField.php @@ -20,11 +20,6 @@ public function getVatCodeFixed(): ?bool return $this->vatCodeFixed; } - public function getVatCodeFixedToString(): ?string - { - return ($this->getVatCodeFixed()) ? 'true' : 'false'; - } - /** * @param bool $vatCodeFixed * @return $this @@ -34,14 +29,4 @@ public function setVatCodeFixed(?bool $vatCodeFixed): self $this->vatCodeFixed = $vatCodeFixed; return $this; } - - /** - * @param string|null $vatCodeFixedString - * @return $this - * @throws Exception - */ - public function setVatCodeFixedFromString(?string $vatCodeFixedString) - { - return $this->setVatCodeFixed(filter_var($vatCodeFixedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/DueDateField.php b/src/Fields/DueDateField.php index 06e4b2a2..c5201eba 100644 --- a/src/Fields/DueDateField.php +++ b/src/Fields/DueDateField.php @@ -2,16 +2,11 @@ namespace PhpTwinfield\Fields; -use PhpTwinfield\Exception; -use PhpTwinfield\Util; - /** * Due date field * Used by: Invoice, PurchaseTransaction, SalesTransaction * * @package PhpTwinfield\Traits - * @see Util::formatDate() - * @see Util::parseDate() */ trait DueDateField { @@ -28,18 +23,6 @@ public function getDueDate(): ?\DateTimeInterface return $this->dueDate; } - /** - * @return string|null - */ - public function getDueDateToString(): ?string - { - if ($this->getDueDate() != null) { - return Util::formatDate($this->getDueDate()); - } else { - return null; - } - } - /** * @param \DateTimeInterface|null $dueDate * @return $this @@ -49,18 +32,4 @@ public function setDueDate(?\DateTimeInterface $dueDate) $this->dueDate = $dueDate; return $this; } - - /** - * @param string|null $dueDateString - * @return $this - * @throws Exception - */ - public function setDueDateFromString(?string $dueDateString) - { - if ((bool)strtotime($dueDateString)) { - return $this->setDueDate(Util::parseDate($dueDateString)); - } else { - return $this->setDueDate(null); - } - } } \ No newline at end of file diff --git a/src/Fields/InUseField.php b/src/Fields/InUseField.php index 01c0da93..1654fc14 100644 --- a/src/Fields/InUseField.php +++ b/src/Fields/InUseField.php @@ -20,11 +20,6 @@ public function getInUse(): ?bool return $this->inUse; } - public function getInUseToString(): ?string - { - return ($this->getInUse()) ? 'true' : 'false'; - } - /** * @param bool $inUse * @return $this @@ -34,14 +29,4 @@ public function setInUse(?bool $inUse): self $this->inUse = $inUse; return $this; } - - /** - * @param string|null $inUseString - * @return $this - * @throws Exception - */ - public function setInUseFromString(?string $inUseString) - { - return $this->setInUse(filter_var($inUseString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Invoice/AllowDiscountOrPremiumField.php b/src/Fields/Invoice/AllowDiscountOrPremiumField.php index 54aabe65..fc8eea09 100644 --- a/src/Fields/Invoice/AllowDiscountOrPremiumField.php +++ b/src/Fields/Invoice/AllowDiscountOrPremiumField.php @@ -19,12 +19,7 @@ public function getAllowDiscountOrPremium(): ?bool { return $this->allowDiscountOrPremium; } - - public function getAllowDiscountOrPremiumToString(): ?string - { - return ($this->getAllowDiscountOrPremium()) ? 'true' : 'false'; - } - + /** * @param bool $allowDiscountOrPremium * @return $this @@ -34,14 +29,4 @@ public function setAllowDiscountOrPremium(?bool $allowDiscountOrPremium): self $this->allowDiscountOrPremium = $allowDiscountOrPremium; return $this; } - - /** - * @param string|null $allowDiscountOrPremiumString - * @return $this - * @throws Exception - */ - public function setAllowDiscountOrPremiumFromString(?string $allowDiscountOrPremiumString) - { - return $this->setAllowDiscountOrPremium(filter_var($allowDiscountOrPremiumString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Invoice/Article/AllowChangePerformanceTypeField.php b/src/Fields/Invoice/Article/AllowChangePerformanceTypeField.php index bdc10c2e..7ac1b0c2 100644 --- a/src/Fields/Invoice/Article/AllowChangePerformanceTypeField.php +++ b/src/Fields/Invoice/Article/AllowChangePerformanceTypeField.php @@ -20,11 +20,6 @@ public function getAllowChangePerformanceType(): ?bool return $this->allowChangePerformanceType; } - public function getAllowChangePerformanceTypeToString(): ?string - { - return ($this->getAllowChangePerformanceType()) ? 'true' : 'false'; - } - /** * @param bool $allowChangePerformanceType * @return $this @@ -34,14 +29,4 @@ public function setAllowChangePerformanceType(?bool $allowChangePerformanceType) $this->allowChangePerformanceType = $allowChangePerformanceType; return $this; } - - /** - * @param string|null $allowChangePerformanceTypeString - * @return $this - * @throws Exception - */ - public function setAllowChangePerformanceTypeFromString(?string $allowChangePerformanceTypeString) - { - return $this->setAllowChangePerformanceType(filter_var($allowChangePerformanceTypeString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Invoice/Article/AllowChangeUnitsPriceField.php b/src/Fields/Invoice/Article/AllowChangeUnitsPriceField.php index c8c51909..4b53502e 100644 --- a/src/Fields/Invoice/Article/AllowChangeUnitsPriceField.php +++ b/src/Fields/Invoice/Article/AllowChangeUnitsPriceField.php @@ -19,12 +19,7 @@ public function getAllowChangeUnitsPrice(): ?bool { return $this->allowChangeUnitsPrice; } - - public function getAllowChangeUnitsPriceToString(): ?string - { - return ($this->getAllowChangeUnitsPrice()) ? 'true' : 'false'; - } - + /** * @param bool $allowChangeUnitsPrice * @return $this @@ -34,14 +29,4 @@ public function setAllowChangeUnitsPrice(?bool $allowChangeUnitsPrice): self $this->allowChangeUnitsPrice = $allowChangeUnitsPrice; return $this; } - - /** - * @param string|null $allowChangeUnitsPriceString - * @return $this - * @throws Exception - */ - public function setAllowChangeUnitsPriceFromString(?string $allowChangeUnitsPriceString) - { - return $this->setAllowChangeUnitsPrice(filter_var($allowChangeUnitsPriceString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Invoice/Article/AllowChangeVatCodeField.php b/src/Fields/Invoice/Article/AllowChangeVatCodeField.php index fde5bb6f..5f821b4b 100644 --- a/src/Fields/Invoice/Article/AllowChangeVatCodeField.php +++ b/src/Fields/Invoice/Article/AllowChangeVatCodeField.php @@ -20,11 +20,6 @@ public function getAllowChangeVatCode(): ?bool return $this->allowChangeVatCode; } - public function getAllowChangeVatCodeToString(): ?string - { - return ($this->getAllowChangeVatCode()) ? 'true' : 'false'; - } - /** * @param bool $allowChangeVatCode * @return $this @@ -34,14 +29,4 @@ public function setAllowChangeVatCode(?bool $allowChangeVatCode): self $this->allowChangeVatCode = $allowChangeVatCode; return $this; } - - /** - * @param string|null $allowChangeVatCodeString - * @return $this - * @throws Exception - */ - public function setAllowChangeVatCodeFromString(?string $allowChangeVatCodeString) - { - return $this->setAllowChangeVatCode(filter_var($allowChangeVatCodeString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Invoice/Article/AllowDecimalQuantityField.php b/src/Fields/Invoice/Article/AllowDecimalQuantityField.php index 1ba81b39..206603fa 100644 --- a/src/Fields/Invoice/Article/AllowDecimalQuantityField.php +++ b/src/Fields/Invoice/Article/AllowDecimalQuantityField.php @@ -19,12 +19,7 @@ public function getAllowDecimalQuantity(): ?bool { return $this->allowDecimalQuantity; } - - public function getAllowDecimalQuantityToString(): ?string - { - return ($this->getAllowDecimalQuantity()) ? 'true' : 'false'; - } - + /** * @param bool $allowDecimalQuantity * @return $this @@ -34,14 +29,4 @@ public function setAllowDecimalQuantity(?bool $allowDecimalQuantity): self $this->allowDecimalQuantity = $allowDecimalQuantity; return $this; } - - /** - * @param string|null $allowDecimalQuantityString - * @return $this - * @throws Exception - */ - public function setAllowDecimalQuantityFromString(?string $allowDecimalQuantityString) - { - return $this->setAllowDecimalQuantity(filter_var($allowDecimalQuantityString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Invoice/Article/FreeText1Field.php b/src/Fields/Invoice/Article/FreeText1Field.php index 8782820c..dea64806 100644 --- a/src/Fields/Invoice/Article/FreeText1Field.php +++ b/src/Fields/Invoice/Article/FreeText1Field.php @@ -22,15 +22,6 @@ public function getFreeText1(): ?GeneralLedger return $this->freeText1; } - public function getFreeText1ToString(): ?string - { - if ($this->getFreeText1() != null) { - return $this->freeText1->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setFreeText1(?GeneralLedger $freeText1): self $this->freeText1 = $freeText1; return $this; } - - /** - * @param string|null $freeText1String - * @return $this - * @throws Exception - */ - public function setFreeText1FromString(?string $freeText1String) - { - $freeText1 = new GeneralLedger(); - $freeText1->setCode($freeText1String); - return $this->setFreeText1($freeText1); - } } diff --git a/src/Fields/Invoice/Article/FreeText2Field.php b/src/Fields/Invoice/Article/FreeText2Field.php index 33f78aea..a7189bef 100644 --- a/src/Fields/Invoice/Article/FreeText2Field.php +++ b/src/Fields/Invoice/Article/FreeText2Field.php @@ -22,15 +22,6 @@ public function getFreeText2(): ?CostCenter return $this->freeText2; } - public function getFreeText2ToString(): ?string - { - if ($this->getFreeText2() != null) { - return $this->freeText2->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setFreeText2(?CostCenter $freeText2): self $this->freeText2 = $freeText2; return $this; } - - /** - * @param string|null $freeText2String - * @return $this - * @throws Exception - */ - public function setFreeText2FromString(?string $freeText2String) - { - $freeText2 = new CostCenter(); - $freeText2->setCode($freeText2String); - return $this->setFreeText2($freeText2); - } } diff --git a/src/Fields/Invoice/Article/PercentageField.php b/src/Fields/Invoice/Article/PercentageField.php index 272de3c8..e8467321 100644 --- a/src/Fields/Invoice/Article/PercentageField.php +++ b/src/Fields/Invoice/Article/PercentageField.php @@ -20,11 +20,6 @@ public function getPercentage(): ?bool return $this->percentage; } - public function getPercentageToString(): ?string - { - return ($this->getPercentage()) ? 'true' : 'false'; - } - /** * @param bool $percentage * @return $this @@ -34,14 +29,4 @@ public function setPercentage(?bool $percentage): self $this->percentage = $percentage; return $this; } - - /** - * @param string|null $percentageString - * @return $this - * @throws Exception - */ - public function setPercentageFromString(?string $percentageString) - { - return $this->setPercentage(filter_var($percentageString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Invoice/Article/TypeField.php b/src/Fields/Invoice/Article/TypeField.php index cbfb6b4f..8136551e 100644 --- a/src/Fields/Invoice/Article/TypeField.php +++ b/src/Fields/Invoice/Article/TypeField.php @@ -28,14 +28,4 @@ public function setType(?ArticleType $type): self $this->type = $type; return $this; } - - /** - * @param string|null $typeString - * @return $this - * @throws Exception - */ - public function setTypeFromString(?string $typeString) - { - return $this->setType(new ArticleType((string)$typeString)); - } } \ No newline at end of file diff --git a/src/Fields/Invoice/ArticleField.php b/src/Fields/Invoice/ArticleField.php index 19b12227..f412b76c 100644 --- a/src/Fields/Invoice/ArticleField.php +++ b/src/Fields/Invoice/ArticleField.php @@ -22,15 +22,6 @@ public function getArticle(): ?Article return $this->article; } - public function getArticleToString(): ?string - { - if ($this->getArticle() != null) { - return $this->article->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setArticle(?Article $article): self $this->article = $article; return $this; } - - /** - * @param string|null $articleString - * @return $this - * @throws Exception - */ - public function setArticleFromString(?string $articleString) - { - $article = new Article(); - $article->setCode($articleString); - return $this->setArticle($article); - } } diff --git a/src/Fields/Invoice/BankField.php b/src/Fields/Invoice/BankField.php index c22211d8..27189d2e 100644 --- a/src/Fields/Invoice/BankField.php +++ b/src/Fields/Invoice/BankField.php @@ -22,15 +22,6 @@ public function getBank(): ?CashBankBook return $this->bank; } - public function getBankToString(): ?string - { - if ($this->getBank() != null) { - return $this->bank->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setBank(?CashBankBook $bank): self $this->bank = $bank; return $this; } - - /** - * @param string|null $bankString - * @return $this - * @throws Exception - */ - public function setBankFromString(?string $bankString) - { - $bank = new CashBankBook(); - $bank->setCode($bankString); - return $this->setBank($bank); - } } diff --git a/src/Fields/Invoice/CalculateOnlyField.php b/src/Fields/Invoice/CalculateOnlyField.php index b1f44fb0..db36dcc4 100644 --- a/src/Fields/Invoice/CalculateOnlyField.php +++ b/src/Fields/Invoice/CalculateOnlyField.php @@ -20,11 +20,6 @@ public function getCalculateOnly(): ?bool return $this->calculateOnly; } - public function getCalculateOnlyToString(): ?string - { - return ($this->getCalculateOnly()) ? 'true' : 'false'; - } - /** * @param bool $calculateOnly * @return $this @@ -34,14 +29,4 @@ public function setCalculateOnly(?bool $calculateOnly): self $this->calculateOnly = $calculateOnly; return $this; } - - /** - * @param string|null $calculateOnlyString - * @return $this - * @throws Exception - */ - public function setCalculateOnlyFromString(?string $calculateOnlyString) - { - return $this->setCalculateOnly(filter_var($calculateOnlyString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Invoice/InvoiceAmountField.php b/src/Fields/Invoice/InvoiceAmountField.php index 41900a92..c09e9a77 100644 --- a/src/Fields/Invoice/InvoiceAmountField.php +++ b/src/Fields/Invoice/InvoiceAmountField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Invoice; use Money\Money; -use PhpTwinfield\Util; trait InvoiceAmountField { @@ -23,18 +22,6 @@ public function getInvoiceAmount(): ?Money return $this->invoiceAmount; } - /** - * @return float|null - */ - public function getInvoiceAmountToFloat(): ?float - { - if ($this->getInvoiceAmount() != null) { - return Util::formatMoney($this->getInvoiceAmount()); - } else { - return 0; - } - } - /** * @param Money|null $invoiceAmount * @return $this @@ -45,18 +32,4 @@ public function setInvoiceAmount(?Money $invoiceAmount) return $this; } - - /** - * @param float|null $invoiceAmountFloat - * @return $this - * @throws Exception - */ - public function setInvoiceAmountFromFloat(?float $invoiceAmountFloat) - { - if ((float)$invoiceAmountFloat) { - return $this->setInvoiceAmount(Money::EUR(100 * $invoiceAmountFloat)); - } else { - return $this->setInvoiceAmount(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Invoice/InvoiceDateField.php b/src/Fields/Invoice/InvoiceDateField.php index 03a4b03f..a53474cd 100644 --- a/src/Fields/Invoice/InvoiceDateField.php +++ b/src/Fields/Invoice/InvoiceDateField.php @@ -2,16 +2,11 @@ namespace PhpTwinfield\Fields\Invoice; -use PhpTwinfield\Exception; -use PhpTwinfield\Util; - /** * Invoice date field * Used by: Invoice * * @package PhpTwinfield\Traits - * @see Util::formatDate() - * @see Util::parseDate() */ trait InvoiceDateField { @@ -28,18 +23,6 @@ public function getInvoiceDate(): ?\DateTimeInterface return $this->invoiceDate; } - /** - * @return string|null - */ - public function getInvoiceDateToString(): ?string - { - if ($this->getInvoiceDate() != null) { - return Util::formatDate($this->getInvoiceDate()); - } else { - return null; - } - } - /** * @param \DateTimeInterface|null $invoiceDate * @return $this @@ -49,18 +32,4 @@ public function setInvoiceDate(?\DateTimeInterface $invoiceDate) $this->invoiceDate = $invoiceDate; return $this; } - - /** - * @param string|null $invoiceDateString - * @return $this - * @throws Exception - */ - public function setInvoiceDateFromString(?string $invoiceDateString) - { - if ((bool)strtotime($invoiceDateString)) { - return $this->setInvoiceDate(Util::parseDate($invoiceDateString)); - } else { - return $this->setInvoiceDate(null); - } - } } \ No newline at end of file diff --git a/src/Fields/Invoice/InvoiceTypeField.php b/src/Fields/Invoice/InvoiceTypeField.php index 2ec57a37..a0d8b089 100644 --- a/src/Fields/Invoice/InvoiceTypeField.php +++ b/src/Fields/Invoice/InvoiceTypeField.php @@ -22,15 +22,6 @@ public function getInvoiceType(): ?InvoiceType return $this->invoiceType; } - public function getInvoiceTypeToString(): ?string - { - if ($this->getInvoiceType() != null) { - return $this->invoiceType->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setInvoiceType(?InvoiceType $invoiceType): self $this->invoiceType = $invoiceType; return $this; } - - /** - * @param string|null $invoiceTypeString - * @return $this - * @throws Exception - */ - public function setInvoiceTypeFromString(?string $invoiceTypeString) - { - $invoiceType = new InvoiceType(); - $invoiceType->setCode($invoiceTypeString); - return $this->setInvoiceType($invoiceType); - } } diff --git a/src/Fields/Invoice/PaymentMethodField.php b/src/Fields/Invoice/PaymentMethodField.php index 565924df..62e3e467 100644 --- a/src/Fields/Invoice/PaymentMethodField.php +++ b/src/Fields/Invoice/PaymentMethodField.php @@ -28,14 +28,4 @@ public function setPaymentMethod(?PaymentMethod $paymentMethod): self $this->paymentMethod = $paymentMethod; return $this; } - - /** - * @param string|null $paymentMethodString - * @return $this - * @throws Exception - */ - public function setPaymentMethodFromString(?string $paymentMethodString) - { - return $this->setPaymentMethod(new PaymentMethod((string)$paymentMethodString)); - } } \ No newline at end of file diff --git a/src/Fields/Invoice/PeriodRaiseWarningField.php b/src/Fields/Invoice/PeriodRaiseWarningField.php index 732a9e6b..650fccc8 100644 --- a/src/Fields/Invoice/PeriodRaiseWarningField.php +++ b/src/Fields/Invoice/PeriodRaiseWarningField.php @@ -19,12 +19,7 @@ public function getPeriodRaiseWarning(): ?bool { return $this->periodRaiseWarning; } - - public function getPeriodRaiseWarningToString(): ?string - { - return ($this->getPeriodRaiseWarning()) ? 'true' : 'false'; - } - + /** * @param bool $periodRaiseWarning * @return $this @@ -34,14 +29,4 @@ public function setPeriodRaiseWarning(?bool $periodRaiseWarning): self $this->periodRaiseWarning = $periodRaiseWarning; return $this; } - - /** - * @param string|null $periodRaiseWarningString - * @return $this - * @throws Exception - */ - public function setPeriodRaiseWarningFromString(?string $periodRaiseWarningString) - { - return $this->setPeriodRaiseWarning(filter_var($periodRaiseWarningString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Invoice/RaiseWarningField.php b/src/Fields/Invoice/RaiseWarningField.php index 993aef3c..0206349d 100644 --- a/src/Fields/Invoice/RaiseWarningField.php +++ b/src/Fields/Invoice/RaiseWarningField.php @@ -20,11 +20,6 @@ public function getRaiseWarning(): ?bool return $this->raiseWarning; } - public function getRaiseWarningToString(): ?string - { - return ($this->getRaiseWarning()) ? 'true' : 'false'; - } - /** * @param bool $raiseWarning * @return $this @@ -34,14 +29,4 @@ public function setRaiseWarning(?bool $raiseWarning): self $this->raiseWarning = $raiseWarning; return $this; } - - /** - * @param string|null $raiseWarningString - * @return $this - * @throws Exception - */ - public function setRaiseWarningFromString(?string $raiseWarningString) - { - return $this->setRaiseWarning(filter_var($raiseWarningString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Invoice/StatusField.php b/src/Fields/Invoice/StatusField.php index 55f935c1..ccc2fc82 100644 --- a/src/Fields/Invoice/StatusField.php +++ b/src/Fields/Invoice/StatusField.php @@ -28,14 +28,4 @@ public function setStatus(?InvoiceStatus $status): self $this->status = $status; return $this; } - - /** - * @param string|null $statusString - * @return $this - * @throws Exception - */ - public function setStatusFromString(?string $statusString) - { - return $this->setStatus(new InvoiceStatus((string)$statusString)); - } } \ No newline at end of file diff --git a/src/Fields/Invoice/SubArticleField.php b/src/Fields/Invoice/SubArticleField.php index e0c1986a..1fa9ab5a 100644 --- a/src/Fields/Invoice/SubArticleField.php +++ b/src/Fields/Invoice/SubArticleField.php @@ -39,16 +39,4 @@ public function setSubArticle(?ArticleLine $subArticle): self $this->subArticle = $subArticle; return $this; } - - /** - * @param string|null $subArticleString - * @return $this - * @throws Exception - */ - public function setSubArticleFromString(?string $subArticleString) - { - $subArticle = new ArticleLine(); - $subArticle->setSubCode($subArticleString); - return $this->setSubArticle($subArticle); - } } diff --git a/src/Fields/Invoice/UnitsPriceExclField.php b/src/Fields/Invoice/UnitsPriceExclField.php index 88859b69..860b5c60 100644 --- a/src/Fields/Invoice/UnitsPriceExclField.php +++ b/src/Fields/Invoice/UnitsPriceExclField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Invoice; use Money\Money; -use PhpTwinfield\Util; trait UnitsPriceExclField { @@ -22,19 +21,7 @@ public function getUnitsPriceExcl(): ?Money { return $this->unitsPriceExcl; } - - /** - * @return float|null - */ - public function getUnitsPriceExclToFloat(): ?float - { - if ($this->getUnitsPriceExcl() != null) { - return Util::formatMoney($this->getUnitsPriceExcl()); - } else { - return 0; - } - } - + /** * @param Money|null $unitsPriceExcl * @return $this @@ -45,18 +32,4 @@ public function setUnitsPriceExcl(?Money $unitsPriceExcl) return $this; } - - /** - * @param float|null $unitsPriceExclFloat - * @return $this - * @throws Exception - */ - public function setUnitsPriceExclFromFloat(?float $unitsPriceExclFloat) - { - if ((float)$unitsPriceExclFloat) { - return $this->setUnitsPriceExcl(Money::EUR(100 * $unitsPriceExclFloat)); - } else { - return $this->setUnitsPriceExcl(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Invoice/UnitsPriceIncField.php b/src/Fields/Invoice/UnitsPriceIncField.php index 0e6268f3..04aabd62 100644 --- a/src/Fields/Invoice/UnitsPriceIncField.php +++ b/src/Fields/Invoice/UnitsPriceIncField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Invoice; use Money\Money; -use PhpTwinfield\Util; trait UnitsPriceIncField { @@ -23,18 +22,6 @@ public function getUnitsPriceInc(): ?Money return $this->unitsPriceInc; } - /** - * @return float|null - */ - public function getUnitsPriceIncToFloat(): ?float - { - if ($this->getUnitsPriceInc() != null) { - return Util::formatMoney($this->getUnitsPriceInc()); - } else { - return 0; - } - } - /** * @param Money|null $unitsPriceInc * @return $this @@ -45,18 +32,4 @@ public function setUnitsPriceInc(?Money $unitsPriceInc) return $this; } - - /** - * @param float|null $unitsPriceIncFloat - * @return $this - * @throws Exception - */ - public function setUnitsPriceIncFromFloat(?float $unitsPriceIncFloat) - { - if ((float)$unitsPriceIncFloat) { - return $this->setUnitsPriceInc(Money::EUR(100 * $unitsPriceIncFloat)); - } else { - return $this->setUnitsPriceInc(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Invoice/ValueExclField.php b/src/Fields/Invoice/ValueExclField.php index d4fb1fac..a4694254 100644 --- a/src/Fields/Invoice/ValueExclField.php +++ b/src/Fields/Invoice/ValueExclField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Invoice; use Money\Money; -use PhpTwinfield\Util; trait ValueExclField { @@ -23,18 +22,6 @@ public function getValueExcl(): ?Money return $this->valueExcl; } - /** - * @return float|null - */ - public function getValueExclToFloat(): ?float - { - if ($this->getValueExcl() != null) { - return Util::formatMoney($this->getValueExcl()); - } else { - return 0; - } - } - /** * @param Money|null $valueExcl * @return $this @@ -45,18 +32,4 @@ public function setValueExcl(?Money $valueExcl) return $this; } - - /** - * @param float|null $valueExclFloat - * @return $this - * @throws Exception - */ - public function setValueExclFromFloat(?float $valueExclFloat) - { - if ((float)$valueExclFloat) { - return $this->setValueExcl(Money::EUR(100 * $valueExclFloat)); - } else { - return $this->setValueExcl(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Invoice/ValueIncField.php b/src/Fields/Invoice/ValueIncField.php index 80b2e210..f8ef58d3 100644 --- a/src/Fields/Invoice/ValueIncField.php +++ b/src/Fields/Invoice/ValueIncField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Invoice; use Money\Money; -use PhpTwinfield\Util; trait ValueIncField { @@ -23,18 +22,6 @@ public function getValueInc(): ?Money return $this->valueInc; } - /** - * @return float|null - */ - public function getValueIncToFloat(): ?float - { - if ($this->getValueInc() != null) { - return Util::formatMoney($this->getValueInc()); - } else { - return 0; - } - } - /** * @param Money|null $valueInc * @return $this @@ -45,18 +32,4 @@ public function setValueInc(?Money $valueInc) return $this; } - - /** - * @param float|null $valueIncFloat - * @return $this - * @throws Exception - */ - public function setValueIncFromFloat(?float $valueIncFloat) - { - if ((float)$valueIncFloat) { - return $this->setValueInc(Money::EUR(100 * $valueIncFloat)); - } else { - return $this->setValueInc(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/LineTypeField.php b/src/Fields/LineTypeField.php index d2244307..8ae87b39 100644 --- a/src/Fields/LineTypeField.php +++ b/src/Fields/LineTypeField.php @@ -28,14 +28,4 @@ public function setLineType(?LineType $lineType): self $this->lineType = $lineType; return $this; } - - /** - * @param string|null $lineTypeString - * @return $this - * @throws Exception - */ - public function setLineTypeFromString(?string $lineTypeString) - { - return $this->setLineType(new LineType((string)$lineTypeString)); - } } \ No newline at end of file diff --git a/src/Fields/ModifiedField.php b/src/Fields/ModifiedField.php index c66a09c7..00042d7c 100644 --- a/src/Fields/ModifiedField.php +++ b/src/Fields/ModifiedField.php @@ -2,16 +2,11 @@ namespace PhpTwinfield\Fields; -use PhpTwinfield\Exception; -use PhpTwinfield\Util; - /** * Modified field * Used by: AssetMethod, Office, Rate, User, VatCode * * @package PhpTwinfield\Traits - * @see Util::formatDateTime() - * @see Util::parseDateTime() */ trait ModifiedField { @@ -28,18 +23,6 @@ public function getModified(): ?\DateTimeInterface return $this->modified; } - /** - * @return string|null - */ - public function getModifiedToString(): ?string - { - if ($this->getModified() != null) { - return Util::formatDateTime($this->getModified()); - } else { - return null; - } - } - /** * @param \DateTimeInterface|null $modified * @return $this @@ -49,18 +32,4 @@ public function setModified(?\DateTimeInterface $modified) $this->modified = $modified; return $this; } - - /** - * @param string|null $modifiedString - * @return $this - * @throws Exception - */ - public function setModifiedFromString(?string $modifiedString) - { - if ((bool)strtotime($modifiedString)) { - return $this->setModified(Util::parseDateTime($modifiedString)); - } else { - return $this->setModified(null); - } - } } \ No newline at end of file diff --git a/src/Fields/Office/BaseCurrencyField.php b/src/Fields/Office/BaseCurrencyField.php index 5804e061..c414d222 100644 --- a/src/Fields/Office/BaseCurrencyField.php +++ b/src/Fields/Office/BaseCurrencyField.php @@ -22,15 +22,6 @@ public function getBaseCurrency(): ?Currency return $this->baseCurrency; } - public function getBaseCurrencyToString(): ?string - { - if ($this->getBaseCurrency() != null) { - return $this->baseCurrency->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setBaseCurrency(?Currency $baseCurrency): self $this->baseCurrency = $baseCurrency; return $this; } - - /** - * @param string|null $baseCurrencyString - * @return $this - * @throws Exception - */ - public function setBaseCurrencyFromString(?string $baseCurrencyString) - { - $baseCurrency = new Currency(); - $baseCurrency->setCode($baseCurrencyString); - return $this->setBaseCurrency($baseCurrency); - } } \ No newline at end of file diff --git a/src/Fields/Office/CountryCodeField.php b/src/Fields/Office/CountryCodeField.php index c6dbd581..f3d8389c 100644 --- a/src/Fields/Office/CountryCodeField.php +++ b/src/Fields/Office/CountryCodeField.php @@ -21,16 +21,7 @@ public function getCountryCode(): ?Country { return $this->countryCode; } - - public function getCountryCodeToString(): ?string - { - if ($this->getCountryCode() != null) { - return $this->countryCode->getCode(); - } else { - return null; - } - } - + /** * @return $this */ diff --git a/src/Fields/Office/ReportingCurrencyField.php b/src/Fields/Office/ReportingCurrencyField.php index c99b8215..47a7ce64 100644 --- a/src/Fields/Office/ReportingCurrencyField.php +++ b/src/Fields/Office/ReportingCurrencyField.php @@ -21,16 +21,7 @@ public function getReportingCurrency(): ?Currency { return $this->reportingCurrency; } - - public function getReportingCurrencyToString(): ?string - { - if ($this->getReportingCurrency() != null) { - return $this->reportingCurrency->getCode(); - } else { - return null; - } - } - + /** * @return $this */ @@ -39,16 +30,4 @@ public function setReportingCurrency(?Currency $reportingCurrency): self $this->reportingCurrency = $reportingCurrency; return $this; } - - /** - * @param string|null $reportingCurrencyString - * @return $this - * @throws Exception - */ - public function setReportingCurrencyFromString(?string $reportingCurrencyString) - { - $reportingCurrency = new Currency(); - $reportingCurrency->setCode($reportingCurrencyString); - return $this->setReportingCurrency($reportingCurrency); - } } \ No newline at end of file diff --git a/src/Fields/OfficeField.php b/src/Fields/OfficeField.php index 92cc1eb0..0ce3679a 100644 --- a/src/Fields/OfficeField.php +++ b/src/Fields/OfficeField.php @@ -21,15 +21,6 @@ public function getOffice(): ?Office return $this->office; } - public function getOfficeToString(): ?string - { - if ($this->getOffice() != null) { - return $this->office->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -38,16 +29,4 @@ public function setOffice(?Office $office): self $this->office = $office; return $this; } - - /** - * @param string|null $officeString - * @return $this - * @throws Exception - */ - public function setOfficeFromString(?string $officeString) - { - $office = new Office(); - $office->setCode($officeString); - return $this->setOffice($office); - } } diff --git a/src/Fields/PerformanceDateField.php b/src/Fields/PerformanceDateField.php index b6836f2f..863eb6e4 100644 --- a/src/Fields/PerformanceDateField.php +++ b/src/Fields/PerformanceDateField.php @@ -3,15 +3,12 @@ namespace PhpTwinfield\Fields; use PhpTwinfield\Exception; -use PhpTwinfield\Util; /** * Performance date field * Used by: BankTransactionLine, CashTransactionLine, Invoice, InvoiceLine, InvoiceVatLine, JournalTransactionLine, SalesTransactionLine * * @package PhpTwinfield\Traits - * @see Util::formatDate() - * @see Util::parseDate() */ trait PerformanceDateField { @@ -28,18 +25,6 @@ public function getPerformanceDate(): ?\DateTimeInterface return $this->performanceDate; } - /** - * @return string|null - */ - public function getPerformanceDateToString(): ?string - { - if ($this->getPerformanceDate() != null) { - return Util::formatDate($this->getPerformanceDate()); - } else { - return null; - } - } - /** * @param \DateTimeInterface|null $performanceDate * @return $this @@ -49,18 +34,4 @@ public function setPerformanceDate(?\DateTimeInterface $performanceDate) $this->performanceDate = $performanceDate; return $this; } - - /** - * @param string|null $performanceDateString - * @return $this - * @throws Exception - */ - public function setPerformanceDateFromString(?string $performanceDateString) - { - if ((bool)strtotime($performanceDateString)) { - return $this->setPerformanceDate(Util::parseDate($performanceDateString)); - } else { - return $this->setPerformanceDate(null); - } - } } \ No newline at end of file diff --git a/src/Fields/PerformanceTypeField.php b/src/Fields/PerformanceTypeField.php index b9c4a8c0..80cdcb18 100644 --- a/src/Fields/PerformanceTypeField.php +++ b/src/Fields/PerformanceTypeField.php @@ -28,14 +28,4 @@ public function setPerformanceType(?PerformanceType $performanceType): self $this->performanceType = $performanceType; return $this; } - - /** - * @param string|null $performanceTypeString - * @return $this - * @throws Exception - */ - public function setPerformanceTypeFromString(?string $performanceTypeString) - { - return $this->setPerformanceType(new PerformanceType((string)$performanceTypeString)); - } } \ No newline at end of file diff --git a/src/Fields/Rate/BeginDateField.php b/src/Fields/Rate/BeginDateField.php index c285bf06..7cb38ff3 100644 --- a/src/Fields/Rate/BeginDateField.php +++ b/src/Fields/Rate/BeginDateField.php @@ -2,16 +2,12 @@ namespace PhpTwinfield\Fields\Rate; -use PhpTwinfield\Exception; -use PhpTwinfield\Util; /** * Begin date field * Used by: RateRateChange * * @package PhpTwinfield\Traits - * @see Util::formatDate() - * @see Util::parseDate() */ trait BeginDateField { @@ -28,18 +24,6 @@ public function getBeginDate(): ?\DateTimeInterface return $this->beginDate; } - /** - * @return string|null - */ - public function getBeginDateToString(): ?string - { - if ($this->getBeginDate() != null) { - return Util::formatDate($this->getBeginDate()); - } else { - return null; - } - } - /** * @param \DateTimeInterface|null $beginDate * @return $this @@ -49,18 +33,4 @@ public function setBeginDate(?\DateTimeInterface $beginDate) $this->beginDate = $beginDate; return $this; } - - /** - * @param string|null $beginDateString - * @return $this - * @throws Exception - */ - public function setBeginDateFromString(?string $beginDateString) - { - if ((bool)strtotime($beginDateString)) { - return $this->setBeginDate(Util::parseDate($beginDateString)); - } else { - return $this->setBeginDate(null); - } - } } \ No newline at end of file diff --git a/src/Fields/Rate/EndDateField.php b/src/Fields/Rate/EndDateField.php index 0feee1f2..cab719b4 100644 --- a/src/Fields/Rate/EndDateField.php +++ b/src/Fields/Rate/EndDateField.php @@ -2,16 +2,11 @@ namespace PhpTwinfield\Fields\Rate; -use PhpTwinfield\Exception; -use PhpTwinfield\Util; - /** * End date field * Used by: RateRateChange * * @package PhpTwinfield\Traits - * @see Util::formatDate() - * @see Util::parseDate() */ trait EndDateField { @@ -27,19 +22,7 @@ public function getEndDate(): ?\DateTimeInterface { return $this->endDate; } - - /** - * @return string|null - */ - public function getEndDateToString(): ?string - { - if ($this->getEndDate() != null) { - return Util::formatDate($this->getEndDate()); - } else { - return null; - } - } - + /** * @param \DateTimeInterface|null $endDate * @return $this @@ -49,18 +32,4 @@ public function setEndDate(?\DateTimeInterface $endDate) $this->endDate = $endDate; return $this; } - - /** - * @param string|null $endDateString - * @return $this - * @throws Exception - */ - public function setEndDateFromString(?string $endDateString) - { - if ((bool)strtotime($endDateString)) { - return $this->setEndDate(Util::parseDate($endDateString)); - } else { - return $this->setEndDate(null); - } - } } \ No newline at end of file diff --git a/src/Fields/Rate/TypeField.php b/src/Fields/Rate/TypeField.php index 74b0c23e..15e2b20c 100644 --- a/src/Fields/Rate/TypeField.php +++ b/src/Fields/Rate/TypeField.php @@ -28,14 +28,4 @@ public function setType(?RateType $type): self $this->type = $type; return $this; } - - /** - * @param string|null $typeString - * @return $this - * @throws Exception - */ - public function setTypeFromString(?string $typeString) - { - return $this->setType(new RateType((string)$typeString)); - } } \ No newline at end of file diff --git a/src/Fields/RateField.php b/src/Fields/RateField.php index 5c7c3982..70510176 100644 --- a/src/Fields/RateField.php +++ b/src/Fields/RateField.php @@ -39,16 +39,4 @@ public function setRate(?Rate $rate): self $this->rate = $rate; return $this; } - - /** - * @param string|null $rateString - * @return $this - * @throws Exception - */ - public function setRateFromString(?string $rateString) - { - $rate = new Rate(); - $rate->setCode($rateString); - return $this->setRate($rate); - } } diff --git a/src/Fields/StatusField.php b/src/Fields/StatusField.php index 14297afe..1f25d8e8 100644 --- a/src/Fields/StatusField.php +++ b/src/Fields/StatusField.php @@ -27,14 +27,4 @@ public function setStatus(?Status $status): self $this->status = $status; return $this; } - - /** - * @param string|null $statusString - * @return $this - * @throws Exception - */ - public function setStatusFromString(?string $statusString) - { - return $this->setStatus(new Status((string)$statusString)); - } } \ No newline at end of file diff --git a/src/Fields/Transaction/AutoBalanceVatField.php b/src/Fields/Transaction/AutoBalanceVatField.php index 7cf20206..ef76c128 100644 --- a/src/Fields/Transaction/AutoBalanceVatField.php +++ b/src/Fields/Transaction/AutoBalanceVatField.php @@ -20,11 +20,6 @@ public function getAutoBalanceVat(): ?bool return $this->autoBalanceVat; } - public function getAutoBalanceVatToString(): ?string - { - return ($this->getAutoBalanceVat()) ? 'true' : 'false'; - } - /** * @param bool $autoBalanceVat * @return $this @@ -34,14 +29,4 @@ public function setAutoBalanceVat(?bool $autoBalanceVat): self $this->autoBalanceVat = $autoBalanceVat; return $this; } - - /** - * @param string|null $autoBalanceVatString - * @return $this - * @throws Exception - */ - public function setAutoBalanceVatFromString(?string $autoBalanceVatString) - { - return $this->setAutoBalanceVat(filter_var($autoBalanceVatString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Transaction/CloseAndStartValueFields.php b/src/Fields/Transaction/CloseAndStartValueFields.php index 6c0647ed..685fcaec 100644 --- a/src/Fields/Transaction/CloseAndStartValueFields.php +++ b/src/Fields/Transaction/CloseAndStartValueFields.php @@ -35,15 +35,6 @@ public function getCurrency(): ?Currency return $this->currency; } - public function getCurrencyToString(): ?string - { - if ($this->getCurrency() != null) { - return $this->currency->getCode(); - } else { - return null; - } - } - /** * Set the currency. Can only be done when the start value is still 0. * @@ -58,19 +49,6 @@ public function setCurrency(?Currency $currency): self return $this; } - /** - * @param string|null $currencyString - * @return $this - * @throws Exception - */ - public function setCurrencyFromString(?string $currencyString) - { - $currency = new Currency(); - $currency->setCode($currencyString); - - return $this->setCurrency($currency); - } - /** * @return Money|null */ @@ -79,18 +57,6 @@ public function getStartValue(): ?Money return $this->startValue; } - /** - * @return float|null - */ - public function getStartValueToFloat(): ?float - { - if ($this->getStartValue() != null) { - return Util::formatMoney($this->getStartValue()); - } else { - return 0; - } - } - /** * @param Money|null $startValue * @return $this @@ -105,34 +71,8 @@ public function setStartValue(?Money $startValue): void $this->closeValue = $startValue; } - /** - * @param float|null $startValueFloat - * @return $this - * @throws Exception - */ - public function setStartValueFromFloat(?float $startValueFloat) - { - if ((float)$startValueFloat) { - $this->setStartValue(new Money(100 * $startValueFloat, new \Money\Currency($this->getCurrencyToString()))); - } else { - $this->setStartValue(new Money(0, new \Money\Currency($this->getCurrencyToString()))); - } - } - public function getCloseValue(): Money { - return $this->closeValue ?? new Money(0, new \Money\Currency($this->getCurrencyToString())); - } - - /** - * @return float|null - */ - public function getCloseValueToFloat(): ?float - { - if ($this->getCloseValue() != null) { - return Util::formatMoney($this->getCloseValue()); - } else { - return 0; - } + return $this->closeValue ?? new Money(0, new \Money\Currency($this->getCurrency()->getCode())); } } \ No newline at end of file diff --git a/src/Fields/Transaction/DateRaiseWarningField.php b/src/Fields/Transaction/DateRaiseWarningField.php index 35ab04ad..573da7e0 100644 --- a/src/Fields/Transaction/DateRaiseWarningField.php +++ b/src/Fields/Transaction/DateRaiseWarningField.php @@ -34,14 +34,4 @@ public function setDateRaiseWarning(?bool $dateRaiseWarning): self $this->dateRaiseWarning = $dateRaiseWarning; return $this; } - - /** - * @param string|null $dateRaiseWarningString - * @return $this - * @throws Exception - */ - public function setDateRaiseWarningFromString(?string $dateRaiseWarningString) - { - return $this->setDateRaiseWarning(filter_var($dateRaiseWarningString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Transaction/DestinyField.php b/src/Fields/Transaction/DestinyField.php index 2683d3ae..5932acb5 100644 --- a/src/Fields/Transaction/DestinyField.php +++ b/src/Fields/Transaction/DestinyField.php @@ -28,14 +28,4 @@ public function setDestiny(?Destiny $destiny): self $this->destiny = $destiny; return $this; } - - /** - * @param string|null $destinyString - * @return $this - * @throws Exception - */ - public function setDestinyFromString(?string $destinyString) - { - return $this->setDestiny(new Destiny((string)$destinyString)); - } } \ No newline at end of file diff --git a/src/Fields/Transaction/InputDateField.php b/src/Fields/Transaction/InputDateField.php index d03b3a9f..c8ed49e9 100644 --- a/src/Fields/Transaction/InputDateField.php +++ b/src/Fields/Transaction/InputDateField.php @@ -2,16 +2,11 @@ namespace PhpTwinfield\Fields\Transaction; -use PhpTwinfield\Exception; -use PhpTwinfield\Util; - /** * Input date field * Used by: BaseTransaction * * @package PhpTwinfield\Traits - * @see Util::formatDateTime() - * @see Util::parseDateTime() */ trait InputDateField { @@ -28,18 +23,6 @@ public function getInputDate(): ?\DateTimeInterface return $this->inputDate; } - /** - * @return string|null - */ - public function getInputDateToString(): ?string - { - if ($this->getInputDate() != null) { - return Util::formatDateTime($this->getInputDate()); - } else { - return null; - } - } - /** * @param \DateTimeInterface|null $inputDate * @return $this @@ -49,18 +32,4 @@ public function setInputDate(?\DateTimeInterface $inputDate) $this->inputDate = $inputDate; return $this; } - - /** - * @param string|null $inputDateString - * @return $this - * @throws Exception - */ - public function setInputDateFromString(?string $inputDateString) - { - if ((bool)strtotime($inputDateString)) { - return $this->setInputDate(Util::parseDateTime($inputDateString)); - } else { - return $this->setInputDate(null); - } - } } \ No newline at end of file diff --git a/src/Fields/Transaction/InvoiceNumberRaiseWarningField.php b/src/Fields/Transaction/InvoiceNumberRaiseWarningField.php index 2f4c10d2..524ba0b7 100644 --- a/src/Fields/Transaction/InvoiceNumberRaiseWarningField.php +++ b/src/Fields/Transaction/InvoiceNumberRaiseWarningField.php @@ -34,14 +34,4 @@ public function setInvoiceNumberRaiseWarning(?bool $invoiceNumberRaiseWarning): $this->invoiceNumberRaiseWarning = $invoiceNumberRaiseWarning; return $this; } - - /** - * @param string|null $invoiceNumberRaiseWarningString - * @return $this - * @throws Exception - */ - public function setInvoiceNumberRaiseWarningFromString(?string $invoiceNumberRaiseWarningString) - { - return $this->setInvoiceNumberRaiseWarning(filter_var($invoiceNumberRaiseWarningString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Transaction/ModificationDateField.php b/src/Fields/Transaction/ModificationDateField.php index f978db7f..24ca8f1b 100644 --- a/src/Fields/Transaction/ModificationDateField.php +++ b/src/Fields/Transaction/ModificationDateField.php @@ -2,16 +2,11 @@ namespace PhpTwinfield\Fields\Transaction; -use PhpTwinfield\Exception; -use PhpTwinfield\Util; - /** * ModificationDate field * Used by: BaseTransaction * * @package PhpTwinfield\Traits - * @see Util::formatDateTime() - * @see Util::parseDateTime() */ trait ModificationDateField { @@ -28,18 +23,6 @@ public function getModificationDate(): ?\DateTimeInterface return $this->modificationDate; } - /** - * @return string|null - */ - public function getModificationDateToString(): ?string - { - if ($this->getModificationDate() != null) { - return Util::formatDateTime($this->getModificationDate()); - } else { - return null; - } - } - /** * @param \DateTimeInterface|null $modificationDate * @return $this @@ -49,18 +32,4 @@ public function setModificationDate(?\DateTimeInterface $modificationDate) $this->modificationDate = $modificationDate; return $this; } - - /** - * @param string|null $modificationDateString - * @return $this - * @throws Exception - */ - public function setModificationDateFromString(?string $modificationDateString) - { - if ((bool)strtotime($modificationDateString)) { - return $this->setModificationDate(Util::parseDateTime($modificationDateString)); - } else { - return $this->setModificationDate(null); - } - } } \ No newline at end of file diff --git a/src/Fields/Transaction/RaiseWarningField.php b/src/Fields/Transaction/RaiseWarningField.php index 2419b50e..dcd0af3e 100644 --- a/src/Fields/Transaction/RaiseWarningField.php +++ b/src/Fields/Transaction/RaiseWarningField.php @@ -20,11 +20,6 @@ public function getRaiseWarning(): ?bool return $this->raiseWarning; } - public function getRaiseWarningToString(): ?string - { - return ($this->getRaiseWarning()) ? 'true' : 'false'; - } - /** * @param bool $raiseWarning * @return $this @@ -34,14 +29,4 @@ public function setRaiseWarning(?bool $raiseWarning): self $this->raiseWarning = $raiseWarning; return $this; } - - /** - * @param string|null $raiseWarningString - * @return $this - * @throws Exception - */ - public function setRaiseWarningFromString(?string $raiseWarningString) - { - return $this->setRaiseWarning(filter_var($raiseWarningString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/Transaction/RegimeField.php b/src/Fields/Transaction/RegimeField.php index 0d575b7c..11e791a6 100644 --- a/src/Fields/Transaction/RegimeField.php +++ b/src/Fields/Transaction/RegimeField.php @@ -28,14 +28,4 @@ public function setRegime(?Regime $regime): self $this->regime = $regime; return $this; } - - /** - * @param string|null $regimeString - * @return $this - * @throws Exception - */ - public function setRegimeFromString(?string $regimeString) - { - return $this->setRegime(new Regime((string)$regimeString)); - } } \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/BaseValueField.php b/src/Fields/Transaction/TransactionLine/BaseValueField.php index ee5d4b8a..b975f736 100644 --- a/src/Fields/Transaction/TransactionLine/BaseValueField.php +++ b/src/Fields/Transaction/TransactionLine/BaseValueField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Transaction\TransactionLine; use Money\Money; -use PhpTwinfield\Util; trait BaseValueField { @@ -23,18 +22,6 @@ public function getBaseValue(): ?Money return $this->baseValue; } - /** - * @return float|null - */ - public function getBaseValueToFloat(): ?float - { - if ($this->getBaseValue() != null) { - return Util::formatMoney($this->getBaseValue()); - } else { - return 0; - } - } - /** * @param Money|null $baseValue * @return $this @@ -45,18 +32,4 @@ public function setBaseValue(?Money $baseValue) return $this; } - - /** - * @param float|null $baseValueFloat - * @return $this - * @throws Exception - */ - public function setBaseValueFromFloat(?float $baseValueFloat) - { - if ((float)$baseValueFloat) { - return $this->setBaseValue(Money::EUR(100 * $baseValueFloat)); - } else { - return $this->setBaseValue(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/BaseValueOpenField.php b/src/Fields/Transaction/TransactionLine/BaseValueOpenField.php index 6bba766c..02d64435 100644 --- a/src/Fields/Transaction/TransactionLine/BaseValueOpenField.php +++ b/src/Fields/Transaction/TransactionLine/BaseValueOpenField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Transaction\TransactionLine; use Money\Money; -use PhpTwinfield\Util; trait BaseValueOpenField { @@ -22,19 +21,7 @@ public function getBaseValueOpen(): ?Money { return $this->baseValueOpen; } - - /** - * @return float|null - */ - public function getBaseValueOpenToFloat(): ?float - { - if ($this->getBaseValueOpen() != null) { - return Util::formatMoney($this->getBaseValueOpen()); - } else { - return 0; - } - } - + /** * @param Money|null $baseValueOpen * @return $this @@ -45,18 +32,4 @@ public function setBaseValueOpen(?Money $baseValueOpen) return $this; } - - /** - * @param float|null $baseValueOpenFloat - * @return $this - * @throws Exception - */ - public function setBaseValueOpenFromFloat(?float $baseValueOpenFloat) - { - if ((float)$baseValueOpenFloat) { - return $this->setBaseValueOpen(Money::EUR(100 * $baseValueOpenFloat)); - } else { - return $this->setBaseValueOpen(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/CurrencyDateField.php b/src/Fields/Transaction/TransactionLine/CurrencyDateField.php index 7737fa49..ff5022d2 100644 --- a/src/Fields/Transaction/TransactionLine/CurrencyDateField.php +++ b/src/Fields/Transaction/TransactionLine/CurrencyDateField.php @@ -2,16 +2,11 @@ namespace PhpTwinfield\Fields\Transaction\TransactionLine; -use PhpTwinfield\Exception; -use PhpTwinfield\Util; - /** * Currency date field * Used by: BankTransactionLine, CashTransactionLine, JournalTransactionLine * * @package PhpTwinfield\Traits - * @see Util::formatDate() - * @see Util::parseDate() */ trait CurrencyDateField { @@ -28,18 +23,6 @@ public function getCurrencyDate(): ?\DateTimeInterface return $this->currencyDate; } - /** - * @return string|null - */ - public function getCurrencyDateToString(): ?string - { - if ($this->getCurrencyDate() != null) { - return Util::formatDate($this->getCurrencyDate()); - } else { - return null; - } - } - /** * @param \DateTimeInterface|null $currencyDate * @return $this @@ -49,18 +32,4 @@ public function setCurrencyDate(?\DateTimeInterface $currencyDate) $this->currencyDate = $currencyDate; return $this; } - - /** - * @param string|null $currencyDateString - * @return $this - * @throws Exception - */ - public function setCurrencyDateFromString(?string $currencyDateString) - { - if ((bool)strtotime($currencyDateString)) { - return $this->setCurrencyDate(Util::parseDate($currencyDateString)); - } else { - return $this->setCurrencyDate(null); - } - } } \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/DestOfficeField.php b/src/Fields/Transaction/TransactionLine/DestOfficeField.php index 3e00d6bb..96c9d72d 100644 --- a/src/Fields/Transaction/TransactionLine/DestOfficeField.php +++ b/src/Fields/Transaction/TransactionLine/DestOfficeField.php @@ -21,15 +21,6 @@ public function getDestOffice(): ?Office return $this->destOffice; } - public function getDestOfficeToString(): ?string - { - if ($this->getDestOffice() != null) { - return $this->destOffice->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -38,16 +29,4 @@ public function setDestOffice(?Office $destOffice): self $this->destOffice = $destOffice; return $this; } - - /** - * @param string|null $officeString - * @return $this - * @throws Exception - */ - public function setDestOfficeFromString(?string $officeString) - { - $destOffice = new Office(); - $destOffice->setCode($officeString); - return $this->setDestOffice($destOffice); - } } diff --git a/src/Fields/Transaction/TransactionLine/Dim1Field.php b/src/Fields/Transaction/TransactionLine/Dim1Field.php index 81a43c0a..1f09319f 100644 --- a/src/Fields/Transaction/TransactionLine/Dim1Field.php +++ b/src/Fields/Transaction/TransactionLine/Dim1Field.php @@ -2,8 +2,6 @@ namespace PhpTwinfield\Fields\Transaction\TransactionLine; -use PhpTwinfield\Dummy; - /** * The dimension * Used by: BaseTransactionLine @@ -22,15 +20,6 @@ public function getDim1() return $this->dim1; } - public function getDim1ToString(): ?string - { - if ($this->getDim1() != null) { - return $this->dim1->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +28,4 @@ public function setDim1($dim1): self $this->dim1 = $dim1; return $this; } - - /** - * @param string|null $dim1String - * @return $this - * @throws Exception - */ - public function setDim1FromString(?string $dim1String) - { - $dim1 = new Dummy(); - $dim1->setCode($dim1String); - return $this->setDim1($dim1); - } } diff --git a/src/Fields/Transaction/TransactionLine/MatchDateField.php b/src/Fields/Transaction/TransactionLine/MatchDateField.php index a21dc0a9..dfcc7e6f 100644 --- a/src/Fields/Transaction/TransactionLine/MatchDateField.php +++ b/src/Fields/Transaction/TransactionLine/MatchDateField.php @@ -2,16 +2,11 @@ namespace PhpTwinfield\Fields\Transaction\TransactionLine; -use PhpTwinfield\Exception; -use PhpTwinfield\Util; - /** * Match date field * Used by: MatchSet, PurchaseTransactionLine * * @package PhpTwinfield\Traits - * @see Util::formatDate() - * @see Util::parseDate() */ trait MatchDateField { @@ -28,18 +23,6 @@ public function getMatchDate(): ?\DateTimeInterface return $this->matchDate; } - /** - * @return string|null - */ - public function getMatchDateToString(): ?string - { - if ($this->getMatchDate() != null) { - return Util::formatDate($this->getMatchDate()); - } else { - return null; - } - } - /** * @param \DateTimeInterface|null $matchDate * @return $this @@ -49,18 +32,4 @@ public function setMatchDate(?\DateTimeInterface $matchDate) $this->matchDate = $matchDate; return $this; } - - /** - * @param string|null $matchDateString - * @return $this - * @throws Exception - */ - public function setMatchDateFromString(?string $matchDateString) - { - if ((bool)strtotime($matchDateString)) { - return $this->setMatchDate(Util::parseDate($matchDateString)); - } else { - return $this->setMatchDate(null); - } - } } \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/MatchStatusField.php b/src/Fields/Transaction/TransactionLine/MatchStatusField.php index f48b1465..68bf37fd 100644 --- a/src/Fields/Transaction/TransactionLine/MatchStatusField.php +++ b/src/Fields/Transaction/TransactionLine/MatchStatusField.php @@ -27,14 +27,4 @@ public function setMatchStatus(?MatchStatus $matchStatus): self $this->matchStatus = $matchStatus; return $this; } - - /** - * @param string|null $matchStatusString - * @return $this - * @throws Exception - */ - public function setMatchStatusFromString(?string $matchStatusString) - { - return $this->setMatchStatus(new MatchStatus((string)$matchStatusString)); - } } \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/PerformanceCountryField.php b/src/Fields/Transaction/TransactionLine/PerformanceCountryField.php index fb607c54..96bb9a37 100644 --- a/src/Fields/Transaction/TransactionLine/PerformanceCountryField.php +++ b/src/Fields/Transaction/TransactionLine/PerformanceCountryField.php @@ -22,15 +22,6 @@ public function getPerformanceCountry(): ?Country return $this->performanceCountry; } - public function getPerformanceCountryToString(): ?string - { - if ($this->getPerformanceCountry() != null) { - return $this->performanceCountry->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setPerformanceCountry(?Country $performanceCountry): self $this->performanceCountry = $performanceCountry; return $this; } - - /** - * @param string|null $performanceCountryString - * @return $this - * @throws Exception - */ - public function setPerformanceCountryFromString(?string $performanceCountryString) - { - $performanceCountry = new Country(); - $performanceCountry->setCode($performanceCountryString); - return $this->setPerformanceCountry($performanceCountry); - } } \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/RepValueField.php b/src/Fields/Transaction/TransactionLine/RepValueField.php index 0b5002a4..d6e373f5 100644 --- a/src/Fields/Transaction/TransactionLine/RepValueField.php +++ b/src/Fields/Transaction/TransactionLine/RepValueField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Transaction\TransactionLine; use Money\Money; -use PhpTwinfield\Util; trait RepValueField { @@ -23,18 +22,6 @@ public function getRepValue(): ?Money return $this->repValue; } - /** - * @return float|null - */ - public function getRepValueToFloat(): ?float - { - if ($this->getRepValue() != null) { - return Util::formatMoney($this->getRepValue()); - } else { - return 0; - } - } - /** * @param Money|null $repValue * @return $this @@ -45,18 +32,4 @@ public function setRepValue(?Money $repValue) return $this; } - - /** - * @param float|null $repValueFloat - * @return $this - * @throws Exception - */ - public function setRepValueFromFloat(?float $repValueFloat) - { - if ((float)$repValueFloat) { - return $this->setRepValue(Money::EUR(100 * $repValueFloat)); - } else { - return $this->setRepValue(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/RepValueOpenField.php b/src/Fields/Transaction/TransactionLine/RepValueOpenField.php index b3d05ee9..8988525c 100644 --- a/src/Fields/Transaction/TransactionLine/RepValueOpenField.php +++ b/src/Fields/Transaction/TransactionLine/RepValueOpenField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Transaction\TransactionLine; use Money\Money; -use PhpTwinfield\Util; trait RepValueOpenField { @@ -23,18 +22,6 @@ public function getRepValueOpen(): ?Money return $this->repValueOpen; } - /** - * @return float|null - */ - public function getRepValueOpenToFloat(): ?float - { - if ($this->getRepValueOpen() != null) { - return Util::formatMoney($this->getRepValueOpen()); - } else { - return 0; - } - } - /** * @param Money|null $repValueOpen * @return $this @@ -45,18 +32,4 @@ public function setRepValueOpen(?Money $repValueOpen) return $this; } - - /** - * @param float|null $repValueOpenFloat - * @return $this - * @throws Exception - */ - public function setRepValueOpenFromFloat(?float $repValueOpenFloat) - { - if ((float)$repValueOpenFloat) { - return $this->setRepValueOpen(Money::EUR(100 * $repValueOpenFloat)); - } else { - return $this->setRepValueOpen(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/ValueFields.php b/src/Fields/Transaction/TransactionLine/ValueFields.php index 92ef971e..6585508e 100644 --- a/src/Fields/Transaction/TransactionLine/ValueFields.php +++ b/src/Fields/Transaction/TransactionLine/ValueFields.php @@ -5,7 +5,6 @@ use Money\Money; use PhpTwinfield\Enums\DebitCredit; use PhpTwinfield\Enums\LineType; -use PhpTwinfield\Util; use Webmozart\Assert\Assert; trait ValueFields @@ -84,18 +83,6 @@ public function getValue(): Money return $this->value->absolute(); } - /** - * @return float|null - */ - public function getValueToFloat(): ?float - { - if ($this->getValue() != null) { - return Util::formatMoney($this->getValue()); - } else { - return 0; - } - } - public function getSignedValue(): Money { return $this->value; @@ -125,18 +112,4 @@ public function setValue(Money $value) $this->value = $value; return $this; } - - /** - * @param float|null $valueFloat - * @return $this - * @throws Exception - */ - public function setValueFromFloat(?float $valueFloat) - { - if ((float)$valueFloat) { - return $this->setValue(Money::EUR(100 * $valueFloat)); - } else { - return $this->setValue(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/ValueOpenField.php b/src/Fields/Transaction/TransactionLine/ValueOpenField.php index 33668dd7..e703bffa 100644 --- a/src/Fields/Transaction/TransactionLine/ValueOpenField.php +++ b/src/Fields/Transaction/TransactionLine/ValueOpenField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Transaction\TransactionLine; use Money\Money; -use PhpTwinfield\Util; trait ValueOpenField { @@ -23,18 +22,6 @@ public function getValueOpen(): ?Money return $this->valueOpen; } - /** - * @return float|null - */ - public function getValueOpenToFloat(): ?float - { - if ($this->getValueOpen() != null) { - return Util::formatMoney($this->getValueOpen()); - } else { - return 0; - } - } - /** * @param Money|null $valueOpen * @return $this @@ -45,18 +32,4 @@ public function setValueOpen(?Money $valueOpen) return $this; } - - /** - * @param float|null $valueOpenFloat - * @return $this - * @throws Exception - */ - public function setValueOpenFromFloat(?float $valueOpenFloat) - { - if ((float)$valueOpenFloat) { - return $this->setValueOpen(Money::EUR(100 * $valueOpenFloat)); - } else { - return $this->setValueOpen(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/VatBaseTotalField.php b/src/Fields/Transaction/TransactionLine/VatBaseTotalField.php index aea42f7c..845a2e74 100644 --- a/src/Fields/Transaction/TransactionLine/VatBaseTotalField.php +++ b/src/Fields/Transaction/TransactionLine/VatBaseTotalField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Transaction\TransactionLine; use Money\Money; -use PhpTwinfield\Util; trait VatBaseTotalField { @@ -23,18 +22,6 @@ public function getVatBaseTotal(): ?Money return $this->vatBaseTotal; } - /** - * @return float|null - */ - public function getVatBaseTotalToFloat(): ?float - { - if ($this->getVatBaseTotal() != null) { - return Util::formatMoney($this->getVatBaseTotal()); - } else { - return 0; - } - } - /** * @param Money|null $vatBaseTotal * @return $this @@ -45,18 +32,4 @@ public function setVatBaseTotal(?Money $vatBaseTotal) return $this; } - - /** - * @param float|null $vatBaseTotalFloat - * @return $this - * @throws Exception - */ - public function setVatBaseTotalFromFloat(?float $vatBaseTotalFloat) - { - if ((float)$vatBaseTotalFloat) { - return $this->setVatBaseTotal(Money::EUR(100 * $vatBaseTotalFloat)); - } else { - return $this->setVatBaseTotal(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/VatBaseTurnoverField.php b/src/Fields/Transaction/TransactionLine/VatBaseTurnoverField.php index 9db8b86b..bb2d396a 100644 --- a/src/Fields/Transaction/TransactionLine/VatBaseTurnoverField.php +++ b/src/Fields/Transaction/TransactionLine/VatBaseTurnoverField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Transaction\TransactionLine; use Money\Money; -use PhpTwinfield\Util; trait VatBaseTurnoverField { @@ -23,18 +22,6 @@ public function getVatBaseTurnover(): ?Money return $this->vatBaseTurnover; } - /** - * @return float|null - */ - public function getVatBaseTurnoverToFloat(): ?float - { - if ($this->getVatBaseTurnover() != null) { - return Util::formatMoney($this->getVatBaseTurnover()); - } else { - return 0; - } - } - /** * @param Money|null $vatBaseTurnover * @return $this @@ -45,18 +32,4 @@ public function setVatBaseTurnover(?Money $vatBaseTurnover) return $this; } - - /** - * @param float|null $vatBaseTurnoverFloat - * @return $this - * @throws Exception - */ - public function setVatBaseTurnoverFromFloat(?float $vatBaseTurnoverFloat) - { - if ((float)$vatBaseTurnoverFloat) { - return $this->setVatBaseTurnover(Money::EUR(100 * $vatBaseTurnoverFloat)); - } else { - return $this->setVatBaseTurnover(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/VatBaseValueField.php b/src/Fields/Transaction/TransactionLine/VatBaseValueField.php index f38cd19f..fe56a4bb 100644 --- a/src/Fields/Transaction/TransactionLine/VatBaseValueField.php +++ b/src/Fields/Transaction/TransactionLine/VatBaseValueField.php @@ -3,8 +3,7 @@ namespace PhpTwinfield\Fields\Transaction\TransactionLine; use Money\Money; -use PhpTwinfield\Util; - +s trait VatBaseValueField { /** @@ -23,18 +22,6 @@ public function getVatBaseValue(): ?Money return $this->vatBaseValue; } - /** - * @return float|null - */ - public function getVatBaseValueToFloat(): ?float - { - if ($this->getVatBaseValue() != null) { - return Util::formatMoney($this->getVatBaseValue()); - } else { - return 0; - } - } - /** * @param Money|null $vatBaseValue * @return $this @@ -45,18 +32,4 @@ public function setVatBaseValue(?Money $vatBaseValue) return $this; } - - /** - * @param float|null $vatBaseValueFloat - * @return $this - * @throws Exception - */ - public function setVatBaseValueFromFloat(?float $vatBaseValueFloat) - { - if ((float)$vatBaseValueFloat) { - return $this->setVatBaseValue(Money::EUR(100 * $vatBaseValueFloat)); - } else { - return $this->setVatBaseValue(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/VatRepTotalField.php b/src/Fields/Transaction/TransactionLine/VatRepTotalField.php index a77676e4..500c4b0f 100644 --- a/src/Fields/Transaction/TransactionLine/VatRepTotalField.php +++ b/src/Fields/Transaction/TransactionLine/VatRepTotalField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Transaction\TransactionLine; use Money\Money; -use PhpTwinfield\Util; trait VatRepTotalField { @@ -23,18 +22,6 @@ public function getVatRepTotal(): ?Money return $this->vatRepTotal; } - /** - * @return float|null - */ - public function getVatRepTotalToFloat(): ?float - { - if ($this->getVatRepTotal() != null) { - return Util::formatMoney($this->getVatRepTotal()); - } else { - return 0; - } - } - /** * @param Money|null $vatRepTotal * @return $this @@ -45,18 +32,4 @@ public function setVatRepTotal(?Money $vatRepTotal) return $this; } - - /** - * @param float|null $vatRepTotalFloat - * @return $this - * @throws Exception - */ - public function setVatRepTotalFromFloat(?float $vatRepTotalFloat) - { - if ((float)$vatRepTotalFloat) { - return $this->setVatRepTotal(Money::EUR(100 * $vatRepTotalFloat)); - } else { - return $this->setVatRepTotal(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/VatRepTurnoverField.php b/src/Fields/Transaction/TransactionLine/VatRepTurnoverField.php index 92490ddd..117607eb 100644 --- a/src/Fields/Transaction/TransactionLine/VatRepTurnoverField.php +++ b/src/Fields/Transaction/TransactionLine/VatRepTurnoverField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Transaction\TransactionLine; use Money\Money; -use PhpTwinfield\Util; trait VatRepTurnoverField { @@ -23,18 +22,6 @@ public function getVatRepTurnover(): ?Money return $this->vatRepTurnover; } - /** - * @return float|null - */ - public function getVatRepTurnoverToFloat(): ?float - { - if ($this->getVatRepTurnover() != null) { - return Util::formatMoney($this->getVatRepTurnover()); - } else { - return 0; - } - } - /** * @param Money|null $vatRepTurnover * @return $this @@ -45,18 +32,4 @@ public function setVatRepTurnover(?Money $vatRepTurnover) return $this; } - - /** - * @param float|null $vatRepTurnoverFloat - * @return $this - * @throws Exception - */ - public function setVatRepTurnoverFromFloat(?float $vatRepTurnoverFloat) - { - if ((float)$vatRepTurnoverFloat) { - return $this->setVatRepTurnover(Money::EUR(100 * $vatRepTurnoverFloat)); - } else { - return $this->setVatRepTurnover(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/VatRepValueField.php b/src/Fields/Transaction/TransactionLine/VatRepValueField.php index e4199f5d..1a152921 100644 --- a/src/Fields/Transaction/TransactionLine/VatRepValueField.php +++ b/src/Fields/Transaction/TransactionLine/VatRepValueField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Transaction\TransactionLine; use Money\Money; -use PhpTwinfield\Util; trait VatRepValueField { @@ -23,18 +22,6 @@ public function getVatRepValue(): ?Money return $this->vatRepValue; } - /** - * @return float|null - */ - public function getVatRepValueToFloat(): ?float - { - if ($this->getVatRepValue() != null) { - return Util::formatMoney($this->getVatRepValue()); - } else { - return 0; - } - } - /** * @param Money|null $vatRepValue * @return $this @@ -45,18 +32,4 @@ public function setVatRepValue(?Money $vatRepValue) return $this; } - - /** - * @param float|null $vatRepValueFloat - * @return $this - * @throws Exception - */ - public function setVatRepValueFromFloat(?float $vatRepValueFloat) - { - if ((float)$vatRepValueFloat) { - return $this->setVatRepValue(Money::EUR(100 * $vatRepValueFloat)); - } else { - return $this->setVatRepValue(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/VatTotalField.php b/src/Fields/Transaction/TransactionLine/VatTotalField.php index 4e3f74ed..eeb90e0b 100644 --- a/src/Fields/Transaction/TransactionLine/VatTotalField.php +++ b/src/Fields/Transaction/TransactionLine/VatTotalField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Transaction\TransactionLine; use Money\Money; -use PhpTwinfield\Util; trait VatTotalField { @@ -23,18 +22,6 @@ public function getVatTotal(): ?Money return $this->vatTotal; } - /** - * @return float|null - */ - public function getVatTotalToFloat(): ?float - { - if ($this->getVatTotal() != null) { - return Util::formatMoney($this->getVatTotal()); - } else { - return 0; - } - } - /** * @param Money|null $vatTotal * @return $this @@ -45,18 +32,4 @@ public function setVatTotal(?Money $vatTotal) return $this; } - - /** - * @param float|null $vatTotalFloat - * @return $this - * @throws Exception - */ - public function setVatTotalFromFloat(?float $vatTotalFloat) - { - if ((float)$vatTotalFloat) { - return $this->setVatTotal(Money::EUR(100 * $vatTotalFloat)); - } else { - return $this->setVatTotal(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/Transaction/TransactionLine/VatTurnoverField.php b/src/Fields/Transaction/TransactionLine/VatTurnoverField.php index bd35adac..8a5c4669 100644 --- a/src/Fields/Transaction/TransactionLine/VatTurnoverField.php +++ b/src/Fields/Transaction/TransactionLine/VatTurnoverField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields\Transaction\TransactionLine; use Money\Money; -use PhpTwinfield\Util; trait VatTurnoverField { @@ -23,18 +22,6 @@ public function getVatTurnover(): ?Money return $this->vatTurnover; } - /** - * @return float|null - */ - public function getVatTurnoverToFloat(): ?float - { - if ($this->getVatTurnover() != null) { - return Util::formatMoney($this->getVatTurnover()); - } else { - return 0; - } - } - /** * @param Money|null $vatTurnover * @return $this @@ -45,18 +32,4 @@ public function setVatTurnover(?Money $vatTurnover) return $this; } - - /** - * @param float|null $vatTurnoverFloat - * @return $this - * @throws Exception - */ - public function setVatTurnoverFromFloat(?float $vatTurnoverFloat) - { - if ((float)$vatTurnoverFloat) { - return $this->setVatTurnover(Money::EUR(100 * $vatTurnoverFloat)); - } else { - return $this->setVatTurnover(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/Fields/User/AcceptExtraCostField.php b/src/Fields/User/AcceptExtraCostField.php index 3bd68ca3..735463e4 100644 --- a/src/Fields/User/AcceptExtraCostField.php +++ b/src/Fields/User/AcceptExtraCostField.php @@ -20,11 +20,6 @@ public function getAcceptExtraCost(): ?bool return $this->acceptExtraCost; } - public function getAcceptExtraCostToString(): ?string - { - return ($this->getAcceptExtraCost()) ? 'true' : 'false'; - } - /** * @param bool $acceptExtraCost * @return $this @@ -34,14 +29,4 @@ public function setAcceptExtraCost(?bool $acceptExtraCost): self $this->acceptExtraCost = $acceptExtraCost; return $this; } - - /** - * @param string|null $acceptExtraCostString - * @return $this - * @throws Exception - */ - public function setAcceptExtraCostFromString(?string $acceptExtraCostString) - { - return $this->setAcceptExtraCost(filter_var($acceptExtraCostString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/User/CultureField.php b/src/Fields/User/CultureField.php index e9665f3d..5dbf2e0d 100644 --- a/src/Fields/User/CultureField.php +++ b/src/Fields/User/CultureField.php @@ -27,14 +27,4 @@ public function setCulture(?Culture $culture): self $this->culture = $culture; return $this; } - - /** - * @param string|null $cultureString - * @return $this - * @throws Exception - */ - public function setCultureFromString(?string $cultureString) - { - return $this->setCulture(new Culture((string)$cultureString)); - } } \ No newline at end of file diff --git a/src/Fields/User/DemoField.php b/src/Fields/User/DemoField.php index cd83d4ad..c202f30c 100644 --- a/src/Fields/User/DemoField.php +++ b/src/Fields/User/DemoField.php @@ -20,11 +20,6 @@ public function getDemo(): ?bool return $this->demo; } - public function getDemoToString(): ?string - { - return ($this->getDemo()) ? 'true' : 'false'; - } - /** * @param bool $demo * @return $this @@ -34,14 +29,4 @@ public function setDemo(?bool $demo): self $this->demo = $demo; return $this; } - - /** - * @param string|null $demoString - * @return $this - * @throws Exception - */ - public function setDemoFromString(?string $demoString) - { - return $this->setDemo(filter_var($demoString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/User/DemoLockedField.php b/src/Fields/User/DemoLockedField.php index dc93f51c..c70aadbb 100644 --- a/src/Fields/User/DemoLockedField.php +++ b/src/Fields/User/DemoLockedField.php @@ -19,12 +19,7 @@ public function getDemoLocked(): ?bool { return $this->demoLocked; } - - public function getDemoLockedToString(): ?string - { - return ($this->getDemoLocked()) ? 'true' : 'false'; - } - + /** * @param bool $demoLocked * @return $this @@ -34,14 +29,4 @@ public function setDemoLocked(?bool $demoLocked): self $this->demoLocked = $demoLocked; return $this; } - - /** - * @param string|null $demoLockedString - * @return $this - * @throws Exception - */ - public function setDemoLockedFromString(?string $demoLockedString) - { - return $this->setDemoLocked(filter_var($demoLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/User/ExchangeQuotaLockedField.php b/src/Fields/User/ExchangeQuotaLockedField.php index 555e2c9a..9ad6483b 100644 --- a/src/Fields/User/ExchangeQuotaLockedField.php +++ b/src/Fields/User/ExchangeQuotaLockedField.php @@ -20,11 +20,6 @@ public function getExchangeQuotaLocked(): ?bool return $this->exchangeQuotaLocked; } - public function getExchangeQuotaLockedToString(): ?string - { - return ($this->getExchangeQuotaLocked()) ? 'true' : 'false'; - } - /** * @param bool $exchangeQuotaLocked * @return $this @@ -34,14 +29,4 @@ public function setExchangeQuotaLocked(?bool $exchangeQuotaLocked): self $this->exchangeQuotaLocked = $exchangeQuotaLocked; return $this; } - - /** - * @param string|null $exchangeQuotaLockedString - * @return $this - * @throws Exception - */ - public function setExchangeQuotaLockedFromString(?string $exchangeQuotaLockedString) - { - return $this->setExchangeQuotaLocked(filter_var($exchangeQuotaLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/User/FileManagerQuotaLockedField.php b/src/Fields/User/FileManagerQuotaLockedField.php index 9415787e..06c8293c 100644 --- a/src/Fields/User/FileManagerQuotaLockedField.php +++ b/src/Fields/User/FileManagerQuotaLockedField.php @@ -20,11 +20,6 @@ public function getFileManagerQuotaLocked(): ?bool return $this->fileManagerQuotaLocked; } - public function getFileManagerQuotaLockedToString(): ?string - { - return ($this->getFileManagerQuotaLocked()) ? 'true' : 'false'; - } - /** * @param bool $fileManagerQuotaLocked * @return $this @@ -34,14 +29,4 @@ public function setFileManagerQuotaLocked(?bool $fileManagerQuotaLocked): self $this->fileManagerQuotaLocked = $fileManagerQuotaLocked; return $this; } - - /** - * @param string|null $fileManagerQuotaLockedString - * @return $this - * @throws Exception - */ - public function setFileManagerQuotaLockedFromString(?string $fileManagerQuotaLockedString) - { - return $this->setFileManagerQuotaLocked(filter_var($fileManagerQuotaLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/User/IsCurrentUserField.php b/src/Fields/User/IsCurrentUserField.php index cc7149dc..96cb124f 100644 --- a/src/Fields/User/IsCurrentUserField.php +++ b/src/Fields/User/IsCurrentUserField.php @@ -20,11 +20,6 @@ public function getIsCurrentUser(): ?bool return $this->isCurrentUser; } - public function getIsCurrentUserToString(): ?string - { - return ($this->getIsCurrentUser()) ? 'true' : 'false'; - } - /** * @param bool $isCurrentUser * @return $this @@ -34,14 +29,4 @@ public function setIsCurrentUser(?bool $isCurrentUser): self $this->isCurrentUser = $isCurrentUser; return $this; } - - /** - * @param string|null $isCurrentUserString - * @return $this - * @throws Exception - */ - public function setIsCurrentUserFromString(?string $isCurrentUserString) - { - return $this->setIsCurrentUser(filter_var($isCurrentUserString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/User/RoleField.php b/src/Fields/User/RoleField.php index f9bd929c..01367097 100644 --- a/src/Fields/User/RoleField.php +++ b/src/Fields/User/RoleField.php @@ -22,15 +22,6 @@ public function getRole(): ?UserRole return $this->role; } - public function getRoleToString(): ?string - { - if ($this->getRole() != null) { - return $this->role->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,17 +30,5 @@ public function setRole(?UserRole $role): self $this->role = $role; return $this; } - - /** - * @param string|null $roleString - * @return $this - * @throws Exception - */ - public function setRoleFromString(?string $roleString) - { - $role = new UserRole(); - $role->setCode($roleString); - return $this->setRole($role); - } } diff --git a/src/Fields/User/RoleLockedField.php b/src/Fields/User/RoleLockedField.php index 5d28e0bb..e65651ae 100644 --- a/src/Fields/User/RoleLockedField.php +++ b/src/Fields/User/RoleLockedField.php @@ -19,12 +19,7 @@ public function getRoleLocked(): ?bool { return $this->roleLocked; } - - public function getRoleLockedToString(): ?string - { - return ($this->getRoleLocked()) ? 'true' : 'false'; - } - + /** * @param bool $roleLocked * @return $this @@ -34,14 +29,4 @@ public function setRoleLocked(?bool $roleLocked): self $this->roleLocked = $roleLocked; return $this; } - - /** - * @param string|null $roleLockedString - * @return $this - * @throws Exception - */ - public function setRoleLockedFromString(?string $roleLockedString) - { - return $this->setRoleLocked(filter_var($roleLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/User/TypeField.php b/src/Fields/User/TypeField.php index 46663929..9dace761 100644 --- a/src/Fields/User/TypeField.php +++ b/src/Fields/User/TypeField.php @@ -27,14 +27,4 @@ public function setType(?UserType $type): self $this->type = $type; return $this; } - - /** - * @param string|null $typeString - * @return $this - * @throws Exception - */ - public function setTypeFromString(?string $typeString) - { - return $this->setType(new UserType((string)$typeString)); - } } \ No newline at end of file diff --git a/src/Fields/User/TypeLockedField.php b/src/Fields/User/TypeLockedField.php index 0ed2829c..281923f1 100644 --- a/src/Fields/User/TypeLockedField.php +++ b/src/Fields/User/TypeLockedField.php @@ -20,11 +20,6 @@ public function getTypeLocked(): ?bool return $this->typeLocked; } - public function getTypeLockedToString(): ?string - { - return ($this->getTypeLocked()) ? 'true' : 'false'; - } - /** * @param bool $typeLocked * @return $this @@ -34,14 +29,4 @@ public function setTypeLocked(?bool $typeLocked): self $this->typeLocked = $typeLocked; return $this; } - - /** - * @param string|null $typeLockedString - * @return $this - * @throws Exception - */ - public function setTypeLockedFromString(?string $typeLockedString) - { - return $this->setTypeLocked(filter_var($typeLockedString, FILTER_VALIDATE_BOOLEAN)); - } } \ No newline at end of file diff --git a/src/Fields/UserField.php b/src/Fields/UserField.php index 5d3cdcf1..0a8ac524 100644 --- a/src/Fields/UserField.php +++ b/src/Fields/UserField.php @@ -22,15 +22,6 @@ public function getUser(): ?User return $this->user; } - public function getUserToString(): ?string - { - if ($this->getUser() != null) { - return $this->user->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,17 +30,5 @@ public function setUser(?User $user): self $this->user = $user; return $this; } - - /** - * @param string|null $userString - * @return $this - * @throws Exception - */ - public function setUserFromString(?string $userString) - { - $user = new User(); - $user->setCode($userString); - return $this->setUser($user); - } } diff --git a/src/Fields/VatCode/GroupCountryField.php b/src/Fields/VatCode/GroupCountryField.php index c9f31fbf..2c5491a8 100644 --- a/src/Fields/VatCode/GroupCountryField.php +++ b/src/Fields/VatCode/GroupCountryField.php @@ -22,15 +22,6 @@ public function getGroupCountry(): ?VatGroupCountry return $this->groupCountry; } - public function getGroupCountryToString(): ?string - { - if ($this->getGroupCountry() != null) { - return $this->groupCountry->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setGroupCountry(?VatGroupCountry $groupCountry): self $this->groupCountry = $groupCountry; return $this; } - - /** - * @param string|null $groupCountryString - * @return $this - * @throws Exception - */ - public function setGroupCountryFromString(?string $groupCountryString) - { - $groupCountry = new VatGroupCountry(); - $groupCountry->setCode($groupCountryString); - return $this->setGroupCountry($groupCountry); - } } \ No newline at end of file diff --git a/src/Fields/VatCode/GroupField.php b/src/Fields/VatCode/GroupField.php index 56d8d3de..04dd8232 100644 --- a/src/Fields/VatCode/GroupField.php +++ b/src/Fields/VatCode/GroupField.php @@ -22,15 +22,6 @@ public function getGroup(): ?VatGroup return $this->group; } - public function getGroupToString(): ?string - { - if ($this->getGroup() != null) { - return $this->group->getCode(); - } else { - return null; - } - } - /** * @return $this */ @@ -39,16 +30,4 @@ public function setGroup(?VatGroup $group): self $this->group = $group; return $this; } - - /** - * @param string|null $groupString - * @return $this - * @throws Exception - */ - public function setGroupFromString(?string $groupString) - { - $group = new VatGroup(); - $group->setCode($groupString); - return $this->setGroup($group); - } } \ No newline at end of file diff --git a/src/Fields/VatCode/TypeField.php b/src/Fields/VatCode/TypeField.php index d685c0c1..a2887179 100644 --- a/src/Fields/VatCode/TypeField.php +++ b/src/Fields/VatCode/TypeField.php @@ -28,14 +28,4 @@ public function setType(?VatType $type): self $this->type = $type; return $this; } - - /** - * @param string|null $typeString - * @return $this - * @throws Exception - */ - public function setTypeFromString(?string $typeString) - { - return $this->setType(new VatType((string)$typeString)); - } } \ No newline at end of file diff --git a/src/Fields/VatCodeField.php b/src/Fields/VatCodeField.php index 565a4400..17a44cae 100644 --- a/src/Fields/VatCodeField.php +++ b/src/Fields/VatCodeField.php @@ -21,16 +21,7 @@ public function getVatCode(): ?VatCode { return $this->vatCode; } - - public function getVatCodeToString(): ?string - { - if ($this->getVatCode() != null) { - return $this->vatCode->getCode(); - } else { - return null; - } - } - + /** * @return $this */ @@ -39,16 +30,4 @@ public function setVatCode(?VatCode $vatCode): self $this->vatCode = $vatCode; return $this; } - - /** - * @param string|null $vatCodeString - * @return $this - * @throws Exception - */ - public function setVatCodeFromString(?string $vatCodeString) - { - $vatCode = new VatCode(); - $vatCode->setCode($vatCodeString); - return $this->setVatCode($vatCode); - } } diff --git a/src/Fields/VatValueField.php b/src/Fields/VatValueField.php index 27247b83..a8e8df18 100644 --- a/src/Fields/VatValueField.php +++ b/src/Fields/VatValueField.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\Fields; use Money\Money; -use PhpTwinfield\Util; trait VatValueField { @@ -23,18 +22,6 @@ public function getVatValue(): ?Money return $this->vatValue; } - /** - * @return float|null - */ - public function getVatValueToFloat(): ?float - { - if ($this->getVatValue() != null) { - return Util::formatMoney($this->getVatValue()); - } else { - return 0; - } - } - /** * @param Money|null $vatValue * @return $this @@ -45,18 +32,4 @@ public function setVatValue(?Money $vatValue) return $this; } - - /** - * @param float|null $vatValueFloat - * @return $this - * @throws Exception - */ - public function setVatValueFromFloat(?float $vatValueFloat) - { - if ((float)$vatValueFloat) { - return $this->setVatValue(Money::EUR(100 * $vatValueFloat)); - } else { - return $this->setVatValue(Money::EUR(0)); - } - } } \ No newline at end of file diff --git a/src/FixedAsset.php b/src/FixedAsset.php index c2618fc8..59b9027a 100644 --- a/src/FixedAsset.php +++ b/src/FixedAsset.php @@ -19,7 +19,7 @@ * * @author Yannick Aerssens */ -class FixedAsset extends BaseObject +class FixedAsset extends BaseObject implements HasCodeInterface { use BehaviourField; use CodeField; @@ -38,7 +38,10 @@ class FixedAsset extends BaseObject public function __construct() { - $this->setTypeFromString('AST'); + $dimensionType = new \PhpTwinfield\DimensionType; + $dimensionType->setCode('AST'); + $this->setType($dimensionType); + $this->setFinancials(new FixedAssetFinancials); $this->setFixedAssets(new FixedAssetFixedAssets); } diff --git a/src/GeneralLedger.php b/src/GeneralLedger.php index 05f3e48d..a3774b7f 100644 --- a/src/GeneralLedger.php +++ b/src/GeneralLedger.php @@ -23,7 +23,7 @@ * * @author Yannick Aerssens */ -class GeneralLedger extends BaseObject +class GeneralLedger extends BaseObject implements HasCodeInterface { use BeginPeriodField; use BeginYearField; diff --git a/src/GeneralLedgerFinancials.php b/src/GeneralLedgerFinancials.php index 23837e70..c67e57a7 100644 --- a/src/GeneralLedgerFinancials.php +++ b/src/GeneralLedgerFinancials.php @@ -26,8 +26,8 @@ class GeneralLedgerFinancials extends BaseObject public function __construct() { - $this->setMatchTypeFromString('notmatchable'); - $this->setSubAnalyseFromString('maybe'); + $this->setMatchType(\PhpTwinfield\Enums\MatchType::NOTMATCHABLE()); + $this->setSubAnalyse(\PhpTwinfield\Enums\SubAnalyse::MAYBE()); } public function getChildValidations() diff --git a/src/HasCodeInterface.php b/src/HasCodeInterface.php new file mode 100644 index 00000000..e98e19b9 --- /dev/null +++ b/src/HasCodeInterface.php @@ -0,0 +1,16 @@ + */ -class InvoiceType +class InvoiceType extends BaseObject implements HasCodeInterface { use CodeField; use NameField; diff --git a/src/Mappers/ArticleMapper.php b/src/Mappers/ArticleMapper.php index 4676288b..d96782c7 100644 --- a/src/Mappers/ArticleMapper.php +++ b/src/Mappers/ArticleMapper.php @@ -93,7 +93,7 @@ public static function map(Response $response, AuthenticatedConnection $connecti // Set the inuse and status attributes $articleLine->setInUse($lineElement->getAttribute('inuse')); - $articleLine->setStatusFromString($lineElement->getAttribute('status')); + $articleLine->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $lineElement->getAttribute('status'))); // Set the article line elements $articleLine->setFreeText1(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $articleLine, $lineElement, 'freetext1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index f5737ba2..d39354d0 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -8,8 +8,8 @@ use PhpTwinfield\HasMessageInterface; use PhpTwinfield\Message\Message; use PhpTwinfield\Office; -use PhpTwinfield\Util; use PhpTwinfield\Secure\AuthenticatedConnection; +use PhpTwinfield\Util; use Webmozart\Assert\Assert; abstract class BaseMapper @@ -68,8 +68,8 @@ protected static function getOfficeCurrencies(AuthenticatedConnection $connectio $fullOffice = $officeApiConnector->get($office->getCode()); if ($fullOffice->getResult() == 1) { - $currencies['base'] = $fullOffice->getBaseCurrencyToString(); - $currencies['reporting'] = $fullOffice->getReportingCurrencyToString(); + $currencies['base'] = Util::objectToStr($fullOffice->getBaseCurrency()); + $currencies['reporting'] = Util::objectToStr($fullOffice->getReportingCurrency()); } return $currencies; diff --git a/src/Mappers/CustomerMapper.php b/src/Mappers/CustomerMapper.php index 6e5b8ab9..f2361e39 100644 --- a/src/Mappers/CustomerMapper.php +++ b/src/Mappers/CustomerMapper.php @@ -284,7 +284,7 @@ public static function map(Response $response, AuthenticatedConnection $connecti $customerPostingRule->setCurrency(self::parseObjectAttribute(\PhpTwinfield\Currency::class, $customerPostingRule, $postingruleElement, 'currency', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setDescription(self::getField($postingruleElement, 'description', $customerPostingRule)); - $customerPostingRule->setAmount(self::parseMoneyAttribute(self::getField($postingruleElement, 'amount', $customerPostingRule), $customerPostingRule->getCurrencyToString())); + $customerPostingRule->setAmount(self::parseMoneyAttribute(self::getField($postingruleElement, 'amount', $customerPostingRule), Util::objectToStr($customerPostingRule->getCurrency()))); // Get the lines element $linesDOMTag = $postingruleElement->getElementsByTagName('lines'); diff --git a/src/Mappers/InvoiceMapper.php b/src/Mappers/InvoiceMapper.php index 0bdc4070..6968fe66 100644 --- a/src/Mappers/InvoiceMapper.php +++ b/src/Mappers/InvoiceMapper.php @@ -67,8 +67,8 @@ public static function map(Response $response) $invoiceTotals = new InvoiceTotals(); // Set the invoice totals elements from the totals element - $invoiceTotals->setValueExcl(self::parseMoneyAttribute(self::getField($totalsElement, 'valueexcl', $invoiceTotals), $invoice->getCurrencyToString())) - ->setValueInc(self::parseMoneyAttribute(self::getField($totalsElement, 'valueinc', $invoiceTotals), $invoice->getCurrencyToString())); + $invoiceTotals->setValueExcl(self::parseMoneyAttribute(self::getField($totalsElement, 'valueexcl', $invoiceTotals), Util::objectToStr($invoice->getCurrency()))) + ->setValueInc(self::parseMoneyAttribute(self::getField($totalsElement, 'valueinc', $invoiceTotals), Util::objectToStr($invoice->getCurrency()))); // Set the custom class to the invoice $invoice->setTotals($invoiceTotals); @@ -101,14 +101,14 @@ public static function map(Response $response) ->setPerformanceDate(self::parseDateAttribute(self::getField($lineElement, 'performancedate', $invoiceLine))) ->setPerformanceType(self::parseEnumAttribute(\PhpTwinfield\Enums\PerformanceType::class, self::getField($lineElement, 'performancetype', $invoiceLine))) ->setQuantity(self::getField($lineElement, 'quantity', $invoiceLine)) - ->setSubArticleFromString(self::getField($lineElement, 'subarticle', $invoiceLine)) + ->setSubArticle(self::parseObjectAttribute(\PhpTwinfield\ArticleLine::class, $invoiceLine, $lineElement, 'subarticle')) ->setUnits(self::getField($lineElement, 'units', $invoiceLine)) - ->setUnitsPriceExcl(self::parseMoneyAttribute(self::getField($lineElement, 'unitspriceexcl', $invoiceLine), $invoice->getCurrencyToString())) - ->setUnitsPriceInc(self::parseMoneyAttribute(self::getField($lineElement, 'unitspriceinc', $invoiceLine), $invoice->getCurrencyToString())) - ->setValueExcl(self::parseMoneyAttribute(self::getField($lineElement, 'valueexcl', $invoiceLine), $invoice->getCurrencyToString())) - ->setValueInc(self::parseMoneyAttribute(self::getField($lineElement, 'valueinc', $invoiceLine), $invoice->getCurrencyToString())) + ->setUnitsPriceExcl(self::parseMoneyAttribute(self::getField($lineElement, 'unitspriceexcl', $invoiceLine), Util::objectToStr($invoice->getCurrency()))) + ->setUnitsPriceInc(self::parseMoneyAttribute(self::getField($lineElement, 'unitspriceinc', $invoiceLine), Util::objectToStr($invoice->getCurrency()))) + ->setValueExcl(self::parseMoneyAttribute(self::getField($lineElement, 'valueexcl', $invoiceLine), Util::objectToStr($invoice->getCurrency()))) + ->setValueInc(self::parseMoneyAttribute(self::getField($lineElement, 'valueinc', $invoiceLine), Util::objectToStr($invoice->getCurrency()))) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $invoiceLine, $lineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) - ->setVatValue(self::parseMoneyAttribute(self::getField($lineElement, 'vatvalue', $invoiceLine), $invoice->getCurrencyToString())); + ->setVatValue(self::parseMoneyAttribute(self::getField($lineElement, 'vatvalue', $invoiceLine), Util::objectToStr($invoice->getCurrency()))); // Set the custom class to the invoice $invoice->addLine($invoiceLine); @@ -132,7 +132,7 @@ public static function map(Response $response) $invoiceVatLine->setPerformanceDate(self::parseDateAttribute(self::getField($vatlineElement, 'performancedate', $invoiceVatLine))) ->setPerformanceType(self::parseEnumAttribute(\PhpTwinfield\Enums\PerformanceType::class, self::getField($vatlineElement, 'performancetype', $invoiceVatLine))) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $invoiceVatLine, $vatlineElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) - ->setVatValue(self::parseMoneyAttribute(self::getField($vatlineElement, 'vatvalue', $invoiceVatLine), $invoice->getCurrencyToString())); + ->setVatValue(self::parseMoneyAttribute(self::getField($vatlineElement, 'vatvalue', $invoiceVatLine), Util::objectToStr($invoice->getCurrency()))); // Set the custom class to the invoice $invoice->addVatLine($invoiceVatLine); diff --git a/src/Mappers/SupplierMapper.php b/src/Mappers/SupplierMapper.php index e6375519..eacb4333 100644 --- a/src/Mappers/SupplierMapper.php +++ b/src/Mappers/SupplierMapper.php @@ -227,7 +227,7 @@ public static function map(Response $response) $supplierPostingRule->setCurrency(self::parseObjectAttribute(\PhpTwinfield\Currency::class, $supplierPostingRule, $postingruleElement, 'currency', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setDescription(self::getField($postingruleElement, 'description', $supplierPostingRule)); - $supplierPostingRule->setAmount(self::parseMoneyAttribute(self::getField($postingruleElement, 'amount', $supplierPostingRule), $supplierPostingRule->getCurrencyToString())); + $supplierPostingRule->setAmount(self::parseMoneyAttribute(self::getField($postingruleElement, 'amount', $supplierPostingRule), Util::objectToStr($supplierPostingRule->getCurrency()))); // Get the lines element $linesDOMTag = $postingruleElement->getElementsByTagName('lines'); diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 6498b7c6..b010cac3 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -101,11 +101,11 @@ public static function map(string $transactionClassName, Response $response, Aut $currencies = self::getOfficeCurrencies($connection, $transaction->getOffice()); if (Util::objectUses(CloseAndStartValueFields::class, $transaction)) { - $transaction->setStartValueFromFloat(self::getField($transactionElement, 'startvalue', $transaction)); + $transaction->setStartValue(self::parseMoneyAttribute(self::getField($transactionElement, 'startvalue', $transaction), Util::objectToStr($transaction->getCurrency()))); } if (Util::objectUses(DueDateField::class, $transaction)) { - $transaction->setDueDateFromString(self::getField($transactionElement, 'duedate', $transaction)); + $transaction->setDueDate(self::parseDateAttribute(self::getField($transactionElement, 'duedate', $transaction))); } if (Util::objectUses(InvoiceNumberField::class, $transaction)) { @@ -150,11 +150,11 @@ public static function map(string $transactionClassName, Response $response, Aut $transactionLine ->setBaseValue(self::parseMoneyAttribute(self::getField($lineElement, 'basevalue', $transactionLine), $currencies['base'])) ->setComment(self::getField($lineElement, 'comment', $transactionLine)) - ->setValue(self::parseMoneyAttribute(self::getField($lineElement, 'value', $transactionLine), $transaction->getCurrencyToString())) + ->setValue(self::parseMoneyAttribute(self::getField($lineElement, 'value', $transactionLine), Util::objectToStr($transaction->getCurrency()))) ->setDebitCredit(self::parseEnumAttribute(\PhpTwinfield\Enums\DebitCredit::class, self::getField($lineElement, 'debitcredit', $transactionLine))) ->setDescription(self::getField($lineElement, 'description', $transactionLine)) ->setDestOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $transactionLine, $lineElement, 'destoffice')) - ->setDim1(self::parseObjectAttribute(\PhpTwinfield\Dummy::class, $transactionLine, $lineElement, 'dim1')) + ->setDim1(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) ->setId($lineElement->getAttribute('id')) ->setLineType(self::parseEnumAttribute(\PhpTwinfield\Enums\LineType::class, $lineType)) ->setMatchStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\MatchStatus::class, self::getField($lineElement, 'matchstatus', $transactionLine))) @@ -176,8 +176,8 @@ public static function map(string $transactionClassName, Response $response, Aut $transactionLine->setBaseValueOpen(self::parseMoneyAttribute($baseValueOpen, $currencies['base'])); } - $transactionLine->setDim2(self::parseObjectAttribute(\PhpTwinfield\Dummy::class, $transactionLine, $lineElement, 'dim2')); - $transactionLine->setDim3(self::parseObjectAttribute(\PhpTwinfield\Dummy::class, $transactionLine, $lineElement, 'dim3')); + $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) + $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) $transactionLine->setMatchLevel(self::getField($lineElement, 'matchlevel', $transactionLine)); $transactionLine->setRelation(self::getField($lineElement, 'relation', $transactionLine)); $transactionLine->setRepValueOpen(self::parseMoneyAttribute(self::getField($lineElement, 'repvalueopen', $transactionLine), $currencies['reporting'])); @@ -186,12 +186,12 @@ public static function map(string $transactionClassName, Response $response, Aut if ($transaction instanceof PurchaseTransaction || $transaction instanceof SalesTransaction) { if ($lineType == LineType::DETAIL()) { - $transactionLine->setDim2(self::parseObjectAttribute(\PhpTwinfield\Dummy::class, $transactionLine, $lineElement, 'dim2')); - $transactionLine->setDim3(self::parseObjectAttribute(\PhpTwinfield\Dummy::class, $transactionLine, $lineElement, 'dim3')); + $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) + $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) } elseif ($transaction instanceof PurchaseTransaction && $lineType == LineType::VAT()) { - $transactionLine->setDim3(self::parseObjectAttribute(\PhpTwinfield\Dummy::class, $transactionLine, $lineElement, 'dim3')); + $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) } elseif ($lineType == LineType::TOTAL()) { - $transactionLine->setDim2(self::parseObjectAttribute(\PhpTwinfield\Dummy::class, $transactionLine, $lineElement, 'dim2')); + $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) $baseValueOpen = self::getField($lineElement, 'basevalueopen', $transactionLine) ?: self::getField($lineElement, 'openbasevalue', $transactionLine); @@ -216,7 +216,7 @@ public static function map(string $transactionClassName, Response $response, Aut $transactionLine->setVatBaseValue(self::parseMoneyAttribute(self::getField($lineElement, 'vatbasevalue', $transactionLine), $currencies['base'])); $transactionLine->setVatRepValue(self::parseMoneyAttribute(self::getField($lineElement, 'vatrepvalue', $transactionLine), $currencies['reporting'])); - $transactionLine->setVatValue(self::parseMoneyAttribute(self::getField($lineElement, 'vatvalue', $transactionLine), $transaction->getCurrencyToString())); + $transactionLine->setVatValue(self::parseMoneyAttribute(self::getField($lineElement, 'vatvalue', $transactionLine), Util::objectToStr($transaction->getCurrency()))); } elseif ($lineType == LineType::VAT()) { if (Util::objectUses(BaselineField::class, $transactionLine)) { $transactionLine->setBaseline(self::getField($lineElement, 'baseline', $transactionLine)); @@ -224,7 +224,7 @@ public static function map(string $transactionClassName, Response $response, Aut $transactionLine->setVatBaseTurnover(self::parseMoneyAttribute(self::getField($lineElement, 'vatbaseturnover', $transactionLine), $currencies['base'])); $transactionLine->setVatRepTurnover(self::parseMoneyAttribute(self::getField($lineElement, 'vatrepturnover', $transactionLine), $currencies['reporting'])); - $transactionLine->setVatTurnover(self::parseMoneyAttribute(self::getField($lineElement, 'vatturnover', $transactionLine), $transaction->getCurrencyToString())); + $transactionLine->setVatTurnover(self::parseMoneyAttribute(self::getField($lineElement, 'vatturnover', $transactionLine), Util::objectToStr($transaction->getCurrency()))); } elseif ($lineType == LineType::TOTAL()) { if (Util::objectUses(MatchDateField::class, $transactionLine)) { $transactionLine->setMatchDate(self::parseDateAttribute(self::getField($lineElement, 'matchdate', $transactionLine))); @@ -234,7 +234,7 @@ public static function map(string $transactionClassName, Response $response, Aut $valueOpen = self::getField($lineElement, 'valueopen', $transactionLine) ?: self::getField($lineElement, 'openvalue', $transactionLine); if ($valueOpen) { - $transactionLine->setValueOpen(self::parseMoneyAttribute($valueOpen, $transaction->getCurrencyToString())); + $transactionLine->setValueOpen(self::parseMoneyAttribute($valueOpen, Util::objectToStr($transaction->getCurrency()))); } } @@ -247,7 +247,7 @@ public static function map(string $transactionClassName, Response $response, Aut } if (Util::objectUses(VatTotalField::class, $transactionLine)) { - $transactionLine->setVatTotal(self::parseMoneyAttribute(self::getField($lineElement, 'vattotal', $transactionLine), $transaction->getCurrencyToString())); + $transactionLine->setVatTotal(self::parseMoneyAttribute(self::getField($lineElement, 'vattotal', $transactionLine), Util::objectToStr($transaction->getCurrency()))); } } diff --git a/src/Office.php b/src/Office.php index 59380bcb..56d6c365 100644 --- a/src/Office.php +++ b/src/Office.php @@ -16,7 +16,7 @@ use PhpTwinfield\Fields\TouchedField; use PhpTwinfield\Fields\UserField; -class Office extends BaseObject +class Office extends BaseObject implements HasCodeInterface { use BaseCurrencyField; use CodeField; diff --git a/src/PayCode.php b/src/PayCode.php index 3c9ad9ec..58d8f5b3 100644 --- a/src/PayCode.php +++ b/src/PayCode.php @@ -11,7 +11,7 @@ * * @author Yannick Aerssens */ -class PayCode +class PayCode extends BaseObject implements HasCodeInterface { use CodeField; use NameField; diff --git a/src/Project.php b/src/Project.php index c0dca89f..34879d34 100644 --- a/src/Project.php +++ b/src/Project.php @@ -19,7 +19,7 @@ * * @author Yannick Aerssens */ -class Project extends BaseObject +class Project extends BaseObject implements HasCodeInterface { use BehaviourField; use CodeField; @@ -37,7 +37,10 @@ class Project extends BaseObject public function __construct() { - $this->setTypeFromString('PRJ'); + $dimensionType = new \PhpTwinfield\DimensionType; + $dimensionType->setCode('PRJ'); + $this->setType($dimensionType); + $this->setProjects(new ProjectProjects); } diff --git a/src/Rate.php b/src/Rate.php index 01e6ad7c..73ba0b22 100644 --- a/src/Rate.php +++ b/src/Rate.php @@ -20,7 +20,7 @@ * * @author Yannick Aerssens */ -class Rate extends BaseObject +class Rate extends BaseObject implements HasCodeInterface { use CodeField; use CreatedField; diff --git a/src/Supplier.php b/src/Supplier.php index 1c2e9c63..b9c24e22 100644 --- a/src/Supplier.php +++ b/src/Supplier.php @@ -29,7 +29,7 @@ * @see https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers * @todo Add documentation and typehints to all properties. */ -class Supplier extends BaseObject +class Supplier extends BaseObject implements HasCodeInterface { use BeginPeriodField; use BeginYearField; @@ -66,7 +66,10 @@ public function __construct() $this->setBeginYear(0); $this->setEndPeriod(0); $this->setEndYear(0); - $this->setTypeFromString('CRD'); + + $dimensionType = new \PhpTwinfield\DimensionType; + $dimensionType->setCode('CRD'); + $this->setType($dimensionType); $this->setFinancials(new SupplierFinancials); } diff --git a/src/SupplierFinancials.php b/src/SupplierFinancials.php index aeaf355a..ec702091 100644 --- a/src/SupplierFinancials.php +++ b/src/SupplierFinancials.php @@ -44,10 +44,10 @@ class SupplierFinancials extends BaseObject public function __construct() { - $this->setAccountTypeFromString('inherit'); + $this->setAccountType(\PhpTwinfield\Enums\AccountType::INHERIT()); $this->setDueDays(30); - $this->setMatchTypeFromString('customersupplier'); - $this->setSubAnalyseFromString('false'); + $this->setMatchType(\PhpTwinfield\Enums\MatchType::CUSTOMERSUPPLIER()); + $this->setSubAnalyse(\PhpTwinfield\Enums\SubAnalyse::FALSE()); $this->setSubstitutionLevel(1); } diff --git a/src/User.php b/src/User.php index 5b1597ea..46c904cb 100644 --- a/src/User.php +++ b/src/User.php @@ -28,7 +28,7 @@ use PhpTwinfield\Fields\User\TypeField; use PhpTwinfield\Fields\User\TypeLockedField; -class User extends BaseObject +class User extends BaseObject implements HasCodeInterface { use AcceptExtraCostField; use CodeField; diff --git a/src/UserRole.php b/src/UserRole.php index 1ab3720c..de040099 100644 --- a/src/UserRole.php +++ b/src/UserRole.php @@ -12,7 +12,7 @@ * * @author Yannick Aerssens */ -class UserRole +class UserRole extends BaseObject implements HasCodeInterface { use CodeField; use LevelField; diff --git a/src/Util.php b/src/Util.php index 93d56507..ebb508d1 100644 --- a/src/Util.php +++ b/src/Util.php @@ -100,6 +100,19 @@ public static function parseBoolean(?string $value): bool return filter_var($value, FILTER_VALIDATE_BOOLEAN); } + /** + * @param HasCodeInterface|null $object + * @return string|null + */ + public static function objectToStr(?HasCodeInterface $object): ?string + { + if ($object === null) { + return null; + } + + return $object->getCode(); + } + /** * Get all the traits an object uses, includes traits from all parent classes. * diff --git a/src/VatCode.php b/src/VatCode.php index 6b9db814..c0015b5e 100644 --- a/src/VatCode.php +++ b/src/VatCode.php @@ -19,7 +19,7 @@ * * @author Emile Bons , extended by Yannick Aerssens */ -class VatCode extends BaseObject +class VatCode extends BaseObject implements HasCodeInterface { use CodeField; use CreatedField; diff --git a/src/VatGroup.php b/src/VatGroup.php index 5f3aa1c3..9c3a9475 100644 --- a/src/VatGroup.php +++ b/src/VatGroup.php @@ -11,7 +11,7 @@ * * @author Yannick Aerssens */ -class VatGroup +class VatGroup extends BaseObject implements HasCodeInterface { use CodeField; use NameField; diff --git a/src/VatGroupCountry.php b/src/VatGroupCountry.php index f5856f53..7e862da5 100644 --- a/src/VatGroupCountry.php +++ b/src/VatGroupCountry.php @@ -11,7 +11,7 @@ * * @author Yannick Aerssens */ -class VatGroupCountry +class VatGroupCountry extends BaseObject implements HasCodeInterface { use CodeField; use NameField; From 9370f473b2d1ef8957f62172827a1ac02ce5542e Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 22 Jun 2019 12:07:38 +0200 Subject: [PATCH 323/388] Upload --- src/DomDocuments/CostCentersDocument.php | 1 + src/Fields/Transaction/TransactionLine/VatBaseValueField.php | 2 +- src/Mappers/TransactionMapper.php | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/DomDocuments/CostCentersDocument.php b/src/DomDocuments/CostCentersDocument.php index 7f6097db..1e709f77 100644 --- a/src/DomDocuments/CostCentersDocument.php +++ b/src/DomDocuments/CostCentersDocument.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\DomDocuments; use PhpTwinfield\CostCenter; +use PhpTwinfield\Util; /** * The Document Holder for making new XML CostCenter. Is a child class diff --git a/src/Fields/Transaction/TransactionLine/VatBaseValueField.php b/src/Fields/Transaction/TransactionLine/VatBaseValueField.php index fe56a4bb..0b948aa5 100644 --- a/src/Fields/Transaction/TransactionLine/VatBaseValueField.php +++ b/src/Fields/Transaction/TransactionLine/VatBaseValueField.php @@ -3,7 +3,7 @@ namespace PhpTwinfield\Fields\Transaction\TransactionLine; use Money\Money; -s + trait VatBaseValueField { /** diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index b010cac3..2318e1bb 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -176,8 +176,8 @@ public static function map(string $transactionClassName, Response $response, Aut $transactionLine->setBaseValueOpen(self::parseMoneyAttribute($baseValueOpen, $currencies['base'])); } - $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) - $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) + $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); + $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); $transactionLine->setMatchLevel(self::getField($lineElement, 'matchlevel', $transactionLine)); $transactionLine->setRelation(self::getField($lineElement, 'relation', $transactionLine)); $transactionLine->setRepValueOpen(self::parseMoneyAttribute(self::getField($lineElement, 'repvalueopen', $transactionLine), $currencies['reporting'])); From 09f4cfd9782788bb2bdf7014f3636b87ca9a5879 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 22 Jun 2019 12:26:41 +0200 Subject: [PATCH 324/388] Upload --- src/Mappers/TransactionMapper.php | 8 +- src/Util.php | 83 ++++++++++++++----- .../BankTransactionIntegrationTest.php | 13 +-- .../BrowseDataApiConnectorTest.php | 5 +- .../CashTransactionIntegrationTest.php | 13 +-- .../CustomerIntegrationTest.php | 15 ++-- .../InvoiceIntegrationTest.php | 37 +++++---- .../JournalTransactionIntegrationTest.php | 19 +++-- .../PurchaseTransactionIntegrationTest.php | 17 ++-- .../SalesTransactionIntegrationTest.php | 21 ++--- .../ApiConnectors/InvoiceApiConnectorTest.php | 3 +- .../TransactionApiConnectorTest.php | 3 +- .../UnitTests/BankTransactionLineUnitTest.php | 5 +- tests/UnitTests/BankTransactionUnitTest.php | 7 +- .../UnitTests/CashTransactionLineUnitTest.php | 5 +- tests/UnitTests/CashTransactionUnitTest.php | 7 +- .../ElectronicBankStatementUnitTest.php | 3 +- 17 files changed, 162 insertions(+), 102 deletions(-) diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 2318e1bb..6ff92484 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -186,12 +186,12 @@ public static function map(string $transactionClassName, Response $response, Aut if ($transaction instanceof PurchaseTransaction || $transaction instanceof SalesTransaction) { if ($lineType == LineType::DETAIL()) { - $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) - $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) + $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); + $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); } elseif ($transaction instanceof PurchaseTransaction && $lineType == LineType::VAT()) { - $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) + $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); } elseif ($lineType == LineType::TOTAL()) { - $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) + $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); $baseValueOpen = self::getField($lineElement, 'basevalueopen', $transactionLine) ?: self::getField($lineElement, 'openbasevalue', $transactionLine); diff --git a/src/Util.php b/src/Util.php index ebb508d1..cb64e2b3 100644 --- a/src/Util.php +++ b/src/Util.php @@ -11,15 +11,36 @@ final class Util { - public static function formatMoney(Money $money): string + /** + * Format a money object to string according to Twinfield specifications. + * + * @param Money|null $money + * @return string|null + */ + public static function formatMoney(?Money $money): ?string { + if ($money === null) { + return null; + } + $decimalformatter = new DecimalMoneyFormatter(new ISOCurrencies()); return $decimalformatter->format($money); } - public static function parseMoney(string $moneyString, Currency $currency): Money + /** + * Parse a money string and Currency object. + * + * @param string|null $moneyString + * @param Currency|null $currency + * @return Money|null + */ + public static function parseMoney(?string $moneyString, ?Currency $currency): ?Money { + if ($moneyString === null || $currency === null) { + return null; + } + $parser = new DecimalMoneyParser(new ISOCurrencies()); return $parser->parse($moneyString, $currency); } @@ -27,23 +48,31 @@ public static function parseMoney(string $moneyString, Currency $currency): Mone /** * Format a date according to Twinfield specifications. * - * @param \DateTimeInterface $date - * @return string + * @param \DateTimeInterface|null $date + * @return string|null */ - public static function formatDate(\DateTimeInterface $date): string + public static function formatDate(?\DateTimeInterface $date): ?string { + if ($date === null) { + return null; + } + return $date->format("Ymd"); } /** * Parse a date string from a Twinfield XML. * - * @param string $dateString - * @return \DateTimeImmutable + * @param string|null $dateString + * @return \DateTimeImmutable|null * @throws Exception */ - public static function parseDate(string $dateString): \DateTimeImmutable + public static function parseDate(?string $dateString): ?\DateTimeImmutable { + if ($dateString === null) { + return null; + } + $date = \DateTimeImmutable::createFromFormat("Ymd|", $dateString); if (false === $date) { @@ -56,23 +85,31 @@ public static function parseDate(string $dateString): \DateTimeImmutable /** * Format a date time according to Twinfield specifications. * - * @param \DateTimeInterface $datetime - * @return string + * @param \DateTimeInterface|null $datetime + * @return string|null */ - public static function formatDateTime(\DateTimeInterface $datetime): string + public static function formatDateTime(?\DateTimeInterface $datetime): ?string { + if ($datetime === null) { + return null; + } + return $datetime->format("YmdHis"); } /** * Parse a date time string from a Twinfield XML. * - * @param string $dateString - * @return \DateTimeImmutable + * @param string|null $dateString + * @return \DateTimeImmutable|null * @throws Exception */ - public static function parseDateTime(string $dateString): \DateTimeImmutable + public static function parseDateTime(?string $dateString): ?\DateTimeImmutable { + if ($dateString === null) { + return null; + } + $date = \DateTimeImmutable::createFromFormat("YmdHis", $dateString); if (false === $date) { @@ -83,20 +120,28 @@ public static function parseDateTime(string $dateString): \DateTimeImmutable } /** - * @param bool $boolean - * @return string + * @param bool|null $boolean + * @return string|null */ - public static function formatBoolean(bool $boolean): string + public static function formatBoolean(?bool $boolean): ?string { + if ($boolean === null) { + return null; + } + return $boolean ? "true" : "false"; } /** * @param string|null $value - * @return bool + * @return bool|null */ - public static function parseBoolean(?string $value): bool + public static function parseBoolean(?string $value): ?bool { + if ($value === null) { + return null; + } + return filter_var($value, FILTER_VALIDATE_BOOLEAN); } diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index b8aa0c6b..e93775a6 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -17,6 +17,7 @@ use PhpTwinfield\Mappers\TransactionMapper; use PhpTwinfield\Office; use PhpTwinfield\Response\Response; +use PhpTwinfield\Util; /** * @runTestsInSeparateProcesses @@ -76,7 +77,7 @@ public function testGetBankTransactionWorks() $this->assertSame('BNK', $bankTransaction->getCode()); $this->assertSame(201300008, $bankTransaction->getNumber()); $this->assertSame('2013/11', $bankTransaction->getPeriod()); - $this->assertEquals('EUR', $bankTransaction->getCurrencyToString()); + $this->assertEquals('EUR', Util::objectToStr($bankTransaction->getCurrency())); $this->assertEquals(new DateTimeImmutable('2013-11-04'), $bankTransaction->getDate()); $this->assertSame('import', $bankTransaction->getOrigin()); $this->assertNull($bankTransaction->getFreetext1()); @@ -93,7 +94,7 @@ public function testGetBankTransactionWorks() $this->assertEquals(LineType::TOTAL(), $totalLine->getLineType()); $this->assertSame(1, $totalLine->getId()); - $this->assertSame('1001', $totalLine->getDim1ToString()); + $this->assertSame('1001', Util::objectToStr($totalLine->getDim1())); $this->assertEquals(DebitCredit::DEBIT(), $totalLine->getDebitCredit()); $this->assertEquals(Money::EUR(43555), $totalLine->getValue()); $this->assertEquals(Money::EUR(43555), $totalLine->getBaseValue()); @@ -115,8 +116,8 @@ public function testGetBankTransactionWorks() $this->assertEquals(LineType::DETAIL(), $detailLine->getLineType()); $this->assertSame(2, $detailLine->getId()); - $this->assertSame('1300', $detailLine->getDim1ToString()); - $this->assertSame('1000', $detailLine->getDim2ToString()); + $this->assertSame('1300', Util::objectToStr($detailLine->getDim1())); + $this->assertSame('1000', Util::objectToStr($detailLine->getDim2())); $this->assertEquals(DebitCredit::CREDIT(), $detailLine->getDebitCredit()); $this->assertEquals(Money::EUR(43555), $detailLine->getValue()); $this->assertEquals(Money::EUR(43555), $totalLine->getBaseValue()); @@ -129,13 +130,13 @@ public function testGetBankTransactionWorks() $this->assertSame(2, $detailLine->getMatchLevel()); $this->assertEquals(Money::EUR(43555), $detailLine->getBaseValueOpen()); $this->assertEquals(Money::USD(65333), $detailLine->getRepValue()); - $this->assertNull($detailLine->getVatCodeToString()); + $this->assertNull(Util::objectToStr($detailLine->getVatCode())); $this->assertNull($detailLine->getVatValue()); $this->assertNull($detailLine->getVatTotal()); $this->assertNull($detailLine->getVatBaseTotal()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); $this->assertSame($ReflectObject->getConstant('EMPTY'), (string)$detailLine->getPerformanceType()); - $this->assertNull($detailLine->getPerformanceCountryToString()); + $this->assertNull(Util::objectToStr($detailLine->getPerformanceCountry())); $this->assertNull($detailLine->getPerformanceVatNumber()); $this->assertNull($detailLine->getPerformanceDate()); } diff --git a/tests/IntegrationTests/BrowseDataApiConnectorTest.php b/tests/IntegrationTests/BrowseDataApiConnectorTest.php index 490c46e8..d34c0e7a 100644 --- a/tests/IntegrationTests/BrowseDataApiConnectorTest.php +++ b/tests/IntegrationTests/BrowseDataApiConnectorTest.php @@ -7,6 +7,7 @@ use PhpTwinfield\BrowseDefinition; use PhpTwinfield\Enums\BrowseColumnOperator; use PhpTwinfield\Response\Response; +use PhpTwinfield\Util; class BrowseDataApiConnectorTest extends BaseIntegrationTest { @@ -37,7 +38,7 @@ public function testGetBrowseDefinition() $this->assertInstanceOf(BrowseDefinition::class, $browseDefinition); - $this->assertEquals('001', $browseDefinition->getOfficeToString()); + $this->assertEquals('001', Util::objectToStr($browseDefinition->getOffice())); $this->assertEquals('000', $browseDefinition->getCode()); $this->assertEquals('General ledger transactions', $browseDefinition->getName()); $this->assertEquals('General ledger transactions', $browseDefinition->getShortName()); @@ -207,7 +208,7 @@ public function testGetBrowseData() // Rows $row1 = $browseData->getRows()[0]; $this->assertCount(6, $browseData->getRows()); - $this->assertEquals('001', $row1->getOfficeToString()); + $this->assertEquals('001', Util::objectToStr($row1->getOffice())); $this->assertEquals('BNK', $row1->getCode()); $this->assertEquals('201300001', $row1->getNumber()); $this->assertEquals('2', $row1->getLine()); diff --git a/tests/IntegrationTests/CashTransactionIntegrationTest.php b/tests/IntegrationTests/CashTransactionIntegrationTest.php index 955e144e..2e52d504 100644 --- a/tests/IntegrationTests/CashTransactionIntegrationTest.php +++ b/tests/IntegrationTests/CashTransactionIntegrationTest.php @@ -17,6 +17,7 @@ use PhpTwinfield\Mappers\TransactionMapper; use PhpTwinfield\Office; use PhpTwinfield\Response\Response; +use PhpTwinfield\Util; /** * @runTestsInSeparateProcesses @@ -76,7 +77,7 @@ public function testGetCashTransactionWorks() $this->assertSame('CASH', $cashTransaction->getCode()); $this->assertSame(201300008, $cashTransaction->getNumber()); $this->assertSame('2013/11', $cashTransaction->getPeriod()); - $this->assertEquals('EUR', $cashTransaction->getCurrencyToString()); + $this->assertEquals('EUR', Util::objectToStr($cashTransaction->getCurrency())); $this->assertEquals(new DateTimeImmutable('2013-11-04'), $cashTransaction->getDate()); $this->assertSame('import', $cashTransaction->getOrigin()); $this->assertNull($cashTransaction->getFreetext1()); @@ -93,7 +94,7 @@ public function testGetCashTransactionWorks() $this->assertEquals(LineType::TOTAL(), $totalLine->getLineType()); $this->assertSame(1, $totalLine->getId()); - $this->assertSame('1002', $totalLine->getDim1ToString()); + $this->assertSame('1002', Util::objectToStr($totalLine->getDim1())); $this->assertEquals(DebitCredit::DEBIT(), $totalLine->getDebitCredit()); $this->assertEquals(Money::EUR(43555), $totalLine->getValue()); $this->assertEquals(Money::EUR(43555), $totalLine->getBaseValue()); @@ -115,8 +116,8 @@ public function testGetCashTransactionWorks() $this->assertEquals(LineType::DETAIL(), $detailLine->getLineType()); $this->assertSame(2, $detailLine->getId()); - $this->assertSame('1300', $detailLine->getDim1ToString()); - $this->assertSame('1000', $detailLine->getDim2ToString()); + $this->assertSame('1300', Util::objectToStr($detailLine->getDim1())); + $this->assertSame('1000', Util::objectToStr($detailLine->getDim2())); $this->assertEquals(DebitCredit::CREDIT(), $detailLine->getDebitCredit()); $this->assertEquals(Money::EUR(43555), $detailLine->getValue()); $this->assertEquals(Money::EUR(43555), $totalLine->getBaseValue()); @@ -129,13 +130,13 @@ public function testGetCashTransactionWorks() $this->assertSame(2, $detailLine->getMatchLevel()); $this->assertEquals(Money::EUR(43555), $detailLine->getBaseValueOpen()); $this->assertEquals(Money::USD(65333), $detailLine->getRepValue()); - $this->assertNull($detailLine->getVatCodeToString()); + $this->assertNull(Util::objectToStr($detailLine->getVatCode())); $this->assertNull($detailLine->getVatValue()); $this->assertNull($detailLine->getVatTotal()); $this->assertNull($detailLine->getVatBaseTotal()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); $this->assertSame($ReflectObject->getConstant('EMPTY'), (string)$detailLine->getPerformanceType()); - $this->assertNull($detailLine->getPerformanceCountryToString()); + $this->assertNull(Util::objectToStr($detailLine->getPerformanceCountry())); $this->assertNull($detailLine->getPerformanceVatNumber()); $this->assertNull($detailLine->getPerformanceDate()); } diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index f535a097..987553be 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -14,6 +14,7 @@ use PhpTwinfield\Mappers\CustomerMapper; use PhpTwinfield\Office; use PhpTwinfield\Response\Response; +use PhpTwinfield\Util; /** * @runTestsInSeparateProcesses @@ -70,8 +71,8 @@ public function testGetCustomerWorks() $customer = $this->customerApiConnector->get('CODE', Office::fromCode('001')); $this->assertInstanceOf(Customer::class, $customer); - $this->assertSame('001', $customer->getOfficeToString()); - $this->assertSame('DEB', $customer->getTypeToString()); + $this->assertSame('001', Util::objectToStr($customer->getOffice())); + $this->assertSame('DEB', Util::objectToStr($customer->getType())); $this->assertSame('Customer 0', $customer->getName()); $this->assertSame('http://www.example.com', $customer->getWebsite()); @@ -79,9 +80,9 @@ public function testGetCustomerWorks() $financials = $customer->getFinancials(); $this->assertSame(30, $financials->getDueDays()); $this->assertSame(true, $financials->getPayAvailable()); - $this->assertSame('SEPANLDD', $financials->getPayCodeToString()); + $this->assertSame('SEPANLDD', Util::objectToStr($financials->getPayCode())); $this->assertSame(false, $financials->getEBilling()); - $this->assertSame('VN', $financials->getVatCodeToString()); + $this->assertSame('VN', Util::objectToStr($financials->getVatCode())); // Collect Mandate $collectMandate = $financials->getCollectMandate(); @@ -102,7 +103,7 @@ public function testGetCustomerWorks() $this->assertSame($ReflectObject->getConstant('INVOICE'), (string)$address->getType()); $this->assertSame(true, $address->getDefault()); $this->assertSame('Customer 0', $address->getName()); - $this->assertSame('NL', $address->getCountryToString()); + $this->assertSame('NL', Util::objectToStr($address->getCountry())); $this->assertSame('Place', $address->getCity()); $this->assertSame('1000', $address->getPostcode()); $this->assertSame('010-123452000', $address->getTelephone()); @@ -130,7 +131,7 @@ public function testGetCustomerWorks() $this->assertSame('ABN Amro', $bank->getBankName()); $this->assertSame('ABNANL2A', $bank->getBicCode()); $this->assertSame('Place', $bank->getCity()); - $this->assertSame('NL', $bank->getCountryToString()); + $this->assertSame('NL', Util::objectToStr($bank->getCountry())); $this->assertSame('NL02ABNA0123456789', $bank->getIban()); $this->assertNull($bank->getNatBicCode()); $this->assertNull($bank->getPostcode()); @@ -152,7 +153,7 @@ public function testGetCustomerWorks() // Creditmanagement $creditmanagement = $customer->getCreditManagement(); - $this->assertNull($creditmanagement->getResponsibleUserToString()); + $this->assertNull(Util::objectToStr($creditmanagement->getResponsibleUser())); $this->assertSame(0.00, $creditmanagement->getBaseCreditLimitToFloat()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\SendReminder'); $this->assertSame($ReflectObject->getConstant('TRUE'), (string)$creditmanagement->getSendReminder()); diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 6fc331ad..92cad3e9 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -15,6 +15,7 @@ use PhpTwinfield\Mappers\InvoiceMapper; use PhpTwinfield\Office; use PhpTwinfield\Response\Response; +use PhpTwinfield\Util; /** * @runTestsInSeparateProcesses @@ -67,15 +68,15 @@ public function testGetConceptInvoiceWorks() $this->assertInstanceOf(Invoice::class, $invoice); $this->assertEquals(Office::fromCode("11024"), $invoice->getOffice()); - $this->assertSame('FACTUUR', $invoice->getInvoiceTypeToString()); + $this->assertSame('FACTUUR', Util::objectToStr($invoice->getInvoiceType())); $this->assertSame('5', $invoice->getInvoiceNumber()); - $this->assertSame('20120831', $invoice->getInvoiceDateToString()); - $this->assertSame('BNK', $invoice->getBankToString()); + $this->assertSame('20120831', Util::formatDate($invoice->getInvoiceDate())); + $this->assertSame('BNK', Util::objectToStr($invoice->getBank())); $this->assertSame(1, $invoice->getInvoiceAddressNumber()); $this->assertSame(1, $invoice->getDeliverAddressNumber()); - $this->assertSame('1000', $invoice->getCustomerToString()); + $this->assertSame('1000', Util::objectToStr($invoice->getCustomer())); $this->assertSame('2012/08', $invoice->getPeriod()); - $this->assertSame('EUR', $invoice->getCurrencyToString()); + $this->assertSame('EUR', Util::objectToStr($invoice->getCurrency())); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\InvoiceStatus'); $this->assertSame($ReflectObject->getConstant('CONCEPT'), (string)$invoice->getStatus()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PaymentMethod'); @@ -91,7 +92,7 @@ public function testGetConceptInvoiceWorks() $invoiceLine = $invoiceLines[0]; $this->assertSame(1, $invoiceLine->getID()); - $this->assertSame('0', $invoiceLine->getArticleToString()); + $this->assertSame('0', Util::objectToStr($invoiceLine->getArticle())); $this->assertSame('118', $invoiceLine->getSubArticleToString()); $this->assertSame(1.0, $invoiceLine->getQuantity()); $this->assertSame(1, $invoiceLine->getUnits()); @@ -101,7 +102,7 @@ public function testGetConceptInvoiceWorks() $this->assertSame(0.00, $invoiceLine->getVatValueToFloat()); $this->assertSame(15.00, $invoiceLine->getValueIncToFloat()); $this->assertSame(15.00, $invoiceLine->getUnitsPriceExclToFloat()); - $this->assertSame('8020', $invoiceLine->getDim1ToString()); + $this->assertSame('8020', Util::objectToStr($invoiceLine->getDim1())); $invoiceVatLines = $invoice->getVatLines(); $this->assertCount(1, $invoiceVatLines); @@ -109,10 +110,10 @@ public function testGetConceptInvoiceWorks() /** @var InvoiceVatLine $invoiceVatLine */ $invoiceVatLine = current($invoiceVatLines); - $this->assertSame('VN', $invoiceLine->getVatCodeToString()); + $this->assertSame('VN', Util::objectToStr($invoiceLine->getVatCode())); $this->assertSame(0.00, $invoiceLine->getVatValueToFloat()); $this->assertNull($invoiceLine->getPerformanceType()); - $this->assertNull($invoiceLine->getPerformanceDateToString()); + $this->assertNull($invoiceLine->getPerformanceDate()); $this->assertSame(15.00, $invoice->getTotals()->getValueIncToFloat()); $this->assertSame(15.00, $invoice->getTotals()->getValueExclToFloat()); @@ -135,15 +136,15 @@ public function testGetFinalInvoiceWorks() $this->assertInstanceOf(Invoice::class, $invoice); $this->assertEquals(Office::fromCode("11024"), $invoice->getOffice()); - $this->assertSame('FACTUUR', $invoice->getInvoiceTypeToString()); + $this->assertSame('FACTUUR', Util::objectToStr($invoice->getInvoiceType())); $this->assertSame('5', $invoice->getInvoiceNumber()); - $this->assertSame('20120831', $invoice->getInvoiceDateToString()); - $this->assertSame('BNK', $invoice->getBankToString()); + $this->assertSame('20120831', Util::parseDate($invoice->getInvoiceDate())); + $this->assertSame('BNK', Util::objectToStr($invoice->getBank())); $this->assertSame(1, $invoice->getInvoiceAddressNumber()); $this->assertSame(1, $invoice->getDeliverAddressNumber()); - $this->assertSame('1000', $invoice->getCustomerToString()); + $this->assertSame('1000', Util::objectToStr($invoice->getCustomer())); $this->assertSame('2012/08', $invoice->getPeriod()); - $this->assertSame('EUR', $invoice->getCurrencyToString()); + $this->assertSame('EUR', Util::objectToStr($invoice->getCurrency())); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\InvoiceStatus'); $this->assertSame($ReflectObject->getConstant('FINAL'), (string)$invoice->getStatus()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PaymentMethod'); @@ -159,7 +160,7 @@ public function testGetFinalInvoiceWorks() $invoiceLine = $invoiceLines[0]; $this->assertSame(1, $invoiceLine->getID()); - $this->assertSame('0', $invoiceLine->getArticleToString()); + $this->assertSame('0', Util::objectToStr($invoiceLine->getArticle())); $this->assertSame('118', $invoiceLine->getSubArticleToString()); $this->assertSame(1.0, $invoiceLine->getQuantity()); $this->assertSame(1, $invoiceLine->getUnits()); @@ -169,7 +170,7 @@ public function testGetFinalInvoiceWorks() $this->assertSame(0.00, $invoiceLine->getVatValueToFloat()); $this->assertSame(15.00, $invoiceLine->getValueIncToFloat()); $this->assertSame(15.00, $invoiceLine->getUnitsPriceExclToFloat()); - $this->assertSame('8020', $invoiceLine->getDim1ToString()); + $this->assertSame('8020', Util::objectToStr($invoiceLine->getDim1())); $invoiceVatLines = $invoice->getVatLines(); $this->assertCount(1, $invoiceVatLines); @@ -177,10 +178,10 @@ public function testGetFinalInvoiceWorks() /** @var InvoiceVatLine $invoiceVatLine */ $invoiceVatLine = current($invoiceVatLines); - $this->assertSame('VN', $invoiceLine->getVatCodeToString()); + $this->assertSame('VN', Util::objectToStr($invoiceLine->getVatCode())); $this->assertSame(0.00, $invoiceLine->getVatValueToFloat()); $this->assertNull($invoiceLine->getPerformanceType()); - $this->assertNull($invoiceLine->getPerformanceDateToString()); + $this->assertNull($invoiceLine->getPerformanceDate()); $this->assertSame(15.00, $invoice->getTotals()->getValueIncToFloat()); $this->assertSame(15.00, $invoice->getTotals()->getValueExclToFloat()); diff --git a/tests/IntegrationTests/JournalTransactionIntegrationTest.php b/tests/IntegrationTests/JournalTransactionIntegrationTest.php index 33ebc23d..e3ec821d 100644 --- a/tests/IntegrationTests/JournalTransactionIntegrationTest.php +++ b/tests/IntegrationTests/JournalTransactionIntegrationTest.php @@ -16,6 +16,7 @@ use PhpTwinfield\Mappers\TransactionMapper; use PhpTwinfield\Office; use PhpTwinfield\Response\Response; +use PhpTwinfield\Util; /** * @runTestsInSeparateProcesses @@ -75,7 +76,7 @@ public function testGetJournalTransactionWorks() $this->assertSame('MEMO', $journalTransaction->getCode()); $this->assertSame(201300003, $journalTransaction->getNumber()); $this->assertSame('2013/11', $journalTransaction->getPeriod()); - $this->assertEquals('EUR', $journalTransaction->getCurrencyToString()); + $this->assertEquals('EUR', Util::objectToStr($journalTransaction->getCurrency())); $this->assertEquals(new \DateTimeImmutable('2013-11-04'), $journalTransaction->getDate()); $this->assertSame('import', $journalTransaction->getOrigin()); $this->assertNull($journalTransaction->getFreetext1()); @@ -90,8 +91,8 @@ public function testGetJournalTransactionWorks() $this->assertEquals(LineType::DETAIL(), $detailLine1->getLineType()); $this->assertSame(1, $detailLine1->getId()); - $this->assertSame('4008', $detailLine1->getDim1ToString()); - $this->assertNull($detailLine1->getDim2ToString()); + $this->assertSame('4008', Util::objectToStr($detailLine1->getDim1())); + $this->assertNull(Util::objectToStr($detailLine1->getDim2())); $this->assertEquals(DebitCredit::DEBIT(), $detailLine1->getDebitCredit()); $this->assertEquals(Money::EUR(43555), $detailLine1->getValue()); $this->assertEquals(Money::EUR(43555), $detailLine1->getBaseValue()); @@ -103,18 +104,18 @@ public function testGetJournalTransactionWorks() $this->assertSame($ReflectObject->getConstant('NOTMATCHABLE'), (string)$detailLine1->getMatchStatus()); $this->assertNull($detailLine1->getMatchLevel()); $this->assertNull($detailLine1->getBaseValueOpen()); - $this->assertNull($detailLine1->getVatCodeToString()); + $this->assertNull(Util::objectToStr($detailLine1->getVatCode())); $this->assertNull($detailLine1->getVatValue()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); $this->assertSame($ReflectObject->getConstant('EMPTY'), (string)$detailLine1->getPerformanceType()); - $this->assertNull($detailLine1->getPerformanceCountryToString()); + $this->assertNull(Util::objectToStr($detailLine1->getPerformanceCountry())); $this->assertNull($detailLine1->getPerformanceVatNumber()); $this->assertNull($detailLine1->getPerformanceDate()); $this->assertEquals(LineType::DETAIL(), $detailLine2->getLineType()); $this->assertSame(2, $detailLine2->getId()); - $this->assertSame('1300', $detailLine2->getDim1ToString()); - $this->assertSame('1000', $detailLine2->getDim2ToString()); + $this->assertSame('1300', Util::objectToStr($detailLine2->getDim1())); + $this->assertSame('1000', Util::objectToStr($detailLine2->getDim2())); $this->assertEquals(DebitCredit::CREDIT(), $detailLine2->getDebitCredit()); $this->assertEquals(Money::EUR(43555), $detailLine2->getValue()); $this->assertEquals(Money::EUR(43555), $detailLine2->getBaseValue()); @@ -126,11 +127,11 @@ public function testGetJournalTransactionWorks() $this->assertSame($ReflectObject->getConstant('AVAILABLE'), (string)$detailLine2->getMatchStatus()); $this->assertSame(2, $detailLine2->getMatchLevel()); $this->assertEquals(Money::EUR(43555), $detailLine2->getBaseValueOpen()); - $this->assertNull($detailLine2->getVatCodeToString()); + $this->assertNull(Util::objectToStr($detailLine2->getVatCode())); $this->assertNull($detailLine2->getVatValue()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); $this->assertSame($ReflectObject->getConstant('EMPTY'), (string)$detailLine2->getPerformanceType()); - $this->assertNull($detailLine2->getPerformanceCountryToString()); + $this->assertNull(Util::objectToStr($detailLine2->getPerformanceCountry())); $this->assertNull($detailLine2->getPerformanceVatNumber()); $this->assertNull($detailLine2->getPerformanceDate()); } diff --git a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php index f340130d..8c960d35 100644 --- a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php +++ b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php @@ -16,6 +16,7 @@ use PhpTwinfield\PurchaseTransaction; use PhpTwinfield\PurchaseTransactionLine; use PhpTwinfield\Response\Response; +use PhpTwinfield\Util; /** * @runTestsInSeparateProcesses @@ -74,7 +75,7 @@ public function testGetPurchaseTransactionWorks() $this->assertSame('INK', $purchaseTransaction->getCode()); $this->assertSame(201300021, $purchaseTransaction->getNumber()); $this->assertSame('2013/05', $purchaseTransaction->getPeriod()); - $this->assertEquals('EUR', $purchaseTransaction->getCurrencyToString()); + $this->assertEquals('EUR', Util::objectToStr($purchaseTransaction->getCurrency())); $this->assertEquals(new \DateTimeImmutable('2013-05-02'), $purchaseTransaction->getDate()); $this->assertSame('import', $purchaseTransaction->getOrigin()); $this->assertNull($purchaseTransaction->getFreetext1()); @@ -91,8 +92,8 @@ public function testGetPurchaseTransactionWorks() $this->assertEquals(LineType::TOTAL(), $totalLine->getLineType()); $this->assertSame(1, $totalLine->getId()); - $this->assertSame('1600', $totalLine->getDim1ToString()); - $this->assertSame('2000', $totalLine->getDim2ToString()); + $this->assertSame('1600', Util::objectToStr($totalLine->getDim1())); + $this->assertSame('2000', Util::objectToStr($totalLine->getDim2())); $this->assertEquals(DebitCredit::CREDIT(), $totalLine->getDebitCredit()); $this->assertEquals(Money::EUR(12100), $totalLine->getValue()); $this->assertEquals(Money::EUR(12100), $totalLine->getBaseValue()); @@ -112,8 +113,8 @@ public function testGetPurchaseTransactionWorks() $this->assertEquals(LineType::DETAIL(), $detailLine->getLineType()); $this->assertSame(2, $detailLine->getId()); - $this->assertSame('8020', $detailLine->getDim1ToString()); - $this->assertNull($detailLine->getDim2ToString()); + $this->assertSame('8020', Util::objectToStr($detailLine->getDim1())); + $this->assertNull(Util::objectToStr($detailLine->getDim2())); $this->assertEquals(DebitCredit::DEBIT(), $detailLine->getDebitCredit()); $this->assertEquals(Money::EUR(10000), $detailLine->getValue()); $this->assertEquals(Money::EUR(10000), $detailLine->getBaseValue()); @@ -125,7 +126,7 @@ public function testGetPurchaseTransactionWorks() $this->assertSame($ReflectObject->getConstant('NOTMATCHABLE'), (string)$detailLine->getMatchStatus()); $this->assertNull($detailLine->getMatchLevel()); $this->assertNull($detailLine->getBaseValueOpen()); - $this->assertSame('IH', $detailLine->getVatCodeToString()); + $this->assertSame('IH', Util::objectToStr($detailLine->getVatCode())); $this->assertEquals(Money::EUR(2100), $detailLine->getVatValue()); $this->assertNull($detailLine->getVatTotal()); $this->assertNull($detailLine->getVatBaseTotal()); @@ -133,7 +134,7 @@ public function testGetPurchaseTransactionWorks() $this->assertEquals(LineType::VAT(), $vatLine->getLineType()); $this->assertSame(3, $vatLine->getId()); - $this->assertSame('1510', $vatLine->getDim1ToString()); + $this->assertSame('1510', Util::objectToStr($vatLine->getDim1())); $this->assertNull($vatLine->getDim2()); $this->assertEquals(DebitCredit::DEBIT(), $vatLine->getDebitCredit()); $this->assertEquals(Money::EUR(2100), $vatLine->getValue()); @@ -145,7 +146,7 @@ public function testGetPurchaseTransactionWorks() $this->assertNull($vatLine->getMatchStatus()); $this->assertNull($vatLine->getMatchLevel()); $this->assertNull($vatLine->getBaseValueOpen()); - $this->assertSame('IH', $vatLine->getVatCodeToString()); + $this->assertSame('IH', Util::objectToStr($vatLine->getVatCode())); $this->assertNull($vatLine->getVatValue()); $this->assertNull($vatLine->getVatTotal()); $this->assertNull($vatLine->getVatBaseTotal()); diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index 7efc3954..eac6fd2e 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -16,6 +16,7 @@ use PhpTwinfield\Response\Response; use PhpTwinfield\SalesTransaction; use PhpTwinfield\SalesTransactionLine; +use PhpTwinfield\Util; /** * @runTestsInSeparateProcesses @@ -74,7 +75,7 @@ public function testGetSalesTransactionWorks() $this->assertSame('SLS', $salesTransaction->getCode()); $this->assertSame(201300095, $salesTransaction->getNumber()); $this->assertSame('2013/05', $salesTransaction->getPeriod()); - $this->assertEquals('EUR', $salesTransaction->getCurrencyToString()); + $this->assertEquals('EUR', Util::objectToStr($salesTransaction->getCurrency())); $this->assertEquals(new \DateTimeImmutable('2013-05-02'), $salesTransaction->getDate()); $this->assertSame('import', $salesTransaction->getOrigin()); $this->assertNull($salesTransaction->getFreetext1()); @@ -92,8 +93,8 @@ public function testGetSalesTransactionWorks() $this->assertEquals(LineType::TOTAL(), $totalLine->getLineType()); $this->assertSame(1, $totalLine->getId()); - $this->assertSame('1300', $totalLine->getDim1ToString()); - $this->assertSame('1000', $totalLine->getDim2ToString()); + $this->assertSame('1300', Util::objectToStr($totalLine->getDim1())); + $this->assertSame('1000', Util::objectToStr($totalLine->getDim2())); $this->assertEquals(DebitCredit::DEBIT(), $totalLine->getDebitCredit()); $this->assertEquals(Money::EUR(12100), $totalLine->getValue()); $this->assertEquals(Money::EUR(12100), $totalLine->getBaseValue()); @@ -117,8 +118,8 @@ public function testGetSalesTransactionWorks() $this->assertEquals(LineType::DETAIL(), $detailLine->getLineType()); $this->assertSame(2, $detailLine->getId()); - $this->assertSame('8020', $detailLine->getDim1ToString()); - $this->assertNull($detailLine->getDim2ToString()); + $this->assertSame('8020', Util::objectToStr($detailLine->getDim1())); + $this->assertNull(Util::objectToStr($detailLine->getDim2())); $this->assertEquals(DebitCredit::CREDIT(), $detailLine->getDebitCredit()); $this->assertEquals(Money::EUR(10000), $detailLine->getValue()); $this->assertEquals(Money::EUR(10000), $detailLine->getBaseValue()); @@ -130,20 +131,20 @@ public function testGetSalesTransactionWorks() $this->assertSame($ReflectObject->getConstant('NOTMATCHABLE'), (string)$detailLine->getMatchStatus()); $this->assertNull($detailLine->getMatchLevel()); $this->assertNull($detailLine->getBaseValueOpen()); - $this->assertSame('VH', $detailLine->getVatCodeToString()); + $this->assertSame('VH', Util::objectToStr($detailLine->getVatCode())); $this->assertEquals(Money::EUR(2100), $detailLine->getVatValue()); $this->assertNull($detailLine->getVatTotal()); $this->assertNull($detailLine->getVatBaseTotal()); $this->assertNull($detailLine->getValueOpen()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); $this->assertSame($ReflectObject->getConstant('EMPTY'), (string)$detailLine->getPerformanceType()); - $this->assertNull($detailLine->getPerformanceCountryToString()); + $this->assertNull(Util::objectToStr($detailLine->getPerformanceCountry())); $this->assertNull($detailLine->getPerformanceVatNumber()); $this->assertNull($detailLine->getPerformanceDate()); $this->assertEquals(LineType::VAT(), $vatLine->getLineType()); $this->assertSame(3, $vatLine->getId()); - $this->assertSame('1530', $vatLine->getDim1ToString()); + $this->assertSame('1530', Util::objectToStr($vatLine->getDim1())); $this->assertNull($vatLine->getDim2()); $this->assertEquals(DebitCredit::CREDIT(), $vatLine->getDebitCredit()); $this->assertEquals(Money::EUR(2100), $vatLine->getValue()); @@ -155,14 +156,14 @@ public function testGetSalesTransactionWorks() $this->assertNull($vatLine->getMatchStatus()); $this->assertNull($vatLine->getMatchLevel()); $this->assertNull($vatLine->getBaseValueOpen()); - $this->assertSame('VH', $vatLine->getVatCodeToString()); + $this->assertSame('VH', Util::objectToStr($vatLine->getVatCode())); $this->assertNull($vatLine->getVatValue()); $this->assertNull($vatLine->getVatTotal()); $this->assertNull($vatLine->getVatBaseTotal()); $this->assertNull($vatLine->getValueOpen()); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\PerformanceType'); $this->assertSame($ReflectObject->getConstant('EMPTY'), (string)$vatLine->getPerformanceType()); - $this->assertNull($vatLine->getPerformanceCountryToString()); + $this->assertNull(Util::objectToStr($vatLine->getPerformanceCountry())); $this->assertNull($vatLine->getPerformanceVatNumber()); $this->assertNull($vatLine->getPerformanceDate()); } diff --git a/tests/UnitTests/ApiConnectors/InvoiceApiConnectorTest.php b/tests/UnitTests/ApiConnectors/InvoiceApiConnectorTest.php index f615eb7b..076e5180 100644 --- a/tests/UnitTests/ApiConnectors/InvoiceApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/InvoiceApiConnectorTest.php @@ -10,6 +10,7 @@ use PhpTwinfield\Response\Response; use PhpTwinfield\Secure\AuthenticatedConnection; use PhpTwinfield\Services\ProcessXmlService; +use PhpTwinfield\Util; use PHPUnit\Framework\TestCase; /** @@ -81,6 +82,6 @@ public function testSendAllReturnsMappedObjects() $this->assertInstanceOf(Invoice::class, $mapped); $this->assertEquals("10", $mapped->getInvoiceNumber()); - $this->assertEquals("20190410", $mapped->getInvoiceDateToString()); + $this->assertEquals("20190410", Util::formatDate($mapped->getInvoiceDate())); } } diff --git a/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php b/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php index ee278d06..4760cd4a 100644 --- a/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php @@ -12,6 +12,7 @@ use PhpTwinfield\SalesTransaction; use PhpTwinfield\Secure\AuthenticatedConnection; use PhpTwinfield\Services\ProcessXmlService; +use PhpTwinfield\Util; use PHPUnit\Framework\TestCase; /** @@ -141,7 +142,7 @@ public function testSendReturnsMappedObjects() $mapped = $this->apiConnector->send($transaction); $this->assertEquals("VRK", $mapped->getCode()); - $this->assertEquals("EUR", $mapped->getCurrencyToString()); + $this->assertEquals("EUR", Util::objectToStr($mapped->getCurrency())); $this->assertEquals("2017/09", $mapped->getPeriod()); $this->assertEquals("INV123458", $mapped->getInvoiceNumber()); $this->assertEquals(new \DateTimeImmutable("2017-09-01"), $mapped->getDate()); diff --git a/tests/UnitTests/BankTransactionLineUnitTest.php b/tests/UnitTests/BankTransactionLineUnitTest.php index 5e2b58e4..41c8d086 100644 --- a/tests/UnitTests/BankTransactionLineUnitTest.php +++ b/tests/UnitTests/BankTransactionLineUnitTest.php @@ -9,6 +9,7 @@ use PhpTwinfield\Enums\LineType; use PhpTwinfield\Enums\MatchStatus; use PhpTwinfield\SalesTransaction; +use PhpTwinfield\Util; class BankTransactionLineUnitTest extends \PHPUnit\Framework\TestCase { @@ -53,7 +54,7 @@ public function testSetDim2() $this->line->setLineType(LineType::DETAIL()); $this->assertEquals($this->line, $this->line->setDim2FromString('test'), 'Fluid interface is expected'); - $this->assertSame('test', $this->line->getDim2ToString()); + $this->assertSame('test', Util::objectToStr($this->line->getDim2())); } public function testCanNotSetDim2IfLineTypeIsNotDetail() @@ -69,7 +70,7 @@ public function testSetDim3() $this->line->setLineType(LineType::DETAIL()); $this->assertEquals($this->line, $this->line->setDim3FromString('test'), 'Fluid interface is expected'); - $this->assertSame('test', $this->line->getDim3ToString()); + $this->assertSame('test', Util::objectToStr($this->line->getDim3())); } public function testCanNotSetDim3IfLineTypeIsNotDetail() diff --git a/tests/UnitTests/BankTransactionUnitTest.php b/tests/UnitTests/BankTransactionUnitTest.php index 053b777a..8c2506d2 100644 --- a/tests/UnitTests/BankTransactionUnitTest.php +++ b/tests/UnitTests/BankTransactionUnitTest.php @@ -7,6 +7,7 @@ use PhpTwinfield\BankTransactionLine; use PhpTwinfield\Enums\LineType; use PhpTwinfield\SalesTransactionLine; +use PhpTwinfield\Util; class BankTransactionUnitTest extends \PHPUnit\Framework\TestCase { @@ -25,7 +26,7 @@ public function testSetStartValue() $this->bankTransaction->setCurrencyFromString('EUR'); $this->bankTransaction->setStartValue(Money::EUR(100)); - $this->assertEquals('EUR', $this->bankTransaction->getCurrencyToString()); + $this->assertEquals('EUR', Util::objectToStr($this->bankTransaction->getCurrency())); $this->assertEquals(Money::EUR(100), $this->bankTransaction->getStartValue()); $this->assertEquals(Money::EUR(100), $this->bankTransaction->getCloseValue()); } @@ -33,7 +34,7 @@ public function testSetStartValue() public function testSetCurrencyWithoutStartValue() { $this->bankTransaction->setCurrencyFromString('EUR'); - $this->assertEquals('EUR', $this->bankTransaction->getCurrencyToString()); + $this->assertEquals('EUR', Util::objectToStr($this->bankTransaction->getCurrency())); } public function testSetCurrencyWithZeroStartValue() @@ -41,7 +42,7 @@ public function testSetCurrencyWithZeroStartValue() $this->bankTransaction->setStartvalue(Money::EUR(0)); $this->bankTransaction->setCurrencyFromString('EUR'); - $this->assertEquals('EUR', $this->bankTransaction->getCurrencyToString()); + $this->assertEquals('EUR', Util::objectToStr($this->bankTransaction->getCurrency())); } public function testSetCurrencyWithStartValue() diff --git a/tests/UnitTests/CashTransactionLineUnitTest.php b/tests/UnitTests/CashTransactionLineUnitTest.php index 55473c21..2f3602c5 100644 --- a/tests/UnitTests/CashTransactionLineUnitTest.php +++ b/tests/UnitTests/CashTransactionLineUnitTest.php @@ -9,6 +9,7 @@ use PhpTwinfield\Enums\LineType; use PhpTwinfield\Enums\MatchStatus; use PhpTwinfield\SalesTransaction; +use PhpTwinfield\Util; class CashTransactionLineUnitTest extends \PHPUnit\Framework\TestCase { @@ -53,7 +54,7 @@ public function testSetDim2() $this->line->setLineType(LineType::DETAIL()); $this->assertEquals($this->line, $this->line->setDim2FromString('test'), 'Fluid interface is expected'); - $this->assertSame('test', $this->line->getDim2ToString()); + $this->assertSame('test', Util::objectToStr($this->line->getDim2())); } public function testCanNotSetDim2IfLineTypeIsNotDetail() @@ -69,7 +70,7 @@ public function testSetDim3() $this->line->setLineType(LineType::DETAIL()); $this->assertEquals($this->line, $this->line->setDim3FromString('test'), 'Fluid interface is expected'); - $this->assertSame('test', $this->line->getDim3ToString()); + $this->assertSame('test', Util::objectToStr($this->line->getDim3())); } public function testCanNotSetDim3IfLineTypeIsNotDetail() diff --git a/tests/UnitTests/CashTransactionUnitTest.php b/tests/UnitTests/CashTransactionUnitTest.php index dc328760..73909dc6 100644 --- a/tests/UnitTests/CashTransactionUnitTest.php +++ b/tests/UnitTests/CashTransactionUnitTest.php @@ -7,6 +7,7 @@ use PhpTwinfield\CashTransactionLine; use PhpTwinfield\Enums\LineType; use PhpTwinfield\SalesTransactionLine; +use PhpTwinfield\Util; class CashTransactionUnitTest extends \PHPUnit\Framework\TestCase { @@ -25,7 +26,7 @@ public function testSetStartValue() $this->cashTransaction->setCurrencyFromString('EUR'); $this->cashTransaction->setStartValue(Money::EUR(100)); - $this->assertEquals('EUR', $this->cashTransaction->getCurrencyToString()); + $this->assertEquals('EUR', Util::objectToStr($this->cashTransaction->getCurrency())); $this->assertEquals(Money::EUR(100), $this->cashTransaction->getStartValue()); $this->assertEquals(Money::EUR(100), $this->cashTransaction->getCloseValue()); } @@ -33,7 +34,7 @@ public function testSetStartValue() public function testSetCurrencyWithoutStartValue() { $this->cashTransaction->setCurrencyFromString('EUR'); - $this->assertEquals('EUR', $this->cashTransaction->getCurrencyToString()); + $this->assertEquals('EUR', Util::objectToStr($this->cashTransaction->getCurrency())); } public function testSetCurrencyWithZeroStartValue() @@ -41,7 +42,7 @@ public function testSetCurrencyWithZeroStartValue() $this->cashTransaction->setStartvalue(Money::EUR(0)); $this->cashTransaction->setCurrencyFromString('EUR'); - $this->assertEquals('EUR', $this->cashTransaction->getCurrencyToString()); + $this->assertEquals('EUR', Util::objectToStr($this->cashTransaction->getCurrency())); } public function testSetCurrencyWithStartValue() diff --git a/tests/UnitTests/ElectronicBankStatementUnitTest.php b/tests/UnitTests/ElectronicBankStatementUnitTest.php index 5de9a857..ae570435 100644 --- a/tests/UnitTests/ElectronicBankStatementUnitTest.php +++ b/tests/UnitTests/ElectronicBankStatementUnitTest.php @@ -4,6 +4,7 @@ use Money\Money; use PhpTwinfield\ElectronicBankStatement; +use PhpTwinfield\Util; use PHPUnit\Framework\TestCase; class ElectronicBankStatementUnitTest extends TestCase @@ -16,7 +17,7 @@ public function testCanSetCurrencyManually() $ebs = new ElectronicBankStatement(); $ebs->setCurrencyFromString("HUF"); - $this->assertEquals("HUF", $ebs->getCurrencyToString()); + $this->assertEquals("HUF", Util::objectToStr($ebs->getCurrency())); } /** From 6e913bc80027e5902ab6e0d2eb4fd7834c57ec9e Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 22 Jun 2019 13:21:37 +0200 Subject: [PATCH 325/388] Upload --- breaking262.md | 2 - src/Activity.php | 11 +++- src/Article.php | 7 +++ src/ArticleLine.php | 7 +++ src/AssetMethod.php | 7 +++ src/CashBankBook.php | 7 +++ src/CostCenter.php | 11 +++- src/Country.php | 7 +++ src/Currency.php | 7 +++ src/Customer.php | 12 ++-- src/DimensionGroup.php | 7 +++ src/DimensionType.php | 7 +++ src/Fields/Invoice/InvoiceAmountField.php | 17 +++++- src/Fields/Invoice/SubArticleField.php | 12 ++++ src/FixedAsset.php | 12 ++-- src/GeneralLedger.php | 7 +++ src/InvoiceType.php | 7 +++ src/Mappers/InvoiceMapper.php | 2 +- src/PayCode.php | 7 +++ src/Project.php | 12 ++-- src/Rate.php | 7 +++ src/Supplier.php | 12 ++-- src/User.php | 7 +++ src/UserRole.php | 7 +++ src/VatCode.php | 7 +++ src/VatGroup.php | 7 +++ src/VatGroupCountry.php | 7 +++ .../BankTransactionIntegrationTest.php | 8 +-- .../CashTransactionIntegrationTest.php | 12 ++-- .../CustomerIntegrationTest.php | 14 ++--- .../InvoiceIntegrationTest.php | 60 ++++++++++--------- .../JournalTransactionIntegrationTest.php | 17 ++---- .../PurchaseTransactionIntegrationTest.php | 19 +++--- .../SalesTransactionIntegrationTest.php | 19 +++--- .../CustomerApiConnectorTest.php | 9 +-- .../FixedAssetApiConnectorTest.php | 9 +-- .../TransactionApiConnectorTest.php | 11 +--- .../UnitTests/BankTransactionLineUnitTest.php | 4 +- tests/UnitTests/BankTransactionUnitTest.php | 9 +-- .../UnitTests/CashTransactionLineUnitTest.php | 4 +- tests/UnitTests/CashTransactionUnitTest.php | 8 +-- .../DomDocuments/CustomerDocumentUnitTest.php | 26 ++++---- .../DomDocuments/SupplierDocumentUnitTest.php | 14 ++--- .../ElectronicBankStatementUnitTest.php | 5 +- 44 files changed, 309 insertions(+), 161 deletions(-) diff --git a/breaking262.md b/breaking262.md index f4faa0dd..68de117f 100644 --- a/breaking262.md +++ b/breaking262.md @@ -17,8 +17,6 @@ This means (among others) that all booleans are now type cast as bool, all monet Another big change is that retrieved fields that are instances of another entity in Twinfield and this library are now retrieved and set in the same way as was already done with Office or Customer codes. So for example a VAT code retrieved from or set to a PhpTwinfield\Article will now become an instance of PhpTwinfield\VatCode with its $code set to "VH" instead of begin just a string with the value "VH". -Most of these changed methods have gained ToString/FromString or ToFloat/FromFloat methods that will ease the transition. - See the tables per class below for breaking changes and suggestions for fixes/replacement methods. ## Bank Transactions diff --git a/src/Activity.php b/src/Activity.php index b4c2e375..960652b3 100644 --- a/src/Activity.php +++ b/src/Activity.php @@ -37,12 +37,17 @@ class Activity extends BaseObject implements HasCodeInterface public function __construct() { - $dimensionType = new \PhpTwinfield\DimensionType; - $dimensionType->setCode('ACT'); - $this->setType($dimensionType); + $this->setType(\PhpTwinfield\DimensionType::fromCode('ACT')); $this->setProjects(new ActivityProjects); } + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } public function getProjects(): ActivityProjects { diff --git a/src/Article.php b/src/Article.php index b58db15b..f7454972 100644 --- a/src/Article.php +++ b/src/Article.php @@ -52,6 +52,13 @@ public function __construct() $this->setAllowDiscountorPremium(true); $this->setType(\PhpTwinfield\Enums\ArticleType::NORMAL()); } + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } public function getLines() { diff --git a/src/ArticleLine.php b/src/ArticleLine.php index b5109166..5c5a9ebe 100644 --- a/src/ArticleLine.php +++ b/src/ArticleLine.php @@ -33,4 +33,11 @@ class ArticleLine extends BaseObject use UnitsField; use UnitsPriceExclField; use UnitsPriceIncField; + + public static function fromCode(string $code) { + $instance = new self; + $instance->setSubCode($code); + + return $instance; + } } diff --git a/src/AssetMethod.php b/src/AssetMethod.php index 243abbe1..72535571 100644 --- a/src/AssetMethod.php +++ b/src/AssetMethod.php @@ -48,6 +48,13 @@ public function __construct() $this->setBalanceAccounts(new AssetMethodBalanceAccounts); $this->setProfitLossAccounts(new AssetMethodProfitLossAccounts); } + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } public function getBalanceAccounts(): AssetMethodBalanceAccounts { diff --git a/src/CashBankBook.php b/src/CashBankBook.php index 1649185b..3cc46610 100644 --- a/src/CashBankBook.php +++ b/src/CashBankBook.php @@ -16,4 +16,11 @@ class CashBankBook extends BaseObject implements HasCodeInterface use CodeField; use NameField; use ShortNameField; + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } } \ No newline at end of file diff --git a/src/CostCenter.php b/src/CostCenter.php index 0e761d4c..ffd6028f 100644 --- a/src/CostCenter.php +++ b/src/CostCenter.php @@ -33,8 +33,13 @@ class CostCenter extends BaseObject implements HasCodeInterface public function __construct() { - $dimensionType = new \PhpTwinfield\DimensionType; - $dimensionType->setCode('KPL'); - $this->setType($dimensionType); + $this->setType(\PhpTwinfield\DimensionType::fromCode('KPL')); + } + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; } } diff --git a/src/Country.php b/src/Country.php index 6fddc5f7..3ac76be1 100644 --- a/src/Country.php +++ b/src/Country.php @@ -16,4 +16,11 @@ class Country extends BaseObject implements HasCodeInterface use CodeField; use NameField; use ShortNameField; + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } } \ No newline at end of file diff --git a/src/Currency.php b/src/Currency.php index 6d4eb6c6..203d9ac9 100644 --- a/src/Currency.php +++ b/src/Currency.php @@ -21,6 +21,13 @@ class Currency extends BaseObject implements HasCodeInterface use StatusField; private $rates = []; + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } public function getRates() { diff --git a/src/Customer.php b/src/Customer.php index 55dbb5e5..ab8cc629 100644 --- a/src/Customer.php +++ b/src/Customer.php @@ -67,14 +67,18 @@ public function __construct() $this->setBeginYear(0); $this->setEndPeriod(0); $this->setEndYear(0); - - $dimensionType = new \PhpTwinfield\DimensionType; - $dimensionType->setCode('DEB'); - $this->setType($dimensionType); + $this->setType(\PhpTwinfield\DimensionType::fromCode('DEB')); $this->setCreditManagement(new CustomerCreditManagement); $this->setFinancials(new CustomerFinancials); } + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } public function getCreditManagement(): CustomerCreditManagement { diff --git a/src/DimensionGroup.php b/src/DimensionGroup.php index a5c685bd..f2614e24 100644 --- a/src/DimensionGroup.php +++ b/src/DimensionGroup.php @@ -21,6 +21,13 @@ class DimensionGroup extends BaseObject implements HasCodeInterface use StatusField; private $dimensions = []; + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } public function getDimensions() { diff --git a/src/DimensionType.php b/src/DimensionType.php index 47de4228..b8e24311 100644 --- a/src/DimensionType.php +++ b/src/DimensionType.php @@ -30,6 +30,13 @@ public function __construct() $this->setAddress(new DimensionTypeAddress); $this->setLevels(new DimensionTypeLevels); } + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } public function getAddress(): DimensionTypeAddress { diff --git a/src/Fields/Invoice/InvoiceAmountField.php b/src/Fields/Invoice/InvoiceAmountField.php index c09e9a77..6789aa1c 100644 --- a/src/Fields/Invoice/InvoiceAmountField.php +++ b/src/Fields/Invoice/InvoiceAmountField.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\Fields\Invoice; use Money\Money; +use PhpTwinfield\Util; trait InvoiceAmountField { @@ -21,7 +22,7 @@ public function getInvoiceAmount(): ?Money { return $this->invoiceAmount; } - + /** * @param Money|null $invoiceAmount * @return $this @@ -32,4 +33,18 @@ public function setInvoiceAmount(?Money $invoiceAmount) return $this; } + + /** + * @param float|null $invoiceAmountFloat + * @return $this + * @throws Exception + */ + public function setInvoiceAmountFromFloat(?float $invoiceAmountFloat) + { + if ((float)$invoiceAmountFloat) { + return $this->setInvoiceAmount(Money::EUR(100 * $invoiceAmountFloat)); + } else { + return $this->setInvoiceAmount(Money::EUR(0)); + } + } } \ No newline at end of file diff --git a/src/Fields/Invoice/SubArticleField.php b/src/Fields/Invoice/SubArticleField.php index 1fa9ab5a..402f3e67 100644 --- a/src/Fields/Invoice/SubArticleField.php +++ b/src/Fields/Invoice/SubArticleField.php @@ -39,4 +39,16 @@ public function setSubArticle(?ArticleLine $subArticle): self $this->subArticle = $subArticle; return $this; } + + /** + * @param string|null $subArticleString + * @return $this + * @throws Exception + */ + public function setSubArticleFromString(?string $subArticleString) + { + $subArticle = new ArticleLine(); + $subArticle->setSubCode($subArticleString); + return $this->setSubArticle($subArticle); + } } diff --git a/src/FixedAsset.php b/src/FixedAsset.php index 59b9027a..c1c72fe3 100644 --- a/src/FixedAsset.php +++ b/src/FixedAsset.php @@ -38,13 +38,17 @@ class FixedAsset extends BaseObject implements HasCodeInterface public function __construct() { - $dimensionType = new \PhpTwinfield\DimensionType; - $dimensionType->setCode('AST'); - $this->setType($dimensionType); - + $this->setType(\PhpTwinfield\DimensionType::fromCode('AST')); $this->setFinancials(new FixedAssetFinancials); $this->setFixedAssets(new FixedAssetFixedAssets); } + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } public function getFinancials(): FixedAssetFinancials { diff --git a/src/GeneralLedger.php b/src/GeneralLedger.php index a3774b7f..dd5e8831 100644 --- a/src/GeneralLedger.php +++ b/src/GeneralLedger.php @@ -52,6 +52,13 @@ public function __construct() $this->setFinancials(new GeneralLedgerFinancials); } + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } public function getFinancials(): GeneralLedgerFinancials { diff --git a/src/InvoiceType.php b/src/InvoiceType.php index 403813a7..e56afe09 100644 --- a/src/InvoiceType.php +++ b/src/InvoiceType.php @@ -16,4 +16,11 @@ class InvoiceType extends BaseObject implements HasCodeInterface use CodeField; use NameField; use ShortNameField; + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } } \ No newline at end of file diff --git a/src/Mappers/InvoiceMapper.php b/src/Mappers/InvoiceMapper.php index 6968fe66..89ad9ca6 100644 --- a/src/Mappers/InvoiceMapper.php +++ b/src/Mappers/InvoiceMapper.php @@ -101,7 +101,7 @@ public static function map(Response $response) ->setPerformanceDate(self::parseDateAttribute(self::getField($lineElement, 'performancedate', $invoiceLine))) ->setPerformanceType(self::parseEnumAttribute(\PhpTwinfield\Enums\PerformanceType::class, self::getField($lineElement, 'performancetype', $invoiceLine))) ->setQuantity(self::getField($lineElement, 'quantity', $invoiceLine)) - ->setSubArticle(self::parseObjectAttribute(\PhpTwinfield\ArticleLine::class, $invoiceLine, $lineElement, 'subarticle')) + ->setSubArticleFromString(self::getField($lineElement, 'subarticle', $invoiceLine)) ->setUnits(self::getField($lineElement, 'units', $invoiceLine)) ->setUnitsPriceExcl(self::parseMoneyAttribute(self::getField($lineElement, 'unitspriceexcl', $invoiceLine), Util::objectToStr($invoice->getCurrency()))) ->setUnitsPriceInc(self::parseMoneyAttribute(self::getField($lineElement, 'unitspriceinc', $invoiceLine), Util::objectToStr($invoice->getCurrency()))) diff --git a/src/PayCode.php b/src/PayCode.php index 58d8f5b3..d1f12e03 100644 --- a/src/PayCode.php +++ b/src/PayCode.php @@ -16,4 +16,11 @@ class PayCode extends BaseObject implements HasCodeInterface use CodeField; use NameField; use ShortNameField; + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } } \ No newline at end of file diff --git a/src/Project.php b/src/Project.php index 34879d34..88c1d1e2 100644 --- a/src/Project.php +++ b/src/Project.php @@ -37,12 +37,16 @@ class Project extends BaseObject implements HasCodeInterface public function __construct() { - $dimensionType = new \PhpTwinfield\DimensionType; - $dimensionType->setCode('PRJ'); - $this->setType($dimensionType); - + $this->setType(\PhpTwinfield\DimensionType::fromCode('PRJ')); $this->setProjects(new ProjectProjects); } + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } public function getProjects(): ProjectProjects { diff --git a/src/Rate.php b/src/Rate.php index 73ba0b22..41ab8a6a 100644 --- a/src/Rate.php +++ b/src/Rate.php @@ -36,6 +36,13 @@ class Rate extends BaseObject implements HasCodeInterface use UserField; private $rateChanges = []; + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } public function getRateChanges() { diff --git a/src/Supplier.php b/src/Supplier.php index b9c24e22..61c9894f 100644 --- a/src/Supplier.php +++ b/src/Supplier.php @@ -66,13 +66,17 @@ public function __construct() $this->setBeginYear(0); $this->setEndPeriod(0); $this->setEndYear(0); - - $dimensionType = new \PhpTwinfield\DimensionType; - $dimensionType->setCode('CRD'); - $this->setType($dimensionType); + $this->setType(\PhpTwinfield\DimensionType::fromCode('CRD')); $this->setFinancials(new SupplierFinancials); } + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } public function getFinancials(): SupplierFinancials { diff --git a/src/User.php b/src/User.php index 46c904cb..5b3562b6 100644 --- a/src/User.php +++ b/src/User.php @@ -55,4 +55,11 @@ class User extends BaseObject implements HasCodeInterface use TouchedField; use TypeField; use TypeLockedField; + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } } diff --git a/src/UserRole.php b/src/UserRole.php index de040099..1497ceaa 100644 --- a/src/UserRole.php +++ b/src/UserRole.php @@ -18,4 +18,11 @@ class UserRole extends BaseObject implements HasCodeInterface use LevelField; use NameField; use ShortNameField; + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } } \ No newline at end of file diff --git a/src/VatCode.php b/src/VatCode.php index c0015b5e..a0db2031 100644 --- a/src/VatCode.php +++ b/src/VatCode.php @@ -34,6 +34,13 @@ class VatCode extends BaseObject implements HasCodeInterface use UserField; private $percentages = []; + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } public function getPercentages() { diff --git a/src/VatGroup.php b/src/VatGroup.php index 9c3a9475..75e38c87 100644 --- a/src/VatGroup.php +++ b/src/VatGroup.php @@ -16,4 +16,11 @@ class VatGroup extends BaseObject implements HasCodeInterface use CodeField; use NameField; use ShortNameField; + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } } \ No newline at end of file diff --git a/src/VatGroupCountry.php b/src/VatGroupCountry.php index 7e862da5..951c81ea 100644 --- a/src/VatGroupCountry.php +++ b/src/VatGroupCountry.php @@ -16,4 +16,11 @@ class VatGroupCountry extends BaseObject implements HasCodeInterface use CodeField; use NameField; use ShortNameField; + + public static function fromCode(string $code) { + $instance = new self; + $instance->setCode($code); + + return $instance; + } } \ No newline at end of file diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index e93775a6..217541f7 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -149,7 +149,7 @@ public function testSendBankTransactionWorks() ->setDestiny(Destiny::TEMPORARY()) ->setRaiseWarning(false) ->setCode('BNK') - ->setCurrencyFromString('EUR') + ->setCurrency(Currency::fromCode('EUR')) ->setDate(new DateTimeImmutable('2013-11-04')) ->setStatementNumber(4) ->setStartValue(Money::EUR(97401)); @@ -158,15 +158,15 @@ public function testSendBankTransactionWorks() $totalLine ->setLineType(LineType::TOTAL()) ->setId('1') - ->setDim1FromString('1001') + ->setDim1(\PhpTwinfield\GeneralLedger::fromCode('1001')) ->setValue(Money::EUR(43555)); $detailLine = new BankTransactionLine(); $detailLine ->setLineType(LineType::DETAIL()) ->setId('2') - ->setDim1FromString('1300') - ->setDim2FromString('1000') + ->setDim1(\PhpTwinfield\GeneralLedger::fromCode('1300')) + ->setDim2(\PhpTwinfield\CostCenter::fromCode('1000')) ->setValue(Money::EUR(43555)) ->setDescription('Invoice paid'); diff --git a/tests/IntegrationTests/CashTransactionIntegrationTest.php b/tests/IntegrationTests/CashTransactionIntegrationTest.php index 2e52d504..27435fa6 100644 --- a/tests/IntegrationTests/CashTransactionIntegrationTest.php +++ b/tests/IntegrationTests/CashTransactionIntegrationTest.php @@ -40,14 +40,14 @@ protected function setUp() parent::setUp(); $this->transactionApiConnector = new TransactionApiConnector($this->connection); - + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { $baseCurrency = new Currency; $baseCurrency->setCode('EUR'); $reportingCurrency = new Currency; $reportingCurrency->setCode('USD'); - + $office = new Office; $office->setResult(1); $office->setBaseCurrency($baseCurrency); @@ -149,7 +149,7 @@ public function testSendCashTransactionWorks() ->setDestiny(Destiny::TEMPORARY()) ->setRaiseWarning(false) ->setCode('CASH') - ->setCurrencyFromString('EUR') + ->setCurrency(Currency::fromCode('EUR')) ->setDate(new DateTimeImmutable('2013-11-04')) ->setStatementNumber(4) ->setStartValue(Money::EUR(97401)); @@ -158,15 +158,15 @@ public function testSendCashTransactionWorks() $totalLine ->setLineType(LineType::TOTAL()) ->setId('1') - ->setDim1FromString('1002') + ->setDim1(\PhpTwinfield\GeneralLedger::fromCode('1002')) ->setValue(Money::EUR(43555)); $detailLine = new CashTransactionLine(); $detailLine ->setLineType(LineType::DETAIL()) ->setId('2') - ->setDim1FromString('1300') - ->setDim2FromString('1000') + ->setDim1(\PhpTwinfield\GeneralLedger::fromCode('1300')) + ->setDim2(\PhpTwinfield\CostCenter::fromCode('1000')) ->setValue(Money::EUR(43555)) ->setDescription('Invoice paid'); diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 987553be..4c661fc6 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -154,7 +154,7 @@ public function testGetCustomerWorks() $creditmanagement = $customer->getCreditManagement(); $this->assertNull(Util::objectToStr($creditmanagement->getResponsibleUser())); - $this->assertSame(0.00, $creditmanagement->getBaseCreditLimitToFloat()); + $this->assertSame(0.00, Util::formatMoney($creditmanagement->getBaseCreditLimit())); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\SendReminder'); $this->assertSame($ReflectObject->getConstant('TRUE'), (string)$creditmanagement->getSendReminder()); $this->assertNull($creditmanagement->getReminderEmail()); @@ -197,22 +197,22 @@ public function testSendCustomerWorks() $financials = new CustomerFinancials(); $financials->setDueDays(30); $financials->setPayAvailable(true); - $financials->setPayCodeFromString('SEPANLDD'); + $financials->setPayCode(\PhpTwinfield\PayCode::fromCode('SEPANLDD')); $collectMandate = new CustomerCollectMandate(); $collectMandate->setID(1); - $collectMandate->setSignatureDateFromString('20180604'); - $collectMandate->setFirstRunDateFromString('20180608'); + $collectMandate->setSignatureDate(Util::parseDate('20180604')); + $collectMandate->setFirstRunDate(Util::parseDate('20180608')); $financials->setCollectMandate($collectMandate); $customer->setFinancials($financials); $address = new CustomerAddress(); $address->setID(1); - $address->setTypeFromString('invoice'); + $address->setType(AddressType::INVOICE()); $address->setDefault(true); $address->setName('Customer 0'); - $address->setCountryFromString('NL'); + $address->setCountry(\PhpTwinfield\Country::fromCode('NL')); $address->setCity('Place'); $address->setPostcode('1000'); $address->setTelephone('010-123452000'); @@ -232,7 +232,7 @@ public function testSendCustomerWorks() $bank->setBankName('ABN Amro'); $bank->setBicCode('ABNANL2A'); $bank->setCity('Place'); - $bank->setCountryFromString('NL'); + $bank->setCountry(\PhpTwinfield\Country::fromCode('NL')); $bank->setIban('NL02ABNA0123456789'); $bank->setNatBicCode(''); $bank->setPostcode(''); diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 92cad3e9..91cfa243 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -7,6 +7,7 @@ use PhpTwinfield\ApiConnectors\InvoiceTypeApiConnector; use PhpTwinfield\Article; use PhpTwinfield\Customer; +use PhpTwinfield\Currency; use PhpTwinfield\DomDocuments\InvoicesDocument; use PhpTwinfield\Invoice; use PhpTwinfield\InvoiceLine; @@ -98,10 +99,10 @@ public function testGetConceptInvoiceWorks() $this->assertSame(1, $invoiceLine->getUnits()); $this->assertSame(true, $invoiceLine->getAllowDiscountOrPremium()); $this->assertSame('CoalesceFunctioningOnImpatienceTShirt', $invoiceLine->getDescription()); - $this->assertSame(15.00, $invoiceLine->getValueExclToFloat()); - $this->assertSame(0.00, $invoiceLine->getVatValueToFloat()); - $this->assertSame(15.00, $invoiceLine->getValueIncToFloat()); - $this->assertSame(15.00, $invoiceLine->getUnitsPriceExclToFloat()); + $this->assertSame(15.00, Util::formatMoney($invoiceLine->getValueExcl())); + $this->assertSame(0.00, Util::formatMoney($invoiceLine->getVatValue())); + $this->assertSame(15.00, Util::formatMoney($invoiceLine->getValueInc())); + $this->assertSame(15.00, Util::formatMoney($invoiceLine->getUnitsPriceExcl())); $this->assertSame('8020', Util::objectToStr($invoiceLine->getDim1())); $invoiceVatLines = $invoice->getVatLines(); @@ -111,12 +112,12 @@ public function testGetConceptInvoiceWorks() $invoiceVatLine = current($invoiceVatLines); $this->assertSame('VN', Util::objectToStr($invoiceLine->getVatCode())); - $this->assertSame(0.00, $invoiceLine->getVatValueToFloat()); + $this->assertSame(0.00, Util::formatMoney($invoiceLine->getVatValue())); $this->assertNull($invoiceLine->getPerformanceType()); $this->assertNull($invoiceLine->getPerformanceDate()); - $this->assertSame(15.00, $invoice->getTotals()->getValueIncToFloat()); - $this->assertSame(15.00, $invoice->getTotals()->getValueExclToFloat()); + $this->assertSame(15.00, Util::formatMoney($invoice->getTotals()->getValueInc())); + $this->assertSame(15.00, Util::formatMoney($invoice->getTotals()->getValueExcl())); $this->assertNull($invoice->getFinancialNumber()); $this->assertNull($invoice->getFinancialCode()); @@ -166,10 +167,10 @@ public function testGetFinalInvoiceWorks() $this->assertSame(1, $invoiceLine->getUnits()); $this->assertSame(true, $invoiceLine->getAllowDiscountOrPremium()); $this->assertSame('CoalesceFunctioningOnImpatienceTShirt', $invoiceLine->getDescription()); - $this->assertSame(15.00, $invoiceLine->getValueExclToFloat()); - $this->assertSame(0.00, $invoiceLine->getVatValueToFloat()); - $this->assertSame(15.00, $invoiceLine->getValueIncToFloat()); - $this->assertSame(15.00, $invoiceLine->getUnitsPriceExclToFloat()); + $this->assertSame(15.00, Util::formatMoney($invoiceLine->getValueExcl())); + $this->assertSame(0.00, Util::formatMoney($invoiceLine->getVatValue())); + $this->assertSame(15.00, Util::formatMoney($invoiceLine->getValueInc())); + $this->assertSame(15.00, Util::formatMoney($invoiceLine->getUnitsPriceExcl())); $this->assertSame('8020', Util::objectToStr($invoiceLine->getDim1())); $invoiceVatLines = $invoice->getVatLines(); @@ -179,12 +180,12 @@ public function testGetFinalInvoiceWorks() $invoiceVatLine = current($invoiceVatLines); $this->assertSame('VN', Util::objectToStr($invoiceLine->getVatCode())); - $this->assertSame(0.00, $invoiceLine->getVatValueToFloat()); + $this->assertSame(0.00, Util::formatMoney($invoiceLine->getVatValue())); $this->assertNull($invoiceLine->getPerformanceType()); $this->assertNull($invoiceLine->getPerformanceDate()); - $this->assertSame(15.00, $invoice->getTotals()->getValueIncToFloat()); - $this->assertSame(15.00, $invoice->getTotals()->getValueExclToFloat()); + $this->assertSame(15.00, Util::formatMoney($invoice->getTotals()->getValueInc())); + $this->assertSame(15.00, Util::formatMoney($invoice->getTotals()->getValueExcl())); $this->assertSame(123456789, $invoice->getFinancialNumber()); $this->assertSame('123456789', $invoice->getFinancialCode()); @@ -197,34 +198,35 @@ public function testSendInvoiceWorks() $invoice = new Invoice(); $invoice->setOffice(Office::fromCode('11024')); - $invoice->setInvoiceTypeFromString('FACTUUR'); + $invoice->setInvoiceType(\PhpTwinfield\InvoiceType::fromCode('FACTUUR')); $invoice->setInvoiceNumber('5'); - $invoice->setInvoiceDateFromString('20120831'); - $invoice->setBankFromString('BNK'); + $invoice->setInvoiceDate(Util::parseDate('20120831')); + $invoice->setBank(\PhpTwinfield\CashBankBook::fromCode('BNK')); $invoice->setInvoiceAddressNumber(1); $invoice->setDeliverAddressNumber(1); $invoice->setCustomer($customer); $invoice->setPeriod('2012/08'); - $invoice->setCurrencyFromString('EUR'); - $invoice->setStatusFromString('concept'); - $invoice->setPaymentMethodFromString('cash'); + $invoice->setCurrency(Currency::fromCode('EUR')); + $invoice->setStatus(\PhpTwinfield\Enums\Status::CONCEPT()); + $invoice->setPaymentMethod(\PhpTwinfield\Enums\PaymentMethod::CASH()); $invoice->setHeaderText('HEADER'); $invoice->setFooterText('FOOTER'); $invoiceLine = new InvoiceLine(); $invoiceLine->setID(1); - $invoiceLine->setArticleFromString('4'); - $invoiceLine->setSubArticleFromString('118'); + $invoiceLine->setArticle(\PhpTwinfield\Article::fromCode('4')); + $invoiceLine->setSubArticle(\PhpTwinfield\ArticleLine::fromCode('118')); $invoiceLine->setQuantity(1); $invoiceLine->setUnits(1); - $invoiceLine->setAllowDiscountOrPremiumFromString('true'); + $invoiceLine->setAllowDiscountOrPremium(true); $invoiceLine->setDescription('CoalesceFunctioningOnImpatienceTShirt'); - $invoiceLine->setValueExclFromFloat(15.00); - $invoiceLine->setVatValueFromFloat(0.00); - $invoiceLine->setValueIncFromFloat(15.00); - $invoiceLine->setUnitsPriceExclFromFloat(15.00); - $invoiceLine->setDim1FromString('8020'); - $invoiceLine->setVatCodeFromString('VN'); + $currency = \PhpTwinfield\Currency::fromCode('EUR'); + $invoiceLine->setValueExcl(Util:parseMoney(15.00, $currency)); + $invoiceLine->setVatValue(Util:parseMoney(0.00, $currency)); + $invoiceLine->setValueInc(Util:parseMoney(15.00, $currency)); + $invoiceLine->setUnitsPriceExcl(Util:parseMoney(15.00, $currency)); + $invoiceLine->setDim1(\PhpTwinfield\GeneralLedger::fromCode('8020')); + $invoiceLine->setVatCode(\PhpTwinfield\VatCode::fromCode('VN')); $invoice->addLine($invoiceLine); $this->processXmlService diff --git a/tests/IntegrationTests/JournalTransactionIntegrationTest.php b/tests/IntegrationTests/JournalTransactionIntegrationTest.php index e3ec821d..ca727aca 100644 --- a/tests/IntegrationTests/JournalTransactionIntegrationTest.php +++ b/tests/IntegrationTests/JournalTransactionIntegrationTest.php @@ -42,15 +42,10 @@ protected function setUp() $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { - $baseCurrency = new Currency; - $baseCurrency->setCode('EUR'); - $reportingCurrency = new Currency; - $reportingCurrency->setCode('USD'); - $office = new Office; $office->setResult(1); - $office->setBaseCurrency($baseCurrency); - $office->setReportingCurrency($reportingCurrency); + $office->setBaseCurrency(Currency::fromCode('EUR')); + $office->setReportingCurrency(Currency::fromCode('USD')); return $office; }); } @@ -142,7 +137,7 @@ public function testSendJournalTransactionWorks() $journalTransaction ->setDestiny(Destiny::TEMPORARY()) ->setCode('MEMO') - ->setCurrencyFromString('EUR') + ->setCurrency(Currency::fromCode('EUR')) ->setDate(new \DateTimeImmutable('2013-11-04')) ->setOffice(Office::fromCode('001')); @@ -150,15 +145,15 @@ public function testSendJournalTransactionWorks() $detailLine1 ->setLineType(LineType::DETAIL()) ->setId('1') - ->setDim1FromString('4008') + ->setDim1(\PhpTwinfield\GeneralLedger::fromCode('4008')) ->setValue(Money::EUR(-43555)); $detailLine2 = new JournalTransactionLine(); $detailLine2 ->setLineType(LineType::DETAIL()) ->setId('2') - ->setDim1FromString('1300') - ->setDim2FromString('1000') + ->setDim1(\PhpTwinfield\GeneralLedger::fromCode('1300')) + ->setDim2(\PhpTwinfield\CostCenter::fromCode('1000')) ->setValue(Money::EUR(43555)) ->setDescription('Invoice paid'); diff --git a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php index 8c960d35..34932684 100644 --- a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php +++ b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php @@ -41,15 +41,10 @@ protected function setUp() $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { - $baseCurrency = new Currency; - $baseCurrency->setCode('EUR'); - $reportingCurrency = new Currency; - $reportingCurrency->setCode('USD'); - $office = new Office; $office->setResult(1); - $office->setBaseCurrency($baseCurrency); - $office->setReportingCurrency($reportingCurrency); + $office->setBaseCurrency(Currency::fromCode('EUR')); + $office->setReportingCurrency(Currency::fromCode('USD')); return $office; }); } @@ -160,7 +155,7 @@ public function testSendPurchaseTransactionWorks() ->setDestiny(Destiny::TEMPORARY()) ->setRaiseWarning(false) ->setCode('INK') - ->setCurrencyFromString('EUR') + ->setCurrency(Currency::fromCode('EUR')) ->setDate(new \DateTimeImmutable('2013-05-02')) ->setPeriod('2013/05') ->setInvoiceNumber('20130-5481') @@ -172,8 +167,8 @@ public function testSendPurchaseTransactionWorks() $totalLine ->setLineType(LineType::TOTAL()) ->setId('1') - ->setDim1FromString('1600') - ->setDim2FromString('2000') + ->setDim1(\PhpTwinfield\GeneralLedger::fromCode('1600')) + ->setDim2(\PhpTwinfield\CostCenter::fromCode('2000')) ->setValue(Money::EUR(12100)) ->setDescription(''); @@ -181,10 +176,10 @@ public function testSendPurchaseTransactionWorks() $detailLine ->setLineType(LineType::DETAIL()) ->setId('2') - ->setDim1FromString('8020') + ->setDim1(\PhpTwinfield\GeneralLedger::fromCode('8020')) ->setValue(Money::EUR(10000)) ->setDescription('Outfit') - ->setVatCodeFromString('IH'); + ->setVatCode(\PhpTwinfield\VatCode::fromCode('IH')); $purchaseTransaction ->addLine($totalLine) diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index eac6fd2e..8db94330 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -42,15 +42,10 @@ protected function setUp() $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { - $baseCurrency = new Currency; - $baseCurrency->setCode('EUR'); - $reportingCurrency = new Currency; - $reportingCurrency->setCode('USD'); - $office = new Office; $office->setResult(1); - $office->setBaseCurrency($baseCurrency); - $office->setReportingCurrency($reportingCurrency); + $office->setBaseCurrency(Currency::fromCode('EUR')); + $office->setReportingCurrency(Currency::fromCode('USD')); return $office; }); } @@ -175,7 +170,7 @@ public function testSendSalesTransactionWorks() ->setDestiny(Destiny::TEMPORARY()) ->setRaiseWarning(false) ->setCode('SLS') - ->setCurrencyFromString('EUR') + ->setCurrency(Currency::fromCode('EUR')) ->setDate(new \DateTimeImmutable('2013-05-02')) ->setPeriod('2013/05') ->setInvoiceNumber('20130-6000') @@ -187,8 +182,8 @@ public function testSendSalesTransactionWorks() $totalLine ->setLineType(LineType::TOTAL()) ->setId('1') - ->setDim1FromString('1300') - ->setDim2FromString('1000') + ->setDim1(\PhpTwinfield\GeneralLedger::fromCode('1300')) + ->setDim2(\PhpTwinfield\CostCenter::fromCode('1000')) ->setValue(Money::EUR(12100)) ->setDescription(''); @@ -196,10 +191,10 @@ public function testSendSalesTransactionWorks() $detailLine ->setLineType(LineType::DETAIL()) ->setId('2') - ->setDim1FromString('8020') + ->setDim1(\PhpTwinfield\GeneralLedger::fromCode('8020')) ->setValue(Money::EUR(10000)) ->setDescription('Outfit') - ->setVatCodeFromString('VH'); + ->setVatCode(\PhpTwinfield\VatCode::fromCode('VH')); $salesTransaction ->addLine($totalLine) diff --git a/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php b/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php index efa407ab..047ab933 100644 --- a/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php @@ -48,15 +48,10 @@ protected function setUp() $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { - $baseCurrency = new Currency; - $baseCurrency->setCode('EUR'); - $reportingCurrency = new Currency; - $reportingCurrency->setCode('USD'); - $office = new Office; $office->setResult(1); - $office->setBaseCurrency($baseCurrency); - $office->setReportingCurrency($reportingCurrency); + $office->setBaseCurrency(Currency::fromCode('EUR')); + $office->setReportingCurrency(Currency::fromCode('USD')); return $office; }); } diff --git a/tests/UnitTests/ApiConnectors/FixedAssetApiConnectorTest.php b/tests/UnitTests/ApiConnectors/FixedAssetApiConnectorTest.php index a42233cb..e1e6cd43 100644 --- a/tests/UnitTests/ApiConnectors/FixedAssetApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/FixedAssetApiConnectorTest.php @@ -48,15 +48,10 @@ protected function setUp() $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { - $baseCurrency = new Currency; - $baseCurrency->setCode('EUR'); - $reportingCurrency = new Currency; - $reportingCurrency->setCode('USD'); - $office = new Office; $office->setResult(1); - $office->setBaseCurrency($baseCurrency); - $office->setReportingCurrency($reportingCurrency); + $office->setBaseCurrency(Currency::fromCode('EUR')); + $office->setReportingCurrency(Currency::fromCode('USD')); return $office; }); } diff --git a/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php b/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php index 4760cd4a..8f485aea 100644 --- a/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php @@ -50,16 +50,11 @@ protected function setUp() $this->apiConnector = new TransactionApiConnector($connection); $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); - $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { - $baseCurrency = new Currency; - $baseCurrency->setCode('EUR'); - $reportingCurrency = new Currency; - $reportingCurrency->setCode('USD'); - + $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { $office = new Office; $office->setResult(1); - $office->setBaseCurrency($baseCurrency); - $office->setReportingCurrency($reportingCurrency); + $office->setBaseCurrency(Currency::fromCode('EUR')); + $office->setReportingCurrency(Currency::fromCode('USD')); return $office; }); } diff --git a/tests/UnitTests/BankTransactionLineUnitTest.php b/tests/UnitTests/BankTransactionLineUnitTest.php index 41c8d086..f7770482 100644 --- a/tests/UnitTests/BankTransactionLineUnitTest.php +++ b/tests/UnitTests/BankTransactionLineUnitTest.php @@ -53,7 +53,7 @@ public function testSetDim2() { $this->line->setLineType(LineType::DETAIL()); - $this->assertEquals($this->line, $this->line->setDim2FromString('test'), 'Fluid interface is expected'); + $this->assertEquals($this->line, $this->line->setDim2(\PhpTwinfield\CostCenter::fromCode('test')), 'Fluid interface is expected'); $this->assertSame('test', Util::objectToStr($this->line->getDim2())); } @@ -69,7 +69,7 @@ public function testSetDim3() { $this->line->setLineType(LineType::DETAIL()); - $this->assertEquals($this->line, $this->line->setDim3FromString('test'), 'Fluid interface is expected'); + $this->assertEquals($this->line, $this->line->setDim3(\PhpTwinfield\Project::fromCode('test')), 'Fluid interface is expected'); $this->assertSame('test', Util::objectToStr($this->line->getDim3())); } diff --git a/tests/UnitTests/BankTransactionUnitTest.php b/tests/UnitTests/BankTransactionUnitTest.php index 8c2506d2..a3a761d6 100644 --- a/tests/UnitTests/BankTransactionUnitTest.php +++ b/tests/UnitTests/BankTransactionUnitTest.php @@ -5,6 +5,7 @@ use Money\Money; use PhpTwinfield\BankTransaction; use PhpTwinfield\BankTransactionLine; +use PhpTwinfield\Currency; use PhpTwinfield\Enums\LineType; use PhpTwinfield\SalesTransactionLine; use PhpTwinfield\Util; @@ -23,7 +24,7 @@ protected function setUp() public function testSetStartValue() { - $this->bankTransaction->setCurrencyFromString('EUR'); + $this->bankTransaction->setCurrency(Currency::fromCode('EUR')); $this->bankTransaction->setStartValue(Money::EUR(100)); $this->assertEquals('EUR', Util::objectToStr($this->bankTransaction->getCurrency())); @@ -33,14 +34,14 @@ public function testSetStartValue() public function testSetCurrencyWithoutStartValue() { - $this->bankTransaction->setCurrencyFromString('EUR'); + $this->bankTransaction->setCurrency(Currency::fromCode('EUR')); $this->assertEquals('EUR', Util::objectToStr($this->bankTransaction->getCurrency())); } public function testSetCurrencyWithZeroStartValue() { $this->bankTransaction->setStartvalue(Money::EUR(0)); - $this->bankTransaction->setCurrencyFromString('EUR'); + $this->bankTransaction->setCurrency(Currency::fromCode('EUR')); $this->assertEquals('EUR', Util::objectToStr($this->bankTransaction->getCurrency())); } @@ -50,7 +51,7 @@ public function testSetCurrencyWithStartValue() $this->expectException(InvalidArgumentException::class); $this->bankTransaction->setStartValue(Money::EUR(100)); - $this->bankTransaction->setCurrencyFromString('EUR'); + $this->bankTransaction->setCurrency(Currency::fromCode('EUR')); } public function testAddLineWithWrongTransactionLine() diff --git a/tests/UnitTests/CashTransactionLineUnitTest.php b/tests/UnitTests/CashTransactionLineUnitTest.php index 2f3602c5..8bb00ddf 100644 --- a/tests/UnitTests/CashTransactionLineUnitTest.php +++ b/tests/UnitTests/CashTransactionLineUnitTest.php @@ -53,7 +53,7 @@ public function testSetDim2() { $this->line->setLineType(LineType::DETAIL()); - $this->assertEquals($this->line, $this->line->setDim2FromString('test'), 'Fluid interface is expected'); + $this->assertEquals($this->line, $this->line->setDim2(\PhpTwinfield\CostCenter::fromCode('test')), 'Fluid interface is expected'); $this->assertSame('test', Util::objectToStr($this->line->getDim2())); } @@ -69,7 +69,7 @@ public function testSetDim3() { $this->line->setLineType(LineType::DETAIL()); - $this->assertEquals($this->line, $this->line->setDim3FromString('test'), 'Fluid interface is expected'); + $this->assertEquals($this->line, $this->line->setDim3(\PhpTwinfield\Project::fromCode('test')), 'Fluid interface is expected'); $this->assertSame('test', Util::objectToStr($this->line->getDim3())); } diff --git a/tests/UnitTests/CashTransactionUnitTest.php b/tests/UnitTests/CashTransactionUnitTest.php index 73909dc6..078c90c0 100644 --- a/tests/UnitTests/CashTransactionUnitTest.php +++ b/tests/UnitTests/CashTransactionUnitTest.php @@ -23,7 +23,7 @@ protected function setUp() public function testSetStartValue() { - $this->cashTransaction->setCurrencyFromString('EUR'); + $this->cashTransaction->setCurrency(Currency::fromCode('EUR')); $this->cashTransaction->setStartValue(Money::EUR(100)); $this->assertEquals('EUR', Util::objectToStr($this->cashTransaction->getCurrency())); @@ -33,14 +33,14 @@ public function testSetStartValue() public function testSetCurrencyWithoutStartValue() { - $this->cashTransaction->setCurrencyFromString('EUR'); + $this->cashTransaction->setCurrency(Currency::fromCode('EUR')); $this->assertEquals('EUR', Util::objectToStr($this->cashTransaction->getCurrency())); } public function testSetCurrencyWithZeroStartValue() { $this->cashTransaction->setStartvalue(Money::EUR(0)); - $this->cashTransaction->setCurrencyFromString('EUR'); + $this->cashTransaction->setCurrency(Currency::fromCode('EUR')); $this->assertEquals('EUR', Util::objectToStr($this->cashTransaction->getCurrency())); } @@ -50,7 +50,7 @@ public function testSetCurrencyWithStartValue() $this->expectException(InvalidArgumentException::class); $this->cashTransaction->setStartValue(Money::EUR(100)); - $this->cashTransaction->setCurrencyFromString('EUR'); + $this->cashTransaction->setCurrency(Currency::fromCode('EUR')); } public function testAddLineWithWrongTransactionLine() diff --git a/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php index 8c31c890..562c6536 100644 --- a/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php @@ -9,6 +9,7 @@ use PhpTwinfield\CustomerFinancials; use PhpTwinfield\DomDocuments\CustomersDocument; use PhpTwinfield\Office; +use PhpTwinfield\Util; use PHPUnit\Framework\TestCase; class CustomerDocumentUnitTest extends TestCase @@ -32,25 +33,28 @@ public function testXmlIsCreatedPerSpec() $customer->setName('Chuck Norris'); $customer->setWebsite('http://example.org'); $customer->setOffice(Office::fromCode("DEV-10000")); - $customer->setStatusFromString('active'); + $customer->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); $financials = new CustomerFinancials(); $financials->setDueDays(1); $financials->setPayAvailable(true); - $financials->setPayCodeFromString('pay-code'); - $financials->setVatCodeFromString('vat-code'); + $financials->setPayCode(\PhpTwinfield\PayCode:fromCode('pay-code')); + $financials->setVatCode(\PhpTwinfield\VatCode:fromCode('vat-code')); $financials->setEBilling(true); $financials->setEBillMail('ebillingmail@mail.com'); $customer->setFinancials($financials); + + $currency = new \PhpTwinfield\Currency; + $currency->setCode("EUR"); $customer->setCreditManagement( (new CustomerCreditManagement()) - ->setResponsibleUserFromString('responsible-user') - ->setBaseCreditLimitFromFloat(50) - ->setSendReminderFromString('true') + ->setResponsibleUser(\PhpTwinfield\User:fromCode('responsible-user')) + ->setBaseCreditLimit(Util:parseMoney(50, $currency)) + ->setSendReminder(\PhpTwinfield\Enums\SendReminder::TRUE()) ->setReminderEmail('reminderemail@mail.com') ->setBlocked(false) - ->setFreeText1FromString('true') + ->setFreeText1(true) ->setFreeText2('free2') ->setComment('comment comment') ); @@ -58,9 +62,9 @@ public function testXmlIsCreatedPerSpec() $customer->addAddress( (new CustomerAddress()) ->setDefault(true) - ->setTypeFromString('invoice') + ->setType(\PhpTwinfield\Enums\AddressType::INVOICE()) ->setName('My Address') - ->setCountryFromString('nl') + ->setCountry(\PhpTwinfield\Country:fromCode('nl')) ->setCity('city') ->setPostcode('postal code') ->setTelephone('phone number') @@ -84,7 +88,7 @@ public function testXmlIsCreatedPerSpec() ->setBankName('bank name') ->setBicCode('bic code') ->setCity('city') - ->setCountryFromString('nl') + ->setCountry(\PhpTwinfield\Country:fromCode('nl')) ->setIban('iban') ->setNatBicCode('nat-bic') ->setPostcode('postcode') @@ -98,7 +102,7 @@ public function testXmlIsCreatedPerSpec() $customer->setName('Nuck Chorris'); $customer->setWebsite('http://example.org'); $customer->setOffice(Office::fromCode("DEV-00001")); - $customer->setStatusFromString('deleted'); + $customer->setStatus(\PhpTwinfield\Enums\Status::DELETED()); $this->document->addCustomer($customer); diff --git a/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php b/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php index dea71d83..12c4910b 100644 --- a/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php @@ -31,21 +31,21 @@ public function testXmlIsCreatedPerSpec() $supplier->setName('Chuck Norris'); $supplier->setWebsite('http://example.org'); $supplier->setOffice(Office::fromCode("DEV-10000")); - $supplier->setStatusFromString('active'); + $supplier->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); $financials = new SupplierFinancials(); $financials->setDueDays(1); $financials->setPayAvailable(true); - $financials->setPayCodeFromString('pay-code'); - $financials->setVatCodeFromString('vat-code'); + $financials->setPayCode(\PhpTwinfield\PayCode:fromCode('pay-code')); + $financials->setVatCode(\PhpTwinfield\VatCode:fromCode('vat-code')); $supplier->setFinancials($financials); $supplier->addAddress( (new SupplierAddress()) ->setDefault(true) - ->setTypeFromString('invoice') + ->setType(\PhpTwinfield\Enums\AddressType::INVOICE()) ->setName('My Address') - ->setCountryFromString('nl') + ->setCountry(\PhpTwinfield\Country:fromCode('nl')) ->setCity('city') ->setPostcode('postal code') ->setTelephone('phone number') @@ -69,7 +69,7 @@ public function testXmlIsCreatedPerSpec() ->setBankName('bank name') ->setBicCode('bic code') ->setCity('city') - ->setCountryFromString('nl') + ->setCountry(\PhpTwinfield\Country:fromCode('nl')) ->setIban('iban') ->setNatBicCode('nat-bic') ->setPostcode('postcode') @@ -83,7 +83,7 @@ public function testXmlIsCreatedPerSpec() $supplier->setName('Nuck Chorris'); $supplier->setWebsite('http://example.org'); $supplier->setOffice(Office::fromCode("DEV-00001")); - $supplier->setStatusFromString('deleted'); + $supplier->setStatus(\PhpTwinfield\Enums\Status::DELETED()); $this->document->addSupplier($supplier); diff --git a/tests/UnitTests/ElectronicBankStatementUnitTest.php b/tests/UnitTests/ElectronicBankStatementUnitTest.php index ae570435..a378208f 100644 --- a/tests/UnitTests/ElectronicBankStatementUnitTest.php +++ b/tests/UnitTests/ElectronicBankStatementUnitTest.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\UnitTests; use Money\Money; +use PhpTwinfield\Currency; use PhpTwinfield\ElectronicBankStatement; use PhpTwinfield\Util; use PHPUnit\Framework\TestCase; @@ -15,7 +16,7 @@ class ElectronicBankStatementUnitTest extends TestCase public function testCanSetCurrencyManually() { $ebs = new ElectronicBankStatement(); - $ebs->setCurrencyFromString("HUF"); + $ebs->setCurrency(Currency::fromCode("HUF")); $this->assertEquals("HUF", Util::objectToStr($ebs->getCurrency())); } @@ -28,6 +29,6 @@ public function testCannotChangeCurrencyOnceValueIsSet() $ebs = new ElectronicBankStatement(); $ebs->setStartValue(Money::GBP(1)); - $ebs->setCurrencyFromString("EUR"); + $ebs->setCurrency(Currency::fromCode("EUR")); } } From ec96351f25d88d64f0a61548c6612ed53cbd2b0f Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 22 Jun 2019 13:28:34 +0200 Subject: [PATCH 326/388] Upload --- tests/IntegrationTests/CustomerIntegrationTest.php | 2 +- tests/IntegrationTests/InvoiceIntegrationTest.php | 8 ++++---- tests/UnitTests/CashTransactionUnitTest.php | 1 + tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php | 4 ++-- tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php | 4 ++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 4c661fc6..c8eaf1f9 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -209,7 +209,7 @@ public function testSendCustomerWorks() $address = new CustomerAddress(); $address->setID(1); - $address->setType(AddressType::INVOICE()); + $address->setType(\PhpTwinfield\Enums\AddressType::INVOICE()); $address->setDefault(true); $address->setName('Customer 0'); $address->setCountry(\PhpTwinfield\Country::fromCode('NL')); diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 91cfa243..aa3dd466 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -221,10 +221,10 @@ public function testSendInvoiceWorks() $invoiceLine->setAllowDiscountOrPremium(true); $invoiceLine->setDescription('CoalesceFunctioningOnImpatienceTShirt'); $currency = \PhpTwinfield\Currency::fromCode('EUR'); - $invoiceLine->setValueExcl(Util:parseMoney(15.00, $currency)); - $invoiceLine->setVatValue(Util:parseMoney(0.00, $currency)); - $invoiceLine->setValueInc(Util:parseMoney(15.00, $currency)); - $invoiceLine->setUnitsPriceExcl(Util:parseMoney(15.00, $currency)); + $invoiceLine->setValueExcl(Util::parseMoney(15.00, $currency)); + $invoiceLine->setVatValue(Util::parseMoney(0.00, $currency)); + $invoiceLine->setValueInc(Util::parseMoney(15.00, $currency)); + $invoiceLine->setUnitsPriceExcl(Util::parseMoney(15.00, $currency)); $invoiceLine->setDim1(\PhpTwinfield\GeneralLedger::fromCode('8020')); $invoiceLine->setVatCode(\PhpTwinfield\VatCode::fromCode('VN')); $invoice->addLine($invoiceLine); diff --git a/tests/UnitTests/CashTransactionUnitTest.php b/tests/UnitTests/CashTransactionUnitTest.php index 078c90c0..7123e370 100644 --- a/tests/UnitTests/CashTransactionUnitTest.php +++ b/tests/UnitTests/CashTransactionUnitTest.php @@ -5,6 +5,7 @@ use Money\Money; use PhpTwinfield\CashTransaction; use PhpTwinfield\CashTransactionLine; +use PhpTwinfield\Currency; use PhpTwinfield\Enums\LineType; use PhpTwinfield\SalesTransactionLine; use PhpTwinfield\Util; diff --git a/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php index 562c6536..0ce7ceaf 100644 --- a/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php @@ -38,8 +38,8 @@ public function testXmlIsCreatedPerSpec() $financials = new CustomerFinancials(); $financials->setDueDays(1); $financials->setPayAvailable(true); - $financials->setPayCode(\PhpTwinfield\PayCode:fromCode('pay-code')); - $financials->setVatCode(\PhpTwinfield\VatCode:fromCode('vat-code')); + $financials->setPayCode(\PhpTwinfield\PayCode::fromCode('pay-code')); + $financials->setVatCode(\PhpTwinfield\VatCode::fromCode('vat-code')); $financials->setEBilling(true); $financials->setEBillMail('ebillingmail@mail.com'); $customer->setFinancials($financials); diff --git a/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php b/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php index 12c4910b..1da3f921 100644 --- a/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php @@ -36,8 +36,8 @@ public function testXmlIsCreatedPerSpec() $financials = new SupplierFinancials(); $financials->setDueDays(1); $financials->setPayAvailable(true); - $financials->setPayCode(\PhpTwinfield\PayCode:fromCode('pay-code')); - $financials->setVatCode(\PhpTwinfield\VatCode:fromCode('vat-code')); + $financials->setPayCode(\PhpTwinfield\PayCode::fromCode('pay-code')); + $financials->setVatCode(\PhpTwinfield\VatCode::fromCode('vat-code')); $supplier->setFinancials($financials); $supplier->addAddress( From 03fc0554deb5a0408947bdc4c01c7f1464c41071 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 22 Jun 2019 13:31:41 +0200 Subject: [PATCH 327/388] Upload --- tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php | 4 ++-- tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php index 0ce7ceaf..ed5e275c 100644 --- a/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php @@ -64,7 +64,7 @@ public function testXmlIsCreatedPerSpec() ->setDefault(true) ->setType(\PhpTwinfield\Enums\AddressType::INVOICE()) ->setName('My Address') - ->setCountry(\PhpTwinfield\Country:fromCode('nl')) + ->setCountry(\PhpTwinfield\Country::fromCode('nl')) ->setCity('city') ->setPostcode('postal code') ->setTelephone('phone number') @@ -88,7 +88,7 @@ public function testXmlIsCreatedPerSpec() ->setBankName('bank name') ->setBicCode('bic code') ->setCity('city') - ->setCountry(\PhpTwinfield\Country:fromCode('nl')) + ->setCountry(\PhpTwinfield\Country::fromCode('nl')) ->setIban('iban') ->setNatBicCode('nat-bic') ->setPostcode('postcode') diff --git a/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php b/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php index 1da3f921..9f818283 100644 --- a/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php @@ -45,7 +45,7 @@ public function testXmlIsCreatedPerSpec() ->setDefault(true) ->setType(\PhpTwinfield\Enums\AddressType::INVOICE()) ->setName('My Address') - ->setCountry(\PhpTwinfield\Country:fromCode('nl')) + ->setCountry(\PhpTwinfield\Country::fromCode('nl')) ->setCity('city') ->setPostcode('postal code') ->setTelephone('phone number') @@ -69,7 +69,7 @@ public function testXmlIsCreatedPerSpec() ->setBankName('bank name') ->setBicCode('bic code') ->setCity('city') - ->setCountry(\PhpTwinfield\Country:fromCode('nl')) + ->setCountry(\PhpTwinfield\Country::fromCode('nl')) ->setIban('iban') ->setNatBicCode('nat-bic') ->setPostcode('postcode') From 0d33c249a8ed6789b86957d9f8937690c55ebb0f Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 22 Jun 2019 13:33:53 +0200 Subject: [PATCH 328/388] Update CustomerDocumentUnitTest.php --- tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php index ed5e275c..e26f9e68 100644 --- a/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php @@ -50,7 +50,7 @@ public function testXmlIsCreatedPerSpec() $customer->setCreditManagement( (new CustomerCreditManagement()) ->setResponsibleUser(\PhpTwinfield\User:fromCode('responsible-user')) - ->setBaseCreditLimit(Util:parseMoney(50, $currency)) + ->setBaseCreditLimit(Util::parseMoney(50, $currency)) ->setSendReminder(\PhpTwinfield\Enums\SendReminder::TRUE()) ->setReminderEmail('reminderemail@mail.com') ->setBlocked(false) From dcf54bb9d2b1f75d46c6dcdae7d92d8f889abd4e Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 22 Jun 2019 13:35:44 +0200 Subject: [PATCH 329/388] Update CustomerDocumentUnitTest.php --- tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php index e26f9e68..2f849345 100644 --- a/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php @@ -49,7 +49,7 @@ public function testXmlIsCreatedPerSpec() $customer->setCreditManagement( (new CustomerCreditManagement()) - ->setResponsibleUser(\PhpTwinfield\User:fromCode('responsible-user')) + ->setResponsibleUser(\PhpTwinfield\User::fromCode('responsible-user')) ->setBaseCreditLimit(Util::parseMoney(50, $currency)) ->setSendReminder(\PhpTwinfield\Enums\SendReminder::TRUE()) ->setReminderEmail('reminderemail@mail.com') From af7618dd27d87a799f05008a66366f3e3ed22216 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 22 Jun 2019 13:47:07 +0200 Subject: [PATCH 330/388] Upload --- src/BankTransaction.php | 5 +++++ src/CashTransaction.php | 5 +++++ src/ElectronicBankStatement.php | 8 ++++++++ src/Fields/VatCode/TypeField.php | 10 ++++++++++ tests/IntegrationTests/InvoiceIntegrationTest.php | 2 +- .../ElectronicBankStatementDocumentUnitTest.php | 8 ++++---- .../DomDocuments/SupplierDocumentUnitTest.php | 4 ++-- 7 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/BankTransaction.php b/src/BankTransaction.php index b0baac8c..53601db3 100644 --- a/src/BankTransaction.php +++ b/src/BankTransaction.php @@ -19,6 +19,11 @@ class BankTransaction extends BaseTransaction use StatementNumberField; + public function __construct() + { + $this->startValue = new \Money\Money(0, new \Money\Currency('EUR')); + } + /* * @return string */ diff --git a/src/CashTransaction.php b/src/CashTransaction.php index 78057b25..6df540b2 100644 --- a/src/CashTransaction.php +++ b/src/CashTransaction.php @@ -19,6 +19,11 @@ class CashTransaction extends BaseTransaction use StatementNumberField; + public function __construct() + { + $this->startValue = new \Money\Money(0, new \Money\Currency('EUR')); + } + /* * @return string */ diff --git a/src/ElectronicBankStatement.php b/src/ElectronicBankStatement.php index d2e14fd1..d132c3ea 100644 --- a/src/ElectronicBankStatement.php +++ b/src/ElectronicBankStatement.php @@ -56,6 +56,14 @@ class ElectronicBankStatement */ private $transactions = []; + public function __construct() + { + $currency = new \PhpTwinfield\Currency; + $currency->setCode('EUR'); + $this->currency = $currency; + $this->startValue = new \Money\Money(0, new \Money\Currency($currency->getCode())); + } + public function getAccount(): ?string { return $this->account; diff --git a/src/Fields/VatCode/TypeField.php b/src/Fields/VatCode/TypeField.php index a2887179..d685c0c1 100644 --- a/src/Fields/VatCode/TypeField.php +++ b/src/Fields/VatCode/TypeField.php @@ -28,4 +28,14 @@ public function setType(?VatType $type): self $this->type = $type; return $this; } + + /** + * @param string|null $typeString + * @return $this + * @throws Exception + */ + public function setTypeFromString(?string $typeString) + { + return $this->setType(new VatType((string)$typeString)); + } } \ No newline at end of file diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index aa3dd466..bb622239 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -207,7 +207,7 @@ public function testSendInvoiceWorks() $invoice->setCustomer($customer); $invoice->setPeriod('2012/08'); $invoice->setCurrency(Currency::fromCode('EUR')); - $invoice->setStatus(\PhpTwinfield\Enums\Status::CONCEPT()); + $invoice->setStatus(\PhpTwinfield\Enums\InvoiceStatus::CONCEPT()); $invoice->setPaymentMethod(\PhpTwinfield\Enums\PaymentMethod::CASH()); $invoice->setHeaderText('HEADER'); $invoice->setFooterText('FOOTER'); diff --git a/tests/UnitTests/DomDocuments/ElectronicBankStatementDocumentUnitTest.php b/tests/UnitTests/DomDocuments/ElectronicBankStatementDocumentUnitTest.php index e7d4dbaa..bd4715af 100644 --- a/tests/UnitTests/DomDocuments/ElectronicBankStatementDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/ElectronicBankStatementDocumentUnitTest.php @@ -45,13 +45,13 @@ public function testDocumentationExampleCreatedSuccessfully() N100 credit - 151 + 151.00 Invoice 3722838 N999 debit - 7.5 + 7.50 Costs *300 @@ -78,8 +78,8 @@ public function testImportDuplicateIsSet() 20171130 EUR - 0 - 0 + 0.00 + 0.00 236 diff --git a/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php b/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php index 9f818283..58f7b1b5 100644 --- a/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/SupplierDocumentUnitTest.php @@ -129,7 +129,7 @@ public function testXmlIsCreatedPerSpec()
- +
address 2 address 3 @@ -175,7 +175,7 @@ public function testXmlIsCreatedPerSpec() 30 - false + From f4a778076b1b6129154a262f0239588019ad3522 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 22 Jun 2019 13:48:17 +0200 Subject: [PATCH 331/388] Update CustomerDocumentUnitTest.php --- tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php index 2f849345..7faa644a 100644 --- a/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php @@ -43,14 +43,11 @@ public function testXmlIsCreatedPerSpec() $financials->setEBilling(true); $financials->setEBillMail('ebillingmail@mail.com'); $customer->setFinancials($financials); - - $currency = new \PhpTwinfield\Currency; - $currency->setCode("EUR"); $customer->setCreditManagement( (new CustomerCreditManagement()) ->setResponsibleUser(\PhpTwinfield\User::fromCode('responsible-user')) - ->setBaseCreditLimit(Util::parseMoney(50, $currency)) + ->setBaseCreditLimit(Util::parseMoney(50, new \Money\Currency("EUR"))) ->setSendReminder(\PhpTwinfield\Enums\SendReminder::TRUE()) ->setReminderEmail('reminderemail@mail.com') ->setBlocked(false) From f53a222996c6484391252c03c0029fa7bd60262d Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 22 Jun 2019 13:56:43 +0200 Subject: [PATCH 332/388] Update BaseMapper.php --- src/Mappers/BaseMapper.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index d39354d0..0a4bb794 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -119,6 +119,8 @@ protected static function parseUnknownEntity($object, \DOMElement $element, stri { if (is_a($object, \PhpTwinfield\DimensionGroupDimension::class)) { $type = self::getField($element, "type", $object); + } elseif (is_a($object, \PhpTwinfield\TransactionLineInterface::class)) { + $type = self::getAttribute($element, $fieldTagName, "type"); } else { $type = self::getAttribute($element, $fieldTagName, "dimensiontype"); } From b9fa8ddf014d6225ab7f5ce54dabf3be55900715 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 11:11:51 +0200 Subject: [PATCH 333/388] Upload --- src/Mappers/BaseMapper.php | 2 + .../CustomerIntegrationTest.php | 2 +- .../InvoiceIntegrationTest.php | 8 +- .../DomDocuments/CustomerDocumentUnitTest.php | 92 +++++++++---------- 4 files changed, 53 insertions(+), 51 deletions(-) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index 0a4bb794..afbd5e82 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -121,8 +121,10 @@ protected static function parseUnknownEntity($object, \DOMElement $element, stri $type = self::getField($element, "type", $object); } elseif (is_a($object, \PhpTwinfield\TransactionLineInterface::class)) { $type = self::getAttribute($element, $fieldTagName, "type"); + $type = "BAS"; } else { $type = self::getAttribute($element, $fieldTagName, "dimensiontype"); + $type = "PNL"; } switch ($type) { diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index c8eaf1f9..6becf3de 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -154,7 +154,7 @@ public function testGetCustomerWorks() $creditmanagement = $customer->getCreditManagement(); $this->assertNull(Util::objectToStr($creditmanagement->getResponsibleUser())); - $this->assertSame(0.00, Util::formatMoney($creditmanagement->getBaseCreditLimit())); + $this->assertSame('0.00', Util::formatMoney($creditmanagement->getBaseCreditLimit())); $ReflectObject = new \ReflectionClass('\PhpTwinfield\Enums\SendReminder'); $this->assertSame($ReflectObject->getConstant('TRUE'), (string)$creditmanagement->getSendReminder()); $this->assertNull($creditmanagement->getReminderEmail()); diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index bb622239..d5cfbd11 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -99,10 +99,10 @@ public function testGetConceptInvoiceWorks() $this->assertSame(1, $invoiceLine->getUnits()); $this->assertSame(true, $invoiceLine->getAllowDiscountOrPremium()); $this->assertSame('CoalesceFunctioningOnImpatienceTShirt', $invoiceLine->getDescription()); - $this->assertSame(15.00, Util::formatMoney($invoiceLine->getValueExcl())); - $this->assertSame(0.00, Util::formatMoney($invoiceLine->getVatValue())); - $this->assertSame(15.00, Util::formatMoney($invoiceLine->getValueInc())); - $this->assertSame(15.00, Util::formatMoney($invoiceLine->getUnitsPriceExcl())); + $this->assertSame('15.00', Util::formatMoney($invoiceLine->getValueExcl())); + $this->assertSame('0.00', Util::formatMoney($invoiceLine->getVatValue())); + $this->assertSame('15.00', Util::formatMoney($invoiceLine->getValueInc())); + $this->assertSame('15.00', Util::formatMoney($invoiceLine->getUnitsPriceExcl())); $this->assertSame('8020', Util::objectToStr($invoiceLine->getDim1())); $invoiceVatLines = $invoice->getVatLines(); diff --git a/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php index 7faa644a..730b4f01 100644 --- a/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php @@ -123,26 +123,26 @@ public function testXmlIsCreatedPerSpec() 1 true ebillingmail@mail.com - + true pay-code vat-code - + - 50 - false - comment comment - true + 50.00 + false + comment comment + true free2 - - reminderemail@mail.com - responsible-user + + reminderemail@mail.com + responsible-user true - - - + + +
city @@ -155,14 +155,14 @@ public function testXmlIsCreatedPerSpec() field 5 field 6 My Address - postal code - fax number + postal code + fax number phone number
-
+
address 2 address 3
@@ -178,13 +178,13 @@ public function testXmlIsCreatedPerSpec() state - - + + - - - - + + + + @@ -201,39 +201,39 @@ public function testXmlIsCreatedPerSpec() DEB http://example.org - core - 30 - false - - - false - - - + core + 30 + + + + + + + - 0 - false - - false - - - - - true + + + + + + + + + true - + - - + + - - - - + + + + From 052507f02cef006b6ed70cd98ddd5bcb00e8b36c Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 11:22:00 +0200 Subject: [PATCH 334/388] Upload --- tests/IntegrationTests/CustomerIntegrationTest.php | 2 ++ tests/IntegrationTests/InvoiceIntegrationTest.php | 11 +++++------ .../PurchaseTransactionIntegrationTest.php | 2 ++ .../SalesTransactionIntegrationTest.php | 2 ++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 6becf3de..3cc35b92 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -194,6 +194,7 @@ public function testSendCustomerWorks() $customer->setOffice(Office::fromCode('001')); $customer->setName('Customer 0'); + /* $financials = new CustomerFinancials(); $financials->setDueDays(30); $financials->setPayAvailable(true); @@ -253,5 +254,6 @@ public function testSendCustomerWorks() }); $this->customerApiConnector->send($customer); + */ } } diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index d5cfbd11..1756205c 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -139,7 +139,7 @@ public function testGetFinalInvoiceWorks() $this->assertEquals(Office::fromCode("11024"), $invoice->getOffice()); $this->assertSame('FACTUUR', Util::objectToStr($invoice->getInvoiceType())); $this->assertSame('5', $invoice->getInvoiceNumber()); - $this->assertSame('20120831', Util::parseDate($invoice->getInvoiceDate())); + $this->assertSame('20120831', Util::formatDate($invoice->getInvoiceDate())); $this->assertSame('BNK', Util::objectToStr($invoice->getBank())); $this->assertSame(1, $invoice->getInvoiceAddressNumber()); $this->assertSame(1, $invoice->getDeliverAddressNumber()); @@ -220,11 +220,10 @@ public function testSendInvoiceWorks() $invoiceLine->setUnits(1); $invoiceLine->setAllowDiscountOrPremium(true); $invoiceLine->setDescription('CoalesceFunctioningOnImpatienceTShirt'); - $currency = \PhpTwinfield\Currency::fromCode('EUR'); - $invoiceLine->setValueExcl(Util::parseMoney(15.00, $currency)); - $invoiceLine->setVatValue(Util::parseMoney(0.00, $currency)); - $invoiceLine->setValueInc(Util::parseMoney(15.00, $currency)); - $invoiceLine->setUnitsPriceExcl(Util::parseMoney(15.00, $currency)); + $invoiceLine->setValueExcl(Util::parseMoney(15.00, new Money\Currency('EUR'))); + $invoiceLine->setVatValue(Util::parseMoney(0.00, new Money\Currency('EUR'))); + $invoiceLine->setValueInc(Util::parseMoney(15.00, new Money\Currency('EUR'))); + $invoiceLine->setUnitsPriceExcl(Util::parseMoney(15.00, new Money\Currency('EUR'))); $invoiceLine->setDim1(\PhpTwinfield\GeneralLedger::fromCode('8020')); $invoiceLine->setVatCode(\PhpTwinfield\VatCode::fromCode('VN')); $invoice->addLine($invoiceLine); diff --git a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php index 34932684..61806343 100644 --- a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php +++ b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php @@ -150,6 +150,7 @@ public function testGetPurchaseTransactionWorks() public function testSendPurchaseTransactionWorks() { + /* $purchaseTransaction = new PurchaseTransaction(); $purchaseTransaction ->setDestiny(Destiny::TEMPORARY()) @@ -199,6 +200,7 @@ public function testSendPurchaseTransactionWorks() }); $this->transactionApiConnector->send($purchaseTransaction); + */ } protected function getSuccessfulResponse(): Response diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index 8db94330..421ab815 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -178,6 +178,7 @@ public function testSendSalesTransactionWorks() ->setOffice(Office::fromCode('001')) ->setDueDate(new \DateTimeImmutable('2013-05-06')); + /* $totalLine = new SalesTransactionLine(); $totalLine ->setLineType(LineType::TOTAL()) @@ -214,6 +215,7 @@ public function testSendSalesTransactionWorks() }); $this->transactionApiConnector->send($salesTransaction); + */ } protected function getSuccessfulResponse(): Response From dae63436a195632ba97dbe6a09aece9f3dc82f4c Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 11:26:51 +0200 Subject: [PATCH 335/388] Upload --- .../CustomerIntegrationTest.php | 6 +++-- .../InvoiceIntegrationTest.php | 22 +++++++++---------- .../PurchaseTransactionIntegrationTest.php | 3 ++- .../SalesTransactionIntegrationTest.php | 6 +++-- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 3cc35b92..f05a43a0 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -159,7 +159,7 @@ public function testGetCustomerWorks() $this->assertSame($ReflectObject->getConstant('TRUE'), (string)$creditmanagement->getSendReminder()); $this->assertNull($creditmanagement->getReminderEmail()); $this->assertSame(false, $creditmanagement->getBlocked()); - $this->assertSame(false, $creditmanagement->getFreeText1()); + $this->assertNull($creditmanagement->getFreeText1()); $this->assertNull($creditmanagement->getFreeText2()); $this->assertNull($creditmanagement->getFreeText3()); $this->assertNull($creditmanagement->getComment()); @@ -194,7 +194,6 @@ public function testSendCustomerWorks() $customer->setOffice(Office::fromCode('001')); $customer->setName('Customer 0'); - /* $financials = new CustomerFinancials(); $financials->setDueDays(30); $financials->setPayAvailable(true); @@ -224,6 +223,9 @@ public function testSendCustomerWorks() $address->setField3('Streetname part 1 - 2'); $customer->addAddress($address); + $this->assertNull(null); + + /* $bank = new CustomerBank(); $bank->setDefault(true); $bank->setAscription('Customer 1'); diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 1756205c..6644f551 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -112,12 +112,12 @@ public function testGetConceptInvoiceWorks() $invoiceVatLine = current($invoiceVatLines); $this->assertSame('VN', Util::objectToStr($invoiceLine->getVatCode())); - $this->assertSame(0.00, Util::formatMoney($invoiceLine->getVatValue())); + $this->assertSame('0.00', Util::formatMoney($invoiceLine->getVatValue())); $this->assertNull($invoiceLine->getPerformanceType()); $this->assertNull($invoiceLine->getPerformanceDate()); - $this->assertSame(15.00, Util::formatMoney($invoice->getTotals()->getValueInc())); - $this->assertSame(15.00, Util::formatMoney($invoice->getTotals()->getValueExcl())); + $this->assertSame('15.00', Util::formatMoney($invoice->getTotals()->getValueInc())); + $this->assertSame('15.00', Util::formatMoney($invoice->getTotals()->getValueExcl())); $this->assertNull($invoice->getFinancialNumber()); $this->assertNull($invoice->getFinancialCode()); @@ -167,10 +167,10 @@ public function testGetFinalInvoiceWorks() $this->assertSame(1, $invoiceLine->getUnits()); $this->assertSame(true, $invoiceLine->getAllowDiscountOrPremium()); $this->assertSame('CoalesceFunctioningOnImpatienceTShirt', $invoiceLine->getDescription()); - $this->assertSame(15.00, Util::formatMoney($invoiceLine->getValueExcl())); - $this->assertSame(0.00, Util::formatMoney($invoiceLine->getVatValue())); - $this->assertSame(15.00, Util::formatMoney($invoiceLine->getValueInc())); - $this->assertSame(15.00, Util::formatMoney($invoiceLine->getUnitsPriceExcl())); + $this->assertSame('15.00', Util::formatMoney($invoiceLine->getValueExcl())); + $this->assertSame('0.00', Util::formatMoney($invoiceLine->getVatValue())); + $this->assertSame('15.00', Util::formatMoney($invoiceLine->getValueInc())); + $this->assertSame('15.00', Util::formatMoney($invoiceLine->getUnitsPriceExcl())); $this->assertSame('8020', Util::objectToStr($invoiceLine->getDim1())); $invoiceVatLines = $invoice->getVatLines(); @@ -220,10 +220,10 @@ public function testSendInvoiceWorks() $invoiceLine->setUnits(1); $invoiceLine->setAllowDiscountOrPremium(true); $invoiceLine->setDescription('CoalesceFunctioningOnImpatienceTShirt'); - $invoiceLine->setValueExcl(Util::parseMoney(15.00, new Money\Currency('EUR'))); - $invoiceLine->setVatValue(Util::parseMoney(0.00, new Money\Currency('EUR'))); - $invoiceLine->setValueInc(Util::parseMoney(15.00, new Money\Currency('EUR'))); - $invoiceLine->setUnitsPriceExcl(Util::parseMoney(15.00, new Money\Currency('EUR'))); + $invoiceLine->setValueExcl(Util::parseMoney(15.00, new \Money\Currency('EUR'))); + $invoiceLine->setVatValue(Util::parseMoney(0.00, new \Money\Currency('EUR'))); + $invoiceLine->setValueInc(Util::parseMoney(15.00, new \Money\Currency('EUR'))); + $invoiceLine->setUnitsPriceExcl(Util::parseMoney(15.00, new \Money\Currency('EUR'))); $invoiceLine->setDim1(\PhpTwinfield\GeneralLedger::fromCode('8020')); $invoiceLine->setVatCode(\PhpTwinfield\VatCode::fromCode('VN')); $invoice->addLine($invoiceLine); diff --git a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php index 61806343..9b2ac444 100644 --- a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php +++ b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php @@ -150,7 +150,6 @@ public function testGetPurchaseTransactionWorks() public function testSendPurchaseTransactionWorks() { - /* $purchaseTransaction = new PurchaseTransaction(); $purchaseTransaction ->setDestiny(Destiny::TEMPORARY()) @@ -173,6 +172,8 @@ public function testSendPurchaseTransactionWorks() ->setValue(Money::EUR(12100)) ->setDescription(''); + $this->assertNull(null); + /* $detailLine = new PurchaseTransactionLine(); $detailLine ->setLineType(LineType::DETAIL()) diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index 421ab815..2a490966 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -178,7 +178,6 @@ public function testSendSalesTransactionWorks() ->setOffice(Office::fromCode('001')) ->setDueDate(new \DateTimeImmutable('2013-05-06')); - /* $totalLine = new SalesTransactionLine(); $totalLine ->setLineType(LineType::TOTAL()) @@ -200,7 +199,10 @@ public function testSendSalesTransactionWorks() $salesTransaction ->addLine($totalLine) ->addLine($detailLine); - + + $this->assertNull(null); + + /* $this->processXmlService ->expects($this->once()) ->method("sendDocument") From 0f85eaead4204cb56107f3f613318edec7d3b449 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 11:32:07 +0200 Subject: [PATCH 336/388] Upload --- tests/IntegrationTests/CustomerIntegrationTest.php | 6 +++--- tests/IntegrationTests/InvoiceIntegrationTest.php | 12 ++++++++---- .../PurchaseTransactionIntegrationTest.php | 4 ++-- .../SalesTransactionIntegrationTest.php | 2 +- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index f05a43a0..71b47706 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -223,9 +223,6 @@ public function testSendCustomerWorks() $address->setField3('Streetname part 1 - 2'); $customer->addAddress($address); - $this->assertNull(null); - - /* $bank = new CustomerBank(); $bank->setDefault(true); $bank->setAscription('Customer 1'); @@ -241,7 +238,10 @@ public function testSendCustomerWorks() $bank->setPostcode(''); $bank->setState(''); $customer->addBank($bank); + + $this->assertNull(null); + /* $this->processXmlService ->expects($this->once()) ->method("sendDocument") diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 6644f551..e3f32f07 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -180,12 +180,12 @@ public function testGetFinalInvoiceWorks() $invoiceVatLine = current($invoiceVatLines); $this->assertSame('VN', Util::objectToStr($invoiceLine->getVatCode())); - $this->assertSame(0.00, Util::formatMoney($invoiceLine->getVatValue())); + $this->assertSame('0.00', Util::formatMoney($invoiceLine->getVatValue())); $this->assertNull($invoiceLine->getPerformanceType()); $this->assertNull($invoiceLine->getPerformanceDate()); - $this->assertSame(15.00, Util::formatMoney($invoice->getTotals()->getValueInc())); - $this->assertSame(15.00, Util::formatMoney($invoice->getTotals()->getValueExcl())); + $this->assertSame('15.00', Util::formatMoney($invoice->getTotals()->getValueInc())); + $this->assertSame('15.00', Util::formatMoney($invoice->getTotals()->getValueExcl())); $this->assertSame(123456789, $invoice->getFinancialNumber()); $this->assertSame('123456789', $invoice->getFinancialCode()); @@ -227,7 +227,10 @@ public function testSendInvoiceWorks() $invoiceLine->setDim1(\PhpTwinfield\GeneralLedger::fromCode('8020')); $invoiceLine->setVatCode(\PhpTwinfield\VatCode::fromCode('VN')); $invoice->addLine($invoiceLine); - + + $this->assertNull(null); + + /* $this->processXmlService ->expects($this->once()) ->method("sendDocument") @@ -242,6 +245,7 @@ public function testSendInvoiceWorks() }); $this->invoiceApiConnector->send($invoice); + */ } protected function getSuccessfulResponse(): Response diff --git a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php index 9b2ac444..15558e47 100644 --- a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php +++ b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php @@ -172,8 +172,6 @@ public function testSendPurchaseTransactionWorks() ->setValue(Money::EUR(12100)) ->setDescription(''); - $this->assertNull(null); - /* $detailLine = new PurchaseTransactionLine(); $detailLine ->setLineType(LineType::DETAIL()) @@ -187,6 +185,8 @@ public function testSendPurchaseTransactionWorks() ->addLine($totalLine) ->addLine($detailLine); + $this->assertNull(null); + /* $this->processXmlService ->expects($this->once()) ->method("sendDocument") diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index 2a490966..cd87b82d 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -202,7 +202,6 @@ public function testSendSalesTransactionWorks() $this->assertNull(null); - /* $this->processXmlService ->expects($this->once()) ->method("sendDocument") @@ -216,6 +215,7 @@ public function testSendSalesTransactionWorks() return $this->getSuccessfulResponse(); }); + /* $this->transactionApiConnector->send($salesTransaction); */ } From f73bb7a3bf77b58f05718555e6577bfef228a6d6 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 11:34:32 +0200 Subject: [PATCH 337/388] Update SalesTransactionIntegrationTest.php --- tests/IntegrationTests/SalesTransactionIntegrationTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index cd87b82d..3693a7e3 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -215,9 +215,7 @@ public function testSendSalesTransactionWorks() return $this->getSuccessfulResponse(); }); - /* $this->transactionApiConnector->send($salesTransaction); - */ } protected function getSuccessfulResponse(): Response From cadb1c6cba4228b318e877e90ec1338a8fab57ff Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 11:42:28 +0200 Subject: [PATCH 338/388] Upload --- src/ApiConnectors/CustomerApiConnector.php | 4 ++-- src/Mappers/CustomerMapper.php | 8 ++++---- tests/IntegrationTests/CustomerIntegrationTest.php | 4 ---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/ApiConnectors/CustomerApiConnector.php b/src/ApiConnectors/CustomerApiConnector.php index 06003075..7f183ae0 100644 --- a/src/ApiConnectors/CustomerApiConnector.php +++ b/src/ApiConnectors/CustomerApiConnector.php @@ -46,7 +46,7 @@ public function get(string $code, Office $office): Customer // Send the Request document and set the response to this instance. $response = $this->sendXmlDocument($request_customer); - return CustomerMapper::map($response, $this->getConnection()); + return CustomerMapper::map($response); } /** @@ -86,7 +86,7 @@ public function sendAll(array $customers): MappedResponseCollection } return $this->getProcessXmlService()->mapAll($responses, "dimension", function(Response $response): Customer { - return CustomerMapper::map($response, $this->getConnection()); + return CustomerMapper::map($response); }); } diff --git a/src/Mappers/CustomerMapper.php b/src/Mappers/CustomerMapper.php index f2361e39..521f2b82 100644 --- a/src/Mappers/CustomerMapper.php +++ b/src/Mappers/CustomerMapper.php @@ -29,11 +29,10 @@ class CustomerMapper extends BaseMapper * * @access public * @param \PhpTwinfield\Response\Response $response - * @param \PhpTwinfield\Secure\AuthenticatedConnection $connection * @return Customer * @throws \PhpTwinfield\Exception */ - public static function map(Response $response, AuthenticatedConnection $connection) + public static function map(Response $response) { // Generate new Customer object $customer = new Customer(); @@ -65,8 +64,9 @@ public static function map(Response $response, AuthenticatedConnection $connecti ->setUID(self::getField($customerElement, 'uid', $customer)) ->setWebsite(self::getField($customerElement, 'website', $customer)); - $currencies = self::getOfficeCurrencies($connection, $customer->getOffice()); - + //$currencies = self::getOfficeCurrencies($connection, $customer->getOffice()); + $currencies = ["base" => "EUR", "reporting" => "USD"]; + // Set the customer elements from the customer element attributes $customer->setDiscountArticleID(self::getAttribute($customerElement, 'discountarticle', 'id')); diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 71b47706..921c53b8 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -238,10 +238,7 @@ public function testSendCustomerWorks() $bank->setPostcode(''); $bank->setState(''); $customer->addBank($bank); - - $this->assertNull(null); - /* $this->processXmlService ->expects($this->once()) ->method("sendDocument") @@ -256,6 +253,5 @@ public function testSendCustomerWorks() }); $this->customerApiConnector->send($customer); - */ } } From 93433890b6f1ddf359853bd8601660b1a281fd2d Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 11:44:43 +0200 Subject: [PATCH 339/388] Update CustomersDocument.php --- src/DomDocuments/CustomersDocument.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/DomDocuments/CustomersDocument.php b/src/DomDocuments/CustomersDocument.php index a6ef0058..35236a51 100644 --- a/src/DomDocuments/CustomersDocument.php +++ b/src/DomDocuments/CustomersDocument.php @@ -43,6 +43,7 @@ public function addCustomer(Customer $customer) $customerElement->setAttribute('status', $status); } + /* $customerElement->appendChild($this->createNodeWithTextContent('beginperiod', $customer->getBeginPeriod())); $customerElement->appendChild($this->createNodeWithTextContent('beginyear', $customer->getBeginYear())); @@ -287,5 +288,6 @@ public function addCustomer(Customer $customer) $paymentconditionElement->appendChild($this->createNodeWithTextContent('discountdays', $customer->getPaymentConditionDiscountDays())); $paymentconditionElement->appendChild($this->createNodeWithTextContent('discountpercentage', $customer->getPaymentConditionDiscountPercentage())); + */ } } \ No newline at end of file From c766b27c4104fb3096206edf02a13ee84616c08d Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 11:58:04 +0200 Subject: [PATCH 340/388] Upload --- src/ApiConnectors/CustomerApiConnector.php | 4 ++-- src/DomDocuments/CustomersDocument.php | 2 -- src/Mappers/CustomerMapper.php | 8 ++++---- tests/IntegrationTests/BankTransactionIntegrationTest.php | 2 +- tests/IntegrationTests/CustomerIntegrationTest.php | 2 +- tests/IntegrationTests/InvoiceIntegrationTest.php | 8 ++------ .../PurchaseTransactionIntegrationTest.php | 5 +---- .../IntegrationTests/SalesTransactionIntegrationTest.php | 6 ++---- 8 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/ApiConnectors/CustomerApiConnector.php b/src/ApiConnectors/CustomerApiConnector.php index 7f183ae0..06003075 100644 --- a/src/ApiConnectors/CustomerApiConnector.php +++ b/src/ApiConnectors/CustomerApiConnector.php @@ -46,7 +46,7 @@ public function get(string $code, Office $office): Customer // Send the Request document and set the response to this instance. $response = $this->sendXmlDocument($request_customer); - return CustomerMapper::map($response); + return CustomerMapper::map($response, $this->getConnection()); } /** @@ -86,7 +86,7 @@ public function sendAll(array $customers): MappedResponseCollection } return $this->getProcessXmlService()->mapAll($responses, "dimension", function(Response $response): Customer { - return CustomerMapper::map($response); + return CustomerMapper::map($response, $this->getConnection()); }); } diff --git a/src/DomDocuments/CustomersDocument.php b/src/DomDocuments/CustomersDocument.php index 35236a51..a6ef0058 100644 --- a/src/DomDocuments/CustomersDocument.php +++ b/src/DomDocuments/CustomersDocument.php @@ -43,7 +43,6 @@ public function addCustomer(Customer $customer) $customerElement->setAttribute('status', $status); } - /* $customerElement->appendChild($this->createNodeWithTextContent('beginperiod', $customer->getBeginPeriod())); $customerElement->appendChild($this->createNodeWithTextContent('beginyear', $customer->getBeginYear())); @@ -288,6 +287,5 @@ public function addCustomer(Customer $customer) $paymentconditionElement->appendChild($this->createNodeWithTextContent('discountdays', $customer->getPaymentConditionDiscountDays())); $paymentconditionElement->appendChild($this->createNodeWithTextContent('discountpercentage', $customer->getPaymentConditionDiscountPercentage())); - */ } } \ No newline at end of file diff --git a/src/Mappers/CustomerMapper.php b/src/Mappers/CustomerMapper.php index 521f2b82..f2361e39 100644 --- a/src/Mappers/CustomerMapper.php +++ b/src/Mappers/CustomerMapper.php @@ -29,10 +29,11 @@ class CustomerMapper extends BaseMapper * * @access public * @param \PhpTwinfield\Response\Response $response + * @param \PhpTwinfield\Secure\AuthenticatedConnection $connection * @return Customer * @throws \PhpTwinfield\Exception */ - public static function map(Response $response) + public static function map(Response $response, AuthenticatedConnection $connection) { // Generate new Customer object $customer = new Customer(); @@ -64,9 +65,8 @@ public static function map(Response $response) ->setUID(self::getField($customerElement, 'uid', $customer)) ->setWebsite(self::getField($customerElement, 'website', $customer)); - //$currencies = self::getOfficeCurrencies($connection, $customer->getOffice()); - $currencies = ["base" => "EUR", "reporting" => "USD"]; - + $currencies = self::getOfficeCurrencies($connection, $customer->getOffice()); + // Set the customer elements from the customer element attributes $customer->setDiscountArticleID(self::getAttribute($customerElement, 'discountarticle', 'id')); diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index 217541f7..06ff91e4 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -21,7 +21,7 @@ /** * @runTestsInSeparateProcesses - * @preserveGlobalState disabled + * @preserveGlobalState enabled * @covers BankTransaction * @covers BankTransactionLine * @covers TransactionsDocument diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 921c53b8..04f2afb3 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -18,7 +18,7 @@ /** * @runTestsInSeparateProcesses - * @preserveGlobalState disabled + * @preserveGlobalState enabled * @covers Customer * @covers CustomerAddress * @covers CustomerBank diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index e3f32f07..67468707 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -20,7 +20,7 @@ /** * @runTestsInSeparateProcesses - * @preserveGlobalState disabled + * @preserveGlobalState enabled * @covers Invoice * @covers InvoiceLine * @covers InvoiceTotals @@ -227,10 +227,7 @@ public function testSendInvoiceWorks() $invoiceLine->setDim1(\PhpTwinfield\GeneralLedger::fromCode('8020')); $invoiceLine->setVatCode(\PhpTwinfield\VatCode::fromCode('VN')); $invoice->addLine($invoiceLine); - - $this->assertNull(null); - - /* + $this->processXmlService ->expects($this->once()) ->method("sendDocument") @@ -245,7 +242,6 @@ public function testSendInvoiceWorks() }); $this->invoiceApiConnector->send($invoice); - */ } protected function getSuccessfulResponse(): Response diff --git a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php index 15558e47..41be68ab 100644 --- a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php +++ b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php @@ -20,7 +20,7 @@ /** * @runTestsInSeparateProcesses - * @preserveGlobalState disabled + * @preserveGlobalState enabled * @covers PurchaseTransaction * @covers PurchaseTransactionLine * @covers TransactionsDocument @@ -185,8 +185,6 @@ public function testSendPurchaseTransactionWorks() ->addLine($totalLine) ->addLine($detailLine); - $this->assertNull(null); - /* $this->processXmlService ->expects($this->once()) ->method("sendDocument") @@ -201,7 +199,6 @@ public function testSendPurchaseTransactionWorks() }); $this->transactionApiConnector->send($purchaseTransaction); - */ } protected function getSuccessfulResponse(): Response diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index 3693a7e3..bdce44d9 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -20,7 +20,7 @@ /** * @runTestsInSeparateProcesses - * @preserveGlobalState disabled + * @preserveGlobalState enabled * @covers SalesTransaction * @covers SalesTransactionLine * @covers TransactionsDocument @@ -199,9 +199,7 @@ public function testSendSalesTransactionWorks() $salesTransaction ->addLine($totalLine) ->addLine($detailLine); - - $this->assertNull(null); - + $this->processXmlService ->expects($this->once()) ->method("sendDocument") From f98cd9d13148722408e722e73576865ee5f0e3bc Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 12:01:59 +0200 Subject: [PATCH 341/388] Upload --- tests/IntegrationTests/BankTransactionIntegrationTest.php | 2 +- tests/IntegrationTests/BaseIntegrationTest.php | 3 +++ tests/IntegrationTests/CustomerIntegrationTest.php | 2 +- tests/IntegrationTests/InvoiceIntegrationTest.php | 2 +- tests/IntegrationTests/PurchaseTransactionIntegrationTest.php | 2 +- tests/IntegrationTests/SalesTransactionIntegrationTest.php | 2 +- 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index 06ff91e4..217541f7 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -21,7 +21,7 @@ /** * @runTestsInSeparateProcesses - * @preserveGlobalState enabled + * @preserveGlobalState disabled * @covers BankTransaction * @covers BankTransactionLine * @covers TransactionsDocument diff --git a/tests/IntegrationTests/BaseIntegrationTest.php b/tests/IntegrationTests/BaseIntegrationTest.php index 1d057088..c493d94c 100644 --- a/tests/IntegrationTests/BaseIntegrationTest.php +++ b/tests/IntegrationTests/BaseIntegrationTest.php @@ -10,6 +10,9 @@ use PhpTwinfield\Services\ProcessXmlService; use PHPUnit\Framework\TestCase; +/** + * @backupGlobals disabled + */ abstract class BaseIntegrationTest extends TestCase { /** diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 04f2afb3..921c53b8 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -18,7 +18,7 @@ /** * @runTestsInSeparateProcesses - * @preserveGlobalState enabled + * @preserveGlobalState disabled * @covers Customer * @covers CustomerAddress * @covers CustomerBank diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 67468707..1ce27ed8 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -20,7 +20,7 @@ /** * @runTestsInSeparateProcesses - * @preserveGlobalState enabled + * @preserveGlobalState disabled * @covers Invoice * @covers InvoiceLine * @covers InvoiceTotals diff --git a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php index 41be68ab..34932684 100644 --- a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php +++ b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php @@ -20,7 +20,7 @@ /** * @runTestsInSeparateProcesses - * @preserveGlobalState enabled + * @preserveGlobalState disabled * @covers PurchaseTransaction * @covers PurchaseTransactionLine * @covers TransactionsDocument diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index bdce44d9..8db94330 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -20,7 +20,7 @@ /** * @runTestsInSeparateProcesses - * @preserveGlobalState enabled + * @preserveGlobalState disabled * @covers SalesTransaction * @covers SalesTransactionLine * @covers TransactionsDocument From 139be894a23eb18e81a052be7ddb546922d2f71e Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 12:06:32 +0200 Subject: [PATCH 342/388] Upload --- .../BankTransactionIntegrationTest.php | 17 ----------------- tests/IntegrationTests/BaseIntegrationTest.php | 12 +++++++++--- .../CashTransactionIntegrationTest.php | 17 ----------------- .../CustomerIntegrationTest.php | 17 ----------------- .../IntegrationTests/InvoiceIntegrationTest.php | 2 -- .../JournalTransactionIntegrationTest.php | 12 ------------ .../PurchaseTransactionIntegrationTest.php | 12 ------------ .../SalesTransactionIntegrationTest.php | 12 ------------ 8 files changed, 9 insertions(+), 92 deletions(-) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index 217541f7..8fce7674 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -4,7 +4,6 @@ use DateTimeImmutable; use Money\Money; -use PhpTwinfield\ApiConnectors\OfficeApiConnector; use PhpTwinfield\ApiConnectors\TransactionApiConnector; use PhpTwinfield\BankTransaction; use PhpTwinfield\BankTransactionLine; @@ -20,8 +19,6 @@ use PhpTwinfield\Util; /** - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled * @covers BankTransaction * @covers BankTransactionLine * @covers TransactionsDocument @@ -40,20 +37,6 @@ protected function setUp() parent::setUp(); $this->transactionApiConnector = new TransactionApiConnector($this->connection); - - $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); - $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { - $baseCurrency = new Currency; - $baseCurrency->setCode('EUR'); - $reportingCurrency = new Currency; - $reportingCurrency->setCode('USD'); - - $office = new Office; - $office->setResult(1); - $office->setBaseCurrency($baseCurrency); - $office->setReportingCurrency($reportingCurrency); - return $office; - }); } public function testGetBankTransactionWorks() diff --git a/tests/IntegrationTests/BaseIntegrationTest.php b/tests/IntegrationTests/BaseIntegrationTest.php index c493d94c..008c627d 100644 --- a/tests/IntegrationTests/BaseIntegrationTest.php +++ b/tests/IntegrationTests/BaseIntegrationTest.php @@ -10,9 +10,6 @@ use PhpTwinfield\Services\ProcessXmlService; use PHPUnit\Framework\TestCase; -/** - * @backupGlobals disabled - */ abstract class BaseIntegrationTest extends TestCase { /** @@ -59,6 +56,15 @@ protected function setUp() throw new \InvalidArgumentException("Unknown service {$service->getValue()}"); }); + + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); + $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { + $office = new Office; + $office->setResult(1); + $office->setBaseCurrency(Currency::fromCode('EUR')); + $office->setReportingCurrency(Currency::fromCode('USD')); + return $office; + }); } protected function getSuccessfulResponse(): Response diff --git a/tests/IntegrationTests/CashTransactionIntegrationTest.php b/tests/IntegrationTests/CashTransactionIntegrationTest.php index 27435fa6..fd7556a2 100644 --- a/tests/IntegrationTests/CashTransactionIntegrationTest.php +++ b/tests/IntegrationTests/CashTransactionIntegrationTest.php @@ -4,7 +4,6 @@ use DateTimeImmutable; use Money\Money; -use PhpTwinfield\ApiConnectors\OfficeApiConnector; use PhpTwinfield\ApiConnectors\TransactionApiConnector; use PhpTwinfield\CashTransaction; use PhpTwinfield\CashTransactionLine; @@ -20,8 +19,6 @@ use PhpTwinfield\Util; /** - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled * @covers SalesTransaction * @covers SalesTransactionLine * @covers TransactionsDocument @@ -40,20 +37,6 @@ protected function setUp() parent::setUp(); $this->transactionApiConnector = new TransactionApiConnector($this->connection); - - $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); - $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { - $baseCurrency = new Currency; - $baseCurrency->setCode('EUR'); - $reportingCurrency = new Currency; - $reportingCurrency->setCode('USD'); - - $office = new Office; - $office->setResult(1); - $office->setBaseCurrency($baseCurrency); - $office->setReportingCurrency($reportingCurrency); - return $office; - }); } public function testGetCashTransactionWorks() diff --git a/tests/IntegrationTests/CustomerIntegrationTest.php b/tests/IntegrationTests/CustomerIntegrationTest.php index 921c53b8..e5c85191 100644 --- a/tests/IntegrationTests/CustomerIntegrationTest.php +++ b/tests/IntegrationTests/CustomerIntegrationTest.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\IntegrationTests; use PhpTwinfield\ApiConnectors\CustomerApiConnector; -use PhpTwinfield\ApiConnectors\OfficeApiConnector; use PhpTwinfield\Currency; use PhpTwinfield\Customer; use PhpTwinfield\CustomerAddress; @@ -17,8 +16,6 @@ use PhpTwinfield\Util; /** - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled * @covers Customer * @covers CustomerAddress * @covers CustomerBank @@ -42,20 +39,6 @@ protected function setUp() parent::setUp(); $this->customerApiConnector = new CustomerApiConnector($this->connection); - - $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); - $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { - $baseCurrency = new Currency; - $baseCurrency->setCode('EUR'); - $reportingCurrency = new Currency; - $reportingCurrency->setCode('USD'); - - $office = new Office; - $office->setResult(1); - $office->setBaseCurrency($baseCurrency); - $office->setReportingCurrency($reportingCurrency); - return $office; - }); } public function testGetCustomerWorks() diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 1ce27ed8..95e8fbdd 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -19,8 +19,6 @@ use PhpTwinfield\Util; /** - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled * @covers Invoice * @covers InvoiceLine * @covers InvoiceTotals diff --git a/tests/IntegrationTests/JournalTransactionIntegrationTest.php b/tests/IntegrationTests/JournalTransactionIntegrationTest.php index ca727aca..3e933a57 100644 --- a/tests/IntegrationTests/JournalTransactionIntegrationTest.php +++ b/tests/IntegrationTests/JournalTransactionIntegrationTest.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\IntegrationTests; use Money\Money; -use PhpTwinfield\ApiConnectors\OfficeApiConnector; use PhpTwinfield\ApiConnectors\TransactionApiConnector; use PhpTwinfield\Currency; use PhpTwinfield\DomDocuments\TransactionsDocument; @@ -19,8 +18,6 @@ use PhpTwinfield\Util; /** - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled * @covers JournalTransaction * @covers JournalTransactionLine * @covers TransactionsDocument @@ -39,15 +36,6 @@ protected function setUp() parent::setUp(); $this->transactionApiConnector = new TransactionApiConnector($this->connection); - - $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); - $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { - $office = new Office; - $office->setResult(1); - $office->setBaseCurrency(Currency::fromCode('EUR')); - $office->setReportingCurrency(Currency::fromCode('USD')); - return $office; - }); } public function testGetJournalTransactionWorks() diff --git a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php index 34932684..5e991827 100644 --- a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php +++ b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\IntegrationTests; use Money\Money; -use PhpTwinfield\ApiConnectors\OfficeApiConnector; use PhpTwinfield\ApiConnectors\TransactionApiConnector; use PhpTwinfield\Currency; use PhpTwinfield\DomDocuments\TransactionsDocument; @@ -19,8 +18,6 @@ use PhpTwinfield\Util; /** - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled * @covers PurchaseTransaction * @covers PurchaseTransactionLine * @covers TransactionsDocument @@ -38,15 +35,6 @@ protected function setUp() { parent::setUp(); $this->transactionApiConnector = new TransactionApiConnector($this->connection); - - $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); - $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { - $office = new Office; - $office->setResult(1); - $office->setBaseCurrency(Currency::fromCode('EUR')); - $office->setReportingCurrency(Currency::fromCode('USD')); - return $office; - }); } public function testGetPurchaseTransactionWorks() diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index 8db94330..e85b0519 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\IntegrationTests; use Money\Money; -use PhpTwinfield\ApiConnectors\OfficeApiConnector; use PhpTwinfield\ApiConnectors\TransactionApiConnector; use PhpTwinfield\Currency; use PhpTwinfield\DomDocuments\TransactionsDocument; @@ -19,8 +18,6 @@ use PhpTwinfield\Util; /** - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled * @covers SalesTransaction * @covers SalesTransactionLine * @covers TransactionsDocument @@ -39,15 +36,6 @@ protected function setUp() parent::setUp(); $this->transactionApiConnector = new TransactionApiConnector($this->connection); - - $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); - $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { - $office = new Office; - $office->setResult(1); - $office->setBaseCurrency(Currency::fromCode('EUR')); - $office->setReportingCurrency(Currency::fromCode('USD')); - return $office; - }); } public function testGetSalesTransactionWorks() From 5498579b9daca9ab2e11ae2f4537321106f1c3ef Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 12:07:31 +0200 Subject: [PATCH 343/388] Update BaseIntegrationTest.php --- tests/IntegrationTests/BaseIntegrationTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/IntegrationTests/BaseIntegrationTest.php b/tests/IntegrationTests/BaseIntegrationTest.php index 008c627d..b4112974 100644 --- a/tests/IntegrationTests/BaseIntegrationTest.php +++ b/tests/IntegrationTests/BaseIntegrationTest.php @@ -2,6 +2,8 @@ namespace PhpTwinfield\IntegrationTests; +use PhpTwinfield\ApiConnectors\OfficeApiConnector; +use PhpTwinfield\Currency; use PhpTwinfield\Enums\Services; use PhpTwinfield\Office; use PhpTwinfield\Response\Response; From 72048bc30f0b24c2238907a45d22fa0fb219bc6a Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 12:21:06 +0200 Subject: [PATCH 344/388] Upload --- tests/IntegrationTests/BaseIntegrationTest.php | 2 +- tests/IntegrationTests/resources/customerSendRequest.xml | 8 ++++---- tests/IntegrationTests/resources/invoiceSendRequest.xml | 2 +- .../resources/purchaseTransactionSendRequest.xml | 4 ++-- .../resources/salesTransactionSendRequest.xml | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/IntegrationTests/BaseIntegrationTest.php b/tests/IntegrationTests/BaseIntegrationTest.php index b4112974..2f359059 100644 --- a/tests/IntegrationTests/BaseIntegrationTest.php +++ b/tests/IntegrationTests/BaseIntegrationTest.php @@ -59,7 +59,7 @@ protected function setUp() throw new \InvalidArgumentException("Unknown service {$service->getValue()}"); }); - $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); + $mockOfficeApiConnector = \Mockery::mock(OfficeApiConnector::class)->makePartial(); $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { $office = new Office; $office->setResult(1); diff --git a/tests/IntegrationTests/resources/customerSendRequest.xml b/tests/IntegrationTests/resources/customerSendRequest.xml index 67aeb7bb..3f1a34fe 100644 --- a/tests/IntegrationTests/resources/customerSendRequest.xml +++ b/tests/IntegrationTests/resources/customerSendRequest.xml @@ -12,7 +12,7 @@ core 30 - false + true @@ -26,10 +26,10 @@ - 0 - false + + - false + diff --git a/tests/IntegrationTests/resources/invoiceSendRequest.xml b/tests/IntegrationTests/resources/invoiceSendRequest.xml index 55be3f6e..ebe088cf 100644 --- a/tests/IntegrationTests/resources/invoiceSendRequest.xml +++ b/tests/IntegrationTests/resources/invoiceSendRequest.xml @@ -32,7 +32,7 @@ 1 118 1 - 15 + 15.00 VN diff --git a/tests/IntegrationTests/resources/purchaseTransactionSendRequest.xml b/tests/IntegrationTests/resources/purchaseTransactionSendRequest.xml index b60cd1fe..d7dd5487 100644 --- a/tests/IntegrationTests/resources/purchaseTransactionSendRequest.xml +++ b/tests/IntegrationTests/resources/purchaseTransactionSendRequest.xml @@ -15,12 +15,12 @@ 1600 2000 credit - 121 + 121.00 8020 debit - 100 + 100.00 Outfit IH diff --git a/tests/IntegrationTests/resources/salesTransactionSendRequest.xml b/tests/IntegrationTests/resources/salesTransactionSendRequest.xml index 52e68d3f..cd013730 100644 --- a/tests/IntegrationTests/resources/salesTransactionSendRequest.xml +++ b/tests/IntegrationTests/resources/salesTransactionSendRequest.xml @@ -15,12 +15,12 @@ 1300 1000 debit - 121 + 121.00 8020 credit - 100 + 100.00 Outfit VH From 91521be51c1f542b23869fc6b27475dbb0efff8b Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 12:27:17 +0200 Subject: [PATCH 345/388] Upload --- tests/IntegrationTests/BaseIntegrationTest.php | 2 +- tests/IntegrationTests/InvoiceIntegrationTest.php | 11 +++++++++-- tests/IntegrationTests/OfficeIntegrationTest.php | 6 ++++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/IntegrationTests/BaseIntegrationTest.php b/tests/IntegrationTests/BaseIntegrationTest.php index 2f359059..b4112974 100644 --- a/tests/IntegrationTests/BaseIntegrationTest.php +++ b/tests/IntegrationTests/BaseIntegrationTest.php @@ -59,7 +59,7 @@ protected function setUp() throw new \InvalidArgumentException("Unknown service {$service->getValue()}"); }); - $mockOfficeApiConnector = \Mockery::mock(OfficeApiConnector::class)->makePartial(); + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { $office = new Office; $office->setResult(1); diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 95e8fbdd..5312d8b3 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -40,18 +40,25 @@ protected function setUp() $this->invoiceApiConnector = new InvoiceApiConnector($this->connection); - $mockInvoiceTypeApiConnector = \Mockery::mock('overload:'.InvoiceTypeApiConnector::class)->makePartial(); + $mockInvoiceTypeApiConnector = \Mockery::mock(InvoiceTypeApiConnector::class)->makePartial(); $mockInvoiceTypeApiConnector->shouldReceive('getInvoiceTypeVatType')->andReturnUsing(function() { return 'exclusive'; }); - $mockArticleApiConnector = \Mockery::mock('overload:'.ArticleApiConnector::class)->makePartial(); + $mockArticleApiConnector = \Mockery::mock(ArticleApiConnector::class)->makePartial(); $mockArticleApiConnector->shouldReceive('get')->andReturnUsing(function() { $article = new Article; $article->setAllowChangeVatCode(true); return $article; }); } + + protected function tearDown() + { + parent::setUp(); + + unset($mockInvoiceTypeApiConnector, $mockArticleApiConnector); + } public function testGetConceptInvoiceWorks() { diff --git a/tests/IntegrationTests/OfficeIntegrationTest.php b/tests/IntegrationTests/OfficeIntegrationTest.php index f35e08f3..fc7fe6af 100644 --- a/tests/IntegrationTests/OfficeIntegrationTest.php +++ b/tests/IntegrationTests/OfficeIntegrationTest.php @@ -5,6 +5,10 @@ use PhpTwinfield\ApiConnectors\OfficeApiConnector; use PhpTwinfield\Response\Response; +/** + * @runTestsInSeparateProcesses + * @preserveGlobalState disabled + */ class OfficeIntegrationTest extends BaseIntegrationTest { /** @@ -16,6 +20,8 @@ protected function setUp() { parent::setUp(); + unset($mockOfficeApiConnector); + $this->officeApiConnector = new OfficeApiConnector($this->connection); } From 0b6952181aadcd421d6c41801a78e22b6f2d91e8 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 12:35:37 +0200 Subject: [PATCH 346/388] Update InvoiceIntegrationTest.php --- tests/IntegrationTests/InvoiceIntegrationTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 5312d8b3..0e6556a0 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -40,12 +40,12 @@ protected function setUp() $this->invoiceApiConnector = new InvoiceApiConnector($this->connection); - $mockInvoiceTypeApiConnector = \Mockery::mock(InvoiceTypeApiConnector::class)->makePartial(); + $mockInvoiceTypeApiConnector = \Mockery::mock('overload:'.InvoiceTypeApiConnector::class)->makePartial(); $mockInvoiceTypeApiConnector->shouldReceive('getInvoiceTypeVatType')->andReturnUsing(function() { return 'exclusive'; }); - $mockArticleApiConnector = \Mockery::mock(ArticleApiConnector::class)->makePartial(); + $mockArticleApiConnector = \Mockery::mock('overload:'.ArticleApiConnector::class)->makePartial(); $mockArticleApiConnector->shouldReceive('get')->andReturnUsing(function() { $article = new Article; $article->setAllowChangeVatCode(true); @@ -54,10 +54,10 @@ protected function setUp() } protected function tearDown() - { - parent::setUp(); - + { unset($mockInvoiceTypeApiConnector, $mockArticleApiConnector); + + \Mockery::close(); } public function testGetConceptInvoiceWorks() From eb680137cada2b03f218f87a767496d9556a2bd3 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 12:37:20 +0200 Subject: [PATCH 347/388] Update OfficeIntegrationTest.php --- tests/IntegrationTests/OfficeIntegrationTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/IntegrationTests/OfficeIntegrationTest.php b/tests/IntegrationTests/OfficeIntegrationTest.php index fc7fe6af..b8cef080 100644 --- a/tests/IntegrationTests/OfficeIntegrationTest.php +++ b/tests/IntegrationTests/OfficeIntegrationTest.php @@ -21,6 +21,7 @@ protected function setUp() parent::setUp(); unset($mockOfficeApiConnector); + \Mockery::close(); $this->officeApiConnector = new OfficeApiConnector($this->connection); } From 314a9971ae8111bd8400ba3eb7d29bd10b636345 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 12:41:02 +0200 Subject: [PATCH 348/388] Update OfficeIntegrationTest.php --- .../OfficeIntegrationTest.php | 55 ++++++++++++++++++- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/tests/IntegrationTests/OfficeIntegrationTest.php b/tests/IntegrationTests/OfficeIntegrationTest.php index b8cef080..e10307ec 100644 --- a/tests/IntegrationTests/OfficeIntegrationTest.php +++ b/tests/IntegrationTests/OfficeIntegrationTest.php @@ -3,29 +3,78 @@ namespace PhpTwinfield\IntegrationTests; use PhpTwinfield\ApiConnectors\OfficeApiConnector; +use PhpTwinfield\Enums\Services; +use PhpTwinfield\Office; use PhpTwinfield\Response\Response; +use PhpTwinfield\Secure\AuthenticatedConnection; +use PhpTwinfield\Services\FinderService; +use PhpTwinfield\Services\ProcessXmlService; +use PHPUnit\Framework\TestCase; /** * @runTestsInSeparateProcesses * @preserveGlobalState disabled */ -class OfficeIntegrationTest extends BaseIntegrationTest +class OfficeIntegrationTest extends TestCase { /** * @var OfficeApiConnector|\PHPUnit_Framework_MockObject_MockObject */ private $officeApiConnector; + + /** + * @var Office + */ + protected $office; + + /** + * @var AuthenticatedConnection|\PHPUnit_Framework_MockObject_MockObject + */ + protected $connection; + + /** + * @var ProcessXmlService|\PHPUnit_Framework_MockObject_MockObject + */ + protected $processXmlService; + + /** + * @var FinderService|\PHPUnit_Framework_MockObject_MockObject + */ + protected $finderService; protected function setUp() { parent::setUp(); - unset($mockOfficeApiConnector); - \Mockery::close(); + $this->office = new Office(); + $this->office->setCode("11024"); + + $this->processXmlService = $this->createPartialMock(ProcessXmlService::class, ['sendDocument']); + $this->finderService = $this->createPartialMock(FinderService::class, ['searchFinder']); + + $this->connection = $this->createMock(AuthenticatedConnection::class); + $this->connection->expects($this->any()) + ->method("getAuthenticatedClient") + ->willReturnCallback(function (Services $service) { + switch ($service->getValue()) { + case Services::PROCESSXML()->getValue(): + return $this->processXmlService; + case Services::FINDER()->getValue(): + return $this->finderService; + } + + throw new \InvalidArgumentException("Unknown service {$service->getValue()}"); + }); + $this->officeApiConnector = new OfficeApiConnector($this->connection); } + protected function getSuccessfulResponse(): Response + { + return Response::fromString(''); + } + public function testListOfficesWithoutCompanyId() { $response = Response::fromString(file_get_contents(__DIR__ . '/resources/officeOauthGetResponse.xml')); From 5bd78939d37927c6c8b05505a90583f2994e4f8f Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 14:41:48 +0200 Subject: [PATCH 349/388] Upload --- src/Mappers/BaseMapper.php | 12 +++++++----- src/Mappers/TransactionMapper.php | 14 +++++++------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index afbd5e82..07922d88 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -119,12 +119,8 @@ protected static function parseUnknownEntity($object, \DOMElement $element, stri { if (is_a($object, \PhpTwinfield\DimensionGroupDimension::class)) { $type = self::getField($element, "type", $object); - } elseif (is_a($object, \PhpTwinfield\TransactionLineInterface::class)) { - $type = self::getAttribute($element, $fieldTagName, "type"); - $type = "BAS"; } else { $type = self::getAttribute($element, $fieldTagName, "dimensiontype"); - $type = "PNL"; } switch ($type) { @@ -152,12 +148,18 @@ protected static function parseUnknownEntity($object, \DOMElement $element, stri /** @var SomeClassWithMethodsetCode $object2 */ protected static function parseObjectAttribute(?string $objectClass, $object, \DOMElement $element, string $fieldTagName, array $attributes = []) { + $value = self::getField($element, $fieldTagName, $object); + + if ($value === null) { + return null; + } + if ($objectClass === null) { $objectClass = self::parseUnknownEntity($object, $element, $fieldTagName); } $object2 = new $objectClass(); - $object2->setCode(self::getField($element, $fieldTagName, $object)); + $object2->setCode($value); foreach ($attributes as $attributeName => $method) { $object2->$method(self::getAttribute($element, $fieldTagName, $attributeName)); diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 6ff92484..f8f80d6a 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -154,7 +154,7 @@ public static function map(string $transactionClassName, Response $response, Aut ->setDebitCredit(self::parseEnumAttribute(\PhpTwinfield\Enums\DebitCredit::class, self::getField($lineElement, 'debitcredit', $transactionLine))) ->setDescription(self::getField($lineElement, 'description', $transactionLine)) ->setDestOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $transactionLine, $lineElement, 'destoffice')) - ->setDim1(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) + ->setDim1(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setId($lineElement->getAttribute('id')) ->setLineType(self::parseEnumAttribute(\PhpTwinfield\Enums\LineType::class, $lineType)) ->setMatchStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\MatchStatus::class, self::getField($lineElement, 'matchstatus', $transactionLine))) @@ -176,8 +176,8 @@ public static function map(string $transactionClassName, Response $response, Aut $transactionLine->setBaseValueOpen(self::parseMoneyAttribute($baseValueOpen, $currencies['base'])); } - $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); - $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); + $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))); + $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))); $transactionLine->setMatchLevel(self::getField($lineElement, 'matchlevel', $transactionLine)); $transactionLine->setRelation(self::getField($lineElement, 'relation', $transactionLine)); $transactionLine->setRepValueOpen(self::parseMoneyAttribute(self::getField($lineElement, 'repvalueopen', $transactionLine), $currencies['reporting'])); @@ -186,12 +186,12 @@ public static function map(string $transactionClassName, Response $response, Aut if ($transaction instanceof PurchaseTransaction || $transaction instanceof SalesTransaction) { if ($lineType == LineType::DETAIL()) { - $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); - $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); + $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))); + $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))); } elseif ($transaction instanceof PurchaseTransaction && $lineType == LineType::VAT()) { - $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); + $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))); } elseif ($lineType == LineType::TOTAL()) { - $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); + $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))); $baseValueOpen = self::getField($lineElement, 'basevalueopen', $transactionLine) ?: self::getField($lineElement, 'openbasevalue', $transactionLine); From 6c729e907647a66d9c53608d381f2a68e7820676 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 17:58:42 +0200 Subject: [PATCH 350/388] Upload --- examples/Activity.php | 34 +++------ examples/Article.php | 65 +++++++--------- examples/BrowseData.php | 3 + examples/CashBankBook.php | 3 + examples/CostCenter.php | 16 ++-- examples/Country.php | 3 + examples/Currency.php | 22 +++--- examples/Customer.php | 45 +++++------ examples/DimensionGroup.php | 25 ++++--- examples/DimensionType.php | 9 ++- examples/GeneralLedger.php | 10 +-- examples/Invoice.php | 74 ++++++++----------- examples/InvoiceType.php | 3 + examples/Office.php | 17 +++-- examples/PayCode.php | 3 + examples/Project.php | 21 +++--- examples/Rate.php | 39 +++++----- examples/Supplier.php | 35 ++++----- examples/UserRole.php | 3 + examples/VatCode.php | 49 ++++++------ examples/VatGroup.php | 3 + examples/VatGroupCountry.php | 3 + .../resources/bankTransactionGetResponse.xml | 6 +- .../resources/cashTransactionGetResponse.xml | 6 +- .../journalTransactionGetResponse.xml | 6 +- .../purchaseTransactionGetResponse.xml | 8 +- .../resources/salesTransactionGetResponse.xml | 8 +- 27 files changed, 259 insertions(+), 260 deletions(-) diff --git a/examples/Activity.php b/examples/Activity.php index 9ec44626..72a51535 100644 --- a/examples/Activity.php +++ b/examples/Activity.php @@ -11,6 +11,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection @@ -99,26 +102,24 @@ /* Activity * \PhpTwinfield\Activity - * Available getters: getBehaviour, getCode, getInUse, getInUseToString, getMessages, getName, getOffice, getOfficeToString, getResult, getShortName, getStatus, getTouched, getType, getTypeToString, getUID, getVatCode, getVatCodeToString, hasMessages, getProjects - * Available setters: setBehaviour, setBehaviourFromString, setCode, setName, setOffice, setOfficeFromString, setShortName, setStatus, setStatusFromString, setType, setTypeFromString, setVatCode, setVatCodeFromString, setProjects + * Available getters: getBehaviour, getCode, getInUse, getMessages, getName, getOffice, getResult, getShortName, getStatus, getTouched, getType, getUID, getVatCode, hasMessages, getProjects + * Available setters: setBehaviour, setCode, setName, setOffice, setShortName, setStatus, setType, setVatCode, setProjects */ /* ActivityProjects * \PhpTwinfield\ActivityProjects - * Available getters: getAuthoriser, getAuthoriserInherit, getAuthoriserInheritToString, getAuthoriserLocked, getAuthoriserLockedToString, getAuthoriserToString, getBillable, getBillableForRatio, getBillableForRatioToString, getBillableInherit, getBillableInheritToString, - * getBillableLocked, getBillableLockedToString, getBillableToString, getCustomer, getCustomerInherit, getCustomerInheritToString, getCustomerLocked, getCustomerLockedToString, getCustomerToString, getInvoiceDescription, getMessages, getRate, getRateInherit, getRateInheritToString, - * getRateLocked, getRateLockedToString, getRateToString, getResult, getValidFrom, getValidFromToString, getValidTill, getValidTillToString, hasMessages, getQuantities + * Available getters: getAuthoriser, getAuthoriserInherit, getAuthoriserLocked, getBillable, getBillableForRatio, getBillableInherit, getBillableLocked, getCustomer, getCustomerInherit, getCustomerLocked, getInvoiceDescription, getMessages, getRate, getRateInherit, + * getRateLocked, getResult, getValidFrom, getValidTill, hasMessages, getQuantities * - * Available setters: setAuthoriser, setAuthoriserFromString, setAuthoriserInherit, setAuthoriserInheritFromString, setAuthoriserLocked, setAuthoriserLockedFromString, setBillable, setBillableForRatio, setBillableForRatioFromString, setBillableFromString, setBillableInherit, setBillableInheritFromString, - * setBillableLocked, setBillableLockedFromString, setCustomer, setCustomerFromString, setCustomerInherit, setCustomerInheritFromString, setCustomerLocked, setCustomerLockedFromString, setInvoiceDescription, setRate, setRateFromString, setRateInherit, setRateInheritFromString, - * setRateLocked, setRateLockedFromString, setValidFrom, setValidFromFromString, setValidTill, setValidTillFromString, addQuantity, removeQuantity + * Available setters: setAuthoriser, setAuthoriserInherit, setAuthoriserLocked, setBillable, setBillableForRatio, setBillableInherit, setBillableLocked, setCustomer, setCustomerInherit, setCustomerLocked, setInvoiceDescription, setRate, setRateInherit, + * setRateLocked, setValidFrom, setValidTill, addQuantity, removeQuantity * */ /* ActivityQuantity * \PhpTwinfield\ActivityQuantity - * Available getters: getBillable, getBillableLocked, getBillableLockedToString, getBillableToString, getLabel, getMandatory, getMandatoryToString, getMessages, getRate, getRateToString, getResult, hasMessages - * Available setters: setBillable, setBillableFromString, setBillableLocked, setBillableLockedFromString, setLabel, setMandatory, setMandatoryFromString, setRate, setRateFromString + * Available getters: getBillable, getBillableLocked, getLabel, getMandatory, getMessages, getRate, getResult, hasMessages + * Available setters: setBillable, setBillableLocked, setLabel, setMandatory, setRate */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { @@ -281,34 +282,24 @@ $activityProjects->setAuthoriser($authoriser); // User|null A specific authoriser for an activity. $activityProjects->setAuthoriserFromString('TWINAPPS'); // string|null If "change" = allow then locked = false and inherit = false $activityProjects->setAuthoriserInherit(false); // bool|null - $activityProjects->setAuthoriserInheritFromString('false'); // string|null If "change" = disallow then locked = true and inherit = false $activityProjects->setAuthoriserLocked(false); // bool|null - $activityProjects->setAuthoriserLockedFromString('false'); // string|null If "change" = inherit then locked = true and inherit = true $activityProjects->setBillable(false); // bool|null Choose to make an activity billable (true) or not (false) and whether or not it should be included when calculating the "productivity" ratio (@forratio). - $activityProjects->setBillableFromString('false'); // string|null You could also decide that these settings should be inherited from project or user level (@inherit). $activityProjects->setBillableForRatio(false); // bool|null You can also set whether a change of these settings is allowed or disallowed when a user is entering their timesheet (@locked). - $activityProjects->setBillableForRatioFromString('false'); // string|null If "change" = allow then locked = false and inherit = false. $activityProjects->setBillableInherit(false); // bool|null - $activityProjects->setBillableInheritFromString('false'); // string|null If "change" = disallow then locked = true and inherit = false. $activityProjects->setBillableLocked(false); // bool|null - $activityProjects->setBillableLockedFromString('false'); // string|null If "change" = inherit then locked = true and inherit = true $customer = new \PhpTwinfield\Customer; $customer->setCode('1000'); //$activityProjects->setCustomer($customer); // Customer|null An activity always needs to be linked to a customer. //$activityProjects->setCustomerFromString('1000'); // string|null Choose to have the customer ‘inherited’ (from a project) or you can specify the customer here. $activityProjects->setCustomerInherit(true); // bool|null - $activityProjects->setCustomerInheritFromString('true'); // string|null If "change" = allow then locked = false and inherit = false $activityProjects->setCustomerLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false - $activityProjects->setCustomerLockedFromString('true'); // string|null If "change" = inherit then locked = true and inherit = true $activityProjects->setInvoiceDescription('Example Invoice Description'); // string|null This field can be used to enter a longer activity description which will be available on the invoice template. $rate = new \PhpTwinfield\Rate; $rate->setCode('DIRECT'); $activityProjects->setRate($rate); // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). $activityProjects->setRateFromString('DIRECT'); // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). $activityProjects->setRateInherit(false); // bool|null - $activityProjects->setRateInheritFromString('false'); // string|null If "change" = allow then locked = false and inherit = false $activityProjects->setRateLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false - $activityProjects->setRateLockedFromString('true'); // string|null If "change" = inherit then locked = true and inherit = true $validFrom = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); $activityProjects->setValidFrom($validFrom); // DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. $activityProjects->setValidFromFromString('20190101'); // string|null @@ -319,12 +310,9 @@ // The minimum amount of ActivityQuantities linked to a ActivityProjects object is 0, the maximum amount is 4 $activityQuantity = new \PhpTwinfield\ActivityQuantity; $activityQuantity->setBillable(false); // bool|null Is the quantity line billable or not. - $activityQuantity->setBillableFromString('false'); // string|null If "billable" = true and "change is not allowed" then locked = true $activityQuantity->setBillableLocked(false); // bool|null - $activityQuantity->setBillableLockedFromString('false'); // string|null If "billable" = true and "change is allowed" then locked = false $activityQuantity->setLabel('Example Quantity'); // string|null $activityQuantity->setMandatory(false); // bool|null Is the quantity line mandatory or not. - $activityQuantity->setMandatoryFromString('false'); // string|null $rate = new \PhpTwinfield\Rate; $rate->setCode('KILOMETERS'); $activityQuantity->setRate($rate); // Rate|null The rate. diff --git a/examples/Article.php b/examples/Article.php index ff619a00..bc21631f 100644 --- a/examples/Article.php +++ b/examples/Article.php @@ -11,6 +11,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection @@ -90,18 +93,18 @@ /* Article * \PhpTwinfield\Article - * Available getters: getAllowChangePerformanceType, getAllowChangePerformanceTypeToString, getAllowChangeUnitsPrice, getAllowChangeUnitsPriceToString, getAllowChangeVatCode, getAllowChangeVatCodeToString, getAllowDecimalQuantity, getAllowDecimalQuantityToString, getAllowDiscountOrPremium, - * getAllowDiscountOrPremiumToString, getCode, getMessages, getName, getOffice, getOfficeToString, getPercentage, getPercentageToString, getPerformanceType, getResult, getShortName, getStatus, getType, getUnitNamePlural, getUnitNameSingular, getVatCode, getVatCodeToString, hasMessages, getLines + * Available getters: getAllowChangePerformanceType, getAllowChangeUnitsPrice, getAllowChangeVatCode, getAllowDecimalQuantity, getAllowDiscountOrPremium, + * getAllowDiscountOrPremiumToString, getCode, getMessages, getName, getOffice, getPercentage, getPerformanceType, getResult, getShortName, getStatus, getType, getUnitNamePlural, getUnitNameSingular, getVatCode, hasMessages, getLines * - * Available setters: setAllowChangePerformanceType, setAllowChangePerformanceTypeFromString, setAllowChangeUnitsPrice, setAllowChangeUnitsPriceFromString, setAllowChangeVatCode, setAllowChangeVatCodeFromString, setAllowDecimalQuantity, setAllowDecimalQuantityFromString, setAllowDiscountOrPremium, setAllowDiscountOrPremiumFromString, - * setCode, setName, setOffice, setOfficeFromString, setPercentage, setPercentageFromString, setPerformanceType, setPerformanceTypeFromString, setShortName, setStatus, setStatusFromString, setType, setTypeFromString, setUnitNamePlural, setUnitNameSingular, setVatCode, setVatCodeFromString, addLine, removeLine + * Available setters: setAllowChangePerformanceType, setAllowChangeUnitsPrice, setAllowChangeVatCode, setAllowDecimalQuantity, setAllowDiscountOrPremium, + * setCode, setName, setOffice, setPercentage, setPerformanceType, setShortName, setStatus, setType, setUnitNamePlural, setUnitNameSingular, setVatCode, addLine, removeLine * */ /* ArticleLine * \PhpTwinfield\ArticleLine - * Available getters: getFreeText1, getFreeText1ToString, getFreeText2, getFreeText2ToString, getFreetext3, getID, getInUse, getInUseToString, getMessages, getName, getResult, getShortName, getStatus, getSubCode, getUnits, getUnitsPriceExcl, getUnitsPriceExclToFloat, getUnitsPriceInc, getUnitsPriceIncToFloat, hasMessages - * Available setters: setFreeText1, setFreeText1FromString, setFreeText2, setFreeText2FromString, setFreetext3, setID, setName, setShortName, setStatus, setStatusFromString, setSubCode, setUnits, setUnitsPriceExcl, setUnitsPriceExclFromFloat, setUnitsPriceInc, setUnitsPriceIncFromFloat + * Available getters: getFreeText1, getFreeText2, getFreetext3, getID, getInUse, getMessages, getName, getResult, getShortName, getStatus, getSubCode, getUnits, getUnitsPriceExcl, getUnitsPriceInc, hasMessages + * Available setters: setFreeText1, setFreeText2, setFreetext3, setID, setName, setShortName, setStatus, setSubCode, setUnits, setUnitsPriceExcl, setUnitsPriceInc */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { @@ -126,15 +129,15 @@ echo "Article
"; echo "AllowChangePerformanceType (bool): {$article->getAllowChangePerformanceType()}
"; // bool|null Is it allowed to change the performance type. - echo "AllowChangePerformanceType (string): {$article->getAllowChangePerformanceTypeToString()}
"; // string|null + echo "AllowChangePerformanceType (string): " . Util::formatBoolean($article->getAllowChangePerformanceTypeToString()) . "
"; // string|null echo "AllowChangeUnitsPrice (bool): {$article->getAllowChangeUnitsPrice()}
"; // bool|null Is it allowed to change the units price. - echo "AllowChangeUnitsPrice (string): {$article->getAllowChangeUnitsPriceToString()}
"; // string|null + echo "AllowChangeUnitsPrice (string): " . Util::formatBoolean($article->getAllowChangeUnitsPriceToString()) . "
"; // string|null echo "AllowChangeVatCode (bool): {$article->getAllowChangeVatCode()}
"; // bool|null Is it allowed to change the VAT. - echo "AllowChangeVatCode (string): {$article->getAllowChangeVatCodeToString()}
"; // string|null + echo "AllowChangeVatCode (string): " . Util::formatBoolean($article->getAllowChangeVatCodeToString()) . "
"; // string|null echo "AllowDecimalQuantity (bool): {$article->getAllowDecimalQuantity()}
"; // bool|null Are decimals allowed. - echo "AllowDecimalQuantity (string): {$article->getAllowDecimalQuantityToString()}
"; // string|null + echo "AllowDecimalQuantity (string): " . Util::formatBoolean($article->getAllowDecimalQuantityToString()) . "
"; // string|null echo "AllowDiscountOrPremium (bool): {$article->getAllowDiscountOrPremium()}
"; // bool|null Is discount or premium allowed. - echo "AllowDiscountOrPremium (string): {$article->getAllowDiscountOrPremiumToString()}
"; // string|null + echo "AllowDiscountOrPremium (string): " . Util::formatBoolean($article->getAllowDiscountOrPremiumToString()) . "
"; // string|null echo "Code: {$article->getCode()}
"; // string|null Article code. if ($article->hasMessages()) { // bool Object contains (error) messages true/false. @@ -145,7 +148,7 @@ echo "Office (\\PhpTwinfield\\Office):
" . print_r($article->getOffice(), true) . "

"; // Office|null Office code. echo "Office (string): {$article->getOfficeToString()}
"; // string|null echo "Percentage (bool): {$article->getPercentage()}
"; // bool|null Only available when article type is discount or premium. - echo "Percentage (string): {$article->getPercentageToString()}
"; // string|null + echo "Percentage (string): " . Util::formatBoolean($article->getPercentageToString()) . "
"; // string|null echo "PerformanceType: {$article->getPerformanceType()}
"; // PerformanceType|null The performance type. echo "Result: {$article->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "ShortName: {$article->getShortName()}
"; // string|null Short article description. @@ -154,7 +157,7 @@ echo "UnitNamePlural: {$article->getUnitNamePlural()}
"; // string|null Unit name for multiple items. echo "UnitNameSingular: {$article->getUnitNameSingular()}
"; // string|null Unit name for a single item. echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($article->getVatCode(), true) . "

"; // VatCode|null Default VAT code. - echo "VatCode (string): {$article->getVatCodeToString()}
"; // string|null + echo "VatCode (string): " . Util::objectToStr($article->getVatCodeToString()) . "
"; // string|null $articleLines = $article->getLines(); // array|null Array of ArticleLine objects. @@ -162,13 +165,13 @@ echo "ArticleLine {$key}
"; echo "FreeText1 (\\PhpTwinfield\\GeneralLedger):
" . print_r($articleLine->getFreeText1(), true) . "

"; // GeneralLedger|null Mandatory. The general ledger code linked to the article. - echo "FreeText1 (string): {$articleLine->getFreeText1ToString()}
"; // string|null + echo "FreeText1 (string): " . Util::objectToStr($articleLine->getFreeText1()) . "
"; // string|null echo "FreeText2 (\\PhpTwinfield\\CostCenter):
" . print_r($articleLine->getFreeText2(), true) . "

"; // CostCenter|null Optional. The cost center linked to the article. - echo "FreeText2 (string): {$articleLine->getFreeText2ToString()}
"; // string|null + echo "FreeText2 (string): " . Util::objectToStr($articleLine->getFreeText2()) . "
"; // string|null echo "FreeText3: {$articleLine->getFreetext3()}
"; // string|null Free text element 3 echo "ID: {$articleLine->getID()}
"; // int|null Line ID echo "InUse (bool): {$articleLine->getInUse()}
"; // bool|null Read-only attribute. Indicates that the sub item has been used in an invoice. - echo "InUse (string): {$articleLine->getInUseToString()}
"; // string|null + echo "InUse (string): " . Util::formatBoolean($articleLine->getInUse()) . "
"; // string|null if ($articleLine->hasMessages()) { // bool Object contains (error) messages true/false. echo "Messages: " . print_r($articleLine->getMessages(), true) . "
"; // Array|null (Error) messages. @@ -181,9 +184,9 @@ echo "SubCode: {$articleLine->getSubCode()}
"; // string|null Can only be empty if there is just one sub article echo "Units: {$articleLine->getUnits()}
"; // int|null The number of units of the article per quantity echo "UnitsPriceExcl (\\Money\\Money):
" . print_r($articleLine->getUnitsPriceExcl(), true) . "

"; // Money|null Price excluding VAT - echo "UnitsPriceExcl (float): {$articleLine->getUnitsPriceExclToFloat()}
"; // float|null + echo "UnitsPriceExcl (string): " . Util::formatMoney($articleLine->getUnitsPriceExcl()) . "
"; // string|null echo "UnitsPriceInc (\\Money\\Money):
" . print_r($articleLine->getUnitsPriceInc(), true) . "

"; // Money|null Price including VAT - echo "UnitsPriceInc (float): {$articleLine->getUnitsPriceIncToFloat()}
"; // float|null + echo "UnitsPriceInc (string): " . Util::formatMoney($articleLine->getUnitsPriceInc()) . "
"; // string|null } } @@ -219,36 +222,26 @@ $article->setCode('9061'); // string|null Article code. $article->setName("Example Article"); // string|null Article description. $article->setOffice($office); // Office|null Office code. - $article->setOfficeFromString($officeCode); // string|null + $article->setOfficeFromString(\PhpTwinfield\Office::fromCode($officeCode)); // string|null $article->setUnitNamePlural("Example Art Units"); // string|null Unit name for multiple items $article->setUnitNameSingular("Example Art Unit"); // string|null Unit name for a single item // Optional values for creating a new Article $article->setAllowChangePerformanceType(true); // bool|null Is it allowed to change the performance type. - $article->setAllowChangePerformanceTypeFromString('true'); // string|null $article->setAllowChangeUnitsPrice(true); // bool|null Is it allowed to change the units price. - $article->setAllowChangeUnitsPriceFromString('true'); // string|null $article->setAllowChangeVatCode(true); // bool|null Is it allowed to change the VAT. - $article->setAllowChangeVatCodeFromString('true'); // string|null $article->setAllowDecimalQuantity(true); // bool|null Are decimals allowed. - $article->setAllowDecimalQuantityFromString('true'); // string|null $article->setAllowDiscountOrPremium(true); // bool|null Is discount or premium allowed. - $article->setAllowDiscountOrPremiumFromString('true'); // string|null //$article->setPercentage(true); // bool|null Only available when article type is discount or premium - //$article->setPercentageFromString('true'); // string|null $article->setPerformanceType(\PhpTwinfield\Enums\PerformanceType::SERVICES()); // PerformanceType|null The performance type. - $article->setPerformanceTypeFromString('services'); // string|null $article->setShortName("ExmplArt"); // string|null Short article description. //$article->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. //$article->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case an article is in use, its status has been changed into hide. Hidden articles can be activated by using active. - //$article->setStatusFromString('active'); // string|null - //$article->setStatusFromString('deleted'); // string|null $article->setType(\PhpTwinfield\Enums\ArticleType::NORMAL()); // ArticleType|null Set to normal in case special item is none. Set to either discount or premium in case special item is deduction or premium respectively. - $article->setTypeFromString('normal'); // string|null $vatCode = new \PhpTwinfield\VatCode; $vatCode->setCode('VH'); $article->setVatCode($vatCode); // VatCode|null Default VAT code - $article->setVatCodeFromString('VH'); // string|null + $article->setVatCode(\PhpTwinfield\VatCode::fromCode('VH')); // string|null // The minimum amount of ArticleLines linked to an Article object is 1 $articleLine = new \PhpTwinfield\ArticleLine; @@ -256,11 +249,11 @@ $freeText1 = new \PhpTwinfield\GeneralLedger; $freeText1->setCode('9060'); $articleLine->setFreeText1($freeText1); // GeneralLedger|null Mandatory. The general ledger code linked to the article. - $articleLine->setFreeText1FromString('9060'); // string|null + $articleLine->setFreeText1(\PhpTwinfield\GeneralLedger::fromCode('9060')); // string|null $freeText2 = new \PhpTwinfield\CostCenter; $freeText2->setCode('00000'); //$articleLine->setFreeText2($freeText1); // CostCenter|null Optional. The cost center linked to the article. - //$articleLine->setFreeText2FromString('00000'); // string|null + //$articleLine->setFreeText2(\PhpTwinfield\CostCenter::fromCode('00000')); // string|null //$articleLine->setFreetext3(""); // string|null Free text element 3 $articleLine->setID(1); // int|null Line ID. $articleLine->setName("Example Sub Article"); // string|null Sub article name. @@ -268,14 +261,10 @@ $articleLine->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null Allows you to delete sub items and to recover them (if sub item is @inuse). //$articleLine->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null - $articleLine->setStatusFromString('active'); // string|null - //$articleLine->setStatusFromString('deleted'); // string|null $articleLine->setSubCode('9061'); // string|null Can only be empty if there is just one sub article $articleLine->setUnits(1); // int|null The number of units of the article per quantity - $articleLine->setUnitsPriceExcl(\Money\Money::EUR(1000)); // Money|null Price excluding VAT - $articleLine->setUnitsPriceExclFromFloat(10); // float|null - //$articleLine->setUnitsPriceInc(\Money\Money::EUR(1210)); // Money|null Price including VAT - //$articleLine->setUnitsPriceIncFromFloat(12.10); // float|null + $articleLine->setUnitsPriceExcl(\Money\Money::EUR(1000)); // Money|null Price excluding VAT (equals 10.00 EUR) + //$articleLine->setUnitsPriceInc(\Money\Money::EUR(1210)); // Money|null Price including VAT (equals 12.10 EUR) $article->addLine($articleLine); // ArticleLine Add an ArticleLine object to the Article object //$article->removeLine(0); // int Remove an article line based on the index of the article line diff --git a/examples/BrowseData.php b/examples/BrowseData.php index 8c8424b1..51cf9a3d 100644 --- a/examples/BrowseData.php +++ b/examples/BrowseData.php @@ -10,6 +10,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection diff --git a/examples/CashBankBook.php b/examples/CashBankBook.php index 3bb1a3e2..464f2607 100644 --- a/examples/CashBankBook.php +++ b/examples/CashBankBook.php @@ -8,6 +8,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection diff --git a/examples/CostCenter.php b/examples/CostCenter.php index bb187a55..96e5852f 100644 --- a/examples/CostCenter.php +++ b/examples/CostCenter.php @@ -11,6 +11,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection @@ -96,8 +99,8 @@ /* CostCenter * \PhpTwinfield\CostCenter - * Available getters: getBehaviour, getCode, getInUse, getInUseToString, getMessages, getName, getOffice, getOfficeToString, getResult, getShortName, getStatus, getTouched, getType, getTypeToString, getUID, hasMessages - * Available setters: setBehaviour, setBehaviourFromString, setCode, setName, setOffice, setOfficeFromString, setShortName, setStatus, setStatusFromString, setType, setTypeFromString + * Available getters: getBehaviour, getCode, getInUse, getMessages, getName, getOffice, getResult, getShortName, getStatus, getTouched, getType, getUID, hasMessages + * Available setters: setBehaviour, setCode, setName, setOffice, setShortName, setStatus, setType */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { @@ -124,7 +127,7 @@ echo "Behaviour: {$costCenter->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. echo "Code: {$costCenter->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the KPL Dimension type. echo "InUse (bool): {$costCenter->getInUse()}
"; // bool|null Indicates whether the cost center is used in a financial transaction or not. Read-only attribute. - echo "InUse (string): {$costCenter->getInUseToString()}
"; // string|null + echo "InUse (string): " . Util::formatBoolean($costCenter->getInUse()) . "
"; // string|null if ($costCenter->hasMessages()) { // bool Object contains (error) messages true/false. echo "Messages: " . print_r($costCenter->getMessages(), true) . "
"; // Array|null (Error) messages. @@ -132,13 +135,13 @@ echo "Name: {$costCenter->getName()}
"; // string|null Name of the dimension. echo "Office (\\PhpTwinfield\\Office):
" . print_r($costCenter->getOffice(), true) . "

"; // Office|null Office. - echo "Office (string): {$costCenter->getOfficeToString()}
"; // string|null + echo "Office (string): " . Util::objectToStr($costCenter->getOffice()) . "
"; // string|null echo "Result: {$costCenter->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "ShortName: {$costCenter->getShortName()}
"; // string|null Not in use. echo "Status: {$costCenter->getStatus()}
"; // Status|null Status of the cost center. echo "Touched: {$costCenter->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($costCenter->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of cost centers is KPL. - echo "Type (string): {$costCenter->getTypeToString()}
"; // string|null + echo "Type (string): " . Util::objectToStr($costCenter->getType()) . "
"; // string|null echo "UID: {$costCenter->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. } @@ -182,9 +185,6 @@ $costCenter->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. //$costCenter->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null For deleting deleted should be used. In case a dimension that is used in a transaction is deleted, // its status has been changed into hide. Hidden dimensions can be activated by using active. - $costCenter->setStatusFromString('active'); // string|null - //$costCenter->setStatusFromString('deleted'); // string|null - try { $costCenterNew = $costCenterApiConnector->send($costCenter); } catch (ResponseException $e) { diff --git a/examples/Country.php b/examples/Country.php index ddd7769d..48caf03b 100644 --- a/examples/Country.php +++ b/examples/Country.php @@ -8,6 +8,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection diff --git a/examples/Currency.php b/examples/Currency.php index 66a9d581..7d6dd494 100644 --- a/examples/Currency.php +++ b/examples/Currency.php @@ -11,6 +11,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection @@ -82,14 +85,14 @@ /* Currency * \PhpTwinfield\Currency - * Available getters: getCode, getMessages, getName, getOffice, getOfficeToString, getResult, getShortName, getStatus, hasMessages, getRates - * Available setters: setCode, setName, setOffice, setOfficeFromString, setShortName, setStatus, setStatusFromString, addRate, removeRate + * Available getters: getCode, getMessages, getName, getOffice, getResult, getShortName, getStatus, hasMessages, getRates + * Available setters: setCode, setName, setOffice, setShortName, setStatus, addRate, removeRate */ /* CurrencyRate * \PhpTwinfield\CurrencyRate - * Available getters: getMessages, getRate, getResult, getStartDate, getStartDateToString, getStatus, hasMessages - * Available setters: setRate ,setStartDate, setStartDateFromString, setStatus, setStatusFromString + * Available getters: getMessages, getRate, getResult, getStartDate, getStatus, hasMessages + * Available setters: setRate ,setStartDate, setStatus */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { @@ -121,7 +124,7 @@ echo "Name: {$currency->getName()}
"; // string|null Name of the currency. echo "Office (\\PhpTwinfield\\Office):
" . print_r($currency->getOffice(), true) . "

"; // Office|null Office of the currency. - echo "Office (string): {$currency->getOfficeToString()}
"; // string|null + echo "Office (string): " . Util::objectToStr($currency->getOffice()) . "
"; // string|null echo "Result: {$currency->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "ShortName: {$currency->getShortName()}
"; // string|null Short name of the currency. NOTE: Because of the "hackish" way a currency is read (because Twinfield does not officially support reading currencies) the get() method will not return the current Short Name echo "Status: {$currency->getStatus()}
"; // Status|null Status of the currency. @@ -138,7 +141,7 @@ echo "Rate: {$currencyRate->getRate()}
"; // float|null Conversion rate to be used as of the start date. echo "Result: {$currencyRate->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "StartDate (\\DateTimeInterface):
" . print_r($currencyRate->getStartDate(), true) . "

"; // DateTimeInterface|null Starting date of the rate. - echo "StartDate (string): {$currencyRate->getStartDateToString()}
"; // string|null + echo "StartDate (string): " . Util::formatDate($currencyRate->getStartDate()) . "
"; // string|null echo "Status: {$currencyRate->getStatus()}
"; // Status|null Status of the currency rate. } } @@ -175,7 +178,7 @@ $currency->setCode('JPY'); // string|null The code of the currency. $currency->setName("Japanese yen"); // string|null Name of the currency. $currency->setOffice($office); // Office|null Office code of the currency. - $currency->setOfficeFromString($officeCode); // string|null + $currency->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null // Optional values for creating a new Currency $currency->setShortName("Yen"); // string|null Short name of the currency. @@ -183,18 +186,15 @@ $currency->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. //$currency->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null For deleting deleted should be used. In case a dimension that is used in a transaction is deleted, // its status has been changed into hide. Hidden dimensions can be activated by using active. - $currency->setStatusFromString('active'); // string|null - //$currency->setStatusFromString('deleted'); // string|null // The minimum amount of CurrencyRates linked to a Currency object is 0 $currencyRate = new \PhpTwinfield\CurrencyRate; $currencyRate->setRate(122.87); // float|null Conversion rate to be used as of the start date. $startDate = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); $currencyRate->setStartDate($startDate); // DateTimeInterface|null Starting date of the rate. - $currencyRate->setStartDateFromString('20190101'); // string|null + $currencyRate->setStartDate(Util::parseDate('20190101')); // string|null //$currencyRate->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null For creating and updating status may be left empty. NOTE: Do not use $currencyRate->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // For deleting deleted should be used. - //$currencyRate->setStatusFromString('deleted'); // string|null NOTE: Do not use $currencyRate->setStatusFromString('active'); $currency->addRate($currencyRate); // CurrencyRate Add a CurrencyRate object to the Currency object //$currency->removeRate(0); // int Remove a rate based on the index of the rate within the array diff --git a/examples/Customer.php b/examples/Customer.php index c358fca3..00504693 100644 --- a/examples/Customer.php +++ b/examples/Customer.php @@ -11,6 +11,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection @@ -108,64 +111,64 @@ /* Customer * \PhpTwinfield\Customer - * Available getters: getBeginPeriod, getBeginYear, getBehaviour, getCode, getDiscountArticle, getDiscountArticleID, getDiscountArticleToString, getEndPeriod, getEndYear, getGroup, getGroupToString, getInUse, getInUseToString, getMessages, getName, getOffice, getOfficeToString, - * getPaymentConditionDiscountDays, getPaymentConditionDiscountPercentage, getRemittanceAdviceSendMail, getRemittanceAdviceSendType, getResult, getShortName, getStatus, getTouched, getType, getTypeToString, getUID, getWebsite, hasMessages, getAddresses, getBanks, getCreditManagement, getFinancials, getPostingRules + * Available getters: getBeginPeriod, getBeginYear, getBehaviour, getCode, getDiscountArticle, getDiscountArticleID, getEndPeriod, getEndYear, getGroup, getInUse, getMessages, getName, getOffice, + * getPaymentConditionDiscountDays, getPaymentConditionDiscountPercentage, getRemittanceAdviceSendMail, getRemittanceAdviceSendType, getResult, getShortName, getStatus, getTouched, getType, getUID, getWebsite, hasMessages, getAddresses, getBanks, getCreditManagement, getFinancials, getPostingRules * - * Available setters: setBeginPeriod, setBeginYear, setBehaviour, setBehaviourFromString, setCode, setDiscountArticle, setDiscountArticleFromString, setDiscountArticleID, setEndPeriod, setEndYear, setGroup, setGroupFromString, setName, setOffice, setOfficeFromString, setPaymentConditionDiscountDays, - * setPaymentConditionDiscountPercentage, setRemittanceAdviceSendMail, setRemittanceAdviceSendType, setRemittanceAdviceSendTypeFromString, setShortName, setStatus, setStatusFromString, setType, setTypeFromString, setWebsite, setCreditManagement, setFinancials, addAddress, addBank, addPostingRule, removeAddress, removeBank, removePostingRule + * Available setters: setBeginPeriod, setBeginYear, setBehaviour, setCode, setDiscountArticle, setDiscountArticleID, setEndPeriod, setEndYear, setGroup, setName, setOffice, setPaymentConditionDiscountDays, + * setPaymentConditionDiscountPercentage, setRemittanceAdviceSendMail, setRemittanceAdviceSendType, setShortName, setStatus, setType, setWebsite, setCreditManagement, setFinancials, addAddress, addBank, addPostingRule, removeAddress, removeBank, removePostingRule * */ /* CustomerFinancials * \PhpTwinfield\CustomerFinancials - * Available getters: getAccountType, getCollectionSchema, getDueDays, getEBillMail, getEBilling, getEBillingToString, getLevel, getMatchType, getMeansOfPayment, getMessages, getPayAvailable, getPayAvailableToString, getPayCode, getPayCodeID, getPayCodeToString, - * getResult, getSubAnalyse, getSubstituteWith, getSubstituteWithID, getSubstituteWithToString, getSubstitutionLevel, getVatCode, getVatCodeFixed, getVatCodeFixedToString, getVatCodeToString, getChildValidations, getCollectMandate, hasMessages + * Available getters: getAccountType, getCollectionSchema, getDueDays, getEBillMail, getEBilling, getLevel, getMatchType, getMeansOfPayment, getMessages, getPayAvailable, getPayCode, getPayCodeID, + * getResult, getSubAnalyse, getSubstituteWith, getSubstituteWithID, getSubstitutionLevel, getVatCode, getVatCodeFixed, getChildValidations, getCollectMandate, hasMessages * - * Available setters: setAccountType, setAccountTypeFromString, setCollectionSchema, setCollectionSchemaFromString, setDueDays, setEBillMail, setEBilling, setEBillingFromString, setLevel, setMatchType, setMatchTypeFromString, setMeansOfPayment, setMeansOfPaymentFromString, - * setPayAvailable, setPayAvailableFromString, setPayCode, setPayCodeFromString, setPayCodeID, setSubAnalyse, setSubAnalyseFromString, setSubstituteWith, setSubstituteWithFromString, setSubstituteWithID, setSubstitutionLevel, setVatCode, setVatCodeFixed, setVatCodeFixedFromString, setVatCodeFromString, setCollectMandate, addChildValidation, removeChildValidation + * Available setters: setAccountType, setCollectionSchema, setDueDays, setEBillMail, setEBilling, setLevel, setMatchType, setMeansOfPayment, + * setPayAvailable, setPayCode, setPayCodeID, setSubAnalyse, setSubstituteWith, setSubstituteWithID, setSubstitutionLevel, setVatCode, setVatCodeFixed, setCollectMandate, addChildValidation, removeChildValidation * */ /* CustomerCollectMandate * \PhpTwinfield\CustomerCollectMandate - * Available getters: getFirstRunDate, getFirstRunDateToString, getID, getMessages, getResult, getSignatureDate, getSignatureDateToString, hasMessages - * Available setters: setFirstRunDate, setFirstRunDateFromString, setID, setSignatureDate, setSignatureDateFromString + * Available getters: getFirstRunDate, getID, getMessages, getResult, getSignatureDate, hasMessages + * Available setters: setFirstRunDate, setID, setSignatureDate */ /* CustomerChildValidation * \PhpTwinfield\CustomerChildValidation * Available getters: getElementValue, getLevel, getMessages, getResult, getType, hasMessages - * Available setters: setElementValue, setLevel, setType, setTypeFromString + * Available setters: setElementValue, setLevel, setType */ /* CustomerCreditManagement * \PhpTwinfield\CustomerCreditManagement - * Available getters: getBaseCreditLimit, getBaseCreditLimitToFloat, getBlocked, getBlockedLocked, getBlockedLockedToString, getBlockedModified, getBlockedModifiedToString, getBlockedToString, getComment, getFreeText1, getFreeText1ToString, getFreetext2, getFreetext3, getMessages, getReminderEmail, getResponsibleUser, getResponsibleUserToString, getResult, getSendReminder, hasMessages - * Available setters: setBaseCreditLimit, setBaseCreditLimitFromFloat, setBlocked, setBlockedFromString, setBlockedLocked, setBlockedLockedFromString, setBlockedModified, setBlockedModifiedFromString, setComment, setFreeText1, setFreeText1FromString, setFreetext2, setFreetext3, setReminderEmail, setResponsibleUser, setResponsibleUserFromString, setSendReminder, setSendReminderFromString + * Available getters: getBaseCreditLimit, getBlocked, getBlockedLocked, getBlockedModified, getComment, getFreeText1, getFreetext2, getFreetext3, getMessages, getReminderEmail, getResponsibleUser, getResult, getSendReminder, hasMessages + * Available setters: setBaseCreditLimit, setBlocked, setBlockedLocked, setBlockedModified, setComment, setFreeText1, setFreetext2, setFreetext3, setReminderEmail, setResponsibleUser, setSendReminder */ /* CustomerAddress * \PhpTwinfield\CustomerAddress - * Available getters: getCity, getCountry, getCountryToString, getDefault, getDefaultToString, getEmail, getField1, getField2, getField3, getField4, getField5, getField6, getID, getMessages, getName, getPostcode, getResult, getTelefax, getTelephone, getType, hasMessages - * Available setters: setCity, setCountry, setCountryFromString, setDefault, setDefaultFromString, setEmail, setField1, setField2, setField3, setField4, setField5, setField6, setID, setName, setPostcode, setTelefax, setTelephone, setType, setTypeFromString + * Available getters: getCity, getCountry, getDefault, getEmail, getField1, getField2, getField3, getField4, getField5, getField6, getID, getMessages, getName, getPostcode, getResult, getTelefax, getTelephone, getType, hasMessages + * Available setters: setCity, setCountry, setDefault, setEmail, setField1, setField2, setField3, setField4, setField5, setField6, setID, setName, setPostcode, setTelefax, setTelephone, setType */ /* CustomerBank * \PhpTwinfield\CustomerBank - * Available getters: getAccountNumber, getAddressField2, getAddressField3, getAscription, getBankName, getBicCode, getBlocked, getBlockedToString, getCity, getCountry, getCountryToString, getDefault, getDefaultToString, getID, getIban, getMessages, getNatBicCode, getPostcode, getResult, getState, hasMessages - * Available setters: setAccountNumber, setAddressField2, setAddressField3, setAscription, setBankName, setBicCode, setBlocked, setBlockedFromString, setCity, setCountry, setCountryFromString, setDefault, setDefaultFromString, setID, setIban, setNatBicCode, setPostcode, setState + * Available getters: getAccountNumber, getAddressField2, getAddressField3, getAscription, getBankName, getBicCode, getBlocked, getCity, getCountry, getDefault, getID, getIban, getMessages, getNatBicCode, getPostcode, getResult, getState, hasMessages + * Available setters: setAccountNumber, setAddressField2, setAddressField3, setAscription, setBankName, setBicCode, setBlocked, setCity, setCountry, setDefault, setID, setIban, setNatBicCode, setPostcode, setState */ /* CustomerPostingRule * \PhpTwinfield\CustomerPostingRule - * Available getters: getAmount, getAmountToFloat, getCurrency, getCurrencyToString, getDescription, getID, getMessages, getResult, getStatus, getLines, hasMessages - * Available setters: setAmount, setAmountFromFloat, setCurrency, setCurrencyFromString, setDescription, setID, setStatus, setStatusFromString, addLine, removeLine + * Available getters: getAmount, getCurrency, getDescription, getID, getMessages, getResult, getStatus, getLines, hasMessages + * Available setters: setAmount, setCurrency, setDescription, setID, setStatus, addLine, removeLine */ /* CustomerLine * \PhpTwinfield\CustomerLine - * Available getters: getDescription, getDimension1, getDimension1ID, getDimension1ToString, getDimension2, getDimension2ID, getDimension2ToString, getDimension3, getDimension3ID, getDimension3ToString, getMessages, getOffice, getOfficeToString, getRatio, getResult, getVatCode, getVatCodeToString, hasMessages - * Available setters: setDescription, setDimension1, setDimension1FromString, setDimension1ID, setDimension2, setDimension2FromString, setDimension2ID, setDimension3, setDimension3FromString, setDimension3ID, setOffice, setOfficeFromString, setRatio, setVatCode, setVatCodeFromString + * Available getters: getDescription, getDimension1, getDimension1ID, getDimension2, getDimension2ID, getDimension3, getDimension3ID, getMessages, getOffice, getRatio, getResult, getVatCode, hasMessages + * Available setters: setDescription, setDimension1, setDimension1ID, setDimension2, setDimension2ID, setDimension3, setDimension3ID, setOffice, setRatio, setVatCode */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { diff --git a/examples/DimensionGroup.php b/examples/DimensionGroup.php index 8046c18b..369d1f40 100644 --- a/examples/DimensionGroup.php +++ b/examples/DimensionGroup.php @@ -11,6 +11,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection @@ -92,14 +95,14 @@ /* DimensionGroup * \PhpTwinfield\DimensionGroup - * Available getters: getCode, getMessages, getName, getOffice, getOfficeToString, getResult, getShortName, getStatus, hasMessages, getDimensions - * Available setters: setCode, setName, setOffice, setOfficeFromString, setShortName, setStatus, setStatusFromString, addDimension,removeDimension + * Available getters: getCode, getMessages, getName, getOffice, getResult, getShortName, getStatus, hasMessages, getDimensions + * Available setters: setCode, setName, setOffice, setShortName, setStatus, addDimension,removeDimension */ /* DimensionGroupDimension * \PhpTwinfield\DimensionGroupDimension - * Available getters: getCode, getCodeToString, getMessages, getResult, getType, getTypeToString, hasMessages - * Available setters: setCode, setCodeFromString, setType, setTypeFromString + * Available getters: getCode, getMessages, getResult, getType, hasMessages + * Available setters: setCode, setType */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { @@ -131,7 +134,7 @@ echo "Name: {$dimensionGroup->getName()}
"; // string|null Name of the dimension group. echo "Office (\\PhpTwinfield\\Office):
" . print_r($dimensionGroup->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): {$dimensionGroup->getOfficeToString()}
"; // string|null + echo "Office (string): " . Util::objectToStr($dimensionGroup->getOffice()) . "
"; // string|null echo "Result: {$dimensionGroup->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "ShortName: {$dimensionGroup->getShortName()}
"; // string|null Short name of the dimension group. echo "Status: {$dimensionGroup->getStatus()}
"; // Status|null Status of the dimension group. @@ -146,10 +149,10 @@ } echo "Code:
" . print_r($dimensionGroupDimension->getCode(), true) . "

"; // object|null Code of the dimension. - echo "Code (string): {$dimensionGroupDimension->getCodeToString()}
"; // string|null + echo "Code (string): " . Util::objectToStr($dimensionGroupDimension->getCode()) . "
"; // string|null echo "Result: {$dimensionGroupDimension->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($dimensionGroupDimension->getType(), true) . "

"; // DimensionType|null Dimension type. - echo "Type (string): {$dimensionGroupDimension->getTypeToString()}
"; // string|null + echo "Type (string): " . Util::objectToStr($dimensionGroupDimension->getType()) . "
"; // string|null } } @@ -185,11 +188,9 @@ $dimensionGroup->setCode('DIMGRP2'); // string|null Dimension group code. $dimensionGroup->setName("Dimension Group 2"); // string|null Name of the dimension group. $dimensionGroup->setOffice($office); // Office|null Office code. - $dimensionGroup->setOfficeFromString($officeCode); // string|null + $dimensionGroup->setOfficeFromString(\PhpTwinfield\Office::fromCode($officeCode)); // string|null $dimensionGroup->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating active should be used. For deleting deleted should be used. //$dimensionGroup->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null - $dimensionGroup->setStatusFromString('active'); // string|null - //$dimensionGroup->setStatusFromString('deleted'); // string|null // Optional values for creating a new DimensionGroup $dimensionGroup->setShortName("DIM GRP 2"); // string|null Short name of the dimension group. @@ -199,11 +200,11 @@ $code = new \PhpTwinfield\GeneralLedger; $code->setCode('1010'); $dimensionGroupDimension->setCode($code); // object|null Code of the dimension. - $dimensionGroupDimension->setCodeFromString('1010'); // string|null + $dimensionGroupDimension->setCode(\PhpTwinfield\GeneralLedger::fromCode('1010')); // string|null $type = new \PhpTwinfield\DimensionType; $type->setCode('BAS'); $dimensionGroupDimension->setType($type); // DimensionType|null Dimension type. - $dimensionGroupDimension->setTypeFromString('BAS'); // string|null + $dimensionGroupDimension->setType(\PhpTwinfield\DimensionType::fromCode('BAS')); // string|null $dimensionGroup->addDimension($dimensionGroupDimension); // DimensionGroupDimension Add a DimensionGroupDimension object to the DimensionGroup object //$dimensionGroup->removeDimension(0); // int Remove a dimension based on the index of the dimension within the array diff --git a/examples/DimensionType.php b/examples/DimensionType.php index 0521dbd1..8491acd8 100644 --- a/examples/DimensionType.php +++ b/examples/DimensionType.php @@ -11,6 +11,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection @@ -90,8 +93,8 @@ /* DimensionType * \PhpTwinfield\DimensionType - * Available getters: getCode, getMask, getMessages, getName, getOffice, getOfficeToString, getResult, getShortName, getStatus, hasMessages, getAddress, getLevels - * Available setters: setCode, setMask, setName, setOffice, setOfficeFromString, setShortName, setStatus, setStatusFromString, setAddress, setLevels + * Available getters: getCode, getMask, getMessages, getName, getOffice, getResult, getShortName, getStatus, hasMessages, getAddress, getLevels + * Available setters: setCode, setMask, setName, setOffice, setShortName, setStatus, setAddress, setLevels */ /* DimensionTypeLevels @@ -136,7 +139,7 @@ echo "Name: {$dimensionType->getName()}
"; // string|null Dimension type name. echo "Office (\\PhpTwinfield\\Office):
" . print_r($dimensionType->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): {$dimensionType->getOfficeToString()}
"; // string|null + echo "Office (string): " . Util::objectToStr($dimensionType->getOffice()) . "
"; // string|null echo "Result: {$dimensionType->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "ShortName: {$dimensionType->getShortName()}
"; // string|null Dimension type short name. echo "Status: {$dimensionType->getStatus()}
"; // Status|null Status of the dimension type. diff --git a/examples/GeneralLedger.php b/examples/GeneralLedger.php index cc91d78e..84b04f18 100644 --- a/examples/GeneralLedger.php +++ b/examples/GeneralLedger.php @@ -104,20 +104,20 @@ /* GeneralLedger * \PhpTwinfield\GeneralLedger - * Available getters: getBeginPeriod, getBeginYear, getBehaviour, getCode, getEndPeriod, getEndYear, getGroup, getGroupToString, getInUse, getInUseToString, getMessages, getName, getOffice, getOfficeToString, getResult, getShortName, getStatus, getTouched, getType, getTypeToString, getWebsite, hasMessages, getFinancials - * Available setters: setBeginPeriod, setBeginYear, setBehaviour, setBehaviourFromString, setCode, setEndPeriod, setEndYear, setGroup, setGroupFromString, setName, setOffice, setOfficeFromString, setShortName, setStatus, setStatusFromString, setType, setTypeFromString, setFinancials + * Available getters: getBeginPeriod, getBeginYear, getBehaviour, getCode, getEndPeriod, getEndYear, getGroup, getInUse, getMessages, getName, getOffice, getResult, getShortName, getStatus, getTouched, getType, getWebsite, hasMessages, getFinancials + * Available setters: setBeginPeriod, setBeginYear, setBehaviour, setCode, setEndPeriod, setEndYear, setGroup, setName, setOffice, setShortName, setStatus, setType, setFinancials */ /* GeneralLedgerFinancials * \PhpTwinfield\GeneralLedgerFinancials - * Available getters: getAccountType, getLevel, getMatchType, getMessages, getResult, getSubAnalyse, getVatCode, getVatCodeFixed, getVatCodeFixedToString, getVatCodeToString, getChildValidations, hasMessages - * Available setters: setAccountType, setAccountTypeFromString, setLevel, setMatchType, setMatchTypeFromString, setSubAnalyse, setSubAnalyseFromString, setVatCode, setVatCodeFixed, setVatCodeFixedFromString, setVatCodeFromString, addChildValidation, removeChildValidation + * Available getters: getAccountType, getLevel, getMatchType, getMessages, getResult, getSubAnalyse, getVatCode, getVatCodeFixed, getChildValidations, hasMessages + * Available setters: setAccountType, setLevel, setMatchType, setSubAnalyse, setVatCode, setVatCodeFixed, addChildValidation, removeChildValidation */ /* GeneralLedgerChildValidation * \PhpTwinfield\GeneralLedgerChildValidation * Available getters: getElementValue, getLevel, getMessages, getResult, getType, hasMessages - * Available setters: setElementValue, setLevel, setType, setTypeFromString + * Available setters: setElementValue, setLevel, setType */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { diff --git a/examples/Invoice.php b/examples/Invoice.php index f565ed6b..a3383d65 100644 --- a/examples/Invoice.php +++ b/examples/Invoice.php @@ -11,6 +11,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection @@ -94,34 +97,30 @@ /* Invoice * \PhpTwinfield\Invoice - * Available getters: getBank, getBankToString, getCalculateOnly, getCalculateOnlyToString, getCurrency, getCurrencyToString, getCustomer, getCustomerName, getCustomerToString, getDebitCredit, getDeliverAddressNumber, getDueDate, getDueDateToString, getFinancialCode, getFinancialNumber, - * getFooterText, getHeaderText, getInvoiceAddressNumber, getInvoiceAmount, getInvoiceAmountToFloat, getInvoiceDate, getInvoiceDateToString, getInvoiceNumber, getInvoiceType, getInvoiceTypeToString, getMessages, getOffice, getOfficeToString, getPaymentMethod, - * getPerformanceDate, getPerformanceDateToString, getPeriod, getPeriodRaiseWarning, getPeriodRaiseWarningToString, getRaiseWarning, getRaiseWarningToString, getResult, getStatus, hasMessages, getLines, getMatchReference, getTotals, getVatLines + * Available getters: getBank, getCalculateOnly, getCurrency, getCustomer, getCustomerName, getDebitCredit, getDeliverAddressNumber, getDueDate, getFinancialCode, getFinancialNumber, getFooterText, getHeaderText, getInvoiceAddressNumber, getInvoiceAmount, getInvoiceDate, getInvoiceNumber, getInvoiceType, getMessages, getOffice, getPaymentMethod, + * getPerformanceDate, getPeriod, getPeriodRaiseWarning, getRaiseWarning, getResult, getStatus, hasMessages, getLines, getMatchReference, getTotals, getVatLines * - * Available setters: setBank, setBankFromString, setCalculateOnly, setCalculateOnlyFromString, setCurrency, setCurrencyFromString, setCustomer, setCustomerFromString, setCustomerName, setDebitCredit, setDebitCreditFromString, setDeliverAddressNumber, setDueDate, setDueDateFromString, - * setFinancialCode, setFinancialNumber, setFooterText, setHeaderText, setInvoiceAddressNumber, setInvoiceAmount, setInvoiceAmountFromFloat, setInvoiceDate, setInvoiceDateFromString, setInvoiceNumber, setInvoiceType, setInvoiceTypeFromString, setOffice, - * setOfficeFromString, setPaymentMethod, setPaymentMethodFromString, setPerformanceDate, setPerformanceDateFromString, setPeriod, setPeriodRaiseWarning, setPeriodRaiseWarningFromString, setRaiseWarning, setRaiseWarningFromString, setStatus, setStatusFromString, setTotals, addLine, addVatLine, removeLine, removeVatLine + * Available setters: setBank, setCalculateOnly, setCurrency, setCustomer, setCustomerName, setDebitCredit, setDeliverAddressNumber, setDueDate, setFinancialCode, setFinancialNumber, setFooterText, setHeaderText, setInvoiceAddressNumber, setInvoiceAmount, setInvoiceDate, setInvoiceNumber, setInvoiceType, setOffice, + * setOfficeFromString, setPaymentMethod, setPerformanceDate, setPeriod, setPeriodRaiseWarning, setRaiseWarning, setStatus, setTotals, addLine, addVatLine, removeLine, removeVatLine * */ /* InvoiceTotals * \PhpTwinfield\InvoiceTotals - * Available getters: getMessages, getResult, getValueExcl, getValueExclToFloat, getValueInc, getValueIncToFloat, hasMessages - * Available setters: setValueExcl, setValueExclFromFloat, setValueInc, setValueIncFromFloat + * Available getters: getMessages, getResult, getValueExcl, getValueInc, hasMessages + * Available setters: setValueExcl, setValueInc */ /* InvoiceLine * \PhpTwinfield\InvoiceLine - * Available getters: getAllowDiscountOrPremium, getAllowDiscountOrPremiumToString, getArticle, getArticleToString, getDescription, getDim1, getDim1ToString, getFreetext1, getFreetext2, getFreetext3, getID, getMessages, getPerformanceDate, getPerformanceDateToString, getPerformanceType, - * getQuantity, getResult, getSubArticle, getSubArticleToString, getUnits, getUnitsPriceExcl, getUnitsPriceExclToFloat, getUnitsPriceInc, getUnitsPriceIncToFloat, getValueExcl, getValueExclToFloat, getValueInc, getValueIncToFloat, getVatCode, getVatCodeToString, getVatValue, getVatValueToFloat, hasMessages - * Available setters: setAllowDiscountOrPremium, setAllowDiscountOrPremiumFromString, setArticle, setArticleFromString, setDescription, setDim1, setDim1FromString, setFreetext1, setFreetext2, setFreetext3, setID, setPerformanceDate, setPerformanceDateFromString, setPerformanceType, setPerformanceTypeFromString, - * setQuantity, setSubArticle, setSubArticleFromString, setUnits, setUnitsPriceExcl, setUnitsPriceExclFromFloat, setUnitsPriceInc, setUnitsPriceIncFromFloat, setValueExcl, setValueExclFromFloat, setValueInc, setValueIncFromFloat, setVatCode, setVatCodeFromString, setVatValue, setVatValueFromFloat + * Available getters: getAllowDiscountOrPremium, getArticle, getDescription, getDim1, getFreetext1, getFreetext2, getFreetext3, getID, getMessages, getPerformanceDate, getPerformanceType, getQuantity, getResult, getSubArticle, getUnits, getUnitsPriceExcl, getUnitsPriceInc, getValueExcl, getValueInc, getVatCode, getVatValue, hasMessages + * Available setters: setAllowDiscountOrPremium, setArticle, setDescription, setDim1, setFreetext1, setFreetext2, setFreetext3, setID, setPerformanceDate, setPerformanceType, setQuantity, setSubArticle, setUnits, setUnitsPriceExcl, setUnitsPriceInc, setValueExcl, setValueInc, setVatCode, setVatValue */ /* InvoiceVatLine * \PhpTwinfield\InvoiceVatLine - * Available getters: getMessages, getPerformanceDate, getPerformanceDateToString, getPerformanceType, getResult, getVatCode, getVatCodeToString, getVatValue, getVatValueToFloat, hasMessages - * Available setters: setPerformanceDate, setPerformanceDateFromString, setPerformanceType, setPerformanceTypeFromString, setVatCode, setVatCodeFromString, setVatValue, setVatValueFromFloat + * Available getters: getMessages, getPerformanceDate, getPerformanceType, getResult, getVatCode, getVatValue, hasMessages + * Available setters: setPerformanceDate, setPerformanceType, setVatCode, setVatValue */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { @@ -298,87 +297,76 @@ $customer = new \PhpTwinfield\Customer; $customer->setCode('1000'); $invoice->setCustomer($customer); // Customer|null Customer code. - $invoice->setCustomerFromString("1000"); // string|null + $invoice->setCustomer(\PhpTwinfield\Customer::fromCode("1000")); // string|null $invoiceType = new \PhpTwinfield\InvoiceType; $invoiceType->setCode('FACTUUR'); $invoice->setInvoiceType($invoiceType); // InvoiceType|null Invoice type code. - $invoice->setInvoiceTypeFromString("FACTUUR"); // string|null + $invoice->setInvoiceType(\PhpTwinfield\InvoiceType::fromCode("FACTUUR")); // string|null $invoice->setOffice($office); // Office|null Office code. - $invoice->setOfficeFromString($officeCode); // string|null + $invoice->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null // Optional values for creating a new Invoice $invoice->setCalculateOnly(false); // bool|null Attribute to indicate that invoice should not be saved but only checked and calculated. @calculateonly must be true for that. - $invoice->setCalculateOnlyFromString('false'); // string|null $invoice->setRaiseWarning(true); // bool|null Should warnings be given true or not false? Default true. - $invoice->setRaiseWarningFromString('true'); // string|null $bank = new \PhpTwinfield\CashBankBook; $bank->setCode('BNK'); $invoice->setBank($bank); // CashBankBook|null Customer code. - $invoice->setBankFromString("BNK"); + $invoice->setBankFromString(\PhpTwinfield\CashBankBook::fromCode("BNK")); // string|null $currency = new \PhpTwinfield\Currency; $currency->setCode('EUR'); $invoice->setCurrency($currency); // Currency|null Currency code. - $invoice->setCurrencyFromString("EUR"); + $invoice->setCurrency(\PhpTwinfield\Currency::fromCode("EUR")); // string|null $invoice->setDeliverAddressNumber(1); // int|null If you want the default address, omit the tag or leave it empty. $dueDate = \DateTime::createFromFormat('d-m-Y', '01-07-2019'); $invoice->setDueDate($dueDate); // DateTimeInterface|null Due date. - $invoice->setDueDateFromString("20190701"); // string|null + $invoice->setDueDate(Util::parseDate("20190701")); // string|null $invoice->setFooterText("Example Footer"); // string|null Footer text on the invoice. $invoice->setHeaderText("Example Header"); // string|null Header text on the invoice. $invoice->setInvoiceAddressNumber(1); // int|null If you want the default address, omit the tag or leave it empty. $invoiceDate = \DateTime::createFromFormat('d-m-Y', '01-07-2019'); $invoice->setInvoiceDate($invoiceDate); // DateTimeInterface|null Optional; when the invoicedate is not supplied Twinfield uses the system date as the invoice date. - $invoice->setInvoiceDateFromString("20190701"); // string|null + $invoice->setInvoiceDate(Util::parseDate("20190701")); // string|null $invoice->setPaymentMethod(\PhpTwinfield\Enums\PaymentMethod::BANK()); // PaymentMethod|null The payment method. - $invoice->setPaymentMethodFromString("bank"); // string|null $performanceDate = \DateTime::createFromFormat('d-m-Y', '01-07-2019'); $invoice->setPerformanceDate($performanceDate); // DateTimeInterface|null Performance date, when set-up on the invoice header. - $invoice->setPerformanceDateFromString("20190701"); // string|null + $invoice->setPerformanceDate(Util::parseDate("20190701")); // string|null $invoice->setPeriod("2019/07"); // string|null Period in YYYY/PP format. - $invoice->setPeriodRaiseWarning(false); // bool|null Optionally, it is possible to suppress warnings about 'date out of range for the given period' by adding the raisewarning attribute and set its value to false. - - $invoice->setPeriodRaiseWarningFromString('false'); // string|null This overwrites the value of the raisewarning attribute as set on the root element. - //$invoice->setStatus(\PhpTwinfield\Enums\InvoiceStatus::CONCEPT()); // InvoiceStatus|null default can only be returned when retrieving a sales invoice. - //$invoice->setStatus(\PhpTwinfield\Enums\InvoiceStatus::FINAL()); // InvoiceStatus|null You cannot use this status when creating or updating an invoice. - //$invoice->setStatusFromString('concept'); // string|null concept saves the invoice as provisional. After saving as final, no changes can be made anymore. - //$invoice->setStatusFromString('final'); // string|null When posting an invoice final, a financial transaction is generated and posted automatically. + $invoice->setPeriodRaiseWarning(false); // bool|null Optionally, it is possible to suppress warnings about 'date out of range for the given period' by adding the raisewarning attribute and set its value to false. This overwrites the value of the raisewarning attribute as set on the root element. + //$invoice->setStatus(\PhpTwinfield\Enums\InvoiceStatus::CONCEPT()); // InvoiceStatus|null default can only be returned when retrieving a sales invoice. You cannot use this status when creating or updating an invoice. + //$invoice->setStatus(\PhpTwinfield\Enums\InvoiceStatus::FINAL()); // InvoiceStatus|null concept saves the invoice as provisional. After saving as final, no changes can be made anymore. When posting an invoice final, a financial transaction is generated and posted automatically. // The minimum amount of InvoiceLines linked to an Invoice object is 1 $invoiceLine = new \PhpTwinfield\InvoiceLine; $invoiceLine->setAllowDiscountOrPremium(true); // bool|null Calculate discount on this line. - $invoiceLine->setAllowDiscountOrPremiumFromString('true'); // string|null $article = new \PhpTwinfield\Article; $article->setCode('9060'); $invoiceLine->setArticle($article); // Article|null Article code. - $invoiceLine->setArticleFromString('9060'); // string|null + $invoiceLine->setArticle(\PhpTwinfield\Article::fromCode('9060')); // string|null //$invoiceLine->setDescription('Example Description'); // string|null Invoice line description, only on the lines with article ‘0’ or ‘-‘. $dim1 = new \PhpTwinfield\GeneralLedger; $dim1->setCode('9060'); $invoiceLine->setDim1($dim1); // GeneralLedger|null Balance account. - $invoiceLine->setDim1FromString('9060'); // string|null + $invoiceLine->setDim1(\PhpTwinfield\GeneralLedger::fromCode('9060')); // string|null //$invoiceLine->setFreeText1('Example Free Text 1'); // string|null Free text field 1 as entered on the invoice type. //$invoiceLine->setFreeText2('Example Free Text 2'); // string|null Free text field 2 as entered on the invoice type. //$invoiceLine->setFreetext3("Example Free Text 3"); // string|null Free text field 3 as entered on the invoice type. $invoiceLine->setID(1); // int|null Line ID. //$invoiceLine->setPerformanceType(\PhpTwinfield\Enums\PerformanceType::SERVICES()); // PerformanceType|null The performance type in case of an ICT sales invoice. - //$invoiceLine->setPerformanceTypeFromString("services"); // string|null //$invoiceLine->setPerformanceDate($performanceDate); // DateTimeInterface|null Performance date, when set-up on invoice lines. - //$invoiceLine->setPerformanceDateFromString("20190701"); // string|null + //$invoiceLine->setPerformanceDate(Util::parseDate("20190701")); // string|null $invoiceLine->setQuantity(1); // int|null The quantity on the sales invoice line. $subArticle = new \PhpTwinfield\ArticleLine; $subArticle->setSubCode('9060'); $invoiceLine->setSubArticle($subArticle); // ArticleLine|null Sub-article code. - $invoiceLine->setSubArticleFromString('9060'); // string|null + $invoiceLine->setSubArticle(\PhpTwinfield\ArticleLine::fromCode('9060')); // string|null $invoiceLine->setUnits(1); // int|null The number of units per quantity. - $invoiceLine->setUnitsPriceExcl(\Money\Money::EUR(1000)); // Money|null Only valid for invoice types with VAT exclusive units prices. Only add this tag to an XML request if the setting Prices can be changed on an item is set to true. - $invoiceLine->setUnitsPriceExclFromFloat(10); // float|null Otherwise, the price will be determined by the system. - //$invoiceLine->setUnitsPriceInc(\Money\Money::EUR(1210)); // Money|null Only valid for invoice types with VAT inclusive units prices. Only add this tag to an XML request if the setting Prices can be changed on an item is set to true. - //$invoiceLine->setUnitsPriceIncFromFloat(12.10); // float|null Otherwise, the price will be determined by the system. + $invoiceLine->setUnitsPriceExcl(\Money\Money::EUR(1000)); // Money|null Only valid for invoice types with VAT exclusive units prices. Only add this tag to an XML request if the setting Prices can be changed on an item is set to true. Otherwise, the price will be determined by the system. (Equals 10.00 EUR) + //$invoiceLine->setUnitsPriceInc(\Money\Money::EUR(1210)); // Money|null Only valid for invoice types with VAT inclusive units prices. Only add this tag to an XML request if the setting Prices can be changed on an item is set to true. Otherwise, the price will be determined by the system. (Equals 12.10 EUR) $vatCode = new \PhpTwinfield\VatCode; $vatCode->setCode('VH'); //$invoiceLine->getVatCode($vatCode); // VatCode|null VAT code. - //$invoiceLine->setVatCodeFromString('VH'); // string|null + //$invoiceLine->setVatCode(\PhpTwinfield\VatCode::fromCode('VH')); // string|null $invoice->addLine($invoiceLine); // InvoiceLine Add an InvoiceLine object to the Invoice object //$invoice->removeLine(0); // int Remove an invoice line based on the index of the invoice line diff --git a/examples/InvoiceType.php b/examples/InvoiceType.php index a77182a1..0cdab159 100644 --- a/examples/InvoiceType.php +++ b/examples/InvoiceType.php @@ -8,6 +8,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection diff --git a/examples/Office.php b/examples/Office.php index f3cb55a4..ff2fc493 100644 --- a/examples/Office.php +++ b/examples/Office.php @@ -11,6 +11,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection @@ -103,8 +106,8 @@ /* Office * \PhpTwinfield\Office - * Available getters: __toString, getCode, getCountryCode, getCountryCodeToString, getCreated, getCreatedToString, getMessages, getModified, getModifiedToString, getName, getResult, getShortName, getStatus, getTouched, getUser, getUserToString, getVatFirstQuarterStartsIn, getVatPeriod, hasMessages - * Available setters: fromCode, setCode, setCountryCode, setCountryCodeFromString, setName, setShortName, setStatus, setStatusFromString, setVatFirstQuarterStartsIn,setVatPeriod + * Available getters: __toString, getCode, getCountryCode, getCreated, getMessages, getModified, getName, getResult, getShortName, getStatus, getTouched, getUser, getVatFirstQuarterStartsIn, getVatPeriod, hasMessages + * Available setters: fromCode, setCode, setCountryCode, setName, setShortName, setStatus, setVatFirstQuarterStartsIn,setVatPeriod */ if ($executeListAllWithoutOfficeCode || $executeListAllWithFilter || $executeListAllWithoutFilter) { @@ -113,7 +116,7 @@ echo "Code: {$office->getCode()}
"; echo "Name: {$office->getName()}

"; echo "CountryCode (\\PhpTwinfield\\Country):
" . print_r($office->getCountryCode(), true) . "

"; - echo "CountryCode (string): {$office->getCountryCodeToString()}
"; + echo "CountryCode (string): " . Util::objectToStr($office->getCountryCode()) . "
"; echo "VatFirstQuarterStartsIn: {$office->getVatFirstQuarterStartsIn()}
"; echo "VatPeriod: {$office->getVatPeriod()}
"; } @@ -135,23 +138,23 @@ echo "Code: {$office}
"; // string|null echo "Code: {$office->getCode()}
"; // string|null //echo "CountryCode (\\PhpTwinfield\\Country):
" . print_r($office->getCountryCode(), true) . "

"; // Country|null - //echo "CountryCode (string): {$office->getCountryCodeToString()}
"; // string|null + //echo "CountryCode (string): " . Util::objectToStr($office->getCountryCode()) . "
"; // string|null echo "Created (\\DateTimeInterface):
" . print_r($office->getCreated(), true) . "

"; // DateTimeInterface|null The date/time the office was created. - echo "Created (string): {$office->getCreatedToString()}
"; // string|null + echo "Created (string): " . Util::parseDateTime($office->getCreatedToString()) . "
"; // string|null if ($office->hasMessages()) { // bool Object contains (error) messages true/false. echo "Messages: " . print_r($office->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "Modified (\\DateTimeInterface):
" . print_r($office->getModified(), true) . "

"; // DateTimeInterface|null The date/time the office was modified. - echo "Modified (string): {$office->getModifiedToString()}
"; // string|null + echo "Modified (string): " . Util::parseDateTime($office->getModified()) . "
"; // string|null echo "Name: {$office->getName()}
"; // string|null echo "Result: {$office->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "ShortName: {$office->getShortName()}
"; // string|null echo "Status: {$office->getStatus()}
"; // Status|null echo "Touched: {$office->getTouched()}
"; // int|null The number of times the office is modified. echo "User (\\PhpTwinfield\\User):
" . print_r($office->getUser(), true) . "

"; // User|null The code of the user who created or modified the Office. - echo "User (string): {$office->getUserToString()}
"; // string|null + echo "User (string): " . Util::objectToStr($office->getUser()) . "
"; // string|null //echo "VatFirstQuarterStartsIn: {$office->getVatFirstQuarterStartsIn()}
"; // string|null //echo "VatPeriod: {$office->getVatPeriod()}
"; // string|null } \ No newline at end of file diff --git a/examples/PayCode.php b/examples/PayCode.php index d20efade..da5098df 100644 --- a/examples/PayCode.php +++ b/examples/PayCode.php @@ -8,6 +8,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection diff --git a/examples/Project.php b/examples/Project.php index 1bb60f37..d2c1210c 100644 --- a/examples/Project.php +++ b/examples/Project.php @@ -11,6 +11,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection @@ -99,26 +102,24 @@ /* Project * \PhpTwinfield\Project - * Available getters: getBehaviour, getCode, getInUse, getInUseToString, getMessages, getName, getOffice, getOfficeToString, getResult, getShortName, getStatus, getTouched, getType, getTypeToString, getUID, getVatCode, getVatCodeToString, hasMessages, getProjects - * Available setters: setBehaviour, setBehaviourFromString, setCode, setName, setOffice, setOfficeFromString, setShortName, setStatus, setStatusFromString, setType, setTypeFromString, setVatCode, setVatCodeFromString, setProjects + * Available getters: getBehaviour, getCode, getInUse, getMessages, getName, getOffice, getResult, getShortName, getStatus, getTouched, getType, getUID, getVatCode, hasMessages, getProjects + * Available setters: setBehaviour, setCode, setName, setOffice, setShortName, setStatus, setType, setVatCode, setProjects */ /* ProjectProjects * \PhpTwinfield\ProjectProjects - * Available getters: getAuthoriser, getAuthoriserInherit, getAuthoriserInheritToString, getAuthoriserLocked, getAuthoriserLockedToString, getAuthoriserToString, getBillable, getBillableForRatio, getBillableForRatioToString, getBillableInherit, getBillableInheritToString, - * getBillableLocked, getBillableLockedToString, getBillableToString, getCustomer, getCustomerInherit, getCustomerInheritToString, getCustomerLocked, getCustomerLockedToString, getCustomerToString, getInvoiceDescription, getMessages, getRate, getRateInherit, getRateInheritToString, - * getRateLocked, getRateLockedToString, getRateToString, getResult, getValidFrom, getValidFromToString, getValidTill, getValidTillToString, hasMessages, getQuantities + * Available getters: getAuthoriser, getAuthoriserInherit, getAuthoriserLocked, getBillable, getBillableForRatio, getBillableInherit, getBillableLocked, getCustomer, getCustomerInherit, getCustomerLocked, getInvoiceDescription, getMessages, getRate, getRateInherit, + * getRateLocked, getResult, getValidFrom, getValidTill, hasMessages, getQuantities * - * Available setters: setAuthoriser, setAuthoriserFromString, setAuthoriserInherit, setAuthoriserInheritFromString, setAuthoriserLocked, setAuthoriserLockedFromString, setBillable, setBillableForRatio, setBillableForRatioFromString, setBillableFromString, setBillableInherit, setBillableInheritFromString, - * setBillableLocked, setBillableLockedFromString, setCustomer, setCustomerFromString, setCustomerInherit, setCustomerInheritFromString, setCustomerLocked, setCustomerLockedFromString, setInvoiceDescription, setRate, setRateFromString, setRateInherit, setRateInheritFromString, - * setRateLocked, setRateLockedFromString, setValidFrom, setValidFromFromString, setValidTill, setValidTillFromString, addQuantity, removeQuantity + * Available setters: setAuthoriser, setAuthoriserInherit, setAuthoriserLocked, setBillable, setBillableForRatio, setBillableInherit, setBillableLocked, setCustomer, setCustomerInherit, setCustomerLocked, setInvoiceDescription, setRate, setRateInherit, + * setRateLocked, setValidFrom, setValidTill, addQuantity, removeQuantity * */ /* ProjectQuantity * \PhpTwinfield\ProjectQuantity - * Available getters: getBillable, getBillableLocked, getBillableLockedToString, getBillableToString, getLabel, getMandatory, getMandatoryToString, getMessages, getRate, getRateToString, getResult, hasMessages - * Available setters: setBillable, setBillableFromString, setBillableLocked, setBillableLockedFromString, setLabel, setMandatory, setMandatoryFromString, setRate, setRateFromString + * Available getters: getBillable, getBillableLocked, getLabel, getMandatory, getMessages, getRate, getResult, hasMessages + * Available setters: setBillable, setBillableLocked, setLabel, setMandatory, setRate */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { diff --git a/examples/Rate.php b/examples/Rate.php index 43862ea9..bf3160b9 100644 --- a/examples/Rate.php +++ b/examples/Rate.php @@ -11,6 +11,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection @@ -88,14 +91,14 @@ /* Rate * \PhpTwinfield\Rate - * Available getters: getCode, getCreated, getCreatedToString, getCurrency, getCurrencyToString, getMessages, getModified, getModifiedToString, getName, getOffice, getOfficeToString, getResult, getShortName, getStatus, getTouched, getType, getUnit, getUser, getUserToString, hasMessages, getRateChanges - * Available setters: setCode, setCurrency, setCurrencyFromString, setName, setOffice, setOfficeFromString, setShortName, setStatus, setStatusFromString, setType, setTypeFromString, setUnit, addRateChange, removeRateChange + * Available getters: getCode, getCreated, getCurrency, getMessages, getModified, getName, getOffice, getResult, getShortName, getStatus, getTouched, getType, getUnit, getUser, hasMessages, getRateChanges + * Available setters: setCode, setCurrency, setName, setOffice, setShortName, setStatus, setType, setUnit, addRateChange, removeRateChange */ /* RateRateChange * \PhpTwinfield\RateRateChange - * Available getters: getBeginDate, getBeginDateToString, getEndDate, getEndDateToString, getExternalRate, getID, getInternalRate, getMessages, getResult, getStatus, hasMessages - * Available setters: setBeginDate, setBeginDateFromString, setEndDate, setEndDateFromString, setExternalRate, setID, setInternalRate, setStatus, setStatusFromString + * Available getters: getBeginDate, getEndDate, getExternalRate, getID, getInternalRate, getMessages, getResult, getStatus, hasMessages + * Available setters: setBeginDate, setEndDate, setExternalRate, setID, setInternalRate, setStatus */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { @@ -121,19 +124,19 @@ echo "Rate
"; echo "Code: {$rate->getCode()}
"; // string|null Rate code. echo "Created (\\DateTimeInterface):
" . print_r($rate->getCreated(), true) . "

"; // DateTimeInterface|null The date/time the rate was created. Read-only attribute. - echo "Created (string): {$rate->getCreatedToString()}
"; // string|null + echo "Created (string): " . Util::formatDateTime($rate->getCreated()) . "
"; // string|null echo "Currency (\\PhpTwinfield\\Currency):
" . print_r($rate->getCurrency(), true) . "

"; // Currency|null Currency code. - echo "Currency (string): {$rate->getCurrencyToString()}
"; // string|null + echo "Currency (string): " . Util::objectToStr($rate->getCurrency()) . "
"; // string|null if ($rate->hasMessages()) { // bool Object contains (error) messages true/false. echo "Messages: " . print_r($rate->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "Modified (\\DateTimeInterface):
" . print_r($rate->getModified(), true) . "

"; // DateTimeInterface|null The date/time the rate was modified. Read-only attribute. - echo "Modified (string): {$rate->getModifiedToString()}
"; // string|null + echo "Modified (string): " . Util::formatDateTime($rate->getModified()) . "
"; // string|null echo "Name: {$rate->getName()}
"; // string|null Rate description. echo "Office (\\PhpTwinfield\\Office):
" . print_r($rate->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): {$rate->getOfficeToString()}
"; // string|null + echo "Office (string): " . Util::objectToStr($rate->getOffice()) . "
"; // string|null echo "Result: {$rate->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "ShortName: {$rate->getShortName()}
"; // string|null Short rate description. echo "Status: {$rate->getStatus()}
"; // Status|null Status of the rate. @@ -142,7 +145,7 @@ echo "Unit: {$rate->getUnit()}
"; // int|null How will be charged e.g. if charged per hour Time, set it to 60. If charged per 8 hours, set it to 8 * 60 = 460. // Quantities refers to items such as kilometers. If charged per kilometer set it to 1. echo "User (\\PhpTwinfield\\User):
" . print_r($rate->getUser(), true) . "

"; // User|null The code of the user who created or modified the Rate. Read-only attribute. - echo "User (string): {$rate->getUserToString()}
"; // string|null + echo "User (string): " . Util::objectToStr($rate->getUser()) . "
"; // string|null $rateRateChanges = $rate->getRateChanges(); // Array|null Array of RateRateChange objects. @@ -150,9 +153,9 @@ echo "RateRateChange {$key}
"; echo "BeginDate (\\DateTimeInterface):
" . print_r($rateRateChange->getBeginDate(), true) . "

"; // DateTimeInterface|null Begin date of the rate. - echo "BeginDate (string): {$rateRateChange->getBeginDateToString()}
"; // string|null + echo "BeginDate (string): " . Util::formatDate($rateRateChange->getBeginDate()) . "
"; // string|null echo "EndDate (\\DateTimeInterface):
" . print_r($rateRateChange->getEndDate(), true) . "

"; // DateTimeInterface|null End date of the rate. - echo "EndDate (string): {$rateRateChange->getEndDateToString()}
"; // string|null + echo "EndDate (string): " . Util::formatDate($rateRateChange->getEndDate()) . "
"; // string|null echo "ExternalRate: {$rateRateChange->getExternalRate()}
"; // int|null The external rate e.g. the selling price per unit. echo "ID: {$rateRateChange->getID()}
"; // int|null Line ID. echo "InternalRate: {$rateRateChange->getInternalRate()}
"; // int|null The internal rate e.g. the cost price per unit. @@ -199,12 +202,11 @@ $currency = new \PhpTwinfield\Currency; $currency->setCode('EUR'); $rate->setCurrency($currency); // Currency|null Currency code. - $rate->setCurrencyFromString('EUR'); // string|null + $rate->setCurrency(\PhpTwinfield\Currency::fromCode('EUR')); // string|null $rate->setName("Example Rate"); // string|null Rate description. $rate->setOffice($office); // Office|null Office code. - $rate->setOfficeFromString($officeCode); // string|null + $rate->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null $rate->setType(\PhpTwinfield\Enums\RateType::TIME()); // RateType|null The rate type. - $rate->setTypeFromString('time'); // string|null $rate->setUnit(60); // int|null How will be charged e.g. if charged per hour Time, set it to 60. If charged per 8 hours, set it to 8 * 60 = 460. // Quantities refers to items such as kilometers. If charged per kilometer set it to 1. // Optional values for creating a new Rate @@ -212,23 +214,20 @@ $rate->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. //$rate->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // For deleting deleted should be used. In case a rate that is in use, its status has been changed into hide. // Hidden rates can be activated by using active. - $rate->setStatusFromString('active'); // string|null - //$rate->setStatusFromString('deleted'); // string|null // The minimum amount of RateRateChanges linked to a Rate object is 0 $rateRateChange = new \PhpTwinfield\RateRateChange; $beginDate = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); $rateRateChange->setBeginDate($beginDate); // DateTimeInterface|null Begin date of the rate. - $rateRateChange->setBeginDateFromString('20190101'); // string|null + $rateRateChange->setBeginDate(Util::parseDate('20190101')); // string|null $endDate = \DateTime::createFromFormat('d-m-Y', '31-12-2019'); $rateRateChange->setEndDate($endDate); // DateTimeInterface|null Begin date of the rate. - $rateRateChange->setEndDateFromString('20191231'); // string|null + $rateRateChange->setEndDate(Util::parseDate('20191231')); // string|null $rateRateChange->setExternalRate(60); // float|null The internal rate e.g. the cost price per unit. $rateRateChange->setID(2); // int|null Line ID. $rateRateChange->setInternalRate(120); // float|null The internal rate e.g. the cost price per unit. //$rateRateChange->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null Status of the rate line. For creating and updating status may be left empty. NOTE: Do not use $rateRateChange->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); - // For deleting deleted should be used. - //$rateRateChange->setStatusFromString('deleted'); // string|null NOTE: Do not use $rateRateChange->setStatusFromString('active'); + // For deleting deleted should be used. NOTE: Do not use $rateRateChange->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); $rate->addRateChange($rateRateChange); // RateRateChange Add a RateRateChange object to the Rate object //$rate->removeRateChange(0); // int Remove a rate change based on the index of the rate change diff --git a/examples/Supplier.php b/examples/Supplier.php index 81efab14..d2f08ffc 100644 --- a/examples/Supplier.php +++ b/examples/Supplier.php @@ -11,6 +11,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection @@ -108,52 +111,50 @@ /* Supplier * \PhpTwinfield\Supplier - * Available getters: getBeginPeriod, getBeginYear, getBehaviour, getBlockedAccountPaymentConditionsIncludeVat, getBlockedAccountPaymentConditionsPercentage, getCode, getEndPeriod, getEndYear, getGroup, getGroupToString, getInUse, getInUseToString, getMessages, getName, getOffice, getOfficeToString, - * getPaymentConditionDiscountDays, getPaymentConditionDiscountPercentage, getRemittanceAdviceSendMail, getRemittanceAdviceSendType, getResult, getShortName, getStatus, getTouched, getType, getTypeToString, getUID, getWebsite, hasMessages, getAddresses, getBanks, getFinancials, getPostingRules + * Available getters: getBeginPeriod, getBeginYear, getBehaviour, getBlockedAccountPaymentConditionsIncludeVat, getBlockedAccountPaymentConditionsPercentage, getCode, getEndPeriod, getEndYear, getGroup, getInUse, getMessages, getName, getOffice, + * getPaymentConditionDiscountDays, getPaymentConditionDiscountPercentage, getRemittanceAdviceSendMail, getRemittanceAdviceSendType, getResult, getShortName, getStatus, getTouched, getType, getUID, getWebsite, hasMessages, getAddresses, getBanks, getFinancials, getPostingRules * - * Available setters: setBeginPeriod, setBeginYear, setBehaviour, setBehaviourFromString, setBlockedAccountPaymentConditionsIncludeVat, setBlockedAccountPaymentConditionsIncludeVatFromString, setBlockedAccountPaymentConditionsPercentage, setCode, setEndPeriod, setEndYear, setGroup, setGroupFromString, setName, setOffice, setOfficeFromString, - * setPaymentConditionDiscountDays, setPaymentConditionDiscountPercentage, setRemittanceAdviceSendMail, setRemittanceAdviceSendType, setRemittanceAdviceSendTypeFromString, setShortName, setStatus, setStatusFromString, setType, setTypeFromString, setWebsite, setFinancials, addAddress, removeAddress, addBank, removeBank, addPostingRule, removePostingRule + * Available setters: setBeginPeriod, setBeginYear, setBehaviour, setBlockedAccountPaymentConditionsIncludeVat, setBlockedAccountPaymentConditionsPercentage, setCode, setEndPeriod, setEndYear, setGroup, setName, setOffice, + * setPaymentConditionDiscountDays, setPaymentConditionDiscountPercentage, setRemittanceAdviceSendMail, setRemittanceAdviceSendType, setShortName, setStatus, setType, setWebsite, setFinancials, addAddress, removeAddress, addBank, removeBank, addPostingRule, removePostingRule * */ /* SupplierFinancials * \PhpTwinfield\SupplierFinancials - * Available getters: getAccountType, getDueDays, getLevel, getMatchType, getMeansOfPayment, getMessages, getPayAvailable, getPayAvailableToString, getPayCode, getPayCodeID, getPayCodeToString, getRelationsReference, - * getResult, getSubAnalyse, getSubstituteWith, getSubstituteWithID, getSubstituteWithToString, getSubstitutionLevel, getVatCode, getVatCodeFixed, getVatCodeFixedToString, getVatCodeToString, getChildValidations, hasMessages + * Available getters: getAccountType, getDueDays, getLevel, getMatchType, getMeansOfPayment, getMessages, getPayAvailable, getPayCode, getPayCodeID, getRelationsReference, getResult, getSubAnalyse, getSubstituteWith, getSubstituteWithID, getSubstitutionLevel, getVatCode, getVatCodeFixed, getChildValidations, hasMessages * - * Available setters: setAccountType, setAccountTypeFromString, setDueDays, setLevel, setMatchType, setMatchTypeFromString, setMeansOfPayment, setMeansOfPaymentFromString, setPayAvailable, setPayAvailableFromString, - * setPayCode, setPayCodeFromString, setPayCodeID, setRelationsReference, setSubAnalyse, setSubAnalyseFromString, setSubstituteWith, setSubstituteWithFromString, setSubstituteWithID, setSubstitutionLevel, setVatCode, setVatCodeFixed, setVatCodeFixedFromString, setVatCodeFromString, addChildValidation, removeChildValidation + * Available setters: setAccountType, setDueDays, setLevel, setMatchType, setMeansOfPayment, setPayAvailable, setPayCode, setPayCodeID, setRelationsReference, setSubAnalyse, setSubstituteWith, setSubstituteWithID, setSubstitutionLevel, setVatCode, setVatCodeFixed, addChildValidation, removeChildValidation * */ /* SupplierChildValidation * \PhpTwinfield\SupplierChildValidation * Available getters: getElementValue, getLevel, getMessages, getResult, getType, hasMessages - * Available setters: setElementValue, setLevel, setType, setTypeFromString + * Available setters: setElementValue, setLevel, setType */ /* SupplierAddress * \PhpTwinfield\SupplierAddress - * Available getters: getCity, getCountry, getCountryToString, getDefault, getDefaultToString, getEmail, getField1, getField2, getField3, getField4, getField5, getField6, getID, getMessages, getName, getPostcode, getResult, getTelefax, getTelephone, getType, hasMessages - * Available setters: setCity, setCountry, setCountryFromString, setDefault, setDefaultFromString, setEmail, setField1, setField2, setField3, setField4, setField5, setField6, setID, setName, setPostcode, setTelefax, setTelephone, setType, setTypeFromString + * Available getters: getCity, getCountry, getDefault, getEmail, getField1, getField2, getField3, getField4, getField5, getField6, getID, getMessages, getName, getPostcode, getResult, getTelefax, getTelephone, getType, hasMessages + * Available setters: setCity, setCountry, setDefault, setEmail, setField1, setField2, setField3, setField4, setField5, setField6, setID, setName, setPostcode, setTelefax, setTelephone, setType */ /* SupplierBank * \PhpTwinfield\SupplierBank - * Available getters: getAccountNumber, getAddressField2, getAddressField3, getAscription, getBankName, getBicCode, getBlocked, getBlockedToString, getCity, getCountry, getCountryToString, getDefault, getDefaultToString, getID, getIban, getMessages, getNatBicCode, getPostcode, getResult, getState, hasMessages - * Available setters: setAccountNumber, setAddressField2, setAddressField3, setAscription, setBankName, setBicCode, setBlocked, setBlockedFromString, setCity, setCountry, setCountryFromString, setDefault, setDefaultFromString, setID, setIban, setNatBicCode, setPostcode, setState + * Available getters: getAccountNumber, getAddressField2, getAddressField3, getAscription, getBankName, getBicCode, getBlocked, getCity, getCountry, getDefault, getID, getIban, getMessages, getNatBicCode, getPostcode, getResult, getState, hasMessages + * Available setters: setAccountNumber, setAddressField2, setAddressField3, setAscription, setBankName, setBicCode, setBlocked, setCity, setCountry, setDefault, setID, setIban, setNatBicCode, setPostcode, setState */ /* SupplierPostingRule * \PhpTwinfield\SupplierPostingRule - * Available getters: getAmount, getAmountToFloat, getCurrency, getCurrencyToString, getDescription, getID, getMessages, getResult, getStatus, getLines, hasMessages - * Available setters: setAmount, setAmountFromFloat, setCurrency, setCurrencyFromString, setDescription, setID, setStatus, setStatusFromString, addLine, removeLine + * Available getters: getAmount, getCurrency, getDescription, getID, getMessages, getResult, getStatus, getLines, hasMessages + * Available setters: setAmount, setCurrency, setDescription, setID, setStatus, addLine, removeLine */ /* SupplierLine * \PhpTwinfield\SupplierLine - * Available getters: getDescription, getDimension1, getDimension1ID, getDimension1ToString, getDimension2, getDimension2ID, getDimension2ToString, getDimension3, getDimension3ID, getDimension3ToString, getMessages, getOffice, getOfficeToString, getRatio, getResult, getVatCode, getVatCodeToString, hasMessages - * Available setters: setDescription, setDimension1, setDimension1FromString, setDimension1ID, setDimension2, setDimension2FromString, setDimension2ID, setDimension3, setDimension3FromString, setDimension3ID, setOffice, setOfficeFromString, setRatio, setVatCode, setVatCodeFromString + * Available getters: getDescription, getDimension1, getDimension1ID, getDimension2, getDimension2ID, getDimension3, getDimension3ID, getMessages, getOffice, getRatio, getResult, getVatCode, hasMessages + * Available setters: setDescription, setDimension1, setDimension1ID, setDimension2, setDimension2ID, setDimension3, setDimension3ID, setOffice, setRatio, setVatCode */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { diff --git a/examples/UserRole.php b/examples/UserRole.php index 845be5c8..b067bfad 100644 --- a/examples/UserRole.php +++ b/examples/UserRole.php @@ -8,6 +8,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection diff --git a/examples/VatCode.php b/examples/VatCode.php index 3d2e4a80..8201fd1b 100644 --- a/examples/VatCode.php +++ b/examples/VatCode.php @@ -11,6 +11,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection @@ -89,20 +92,20 @@ /* VatCode * \PhpTwinfield\VatCode - * Available getters: getCode, getCreated, getCreatedToString, getMessages, getModified, getModifiedToString, getName, getOffice, getOfficeToString, getResult, getShortName, getStatus, getTouched, getType, getUID, getUser, getUserToString, hasMessages, getPercentages - * Available setters: setCode, setName, setOffice, setOfficeFromString, setShortName, setStatus, setStatusFromString, setType, setTypeFromString, addPercentage, removePercentage + * Available getters: getCode, getCreated, getMessages, getModified, getName, getOffice, getResult, getShortName, getStatus, getTouched, getType, getUID, getUser, hasMessages, getPercentages + * Available setters: setCode, setName, setOffice, setShortName, setStatus, setType, addPercentage, removePercentage */ /* VatCodePercentage * \PhpTwinfield\VatCodePercentage - * Available getters: getCreated, getCreatedToString, getDate, getDateToString, getMessages, getName, getPercentage, getResult, getShortName, getUser, getUserToString, hasMessages, getAccounts - * Available setters: setDate, setDateFromString, setName, setPercentage, setShortName, addAccount, removeAccount + * Available getters: getCreated, getDate, getMessages, getName, getPercentage, getResult, getShortName, getUser, hasMessages, getAccounts + * Available setters: setDate, setName, setPercentage, setShortName, addAccount, removeAccount */ /* VatCodeAccount * \PhpTwinfield\VatCodeAccount - * Available getters: getDim1, getDim1ToString, getGroup, getGroupCountry, getGroupCountryToString, getGroupToString, getID, getLineType, getMessages, getPercentage, getResult, hasMessages - * Available setters: setDim1, setDim1FromString, setGroup, setGroupCountry, setGroupCountryFromString, setGroupFromString, setID, setLineType, setLineTypeFromString, setPercentage + * Available getters: getDim1, getGroup, getGroupCountry, getID, getLineType, getMessages, getPercentage, getResult, hasMessages + * Available setters: setDim1, setGroup, setGroupCountry, setID, setLineType, setPercentage */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { @@ -128,17 +131,17 @@ echo "VatCode
"; echo "Code: {$vatCode->getCode()}
"; // string|null VAT code. echo "Created (\\DateTimeInterface):
" . print_r($vatCode->getCreated(), true) . "

"; // \DateTimeInterface|null The date/time the VAT code was created. Read-only attribute. - echo "Created (string): {$vatCode->getCreatedToString()}
"; // string|null + echo "Created (string): " . Util::formatDate($vatCode->getCreated()) . "
"; // string|null if ($vatCode->hasMessages()) { // bool Object contains (error) messages true/false. echo "Messages: " . print_r($vatCode->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "Modified (\\DateTimeInterface):
" . print_r($vatCode->getModified(), true) . "

"; // \DateTimeInterface|null The most recent date/time the VAT code was modified. Read-only attribute. - echo "Modified (string): {$vatCode->getModifiedToString()}
"; // string|null + echo "Modified (string): " . Util::formatDate($vatCode->getModified()) . "
"; // string|null echo "Name: {$vatCode->getName()}
"; // string|null Name of the VAT. echo "Office (\\PhpTwinfield\\Office):
" . print_r($vatCode->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): {$vatCode->getOfficeToString()}
"; // string|null + echo "Office (string): " . Util::objectToStr($vatCode->getOffice()) . "
"; // string|null echo "Result: {$vatCode->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "ShortName: {$vatCode->getShortName()}
"; // string|null Short name of the VAT. echo "Status: {$vatCode->getStatus()}
"; // Status|null Status of the VAT. @@ -146,7 +149,7 @@ echo "Type: {$vatCode->getType()}
"; // VatType|null The VAT type. echo "UID: {$vatCode->getUID()}
"; // string|null Unique identification of the VAT code. Read-only attribute. echo "User (\\PhpTwinfield\\User):
" . print_r($vatCode->getUser(), true) . "

"; // User|null The code of the user who created or modified the VAT code. Read-only attribute. - echo "User (string): {$vatCode->getUserToString()}
"; // string|null + echo "User (string): " . Util::objectToStr($vatCode->getUser()) . "
"; // string|null $vatCodePercentages = $vatCode->getPercentages(); // Array|null Array of VatCodePercentage objects. @@ -158,15 +161,15 @@ } echo "Created (\\DateTimeInterface):
" . print_r($vatCodePercentage->getCreated(), true) . "

"; // \DateTimeInterface|null The date/time the VAT line was created. Read-only attribute. - echo "Created (string): {$vatCodePercentage->getCreatedToString()}
"; // string|null + echo "Created (string): " . Util::formatDate($vatCodePercentage->getCreated()) . "
"; // string|null echo "Date (\\DateTimeInterface):
" . print_r($vatCodePercentage->getDate(), true) . "

"; // \DateTimeInterface|null Effective date. - echo "Date (string): {$vatCodePercentage->getDateToString()}
"; // string|null + echo "Date (string): " . Util::formatDate($vatCodePercentage->getDate()) . "
"; // string|null echo "Name: {$vatCodePercentage->getName()}
"; // string|null Name of the VAT line. echo "Percentage: {$vatCodePercentage->getPercentage()}
"; // float|null Percentage of the VAT line. echo "Result: {$vatCodePercentage->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "ShortName: {$vatCodePercentage->getShortName()}
"; // string|null Short name of the VAT line. echo "User (\\PhpTwinfield\\User):
" . print_r($vatCodePercentage->getUser(), true) . "

"; // User|null The code of the user who created or modified the VAT line. Read-only attribute. - echo "User (string): {$vatCodePercentage->getUserToString()}
"; // string|null + echo "User (string): " . Util::objectToStr($vatCodePercentage->getUser()) . "
"; // string|null $vatCodeAccounts = $vatCodePercentage->getAccounts(); // Array|null Array of VatCodeAccount objects. @@ -178,11 +181,11 @@ } echo "Dim1 (\\PhpTwinfield\\GeneralLedger):
" . print_r($vatCodeAccount->getDim1(), true) . "

"; // GeneralLedger|null General ledger account on which the VAT amount will be posted. - echo "Dim1 (string): {$vatCodeAccount->getDim1ToString()}
"; // string|null + echo "Dim1 (string): " . Util::objectToStr($vatCodeAccount->getDim1()) . "
"; // string|null echo "Group (\\PhpTwinfield\\VatGroup):
" . print_r($vatCodeAccount->getGroup(), true) . "

"; // VatGroup|null The VAT group. - echo "Group (string): {$vatCodeAccount->getGroupToString()}
"; // string|null + echo "Group (string): " . Util::objectToStr($vatCodeAccount->getGroup()) . "
"; // string|null echo "GroupCountry (\\PhpTwinfield\\VatGroupCountry):
" . print_r($vatCodeAccount->getGroupCountry(), true) . "

"; // VatGroupCountry|null Country code of the VAT group. - echo "GroupCountry (string): {$vatCodeAccount->getGroupCountryToString()}
"; // string|null + echo "GroupCountry (string): " . Util::objectToStr($vatCodeAccount->getGroupCountry()) . "
"; // string|null echo "ID: {$vatCodeAccount->getID()}
"; // int|null Line ID. echo "LineType: {$vatCodeAccount->getLineType()}
"; // LineType|null Is it a vat line or not detail. Use detail in case a part of the calculated vat value should be posted on a different general ledger account. echo "Percentage: {$vatCodeAccount->getPercentage()}
"; // float|null The VAT percentage. @@ -224,13 +227,10 @@ $vatCode->setCode('VH2'); // string|null VAT code. $vatCode->setName("BTW 21%"); // string|null Name of the VAT. $vatCode->setOffice($office); // Office|null Office code. - $vatCode->setOfficeFromString($officeCode); // string|null + $vatCode->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null $vatCode->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating active should be used. For deleting deleted should be used. //$vatCode->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null - $vatCode->setStatusFromString('active'); // string|null - //$vatCode->setStatusFromString('deleted'); // string|null $vatCode->setType(\PhpTwinfield\Enums\VatType::SALES()); // VatType|null - $vatCode->setTypeFromString('sales'); // string|null // Optional values for creating a new VatCode $vatCode->setShortName("VH 21%"); // string|null Short name of the VAT. @@ -239,7 +239,7 @@ $vatCodePercentage = new \PhpTwinfield\VatCodePercentage; $date = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); $vatCodePercentage->setDate($date); // DateTimeInterface|null Effective date. - $vatCodePercentage->setDateFromString('20190101'); // string|null + $vatCodePercentage->setDate(Util::parseDate('20190101')); // string|null $vatCodePercentage->setName("BTW 21%"); // string|null Name of the VAT line. $vatCodePercentage->setPercentage(21); // float|null Percentage of the VAT line. $vatCodePercentage->setShortName("VH 21%"); // string|null Short name of the VAT line. @@ -249,19 +249,18 @@ $generalLedger = new \PhpTwinfield\GeneralLedger; $generalLedger->setCode('1530'); $vatCodeAccount->setDim1($generalLedger); // GeneralLedger|null General ledger account on which the VAT amount will be posted. - $vatCodeAccount->setDim1FromString('1530'); // string|null + $vatCodeAccount->setDim1(\PhpTwinfield\GeneralLedger::fromCode('1530')); // string|null $vatGroup = new \PhpTwinfield\VatGroup; $vatGroup->setCode('NL1A'); $vatCodeAccount->setGroup($vatGroup); // VatGroup|null The VAT group. - $vatCodeAccount->setGroupFromString('NL1A'); // string|null + $vatCodeAccount->setGroup(\PhpTwinfield\VatGroup::fromCode('NL1A')); // string|null $vatGroupCountry = new \PhpTwinfield\VatGroupCountry; $vatGroupCountry->setCode('NL'); $vatCodeAccount->setGroupCountry($vatGroupCountry); // VatGroupCountry|null Country code of the VAT group. - $vatCodeAccount->setGroupCountryFromString('NL'); // string|null + $vatCodeAccount->setGroupCountry(\PhpTwinfield\VatGroupCountry::fromCode('NL')); // string|null $vatCodeAccount->setID(1); // int|null Line ID. $vatCodeAccount->setLineType(\PhpTwinfield\Enums\LineType::VAT()); // LineType|null Is it a vat line or not detail. Use detail in case a part of the calculated vat value should be posted on a different general ledger account. - $vatCodeAccount->setLineTypeFromString('vat'); // string|null $vatCodeAccount->setPercentage(100); // float|null Percentage of the VAT line. diff --git a/examples/VatGroup.php b/examples/VatGroup.php index 01cff0ee..ce02705e 100644 --- a/examples/VatGroup.php +++ b/examples/VatGroup.php @@ -8,6 +8,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection diff --git a/examples/VatGroupCountry.php b/examples/VatGroupCountry.php index e94dd500..77564d9d 100644 --- a/examples/VatGroupCountry.php +++ b/examples/VatGroupCountry.php @@ -8,6 +8,9 @@ // Use the ResponseException class to handle errors when listing, getting and sending objects to/from Twinfield use PhpTwinfield\Response\ResponseException; +// Use the Util class for helper functions +use PhpTwinfield\Util; + require_once('vendor/autoload.php'); // Retrieve an OAuth 2 connection diff --git a/tests/IntegrationTests/resources/bankTransactionGetResponse.xml b/tests/IntegrationTests/resources/bankTransactionGetResponse.xml index 4bfdb0c8..a4330f87 100644 --- a/tests/IntegrationTests/resources/bankTransactionGetResponse.xml +++ b/tests/IntegrationTests/resources/bankTransactionGetResponse.xml @@ -14,7 +14,7 @@
- 1001 + 1001 debit 435.55 1 @@ -24,8 +24,8 @@ notmatchable - 1300 - 1000 + 1300 + 1000 credit 435.55 11001770 diff --git a/tests/IntegrationTests/resources/cashTransactionGetResponse.xml b/tests/IntegrationTests/resources/cashTransactionGetResponse.xml index 232a3ed4..9cafc4e6 100644 --- a/tests/IntegrationTests/resources/cashTransactionGetResponse.xml +++ b/tests/IntegrationTests/resources/cashTransactionGetResponse.xml @@ -14,7 +14,7 @@
- 1002 + 1002 debit 435.55 1 @@ -24,8 +24,8 @@ notmatchable - 1300 - 1000 + 1300 + 1000 credit 435.55 11001770 diff --git a/tests/IntegrationTests/resources/journalTransactionGetResponse.xml b/tests/IntegrationTests/resources/journalTransactionGetResponse.xml index 4753b51e..da7d8c50 100644 --- a/tests/IntegrationTests/resources/journalTransactionGetResponse.xml +++ b/tests/IntegrationTests/resources/journalTransactionGetResponse.xml @@ -11,7 +11,7 @@ - 4008 + 4008 debit 435.55 1 @@ -22,8 +22,8 @@ notmatchable - 1300 - 1000 + 1300 + 1000 credit 435.55 11001770 diff --git a/tests/IntegrationTests/resources/purchaseTransactionGetResponse.xml b/tests/IntegrationTests/resources/purchaseTransactionGetResponse.xml index f74d8f34..6efec89f 100644 --- a/tests/IntegrationTests/resources/purchaseTransactionGetResponse.xml +++ b/tests/IntegrationTests/resources/purchaseTransactionGetResponse.xml @@ -14,8 +14,8 @@ - 1600 - 2000 + 1600 + 2000 121.00 credit @@ -33,7 +33,7 @@ available - 8020 + 8020 100.00 debit Outfit @@ -47,7 +47,7 @@ notmatchable - 1510 + 1510 21.00 IH debit diff --git a/tests/IntegrationTests/resources/salesTransactionGetResponse.xml b/tests/IntegrationTests/resources/salesTransactionGetResponse.xml index bc7202e1..3abebbd3 100644 --- a/tests/IntegrationTests/resources/salesTransactionGetResponse.xml +++ b/tests/IntegrationTests/resources/salesTransactionGetResponse.xml @@ -15,8 +15,8 @@ - 1300 - 1000 + 1300 + 1000 121.00 debit @@ -34,7 +34,7 @@ available - 8020 + 8020 100.00 credit Outfit @@ -49,7 +49,7 @@ notmatchable - 1530 + 1530 21.00 VH credit From cf5d63cb727e6717ee02a85aa3bdfb1483dc5376 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 18:08:47 +0200 Subject: [PATCH 351/388] Upload --- examples/Office.php | 48 ++++++++++--------- src/Mappers/ArticleMapper.php | 4 +- src/Mappers/CustomerMapper.php | 8 ++-- src/Mappers/FixedAssetMapper.php | 4 +- src/Mappers/TransactionMapper.php | 4 +- .../TransactionApiConnectorTest.php | 12 ++--- 6 files changed, 45 insertions(+), 35 deletions(-) diff --git a/examples/Office.php b/examples/Office.php index ff2fc493..d4209a95 100644 --- a/examples/Office.php +++ b/examples/Office.php @@ -106,8 +106,8 @@ /* Office * \PhpTwinfield\Office - * Available getters: __toString, getCode, getCountryCode, getCreated, getMessages, getModified, getName, getResult, getShortName, getStatus, getTouched, getUser, getVatFirstQuarterStartsIn, getVatPeriod, hasMessages - * Available setters: fromCode, setCode, setCountryCode, setName, setShortName, setStatus, setVatFirstQuarterStartsIn,setVatPeriod + * Available getters: __toString, getBaseCurrency, getCode, getCountryCode, getCreated, getMessages, getModified, getName, getReportingCurrency, getResult, getShortName, getStatus, getTouched, getUser, getVatFirstQuarterStartsIn, getVatPeriod, hasMessages + * Available setters: fromCode, setBaseCurrency, setCode, setCountryCode, setName, setReportingCurrency, setShortName, setStatus, setVatFirstQuarterStartsIn,setVatPeriod */ if ($executeListAllWithoutOfficeCode || $executeListAllWithFilter || $executeListAllWithoutFilter) { @@ -135,26 +135,30 @@ echo "
"; echo "Office
"; - echo "Code: {$office}
"; // string|null - echo "Code: {$office->getCode()}
"; // string|null - //echo "CountryCode (\\PhpTwinfield\\Country):
" . print_r($office->getCountryCode(), true) . "

"; // Country|null - //echo "CountryCode (string): " . Util::objectToStr($office->getCountryCode()) . "
"; // string|null - echo "Created (\\DateTimeInterface):
" . print_r($office->getCreated(), true) . "

"; // DateTimeInterface|null The date/time the office was created. - echo "Created (string): " . Util::parseDateTime($office->getCreatedToString()) . "
"; // string|null - - if ($office->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($office->getMessages(), true) . "
"; // Array|null (Error) messages. + echo "BaseCurrency (\\PhpTwinfield\\Currency):
" . print_r($office->getBaseCurrency(), true) . "

"; // Currency|null The base currency + echo "BaseCurrency (string): " . Util::objectToStr($office->getBaseCurrency()) . "
"; // string|null + echo "Code: {$office}
"; // string|null + echo "Code: {$office->getCode()}
"; // string|null + //echo "CountryCode (\\PhpTwinfield\\Country):
" . print_r($office->getCountryCode(), true) . "

"; // Country|null + //echo "CountryCode (string): " . Util::objectToStr($office->getCountryCode()) . "
"; // string|null + echo "Created (\\DateTimeInterface):
" . print_r($office->getCreated(), true) . "

"; // DateTimeInterface|null The date/time the office was created. + echo "Created (string): " . Util::parseDateTime($office->getCreatedToString()) . "
"; // string|null + + if ($office->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($office->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Modified (\\DateTimeInterface):
" . print_r($office->getModified(), true) . "

"; // DateTimeInterface|null The date/time the office was modified. - echo "Modified (string): " . Util::parseDateTime($office->getModified()) . "
"; // string|null - echo "Name: {$office->getName()}
"; // string|null - echo "Result: {$office->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "ShortName: {$office->getShortName()}
"; // string|null - echo "Status: {$office->getStatus()}
"; // Status|null - echo "Touched: {$office->getTouched()}
"; // int|null The number of times the office is modified. - echo "User (\\PhpTwinfield\\User):
" . print_r($office->getUser(), true) . "

"; // User|null The code of the user who created or modified the Office. - echo "User (string): " . Util::objectToStr($office->getUser()) . "
"; // string|null - //echo "VatFirstQuarterStartsIn: {$office->getVatFirstQuarterStartsIn()}
"; // string|null - //echo "VatPeriod: {$office->getVatPeriod()}
"; // string|null + echo "Modified (\\DateTimeInterface):
" . print_r($office->getModified(), true) . "

"; // DateTimeInterface|null The date/time the office was modified. + echo "Modified (string): " . Util::parseDateTime($office->getModified()) . "
"; // string|null + echo "Name: {$office->getName()}
"; // string|null + echo "ReportingCurrency (\\PhpTwinfield\\Currency):
" . print_r($office->getReportingCurrency(), true) . "

"; // Currency|null The reporting currency + echo "ReportingCurrency (string): " . Util::objectToStr($office->getReportingCurrency()) . "
"; // string|null + echo "Result: {$office->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$office->getShortName()}
"; // string|null + echo "Status: {$office->getStatus()}
"; // Status|null + echo "Touched: {$office->getTouched()}
"; // int|null The number of times the office is modified. + echo "User (\\PhpTwinfield\\User):
" . print_r($office->getUser(), true) . "

"; // User|null The code of the user who created or modified the Office. + echo "User (string): " . Util::objectToStr($office->getUser()) . "
"; // string|null + //echo "VatFirstQuarterStartsIn: {$office->getVatFirstQuarterStartsIn()}
"; // string|null + //echo "VatPeriod: {$office->getVatPeriod()}
"; // string|null } \ No newline at end of file diff --git a/src/Mappers/ArticleMapper.php b/src/Mappers/ArticleMapper.php index d96782c7..993a2490 100644 --- a/src/Mappers/ArticleMapper.php +++ b/src/Mappers/ArticleMapper.php @@ -64,7 +64,9 @@ public static function map(Response $response, AuthenticatedConnection $connecti ->setUnitNamePlural(self::getField($headerElement, 'unitnameplural', $article)) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $article, $headerElement, 'vatcode')); - $currencies = self::getOfficeCurrencies($connection, $article->getOffice()); + if ($article->getOffice() !== null) + $currencies = self::getOfficeCurrencies($connection, $article->getOffice()); + ) // Get the lines element $linesDOMTag = $responseDOM->getElementsByTagName('lines'); diff --git a/src/Mappers/CustomerMapper.php b/src/Mappers/CustomerMapper.php index f2361e39..4ed345d9 100644 --- a/src/Mappers/CustomerMapper.php +++ b/src/Mappers/CustomerMapper.php @@ -64,8 +64,10 @@ public static function map(Response $response, AuthenticatedConnection $connecti ->setType(self::parseObjectAttribute(\PhpTwinfield\DimensionType::class, $customer, $customerElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setUID(self::getField($customerElement, 'uid', $customer)) ->setWebsite(self::getField($customerElement, 'website', $customer)); - - $currencies = self::getOfficeCurrencies($connection, $customer->getOffice()); + + if ($customer->getOffice() !== null) + $currencies = self::getOfficeCurrencies($connection, $customer->getOffice()); + ) // Set the customer elements from the customer element attributes $customer->setDiscountArticleID(self::getAttribute($customerElement, 'discountarticle', 'id')); @@ -283,7 +285,7 @@ public static function map(Response $response, AuthenticatedConnection $connecti // Set the postingrule elements from the postingrule element $customerPostingRule->setCurrency(self::parseObjectAttribute(\PhpTwinfield\Currency::class, $customerPostingRule, $postingruleElement, 'currency', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setDescription(self::getField($postingruleElement, 'description', $customerPostingRule)); - + $customerPostingRule->setAmount(self::parseMoneyAttribute(self::getField($postingruleElement, 'amount', $customerPostingRule), Util::objectToStr($customerPostingRule->getCurrency()))); // Get the lines element diff --git a/src/Mappers/FixedAssetMapper.php b/src/Mappers/FixedAssetMapper.php index d73fe0e2..6503f401 100644 --- a/src/Mappers/FixedAssetMapper.php +++ b/src/Mappers/FixedAssetMapper.php @@ -54,7 +54,9 @@ public static function map(Response $response, AuthenticatedConnection $connecti ->setType(self::parseObjectAttribute(\PhpTwinfield\DimensionType::class, $fixedAsset, $fixedAssetElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setUID(self::getField($fixedAssetElement, 'uid', $fixedAsset)); - $currencies = self::getOfficeCurrencies($connection, $fixedAsset->getOffice()); + if ($fixedAsset->getOffice() !== null) + $currencies = self::getOfficeCurrencies($connection, $fixedAsset->getOffice()); + ) // Get the financials element $financialsElement = $responseDOM->getElementsByTagName('financials')->item(0); diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index f8f80d6a..f9b254f2 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -98,7 +98,9 @@ public static function map(string $transactionClassName, Response $response, Aut ->setNumber(self::getField($transactionElement, 'number', $transaction)) ->setPeriod(self::getField($transactionElement, 'period', $transaction)); - $currencies = self::getOfficeCurrencies($connection, $transaction->getOffice()); + if ($transaction->getOffice() !== null) + $currencies = self::getOfficeCurrencies($connection, $transaction->getOffice()); + ) if (Util::objectUses(CloseAndStartValueFields::class, $transaction)) { $transaction->setStartValue(self::parseMoneyAttribute(self::getField($transactionElement, 'startvalue', $transaction), Util::objectToStr($transaction->getCurrency()))); diff --git a/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php b/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php index 8f485aea..f308a83a 100644 --- a/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php @@ -48,9 +48,9 @@ protected function setUp() ->willReturn($this->processXmlService); $this->apiConnector = new TransactionApiConnector($connection); - + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); - $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { + $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { $office = new Office; $office->setResult(1); $office->setBaseCurrency(Currency::fromCode('EUR')); @@ -90,9 +90,9 @@ public function testSendReturnsMappedObjects() - 130000 + 130000 - Dxxxx + Dxxxx debit 100.00 @@ -110,9 +110,7 @@ public function testSendReturnsMappedObjects() available - 191000 - + 191000 credit 100.00 Outfit From 4fdc64ca379c30fc26f88ef7f12684f06ed4e4a0 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 18:11:14 +0200 Subject: [PATCH 352/388] Upload --- src/Mappers/ArticleMapper.php | 4 ++-- src/Mappers/CustomerMapper.php | 4 ++-- src/Mappers/FixedAssetMapper.php | 4 ++-- src/Mappers/TransactionMapper.php | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Mappers/ArticleMapper.php b/src/Mappers/ArticleMapper.php index 993a2490..f46697ef 100644 --- a/src/Mappers/ArticleMapper.php +++ b/src/Mappers/ArticleMapper.php @@ -64,9 +64,9 @@ public static function map(Response $response, AuthenticatedConnection $connecti ->setUnitNamePlural(self::getField($headerElement, 'unitnameplural', $article)) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $article, $headerElement, 'vatcode')); - if ($article->getOffice() !== null) + if ($article->getOffice() !== null) { $currencies = self::getOfficeCurrencies($connection, $article->getOffice()); - ) + } // Get the lines element $linesDOMTag = $responseDOM->getElementsByTagName('lines'); diff --git a/src/Mappers/CustomerMapper.php b/src/Mappers/CustomerMapper.php index 4ed345d9..3ec8bdfe 100644 --- a/src/Mappers/CustomerMapper.php +++ b/src/Mappers/CustomerMapper.php @@ -65,9 +65,9 @@ public static function map(Response $response, AuthenticatedConnection $connecti ->setUID(self::getField($customerElement, 'uid', $customer)) ->setWebsite(self::getField($customerElement, 'website', $customer)); - if ($customer->getOffice() !== null) + if ($customer->getOffice() !== null) { $currencies = self::getOfficeCurrencies($connection, $customer->getOffice()); - ) + } // Set the customer elements from the customer element attributes $customer->setDiscountArticleID(self::getAttribute($customerElement, 'discountarticle', 'id')); diff --git a/src/Mappers/FixedAssetMapper.php b/src/Mappers/FixedAssetMapper.php index 6503f401..d6c50a41 100644 --- a/src/Mappers/FixedAssetMapper.php +++ b/src/Mappers/FixedAssetMapper.php @@ -54,9 +54,9 @@ public static function map(Response $response, AuthenticatedConnection $connecti ->setType(self::parseObjectAttribute(\PhpTwinfield\DimensionType::class, $fixedAsset, $fixedAssetElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setUID(self::getField($fixedAssetElement, 'uid', $fixedAsset)); - if ($fixedAsset->getOffice() !== null) + if ($fixedAsset->getOffice() !== null) { $currencies = self::getOfficeCurrencies($connection, $fixedAsset->getOffice()); - ) + } // Get the financials element $financialsElement = $responseDOM->getElementsByTagName('financials')->item(0); diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index f9b254f2..d7e54b9f 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -98,9 +98,9 @@ public static function map(string $transactionClassName, Response $response, Aut ->setNumber(self::getField($transactionElement, 'number', $transaction)) ->setPeriod(self::getField($transactionElement, 'period', $transaction)); - if ($transaction->getOffice() !== null) + if ($transaction->getOffice() !== null) { $currencies = self::getOfficeCurrencies($connection, $transaction->getOffice()); - ) + } if (Util::objectUses(CloseAndStartValueFields::class, $transaction)) { $transaction->setStartValue(self::parseMoneyAttribute(self::getField($transactionElement, 'startvalue', $transaction), Util::objectToStr($transaction->getCurrency()))); From 1968e560d30fa6c64ed9b5b7b6cc9eb23887b407 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 20:53:15 +0200 Subject: [PATCH 353/388] Upload --- examples/Activity.php | 66 +++++++++-------- examples/Article.php | 20 +++--- examples/CostCenter.php | 2 +- examples/Customer.php | 125 ++++++++++++++------------------- examples/DimensionGroup.php | 6 +- examples/GeneralLedger.php | 34 +++++---- examples/Invoice.php | 60 ++++++++-------- examples/Office.php | 4 +- examples/Project.php | 120 ++++++++++++++----------------- examples/Supplier.php | 88 ++++++++++------------- src/Mappers/CustomerMapper.php | 2 +- src/Mappers/SupplierMapper.php | 2 +- 12 files changed, 244 insertions(+), 285 deletions(-) diff --git a/examples/Activity.php b/examples/Activity.php index 72a51535..f2252058 100644 --- a/examples/Activity.php +++ b/examples/Activity.php @@ -146,7 +146,7 @@ echo "Behaviour: {$activity->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. echo "Code: {$activity->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the ACT Dimension type. echo "InUse (bool): {$activity->getInUse()}
"; // bool|null Indicates whether the activity is used in a transaction or not. Read-only attribute. - echo "InUse (string): {$activity->getInUseToString()}
"; // string|null + echo "InUse (string): " . Util::formatBoolean($activity->getInUse()) . "
"; // string|null if ($activity->hasMessages()) { // bool Object contains (error) messages true/false. echo "Messages: " . print_r($activity->getMessages(), true) . "
"; // Array|null (Error) messages. @@ -154,39 +154,39 @@ echo "Name: {$activity->getName()}
"; // string|null Activity description. echo "Office (\\PhpTwinfield\\Office):
" . print_r($activity->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): {$activity->getOfficeToString()}
"; // string|null + echo "Office (string): " . Util::objectToStr($activity->getOffice()) . "
"; // string|null echo "Result: {$activity->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "ShortName: {$activity->getShortName()}
"; // string|null Short activity description. echo "Status: {$activity->getStatus()}
"; // Status|null Status of the activity. echo "Touched: {$activity->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($activity->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of activities is ACT. - echo "Type (string): {$activity->getTypeToString()}
"; // string|null + echo "Type (string): " . Util::objectToStr($activity->getType()) . "
"; // string|null echo "UID: {$activity->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($activity->getVatCode(), true) . "

"; // VatCode|null The VAT code if one code will apply for all activities within the project. Note that if any VAT codes are - echo "VatCode (string): {$activity->getVatCodeToString()}
"; // string|null defined on activity level, these will apply regardless of what is defined on project level. + echo "VatCode (string): " . Util::objectToStr($activity->getVatCode()) . "
"; // string|null defined on activity level, these will apply regardless of what is defined on project level. $activityProjects = $activity->getProjects(); // ActivityProjects|null ActivityProjects object. echo "Authoriser (\\PhpTwinfield\\User):
" . print_r($activityProjects->getAuthoriser(), true) . "

"; // User|null A specific authoriser for an activity. - echo "Authoriser (string): {$activityProjects->getAuthoriserToString()}
"; // string|null If "change" = allow then locked = false and inherit = false + echo "Authoriser (string): " . Util::objectToStr($activityProjects->getAuthoriser()) . "
"; // string|null If "change" = allow then locked = false and inherit = false echo "Authoriser Inherit (bool): {$activityProjects->getAuthoriserInherit()}
"; // bool|null - echo "Authoriser Inherit (string): {$activityProjects->getAuthoriserInheritToString()}
"; // string|null If "change" = disallow then locked = true and inherit = false + echo "Authoriser Inherit (string): " . Util::formatBoolean($activityProjects->getAuthoriserInherit()) . "
"; // string|null If "change" = disallow then locked = true and inherit = false echo "Authoriser Locked (bool): {$activityProjects->getAuthoriserLocked()}
"; // bool|null - echo "Authoriser Locked (string): {$activityProjects->getAuthoriserLockedToString()}
"; // string|null If "change" = inherit then locked = true and inherit = true + echo "Authoriser Locked (string): " . Util::formatBoolean($activityProjects->getAuthoriserLocked()) . "
"; // string|null If "change" = inherit then locked = true and inherit = true echo "Billable (bool): {$activityProjects->getBillable()}
"; // bool|null Choose to make an activity billable (true) or not (false) and whether or not it should be included when calculating the "productivity" ratio (@forratio). - echo "Billable (string): {$activityProjects->getBillableToString()}
"; // string|null You could also decide that these settings should be inherited from project or user level (@inherit). + echo "Billable (string): " . Util::formatBoolean($activityProjects->getBillable()) . "
"; // string|null You could also decide that these settings should be inherited from project or user level (@inherit). echo "Billable ForRatio (bool): {$activityProjects->getBillableForRatio()}
"; // bool|null You can also set whether a change of these settings is allowed or disallowed when a user is entering their timesheet (@locked). - echo "Billable ForRatio (string): {$activityProjects->getBillableForRatioToString()}
"; // string|null If "change" = allow then locked = false and inherit = false. + echo "Billable ForRatio (string): " . Util::formatBoolean($activityProjects->getBillableForRatio()) . "
"; // string|null If "change" = allow then locked = false and inherit = false. echo "Billable Inherit (bool): {$activityProjects->getBillableInherit()}
"; // bool|null - echo "Billable Inherit (string): {$activityProjects->getBillableInheritToString()}
"; // string|null If "change" = disallow then locked = true and inherit = false. + echo "Billable Inherit (string): " . Util::formatBoolean($activityProjects->getBillableInherit()) . "
"; // string|null If "change" = disallow then locked = true and inherit = false. echo "Billable Locked (bool): {$activityProjects->getBillableLocked()}
"; // bool|null - echo "Billable Locked (string): {$activityProjects->getBillableLockedToString()}
"; // string|null If "change" = inherit then locked = true and inherit = true + echo "Billable Locked (string): " . Util::formatBoolean($activityProjects->getBillableLocked()) . "
"; // string|null If "change" = inherit then locked = true and inherit = true echo "Customer (\\PhpTwinfield\\Customer):
" . print_r($activityProjects->getCustomer(), true) . "

"; // Customer|null An activity always needs to be linked to a customer. - echo "Customer (string): {$activityProjects->getCustomerToString()}
"; // string|null Choose to have the customer ‘inherited’ (from a project) or you can specify the customer here. + echo "Customer (string): " . Util::objectToStr($activityProjects->getCustomer()) . "
"; // string|null Choose to have the customer ‘inherited’ (from a project) or you can specify the customer here. echo "Customer Inherit (bool): {$activityProjects->getCustomerInherit()}
"; // bool|null - echo "Customer Inherit (string): {$activityProjects->getCustomerInheritToString()}
"; // string|null If "change" = allow then locked = false and inherit = false + echo "Customer Inherit (string): " . Util::formatBoolean($activityProjects->getCustomerInherit()) . "
"; // string|null If "change" = allow then locked = false and inherit = false echo "Customer Locked (bool): {$activityProjects->getCustomerLocked()}
"; // bool|null If "change" = disallow then locked = true and inherit = false - echo "Customer Locked (string): {$activityProjects->getCustomerLockedToString()}
"; // string|null If "change" = inherit then locked = true and inherit = true + echo "Customer Locked (string): " . Util::formatBoolean($activityProjects->getCustomerLocked()) . "
"; // string|null If "change" = inherit then locked = true and inherit = true echo "Invoice Description: {$activityProjects->getInvoiceDescription()}
"; // string|null This field can be used to enter a longer activity description which will be available on the invoice template. if ($activityProjects->hasMessages()) { // bool Object contains (error) messages true/false. @@ -194,16 +194,16 @@ } echo "Rate (\\PhpTwinfield\\Rate):
" . print_r($activityProjects->getRate(), true) . "

"; // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). - echo "Rate (string): {$activityProjects->getRateToString()}
"; // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). + echo "Rate (string): " . Util::objectToStr($activityProjects->getRate()) . "
"; // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). echo "Rate Inherit (bool): {$activityProjects->getRateInherit()}
"; // bool|null - echo "Rate Inherit (string): {$activityProjects->getRateInheritToString()}
"; // string|null If "change" = allow then locked = false and inherit = false + echo "Rate Inherit (string): " . Util::formatBoolean($activityProjects->getRateInherit()) . "
"; // string|null If "change" = allow then locked = false and inherit = false echo "Rate Locked (bool): {$activityProjects->getRateLocked()}
"; // bool|null If "change" = disallow then locked = true and inherit = false - echo "Rate Locked (string): {$activityProjects->getRateLockedToString()}
"; // string|null If "change" = inherit then locked = true and inherit = true + echo "Rate Locked (string): " . Util::formatBoolean($activityProjects->getRateLocked()) . "
"; // string|null If "change" = inherit then locked = true and inherit = true echo "Result: {$activityProjects->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "Valid From (\\DateTimeInterface):
" . print_r($activityProjects->getValidFrom(), true) . "

"; // DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. - echo "Valid From (string): {$activityProjects->getValidFromToString()}
"; // string|null + echo "Valid From (string): " . Util::formatDate($activityProjects->getValidFrom()) . "
"; // string|null echo "Valid Till (\\DateTimeInterface):
" . print_r($activityProjects->getValidTill(), true) . "

"; // DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. - echo "Valid Till (string): {$activityProjects->getValidTillToString()}
"; // string|null + echo "Valid Till (string): " . Util::formatDate($activityProjects->getValidTill()) . "
"; // string|null $activityQuantities = $activityProjects->getQuantities(); // array|null Array of ActivityQuantity objects. @@ -211,9 +211,9 @@ echo "ActivityQuantity {$key}
"; echo "Billable (bool): {$activityQuantity->getBillable()}
"; // bool|null Is the quantity line billable or not. - echo "Billable (string): {$activityQuantity->getBillableToString()}
"; // string|null If "billable" = true and "change is not allowed" then locked = true + echo "Billable (string): " . Util::formatBoolean($activityQuantity->getBillable()) . "
"; // string|null If "billable" = true and "change is not allowed" then locked = true echo "Billable Locked (bool): {$activityQuantity->getBillableLocked()}
"; // bool|null If "billable" = true and "change is allowed" then locked = false - echo "Billable Locked (string): {$activityQuantity->getBillableLockedToString()}
"; // string|null + echo "Billable Locked (string): " . Util::formatBoolean($activityQuantity->getBillableLocked()) . "
"; // string|null if ($activityQuantity->hasMessages()) { // bool Object contains (error) messages true/false. echo "Messages: " . print_r($activityQuantity->getMessages(), true) . "
"; // Array|null (Error) messages. @@ -221,9 +221,9 @@ echo "Label: {$activityQuantity->getLabel()}
"; // string|null The label of the quantity. echo "Mandatory (bool): {$activityQuantity->getMandatory()}
"; // bool|null Is the quantity line mandatory or not. - echo "Mandatory (string): {$activityQuantity->getMandatoryToString()}
"; // string|null + echo "Mandatory (string): " . Util::formatBoolean($activityQuantity->getMandatory()) . "
"; // string|null echo "Rate (\\PhpTwinfield\\Rate):
" . print_r($activityQuantity->getRate(), true) . "

"; // Rate|null The rate. - echo "Rate (string): {$activityQuantity->getRateToString()}
"; // string|null + echo "Rate (string): " . Util::objectToStr($activityQuantity->getRate()) . "
"; // string|null echo "Result: {$activityQuantity->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). } } @@ -262,25 +262,23 @@ //$activity->setCode('A100'); // string|null Dimension code, must be compliant with the mask of the ACT Dimension type. $activity->setName("Example Activity"); // string|null Activity description. $activity->setOffice($office); // Office|null Office code. - $activity->setOfficeFromString($officeCode); // string|null + $activity->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null // Optional values for creating a new Activity $activity->setShortName("ExmplAct"); // string|null Short activity description. //$activity->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. //$activity->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case an activity is in use, its status has been changed into hide. Hidden activities can be activated by using active. - //$activity->setStatusFromString('active'); // string|null - //$activity->setStatusFromString('deleted'); // string|null $vatCode = new \PhpTwinfield\VatCode; $vatCode->setCode('VH'); $activity->setVatCode($vatCode); // VatCode|null The VAT code if one code will apply for all activities within the project. Note that if any VAT codes are - $activity->setVatCodeFromString('VH'); // string|null defined on activity level, these will apply regardless of what is defined on project level. + $activity->setVatCode(\PhpTwinfield\VatCode::fromCode('VH')); // string|null defined on activity level, these will apply regardless of what is defined on project level. $activityProjects = new \PhpTwinfield\ActivityProjects; $authoriser = new \PhpTwinfield\User; $authoriser->setCode('TWINAPPS'); $activityProjects->setAuthoriser($authoriser); // User|null A specific authoriser for an activity. - $activityProjects->setAuthoriserFromString('TWINAPPS'); // string|null If "change" = allow then locked = false and inherit = false + $activityProjects->setAuthoriser(\PhpTwinfield\User::fromCode('TWINAPPS')); // string|null If "change" = allow then locked = false and inherit = false $activityProjects->setAuthoriserInherit(false); // bool|null $activityProjects->setAuthoriserLocked(false); // bool|null $activityProjects->setBillable(false); // bool|null Choose to make an activity billable (true) or not (false) and whether or not it should be included when calculating the "productivity" ratio (@forratio). @@ -290,22 +288,22 @@ $customer = new \PhpTwinfield\Customer; $customer->setCode('1000'); //$activityProjects->setCustomer($customer); // Customer|null An activity always needs to be linked to a customer. - //$activityProjects->setCustomerFromString('1000'); // string|null Choose to have the customer ‘inherited’ (from a project) or you can specify the customer here. + //$activityProjects->setCustomer(\PhpTwinfield\Customer::fromCode('1000')); // string|null Choose to have the customer ‘inherited’ (from a project) or you can specify the customer here. $activityProjects->setCustomerInherit(true); // bool|null $activityProjects->setCustomerLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false $activityProjects->setInvoiceDescription('Example Invoice Description'); // string|null This field can be used to enter a longer activity description which will be available on the invoice template. $rate = new \PhpTwinfield\Rate; $rate->setCode('DIRECT'); $activityProjects->setRate($rate); // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). - $activityProjects->setRateFromString('DIRECT'); // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). + $activityProjects->setRate(\PhpTwinfield\Rate::fromCode('DIRECT')); // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). $activityProjects->setRateInherit(false); // bool|null $activityProjects->setRateLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false $validFrom = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); $activityProjects->setValidFrom($validFrom); // DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. - $activityProjects->setValidFromFromString('20190101'); // string|null + $activityProjects->setValidFrom(Util::parseDate('20190101')); // string|null $validTill = \DateTime::createFromFormat('d-m-Y', '31-12-2019'); $activityProjects->setValidTill($validTill); // DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. - $activityProjects->setValidTillFromString('20191231'); // string|null + $activityProjects->setValidTill(Util::parseDate('20191231')); // string|null // The minimum amount of ActivityQuantities linked to a ActivityProjects object is 0, the maximum amount is 4 $activityQuantity = new \PhpTwinfield\ActivityQuantity; @@ -316,7 +314,7 @@ $rate = new \PhpTwinfield\Rate; $rate->setCode('KILOMETERS'); $activityQuantity->setRate($rate); // Rate|null The rate. - $activityQuantity->setRateFromString('KILOMETERS'); // string|null + $activityQuantity->setRate(\PhpTwinfield\Rate::fromCode('KILOMETERS')); // string|null $activityProjects->addQuantity($activityQuantity); // ActivityQuantity Add an ActivityQuantity object to the ActivityProjects object //$activityProjects->removeQuantity(0); // int Remove a quantity based on the index of the quantity within the array @@ -337,7 +335,7 @@ echo "Code of new Activity: {$activityNew->getCode()}
"; } -// Delete a Activity based off the passed in code and optionally the office. +// Delete an Activity based off the passed in code and optionally the office. if ($executeDelete) { try { $activityDeleted = $activityApiConnector->delete("A100", $office); diff --git a/examples/Article.php b/examples/Article.php index bc21631f..04c4c51f 100644 --- a/examples/Article.php +++ b/examples/Article.php @@ -129,15 +129,15 @@ echo "Article
"; echo "AllowChangePerformanceType (bool): {$article->getAllowChangePerformanceType()}
"; // bool|null Is it allowed to change the performance type. - echo "AllowChangePerformanceType (string): " . Util::formatBoolean($article->getAllowChangePerformanceTypeToString()) . "
"; // string|null + echo "AllowChangePerformanceType (string): " . Util::formatBoolean($article->getAllowChangePerformanceType()) . "
"; // string|null echo "AllowChangeUnitsPrice (bool): {$article->getAllowChangeUnitsPrice()}
"; // bool|null Is it allowed to change the units price. - echo "AllowChangeUnitsPrice (string): " . Util::formatBoolean($article->getAllowChangeUnitsPriceToString()) . "
"; // string|null + echo "AllowChangeUnitsPrice (string): " . Util::formatBoolean($article->getAllowChangeUnitsPrice()) . "
"; // string|null echo "AllowChangeVatCode (bool): {$article->getAllowChangeVatCode()}
"; // bool|null Is it allowed to change the VAT. - echo "AllowChangeVatCode (string): " . Util::formatBoolean($article->getAllowChangeVatCodeToString()) . "
"; // string|null + echo "AllowChangeVatCode (string): " . Util::formatBoolean($article->getAllowChangeVatCode()) . "
"; // string|null echo "AllowDecimalQuantity (bool): {$article->getAllowDecimalQuantity()}
"; // bool|null Are decimals allowed. - echo "AllowDecimalQuantity (string): " . Util::formatBoolean($article->getAllowDecimalQuantityToString()) . "
"; // string|null + echo "AllowDecimalQuantity (string): " . Util::formatBoolean($article->getAllowDecimalQuantity()) . "
"; // string|null echo "AllowDiscountOrPremium (bool): {$article->getAllowDiscountOrPremium()}
"; // bool|null Is discount or premium allowed. - echo "AllowDiscountOrPremium (string): " . Util::formatBoolean($article->getAllowDiscountOrPremiumToString()) . "
"; // string|null + echo "AllowDiscountOrPremium (string): " . Util::formatBoolean($article->getAllowDiscountOrPremium()) . "
"; // string|null echo "Code: {$article->getCode()}
"; // string|null Article code. if ($article->hasMessages()) { // bool Object contains (error) messages true/false. @@ -146,9 +146,9 @@ echo "Name: {$article->getName()}
"; // string|null Article description. echo "Office (\\PhpTwinfield\\Office):
" . print_r($article->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): {$article->getOfficeToString()}
"; // string|null + echo "Office (string): " . Util::objectToStr($article->getOffice()) . "
"; // string|null echo "Percentage (bool): {$article->getPercentage()}
"; // bool|null Only available when article type is discount or premium. - echo "Percentage (string): " . Util::formatBoolean($article->getPercentageToString()) . "
"; // string|null + echo "Percentage (string): " . Util::formatBoolean($article->getPercentage()) . "
"; // string|null echo "PerformanceType: {$article->getPerformanceType()}
"; // PerformanceType|null The performance type. echo "Result: {$article->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "ShortName: {$article->getShortName()}
"; // string|null Short article description. @@ -157,7 +157,7 @@ echo "UnitNamePlural: {$article->getUnitNamePlural()}
"; // string|null Unit name for multiple items. echo "UnitNameSingular: {$article->getUnitNameSingular()}
"; // string|null Unit name for a single item. echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($article->getVatCode(), true) . "

"; // VatCode|null Default VAT code. - echo "VatCode (string): " . Util::objectToStr($article->getVatCodeToString()) . "
"; // string|null + echo "VatCode (string): " . Util::objectToStr($article->getVatCode()) . "
"; // string|null $articleLines = $article->getLines(); // array|null Array of ArticleLine objects. @@ -222,7 +222,7 @@ $article->setCode('9061'); // string|null Article code. $article->setName("Example Article"); // string|null Article description. $article->setOffice($office); // Office|null Office code. - $article->setOfficeFromString(\PhpTwinfield\Office::fromCode($officeCode)); // string|null + $article->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null $article->setUnitNamePlural("Example Art Units"); // string|null Unit name for multiple items $article->setUnitNameSingular("Example Art Unit"); // string|null Unit name for a single item @@ -232,7 +232,7 @@ $article->setAllowChangeVatCode(true); // bool|null Is it allowed to change the VAT. $article->setAllowDecimalQuantity(true); // bool|null Are decimals allowed. $article->setAllowDiscountOrPremium(true); // bool|null Is discount or premium allowed. - //$article->setPercentage(true); // bool|null Only available when article type is discount or premium + $article->setPercentage(false); // bool|null Only available when article type is discount or premium $article->setPerformanceType(\PhpTwinfield\Enums\PerformanceType::SERVICES()); // PerformanceType|null The performance type. $article->setShortName("ExmplArt"); // string|null Short article description. //$article->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. diff --git a/examples/CostCenter.php b/examples/CostCenter.php index 96e5852f..d85781c5 100644 --- a/examples/CostCenter.php +++ b/examples/CostCenter.php @@ -179,7 +179,7 @@ $costCenter->setCode(null); // string|null Set to null to let Twinfield assign a Dimension code based on the Dimension type mask //$costCenter->setCode('00020'); // string|null Dimension code, must be compliant with the mask of the KPL Dimension type. $costCenter->setOffice($office); // Office|null Office. - $costCenter->setOfficeFromString($officeCode); // string|null + $costCenter->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null // Optional values for creating a new CostCenter $costCenter->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. diff --git a/examples/Customer.php b/examples/Customer.php index 00504693..952b472a 100644 --- a/examples/Customer.php +++ b/examples/Customer.php @@ -197,14 +197,14 @@ echo "Behaviour: {$customer->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. echo "Code: {$customer->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the DEB Dimension type. echo "DiscountArticle (\\PhpTwinfield\\Article):
" . print_r($customer->getDiscountArticle(), true) . "

"; // Article|null The discount or premium article. - echo "DiscountArticle (string): {$customer->getDiscountArticleToString()}
"; // string|null + echo "DiscountArticle (string): " . Util::objectToStr($customer->getDiscountArticle()) . "
"; // string|null echo "DiscountArticleID: {$customer->getDiscountArticleID()}
"; // string|null echo "EndPeriod: {$customer->getEndPeriod()}
"; // int|null Determines together with endyear the period till which the dimension may be used. echo "EndYear: {$customer->getEndYear()}
"; // int|null Determines together with endperiod the period till which the dimension may be used. echo "Group (\\PhpTwinfield\\DimensionGroup):
" . print_r($customer->getGroup(), true) . "

"; // DimensionGroup|null Sets the dimension group. See Dimension group. - echo "Group (string): {$customer->getGroupToString()}
"; // string|null + echo "Group (string): " . Util::objectToStr($customer->getGroup()) . "
"; // string|null echo "InUse (bool): {$customer->getInUse()}
"; // bool|null Indicates whether the balancesheet is used in a financial transaction or not. Read-only attribute. - echo "InUse (string): {$customer->getInUseToString()}
"; // string|null + echo "InUse (string): " . Util::formatBoolean($customer->getInUse()) . "
"; // string|null if ($customer->hasMessages()) { // bool Object contains (error) messages true/false. echo "Messages: " . print_r($customer->getMessages(), true) . "
"; // Array|null (Error) messages. @@ -212,7 +212,7 @@ echo "Name: {$customer->getName()}
"; // string|null Name of the dimension. echo "Office (\\PhpTwinfield\\Office):
" . print_r($customer->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): {$customer->getOfficeToString()}
"; // string|null + echo "Office (string): " . Util::objectToStr($customer->getOffice()) . "
"; // string|null echo "PaymentCondition:
"; // Sets the payment condition of a dimension. echo "PaymentCondition DiscountDays: {$customer->getPaymentConditionDiscountDays()}
"; // int|null Number of discount days. echo "PaymentCondition DiscountPercentage: {$customer->getPaymentConditionDiscountPercentage()}
"; // float|null Discount percentage. @@ -224,7 +224,7 @@ echo "Status: {$customer->getStatus()}
"; // Status|null Status of the customer. echo "Touched: {$customer->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($customer->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of customers is DEB. - echo "Type (string): {$customer->getTypeToString()}
"; // string|null + echo "Type (string): " . Util::objectToStr($customer->getType()) . "
"; // string|null echo "UID: {$customer->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. echo "Website: {$customer->getWebsite()}
"; // string|null Website of the dimension. @@ -235,9 +235,9 @@ echo "City: {$customerAddress->getCity()}
"; // string|null City. echo "Country (\\PhpTwinfield\\Country):
" . print_r($customerAddress->getCountry(), true) . "

"; // Country|null Country code. The ISO country codes are used. - echo "Country (string): {$customerAddress->getCountryToString()}
"; // string|null + echo "Country (string): " . Util::objectToStr($customerAddress->getCountry()) . "
"; // string|null echo "Default (bool): {$customerAddress->getDefault()}
"; // bool|null Is this the default address, only one default address is possible. - echo "Default (string): {$customerAddress->getDefaultToString()}
"; // string|null + echo "Default (string): " . Util::formatBoolean($customerAddress->getDefault()) . "
"; // string|null echo "Email: {$customerAddress->getEmail()}
"; // string|null echo "Field1: {$customerAddress->getField1()}
"; // string|null User defined fields, the labels are configured in the Dimension type. echo "Field2: {$customerAddress->getField2()}
"; // string|null User defined fields, the labels are configured in the Dimension type. @@ -272,12 +272,12 @@ echo "BicCode: {$customerBank->getBicCode()}
"; // string|null BIC code. echo "Blocked (bool): {$customerBank->getBlocked()}
"; // bool|null - echo "Blocked (string): {$customerBank->getBlockedToString()}
"; // string|null + echo "Blocked (string): " . Util::formatBoolean($customerBank->getBlocked()) . "
"; // string|null echo "City: {$customerBank->getCity()}
"; // string|null City. echo "Country (\\PhpTwinfield\\Country):
" . print_r($customerBank->getCountry(), true) . "

"; // Country|null Bank country code. The ISO country codes are used. - echo "Country (string): {$customerBank->getCountryToString()}
"; // string|null + echo "Country (string): " . Util::objectToStr($customerBank->getCountry()) . "
"; // string|null echo "Default (bool): {$customerBank->getDefault()}
"; // bool|null Is this the default bank account, only one default bank account is possible. - echo "Default (string): {$customerBank->getDefaultToString()}
"; // string|null + echo "Default (string): " . Util::formatBoolean($customerBank->getDefault()) . "
"; // string|null echo "ID: {$customerBank->getID()}
"; // int|null Sequence number of the bank account line. When adding a new bank, do not supply the @id. When changing a bank account, supply the corresponding @id. echo "IBAN: {$customerBank->getIban()}
"; // string|null IBAN account number. @@ -295,16 +295,16 @@ echo "CustomerCreditManagement
"; echo "BaseCreditLimit (\\Money\\Money):
" . print_r($customerCreditManagement->getBaseCreditLimit(), true) . "

"; // Money|null The credit limit amount. - echo "BaseCreditLimit (float): {$customerCreditManagement->getBaseCreditLimitToFloat()}
"; // float|null + echo "BaseCreditLimit (string): " . Util::formatMoney($customerCreditManagement->getBaseCreditLimit()) . "
"; // string|null echo "Blocked (bool): {$customerCreditManagement->getBlocked()}
"; // bool|null Indicates if related projects for this customer are blocked in time & expenses. - echo "Blocked (string): {$customerCreditManagement->getBlockedToString()}
"; // string|null + echo "Blocked (string): " . Util::formatBoolean($customerCreditManagement->getBlocked()) . "
"; // string|null echo "Blocked Locked (bool): {$customerCreditManagement->getBlockedLocked()}
"; // bool|null - echo "Blocked Locked (string): {$customerCreditManagement->getBlockedLockedToString()}
"; // string|null + echo "Blocked Locked (string): " . Util::formatBoolean($customerCreditManagement->getBlockedLocked()) . "
"; // string|null echo "Blocked Modified (\\DateTimeInterface):
" . print_r($customerCreditManagement->getBlockedModified(), true) . "

"; // \DateTimeInterface|null - echo "Blocked Modified (string): {$customerCreditManagement->getBlockedModifiedToString()}
"; // string|null + echo "Blocked Modified (string): " . Util::formatBoolean($customerCreditManagement->getBlockedModified()) . "
"; // string|null echo "Comment: {$customerCreditManagement->getComment()}
"; // string|null Comment. echo "Freetext1 (bool): {$customerCreditManagement->getFreeText1()}
"; // bool|null Right of use. - echo "Freetext1 (string): {$customerCreditManagement->getFreeText1ToString()}
"; // string|null + echo "Freetext1 (string): " . Util::formatBoolean($customerCreditManagement->getFreeText1()) ."
"; // string|null echo "Freetext2: {$customerCreditManagement->getFreetext2()}
"; // string|null Segment code. echo "Freetext3: {$customerCreditManagement->getFreetext3()}
"; // string|null Not in use. @@ -314,7 +314,7 @@ echo "ReminderEmail: {$customerCreditManagement->getReminderEmail()}
"; // string|null Mandatory if sendreminder is email. echo "ResponsibleUser (\\PhpTwinfield\\User):
" . print_r($customerCreditManagement->getResponsibleUser(), true) . "

"; // User|null The credit manager. - echo "ResponsibleUser (string): {$customerCreditManagement->getResponsibleUserToString()}
"; // string|null + echo "ResponsibleUser (string): " . Util::objectToStr($customerCreditManagement->getResponsibleUser()) . "
"; // string|null echo "Result: {$customerCreditManagement->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "SendReminder: {$customerCreditManagement->getSendReminder()}
"; // SendReminder|null Determines if and how a customer will be reminded. @@ -326,7 +326,7 @@ echo "DueDays: {$customerFinancials->getDueDays()}
"; // int|null The number of due days. echo "EBillMail: {$customerFinancials->getEBillMail()}
"; // string|null The mail address the electronic sales invoice is sent to. echo "EBilling (bool): {$customerFinancials->getEBilling()}
"; // bool|null Determines if the sales invoices will be sent electronically to the customer. - echo "EBilling (string): {$customerFinancials->getEBillingToString()}
"; // string|null + echo "EBilling (string): " . Util::formatBoolean($customerFinancials->getEBilling()) . "
"; // string|null echo "Level: {$customerFinancials->getLevel()}
"; // int|null Specifies the dimension level. Normally the level of customers is level 2. Read-only attribute. echo "MatchType: {$customerFinancials->getMatchType()}
"; // MatchType|null Fixed value customersupplier. echo "MeansOfPayment: {$customerFinancials->getMeansOfPayment()}
"; // MeansOfPayment|null The option none is only allowed in case payavailable is set to false. The option paymentfile is only allowed in case payavailable is set to true. @@ -336,20 +336,20 @@ } echo "PayAvailable (bool): {$customerFinancials->getPayAvailable()}
"; // bool|null Determines if direct debit is possible. - echo "PayAvailable (string): {$customerFinancials->getPayAvailableToString()}
"; // string|null + echo "PayAvailable (string): " . Util::formatBoolean($customerFinancials->getPayAvailable()) . "
"; // string|null echo "PayCode (\\PhpTwinfield\\PayCode):
" . print_r($customerFinancials->getPayCode(), true) . "

"; // PayCode|null The code of the payment type in case direct debit is possible. - echo "PayCode (string): {$customerFinancials->getPayCodeToString()}
"; // string|null + echo "PayCode (string): " . Util::objectToStr($customerFinancials->getPayCode()) . "
"; // string|null echo "PayCodeID: {$customerFinancials->getPayCodeID()}
"; // string|null echo "Result: {$customerFinancials->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "SubAnalyse: {$customerFinancials->getSubAnalyse()}
"; // SubAnalyse|null Fixed value false. - echo "SubstituteWith (\\PhpTwinfield\\Dummy):
" . print_r($customerFinancials->getSubstituteWith(), true) . "

"; // Dummy|null Default customer balancesheet account. - echo "SubstituteWith (string): {$customerFinancials->getSubstituteWithToString()}
"; // string|null + echo "SubstituteWith (\\PhpTwinfield\\GeneralLedger):
" . print_r($customerFinancials->getSubstituteWith(), true) . "

"; // GeneralLedger|null Default customer balancesheet account. + echo "SubstituteWith (string): " . Util::objectToStr($customerFinancials->getSubstituteWith()) . "
"; // string|null echo "SubstituteWithID: {$customerFinancials->getSubstituteWithID()}
"; // string|null echo "SubstitutionLevel: {$customerFinancials->getSubstitutionLevel()}
"; // int|null Level of the balancesheet account. Fixed value 1. echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($customerFinancials->getVatCode(), true) . "

"; // VatCode|null Default VAT code. - echo "VatCode (string): {$customerFinancials->getVatCodeToString()}
"; // string|null + echo "VatCode (string): " . Util::objectToStr($customerFinancials->getVatCode()) . "
"; // string|null echo "VatCode Fixed (bool): {$customerFinancials->getVatCodeFixed()}
"; // bool|null - echo "VatCode Fixed (string): {$customerFinancials->getVatCodeFixedToString()}
"; // string|null + echo "VatCode Fixed (string): " . Util::formatBoolean($customerFinancials->getVatCodeFixed()) . "
"; // string|null $customerChildValidations = $customerFinancials->getChildValidations(); // array|null Array of CustomerChildValidations objects. @@ -371,7 +371,7 @@ echo "CustomerCollectMandate
"; echo "FirstRunDate (\\DateTimeInterface):
" . print_r($customerCollectMandate->getFirstRunDate(), true) . "

"; // \DateTimeInterface|null Date on which the first run was collected. - echo "FirstRunDate (string): {$customerCollectMandate->getFirstRunDateToString()}
"; // string|null + echo "FirstRunDate (string): " . Util::formatDate($customerCollectMandate->getFirstRunDate()) . "
"; // string|null echo "ID: {$customerCollectMandate->getID()}
"; // string|null Mandate id which the debtor can collect with. if ($customerCollectMandate->hasMessages()) { // bool Object contains (error) messages true/false. @@ -379,7 +379,7 @@ } echo "SignatureDate (\\DateTimeInterface):
" . print_r($customerCollectMandate->getSignatureDate(), true) . "

"; // \DateTimeInterface|null Date on which the mandate is signed. - echo "SignatureDate (string): {$customerCollectMandate->getSignatureDateToString()}
"; // string|null + echo "SignatureDate (string): " . Util::formatDate($customerCollectMandate->getSignatureDate()) . "
"; // string|null $customerPostingRules = $customer->getPostingRules(); // array|null Array of CustomerPostingRule objects. @@ -387,9 +387,9 @@ echo "CustomerPostingRule {$key}
"; echo "Amount (\\Money\\Money):
" . print_r($customerPostingRule->getAmount(), true) . "

"; // Money|null Amount. - echo "Amount (float): {$customerPostingRule->getAmountToFloat()}
"; // float|null + echo "Amount (string): " . Util::formatMoney($customerPostingRule->getAmount()) . "
"; // string|null echo "Currency (\\PhpTwinfield\\Currency):
" . print_r($customerPostingRule->getCurrency(), true) . "

"; // Currency|null Currency. - echo "Currency (string): {$customerPostingRule->getCurrencyToString()}
"; // string|null + echo "Currency (string): " . Util::objectToStr($customerPostingRule->getCurrency()) . "
"; // string|null echo "Description: {$customerPostingRule->getDescription()}
"; // string|null Description. echo "ID: {$customerPostingRule->getID()}
"; // int|null Sequence number of the posting rule. Fixed value 1. @@ -407,13 +407,13 @@ echo "Description: {$customerLine->getDescription()}
"; // string|null Description. echo "Dimension1 (\\PhpTwinfield\\GeneralLedger):
" . print_r($customerLine->getDimension1(), true) . "

"; // GeneralLedger|null General ledger. - echo "Dimension1 (string): {$customerLine->getDimension1ToString()}
"; // string|null + echo "Dimension1 (string): " . Util::objectToStr($customerLine->getDimension1()) . "
"; // string|null echo "Dimension1ID: {$customerLine->getDimension1ID()}
"; // string|null echo "Dimension2 (\\PhpTwinfield\\CostCenter):
" . print_r($customerLine->getDimension2(), true) . "

"; // CostCenter|null Cost center. - echo "Dimension2 (string): {$customerLine->getDimension2ToString()}
"; // string|null + echo "Dimension2 (string): " . Util::objectToStr($customerLine->getDimension2()) . "
"; // string|null echo "Dimension2ID: {$customerLine->getDimension2ID()}
"; // string|null - echo "Dimension3 (\\PhpTwinfield\\Dummy):
" . print_r($customerLine->getDimension3(), true) . "

"; // Dummy|null Project or asset. - echo "Dimension3 (string): {$customerLine->getDimension3ToString()}
"; // string|null + echo "Dimension3:
" . print_r($customerLine->getDimension3(), true) . "

"; // Project|Activity|null Project or asset. + echo "Dimension3 (string): " . Util::objectToStr($customerLine->getDimension3()) . "
"; // string|null echo "Dimension3ID: {$customerLine->getDimension3ID()}
"; // string|null if ($customerLine->hasMessages()) { // bool Object contains (error) messages true/false. @@ -421,11 +421,11 @@ } echo "Office (\\PhpTwinfield\\Office):
" . print_r($customerLine->getOffice(), true) . "

"; // Office|null Destination company. - echo "Office (string): {$customerLine->getOfficeToString()}
"; // string|null + echo "Office (string): " . Util::objectToStr($customerLine->getOffice()) . "
"; // string|null echo "Ratio: {$customerLine->getRatio()}
"; // float|null The ratio of the posting rule line. echo "Result: {$customerLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($customerLine->getVatCode(), true) . "

"; // VatCode|null VAT code. - echo "VatCode (string): {$customerLine->getVatCodeToString()}
"; // string|null + echo "VatCode (string): " . Util::objectToStr($customerLine->getVatCode()) . "
"; // string|null } } } @@ -471,7 +471,7 @@ //$customer->setCode('1100'); // string|null Dimension code, must be compliant with the mask of the DEB Dimension type. $customer->setName("Example Customer"); // string|null Name of the dimension. $customer->setOffice($office); // Office|null Office code. - $customer->setOfficeFromString($officeCode); // string|null + $customer->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null // Optional values for creating a new Customer $customer->setBeginPeriod(0); // int|null Determines together with beginyear the period from which the dimension may be used. @@ -481,81 +481,69 @@ $customer->setShortName("ExmplCust"); // string|null Short name of the dimension. //$customer->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. //$customer->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case a dimension that is used in a transaction is deleted, its status has been changed into hide. Hidden dimensions can be activated by using active. - //$customer->setStatusFromString('active'); // string|null - //$customer->setStatusFromString('deleted'); // string|null $customer->setWebsite("www.example.com"); // string|null Website of the dimension. $article = new \PhpTwinfield\Article; $article->setCode('9060'); $customer->setDiscountArticle($article); // Article|null The discount or premium article. - $customer->setDiscountArticleFromString("9060"); // string|null + $customer->setDiscountArticle(\PhpTwinfield\Article::fromCode("9060")); // string|null $dimensionGroup = new \PhpTwinfield\DimensionGroup; $dimensionGroup->setCode('DIMGROUP'); //$customer->setGroup($dimensionGroup); // DimensionGroup|null Sets the dimension group. See Dimension group. - //$customer->setGroupFromString("DIMGROUP"); // string|null + //$customer->setGroup(\PhpTwinfield\DimensionGroup::fromCode("DIMGROUP")); // string|null $customer->setPaymentConditionDiscountDays(3); // int|null Number of discount days. $customer->setPaymentConditionDiscountPercentage(25); // int|null Discount percentage. $customer->setRemittanceAdviceSendMail("test@example.com"); // string|null Mandatory if sendtype = ByEmail, remittance advice will be sent using this e-mail address. $customer->setRemittanceAdviceSendType(\PhpTwinfield\Enums\RemittanceAdviceSendType::BYEMAIL()); // RemittanceAdviceSendMail|null To file manager, By e-mail - $customer->setRemittanceAdviceSendTypeFromString('ByEmail'); // string|null $customerCreditManagement = new \PhpTwinfield\CustomerCreditManagement; - $customerCreditManagement->setBaseCreditLimit(\Money\Money::EUR(1000000)); // Money|null The credit limit amount. - $customerCreditManagement->setBaseCreditLimitFromFloat(10000); // float|null + $customerCreditManagement->setBaseCreditLimit(\Money\Money::EUR(1000000)); // Money|null The credit limit amount. (Equals 10000.00 EUR) $customerCreditManagement->setBlocked(false); // bool|null Indicates if related projects for this customer are blocked in time & expenses. - $customerCreditManagement->setBlockedFromString('false'); // string|null $customerCreditManagement->setBlockedLocked(false); // bool|null - $customerCreditManagement->setBlockedLockedFromString('false'); // string|null $customerCreditManagement->setComment('Comment'); // string|null Comment. $customerCreditManagement->setFreeText1(true); // bool|null Right of use. - $customerCreditManagement->setFreeText1FromString('true'); // string|null $customerCreditManagement->setFreetext2(2); // string|null Segment code. $customerCreditManagement->setFreetext3(''); // string|null $customerCreditManagement->setReminderEmail('test@example.com'); // string|null Mandatory if sendreminder is email. $user = new \PhpTwinfield\User; $user->setCode('TWINAPPS'); $customerCreditManagement->setResponsibleUser($user); // User|null The credit manager. - $customerCreditManagement->setResponsibleUserFromString('TWINAPPS'); // string|null + $customerCreditManagement->setResponsibleUser(\PhpTwinfield\User::fromCode('TWINAPPS')); // string|null $customerCreditManagement->setSendReminder(\PhpTwinfield\Enums\SendReminder::EMAIL()); // SendReminder|null Determines if and how a customer will be reminded. - $customerCreditManagement->setSendReminderFromString('email'); // string|null $customer->setCreditManagement($customerCreditManagement); // CustomerCreditManagement Set the CustomerCreditManagement object tot the Customer object $customerFinancials = new \PhpTwinfield\CustomerFinancials; $customerFinancials->setCollectionSchema(\PhpTwinfield\Enums\CollectionSchema::CORE()); - $customerFinancials->setCollectionSchemaFromString('core'); $customerFinancials->setDueDays(14); // int|null The number of due days. $customerFinancials->setEBillMail('test@example.com'); // string|null The mail address the electronic sales invoice is sent to. $customerFinancials->setEBilling(true); // bool|null Determines if the sales invoices will be sent electronically to the customer. - $customerFinancials->setEBillingFromString('true'); // string|null $customerFinancials->setMeansOfPayment(\PhpTwinfield\Enums\MeansOfPayment::PAYMENTFILE()); // MeansOfPayment|null The option none is only allowed in case payavailable is set to false. The option paymentfile is only allowed in case payavailable is set to true. - $customerFinancials->setMeansOfPaymentFromString('paymentfile'); // string|null $customerFinancials->setPayAvailable(true); // bool|null Determines if direct debit is possible. - $customerFinancials->setPayAvailableFromString('true'); // string|null $payCode = new \PhpTwinfield\PayCode; $payCode->setCode('SEPANLCT'); $customerFinancials->setPayCode($payCode); // PayCode|null The code of the payment type in case direct debit is possible. - $customerFinancials->setPayCodeFromString('SEPANLCT'); // string|null + $customerFinancials->setPayCode(\PhpTwinfield\PayCode::fromCode('SEPANLCT')); // string|null $substituteWith = new \PhpTwinfield\GeneralLedger; $substituteWith->getCode('1535'); $customerFinancials->setSubstituteWith($substituteWith); // GeneralLedger|null Default customer balancesheet account. - $customerFinancials->setSubstituteWithFromString('1535'); // string|null + $customerFinancials->setSubstituteWith(\PhpTwinfield\GeneralLedger::fromCode('1535')); // string|null $vatCode = new \PhpTwinfield\VatCode; $vatCode->setCode('VH'); $customerFinancials->setVatCode($vatCode); // VatCode|null Default VAT code. - $customerFinancials->setVatCodeFromString('VH'); // string|null + $customerFinancials->setVatCode(\PhpTwinfield\VatCode::fromCode('VH')); // string|null $customerCollectMandate = new \PhpTwinfield\CustomerCollectMandate; $firstRunDate = \DateTime::createFromFormat('d-m-Y', '01-07-2019'); $customerCollectMandate->setFirstRunDate($firstRunDate); // DateTimeInterface|null Date on which the first run was collected. - $customerCollectMandate->setFirstRunDateFromString('20190701'); // string|null + $customerCollectMandate->setFirstRunDate(Util::parseDate('20190701')); // string|null $customerCollectMandate->setID('1010'); // string|null Mandate id which the debtor can collect with. $signatureDate = \DateTime::createFromFormat('d-m-Y', '01-07-2019'); $customerCollectMandate->setSignatureDate($signatureDate); // DateTimeInterface|null Date on which the first run was collected. - $customerCollectMandate->setSignatureDateFromString('20190701'); // string|null + $customerCollectMandate->setSignatureDate(Util::parseDate('20190701')); // string|null $customerFinancials->setCollectMandate($customerCollectMandate); // CustomerCollectMandate Set the CustomerCollectMandate object tot the CustomerFinancials object @@ -566,9 +554,8 @@ $country = new \PhpTwinfield\Country; $country->setCode('NL'); $customerAddress->setCountry($country); // Country|null Country code. The ISO country codes are used. - $customerAddress->setCountryFromString('NL'); // string|null + $customerAddress->setCountry(\PhpTwinfield\Country::fromCode('NL')); // string|null $customerAddress->setDefault(true); // bool|null Is this the default address, only one default address is possible. - $customerAddress->setDefaultFromString('true'); // string|null $customerAddress->setEmail('test@example.com'); // string|null $customerAddress->setField1(''); // string|null User defined fields, the labels are configured in the Dimension type. $customerAddress->setField2(''); // string|null User defined fields, the labels are configured in the Dimension type. @@ -582,7 +569,6 @@ $customerAddress->setTelefax('012-3456789'); // string|null Fax number. $customerAddress->setTelephone('987-654321'); // string|null Telephone number. $customerAddress->setType(\PhpTwinfield\Enums\AddressType::INVOICE()); // AddressType|null The type of the address. - $customerAddress->setTypeFromString('invoice'); // string|null $customer->addAddress($customerAddress); // CustomerAddress Add a CustomerAddress object to the Customer object //$customer->removeAddress(0); // int Remove an address based on the index of the address within the array @@ -595,14 +581,12 @@ $customerBank->setBankName('Example Bank'); // string|null Bank name. $customerBank->setBicCode('ABNANL2A'); // string|null BIC code. $customerBank->setBlocked(false); // bool|null - $customerBank->setBlockedFromString('false'); // string|null $customerBank->setCity('Amsterdam'); // string|null City. $country = new \PhpTwinfield\Country; $country->setCode('NL'); $customerBank->setCountry($country); // Country|null Bank country code. The ISO country codes are used. - $customerBank->setCountryFromString('NL'); // string|null + $customerBank->setCountry(\PhpTwinfield\Country::fromCode('NL')); // string|null $customerBank->setDefault(true); // bool|null Is this the default bank account, only one default bank account is possible. - $customerBank->setDefaultFromString('true'); // string|null $customerBank->setID(null); // int|null Sequence number of the bank account line. When adding a new bank, do not supply the @id. When changing a bank account, supply the corresponding @id. $customerBank->setIban(null); // string|null IBAN account number. $customerBank->setNatBicCode('NL'); // string|null National bank code. @@ -613,41 +597,38 @@ //$customer->removeBank(0); // int Remove a bank based on the index of the bank within the array $customerPostingRule = new \PhpTwinfield\CustomerPostingRule; - $customerPostingRule->setAmount(\Money\Money::EUR(10000)); // Money|null Amount. - $customerPostingRule->setAmountFromFloat(100); // float|null + $customerPostingRule->setAmount(\Money\Money::EUR(10000)); // Money|null Amount. (Equals 100.00 EUR) $currency = new \PhpTwinfield\Currency; $currency->setCode('EUR'); $customerPostingRule->setCurrency($currency); // Currency|null Currency. - $customerPostingRule->setCurrencyFromString('EUR'); // string|null + $customerPostingRule->setCurrency(\PhpTwinfield\Currency::fromCode('EUR')); // string|null $customerPostingRule->setDescription('Example PostingRule'); // string|null Description. $customerPostingRule->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating active should be used. For deleting deleted should be used. //$customerPostingRule->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null - $customerPostingRule->setStatusFromString('active'); // string|null - //$customerPostingRule->setStatusFromString('deleted'); // string|null $customerLine = new \PhpTwinfield\CustomerLine; $customerLine->setDescription('Example Line'); // string|null Description. $dimension1 = new \PhpTwinfield\GeneralLedger; $dimension1->setCode('1535'); $customerLine->setDimension1($dimension1); // GeneralLedger|null General ledger. - $customerLine->setDimension1FromString('1535'); // string|null + $customerLine->setDimension1(\PhpTwinfield\GeneralLedger::fromCode('1535')); // string|null $costCenter = new \PhpTwinfield\CostCenter; $costCenter->setCode('00000'); $customerLine->setDimension2($costCenter); // CostCenter|null Cost center. - $customerLine->setDimension2FromString ('00000'); // string|null + $customerLine->setDimension2(\PhpTwinfield\CostCenter::fromCode('00000')); // string|null $activity = new \PhpTwinfield\Activity; $activity->setCode('P0000'); - $customerLine->setDimension3($activity); // Dummy|null Project or asset. - $customerLine->setDimension3FromString('P0000'); // string|null + $customerLine->setDimension3($activity); // Project|Activity|null Project or asset. + $customerLine->setDimension3(\PhpTwinfield\Activity::fromCode('P0000')); // string|null $destOffice = new \PhpTwinfield\Office; $destOffice->setCode('NLA0000001'); //$customerLine->setOffice($destOffice); // Office|null Destination company. - //$customerLine->setOfficeFromString('NLA0000001'); // string|null + //$customerLine->setOffice(\PhpTwinfield\Office::fromCode('NLA0000001')); // string|null $customerLine->setRatio(1); // float|null The ratio of the posting rule line. $vatCode = new \PhpTwinfield\VatCode; $vatCode->setCode('VH'); $customerLine->setVatCode($vatCode); // VatCode|null Default VAT code. - $customerLine->setVatCodeFromString('VH'); // string|null + $customerLine->setVatCode(\PhpTwinfield\VatCode::fromCode('VH')); // string|null $customerPostingRule->addLine($customerLine); // CustomerLine Add a CustomerLine object to the CustomerPostingRule object //$customerPostingRule->removeLine(0); // int Remove a line based on the index of the line within the array diff --git a/examples/DimensionGroup.php b/examples/DimensionGroup.php index 369d1f40..fce9c0bb 100644 --- a/examples/DimensionGroup.php +++ b/examples/DimensionGroup.php @@ -27,7 +27,7 @@ // Run all or only some of the following examples $executeListAllWithFilter = false; $executeListAllWithoutFilter = true; -$executeRead = false; +$executeRead = true; $executeCopy = false; $executeNew = false; $executeDelete = false; @@ -188,7 +188,7 @@ $dimensionGroup->setCode('DIMGRP2'); // string|null Dimension group code. $dimensionGroup->setName("Dimension Group 2"); // string|null Name of the dimension group. $dimensionGroup->setOffice($office); // Office|null Office code. - $dimensionGroup->setOfficeFromString(\PhpTwinfield\Office::fromCode($officeCode)); // string|null + $dimensionGroup->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null $dimensionGroup->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating active should be used. For deleting deleted should be used. //$dimensionGroup->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null @@ -226,7 +226,7 @@ // Delete a DimensionGroup based off the passed in code and optionally the office. if ($executeDelete) { try { - $dimensionGroupDeleted = $dimensionGroupApiConnector->delete("TSTDIMGRP2", $office); + $dimensionGroupDeleted = $dimensionGroupApiConnector->delete("DIMGRP2", $office); } catch (ResponseException $e) { $dimensionGroupDeleted = $e->getReturnedObject(); } diff --git a/examples/GeneralLedger.php b/examples/GeneralLedger.php index 84b04f18..f292cee9 100644 --- a/examples/GeneralLedger.php +++ b/examples/GeneralLedger.php @@ -131,7 +131,7 @@ // Read a GeneralLedger based off the passed in code and optionally the office. if ($executeRead) { try { - $generalLedger = $generalLedgerApiConnector->get("1000", $office); + $generalLedger = $generalLedgerApiConnector->get("1000", "BAS", $office); } catch (ResponseException $e) { $generalLedger = $e->getReturnedObject(); } @@ -148,9 +148,9 @@ echo "EndPeriod: {$generalLedger->getEndPeriod()}
"; // int|null Determines together with endyear the period till which the dimension may be used. echo "EndYear: {$generalLedger->getEndYear()}
"; // int|null Determines together with endperiod the period till which the dimension may be used. echo "Group (\\PhpTwinfield\\DimensionGroup):
" . print_r($generalLedger->getGroup(), true) . "

"; // DimensionGroup|null Sets the dimension group. See Dimension group. - echo "Group (string): {$generalLedger->getGroupToString()}
"; // string|null + echo "Group (string): " . Util::objectToStr($generalLedger->getGroup()) . "
"; // string|null echo "InUse (bool): {$generalLedger->getInUse()}
"; // bool|null Indicates if the balance or profit and loss account is used in a financial transaction or linked to a VAT code or linked to an article or not in use at all. Read-only attribute. - echo "InUse (string): {$generalLedger->getInUseToString()}
"; // string|null + echo "InUse (string): " . Util::formatBoolean($generalLedger->getInUse()) . "
"; // string|null if ($generalLedger->hasMessages()) { // bool Object contains (error) messages true/false. echo "Messages: " . print_r($generalLedger->getMessages(), true) . "
"; // Array|null (Error) messages. @@ -158,13 +158,13 @@ echo "Name: {$generalLedger->getName()}
"; // string|null Name of the dimension. echo "Office (\\PhpTwinfield\\Office):
" . print_r($generalLedger->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): {$generalLedger->getOfficeToString()}
"; // string|null + echo "Office (string): " . Util::objectToStr($generalLedger->getOffice()) . "
"; // string|null echo "Result: {$generalLedger->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "ShortName: {$generalLedger->getShortName()}
"; // string|null Short name of the dimension. echo "Status: {$generalLedger->getStatus()}
"; // Status|null Status of the generalLedger. echo "Touched: {$generalLedger->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($generalLedger->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of balance accounts is BAS and type of profit and loss is PNL. - echo "Type (string): {$generalLedger->getTypeToString()}
"; // string|null + echo "Type (string): " . Util::objectToStr($generalLedger->getType()) . "
"; // string|null echo "UID: {$generalLedger->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. echo "GeneralLedgerFinancials
"; @@ -181,9 +181,9 @@ echo "Result: {$generalLedgerFinancials->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "SubAnalyse: {$generalLedgerFinancials->getSubAnalyse()}
"; // SubAnalyse|null Is subanalyses needed. echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($generalLedgerFinancials->getVatCode(), true) . "

"; // VatCode|null Default VAT code. - echo "VatCode (string): {$generalLedgerFinancials->getVatCodeToString()}
"; // string|null + echo "VatCode (string): " . Util::objectToStr($generalLedgerFinancials->getVatCode()) . "
"; // string|null echo "VatCode Fixed (bool): {$generalLedgerFinancials->getVatCodeFixed()}
"; // bool|null - echo "VatCode Fixed (string): {$generalLedgerFinancials->getVatCodeFixedToString()}
"; // string|null + echo "VatCode Fixed (string): " . Util::formatBoolean($generalLedgerFinancials->getVatCodeFixed()) . "
"; // string|null $generalLedgerChildValidations = $generalLedgerFinancials->getChildValidations(); // array|null Array of GeneralLedgerChildValidations objects. Validation rule when subanalyses is needed. @@ -205,7 +205,7 @@ // Copy an existing GeneralLedger to a new entity if ($executeCopy) { try { - $generalLedger = $generalLedgerApiConnector->get("1000", $office); + $generalLedger = $generalLedgerApiConnector->get("1000", "BAS", $office); } catch (ResponseException $e) { $generalLedger = $e->getReturnedObject(); } @@ -235,8 +235,14 @@ $generalLedger->setCode(null); // string|null Set to null to let Twinfield assign a Dimension code based on the Dimension type mask //$generalLedger->setCode('1100'); // string|null Dimension code, must be compliant with the mask of the BAS or PNL Dimension type. $generalLedger->setName("Example GeneralLedger"); // string|null Name of the dimension. + $dimensionType = new \PhpTwinfield\DimensionType; + $dimensionType->setCode('BAS'); + //$dimensionType->setCode('PNL'); + $generalLedger->setType($dimensionType); // DimensionType|null + $generalLedger->setType(\PhpTwinfield\DimensionType::fromCode('BAS')); // string|null + //$generalLedger->setType(\PhpTwinfield\DimensionType::fromCode('PNL')); // string|null $generalLedger->setOffice($office); // Office|null Office code. - $generalLedger->setOfficeFromString($officeCode); // string|null + $generalLedger->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null // Optional values for creating a new GeneralLedger $generalLedger->setBeginPeriod(0); // int|null Determines together with beginyear the period from which the dimension may be used. @@ -246,19 +252,19 @@ $generalLedger->setShortName("ExmplCust"); // string|null Short name of the dimension. //$generalLedger->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. //$generalLedger->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case a dimension that is used in a transaction is deleted, its status has been changed into hide. Hidden dimensions can be activated by using active. - //$generalLedger->setStatusFromString('active'); // string|null - //$generalLedger->setStatusFromString('deleted'); // string|null $dimensionGroup = new \PhpTwinfield\DimensionGroup; $dimensionGroup->setCode('DIMGROUP'); //$generalLedger->setGroup($dimensionGroup); // DimensionGroup|null Sets the dimension group. See Dimension group. - //$generalLedger->setGroupFromString("DIMGROUP"); // string|null + //$generalLedger->setGroup(\PhpTwinfield\DimensionGroup::fromCode("DIMGROUP")); // string|null $generalLedgerFinancials = new \PhpTwinfield\GeneralLedgerFinancials; + $generalLedgerFinancials->setAccountType(\PhpTwinfield\Enums\AccountType::BALANCE()); // AccountType|null + //$generalLedgerFinancials->setAccountType(\PhpTwinfield\Enums\AccountType::PROFITANDLOSS()); // AccountType|null $vatCode = new \PhpTwinfield\VatCode; $vatCode->setCode('VH'); $generalLedgerFinancials->setVatCode($vatCode); // VatCode|null Default VAT code. - $generalLedgerFinancials->setVatCodeFromString('VH'); // string|null + $generalLedgerFinancials->setVatCode(\PhpTwinfield\VatCode::fromCode('VH')); // string|null $generalLedger->setFinancials($generalLedgerFinancials); // GeneralLedgerFinancials Set the GeneralLedgerFinancials object tot the GeneralLedger object @@ -279,7 +285,7 @@ // Delete a GeneralLedger based off the passed in code and optionally the office. if ($executeDelete) { try { - $generalLedgerDeleted = $generalLedgerApiConnector->delete("1003", $office); + $generalLedgerDeleted = $generalLedgerApiConnector->delete("0000", "BAS", $office); } catch (ResponseException $e) { $generalLedgerDeleted = $e->getReturnedObject(); } diff --git a/examples/Invoice.php b/examples/Invoice.php index a3383d65..da2a9799 100644 --- a/examples/Invoice.php +++ b/examples/Invoice.php @@ -101,7 +101,7 @@ * getPerformanceDate, getPeriod, getPeriodRaiseWarning, getRaiseWarning, getResult, getStatus, hasMessages, getLines, getMatchReference, getTotals, getVatLines * * Available setters: setBank, setCalculateOnly, setCurrency, setCustomer, setCustomerName, setDebitCredit, setDeliverAddressNumber, setDueDate, setFinancialCode, setFinancialNumber, setFooterText, setHeaderText, setInvoiceAddressNumber, setInvoiceAmount, setInvoiceDate, setInvoiceNumber, setInvoiceType, setOffice, - * setOfficeFromString, setPaymentMethod, setPerformanceDate, setPeriod, setPeriodRaiseWarning, setRaiseWarning, setStatus, setTotals, addLine, addVatLine, removeLine, removeVatLine + * setPaymentMethod, setPerformanceDate, setPeriod, setPeriodRaiseWarning, setRaiseWarning, setStatus, setTotals, addLine, addVatLine, removeLine, removeVatLine * */ @@ -127,8 +127,10 @@ foreach ($invoices as $key => $invoice) { echo "Invoice {$key}
"; echo "InvoiceNumber: {$invoice->getInvoiceNumber()}
"; - echo "InvoiceAmount: {$invoice->getInvoiceAmountToFloat()}
"; - echo "Customer: {$invoice->getCustomerToString()}
"; + echo "InvoiceAmount (\\Money\\Money):
" . print_r($invoice->getInvoiceAmount(), true) . "

"; + echo "InvoiceAmount (string): " . Util::formatMoney($invoice->getInvoiceAmount()) . "
"; + echo "Customer (\\PhpTwinfield\\Customer):
" . print_r($invoice->getCustomer(), true) . "

"; + echo "Customer (string): " . Util::objectToStr($invoice->getCustomer()) . "
"; echo "CustomerName: {$invoice->getCustomerName()}
"; echo "Debit/Credit: {$invoice->getDebitCredit()}

"; } @@ -148,24 +150,24 @@ echo "Invoice
"; echo "Bank (\\PhpTwinfield\\CashBankBook):
" . print_r($invoice->getBank(), true) . "

"; // CashBankBook|null Bank code. - echo "Bank (string): {$invoice->getBankToString()}
"; // string|null + echo "Bank (string): " . Util::objectToStr($invoice->getBank()) . "
"; // string|null echo "Currency (\\PhpTwinfield\\Currency):
" . print_r($invoice->getCurrency(), true) . "

"; // Currency|null Currency code. - echo "Currency (string): {$invoice->getCurrencyToString()}
"; // string|null + echo "Currency (string): " . Util::objectToStr($invoice->getCurrency()) . "
"; // string|null echo "Customer (\\PhpTwinfield\\Customer):
" . print_r($invoice->getCustomer(), true) . "

"; // Customer|null Customer code. - echo "Customer (string): {$invoice->getCustomerToString()}
"; // string|null + echo "Customer (string): " . Util::objectToStr($invoice->getCustomer()) . "
"; // string|null echo "DeliverAddressNumber: {$invoice->getDeliverAddressNumber()}
"; // int|null echo "DueDate (\\DateTimeInterface):
" . print_r($invoice->getDueDate(), true) . "

"; // DateTimeInterface|null Due date. - echo "DueDate (string): {$invoice->getDueDateToString()}
"; // string|null + echo "DueDate (string): " . Util::formatDate($invoice->getDueDate()) . "
"; // string|null echo "FinancialCode: {$invoice->getFinancialCode()}
"; // string|null The transaction type code. Read-only attribute. echo "FinancialNumber: {$invoice->getFinancialNumber()}
"; // string|null The transaction number. Read-only attribute. echo "FooterText: {$invoice->getFooterText()}
"; // string|null Footer text on the invoice. echo "HeaderText: {$invoice->getHeaderText()}
"; // string|null Header text on the invoice. echo "InvoiceAddressNumber: {$invoice->getInvoiceAddressNumber()}
"; // int|null echo "InvoiceDate (\\DateTimeInterface):
" . print_r($invoice->getInvoiceDate(), true) . "

"; // DateTimeInterface|null Invoice date. - echo "InvoiceDate (string): {$invoice->getInvoiceDateToString()}
"; // string|null + echo "InvoiceDate (string): " . Util::formatDate($invoice->getInvoiceDate()) . "
"; // string|null echo "InvoiceNumber: {$invoice->getInvoiceNumber()}
"; // string|null Invoice Number. echo "InvoiceType (\\PhpTwinfield\\InvoiceType):
" . print_r($invoice->getInvoiceType(), true) . "

"; // InvoiceType|null Invoice type code. - echo "InvoiceType (string): {$invoice->getInvoiceTypeToString()}
"; // string|null + echo "InvoiceType (string): " . Util::objectToStr($invoice->getInvoiceType()) . "
"; // string|null if ($invoice->hasMessages()) { // bool Object contains (error) messages true/false. echo "Messages: " . print_r($invoice->getMessages(), true) . "
"; // Array|null (Error) messages. @@ -173,10 +175,10 @@ echo "PaymentMethod: {$invoice->getPaymentMethod()}
"; // PaymentMethod|null The payment method. echo "PerformanceDate (\\DateTimeInterface):
" . print_r($invoice->getPerformanceDate(), true) . "

"; // DateTimeInterface|null Performance date, when set-up on the invoice header. - echo "PerformanceDate (string): {$invoice->getPerformanceDateToString()}
"; // string|null + echo "PerformanceDate (string): " . Util::formatDate($invoice->getPerformanceDate()) . "
"; // string|null echo "Period: {$invoice->getPeriod()}
"; // string|null Period in YYYY/PP format. echo "Office (\\PhpTwinfield\\Office):
" . print_r($invoice->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): {$invoice->getOfficeToString()}
"; // string|null + echo "Office (string): " . Util::objectToStr($invoice->getOffice()) . "
"; // string|null echo "Result: {$invoice->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "Status: {$invoice->getStatus()}
"; // Status|null Status of the invoice. @@ -190,9 +192,9 @@ echo "Result: {$invoiceTotals->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "ValueExcl (\\Money\\Money):
" . print_r($invoiceTotals->getValueExcl(), true) . "

"; // Money|null Value without VAT. Read-only attribute. - echo "ValueExcl (string): {$invoiceTotals->getValueExclToFloat()}
"; // float|null + echo "ValueExcl (string): " . Util::formatMoney($invoiceTotals->getValueExcl()) . "
"; // string|null echo "ValueInc (\\Money\\Money):
" . print_r($invoiceTotals->getValueInc(), true) . "

"; // Money|null Value with VAT. Read-only attribute. - echo "ValueInc (string): {$invoiceTotals->getValueIncToFloat()}
"; // float|null + echo "ValueInc (string): " . Util::formatMoney($invoiceTotals->getValueInc()) . "
"; // string|null if ($invoice->getFinancialCode() != null && $invoice->getFinancialNumber != null) { $match = $invoice->getMatchReference(); @@ -205,12 +207,12 @@ echo "InvoiceLine {$key}
"; echo "AllowDiscountOrPremium (bool): {$invoiceLine->getAllowDiscountOrPremium()}
"; // bool|null Calculate discount on this line. - echo "AllowDiscountOrPremium (string): {$invoiceLine->getAllowDiscountOrPremiumToString()}
"; // string|null + echo "AllowDiscountOrPremium (string): " . Util::formatBoolean($invoiceLine->getAllowDiscountOrPremium()) . "
"; // string|null echo "Article (\\PhpTwinfield\\Article):
" . print_r($invoiceLine->getArticle(), true) . "

"; // Article|null Article code. - echo "Article (string): {$invoiceLine->getArticleToString()}
"; // string|null + echo "Article (string): " . Util::objectToStr($invoiceLine->getArticle()) . "
"; // string|null echo "Description: {$invoiceLine->getDescription()}
"; // string|null Invoice line description, only on the lines with article ‘0’ or ‘-‘. echo "Dim1 (\\PhpTwinfield\\GeneralLedger):
" . print_r($invoiceLine->getDim1(), true) . "

"; // GeneralLedger|null Balance account. - echo "Dim1 (string): {$invoiceLine->getDim1ToString()}
"; // string|null + echo "Dim1 (string): " . Util::objectToStr($invoiceLine->getDim1()) . "
"; // string|null echo "FreeText1: {$invoiceLine->getFreetext1()}
"; // string|null Free text field 1 as entered on the invoice type. echo "FreeText2: {$invoiceLine->getFreetext2()}
"; // string|null Free text field 2 as entered on the invoice type. echo "FreeText3: {$invoiceLine->getFreetext3()}
"; // string|null Free text field 3 as entered on the invoice type. @@ -221,25 +223,25 @@ } echo "PerformanceDate (\\DateTimeInterface):
" . print_r($invoiceLine->getPerformanceDate(), true) . "

"; // DateTimeInterface|null Performance date, when set-up on invoice lines. - echo "PerformanceDate (string): {$invoiceLine->getPerformanceDateToString()}
"; // string|null + echo "PerformanceDate (string): " . Util::formatDate($invoiceLine->getPerformanceDate()) . "
"; // string|null echo "PerformanceType: {$invoiceLine->getPerformanceType()}
"; // PerformanceType|null The performance type in case of an ICT sales invoice. echo "Quantity: {$invoiceLine->getQuantity()}
"; // int|null The quantity on the sales invoice line. echo "Result: {$invoiceLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "SubArticle (\\PhpTwinfield\\ArticleLine):
" . print_r($invoiceLine->getSubArticle(), true) . "

"; // ArticleLine|null Sub-article code. - echo "SubArticle (string): {$invoiceLine->getSubArticleToString()}
"; // string|null + echo "SubArticle (string): {$invoiceLine->getSubArticleToString()}
"; // string|null echo "Units: {$invoiceLine->getUnits()}
"; // int|null The number of units per quantity. echo "UnitsPriceExcl (\\Money\\Money):
" . print_r($invoiceLine->getUnitsPriceExcl(), true) . "

"; // Money|null Only valid for invoice types with VAT exclusive units prices. - echo "UnitsPriceExcl (string): {$invoiceLine->getUnitsPriceExclToFloat()}
"; // float|null Only add this tag to an XML request if the setting Prices can be changed on an item is set to true. Otherwise, the price will be determined by the system. + echo "UnitsPriceExcl (string): " . Util::formatMoney($invoiceLine->getUnitsPriceExcl()) . "
"; // string|null Only add this tag to an XML request if the setting Prices can be changed on an item is set to true. Otherwise, the price will be determined by the system. echo "UnitsPriceInc (\\Money\\Money):
" . print_r($invoiceLine->getUnitsPriceInc(), true) . "

"; // Money|null Only valid for invoice types with VAT inclusive units prices. - echo "UnitsPriceInc (string): {$invoiceLine->getUnitsPriceIncToFloat()}
"; // float|null Only add this tag to an XML request if the setting Prices can be changed on an item is set to true. Otherwise, the price will be determined by the system. + echo "UnitsPriceInc (string): " . Util::formatMoney($invoiceLine->getUnitsPriceInc()) . "
"; // string|null Only add this tag to an XML request if the setting Prices can be changed on an item is set to true. Otherwise, the price will be determined by the system. echo "ValueExcl (\\Money\\Money):
" . print_r($invoiceLine->getValueExcl(), true) . "

"; // Money|null Calculated element. Read-only attribute. - echo "ValueExcl (string): {$invoiceLine->getValueExclToFloat()}
"; // float|null + echo "ValueExcl (string): " . Util::formatMoney($invoiceLine->getValueExcl()) . "
"; // string|null echo "ValueInc (\\Money\\Money):
" . print_r($invoiceLine->getValueInc(), true) . "

"; // Money|null Calculated element. Read-only attribute. - echo "ValueInc (string): {$invoiceLine->getValueIncToFloat()}
"; // float|null + echo "ValueInc (string): " . Util::formatMoney($invoiceLine->getValueInc()) . "
"; // string|null echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($invoiceLine->getVatCode(), true) . "

"; // VatCode|null VAT code. - echo "VatCode (string): {$invoiceLine->getVatCodeToString()}
"; // string|null + echo "VatCode (string): " . Util::objectToStr($invoiceLine->getVatCode()) . "
"; // string|null echo "VatValue (\\Money\\Money):
" . print_r($invoiceLine->getVatValue(), true) . "

"; // Money|null Calculated element. Read-only attribute. - echo "VatValue (string): {$invoiceLine->getVatValueToFloat()}
"; // float|null + echo "VatValue (string): " . Util::formatMoney($invoiceLine->getVatValue()) . "
"; // string|null } $invoiceVatLines = $invoice->getVatLines(); // array|null Array of InvoiceVatLine objects. @@ -252,13 +254,13 @@ } echo "PerformanceDate (\\DateTimeInterface):
" . print_r($invoiceVatLine->getPerformanceDate(), true) . "

"; // DateTimeInterface|null The performance date. Only in case performancetype = services. Read-only attribute. - echo "PerformanceDate (string): {$invoiceVatLine->getPerformanceDateToString()}
"; // string|null + echo "PerformanceDate (string): " . Util::formatDate($invoiceVatLine->getPerformanceDate()) . "
"; // string|null echo "PerformanceType: {$invoiceVatLine->getPerformanceType()}
"; // PerformanceType|null The performance type. Read-only attribute. echo "Result: {$invoiceVatLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($invoiceVatLine->getVatCode(), true) . "

"; // VatCode|null VAT code. Read-only attribute. - echo "VatCode (string): {$invoiceVatLine->getVatCodeToString()}
"; // string|null + echo "VatCode (string): " . Util::objectToStr($invoiceVatLine->getVatCode()) . "
"; // string|null echo "VatValue (\\Money\\Money):
" . print_r($invoiceVatLine->getVatValue(), true) . "

"; // Money|null VAT amount. Read-only attribute. - echo "VatValue (string): {$invoiceVatLine->getVatValueToFloat()}
"; // float|null + echo "VatValue (string): " . Util::formatMoney($invoiceVatLine->getVatValue()) . "
"; // string|null } } @@ -273,7 +275,7 @@ $invoice->setInvoiceNumber(null); //Optional, but recommended so your copy is not posted to final immediately - $invoice->setStatusFromString('concept'); + $invoice->setStatus(\PhpTwinfield\Enums\InvoiceStatus::CONCEPT()); try { $invoiceCopy = $invoiceApiConnector->send($invoice); @@ -311,7 +313,7 @@ $bank = new \PhpTwinfield\CashBankBook; $bank->setCode('BNK'); $invoice->setBank($bank); // CashBankBook|null Customer code. - $invoice->setBankFromString(\PhpTwinfield\CashBankBook::fromCode("BNK")); // string|null + $invoice->setBank(\PhpTwinfield\CashBankBook::fromCode("BNK")); // string|null $currency = new \PhpTwinfield\Currency; $currency->setCode('EUR'); $invoice->setCurrency($currency); // Currency|null Currency code. diff --git a/examples/Office.php b/examples/Office.php index d4209a95..83713db4 100644 --- a/examples/Office.php +++ b/examples/Office.php @@ -142,14 +142,14 @@ //echo "CountryCode (\\PhpTwinfield\\Country):
" . print_r($office->getCountryCode(), true) . "

"; // Country|null //echo "CountryCode (string): " . Util::objectToStr($office->getCountryCode()) . "
"; // string|null echo "Created (\\DateTimeInterface):
" . print_r($office->getCreated(), true) . "

"; // DateTimeInterface|null The date/time the office was created. - echo "Created (string): " . Util::parseDateTime($office->getCreatedToString()) . "
"; // string|null + echo "Created (string): " . Util::formatDateTime($office->getCreated()) . "
"; // string|null if ($office->hasMessages()) { // bool Object contains (error) messages true/false. echo "Messages: " . print_r($office->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "Modified (\\DateTimeInterface):
" . print_r($office->getModified(), true) . "

"; // DateTimeInterface|null The date/time the office was modified. - echo "Modified (string): " . Util::parseDateTime($office->getModified()) . "
"; // string|null + echo "Modified (string): " . Util::formatDateTime($office->getModified()) . "
"; // string|null echo "Name: {$office->getName()}
"; // string|null echo "ReportingCurrency (\\PhpTwinfield\\Currency):
" . print_r($office->getReportingCurrency(), true) . "

"; // Currency|null The reporting currency echo "ReportingCurrency (string): " . Util::objectToStr($office->getReportingCurrency()) . "
"; // string|null diff --git a/examples/Project.php b/examples/Project.php index d2c1210c..a85dc0f2 100644 --- a/examples/Project.php +++ b/examples/Project.php @@ -130,10 +130,10 @@ } } -// Read a Project based off the passed in code and optionally the office. +// Read an Project based off the passed in code and optionally the office. if ($executeRead) { try { - $project = $projectApiConnector->get("P0001", $office); + $project = $projectApiConnector->get("P0000", $office); } catch (ResponseException $e) { $project = $e->getReturnedObject(); } @@ -144,9 +144,9 @@ echo "Project
"; echo "Behaviour: {$project->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. - echo "Code: {$project->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the PRJ Dimension type. + echo "Code: {$project->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the ACT Dimension type. echo "InUse (bool): {$project->getInUse()}
"; // bool|null Indicates whether the project is used in a transaction or not. Read-only attribute. - echo "InUse (string): {$project->getInUseToString()}
"; // string|null + echo "InUse (string): " . Util::formatBoolean($project->getInUse()) . "
"; // string|null if ($project->hasMessages()) { // bool Object contains (error) messages true/false. echo "Messages: " . print_r($project->getMessages(), true) . "
"; // Array|null (Error) messages. @@ -154,39 +154,39 @@ echo "Name: {$project->getName()}
"; // string|null Project description. echo "Office (\\PhpTwinfield\\Office):
" . print_r($project->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): {$project->getOfficeToString()}
"; // string|null + echo "Office (string): " . Util::objectToStr($project->getOffice()) . "
"; // string|null echo "Result: {$project->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "ShortName: {$project->getShortName()}
"; // string|null Short project description. echo "Status: {$project->getStatus()}
"; // Status|null Status of the project. echo "Touched: {$project->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. - echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($project->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of projects is PRJ. - echo "Type (string): {$project->getTypeToString()}
"; // string|null + echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($project->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of projects is ACT. + echo "Type (string): " . Util::objectToStr($project->getType()) . "
"; // string|null echo "UID: {$project->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($project->getVatCode(), true) . "

"; // VatCode|null The VAT code if one code will apply for all projects within the project. Note that if any VAT codes are - echo "VatCode (string): {$project->getVatCodeToString()}
"; // string|null defined on project level, these will apply regardless of what is defined on project level. + echo "VatCode (string): " . Util::objectToStr($project->getVatCode()) . "
"; // string|null defined on project level, these will apply regardless of what is defined on project level. $projectProjects = $project->getProjects(); // ProjectProjects|null ProjectProjects object. - echo "Authoriser (\\PhpTwinfield\\User):
" . print_r($projectProjects->getAuthoriser(), true) . "

"; // User|null A specific authoriser for a project. - echo "Authoriser (string): {$projectProjects->getAuthoriserToString()}
"; // string|null If "change" = allow then locked = false and inherit = false + echo "Authoriser (\\PhpTwinfield\\User):
" . print_r($projectProjects->getAuthoriser(), true) . "

"; // User|null A specific authoriser for an project. + echo "Authoriser (string): " . Util::objectToStr($projectProjects->getAuthoriser()) . "
"; // string|null If "change" = allow then locked = false and inherit = false echo "Authoriser Inherit (bool): {$projectProjects->getAuthoriserInherit()}
"; // bool|null - echo "Authoriser Inherit (string): {$projectProjects->getAuthoriserInheritToString()}
"; // string|null If "change" = disallow then locked = true and inherit = false + echo "Authoriser Inherit (string): " . Util::formatBoolean($projectProjects->getAuthoriserInherit()) . "
"; // string|null If "change" = disallow then locked = true and inherit = false echo "Authoriser Locked (bool): {$projectProjects->getAuthoriserLocked()}
"; // bool|null - echo "Authoriser Locked (string): {$projectProjects->getAuthoriserLockedToString()}
"; // string|null If "change" = inherit then locked = true and inherit = true - echo "Billable (bool): {$projectProjects->getBillable()}
"; // bool|null Choose to make a project billable (true) or not (false) and whether or not it should be included when calculating the "productivity" ratio (@forratio). - echo "Billable (string): {$projectProjects->getBillableToString()}
"; // string|null You could also decide that these settings should be inherited from project or user level (@inherit). + echo "Authoriser Locked (string): " . Util::formatBoolean($projectProjects->getAuthoriserLocked()) . "
"; // string|null If "change" = inherit then locked = true and inherit = true + echo "Billable (bool): {$projectProjects->getBillable()}
"; // bool|null Choose to make an project billable (true) or not (false) and whether or not it should be included when calculating the "productivity" ratio (@forratio). + echo "Billable (string): " . Util::formatBoolean($projectProjects->getBillable()) . "
"; // string|null You could also decide that these settings should be inherited from project or user level (@inherit). echo "Billable ForRatio (bool): {$projectProjects->getBillableForRatio()}
"; // bool|null You can also set whether a change of these settings is allowed or disallowed when a user is entering their timesheet (@locked). - echo "Billable ForRatio (string): {$projectProjects->getBillableForRatioToString()}
"; // string|null If "change" = allow then locked = false and inherit = false. + echo "Billable ForRatio (string): " . Util::formatBoolean($projectProjects->getBillableForRatio()) . "
"; // string|null If "change" = allow then locked = false and inherit = false. echo "Billable Inherit (bool): {$projectProjects->getBillableInherit()}
"; // bool|null - echo "Billable Inherit (string): {$projectProjects->getBillableInheritToString()}
"; // string|null If "change" = disallow then locked = true and inherit = false. + echo "Billable Inherit (string): " . Util::formatBoolean($projectProjects->getBillableInherit()) . "
"; // string|null If "change" = disallow then locked = true and inherit = false. echo "Billable Locked (bool): {$projectProjects->getBillableLocked()}
"; // bool|null - echo "Billable Locked (string): {$projectProjects->getBillableLockedToString()}
"; // string|null If "change" = inherit then locked = true and inherit = true - echo "Customer (\\PhpTwinfield\\Customer):
" . print_r($projectProjects->getCustomer(), true) . "

"; // Customer|null A project always needs to be linked to a customer. - echo "Customer (string): {$projectProjects->getCustomerToString()}
"; // string|null Choose to have the customer ‘inherited’ (from a project) or you can specify the customer here. + echo "Billable Locked (string): " . Util::formatBoolean($projectProjects->getBillableLocked()) . "
"; // string|null If "change" = inherit then locked = true and inherit = true + echo "Customer (\\PhpTwinfield\\Customer):
" . print_r($projectProjects->getCustomer(), true) . "

"; // Customer|null An project always needs to be linked to a customer. + echo "Customer (string): " . Util::objectToStr($projectProjects->getCustomer()) . "
"; // string|null Choose to have the customer ‘inherited’ (from a project) or you can specify the customer here. echo "Customer Inherit (bool): {$projectProjects->getCustomerInherit()}
"; // bool|null - echo "Customer Inherit (string): {$projectProjects->getCustomerInheritToString()}
"; // string|null If "change" = allow then locked = false and inherit = false + echo "Customer Inherit (string): " . Util::formatBoolean($projectProjects->getCustomerInherit()) . "
"; // string|null If "change" = allow then locked = false and inherit = false echo "Customer Locked (bool): {$projectProjects->getCustomerLocked()}
"; // bool|null If "change" = disallow then locked = true and inherit = false - echo "Customer Locked (string): {$projectProjects->getCustomerLockedToString()}
"; // string|null If "change" = inherit then locked = true and inherit = true + echo "Customer Locked (string): " . Util::formatBoolean($projectProjects->getCustomerLocked()) . "
"; // string|null If "change" = inherit then locked = true and inherit = true echo "Invoice Description: {$projectProjects->getInvoiceDescription()}
"; // string|null This field can be used to enter a longer project description which will be available on the invoice template. if ($projectProjects->hasMessages()) { // bool Object contains (error) messages true/false. @@ -194,16 +194,16 @@ } echo "Rate (\\PhpTwinfield\\Rate):
" . print_r($projectProjects->getRate(), true) . "

"; // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). - echo "Rate (string): {$projectProjects->getRateToString()}
"; // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). + echo "Rate (string): " . Util::objectToStr($projectProjects->getRate()) . "
"; // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). echo "Rate Inherit (bool): {$projectProjects->getRateInherit()}
"; // bool|null - echo "Rate Inherit (string): {$projectProjects->getRateInheritToString()}
"; // string|null If "change" = allow then locked = false and inherit = false + echo "Rate Inherit (string): " . Util::formatBoolean($projectProjects->getRateInherit()) . "
"; // string|null If "change" = allow then locked = false and inherit = false echo "Rate Locked (bool): {$projectProjects->getRateLocked()}
"; // bool|null If "change" = disallow then locked = true and inherit = false - echo "Rate Locked (string): {$projectProjects->getRateLockedToString()}
"; // string|null If "change" = inherit then locked = true and inherit = true + echo "Rate Locked (string): " . Util::formatBoolean($projectProjects->getRateLocked()) . "
"; // string|null If "change" = inherit then locked = true and inherit = true echo "Result: {$projectProjects->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "Valid From (\\DateTimeInterface):
" . print_r($projectProjects->getValidFrom(), true) . "

"; // DateTimeInterface|null A project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. - echo "Valid From (string): {$projectProjects->getValidFromToString()}
"; // string|null - echo "Valid Till (\\DateTimeInterface):
" . print_r($projectProjects->getValidTill(), true) . "

"; // DateTimeInterface|null A project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. - echo "Valid Till (string): {$projectProjects->getValidTillToString()}
"; // string|null + echo "Valid From (\\DateTimeInterface):
" . print_r($projectProjects->getValidFrom(), true) . "

"; // DateTimeInterface|null An project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. + echo "Valid From (string): " . Util::formatDate($projectProjects->getValidFrom()) . "
"; // string|null + echo "Valid Till (\\DateTimeInterface):
" . print_r($projectProjects->getValidTill(), true) . "

"; // DateTimeInterface|null An project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. + echo "Valid Till (string): " . Util::formatDate($projectProjects->getValidTill()) . "
"; // string|null $projectQuantities = $projectProjects->getQuantities(); // array|null Array of ProjectQuantity objects. @@ -211,9 +211,9 @@ echo "ProjectQuantity {$key}
"; echo "Billable (bool): {$projectQuantity->getBillable()}
"; // bool|null Is the quantity line billable or not. - echo "Billable (string): {$projectQuantity->getBillableToString()}
"; // string|null If "billable" = true and "change is not allowed" then locked = true + echo "Billable (string): " . Util::formatBoolean($projectQuantity->getBillable()) . "
"; // string|null If "billable" = true and "change is not allowed" then locked = true echo "Billable Locked (bool): {$projectQuantity->getBillableLocked()}
"; // bool|null If "billable" = true and "change is allowed" then locked = false - echo "Billable Locked (string): {$projectQuantity->getBillableLockedToString()}
"; // string|null + echo "Billable Locked (string): " . Util::formatBoolean($projectQuantity->getBillableLocked()) . "
"; // string|null if ($projectQuantity->hasMessages()) { // bool Object contains (error) messages true/false. echo "Messages: " . print_r($projectQuantity->getMessages(), true) . "
"; // Array|null (Error) messages. @@ -221,9 +221,9 @@ echo "Label: {$projectQuantity->getLabel()}
"; // string|null The label of the quantity. echo "Mandatory (bool): {$projectQuantity->getMandatory()}
"; // bool|null Is the quantity line mandatory or not. - echo "Mandatory (string): {$projectQuantity->getMandatoryToString()}
"; // string|null + echo "Mandatory (string): " . Util::formatBoolean($projectQuantity->getMandatory()) . "
"; // string|null echo "Rate (\\PhpTwinfield\\Rate):
" . print_r($projectQuantity->getRate(), true) . "

"; // Rate|null The rate. - echo "Rate (string): {$projectQuantity->getRateToString()}
"; // string|null + echo "Rate (string): " . Util::objectToStr($projectQuantity->getRate()) . "
"; // string|null echo "Result: {$projectQuantity->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). } } @@ -231,13 +231,13 @@ // Copy an existing Project to a new entity if ($executeCopy) { try { - $project = $projectApiConnector->get("P0001", $office); + $project = $projectApiConnector->get("P0000", $office); } catch (ResponseException $e) { $project = $e->getReturnedObject(); } $project->setCode(null); // string|null Set to null to let Twinfield assign a Dimension code based on the Dimension type mask - //$project->setCode('P0100'); // string|null Dimension code, must be compliant with the mask of the PRJ Dimension type. + //$project->setCode('P0100'); // string|null Dimension code, must be compliant with the mask of the ACT Dimension type. try { $projectCopy = $projectApiConnector->send($project); @@ -258,84 +258,68 @@ $project = new \PhpTwinfield\Project; // Required values for creating a new Project - // $project->setCode(null); // string|null Set to null to let Twinfield assign a Dimension code based on the Dimension type mask - //$project->setCode('P0100'); // string|null Dimension code, must be compliant with the mask of the PRJ Dimension type. + //$project->setCode('P0100'); // string|null Dimension code, must be compliant with the mask of the ACT Dimension type. $project->setName("Example Project"); // string|null Project description. $project->setOffice($office); // Office|null Office code. - $project->setOfficeFromString($officeCode); // string|null + $project->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null // Optional values for creating a new Project - $project->setShortName("ExmplPrj"); // string|null Short project description. + $project->setShortName("ExmplAct"); // string|null Short project description. //$project->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. - //$project->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case a project is in use, its status has been changed into hide. Hidden projects can be activated by using active. - //$project->setStatusFromString('active'); // string|null - //$project->setStatusFromString('deleted'); // string|null + //$project->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case an project is in use, its status has been changed into hide. Hidden projects can be activated by using active. $vatCode = new \PhpTwinfield\VatCode; $vatCode->setCode('VH'); $project->setVatCode($vatCode); // VatCode|null The VAT code if one code will apply for all projects within the project. Note that if any VAT codes are - $project->setVatCodeFromString('VH'); // string|null defined on project level, these will apply regardless of what is defined on project level. + $project->setVatCode(\PhpTwinfield\VatCode::fromCode('VH')); // string|null defined on project level, these will apply regardless of what is defined on project level. $projectProjects = new \PhpTwinfield\ProjectProjects; $authoriser = new \PhpTwinfield\User; $authoriser->setCode('TWINAPPS'); - $projectProjects->setAuthoriser($authoriser); // User|null A specific authoriser for a project. - $projectProjects->setAuthoriserFromString('TWINAPPS'); // string|null If "change" = allow then locked = false and inherit = false + $projectProjects->setAuthoriser($authoriser); // User|null A specific authoriser for an project. + $projectProjects->setAuthoriser(\PhpTwinfield\User::fromCode('TWINAPPS')); // string|null If "change" = allow then locked = false and inherit = false $projectProjects->setAuthoriserInherit(false); // bool|null - $projectProjects->setAuthoriserInheritFromString('false'); // string|null If "change" = disallow then locked = true and inherit = false $projectProjects->setAuthoriserLocked(false); // bool|null - $projectProjects->setAuthoriserLockedFromString('false'); // string|null If "change" = inherit then locked = true and inherit = true - $projectProjects->setBillable(false); // bool|null Choose to make a project billable (true) or not (false) and whether or not it should be included when calculating the "productivity" ratio (@forratio). - $projectProjects->setBillableFromString('false'); // string|null You could also decide that these settings should be inherited from project or user level (@inherit). + $projectProjects->setBillable(false); // bool|null Choose to make an project billable (true) or not (false) and whether or not it should be included when calculating the "productivity" ratio (@forratio). $projectProjects->setBillableForRatio(false); // bool|null You can also set whether a change of these settings is allowed or disallowed when a user is entering their timesheet (@locked). - $projectProjects->setBillableForRatioFromString('false'); // string|null If "change" = allow then locked = false and inherit = false. $projectProjects->setBillableInherit(false); // bool|null - $projectProjects->setBillableInheritFromString('false'); // string|null If "change" = disallow then locked = true and inherit = false. $projectProjects->setBillableLocked(false); // bool|null - $projectProjects->setBillableLockedFromString('false'); // string|null If "change" = inherit then locked = true and inherit = true $customer = new \PhpTwinfield\Customer; $customer->setCode('1000'); - //$projectProjects->setCustomer($customer); // Customer|null A project always needs to be linked to a customer. - //$projectProjects->setCustomerFromString('1000'); // string|null Choose to have the customer ‘inherited’ (from a project) or you can specify the customer here. + //$projectProjects->setCustomer($customer); // Customer|null An project always needs to be linked to a customer. + //$projectProjects->setCustomer(\PhpTwinfield\Customer::fromCode('1000')); // string|null Choose to have the customer ‘inherited’ (from a project) or you can specify the customer here. $projectProjects->setCustomerInherit(true); // bool|null - $projectProjects->setCustomerInheritFromString('true'); // string|null If "change" = allow then locked = false and inherit = false $projectProjects->setCustomerLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false - $projectProjects->setCustomerLockedFromString('true'); // string|null If "change" = inherit then locked = true and inherit = true $projectProjects->setInvoiceDescription('Example Invoice Description'); // string|null This field can be used to enter a longer project description which will be available on the invoice template. $rate = new \PhpTwinfield\Rate; $rate->setCode('DIRECT'); $projectProjects->setRate($rate); // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). - $projectProjects->setRateFromString('DIRECT'); // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). + $projectProjects->setRate(\PhpTwinfield\Rate::fromCode('DIRECT')); // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). $projectProjects->setRateInherit(false); // bool|null - $projectProjects->setRateInheritFromString('false'); // string|null If "change" = allow then locked = false and inherit = false $projectProjects->setRateLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false - $projectProjects->setRateLockedFromString('true'); // string|null If "change" = inherit then locked = true and inherit = true $validFrom = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); - $projectProjects->setValidFrom($validFrom); // DateTimeInterface|null A project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. - $projectProjects->setValidFromFromString('20190101'); // string|null + $projectProjects->setValidFrom($validFrom); // DateTimeInterface|null An project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. + $projectProjects->setValidFrom(Util::parseDate('20190101')); // string|null $validTill = \DateTime::createFromFormat('d-m-Y', '31-12-2019'); - $projectProjects->setValidTill($validTill); // DateTimeInterface|null A project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. - $projectProjects->setValidTillFromString('20191231'); // string|null + $projectProjects->setValidTill($validTill); // DateTimeInterface|null An project can be set to only be valid for certain dates. Users will then only be able to book hours to the project during these dates. + $projectProjects->setValidTill(Util::parseDate('20191231')); // string|null // The minimum amount of ProjectQuantities linked to a ProjectProjects object is 0, the maximum amount is 4 $projectQuantity = new \PhpTwinfield\ProjectQuantity; $projectQuantity->setBillable(false); // bool|null Is the quantity line billable or not. - $projectQuantity->setBillableFromString('false'); // string|null If "billable" = true and "change is not allowed" then locked = true $projectQuantity->setBillableLocked(false); // bool|null - $projectQuantity->setBillableLockedFromString('false'); // string|null If "billable" = true and "change is allowed" then locked = false $projectQuantity->setLabel('Example Quantity'); // string|null $projectQuantity->setMandatory(false); // bool|null Is the quantity line mandatory or not. - $projectQuantity->setMandatoryFromString('false'); // string|null $rate = new \PhpTwinfield\Rate; $rate->setCode('KILOMETERS'); $projectQuantity->setRate($rate); // Rate|null The rate. - $projectQuantity->setRateFromString('KILOMETERS'); // string|null + $projectQuantity->setRate(\PhpTwinfield\Rate::fromCode('KILOMETERS')); // string|null - $projectProjects->addQuantity($projectQuantity); // ProjectQuantity Add a ProjectQuantity object to the ProjectProjects object + $projectProjects->addQuantity($projectQuantity); // ProjectQuantity Add an ProjectQuantity object to the ProjectProjects object //$projectProjects->removeQuantity(0); // int Remove a quantity based on the index of the quantity within the array - $project->setProjects($projectProjects); // ProjectProjects Set the ProjectProjects object tot the Project object + $project->setProjects($projectProjects); // ProjectProjects Set the ProjectProjects object tot the Project object try { $projectNew = $projectApiConnector->send($project); diff --git a/examples/Supplier.php b/examples/Supplier.php index d2f08ffc..92bdc440 100644 --- a/examples/Supplier.php +++ b/examples/Supplier.php @@ -185,9 +185,9 @@ echo "EndPeriod: {$supplier->getEndPeriod()}
"; // int|null Determines together with endyear the period till which the dimension may be used. echo "EndYear: {$supplier->getEndYear()}
"; // int|null Determines together with endperiod the period till which the dimension may be used. echo "Group (\\PhpTwinfield\\DimensionGroup):
" . print_r($supplier->getGroup(), true) . "

"; // DimensionGroup|null Sets the dimension group. See Dimension group. - echo "Group (string): {$supplier->getGroupToString()}
"; // string|null + echo "Group (string): " . Util::objectToStr($supplier->getGroup()) . "
"; // string|null echo "InUse (bool): {$supplier->getInUse()}
"; // bool|null Indicates whether the balancesheet is used in a financial transaction or not. Read-only attribute. - echo "InUse (string): {$supplier->getInUseToString()}
"; // string|null + echo "InUse (string): " . Util::formatBoolean($supplier->getInUse()) . "
"; // string|null if ($supplier->hasMessages()) { // bool Object contains (error) messages true/false. echo "Messages: " . print_r($supplier->getMessages(), true) . "
"; // Array|null (Error) messages. @@ -195,7 +195,7 @@ echo "Name: {$supplier->getName()}
"; // string|null Name of the dimension. echo "Office (\\PhpTwinfield\\Office):
" . print_r($supplier->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): {$supplier->getOfficeToString()}
"; // string|null + echo "Office (string): " . Util::objectToStr($supplier->getOffice()) . "
"; // string|null echo "PaymentCondition:
"; // Sets the payment condition of a dimension. echo "PaymentCondition DiscountDays: {$supplier->getPaymentConditionDiscountDays()}
"; // int|null Number of discount days. echo "PaymentCondition DiscountPercentage: {$supplier->getPaymentConditionDiscountPercentage()}
"; // float|null Discount percentage. @@ -207,7 +207,7 @@ echo "Status: {$supplier->getStatus()}
"; // Status|null Status of the supplier. echo "Touched: {$supplier->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($supplier->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of suppliers is DEB. - echo "Type (string): {$supplier->getTypeToString()}
"; // string|null + echo "Type (string): " . Util::objectToStr($supplier->getType()) . "
"; // string|null echo "UID: {$supplier->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. echo "Website: {$supplier->getWebsite()}
"; // string|null Website of the dimension. @@ -218,9 +218,9 @@ echo "City: {$supplierAddress->getCity()}
"; // string|null City. echo "Country (\\PhpTwinfield\\Country):
" . print_r($supplierAddress->getCountry(), true) . "

"; // Country|null Country code. The ISO country codes are used. - echo "Country (string): {$supplierAddress->getCountryToString()}
"; // string|null + echo "Country (string): " . Util::objectToStr($supplierAddress->getCountry()) . "
"; // string|null echo "Default (bool): {$supplierAddress->getDefault()}
"; // bool|null Is this the default address, only one default address is possible. - echo "Default (string): {$supplierAddress->getDefaultToString()}
"; // string|null + echo "Default (string): " . Util::formatBoolean($supplierAddress->getDefault()) . "
"; // string|null echo "Email: {$supplierAddress->getEmail()}
"; // string|null echo "Field1: {$supplierAddress->getField1()}
"; // string|null User defined fields, the labels are configured in the Dimension type. echo "Field2: {$supplierAddress->getField2()}
"; // string|null User defined fields, the labels are configured in the Dimension type. @@ -255,12 +255,12 @@ echo "BicCode: {$supplierBank->getBicCode()}
"; // string|null BIC code. echo "Blocked (bool): {$supplierBank->getBlocked()}
"; // bool|null - echo "Blocked (string): {$supplierBank->getBlockedToString()}
"; // string|null + echo "Blocked (string): " . Util::formatBoolean($supplierBank->getBlocked()) . "
"; // string|null echo "City: {$supplierBank->getCity()}
"; // string|null City. echo "Country (\\PhpTwinfield\\Country):
" . print_r($supplierBank->getCountry(), true) . "

"; // Country|null Bank country code. The ISO country codes are used. - echo "Country (string): {$supplierBank->getCountryToString()}
"; // string|null + echo "Country (string): " . Util::objectToStr($supplierBank->getCountry()) . "
"; // string|null echo "Default (bool): {$supplierBank->getDefault()}
"; // bool|null Is this the default bank account, only one default bank account is possible. - echo "Default (string): {$supplierBank->getDefaultToString()}
"; // string|null + echo "Default (string): " . Util::formatBoolean($supplierBank->getDefault()) . "
"; // string|null echo "ID: {$supplierBank->getID()}
"; // int|null Sequence number of the bank account line. When adding a new bank, do not supply the @id. When changing a bank account, supply the corresponding @id. echo "IBAN: {$supplierBank->getIban()}
"; // string|null IBAN account number. @@ -288,21 +288,21 @@ } echo "PayAvailable (bool): {$supplierFinancials->getPayAvailable()}
"; // bool|null Determines if direct debit is possible. - echo "PayAvailable (string): {$supplierFinancials->getPayAvailableToString()}
"; // string|null + echo "PayAvailable (string): " . Util::formatBoolean($supplierFinancials->getPayAvailable()) . "
"; // string|null echo "PayCode (\\PhpTwinfield\\PayCode):
" . print_r($supplierFinancials->getPayCode(), true) . "

"; // PayCode|null The code of the payment type in case direct debit is possible. - echo "PayCode (string): {$supplierFinancials->getPayCodeToString()}
"; // string|null + echo "PayCode (string): " . Util::objectToStr($supplierFinancials->getPayCode()) . "
"; // string|null echo "PayCodeID: {$supplierFinancials->getPayCodeID()}
"; // string|null echo "RelationsReference: {$supplierFinancials->getRelationsReference()}
"; // string|null External supplier number. echo "Result: {$supplierFinancials->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "SubAnalyse: {$supplierFinancials->getSubAnalyse()}
"; // SubAnalyse|null Fixed value false. - echo "SubstituteWith (\\PhpTwinfield\\Dummy):
" . print_r($supplierFinancials->getSubstituteWith(), true) . "

"; // Dummy|null Default supplier balancesheet account. - echo "SubstituteWith (string): {$supplierFinancials->getSubstituteWithToString()}
"; // string|null + echo "SubstituteWith (\\PhpTwinfield\\GeneralLedger):
" . print_r($supplierFinancials->getSubstituteWith(), true) . "

"; // GeneralLedger|null Default supplier balancesheet account. + echo "SubstituteWith (string): " . Util::objectToStr($supplierFinancials->getSubstituteWith()) . "
"; // string|null echo "SubstituteWithID: {$supplierFinancials->getSubstituteWithID()}
"; // string|null echo "SubstitutionLevel: {$supplierFinancials->getSubstitutionLevel()}
"; // int|null Level of the balancesheet account. Fixed value 1. echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($supplierFinancials->getVatCode(), true) . "

"; // VatCode|null Default VAT code. - echo "VatCode (string): {$supplierFinancials->getVatCodeToString()}
"; // string|null + echo "VatCode (string): " . Util::objectToStr($supplierFinancials->getVatCode()) . "
"; // string|null echo "VatCode Fixed (bool): {$supplierFinancials->getVatCodeFixed()}
"; // bool|null - echo "VatCode Fixed (string): {$supplierFinancials->getVatCodeFixedToString()}
"; // string|null + echo "VatCode Fixed (string): " . Util::formatBoolean($supplierFinancials->getVatCodeFixed()) . "
"; // string|null $supplierChildValidations = $supplierFinancials->getChildValidations(); // array|null Array of SupplierChildValidations objects. @@ -326,9 +326,9 @@ echo "SupplierPostingRule {$key}
"; echo "Amount (\\Money\\Money):
" . print_r($supplierPostingRule->getAmount(), true) . "

"; // Money|null Amount. - echo "Amount (float): {$supplierPostingRule->getAmountToFloat()}
"; // float|null + echo "Amount (string): " . Util::formatMoney($supplierPostingRule->getAmount()) . "
"; // string|null echo "Currency (\\PhpTwinfield\\Currency):
" . print_r($supplierPostingRule->getCurrency(), true) . "

"; // Currency|null Currency. - echo "Currency (string): {$supplierPostingRule->getCurrencyToString()}
"; // string|null + echo "Currency (string): " . Util::objectToStr($supplierPostingRule->getCurrency()) . "
"; // string|null echo "Description: {$supplierPostingRule->getDescription()}
"; // string|null Description. echo "ID: {$supplierPostingRule->getID()}
"; // int|null Sequence number of the posting rule. Fixed value 1. @@ -346,13 +346,13 @@ echo "Description: {$supplierLine->getDescription()}
"; // string|null Description. echo "Dimension1 (\\PhpTwinfield\\GeneralLedger):
" . print_r($supplierLine->getDimension1(), true) . "

"; // GeneralLedger|null General ledger. - echo "Dimension1 (string): {$supplierLine->getDimension1ToString()}
"; // string|null + echo "Dimension1 (string): " . Util::objectToStr($supplierLine->getDimension1()) . "
"; // string|null echo "Dimension1ID: {$supplierLine->getDimension1ID()}
"; // string|null echo "Dimension2 (\\PhpTwinfield\\CostCenter):
" . print_r($supplierLine->getDimension2(), true) . "

"; // CostCenter|null Cost center. - echo "Dimension2 (string): {$supplierLine->getDimension2ToString()}
"; // string|null + echo "Dimension2 (string): " . Util::objectToStr($supplierLine->getDimension2()) . "
"; // string|null echo "Dimension2ID: {$supplierLine->getDimension2ID()}
"; // string|null - echo "Dimension3 (\\PhpTwinfield\\Dummy):
" . print_r($supplierLine->getDimension3(), true) . "

"; // Dummy|null Project or asset. - echo "Dimension3 (string): {$supplierLine->getDimension3ToString()}
"; // string|null + echo "Dimension3:
" . print_r($supplierLine->getDimension3(), true) . "

"; // Project|Activity|null Project or asset. + echo "Dimension3 (string): " . Util::objectToStr($supplierLine->getDimension3()) . "
"; // string|null echo "Dimension3ID: {$supplierLine->getDimension3ID()}
"; // string|null if ($supplierLine->hasMessages()) { // bool Object contains (error) messages true/false. @@ -360,11 +360,11 @@ } echo "Office (\\PhpTwinfield\\Office):
" . print_r($supplierLine->getOffice(), true) . "

"; // Office|null Destination company. - echo "Office (string): {$supplierLine->getOfficeToString()}
"; // string|null + echo "Office (string): " . Util::objectToStr($supplierLine->getOffice()) . "
"; // string|null echo "Ratio: {$supplierLine->getRatio()}
"; // float|null The ratio of the posting rule line. echo "Result: {$supplierLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($supplierLine->getVatCode(), true) . "

"; // VatCode|null VAT code. - echo "VatCode (string): {$supplierLine->getVatCodeToString()}
"; // string|null + echo "VatCode (string): " . Util::objectToStr($supplierLine->getVatCode()) . "
"; // string|null } } } @@ -410,7 +410,7 @@ //$supplier->setCode('2100'); // string|null Dimension code, must be compliant with the mask of the DEB Dimension type. $supplier->setName("Example Supplier"); // string|null Name of the dimension. $supplier->setOffice($office); // Office|null Office code. - $supplier->setOfficeFromString($officeCode); // string|null + $supplier->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null // Optional values for creating a new Supplier $supplier->setBeginPeriod(0); // int|null Determines together with beginyear the period from which the dimension may be used. @@ -420,40 +420,35 @@ $supplier->setShortName("ExmplCust"); // string|null Short name of the dimension. //$supplier->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. //$supplier->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case a dimension that is used in a transaction is deleted, its status has been changed into hide. Hidden dimensions can be activated by using active. - //$supplier->setStatusFromString('active'); // string|null - //$supplier->setStatusFromString('deleted'); // string|null $supplier->setWebsite("www.example.com"); // string|null Website of the dimension. $dimensionGroup = new \PhpTwinfield\DimensionGroup; $dimensionGroup->setCode('DIMGROUP'); //$supplier->setGroup($dimensionGroup); // DimensionGroup|null Sets the dimension group. See Dimension group. - //$supplier->setGroupFromString("DIMGROUP"); // string|null + //$supplier->setGroup(\PhpTwinfield\DimensionGroup::fromCode("DIMGROUP")); // string|null $supplier->setPaymentConditionDiscountDays(3); // int|null Number of discount days. $supplier->setPaymentConditionDiscountPercentage(25); // int|null Discount percentage. $supplier->setRemittanceAdviceSendMail("test@example.com"); // string|null Mandatory if sendtype = ByEmail, remittance advice will be sent using this e-mail address. $supplier->setRemittanceAdviceSendType(\PhpTwinfield\Enums\RemittanceAdviceSendType::BYEMAIL()); // RemittanceAdviceSendMail|null To file manager, By e-mail - $supplier->setRemittanceAdviceSendTypeFromString('ByEmail'); // string|null $supplierFinancials = new \PhpTwinfield\SupplierFinancials; $supplierFinancials->setDueDays(14); // int|null The number of due days. $supplierFinancials->setMeansOfPayment(\PhpTwinfield\Enums\MeansOfPayment::PAYMENTFILE()); // MeansOfPayment|null The option none is only allowed in case payavailable is set to false. The option paymentfile is only allowed in case payavailable is set to true. - $supplierFinancials->setMeansOfPaymentFromString('paymentfile'); // string|null $supplierFinancials->setPayAvailable(true); // bool|null Determines if direct debit is possible. - $supplierFinancials->setPayAvailableFromString('true'); // string|null $payCode = new \PhpTwinfield\PayCode; $payCode->setCode('SEPANLCT'); $supplierFinancials->setPayCode($payCode); // PayCode|null The code of the payment type in case direct debit is possible. - $supplierFinancials->setPayCodeFromString('SEPANLCT'); // string|null + $supplierFinancials->setPayCode(\PhpTwinfield\PayCode::fromCode('SEPANLCT')); // string|null $substituteWith = new \PhpTwinfield\GeneralLedger; $substituteWith->getCode('1535'); $supplierFinancials->setSubstituteWith($substituteWith); // GeneralLedger|null Default supplier balancesheet account. - $supplierFinancials->setSubstituteWithFromString('1535'); // string|null + $supplierFinancials->setSubstituteWith(\PhpTwinfield\GeneralLedger::fromCode('1535')); // string|null $vatCode = new \PhpTwinfield\VatCode; $vatCode->setCode('IH'); $supplierFinancials->setVatCode($vatCode); // VatCode|null Default VAT code. - $supplierFinancials->setVatCodeFromString('IH'); // string|null + $supplierFinancials->setVatCode(\PhpTwinfield\VatCode::fromCode('IH')); // string|null $supplier->setFinancials($supplierFinancials); // SupplierFinancials Set the SupplierFinancials object tot the Supplier object @@ -462,9 +457,8 @@ $country = new \PhpTwinfield\Country; $country->setCode('NL'); $supplierAddress->setCountry($country); // Country|null Country code. The ISO country codes are used. - $supplierAddress->setCountryFromString('NL'); // string|null + $supplierAddress->setCountry(\PhpTwinfield\Country::fromCode('NL')); // string|null $supplierAddress->setDefault(true); // bool|null Is this the default address, only one default address is possible. - $supplierAddress->setDefaultFromString('true'); // string|null $supplierAddress->setEmail('test@example.com'); // string|null $supplierAddress->setField1(''); // string|null User defined fields, the labels are configured in the Dimension type. $supplierAddress->setField2(''); // string|null User defined fields, the labels are configured in the Dimension type. @@ -478,7 +472,6 @@ $supplierAddress->setTelefax('012-3456789'); // string|null Fax number. $supplierAddress->setTelephone('987-654321'); // string|null Telephone number. $supplierAddress->setType(\PhpTwinfield\Enums\AddressType::INVOICE()); // AddressType|null The type of the address. - $supplierAddress->setTypeFromString('invoice'); // string|null $supplier->addAddress($supplierAddress); // SupplierAddress Add a SupplierAddress object to the Supplier object //$supplier->removeAddress(0); // int Remove an address based on the index of the address within the array @@ -491,14 +484,12 @@ $supplierBank->setBankName('Example Bank'); // string|null Bank name. $supplierBank->setBicCode('ABNANL2A'); // string|null BIC code. $supplierBank->setBlocked(false); // bool|null - $supplierBank->setBlockedFromString('false'); // string|null $supplierBank->setCity('Amsterdam'); // string|null City. $country = new \PhpTwinfield\Country; $country->setCode('NL'); $supplierBank->setCountry($country); // Country|null Bank country code. The ISO country codes are used. - $supplierBank->setCountryFromString('NL'); // string|null + $supplierBank->setCountry(\PhpTwinfield\Country::fromCode('NL')); // string|null $supplierBank->setDefault(true); // bool|null Is this the default bank account, only one default bank account is possible. - $supplierBank->setDefaultFromString('true'); // string|null $supplierBank->setID(null); // int|null Sequence number of the bank account line. When adding a new bank, do not supply the @id. When changing a bank account, supply the corresponding @id. $supplierBank->setIban(null); // string|null IBAN account number. $supplierBank->setNatBicCode('NL'); // string|null National bank code. @@ -509,41 +500,38 @@ //$supplier->removeBank(0); // int Remove a bank based on the index of the bank within the array $supplierPostingRule = new \PhpTwinfield\SupplierPostingRule; - $supplierPostingRule->setAmount(\Money\Money::EUR(10000)); // Money|null Amount. - $supplierPostingRule->setAmountFromFloat(100); // float|null + $supplierPostingRule->setAmount(\Money\Money::EUR(10000)); // Money|null Amount. (Equals 100.00 EUR) $currency = new \PhpTwinfield\Currency; $currency->setCode('EUR'); $supplierPostingRule->setCurrency($currency); // Currency|null Currency. - $supplierPostingRule->setCurrencyFromString('EUR'); // string|null + $supplierPostingRule->setCurrency(\PhpTwinfield\Currency::fromCode('EUR')); // string|null $supplierPostingRule->setDescription('Example PostingRule'); // string|null Description. $supplierPostingRule->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating active should be used. For deleting deleted should be used. //$supplierPostingRule->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null - $supplierPostingRule->setStatusFromString('active'); // string|null - //$supplierPostingRule->setStatusFromString('deleted'); // string|null $supplierLine = new \PhpTwinfield\SupplierLine; $supplierLine->setDescription('Example Line'); // string|null Description. $dimension1 = new \PhpTwinfield\GeneralLedger; $dimension1->setCode('1535'); $supplierLine->setDimension1($dimension1); // GeneralLedger|null General ledger. - $supplierLine->setDimension1FromString('1535'); // string|null + $supplierLine->setDimension1(\PhpTwinfield\GeneralLedger::fromCode('1535')); // string|null $costCenter = new \PhpTwinfield\CostCenter; $costCenter->setCode('00000'); $supplierLine->setDimension2($costCenter); // CostCenter|null Cost center. - $supplierLine->setDimension2FromString ('00000'); // string|null + $supplierLine->setDimension2(\PhpTwinfield\CostCenter::fromCode('00000')); // string|null $activity = new \PhpTwinfield\Activity; $activity->setCode('P0000'); - $supplierLine->setDimension3($activity); // Dummy|null Project or asset. - $supplierLine->setDimension3FromString('P0000'); // string|null + $supplierLine->setDimension3($activity); // Project|Activity|null Project or asset. + $supplierLine->setDimension3(\PhpTwinfield\Activity::fromCode('P0000')); // string|null $destOffice = new \PhpTwinfield\Office; $destOffice->setCode('NLA0000001'); //$supplierLine->setOffice($destOffice); // Office|null Destination company. - //$supplierLine->setOfficeFromString('NLA0000001'); // string|null + //$supplierLine->setOffice(\PhpTwinfield\Office::fromCode('NLA0000001')); // string|null $supplierLine->setRatio(1); // float|null The ratio of the posting rule line. $vatCode = new \PhpTwinfield\VatCode; $vatCode->setCode('IH'); $supplierLine->setVatCode($vatCode); // VatCode|null Default VAT code. - $supplierLine->setVatCodeFromString('IH'); // string|null + $supplierLine->setVatCode(\PhpTwinfield\VatCode::fromCode('IH')); // string|null $supplierPostingRule->addLine($supplierLine); // SupplierLine Add a SupplierLine object to the SupplierPostingRule object //$supplierPostingRule->removeLine(0); // int Remove a line based on the index of the line within the array diff --git a/src/Mappers/CustomerMapper.php b/src/Mappers/CustomerMapper.php index 3ec8bdfe..bc423583 100644 --- a/src/Mappers/CustomerMapper.php +++ b/src/Mappers/CustomerMapper.php @@ -92,7 +92,7 @@ public static function map(Response $response, AuthenticatedConnection $connecti ->setPayCode(self::parseObjectAttribute(\PhpTwinfield\PayCode::class, $customerFinancials, $financialsElement, 'paycode', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setSubAnalyse(self::parseEnumAttribute(\PhpTwinfield\Enums\SubAnalyse::class, self::getField($financialsElement, 'subanalyse', $customerFinancials))) ->setSubstitutionLevel(self::getField($financialsElement, 'substitutionlevel', $customerFinancials)) - ->setSubstituteWith(self::parseObjectAttribute(null, $customerFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setSubstituteWith(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $customerFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $customerFinancials, $financialsElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); // Set the financials elements from the financials element attributes diff --git a/src/Mappers/SupplierMapper.php b/src/Mappers/SupplierMapper.php index eacb4333..2ed9d494 100644 --- a/src/Mappers/SupplierMapper.php +++ b/src/Mappers/SupplierMapper.php @@ -78,7 +78,7 @@ public static function map(Response $response) ->setRelationsReference(self::getField($financialsElement, 'relationsreference', $supplierFinancials)) ->setSubAnalyse(self::parseEnumAttribute(\PhpTwinfield\Enums\SubAnalyse::class, self::getField($financialsElement, 'subanalyse', $supplierFinancials))) ->setSubstitutionLevel(self::getField($financialsElement, 'substitutionlevel', $supplierFinancials)) - ->setSubstituteWith(self::parseObjectAttribute(null, $supplierFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setSubstituteWith(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $supplierFinancials, $financialsElement, 'substitutewith', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $supplierFinancials, $financialsElement, 'vatcode', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); // Set the financials elements from the financials element attributes From 975f06c29b4f2cc413ce08e4ec47aaa27c3abb28 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 23 Jun 2019 21:16:54 +0200 Subject: [PATCH 354/388] Update readme.md --- readme.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index 9e484f43..fb7c1e68 100644 --- a/readme.md +++ b/readme.md @@ -53,11 +53,11 @@ support for another resource. | [Suppliers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Supplier](examples/Supplier.php) | | | | | | | | | | Transactions | | | | | | | -[Bank Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | | -[Cash Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/CashTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | | -[Journal Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/JournalTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | | -[Purchase Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | | -[Sale Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | | +[Bank Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankTransactions) | :white_check_mark: | | :white_check_mark: | | :white_check_mark: | [Bank Transaction](examples/BankTransaction.php) | +[Cash Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/CashTransactions) | :white_check_mark: | | :white_check_mark: | | :white_check_mark: | [Cash Transaction](examples/CashTransaction.php) | +[Journal Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/JournalTransactions) | :white_check_mark: | | :white_check_mark: | | :white_check_mark: | [Journal Transaction](examples/JournalTransaction.php) | +[Purchase Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions) | :white_check_mark: | | :white_check_mark: | | :white_check_mark: | [Purchase Transaction](examples/PurchaseTransaction.php) | +[Sale Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions) | :white_check_mark: | | :white_check_mark: | | :white_check_mark: | [Sales Transaction](examples/SalesTransaction.php) | | | | | | | | | | [Users](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Users) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | [User](examples/User.php) | | User Roles | | :white_check_mark: | | | :white_check_mark: | [User Role](examples/UserRole.php) | From f719b89ec3681f9ba294af71639dba18f2bad84d Mon Sep 17 00:00:00 2001 From: iranl Date: Mon, 24 Jun 2019 22:27:26 +0200 Subject: [PATCH 355/388] Upload --- examples/Activity.php | 9 +- examples/Article.php | 2 +- examples/CashBankBook.php | 2 +- examples/CostCenter.php | 2 +- examples/Country.php | 2 +- examples/Currency.php | 2 +- examples/Customer.php | 2 +- examples/DimensionGroup.php | 2 +- examples/DimensionType.php | 2 +- examples/GeneralLedger.php | 2 +- examples/Invoice.php | 6 +- examples/InvoiceType.php | 2 +- examples/PayCode.php | 2 +- examples/Project.php | 9 +- examples/Rate.php | 2 +- examples/Supplier.php | 2 +- examples/User.php | 166 +++++++++++++++++++++++++++++++++++ examples/UserRole.php | 2 +- examples/VatCode.php | 2 +- examples/VatGroup.php | 2 +- examples/VatGroupCountry.php | 2 +- readme.md | 10 +-- src/Fields/RateField.php | 2 +- src/Mappers/UserMapper.php | 6 +- 24 files changed, 205 insertions(+), 37 deletions(-) create mode 100644 examples/User.php diff --git a/examples/Activity.php b/examples/Activity.php index f2252058..d13cc1f2 100644 --- a/examples/Activity.php +++ b/examples/Activity.php @@ -103,13 +103,14 @@ /* Activity * \PhpTwinfield\Activity * Available getters: getBehaviour, getCode, getInUse, getMessages, getName, getOffice, getResult, getShortName, getStatus, getTouched, getType, getUID, getVatCode, hasMessages, getProjects - * Available setters: setBehaviour, setCode, setName, setOffice, setShortName, setStatus, setType, setVatCode, setProjects + * Available setters: fromCode, setBehaviour, setCode, setName, setOffice, setShortName, setStatus, setType, setVatCode, setProjects */ /* ActivityProjects * \PhpTwinfield\ActivityProjects - * Available getters: getAuthoriser, getAuthoriserInherit, getAuthoriserLocked, getBillable, getBillableForRatio, getBillableInherit, getBillableLocked, getCustomer, getCustomerInherit, getCustomerLocked, getInvoiceDescription, getMessages, getRate, getRateInherit, - * getRateLocked, getResult, getValidFrom, getValidTill, hasMessages, getQuantities + * Available getters: getAuthoriser, getAuthoriserToString, getAuthoriserInherit, getAuthoriserInheritToString, getAuthoriserLocked, getAuthoriserLockedToString, getBillable, getBillableToString, getBillableForRatio, getBillableForRatioToString, + * getBillableInherit, getBillableInheritToString, getBillableLocked, getBillableLockedToString, getCustomer, getCustomerToString, getCustomerInherit, getCustomerInheritToString, getCustomerLocked, getCustomerLockedToString, getInvoiceDescription, getMessages, + * getRate, getRateToString, getRateInherit, getRateInheritToString, getRateLocked, getRateLockedToString, getResult, getValidFrom, getValidTill, hasMessages, getQuantities * * Available setters: setAuthoriser, setAuthoriserInherit, setAuthoriserLocked, setBillable, setBillableForRatio, setBillableInherit, setBillableLocked, setCustomer, setCustomerInherit, setCustomerLocked, setInvoiceDescription, setRate, setRateInherit, * setRateLocked, setValidFrom, setValidTill, addQuantity, removeQuantity @@ -118,7 +119,7 @@ /* ActivityQuantity * \PhpTwinfield\ActivityQuantity - * Available getters: getBillable, getBillableLocked, getLabel, getMandatory, getMessages, getRate, getResult, hasMessages + * Available getters: getBillable, getBillableToString, getBillableLocked, getBillableLockedToString, getLabel, getMandatory, getMessages, getRate, getRateToString, getResult, hasMessages * Available setters: setBillable, setBillableLocked, setLabel, setMandatory, setRate */ diff --git a/examples/Article.php b/examples/Article.php index 04c4c51f..58784619 100644 --- a/examples/Article.php +++ b/examples/Article.php @@ -96,7 +96,7 @@ * Available getters: getAllowChangePerformanceType, getAllowChangeUnitsPrice, getAllowChangeVatCode, getAllowDecimalQuantity, getAllowDiscountOrPremium, * getAllowDiscountOrPremiumToString, getCode, getMessages, getName, getOffice, getPercentage, getPerformanceType, getResult, getShortName, getStatus, getType, getUnitNamePlural, getUnitNameSingular, getVatCode, hasMessages, getLines * - * Available setters: setAllowChangePerformanceType, setAllowChangeUnitsPrice, setAllowChangeVatCode, setAllowDecimalQuantity, setAllowDiscountOrPremium, + * Available setters: fromCode, setAllowChangePerformanceType, setAllowChangeUnitsPrice, setAllowChangeVatCode, setAllowDecimalQuantity, setAllowDiscountOrPremium, * setCode, setName, setOffice, setPercentage, setPerformanceType, setShortName, setStatus, setType, setUnitNamePlural, setUnitNameSingular, setVatCode, addLine, removeLine * */ diff --git a/examples/CashBankBook.php b/examples/CashBankBook.php index 464f2607..fb0de735 100644 --- a/examples/CashBankBook.php +++ b/examples/CashBankBook.php @@ -79,7 +79,7 @@ /* CashBankBook * \PhpTwinfield\CashBankBook * Available getters: getCode, getName, getShortName - * Available setters: setCode, setName, setShortName + * Available setters: fromCode, setCode, setName, setShortName */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { diff --git a/examples/CostCenter.php b/examples/CostCenter.php index d85781c5..ba3feb02 100644 --- a/examples/CostCenter.php +++ b/examples/CostCenter.php @@ -100,7 +100,7 @@ /* CostCenter * \PhpTwinfield\CostCenter * Available getters: getBehaviour, getCode, getInUse, getMessages, getName, getOffice, getResult, getShortName, getStatus, getTouched, getType, getUID, hasMessages - * Available setters: setBehaviour, setCode, setName, setOffice, setShortName, setStatus, setType + * Available setters: fromCode, setBehaviour, setCode, setName, setOffice, setShortName, setStatus, setType */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { diff --git a/examples/Country.php b/examples/Country.php index 48caf03b..5dfdcbba 100644 --- a/examples/Country.php +++ b/examples/Country.php @@ -73,7 +73,7 @@ /* Country * \PhpTwinfield\Country * Available getters: getCode, getName, getShortName - * Available setters: setCode, setName, setShortName + * Available setters: fromCode, setCode, setName, setShortName */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { diff --git a/examples/Currency.php b/examples/Currency.php index 7d6dd494..660ef404 100644 --- a/examples/Currency.php +++ b/examples/Currency.php @@ -86,7 +86,7 @@ /* Currency * \PhpTwinfield\Currency * Available getters: getCode, getMessages, getName, getOffice, getResult, getShortName, getStatus, hasMessages, getRates - * Available setters: setCode, setName, setOffice, setShortName, setStatus, addRate, removeRate + * Available setters: fromCode, setCode, setName, setOffice, setShortName, setStatus, addRate, removeRate */ /* CurrencyRate diff --git a/examples/Customer.php b/examples/Customer.php index 952b472a..f191bdf6 100644 --- a/examples/Customer.php +++ b/examples/Customer.php @@ -114,7 +114,7 @@ * Available getters: getBeginPeriod, getBeginYear, getBehaviour, getCode, getDiscountArticle, getDiscountArticleID, getEndPeriod, getEndYear, getGroup, getInUse, getMessages, getName, getOffice, * getPaymentConditionDiscountDays, getPaymentConditionDiscountPercentage, getRemittanceAdviceSendMail, getRemittanceAdviceSendType, getResult, getShortName, getStatus, getTouched, getType, getUID, getWebsite, hasMessages, getAddresses, getBanks, getCreditManagement, getFinancials, getPostingRules * - * Available setters: setBeginPeriod, setBeginYear, setBehaviour, setCode, setDiscountArticle, setDiscountArticleID, setEndPeriod, setEndYear, setGroup, setName, setOffice, setPaymentConditionDiscountDays, + * Available setters: fromCode, setBeginPeriod, setBeginYear, setBehaviour, setCode, setDiscountArticle, setDiscountArticleID, setEndPeriod, setEndYear, setGroup, setName, setOffice, setPaymentConditionDiscountDays, * setPaymentConditionDiscountPercentage, setRemittanceAdviceSendMail, setRemittanceAdviceSendType, setShortName, setStatus, setType, setWebsite, setCreditManagement, setFinancials, addAddress, addBank, addPostingRule, removeAddress, removeBank, removePostingRule * */ diff --git a/examples/DimensionGroup.php b/examples/DimensionGroup.php index fce9c0bb..f5847bee 100644 --- a/examples/DimensionGroup.php +++ b/examples/DimensionGroup.php @@ -96,7 +96,7 @@ /* DimensionGroup * \PhpTwinfield\DimensionGroup * Available getters: getCode, getMessages, getName, getOffice, getResult, getShortName, getStatus, hasMessages, getDimensions - * Available setters: setCode, setName, setOffice, setShortName, setStatus, addDimension,removeDimension + * Available setters: fromCode, setCode, setName, setOffice, setShortName, setStatus, addDimension,removeDimension */ /* DimensionGroupDimension diff --git a/examples/DimensionType.php b/examples/DimensionType.php index 8491acd8..d13021ba 100644 --- a/examples/DimensionType.php +++ b/examples/DimensionType.php @@ -94,7 +94,7 @@ /* DimensionType * \PhpTwinfield\DimensionType * Available getters: getCode, getMask, getMessages, getName, getOffice, getResult, getShortName, getStatus, hasMessages, getAddress, getLevels - * Available setters: setCode, setMask, setName, setOffice, setShortName, setStatus, setAddress, setLevels + * Available setters: fromCode, setCode, setMask, setName, setOffice, setShortName, setStatus, setAddress, setLevels */ /* DimensionTypeLevels diff --git a/examples/GeneralLedger.php b/examples/GeneralLedger.php index f292cee9..5e4fa60b 100644 --- a/examples/GeneralLedger.php +++ b/examples/GeneralLedger.php @@ -105,7 +105,7 @@ /* GeneralLedger * \PhpTwinfield\GeneralLedger * Available getters: getBeginPeriod, getBeginYear, getBehaviour, getCode, getEndPeriod, getEndYear, getGroup, getInUse, getMessages, getName, getOffice, getResult, getShortName, getStatus, getTouched, getType, getWebsite, hasMessages, getFinancials - * Available setters: setBeginPeriod, setBeginYear, setBehaviour, setCode, setEndPeriod, setEndYear, setGroup, setName, setOffice, setShortName, setStatus, setType, setFinancials + * Available setters: fromCode, setBeginPeriod, setBeginYear, setBehaviour, setCode, setEndPeriod, setEndYear, setGroup, setName, setOffice, setShortName, setStatus, setType, setFinancials */ /* GeneralLedgerFinancials diff --git a/examples/Invoice.php b/examples/Invoice.php index da2a9799..3cca3160 100644 --- a/examples/Invoice.php +++ b/examples/Invoice.php @@ -97,10 +97,10 @@ /* Invoice * \PhpTwinfield\Invoice - * Available getters: getBank, getCalculateOnly, getCurrency, getCustomer, getCustomerName, getDebitCredit, getDeliverAddressNumber, getDueDate, getFinancialCode, getFinancialNumber, getFooterText, getHeaderText, getInvoiceAddressNumber, getInvoiceAmount, getInvoiceDate, getInvoiceNumber, getInvoiceType, getMessages, getOffice, getPaymentMethod, + * Available getters: getBank, getCalculateOnly, getCurrency, getCustomer, getCustomerToString, getCustomerName, getDebitCredit, getDeliverAddressNumber, getDueDate, getFinancialCode, getFinancialNumber, getFooterText, getHeaderText, getInvoiceAddressNumber, getInvoiceAmount, getInvoiceAmountToFloat, getInvoiceDate, getInvoiceNumber, getInvoiceType, getMessages, getOffice, getPaymentMethod, * getPerformanceDate, getPeriod, getPeriodRaiseWarning, getRaiseWarning, getResult, getStatus, hasMessages, getLines, getMatchReference, getTotals, getVatLines * - * Available setters: setBank, setCalculateOnly, setCurrency, setCustomer, setCustomerName, setDebitCredit, setDeliverAddressNumber, setDueDate, setFinancialCode, setFinancialNumber, setFooterText, setHeaderText, setInvoiceAddressNumber, setInvoiceAmount, setInvoiceDate, setInvoiceNumber, setInvoiceType, setOffice, + * Available setters: fromCode, setBank, setCalculateOnly, setCurrency, setCustomer, setCustomerName, setDebitCredit, setDeliverAddressNumber, setDueDate, setFinancialCode, setFinancialNumber, setFooterText, setHeaderText, setInvoiceAddressNumber, setInvoiceAmount, setInvoiceDate, setInvoiceNumber, setInvoiceType, setOffice, * setPaymentMethod, setPerformanceDate, setPeriod, setPeriodRaiseWarning, setRaiseWarning, setStatus, setTotals, addLine, addVatLine, removeLine, removeVatLine * */ @@ -113,7 +113,7 @@ /* InvoiceLine * \PhpTwinfield\InvoiceLine - * Available getters: getAllowDiscountOrPremium, getArticle, getDescription, getDim1, getFreetext1, getFreetext2, getFreetext3, getID, getMessages, getPerformanceDate, getPerformanceType, getQuantity, getResult, getSubArticle, getUnits, getUnitsPriceExcl, getUnitsPriceInc, getValueExcl, getValueInc, getVatCode, getVatValue, hasMessages + * Available getters: getAllowDiscountOrPremium, getArticle, getDescription, getDim1, getFreetext1, getFreetext2, getFreetext3, getID, getMessages, getPerformanceDate, getPerformanceType, getQuantity, getResult, getSubArticle, getSubArticleToString, getUnits, getUnitsPriceExcl, getUnitsPriceInc, getValueExcl, getValueInc, getVatCode, getVatValue, hasMessages * Available setters: setAllowDiscountOrPremium, setArticle, setDescription, setDim1, setFreetext1, setFreetext2, setFreetext3, setID, setPerformanceDate, setPerformanceType, setQuantity, setSubArticle, setUnits, setUnitsPriceExcl, setUnitsPriceInc, setValueExcl, setValueInc, setVatCode, setVatValue */ diff --git a/examples/InvoiceType.php b/examples/InvoiceType.php index 0cdab159..a7ac5f70 100644 --- a/examples/InvoiceType.php +++ b/examples/InvoiceType.php @@ -79,7 +79,7 @@ /* InvoiceType * \PhpTwinfield\InvoiceType * Available getters: getCode, getName, getShortName - * Available setters: setCode, setName, setShortName + * Available setters: fromCode, setCode, setName, setShortName */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { diff --git a/examples/PayCode.php b/examples/PayCode.php index da5098df..4a40d6ee 100644 --- a/examples/PayCode.php +++ b/examples/PayCode.php @@ -79,7 +79,7 @@ /* PayCode * \PhpTwinfield\PayCode * Available getters: getCode, getName, getShortName - * Available setters: setCode, setName, setShortName + * Available setters: fromCode, setCode, setName, setShortName */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { diff --git a/examples/Project.php b/examples/Project.php index a85dc0f2..139c2671 100644 --- a/examples/Project.php +++ b/examples/Project.php @@ -103,13 +103,14 @@ /* Project * \PhpTwinfield\Project * Available getters: getBehaviour, getCode, getInUse, getMessages, getName, getOffice, getResult, getShortName, getStatus, getTouched, getType, getUID, getVatCode, hasMessages, getProjects - * Available setters: setBehaviour, setCode, setName, setOffice, setShortName, setStatus, setType, setVatCode, setProjects + * Available setters: fromCode, setBehaviour, setCode, setName, setOffice, setShortName, setStatus, setType, setVatCode, setProjects */ /* ProjectProjects * \PhpTwinfield\ProjectProjects - * Available getters: getAuthoriser, getAuthoriserInherit, getAuthoriserLocked, getBillable, getBillableForRatio, getBillableInherit, getBillableLocked, getCustomer, getCustomerInherit, getCustomerLocked, getInvoiceDescription, getMessages, getRate, getRateInherit, - * getRateLocked, getResult, getValidFrom, getValidTill, hasMessages, getQuantities + * Available getters: getAuthoriser, getAuthoriserToString, getAuthoriserInherit, getAuthoriserInheritToString, getAuthoriserLocked, getAuthoriserLockedToString, getBillable, getBillableToString, getBillableForRatio, getBillableForRatioToString, + * getBillableInherit, getBillableInheritToString, getBillableLocked, getBillableLockedToString, getCustomer, getCustomerToString, getCustomerInherit, getCustomerInheritToString, getCustomerLocked, getCustomerLockedToString, getInvoiceDescription, getMessages, + * getRate, getRateToString, getRateInherit, getRateInheritToString, getRateLocked, getRateLockedToString, getResult, getValidFrom, getValidTill, hasMessages, getQuantities * * Available setters: setAuthoriser, setAuthoriserInherit, setAuthoriserLocked, setBillable, setBillableForRatio, setBillableInherit, setBillableLocked, setCustomer, setCustomerInherit, setCustomerLocked, setInvoiceDescription, setRate, setRateInherit, * setRateLocked, setValidFrom, setValidTill, addQuantity, removeQuantity @@ -118,7 +119,7 @@ /* ProjectQuantity * \PhpTwinfield\ProjectQuantity - * Available getters: getBillable, getBillableLocked, getLabel, getMandatory, getMessages, getRate, getResult, hasMessages + * Available getters: getBillable, getBillableToString, getBillableLocked, getBillableLockedToString, getLabel, getMandatory, getMessages, getRate, getRateToString, getResult, hasMessages * Available setters: setBillable, setBillableLocked, setLabel, setMandatory, setRate */ diff --git a/examples/Rate.php b/examples/Rate.php index bf3160b9..a1820560 100644 --- a/examples/Rate.php +++ b/examples/Rate.php @@ -92,7 +92,7 @@ /* Rate * \PhpTwinfield\Rate * Available getters: getCode, getCreated, getCurrency, getMessages, getModified, getName, getOffice, getResult, getShortName, getStatus, getTouched, getType, getUnit, getUser, hasMessages, getRateChanges - * Available setters: setCode, setCurrency, setName, setOffice, setShortName, setStatus, setType, setUnit, addRateChange, removeRateChange + * Available setters: fromCode, setCode, setCurrency, setName, setOffice, setShortName, setStatus, setType, setUnit, addRateChange, removeRateChange */ /* RateRateChange diff --git a/examples/Supplier.php b/examples/Supplier.php index 92bdc440..2e5a9445 100644 --- a/examples/Supplier.php +++ b/examples/Supplier.php @@ -114,7 +114,7 @@ * Available getters: getBeginPeriod, getBeginYear, getBehaviour, getBlockedAccountPaymentConditionsIncludeVat, getBlockedAccountPaymentConditionsPercentage, getCode, getEndPeriod, getEndYear, getGroup, getInUse, getMessages, getName, getOffice, * getPaymentConditionDiscountDays, getPaymentConditionDiscountPercentage, getRemittanceAdviceSendMail, getRemittanceAdviceSendType, getResult, getShortName, getStatus, getTouched, getType, getUID, getWebsite, hasMessages, getAddresses, getBanks, getFinancials, getPostingRules * - * Available setters: setBeginPeriod, setBeginYear, setBehaviour, setBlockedAccountPaymentConditionsIncludeVat, setBlockedAccountPaymentConditionsPercentage, setCode, setEndPeriod, setEndYear, setGroup, setName, setOffice, + * Available setters: fromCode, setBeginPeriod, setBeginYear, setBehaviour, setBlockedAccountPaymentConditionsIncludeVat, setBlockedAccountPaymentConditionsPercentage, setCode, setEndPeriod, setEndYear, setGroup, setName, setOffice, * setPaymentConditionDiscountDays, setPaymentConditionDiscountPercentage, setRemittanceAdviceSendMail, setRemittanceAdviceSendType, setShortName, setStatus, setType, setWebsite, setFinancials, addAddress, removeAddress, addBank, removeBank, addPostingRule, removePostingRule * */ diff --git a/examples/User.php b/examples/User.php new file mode 100644 index 00000000..27663cac --- /dev/null +++ b/examples/User.php @@ -0,0 +1,166 @@ + mutualoffices = 0 +if ($executeListAllWithFilter) { + $options = array('mutualoffices' => 0); + + try { + $users = $userApiConnector->listAll("API*", 0, 1, 10, $options); + } catch (ResponseException $e) { + $users = $e->getReturnedObject(); + } + + echo "
";
+    print_r($users);
+    echo "
"; +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +if ($executeListAllWithoutFilter) { + try { + $users = $userApiConnector->listAll(); + } catch (ResponseException $e) { + $users = $e->getReturnedObject(); + } + + echo "
";
+    print_r($users);
+    echo "
"; +} + +/* User + * \PhpTwinfield\User + * Available getters: getAcceptExtraCost, getCode, getCreated, getCulture, getCultureName, getCultureNativeName, getDemo, getDemoLocked, getEmail, getExchangeQuota, getExchangeQuotaLocked, getFileManagerQuota, + * getFileManagerQuotaLocked, getIsCurrentUser, getLevel, getMessages, getModified, getName, getPassword, getResult, getRole, getRoleLocked, getShortName, getStatus, getTouched, getType, getTypeLocked, hasMessages + * + * Available setters: fromCode, setAcceptExtraCost, setCode, setCulture, setCultureName, setCultureNativeName, setDemo, setDemoLocked, setEmail, setExchangeQuota, setExchangeQuotaLocked, setFileManagerQuota, + * setFileManagerQuotaLocked, setIsCurrentUser, setLevel, setName, setPassword, setRole, setRoleLocked, setShortName, setStatus, setType, setTypeLocked + * + */ + +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($users as $key => $user) { + echo "User {$key}
"; + echo "Code: {$user->getCode()}
"; + echo "Name: {$user->getName()}

"; + } +} + +// Read a User based off the passed in code and optionally the office. +if ($executeRead) { + try { + $user = $userApiConnector->get("API000001", $office); + } catch (ResponseException $e) { + $user = $e->getReturnedObject(); + } + + echo "
";
+    print_r($user);
+    echo "
"; + + echo "User
"; + echo "AcceptExtraCost (bool): {$user->getAcceptExtraCost()}
"; // bool|null Are extra costs accepted when changing the role (subscription) of the user. + echo "AcceptExtraCost (string): " . Util::formatBoolean($user->getAcceptExtraCost()) . "
"; // string|null + echo "Code: {$user->getCode()}
"; // string|null Code of the user. + echo "Created (\\DateTimeInterface):
" . print_r($user->getCreated(), true) . "

"; // DateTimeInterface|null The date/time the user was created. Read-only attribute. + echo "Created (string): " . Util::formatDateTime($user->getCreated()) . "
"; // string|null + echo "Culture: {$user->getCulture()}
"; // Culture|null The culture in which Twinfield is shown. + echo "CultureName: {$user->getCultureName()}
"; // string|null + echo "CultureNativeName: {$user->getCultureNativeName()}
"; // string|null + echo "Demo (bool): {$user->getDemo()}
"; // bool|null Indicates whether the user will be used only for training purposes. Only available when type is equal to Client of accountant. + echo "Demo (string): " . Util::formatBoolean($user->getDemo()) . "
"; // string|null + echo "DemoLocked (bool): {$user->getDemoLocked()}
"; // bool|null + echo "DemoLocked (string): " . Util::formatBoolean($user->getDemoLocked()) . "
"; // string|null + echo "Email: {$user->getEmail()}
"; // string|null The user’s email address. + echo "ExchangeQuota: {$user->getExchangeQuota()}
"; // int|null Twinfield Analysis quota. + echo "ExchangeQuotaLocked (bool): {$user->getExchangeQuotaLocked()}
"; // bool|null + echo "ExchangeQuotaLocked (string): " . Util::formatBoolean($user->getExchangeQuotaLocked()) . "
"; // string|null + echo "FileManagerQuota: {$user->getFileManagerQuota()}
"; // int|null File Manager quota. + echo "FileManagerQuotaLocked (bool): {$user->getFileManagerQuotaLocked()}
"; // bool|null + echo "FileManagerQuotaLocked (string): " . Util::formatBoolean($user->getFileManagerQuotaLocked()) . "
"; // string|null + echo "IsCurrentUser (bool): {$user->getIsCurrentUser()}
"; // bool|null + echo "IsCurrentUser (string): " . Util::formatBoolean($user->getIsCurrentUser()) . "
"; // string|null + echo "Level: {$user->getLevel()}
"; // int|null + + if ($user->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($user->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Modified (\\DateTimeInterface):
" . print_r($user->getModified(), true) . "

"; // DateTimeInterface|null The last date/time the user was modified. Read-only attribute. + echo "Modified (string): " . Util::formatDateTime($user->getModified()) . "
"; // string|null + echo "Name: {$user->getName()}
"; // string|null The name of the user. + echo "Password: {$user->getPassword()}
"; // string|null The password for the user. + echo "Result: {$user->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Role (\\PhpTwinfield\\UserRole):
" . print_r($user->getRole(), true) . "

"; // UserRole|null The role the user is linked to. + echo "Role (string): " . Util::objectToStr($user->getRole()) . "
"; // string|null + echo "RoleLocked (bool): {$user->getRoleLocked()}
"; // bool|null + echo "RoleLocked (string): " . Util::formatBoolean($user->getRoleLocked()) . "
"; // string|null + echo "ShortName: {$user->getShortName()}
"; // string|null The short name of the user. + echo "Status: {$user->getStatus()}
"; // Status|null For creating and updating status may be left empty. For deleting deleted should be used. In case a user that is used in a transaction is deleted, its status has been changed into hide. Hidden users can be activated by using active. + echo "Touched: {$user->getTouched()}
"; // int|null Count of the number of times the user settings are changed. Read-only attribute. + echo "Type: {$user->getType()}
"; // UserType|null User type, will be validated with the office type. Use regular in case of a non-accountancy organisation. + echo "TypeLocked (bool): {$user->getTypeLocked()}
"; // bool|null + echo "TypeLocked (string): " . Util::formatBoolean($user->getTypeLocked()) . "
"; // string|null +} \ No newline at end of file diff --git a/examples/UserRole.php b/examples/UserRole.php index b067bfad..1ebbfc0c 100644 --- a/examples/UserRole.php +++ b/examples/UserRole.php @@ -73,7 +73,7 @@ /* UserRole * \PhpTwinfield\UserRole * Available getters: getCode, getName, getShortName - * Available setters: setCode, setName, setShortName + * Available setters: fromCode, setCode, setName, setShortName */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { diff --git a/examples/VatCode.php b/examples/VatCode.php index 8201fd1b..9cff7d8d 100644 --- a/examples/VatCode.php +++ b/examples/VatCode.php @@ -93,7 +93,7 @@ /* VatCode * \PhpTwinfield\VatCode * Available getters: getCode, getCreated, getMessages, getModified, getName, getOffice, getResult, getShortName, getStatus, getTouched, getType, getUID, getUser, hasMessages, getPercentages - * Available setters: setCode, setName, setOffice, setShortName, setStatus, setType, addPercentage, removePercentage + * Available setters: fromCode, setCode, setName, setOffice, setShortName, setStatus, setType, addPercentage, removePercentage */ /* VatCodePercentage diff --git a/examples/VatGroup.php b/examples/VatGroup.php index ce02705e..f33c02df 100644 --- a/examples/VatGroup.php +++ b/examples/VatGroup.php @@ -73,7 +73,7 @@ /* VatGroup * \PhpTwinfield\VatGroup * Available getters: getCode, getName, getShortName - * Available setters: setCode, setName, setShortName + * Available setters: fromCode, setCode, setName, setShortName */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { diff --git a/examples/VatGroupCountry.php b/examples/VatGroupCountry.php index 77564d9d..7704ed8f 100644 --- a/examples/VatGroupCountry.php +++ b/examples/VatGroupCountry.php @@ -78,7 +78,7 @@ /* VatGroupCountry * \PhpTwinfield\VatGroupCountry * Available getters: getCode, getName, getShortName - * Available setters: setCode, setName, setShortName + * Available setters: fromCode, setCode, setName, setShortName */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { diff --git a/readme.md b/readme.md index fb7c1e68..5c76c6e0 100644 --- a/readme.md +++ b/readme.md @@ -53,11 +53,11 @@ support for another resource. | [Suppliers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Supplier](examples/Supplier.php) | | | | | | | | | | Transactions | | | | | | | -[Bank Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankTransactions) | :white_check_mark: | | :white_check_mark: | | :white_check_mark: | [Bank Transaction](examples/BankTransaction.php) | -[Cash Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/CashTransactions) | :white_check_mark: | | :white_check_mark: | | :white_check_mark: | [Cash Transaction](examples/CashTransaction.php) | -[Journal Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/JournalTransactions) | :white_check_mark: | | :white_check_mark: | | :white_check_mark: | [Journal Transaction](examples/JournalTransaction.php) | -[Purchase Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions) | :white_check_mark: | | :white_check_mark: | | :white_check_mark: | [Purchase Transaction](examples/PurchaseTransaction.php) | -[Sale Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions) | :white_check_mark: | | :white_check_mark: | | :white_check_mark: | [Sales Transaction](examples/SalesTransaction.php) | +[Bank Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Bank Transaction](examples/BankTransaction.php) | +[Cash Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/CashTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Cash Transaction](examples/CashTransaction.php) | +[Journal Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/JournalTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Journal Transaction](examples/JournalTransaction.php) | +[Purchase Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Purchase Transaction](examples/PurchaseTransaction.php) | +[Sale Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Sales Transaction](examples/SalesTransaction.php) | | | | | | | | | | [Users](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Users) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | [User](examples/User.php) | | User Roles | | :white_check_mark: | | | :white_check_mark: | [User Role](examples/UserRole.php) | diff --git a/src/Fields/RateField.php b/src/Fields/RateField.php index 70510176..61dd9546 100644 --- a/src/Fields/RateField.php +++ b/src/Fields/RateField.php @@ -6,7 +6,7 @@ /** * The rate - * Used by: ActivityProjects, ActivityQuantity, ProjectProjects, ProjectQuantity, RateRateChange + * Used by: ActivityProjects, ActivityQuantity, ProjectProjects, ProjectQuantity * * @package PhpTwinfield\Traits */ diff --git a/src/Mappers/UserMapper.php b/src/Mappers/UserMapper.php index 5e17a250..61e89d54 100644 --- a/src/Mappers/UserMapper.php +++ b/src/Mappers/UserMapper.php @@ -44,8 +44,8 @@ public static function map(Response $response) $user->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $userElement->getAttribute('status'))); // Set the user elements from the user element - $user->setAcceptExtraCostField(Util::parseBoolean(self::getField($userElement, 'acceptextracost', $user))) - ->setCulture(self::getField($userElement, 'culture', $user)) + $user->setAcceptExtraCost(Util::parseBoolean(self::getField($userElement, 'acceptextracost', $user))) + ->setCulture(self::parseEnumAttribute(\PhpTwinfield\Enums\Culture::class, self::getField($userElement, 'culture', $user))) ->setCode(self::getField($userElement, 'code', $user)) ->setCreated(self::parseDateTimeAttribute(self::getField($userElement, 'created', $user))) ->setDemo(Util::parseBoolean(self::getField($userElement, 'demo', $user))) @@ -71,4 +71,4 @@ public static function map(Response $response) // Return the complete object return $user; } -} +} \ No newline at end of file From 6146ac90793f1c22eb0a3e933cfb579c40f0fafb Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 26 Jun 2019 17:03:23 +0200 Subject: [PATCH 356/388] Upload --- src/BankTransaction.php | 2 +- src/CashTransaction.php | 2 +- src/ElectronicBankStatement.php | 2 +- src/Fields/Invoice/InvoiceAmountField.php | 4 ++-- src/Mappers/MatchSetMapper.php | 3 +-- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/BankTransaction.php b/src/BankTransaction.php index 53601db3..f0415834 100644 --- a/src/BankTransaction.php +++ b/src/BankTransaction.php @@ -21,7 +21,7 @@ class BankTransaction extends BaseTransaction public function __construct() { - $this->startValue = new \Money\Money(0, new \Money\Currency('EUR')); + $this->startValue = new \Money\Money(0, new \Money\Currency('XXX')); } /* diff --git a/src/CashTransaction.php b/src/CashTransaction.php index 6df540b2..d9f9b991 100644 --- a/src/CashTransaction.php +++ b/src/CashTransaction.php @@ -21,7 +21,7 @@ class CashTransaction extends BaseTransaction public function __construct() { - $this->startValue = new \Money\Money(0, new \Money\Currency('EUR')); + $this->startValue = new \Money\Money(0, new \Money\Currency('XXX')); } /* diff --git a/src/ElectronicBankStatement.php b/src/ElectronicBankStatement.php index d132c3ea..881ea6bd 100644 --- a/src/ElectronicBankStatement.php +++ b/src/ElectronicBankStatement.php @@ -59,7 +59,7 @@ class ElectronicBankStatement public function __construct() { $currency = new \PhpTwinfield\Currency; - $currency->setCode('EUR'); + $currency->setCode('XXX'); $this->currency = $currency; $this->startValue = new \Money\Money(0, new \Money\Currency($currency->getCode())); } diff --git a/src/Fields/Invoice/InvoiceAmountField.php b/src/Fields/Invoice/InvoiceAmountField.php index 6789aa1c..dc1e92a5 100644 --- a/src/Fields/Invoice/InvoiceAmountField.php +++ b/src/Fields/Invoice/InvoiceAmountField.php @@ -42,9 +42,9 @@ public function setInvoiceAmount(?Money $invoiceAmount) public function setInvoiceAmountFromFloat(?float $invoiceAmountFloat) { if ((float)$invoiceAmountFloat) { - return $this->setInvoiceAmount(Money::EUR(100 * $invoiceAmountFloat)); + return $this->setInvoiceAmount(Money::XXX(100 * $invoiceAmountFloat)); } else { - return $this->setInvoiceAmount(Money::EUR(0)); + return $this->setInvoiceAmount(Money::XXX(0)); } } } \ No newline at end of file diff --git a/src/Mappers/MatchSetMapper.php b/src/Mappers/MatchSetMapper.php index 5e4174f0..11d619fc 100644 --- a/src/Mappers/MatchSetMapper.php +++ b/src/Mappers/MatchSetMapper.php @@ -71,7 +71,6 @@ private static function getMatchValueFrom(\DOMElement $lineElement): ?Money return null; } - // TODO: Perhaps not hard code this to EUR, but the element doesn't seem to contain a currency - return Util::parseMoney($matchValue, new Currency('EUR')); + return Util::parseMoney($matchValue, new Currency('XXX')); } } \ No newline at end of file From 903effe89c2a5411231761346a7edc1acc303f79 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 26 Jun 2019 17:30:30 +0200 Subject: [PATCH 357/388] Upload --- src/BankTransaction.php | 2 +- src/CashTransaction.php | 2 +- src/ElectronicBankStatement.php | 2 +- src/Fields/Invoice/InvoiceAmountField.php | 4 ++-- src/Mappers/MatchSetMapper.php | 2 +- tests/UnitTests/ApiConnectors/MatchesApiConnectorTest.php | 8 ++++---- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/BankTransaction.php b/src/BankTransaction.php index f0415834..7f48c35c 100644 --- a/src/BankTransaction.php +++ b/src/BankTransaction.php @@ -21,7 +21,7 @@ class BankTransaction extends BaseTransaction public function __construct() { - $this->startValue = new \Money\Money(0, new \Money\Currency('XXX')); + $this->startValue = new \Money\Money(0, new \Money\Currency('ZZZ')); } /* diff --git a/src/CashTransaction.php b/src/CashTransaction.php index d9f9b991..750171fa 100644 --- a/src/CashTransaction.php +++ b/src/CashTransaction.php @@ -21,7 +21,7 @@ class CashTransaction extends BaseTransaction public function __construct() { - $this->startValue = new \Money\Money(0, new \Money\Currency('XXX')); + $this->startValue = new \Money\Money(0, new \Money\Currency('ZZZ')); } /* diff --git a/src/ElectronicBankStatement.php b/src/ElectronicBankStatement.php index 881ea6bd..933d8d15 100644 --- a/src/ElectronicBankStatement.php +++ b/src/ElectronicBankStatement.php @@ -59,7 +59,7 @@ class ElectronicBankStatement public function __construct() { $currency = new \PhpTwinfield\Currency; - $currency->setCode('XXX'); + $currency->setCode('ZZZ'); $this->currency = $currency; $this->startValue = new \Money\Money(0, new \Money\Currency($currency->getCode())); } diff --git a/src/Fields/Invoice/InvoiceAmountField.php b/src/Fields/Invoice/InvoiceAmountField.php index dc1e92a5..4e1c8a65 100644 --- a/src/Fields/Invoice/InvoiceAmountField.php +++ b/src/Fields/Invoice/InvoiceAmountField.php @@ -42,9 +42,9 @@ public function setInvoiceAmount(?Money $invoiceAmount) public function setInvoiceAmountFromFloat(?float $invoiceAmountFloat) { if ((float)$invoiceAmountFloat) { - return $this->setInvoiceAmount(Money::XXX(100 * $invoiceAmountFloat)); + return $this->setInvoiceAmount(Money::ZZZ(100 * $invoiceAmountFloat)); } else { - return $this->setInvoiceAmount(Money::XXX(0)); + return $this->setInvoiceAmount(Money::ZZZ(0)); } } } \ No newline at end of file diff --git a/src/Mappers/MatchSetMapper.php b/src/Mappers/MatchSetMapper.php index 11d619fc..cafcad28 100644 --- a/src/Mappers/MatchSetMapper.php +++ b/src/Mappers/MatchSetMapper.php @@ -71,6 +71,6 @@ private static function getMatchValueFrom(\DOMElement $lineElement): ?Money return null; } - return Util::parseMoney($matchValue, new Currency('XXX')); + return Util::parseMoney($matchValue, new Currency('ZZZ')); } } \ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/MatchesApiConnectorTest.php b/tests/UnitTests/ApiConnectors/MatchesApiConnectorTest.php index fd3b45c8..8804df55 100644 --- a/tests/UnitTests/ApiConnectors/MatchesApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/MatchesApiConnectorTest.php @@ -90,13 +90,13 @@ public function testSendAllReturnsMappedObjects() $this->assertEquals("VRK", $line->getTransCode()); $this->assertSame(201700103, $line->getTransNumber()); $this->assertSame(1, $line->getTransLine()); - $this->assertEquals(Money::EUR(526), $line->getMatchValue()); + $this->assertEquals(Money::ZZZ(526), $line->getMatchValue()); $line = $lines[1]; $this->assertEquals("DUM2", $line->getTransCode()); $this->assertSame(201700029, $line->getTransNumber()); $this->assertSame(79, $line->getTransLine()); - $this->assertEquals(Money::EUR(-526), $line->getMatchValue()); + $this->assertEquals(Money::ZZZ(-526), $line->getMatchValue()); /** @var MatchSet $matchSet */ try { @@ -116,12 +116,12 @@ public function testSendAllReturnsMappedObjects() $this->assertEquals("VRK", $line->getTransCode()); $this->assertSame(201700100, $line->getTransNumber()); $this->assertSame(1, $line->getTransLine()); - $this->assertEquals(Money::EUR(140), $line->getMatchValue()); + $this->assertEquals(Money::ZZZ(140), $line->getMatchValue()); $line = $lines[1]; $this->assertEquals("DUM2", $line->getTransCode()); $this->assertSame(201700029, $line->getTransNumber()); $this->assertSame(64, $line->getTransLine()); - $this->assertEquals(Money::EUR(-140), $line->getMatchValue()); + $this->assertEquals(Money::ZZZ(-140), $line->getMatchValue()); } } From 428263447029db43ff5a3e35f1aad07a1d0f9862 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 26 Jun 2019 17:36:09 +0200 Subject: [PATCH 358/388] Upload --- src/Fields/Invoice/InvoiceAmountField.php | 4 ++-- tests/UnitTests/ApiConnectors/MatchesApiConnectorTest.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Fields/Invoice/InvoiceAmountField.php b/src/Fields/Invoice/InvoiceAmountField.php index 4e1c8a65..d6c1ca97 100644 --- a/src/Fields/Invoice/InvoiceAmountField.php +++ b/src/Fields/Invoice/InvoiceAmountField.php @@ -42,9 +42,9 @@ public function setInvoiceAmount(?Money $invoiceAmount) public function setInvoiceAmountFromFloat(?float $invoiceAmountFloat) { if ((float)$invoiceAmountFloat) { - return $this->setInvoiceAmount(Money::ZZZ(100 * $invoiceAmountFloat)); + return $this->setInvoiceAmount(new \Money\Money(100 * $invoiceAmountFloat, new \Money\Currency('ZZZ'))); } else { - return $this->setInvoiceAmount(Money::ZZZ(0)); + return $this->setInvoiceAmount(new \Money\Money(0, new \Money\Currency('ZZZ'))); } } } \ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/MatchesApiConnectorTest.php b/tests/UnitTests/ApiConnectors/MatchesApiConnectorTest.php index 8804df55..1154ce39 100644 --- a/tests/UnitTests/ApiConnectors/MatchesApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/MatchesApiConnectorTest.php @@ -90,13 +90,13 @@ public function testSendAllReturnsMappedObjects() $this->assertEquals("VRK", $line->getTransCode()); $this->assertSame(201700103, $line->getTransNumber()); $this->assertSame(1, $line->getTransLine()); - $this->assertEquals(Money::ZZZ(526), $line->getMatchValue()); + $this->assertEquals(new \Money\Money(526, new \Money\Currency('ZZZ')), $line->getMatchValue()); $line = $lines[1]; $this->assertEquals("DUM2", $line->getTransCode()); $this->assertSame(201700029, $line->getTransNumber()); $this->assertSame(79, $line->getTransLine()); - $this->assertEquals(Money::ZZZ(-526), $line->getMatchValue()); + $this->assertEquals(new \Money\Money(-526, new \Money\Currency('ZZZ')), $line->getMatchValue()); /** @var MatchSet $matchSet */ try { @@ -116,12 +116,12 @@ public function testSendAllReturnsMappedObjects() $this->assertEquals("VRK", $line->getTransCode()); $this->assertSame(201700100, $line->getTransNumber()); $this->assertSame(1, $line->getTransLine()); - $this->assertEquals(Money::ZZZ(140), $line->getMatchValue()); + $this->assertEquals(new \Money\Money(140, new \Money\Currency('ZZZ')), $line->getMatchValue()); $line = $lines[1]; $this->assertEquals("DUM2", $line->getTransCode()); $this->assertSame(201700029, $line->getTransNumber()); $this->assertSame(64, $line->getTransLine()); - $this->assertEquals(Money::ZZZ(-140), $line->getMatchValue()); + $this->assertEquals(new \Money\Money(-140, new \Money\Currency('ZZZ')), $line->getMatchValue()); } } From ca336d3fcf754d2b0ababdd3792e6f19c730855b Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 26 Jun 2019 17:42:59 +0200 Subject: [PATCH 359/388] Upload --- src/BankTransaction.php | 2 +- src/CashTransaction.php | 2 +- src/ElectronicBankStatement.php | 2 +- src/Fields/Invoice/InvoiceAmountField.php | 4 ++-- src/Mappers/MatchSetMapper.php | 3 ++- tests/UnitTests/ApiConnectors/MatchesApiConnectorTest.php | 8 ++++---- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/BankTransaction.php b/src/BankTransaction.php index 7f48c35c..f0415834 100644 --- a/src/BankTransaction.php +++ b/src/BankTransaction.php @@ -21,7 +21,7 @@ class BankTransaction extends BaseTransaction public function __construct() { - $this->startValue = new \Money\Money(0, new \Money\Currency('ZZZ')); + $this->startValue = new \Money\Money(0, new \Money\Currency('XXX')); } /* diff --git a/src/CashTransaction.php b/src/CashTransaction.php index 750171fa..d9f9b991 100644 --- a/src/CashTransaction.php +++ b/src/CashTransaction.php @@ -21,7 +21,7 @@ class CashTransaction extends BaseTransaction public function __construct() { - $this->startValue = new \Money\Money(0, new \Money\Currency('ZZZ')); + $this->startValue = new \Money\Money(0, new \Money\Currency('XXX')); } /* diff --git a/src/ElectronicBankStatement.php b/src/ElectronicBankStatement.php index 933d8d15..881ea6bd 100644 --- a/src/ElectronicBankStatement.php +++ b/src/ElectronicBankStatement.php @@ -59,7 +59,7 @@ class ElectronicBankStatement public function __construct() { $currency = new \PhpTwinfield\Currency; - $currency->setCode('ZZZ'); + $currency->setCode('XXX'); $this->currency = $currency; $this->startValue = new \Money\Money(0, new \Money\Currency($currency->getCode())); } diff --git a/src/Fields/Invoice/InvoiceAmountField.php b/src/Fields/Invoice/InvoiceAmountField.php index d6c1ca97..6789aa1c 100644 --- a/src/Fields/Invoice/InvoiceAmountField.php +++ b/src/Fields/Invoice/InvoiceAmountField.php @@ -42,9 +42,9 @@ public function setInvoiceAmount(?Money $invoiceAmount) public function setInvoiceAmountFromFloat(?float $invoiceAmountFloat) { if ((float)$invoiceAmountFloat) { - return $this->setInvoiceAmount(new \Money\Money(100 * $invoiceAmountFloat, new \Money\Currency('ZZZ'))); + return $this->setInvoiceAmount(Money::EUR(100 * $invoiceAmountFloat)); } else { - return $this->setInvoiceAmount(new \Money\Money(0, new \Money\Currency('ZZZ'))); + return $this->setInvoiceAmount(Money::EUR(0)); } } } \ No newline at end of file diff --git a/src/Mappers/MatchSetMapper.php b/src/Mappers/MatchSetMapper.php index cafcad28..5e4174f0 100644 --- a/src/Mappers/MatchSetMapper.php +++ b/src/Mappers/MatchSetMapper.php @@ -71,6 +71,7 @@ private static function getMatchValueFrom(\DOMElement $lineElement): ?Money return null; } - return Util::parseMoney($matchValue, new Currency('ZZZ')); + // TODO: Perhaps not hard code this to EUR, but the element doesn't seem to contain a currency + return Util::parseMoney($matchValue, new Currency('EUR')); } } \ No newline at end of file diff --git a/tests/UnitTests/ApiConnectors/MatchesApiConnectorTest.php b/tests/UnitTests/ApiConnectors/MatchesApiConnectorTest.php index 1154ce39..fd3b45c8 100644 --- a/tests/UnitTests/ApiConnectors/MatchesApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/MatchesApiConnectorTest.php @@ -90,13 +90,13 @@ public function testSendAllReturnsMappedObjects() $this->assertEquals("VRK", $line->getTransCode()); $this->assertSame(201700103, $line->getTransNumber()); $this->assertSame(1, $line->getTransLine()); - $this->assertEquals(new \Money\Money(526, new \Money\Currency('ZZZ')), $line->getMatchValue()); + $this->assertEquals(Money::EUR(526), $line->getMatchValue()); $line = $lines[1]; $this->assertEquals("DUM2", $line->getTransCode()); $this->assertSame(201700029, $line->getTransNumber()); $this->assertSame(79, $line->getTransLine()); - $this->assertEquals(new \Money\Money(-526, new \Money\Currency('ZZZ')), $line->getMatchValue()); + $this->assertEquals(Money::EUR(-526), $line->getMatchValue()); /** @var MatchSet $matchSet */ try { @@ -116,12 +116,12 @@ public function testSendAllReturnsMappedObjects() $this->assertEquals("VRK", $line->getTransCode()); $this->assertSame(201700100, $line->getTransNumber()); $this->assertSame(1, $line->getTransLine()); - $this->assertEquals(new \Money\Money(140, new \Money\Currency('ZZZ')), $line->getMatchValue()); + $this->assertEquals(Money::EUR(140), $line->getMatchValue()); $line = $lines[1]; $this->assertEquals("DUM2", $line->getTransCode()); $this->assertSame(201700029, $line->getTransNumber()); $this->assertSame(64, $line->getTransLine()); - $this->assertEquals(new \Money\Money(-140, new \Money\Currency('ZZZ')), $line->getMatchValue()); + $this->assertEquals(Money::EUR(-140), $line->getMatchValue()); } } From b5d8f942449cd78cbfd61642aa05dc64c62f29f7 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 26 Jun 2019 20:48:51 +0200 Subject: [PATCH 360/388] Upload --- examples/AssetMethod.php | 349 +++++++++++++++++++++++++++++++++++++ examples/GeneralLedger.php | 4 +- 2 files changed, 351 insertions(+), 2 deletions(-) create mode 100644 examples/AssetMethod.php diff --git a/examples/AssetMethod.php b/examples/AssetMethod.php new file mode 100644 index 00000000..490e6f1f --- /dev/null +++ b/examples/AssetMethod.php @@ -0,0 +1,349 @@ +listAll("10*", 0, 1, 10); + } catch (ResponseException $e) { + $assetMethods = $e->getReturnedObject(); + } + + echo "
";
+    print_r($assetMethods);
+    echo "
"; +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +if ($executeListAllWithoutFilter) { + try { + $assetMethods = $assetMethodApiConnector->listAll(); + } catch (ResponseException $e) { + $assetMethods = $e->getReturnedObject(); + } + + echo "
";
+    print_r($assetMethods);
+    echo "
"; +} + +/* AssetMethod + * \PhpTwinfield\AssetMethod + * Available getters: getCalcMethod, getCode, getCreated, getDepreciateReconciliation, getInUse, getMessages, getModified, getName, getNrOfPeriods, getOffice, getPercentage, getResult, getShortName, getStatus, getTouched, getUser, hasMessages, getBalanceAccounts, getFreeTexts, getProfitLossAccounts + * Available setters: fromCode, setBalanceAccounts, setCalcMethod, setCode, setDepreciateReconciliation, setName, setNrOfPeriods, setOffice, setPercentage, setProfitLossAccounts, setShortName, setStatus, addFreeText, removeFreeText + */ + +/* AssetMethodBalanceAccounts + * \PhpTwinfield\AssetMethodBalanceAccounts + * Available getters: getAssetsToActivate, getDepreciation, getDepreciationGroup, getMessages, getPurchaseValue, getPurchaseValueGroup, getReconciliation, getResult, getToBeInvoiced, hasMessages + * Available setters: setAssetsToActivate, setDepreciation, setDepreciationGroup, setPurchaseValue, setPurchaseValueGroup, setReconciliation, setToBeInvoiced + */ + +/* AssetMethodProfitLossAccounts + * \PhpTwinfield\AssetMethodProfitLossAccounts + * Available getters: getDepreciation, getMessages, getReconciliation, getResult, getSales, hasMessages + * Available setters: setDepreciation, setReconciliation, setSales + */ + +/* AssetMethodFreeText + * \PhpTwinfield\AssetMethodFreeText + * Available getters: getElementValue, getID, getMessages, getResult, getType, hasMessages + * Available setters: setElementValue, setID, setType + */ + +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($assetMethods as $key => $assetMethod) { + echo "AssetMethod {$key}
"; + echo "Code: {$assetMethod->getCode()}
"; + echo "Name: {$assetMethod->getName()}

"; + } +} + +// Read an AssetMethod based off the passed in code and optionally the office. +if ($executeRead) { + try { + $assetMethod = $assetMethodApiConnector->get("101", $office); + } catch (ResponseException $e) { + $assetMethod = $e->getReturnedObject(); + } + + echo "
";
+    print_r($assetMethod);
+    echo "
"; + + echo "AssetMethod
"; + echo "CalcMethod: {$assetMethod->getCalcMethod()}
"; // CalcMethod|null The calculation method. + echo "Code: {$assetMethod->getCode()}
"; // string|null Asset method code. + echo "Created (\\DateTimeInterface):
" . print_r($assetMethod->getCreated(), true) . "

"; // \DateTimeInterface|null Date/time the asset method is created. + echo "Created (string): " . Util::formatDate($assetMethod->getCreated()) . "
"; // string|null + echo "DepreciateReconciliation: {$assetMethod->getDepreciateReconciliation()}
"; // DepreciateReconciliation|null Depreciate as of the revaluation date. Depreciate in retrospect, back to the purchase date. + echo "InUse (bool): {$assetMethod->getInUse()}
"; // bool|null + echo "InUse (string): " . Util::formatBoolean($assetMethod->getInUse()) . "
"; // string|null + + if ($assetMethod->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($assetMethod->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Modified (\\DateTimeInterface):
" . print_r($assetMethod->getModified(), true) . "

"; // \DateTimeInterface|null Date/time the asset method is modified the last time. + echo "Modified (string): " . Util::formatDate($assetMethod->getModified()) . "
"; // string|null + echo "Name: {$assetMethod->getName()}
"; // string|null The name of the asset method. + echo "NrOfPeriods: {$assetMethod->getNrOfPeriods()}
"; // int|null The number of periods over which the asset linked to the asset method should be depreciated. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($assetMethod->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): " . Util::objectToStr($assetMethod->getOffice()) . "
"; // string|null + echo "Percentage: {$assetMethod->getPercentage()}
"; // int|null + echo "Result: {$assetMethod->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$assetMethod->getShortName()}
"; // string|null The short name of the asset method. + echo "Status: {$assetMethod->getStatus()}
"; // Status|null Status of the asset method. + echo "Touched: {$assetMethod->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. + echo "User (\\PhpTwinfield\\User):
" . print_r($assetMethod->getUser(), true) . "

"; // User|null The user who modified the asset method the last time. + echo "User (string): " . Util::objectToStr($assetMethod->getUser()) . "
"; // string|null + + echo "AssetMethodBalanceAccounts
"; + $assetMethodBalanceAccounts = $assetMethod->getBalanceAccounts(); // AssetMethodBalanceAccounts|null AssetMethodBalanceAccounts object. + + echo "AssetsToActivate (\\PhpTwinfield\\GeneralLedger):
" . print_r($assetMethodBalanceAccounts->getAssetsToActivate(), true) . "

"; // GeneralLedger|null Assets to activate balance sheet. + echo "AssetsToActivate (string): " . Util::objectToStr($assetMethodBalanceAccounts->getAssetsToActivate()) . "
"; // string|null + echo "Depreciation (\\PhpTwinfield\\GeneralLedger):
" . print_r($assetMethodBalanceAccounts->getDepreciation(), true) . "

"; // GeneralLedger|null Cumulative depreciation balance sheet. + echo "Depreciation (string): " . Util::objectToStr($assetMethodBalanceAccounts->getDepreciation()) . "
"; // string|null + echo "DepreciationGroup (\\PhpTwinfield\\DimensionGroup):
" . print_r($assetMethodBalanceAccounts->getDepreciationGroup(), true) . "

"; // DimensionGroup|null Depreciation group. + echo "DepreciationGroup (string): " . Util::objectToStr($assetMethodBalanceAccounts->getDepreciationGroup()) . "
"; // string|null + + if ($assetMethodBalanceAccounts->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($assetMethodBalanceAccounts->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "PurchaseValue (\\PhpTwinfield\\GeneralLedger):
" . print_r($assetMethodBalanceAccounts->getPurchaseValue(), true) . "

"; // GeneralLedger|null Purchase value balance sheet. + echo "PurchaseValue (string): " . Util::objectToStr($assetMethodBalanceAccounts->getPurchaseValue()) . "
"; // string|null + echo "PurchaseValueGroup (\\PhpTwinfield\\DimensionGroup):
" . print_r($assetMethodBalanceAccounts->getPurchaseValueGroup(), true) . "

"; // DimensionGroup|null Purchase value group. + echo "PurchaseValueGroup (string): " . Util::objectToStr($assetMethodBalanceAccounts->getPurchaseValueGroup()) . "
"; // string|null + echo "Reconciliation (\\PhpTwinfield\\GeneralLedger):
" . print_r($assetMethodBalanceAccounts->getReconciliation(), true) . "

"; // GeneralLedger|null Revaluation of purchase value balance sheet. + echo "Reconciliation (string): " . Util::objectToStr($assetMethodBalanceAccounts->getReconciliation()) . "
"; // string|null + echo "Result: {$assetMethodBalanceAccounts->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ToBeInvoiced (\\PhpTwinfield\\GeneralLedger):
" . print_r($assetMethodBalanceAccounts->getToBeInvoiced(), true) . "

"; // GeneralLedger|null Disposal value to be invoiced balance sheet. + echo "ToBeInvoiced (string): " . Util::objectToStr($assetMethodBalanceAccounts->getToBeInvoiced()) . "
"; // string|null + + echo "AssetMethodProfitLossAccounts
"; + $assetMethodProfitLossAccounts = $assetMethod->getProfitLossAccounts(); // AssetMethodProfitLossAccounts|null AssetMethodProfitLossAccounts object. + + echo "Depreciation (\\PhpTwinfield\\GeneralLedger):
" . print_r($assetMethodProfitLossAccounts->getDepreciation(), true) . "

"; // GeneralLedger|null Depreciation costs profit and loss account. + echo "Depreciation (string): " . Util::objectToStr($assetMethodProfitLossAccounts->getDepreciation()) . "
"; // string|null + + if ($assetMethodProfitLossAccounts->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($assetMethodProfitLossAccounts->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Reconciliation (\\PhpTwinfield\\GeneralLedger):
" . print_r($assetMethodProfitLossAccounts->getReconciliation(), true) . "

"; // GeneralLedger|null Revaluation reserve profit and loss account. + echo "Reconciliation (string): " . Util::objectToStr($assetMethodProfitLossAccounts->getReconciliation()) . "
"; // string|null + echo "Result: {$assetMethodProfitLossAccounts->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Sales (\\PhpTwinfield\\GeneralLedger):
" . print_r($assetMethodProfitLossAccounts->getSales(), true) . "

"; // GeneralLedger|null Disposal result profit and loss account. + echo "Sales (string): " . Util::objectToStr($assetMethodProfitLossAccounts->getSales()) . "
"; // string|null + + $assetMethodFreeTexts = $assetMethod->getFreeTexts(); // array|null Array of AssetMethodFreeText objects. + + foreach ($assetMethodFreeTexts as $key => $assetMethodFreeText) { + echo "AssetMethodFreeText {$key}
"; + + echo "ElementValue: {$assetMethodFreeText->getElementValue()}
"; // string|null Free text. + echo "ID: {$assetMethodFreeText->getID()}
"; // int|null Free text id. In total, five free text fields are available. + + if ($assetMethodFreeText->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($assetMethodFreeText->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Result: {$assetMethodFreeText->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Type: {$assetMethodFreeText->getType()}
"; // FreeTextType|null Free text type. + } +} + +// Copy an existing AssetMethod to a new entity +if ($executeCopy) { + try { + $assetMethod = $assetMethodApiConnector->get("101", $office); + } catch (ResponseException $e) { + $assetMethod = $e->getReturnedObject(); + } + + $assetMethod->setCode('102'); // string|null Dimension code, must be compliant with the mask of the BAS or PNL Dimension type. + + try { + $assetMethodCopy = $assetMethodApiConnector->send($assetMethod); + } catch (ResponseException $e) { + $assetMethodCopy = $e->getReturnedObject(); + } + + echo "
";
+    print_r($assetMethodCopy);
+    echo "
"; + + echo "Result of copy process: {$assetMethodCopy->getResult()}
"; + echo "Code of copied AssetMethod: {$assetMethodCopy->getCode()}
"; +} + +// Create a new AssetMethod from scratch, alternatively read an existing AssetMethod as shown above and than modify the values in the same way as shown below +if ($executeNew) { + $assetMethod = new \PhpTwinfield\AssetMethod; + + // Required values for creating a new AssetMethod + $assetMethod->setCalcMethod(\PhpTwinfield\Enums\CalcMethod::NONE()); // CalcMethod|null The calculation method. + $assetMethod->setCode('102'); // string|null + $assetMethod->setName("Example AssetMethod"); // string|null The name of the asset method. + $assetMethod->setOffice($office); // Office|null Office code. + $assetMethod->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null + + $assetMethodBalanceAccounts = new \PhpTwinfield\AssetMethodBalanceAccounts; + + $depreciation = new \PhpTwinfield\GeneralLedger; + $depreciation->setCode('0150'); + $assetMethodBalanceAccounts->setDepreciation($depreciation); // GeneralLedger|null Cumulative depreciation balance sheet. + $assetMethodBalanceAccounts->setDepreciation(\PhpTwinfield\GeneralLedger::fromCode('0150')); // string|null + $purchasevalue = new \PhpTwinfield\GeneralLedger; + $purchasevalue->setCode('0155'); + $assetMethodBalanceAccounts->setPurchaseValue($purchasevalue); // GeneralLedger|null Purchase value balance sheet. + $assetMethodBalanceAccounts->setPurchaseValue(\PhpTwinfield\GeneralLedger::fromCode('0155')); // string|null + + $assetMethod->setBalanceAccounts($assetMethodBalanceAccounts); // AssetMethodBalanceAccounts Set the AssetMethodBalanceAccounts object tot the AssetMethod object + + $assetMethodProfitLossAccounts = new \PhpTwinfield\AssetMethodProfitLossAccounts; + + $depreciation = new \PhpTwinfield\GeneralLedger; + $depreciation->setCode('4750'); + $assetMethodProfitLossAccounts->setDepreciation($depreciation); // GeneralLedger|null Depreciation costs profit and loss account. + $assetMethodProfitLossAccounts->setDepreciation(\PhpTwinfield\GeneralLedger::fromCode('4750')); // string|null + + $assetMethod->setProfitLossAccounts($assetMethodProfitLossAccounts); // AssetMethodProfitLossAccounts Set the AssetMethodProfitLossAccounts object tot the AssetMethod object + + // Optional values for creating a new AssetMethod + //$assetMethod->setDepreciateReconciliation(\PhpTwinfield\Enums\DepreciateReconciliation::FROMPURCHASEDATE()); // DepreciateReconciliation|null Depreciate as of the revaluation date. Depreciate in retrospect, back to the purchase date. + //$assetMethod->setNrOfPeriods(1); // int|null The number of periods over which the asset linked to the asset method should be depreciated. + //$assetMethod->setPercentage(1); // int|null + $assetMethod->setShortName("ExmplAsstMthd"); // string|null The short name of the asset method. + $assetMethod->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. + //$assetMethod->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case a dimension that is used in a transaction is deleted, its status has been changed into hide. Hidden dimensions can be activated by using active. + + $assetsToActivate = new \PhpTwinfield\GeneralLedger; + $assetsToActivate->setCode('0180'); + //$assetMethodBalanceAccounts->setAssetsToActivate($assetsToActivate); // GeneralLedger|null Assets to activate balance sheet. + //$assetMethodBalanceAccounts->setAssetsToActivate(\PhpTwinfield\GeneralLedger::fromCode('0180')); // string|null + $depreciationGroup = new \PhpTwinfield\DimensionGroup; + $depreciationGroup->setCode('EXAMPLEGRP'); + //$assetMethodBalanceAccounts->setDepreciationGroup($depreciationGroup); // DimensionGroup|null Depreciation group. + //$assetMethodBalanceAccounts->setDepreciationGroup(\PhpTwinfield\DimensionGroup::fromCode('EXAMPLEGRP')); // string|null + $purchasevalueGroup = new \PhpTwinfield\DimensionGroup; + $purchasevalueGroup->setCode('EXAMPLEGRP'); + //$assetMethodBalanceAccounts->setPurchaseValueGroup($purchasevalueGroup); // DimensionGroup|null Purchase value group. + //$assetMethodBalanceAccounts->setPurchaseValueGroup(\PhpTwinfield\DimensionGroup::fromCode('EXAMPLEGRP')); // string|null + $reconciliation = new \PhpTwinfield\GeneralLedger; + $reconciliation->setCode('0845'); + //$assetMethodBalanceAccounts->setReconciliation($reconciliation); // GeneralLedger|null Revaluation of purchase value balance sheet. + //$assetMethodBalanceAccounts->setReconciliation(\PhpTwinfield\GeneralLedger::fromCode('0845')); // string|null + $toBeInvoiced = new \PhpTwinfield\GeneralLedger; + $toBeInvoiced->setCode('1260'); + //$assetMethodBalanceAccounts->setToBeInvoiced($toBeInvoiced); // GeneralLedger|null Disposal value to be invoiced balance sheet. + //$assetMethodBalanceAccounts->setToBeInvoiced(\PhpTwinfield\GeneralLedger::fromCode('1260')); // string|null + + $assetMethod->setBalanceAccounts($assetMethodBalanceAccounts); // AssetMethodBalanceAccounts Set the AssetMethodBalanceAccounts object tot the AssetMethod object + + $reconciliation = new \PhpTwinfield\GeneralLedger; + $reconciliation->setCode('0845'); + //$assetMethodProfitLossAccounts->setReconciliation($reconciliation); // GeneralLedger|null Revaluation reserve profit and loss account. + //$assetMethodProfitLossAccounts->setReconciliation(\PhpTwinfield\GeneralLedger::fromCode('0845')); // string|null + $sales = new \PhpTwinfield\GeneralLedger; + $sales->setCode('0155'); + //$assetMethodProfitLossAccounts->setSales($sales); // GeneralLedger|null Disposal result profit and loss account. + //$assetMethodProfitLossAccounts->setSales(\PhpTwinfield\GeneralLedger::fromCode('0155')); // string|null + + $assetMethod->setProfitLossAccounts($assetMethodProfitLossAccounts); // AssetMethodProfitLossAccounts Set the AssetMethodProfitLossAccounts object tot the AssetMethod object + + // The minimum amount of AssetMethodFreeTexts linked to an AssetMethod object is 0, the maximum amount is 5 + $assetMethodFreeText = new \PhpTwinfield\AssetMethodFreeText; + + $assetMethodFreeText->setID(1); // int|null Free text id. In total, five free text fields are available. + $assetMethodFreeText->setType(\PhpTwinfield\Enums\FreeTextType::TEXT()); // FreeTextType|null Free text type. + $assetMethodFreeText->setElementValue('Example free text'); // string|null Free text. + + $assetMethod->addFreeText($assetMethodFreeText); // AssetMethodFreeText Add an AssetMethodFreeText object to the AssetMethod object + //$assetMethod->removeFreeText(0); // int Remove a free text based on the index of the free text + + try { + $assetMethodNew = $assetMethodApiConnector->send($assetMethod); + } catch (ResponseException $e) { + $assetMethodNew = $e->getReturnedObject(); + } + + echo "
";
+    print_r($assetMethodNew);
+    echo "
"; + + echo "Result of creation process: {$assetMethodNew->getResult()}
"; + echo "Code of new AssetMethod: {$assetMethodNew->getCode()}
"; +} + +// Delete an AssetMethod based off the passed in code and optionally the office. +if ($executeDelete) { + try { + $assetMethodDeleted = $assetMethodApiConnector->delete("102", $office); + } catch (ResponseException $e) { + $assetMethodDeleted = $e->getReturnedObject(); + } + + echo "
";
+    print_r($assetMethodDeleted);
+    echo "
"; + + echo "Result of deletion process: {$assetMethodDeleted->getResult()}
"; +} \ No newline at end of file diff --git a/examples/GeneralLedger.php b/examples/GeneralLedger.php index 5e4fa60b..c56992bd 100644 --- a/examples/GeneralLedger.php +++ b/examples/GeneralLedger.php @@ -128,7 +128,7 @@ } } -// Read a GeneralLedger based off the passed in code and optionally the office. +// Read a GeneralLedger based off the passed in code, dimension type and optionally the office. if ($executeRead) { try { $generalLedger = $generalLedgerApiConnector->get("1000", "BAS", $office); @@ -282,7 +282,7 @@ echo "Code of new GeneralLedger: {$generalLedgerNew->getCode()}
"; } -// Delete a GeneralLedger based off the passed in code and optionally the office. +// Delete a GeneralLedger based off the passed in code, dimension type and optionally the office. if ($executeDelete) { try { $generalLedgerDeleted = $generalLedgerApiConnector->delete("0000", "BAS", $office); From db2af0723a6830c2fb18685f31da275b9100abcd Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 26 Jun 2019 21:00:28 +0200 Subject: [PATCH 361/388] Upload --- src/DomDocuments/BaseDocument.php | 4 ++-- src/Mappers/BaseMapper.php | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/DomDocuments/BaseDocument.php b/src/DomDocuments/BaseDocument.php index 24232fd1..c08a83cc 100644 --- a/src/DomDocuments/BaseDocument.php +++ b/src/DomDocuments/BaseDocument.php @@ -35,11 +35,11 @@ public function __construct($version = "1.0", $encoding = "UTF-8") * * @param string $tag * @param string|null $textContent - * @param $object + * @param HasMessageInterface|null $object * @param array $methodToAttributeMap * @return \DOMElement */ - final protected function createNodeWithTextContent(string $tag, ?string $textContent, $object = null, array $methodToAttributeMap = []): \DOMElement + final protected function createNodeWithTextContent(string $tag, ?string $textContent, ?HasMessageInterface $object = null, array $methodToAttributeMap = []): \DOMElement { $element = $this->createElement($tag); diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index 07922d88..fb773935 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -115,7 +115,7 @@ protected static function parseMoneyAttribute(?float $value, ?string $currency): return Util::parseMoney($value, new Currency($currency)); } - protected static function parseUnknownEntity($object, \DOMElement $element, string $fieldTagName): string + protected static function parseUnknownEntity(HasMessageInterface $object, \DOMElement $element, string $fieldTagName): string { if (is_a($object, \PhpTwinfield\DimensionGroupDimension::class)) { $type = self::getField($element, "type", $object); @@ -145,8 +145,17 @@ protected static function parseUnknownEntity($object, \DOMElement $element, stri } } - /** @var SomeClassWithMethodsetCode $object2 */ - protected static function parseObjectAttribute(?string $objectClass, $object, \DOMElement $element, string $fieldTagName, array $attributes = []) + /** + * Parse a code referring to a Twinfield Entity / PHP Twinfield object + * + * @param string|null $objectClass + * @param HasMessageInterface $object + * @param \DOMElement $element + * @param string $fieldTagName + * @param array $attributes + * @return HasCodeInterface + */ + protected static function parseObjectAttribute(?string $objectClass, HasMessageInterface $object, \DOMElement $element, string $fieldTagName, array $attributes = []) { $value = self::getField($element, $fieldTagName, $object); From 508afebaa0c320476c2394b365b524f102440328 Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 26 Jun 2019 21:05:42 +0200 Subject: [PATCH 362/388] Upload --- src/DomDocuments/BaseDocument.php | 2 ++ src/Mappers/BaseMapper.php | 1 + 2 files changed, 3 insertions(+) diff --git a/src/DomDocuments/BaseDocument.php b/src/DomDocuments/BaseDocument.php index c08a83cc..e204aba2 100644 --- a/src/DomDocuments/BaseDocument.php +++ b/src/DomDocuments/BaseDocument.php @@ -2,6 +2,8 @@ namespace PhpTwinfield\DomDocuments; +use PhpTwinfield\HasMessageInterface; + /** * You should add a public function add($instance): void method which will add an instance to the rootElement, so * that you can send multiple elements in one go. diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index fb773935..29c12ba9 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -5,6 +5,7 @@ use Money\Currency; use Money\Money; use PhpTwinfield\ApiConnectors\OfficeApiConnector; +use PhpTwinfield\HasCodeInterface; use PhpTwinfield\HasMessageInterface; use PhpTwinfield\Message\Message; use PhpTwinfield\Office; From 6fd649ea0bd585624f3d90c4c0efe5230c1ed6bd Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 26 Jun 2019 21:50:17 +0200 Subject: [PATCH 363/388] Upload --- src/Article.php | 18 +++++++++++++ src/AssetMethod.php | 18 +++++++++++++ src/Customer.php | 54 +++++++++++++++++++++++++++++++++++++++ src/Invoice.php | 18 +++++++++++++ src/Rate.php | 18 +++++++++++++ src/Supplier.php | 54 +++++++++++++++++++++++++++++++++++++++ src/VatCodePercentage.php | 18 +++++++++++++ 7 files changed, 198 insertions(+) diff --git a/src/Article.php b/src/Article.php index f7454972..83fa68e6 100644 --- a/src/Article.php +++ b/src/Article.php @@ -80,4 +80,22 @@ public function removeLine($index) return false; } } + + public function removeLineByID($id) + { + $found = false; + + foreach ($this->lines as $index => $line) { + if ($id == $line->getID()) { + unset($this->lines[$index]); + $found = true; + } + } + + if ($found) { + return true; + } + + return false; + } } diff --git a/src/AssetMethod.php b/src/AssetMethod.php index 72535571..1155fd38 100644 --- a/src/AssetMethod.php +++ b/src/AssetMethod.php @@ -98,4 +98,22 @@ public function removeFreeText($index) return false; } } + + public function removeFreeTextByID($id) + { + $found = false; + + foreach ($this->freeTexts as $index => $freeText) { + if ($id == $freeText->getID()) { + unset($this->freeTexts[$index]); + $found = true; + } + } + + if ($found) { + return true; + } + + return false; + } } diff --git a/src/Customer.php b/src/Customer.php index ab8cc629..4c989397 100644 --- a/src/Customer.php +++ b/src/Customer.php @@ -122,6 +122,24 @@ public function removeAddress($index) return false; } } + + public function removeAddressByID($id) + { + $found = false; + + foreach ($this->addresses as $index => $address) { + if ($id == $address->getID()) { + unset($this->addresses[$index]); + $found = true; + } + } + + if ($found) { + return true; + } + + return false; + } public function getBanks() { @@ -143,6 +161,24 @@ public function removeBank($index) return false; } } + + public function removeBankByID($id) + { + $found = false; + + foreach ($this->banks as $index => $bank) { + if ($id == $bank->getID()) { + unset($this->banks[$index]); + $found = true; + } + } + + if ($found) { + return true; + } + + return false; + } public function getPostingRules() { @@ -164,4 +200,22 @@ public function removePostingRule($index) return false; } } + + public function removePostingRuleByID($id) + { + $found = false; + + foreach ($this->postingRules as $index => $postingRule) { + if ($id == $postingRule->getID()) { + unset($this->postingRules[$index]); + $found = true; + } + } + + if ($found) { + return true; + } + + return false; + } } diff --git a/src/Invoice.php b/src/Invoice.php index 4f8aa451..26b6b267 100644 --- a/src/Invoice.php +++ b/src/Invoice.php @@ -112,6 +112,24 @@ public function removeLine($index) return false; } } + + public function removeLineByID($id) + { + $found = false; + + foreach ($this->lines as $index => $line) { + if ($id == $line->getID()) { + unset($this->lines[$index]); + $found = true; + } + } + + if ($found) { + return true; + } + + return false; + } /** * @return InvoiceVatLine[] diff --git a/src/Rate.php b/src/Rate.php index 41ab8a6a..06cd78c3 100644 --- a/src/Rate.php +++ b/src/Rate.php @@ -64,4 +64,22 @@ public function removeRateChange($index) return false; } } + + public function removeRateChangeByID($id) + { + $found = false; + + foreach ($this->rateChanges as $index => $rateChange) { + if ($id == $rateChange->getID()) { + unset($this->rateChanges[$index]); + $found = true; + } + } + + if ($found) { + return true; + } + + return false; + } } diff --git a/src/Supplier.php b/src/Supplier.php index 61c9894f..26e690f2 100644 --- a/src/Supplier.php +++ b/src/Supplier.php @@ -109,6 +109,24 @@ public function removeAddress($index) return false; } } + + public function removeAddressByID($id) + { + $found = false; + + foreach ($this->addresses as $index => $address) { + if ($id == $address->getID()) { + unset($this->addresses[$index]); + $found = true; + } + } + + if ($found) { + return true; + } + + return false; + } public function getBanks() { @@ -130,6 +148,24 @@ public function removeBank($index) return false; } } + + public function removeBankByID($id) + { + $found = false; + + foreach ($this->banks as $index => $bank) { + if ($id == $bank->getID()) { + unset($this->banks[$index]); + $found = true; + } + } + + if ($found) { + return true; + } + + return false; + } public function getPostingRules() { @@ -151,4 +187,22 @@ public function removePostingRule($index) return false; } } + + public function removePostingRuleByID($id) + { + $found = false; + + foreach ($this->postingRules as $index => $postingRule) { + if ($id == $postingRule->getID()) { + unset($this->postingRules[$index]); + $found = true; + } + } + + if ($found) { + return true; + } + + return false; + } } diff --git a/src/VatCodePercentage.php b/src/VatCodePercentage.php index 34dd28ae..36cbbb24 100644 --- a/src/VatCodePercentage.php +++ b/src/VatCodePercentage.php @@ -44,4 +44,22 @@ public function removeAccount($index) return false; } } + + public function removeAccountByID($id) + { + $found = false; + + foreach ($this->accounts as $index => $account) { + if ($id == $account->getID()) { + unset($this->accounts[$index]); + $found = true; + } + } + + if ($found) { + return true; + } + + return false; + } } From 29b3167481dee86f6f0b5c3c88aa47f1c0e43ce0 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 27 Jun 2019 11:51:52 +0200 Subject: [PATCH 364/388] Upload --- examples/Activity.php | 4 + examples/Article.php | 12 +- examples/AssetMethod.php | 4 + examples/CostCenter.php | 4 + examples/Currency.php | 4 + examples/Customer.php | 18 +- examples/DimensionGroup.php | 4 + examples/DimensionType.php | 1 + examples/FixedAsset.php | 434 ++++++++++++++++++ examples/GeneralLedger.php | 4 + examples/Invoice.php | 14 +- examples/Project.php | 4 + examples/Rate.php | 5 +- examples/Supplier.php | 14 +- examples/VatCode.php | 4 + src/DomDocuments/TransactionsDocument.php | 12 +- .../Level34/FixedAsset/FreeText4Field.php | 4 +- .../Level34/FixedAsset/FreeText5Field.php | 4 +- src/Fields/FreeText1Field.php | 4 +- src/Fields/FreeText2Field.php | 4 +- src/Fields/FreeText3Field.php | 4 +- src/Mappers/TransactionMapper.php | 6 +- .../BankTransactionIntegrationTest.php | 6 +- .../CashTransactionIntegrationTest.php | 6 +- .../JournalTransactionIntegrationTest.php | 6 +- .../PurchaseTransactionIntegrationTest.php | 6 +- .../SalesTransactionIntegrationTest.php | 6 +- 27 files changed, 541 insertions(+), 57 deletions(-) create mode 100644 examples/FixedAsset.php diff --git a/examples/Activity.php b/examples/Activity.php index d13cc1f2..9cae6cd0 100644 --- a/examples/Activity.php +++ b/examples/Activity.php @@ -252,6 +252,7 @@ echo "Result of copy process: {$activityCopy->getResult()}
"; echo "Code of copied Activity: {$activityCopy->getCode()}
"; + echo "Status of copied Activity: {$activityCopy->getStatus()}
"; } // Create a new Activity from scratch, alternatively read an existing Activity as shown above and than modify the values in the same way as shown below @@ -334,6 +335,7 @@ echo "Result of creation process: {$activityNew->getResult()}
"; echo "Code of new Activity: {$activityNew->getCode()}
"; + echo "Status of new Activity: {$activityNew->getStatus()}
"; } // Delete an Activity based off the passed in code and optionally the office. @@ -349,4 +351,6 @@ echo ""; echo "Result of deletion process: {$activityDeleted->getResult()}
"; + echo "Code of deleted Activity: {$activityDeleted->getCode()}
"; + echo "Status of deleted Activity: {$activityDeleted->getStatus()}
"; } \ No newline at end of file diff --git a/examples/Article.php b/examples/Article.php index 58784619..469f7d56 100644 --- a/examples/Article.php +++ b/examples/Article.php @@ -103,8 +103,8 @@ /* ArticleLine * \PhpTwinfield\ArticleLine - * Available getters: getFreeText1, getFreeText2, getFreetext3, getID, getInUse, getMessages, getName, getResult, getShortName, getStatus, getSubCode, getUnits, getUnitsPriceExcl, getUnitsPriceInc, hasMessages - * Available setters: setFreeText1, setFreeText2, setFreetext3, setID, setName, setShortName, setStatus, setSubCode, setUnits, setUnitsPriceExcl, setUnitsPriceInc + * Available getters: getFreeText1, getFreeText2, getFreeText3, getID, getInUse, getMessages, getName, getResult, getShortName, getStatus, getSubCode, getUnits, getUnitsPriceExcl, getUnitsPriceInc, hasMessages + * Available setters: setFreeText1, setFreeText2, setFreeText3, setID, setName, setShortName, setStatus, setSubCode, setUnits, setUnitsPriceExcl, setUnitsPriceInc */ if ($executeListAllWithFilter || $executeListAllWithoutFilter) { @@ -168,7 +168,7 @@ echo "FreeText1 (string): " . Util::objectToStr($articleLine->getFreeText1()) . "
"; // string|null echo "FreeText2 (\\PhpTwinfield\\CostCenter):
" . print_r($articleLine->getFreeText2(), true) . "

"; // CostCenter|null Optional. The cost center linked to the article. echo "FreeText2 (string): " . Util::objectToStr($articleLine->getFreeText2()) . "
"; // string|null - echo "FreeText3: {$articleLine->getFreetext3()}
"; // string|null Free text element 3 + echo "FreeText3: {$articleLine->getFreeText3()}
"; // string|null Free text element 3 echo "ID: {$articleLine->getID()}
"; // int|null Line ID echo "InUse (bool): {$articleLine->getInUse()}
"; // bool|null Read-only attribute. Indicates that the sub item has been used in an invoice. echo "InUse (string): " . Util::formatBoolean($articleLine->getInUse()) . "
"; // string|null @@ -212,6 +212,7 @@ echo "Result of copy process: {$articleCopy->getResult()}
"; echo "Code of copied Article: {$articleCopy->getCode()}
"; + echo "Status of copied Article: {$articleCopy->getStatus()}
"; } // Create a new Article from scratch, alternatively read an existing Article as shown above and than modify the values in the same way as shown below @@ -254,7 +255,7 @@ $freeText2->setCode('00000'); //$articleLine->setFreeText2($freeText1); // CostCenter|null Optional. The cost center linked to the article. //$articleLine->setFreeText2(\PhpTwinfield\CostCenter::fromCode('00000')); // string|null - //$articleLine->setFreetext3(""); // string|null Free text element 3 + //$articleLine->setFreeText3(""); // string|null Free text element 3 $articleLine->setID(1); // int|null Line ID. $articleLine->setName("Example Sub Article"); // string|null Sub article name. $articleLine->setShortName("ExmplSubArt"); // string|null Sub article short name. @@ -281,6 +282,7 @@ echo "Result of creation process: {$articleNew->getResult()}
"; echo "Code of new Article: {$articleNew->getCode()}
"; + echo "Status of new Article: {$articleNew->getStatus()}
"; } // Delete a Article based off the passed in code and optionally the office. @@ -296,4 +298,6 @@ echo ""; echo "Result of deletion process: {$articleDeleted->getResult()}
"; + echo "Code of deleted Article: {$articleDeleted->getCode()}
"; + echo "Status of deleted Article: {$articleDeleted->getStatus()}
"; } \ No newline at end of file diff --git a/examples/AssetMethod.php b/examples/AssetMethod.php index 490e6f1f..78b0cd9c 100644 --- a/examples/AssetMethod.php +++ b/examples/AssetMethod.php @@ -232,6 +232,7 @@ echo "Result of copy process: {$assetMethodCopy->getResult()}
"; echo "Code of copied AssetMethod: {$assetMethodCopy->getCode()}
"; + echo "Status of copied AssetMethod: {$assetMethodCopy->getStatus()}
"; } // Create a new AssetMethod from scratch, alternatively read an existing AssetMethod as shown above and than modify the values in the same way as shown below @@ -331,6 +332,7 @@ echo "Result of creation process: {$assetMethodNew->getResult()}
"; echo "Code of new AssetMethod: {$assetMethodNew->getCode()}
"; + echo "Status of new AssetMethod: {$assetMethodNew->getStatus()}
"; } // Delete an AssetMethod based off the passed in code and optionally the office. @@ -346,4 +348,6 @@ echo ""; echo "Result of deletion process: {$assetMethodDeleted->getResult()}
"; + echo "Code of deleted AssetMethod: {$assetMethodDeleted->getCode()}
"; + echo "Status of deleted AssetMethod: {$assetMethodDeleted->getStatus()}
"; } \ No newline at end of file diff --git a/examples/CostCenter.php b/examples/CostCenter.php index ba3feb02..c77191a1 100644 --- a/examples/CostCenter.php +++ b/examples/CostCenter.php @@ -168,6 +168,7 @@ echo "Result of copy process: {$costCenterCopy->getResult()}
"; echo "Code of copied CostCenter: {$costCenterCopy->getCode()}
"; + echo "Status of copied CostCenter: {$costCenterCopy->getStatus()}
"; } // Create a new CostCenter from scratch, alternatively read an existing CostCenter as shown above and than modify the values in the same way as shown below @@ -197,6 +198,7 @@ echo "Result of creation process: {$costCenterNew->getResult()}
"; echo "Code of new CostCenter: {$costCenterNew->getCode()}
"; + echo "Status of new CostCenter: {$costCenterNew->getStatus()}
"; } // Delete a CostCenter based off the passed in code and optionally the office. @@ -212,4 +214,6 @@ echo ""; echo "Result of deletion process: {$costCenterDeleted->getResult()}
"; + echo "Code of deleted CostCenter: {$costCenterDeleted->getCode()}
"; + echo "Status of deleted CostCenter: {$costCenterDeleted->getStatus()}
"; } \ No newline at end of file diff --git a/examples/Currency.php b/examples/Currency.php index 660ef404..02e82d28 100644 --- a/examples/Currency.php +++ b/examples/Currency.php @@ -168,6 +168,7 @@ echo "Result of copy process: {$currencyCopy->getResult()}
"; echo "Code of copied Currency: {$currencyCopy->getCode()}
"; + echo "Status of copied Currency: {$currencyCopy->getStatus()}
"; } // Create a new Currency from scratch, alternatively read an existing Currency as shown above and than modify the values in the same way as shown below @@ -211,6 +212,7 @@ echo "Result of creation process: {$currencyNew->getResult()}
"; echo "Code of new Currency: {$currencyNew->getCode()}
"; + echo "Status of new Currency: {$currencyNew->getStatus()}
"; } // Delete a Currency based off the passed in code and optionally the office. @@ -226,4 +228,6 @@ echo ""; echo "Result of deletion process: {$currencyDeleted->getResult()}
"; + echo "Code of deleted Currency: {$currencyDeleted->getCode()}
"; + echo "Status of deleted Currency: {$currencyDeleted->getStatus()}
"; } \ No newline at end of file diff --git a/examples/Customer.php b/examples/Customer.php index f191bdf6..7bb73f2b 100644 --- a/examples/Customer.php +++ b/examples/Customer.php @@ -143,8 +143,8 @@ /* CustomerCreditManagement * \PhpTwinfield\CustomerCreditManagement - * Available getters: getBaseCreditLimit, getBlocked, getBlockedLocked, getBlockedModified, getComment, getFreeText1, getFreetext2, getFreetext3, getMessages, getReminderEmail, getResponsibleUser, getResult, getSendReminder, hasMessages - * Available setters: setBaseCreditLimit, setBlocked, setBlockedLocked, setBlockedModified, setComment, setFreeText1, setFreetext2, setFreetext3, setReminderEmail, setResponsibleUser, setSendReminder + * Available getters: getBaseCreditLimit, getBlocked, getBlockedLocked, getBlockedModified, getComment, getFreeText1, getFreeText2, getFreeText3, getMessages, getReminderEmail, getResponsibleUser, getResult, getSendReminder, hasMessages + * Available setters: setBaseCreditLimit, setBlocked, setBlockedLocked, setBlockedModified, setComment, setFreeText1, setFreeText2, setFreeText3, setReminderEmail, setResponsibleUser, setSendReminder */ /* CustomerAddress @@ -203,7 +203,7 @@ echo "EndYear: {$customer->getEndYear()}
"; // int|null Determines together with endperiod the period till which the dimension may be used. echo "Group (\\PhpTwinfield\\DimensionGroup):
" . print_r($customer->getGroup(), true) . "

"; // DimensionGroup|null Sets the dimension group. See Dimension group. echo "Group (string): " . Util::objectToStr($customer->getGroup()) . "
"; // string|null - echo "InUse (bool): {$customer->getInUse()}
"; // bool|null Indicates whether the balancesheet is used in a financial transaction or not. Read-only attribute. + echo "InUse (bool): {$customer->getInUse()}
"; // bool|null Indicates whether the dimension is used in a financial transaction or not. Read-only attribute. echo "InUse (string): " . Util::formatBoolean($customer->getInUse()) . "
"; // string|null if ($customer->hasMessages()) { // bool Object contains (error) messages true/false. @@ -305,8 +305,8 @@ echo "Comment: {$customerCreditManagement->getComment()}
"; // string|null Comment. echo "Freetext1 (bool): {$customerCreditManagement->getFreeText1()}
"; // bool|null Right of use. echo "Freetext1 (string): " . Util::formatBoolean($customerCreditManagement->getFreeText1()) ."
"; // string|null - echo "Freetext2: {$customerCreditManagement->getFreetext2()}
"; // string|null Segment code. - echo "Freetext3: {$customerCreditManagement->getFreetext3()}
"; // string|null Not in use. + echo "Freetext2: {$customerCreditManagement->getFreeText2()}
"; // string|null Segment code. + echo "Freetext3: {$customerCreditManagement->getFreeText3()}
"; // string|null Not in use. if ($customerCreditManagement->hasMessages()) { // bool Object contains (error) messages true/false. echo "Messages: " . print_r($customerCreditManagement->getMessages(), true) . "
"; // Array|null (Error) messages. @@ -460,6 +460,7 @@ echo "Result of copy process: {$customerCopy->getResult()}
"; echo "Code of copied Customer: {$customerCopy->getCode()}
"; + echo "Status of copied Customer: {$customerCopy->getStatus()}
"; } // Create a new Customer from scratch, alternatively read an existing Customer as shown above and than modify the values in the same way as shown below @@ -505,8 +506,8 @@ $customerCreditManagement->setBlockedLocked(false); // bool|null $customerCreditManagement->setComment('Comment'); // string|null Comment. $customerCreditManagement->setFreeText1(true); // bool|null Right of use. - $customerCreditManagement->setFreetext2(2); // string|null Segment code. - $customerCreditManagement->setFreetext3(''); // string|null + $customerCreditManagement->setFreeText2(2); // string|null Segment code. + $customerCreditManagement->setFreeText3(''); // string|null $customerCreditManagement->setReminderEmail('test@example.com'); // string|null Mandatory if sendreminder is email. $user = new \PhpTwinfield\User; $user->setCode('TWINAPPS'); @@ -648,6 +649,7 @@ echo "Result of creation process: {$customerNew->getResult()}
"; echo "Code of new Customer: {$customerNew->getCode()}
"; + echo "Status of new Customer: {$customerNew->getStatus()}
"; } // Delete a Customer based off the passed in code and optionally the office. @@ -663,4 +665,6 @@ echo ""; echo "Result of deletion process: {$customerDeleted->getResult()}
"; + echo "Code of deleted Customer: {$customerDeleted->getCode()}
"; + echo "Status of deleted Customer: {$customerDeleted->getStatus()}
"; } \ No newline at end of file diff --git a/examples/DimensionGroup.php b/examples/DimensionGroup.php index f5847bee..b71551b6 100644 --- a/examples/DimensionGroup.php +++ b/examples/DimensionGroup.php @@ -178,6 +178,7 @@ echo "Result of copy process: {$dimensionGroupCopy->getResult()}
"; echo "Code of copied DimensionGroup: {$dimensionGroupCopy->getCode()}
"; + echo "Status of copied DimensionGroup: {$dimensionGroupCopy->getStatus()}
"; } // Create a new DimensionGroup from scratch, alternatively read an existing DimensionGroup as shown above and than modify the values in the same way as shown below @@ -221,6 +222,7 @@ echo "Result of creation process: {$dimensionGroupNew->getResult()}
"; echo "Code of new DimensionGroup: {$dimensionGroupNew->getCode()}
"; + echo "Status of new DimensionGroup: {$dimensionGroupNew->getStatus()}
"; } // Delete a DimensionGroup based off the passed in code and optionally the office. @@ -236,4 +238,6 @@ echo ""; echo "Result of deletion process: {$dimensionGroupDeleted->getResult()}
"; + echo "Code of deleted DimensionGroup: {$dimensionGroupDeleted->getCode()}
"; + echo "Status of deleted DimensionGroup: {$dimensionGroupDeleted->getStatus()}
"; } \ No newline at end of file diff --git a/examples/DimensionType.php b/examples/DimensionType.php index d13021ba..a17be814 100644 --- a/examples/DimensionType.php +++ b/examples/DimensionType.php @@ -202,4 +202,5 @@ echo "Result of modify process: {$dimensionTypeModify->getResult()}
"; echo "Code of modified DimensionType: {$dimensionTypeModify->getCode()}
"; + echo "Status of modified DimensionType: {$dimensionTypeModify->getStatus()}
"; } \ No newline at end of file diff --git a/examples/FixedAsset.php b/examples/FixedAsset.php new file mode 100644 index 00000000..fb14a15c --- /dev/null +++ b/examples/FixedAsset.php @@ -0,0 +1,434 @@ + modifiedsince = '20190101170000' +if ($executeListAllWithFilter) { + $options = array('modifiedsince' => '20190101170000'); + + try { + $fixedAssets = $fixedAssetApiConnector->listAll("6*", 0, 1, 10, $options); + } catch (ResponseException $e) { + $fixedAssets = $e->getReturnedObject(); + } + + echo "
";
+    print_r($fixedAssets);
+    echo "
"; +} + +//List all with default settings (pattern '*', field 0, firstRow 1, maxRows 100, options []) +if ($executeListAllWithoutFilter) { + try { + $fixedAssets = $fixedAssetApiConnector->listAll(); + } catch (ResponseException $e) { + $fixedAssets = $e->getReturnedObject(); + } + + echo "
";
+    print_r($fixedAssets);
+    echo "
"; +} + +/* FixedAsset + * \PhpTwinfield\FixedAsset + * Available getters: getBehaviour, getCode, getGroup, getInUse, getMessages, getName, getOffice, getResult, getShortName, getStatus, getTouched, getType, getUID, hasMessages, getFinancials, getFixedAssets + * Available setters: fromCode, setBehaviour, setCode, setGroup, setName, setOffice, setShortName, setStatus, setType, setTypeFromString, setFinancials, setFixedAssets + */ + +/* FixedAssetFinancials + * \PhpTwinfield\FixedAssetFinancials + * Available getters: getAccountType, getLevel, getMatchType, getMessages, getResult, getSubAnalyse, getSubstituteWith, getSubstituteWithID, getSubstitutionLevel, getVatCode, getVatCodeFixed, hasMessages + * Available setters: setAccountType, setLevel, setMatchType, setSubAnalyse, setSubstituteWith, setSubstituteWithID, setSubstitutionLevel, setVatCode, setVatCodeFixed + */ + +/* FixedAssetFixedAssets + * \PhpTwinfield\FixedAssetFixedAssets + * Available getters: getBeginPeriod, getBeginPeriodLocked, getFreeText1, getFreeText1Locked, getFreeText2, getFreeText2Locked, getFreeText3, getFreeText3Locked, getFreeText4, getFreeText4Locked, getFreeText5, getFreeText5Locked, getLastDepreciation, getLastDepreciationLocked, getMessages, getMethod, getMethodLocked, + * getNrOfPeriods, getNrOfPeriodsInherited, getNrOfPeriodsLocked, getPercentage, getPercentageLocked, getPurchaseDate, getPurchaseDateLocked, getResidualValue, getResidualValueLocked, getResult, getSellDate, getSellDateLocked, getStatus, getStatusLocked, getStopValue, getStopValueLocked, getTransactionLinesLocked, hasMessages, getTransactionLines + * + * Available setters: setBeginPeriod, setBeginPeriodLocked, setFreeText1, setFreeText1Locked, setFreeText2, setFreeText2Locked, setFreeText3, setFreeText3Locked, setFreeText4, setFreeText4Locked, setFreeText5, setFreeText5Locked, setLastDepreciation, setLastDepreciationLocked, setMethod, setMethodLocked, + * setNrOfPeriods, setNrOfPeriodsInherited, setNrOfPeriodsLocked, setPercentage, setPercentageLocked, setPurchaseDate, setPurchaseDateLocked, setResidualValue, setResidualValueLocked, setSellDate, setSellDateLocked, setStatus, setStatusLocked, setStopValue, setStopValueLocked, setTransactionLinesLocked, addTransactionLine, removeTransactionLine + * + */ + +/* FixedAssetTransactionLine + * \PhpTwinfield\FixedAssetTransactionLine + * Available getters: getAmount, getAmountLocked, getCode, getCodeLocked, getDim1, getDim1Locked, getDim2, getDim2Locked, getDim3, getDim3Locked, getDim4, getDim4Locked, getDim5, getDim5Locked, getDim6, getDim6Locked, getLine, getLineLocked, getMessages, getNumber, getNumberLocked, getPeriod, getPeriodLocked, getResult, hasMessages + * Available setAmount, setAmountLocked, setCode, setCodeLocked, setDim1, setDim1Locked, setDim2, setDim2Locked, setDim3, setDim3Locked, setDim4, setDim4Locked, setDim5, setDim5Locked, setDim6, setDim6Locked, setLine, setLineLocked, setNumber, setNumberLocked, setPeriod, setPeriodLocked + */ + +if ($executeListAllWithFilter || $executeListAllWithoutFilter) { + foreach ($fixedAssets as $key => $fixedAsset) { + echo "FixedAsset {$key}
"; + echo "Code: {$fixedAsset->getCode()}
"; + echo "Name: {$fixedAsset->getName()}

"; + } +} + +// Read a FixedAsset based off the passed in code and optionally the office. +if ($executeRead) { + try { + $fixedAsset = $fixedAssetApiConnector->get("60001", $office); + } catch (ResponseException $e) { + $fixedAsset = $e->getReturnedObject(); + } + + echo "
";
+    print_r($fixedAsset);
+    echo "
"; + + echo "FixedAsset
"; + echo "Behaviour: {$fixedAsset->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. + echo "Code: {$fixedAsset->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the AST Dimension type. + echo "Group (\\PhpTwinfield\\DimensionGroup):
" . print_r($fixedAsset->getGroup(), true) . "

"; // DimensionGroup|null Sets the dimension group. See Dimension group. + echo "Group (string): " . Util::objectToStr($fixedAsset->getGroup()) . "
"; // string|null + echo "InUse (bool): {$fixedAsset->getInUse()}
"; // bool|null Indicates whether the fixed asset is used in a financial transaction or not. Read-only attribute. + echo "InUse (string): " . Util::formatBoolean($fixedAsset->getInUse()) . "
"; // string|null + + if ($fixedAsset->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($fixedAsset->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Name: {$fixedAsset->getName()}
"; // string|null Name of the dimension. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($fixedAsset->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): " . Util::objectToStr($fixedAsset->getOffice()) . "
"; // string|null + echo "Result: {$fixedAsset->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$fixedAsset->getShortName()}
"; // string|null Not in use. + echo "Status: {$fixedAsset->getStatus()}
"; // Status|null Status of the fixed asset. + echo "Touched: {$fixedAsset->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. + echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($fixedAsset->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of fixed assets is AST. + echo "Type (string): " . Util::objectToStr($fixedAsset->getType()) . "
"; // string|null + echo "UID: {$fixedAsset->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. + + echo "FixedAssetFinancials
"; + $fixedAssetFinancials = $fixedAsset->getFinancials(); // FixedAssetFinancials|null FixedAssetFinancials object. + + echo "AccountType: {$fixedAssetFinancials->getAccountType()}
"; // AccountType|null Fixed value inherit. Read-only attribute. + echo "Level: {$fixedAssetFinancials->getLevel()}
"; // int|null Specifies the dimension level. Normally the level of fixed assets is level 3. Read-only attribute. + echo "MatchType: {$fixedAssetFinancials->getMatchType()}
"; // MatchType|null The matchable value of the balance account. Read-only attribute. + + if ($fixedAssetFinancials->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($fixedAssetFinancials->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Result: {$fixedAssetFinancials->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "SubAnalyse: {$fixedAssetFinancials->getSubAnalyse()}
"; // SubAnalyse|null Is subanalyses needed. Read-only attribute. + echo "SubstituteWith (\\PhpTwinfield\\CostCenter):
" . print_r($fixedAssetFinancials->getSubstituteWith(), true) . "

"; // CostCenter|null Dimension code of the cost center. + echo "SubstituteWith (string): " . Util::objectToStr($fixedAssetFinancials->getSubstituteWith()) . "
"; // string|null + echo "SubstituteWithID: {$fixedAssetFinancials->getSubstituteWithID()}
"; // string|null + echo "SubstitutionLevel: {$fixedAssetFinancials->getSubstitutionLevel()}
"; // int|null Dimension level of the cost center. + echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($fixedAssetFinancials->getVatCode(), true) . "

"; // VatCode|null Default VAT code. + echo "VatCode (string): " . Util::objectToStr($fixedAssetFinancials->getVatCode()) . "
"; // string|null + echo "VatCode Fixed (bool): {$fixedAssetFinancials->getVatCodeFixed()}
"; // bool|null + echo "VatCode Fixed (string): " . Util::formatBoolean($fixedAssetFinancials->getVatCodeFixed()) . "
"; // string|null + + $fixedAssetFixedAssets = $fixedAsset->getFixedAssets(); // array|null Array of FixedAssetFixedAssets objects. + + echo "FixedAssetFixedAssets {$key}
"; + + echo "BeginPeriod: {$fixedAssetFixedAssets->getBeginPeriod()}
"; // string|null Period in YYYY/PP format. The period from which the depreciation to begin. + echo "BeginPeriod Locked (bool): {$fixedAssetFixedAssets->getBeginPeriodLocked()}
"; // bool|null + echo "BeginPeriod Locked (string): " . Util::formatBoolean($fixedAssetFixedAssets->getBeginPeriodLocked()) . "
"; // string|null + echo "FreeText1: {$fixedAssetFixedAssets->getFreeText1()}
"; // string|null Free text field 1 as set on the asset method. + echo "FreeText1 Locked (bool): {$fixedAssetFixedAssets->getFreeText1Locked()}
"; // bool|null + echo "FreeText1 Locked (string): " . Util::formatBoolean($fixedAssetFixedAssets->getFreeText1Locked()) . "
"; // string|null + echo "FreeText2: {$fixedAssetFixedAssets->getFreeText2()}
"; // string|null Free text field 2 as set on the asset method. + echo "FreeText2 Locked (bool): {$fixedAssetFixedAssets->getFreeText2Locked()}
"; // bool|null + echo "FreeText2 Locked (string): " . Util::formatBoolean($fixedAssetFixedAssets->getFreeText2Locked()) . "
"; // string|null + echo "FreeText3: {$fixedAssetFixedAssets->getFreeText3()}
"; // string|null Free text field 3 as set on the asset method. + echo "FreeText3 Locked (bool): {$fixedAssetFixedAssets->getFreeText3Locked()}
"; // bool|null + echo "FreeText3 Locked (string): " . Util::formatBoolean($fixedAssetFixedAssets->getFreeText3Locked()) . "
"; // string|null + echo "FreeText4: {$fixedAssetFixedAssets->getFreeText4()}
"; // string|null Free text field 4 as set on the asset method. + echo "FreeText4 Locked (bool): {$fixedAssetFixedAssets->getFreeText4Locked()}
"; // bool|null + echo "FreeText4 Locked (string): " . Util::formatBoolean($fixedAssetFixedAssets->getFreeText4Locked()) . "
"; // string|null + echo "FreeText5: {$fixedAssetFixedAssets->getFreeText5()}
"; // string|null Free text field 5 as set on the asset method. + echo "FreeText5 Locked (bool): {$fixedAssetFixedAssets->getFreeText5Locked()}
"; // bool|null + echo "FreeText5 Locked (string): " . Util::formatBoolean($fixedAssetFixedAssets->getFreeText5Locked()) . "
"; // string|null + echo "LastDepreciation: {$fixedAssetFixedAssets->getLastDepreciation()}
"; // string|null Period in YYYY/PP format. The period of the last depreciation of the asset. + echo "LastDepreciation Locked (bool): {$fixedAssetFixedAssets->getLastDepreciationLocked()}
"; // bool|null + echo "LastDepreciation Locked (string): " . Util::formatBoolean($fixedAssetFixedAssets->getLastDepreciationLocked()) . "
"; // string|null + + if ($fixedAssetFixedAssets->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($fixedAssetFixedAssets->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Method (\\PhpTwinfield\\AssetMethod):
" . print_r($fixedAssetFixedAssets->getMethod(), true) . "

"; // AssetMethod|null The asset method. See Asset methods. + echo "Method (string): " . Util::objectToStr($fixedAssetFixedAssets->getMethod()) . "
"; // string|null + echo "Method Locked (bool): {$fixedAssetFixedAssets->getMethodLocked()}
"; // bool|null + echo "Method Locked (string): " . Util::formatBoolean($fixedAssetFixedAssets->getMethodLocked()) . "
"; // string|null + echo "NrOfPeriods: {$fixedAssetFixedAssets->getNrOfPeriods()}
"; // int|null The number of periods over which the asset should be depreciated. + echo "NrOfPeriods Inherited (bool): {$fixedAssetFixedAssets->getNrOfPeriodsInherited()}
"; // bool|null + echo "NrOfPeriods Inherited (string): " . Util::formatBoolean($fixedAssetFixedAssets->getNrOfPeriodsInherited()) . "
"; // string|null + echo "NrOfPeriods Locked (bool): {$fixedAssetFixedAssets->getNrOfPeriodsLocked()}
"; // bool|null + echo "NrOfPeriods Locked (string): " . Util::formatBoolean($fixedAssetFixedAssets->getNrOfPeriodsLocked()) . "
"; // string|null + echo "Percentage: {$fixedAssetFixedAssets->getPercentage()}
"; // int|null The depreciation percentage. + echo "Percentage Locked (bool): {$fixedAssetFixedAssets->getPercentageLocked()}
"; // bool|null + echo "Percentage Locked (string): " . Util::formatBoolean($fixedAssetFixedAssets->getPercentageLocked()) . "
"; // string|null + echo "PurchaseDate (\\DateTimeInterface):
" . print_r($fixedAssetFixedAssets->getPurchaseDate(), true) . "

"; // DateTimeInterface|null The purchase date of the asset. + echo "PurchaseDate (string): " . Util::formatDate($fixedAssetFixedAssets->getPurchaseDate()) . "
"; // string|null + echo "PurchaseDate Locked (bool): {$fixedAssetFixedAssets->getPurchaseDateLocked()}
"; // bool|null + echo "PurchaseDate Locked (string): " . Util::formatBoolean($fixedAssetFixedAssets->getPurchaseDateLocked()) . "
"; // string|null + echo "ResidualValue (\\Money\\Money):
" . print_r($fixedAssetFixedAssets->getResidualValue(), true) . "

"; // Money|null The residual value of the asset at the end of the depreciation duration. + echo "ResidualValue (string): " . Util::formatMoney($fixedAssetFixedAssets->getResidualValue()) . "
"; // string|null + echo "ResidualValue Locked (bool): {$fixedAssetFixedAssets->getResidualValueLocked()}
"; // bool|null + echo "ResidualValue Locked (string): " . Util::formatBoolean($fixedAssetFixedAssets->getResidualValueLocked()) . "
"; // string|null + echo "Result: {$fixedAssetFixedAssets->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "SellDate (\\DateTimeInterface):
" . print_r($fixedAssetFixedAssets->getSellDate(), true) . "

"; // DateTimeInterface|null The date the asset is sold. + echo "SellDate (string): " . Util::formatDate($fixedAssetFixedAssets->getSellDate()) . "
"; // string|null + echo "SellDate Locked (bool): {$fixedAssetFixedAssets->getSellDateLocked()}
"; // bool|null + echo "SellDate Locked (string): " . Util::formatBoolean($fixedAssetFixedAssets->getSellDateLocked()) . "
"; // string|null + echo "Status: {$fixedAssetFixedAssets->getStatus()}
"; // FixedAssetsStatus|null The status of the asset. + echo "Status Locked (bool): {$fixedAssetFixedAssets->getStatusLocked()}
"; // bool|null The value future depreciation should stop at. + echo "Status Locked (string): " . Util::formatBoolean($fixedAssetFixedAssets->getStatusLocked()) . "
"; // string|null + echo "StopValue (\\Money\\Money):
" . print_r($fixedAssetFixedAssets->getStopValue(), true) . "

"; // Money|null Transaction line amount. + echo "StopValue (string): " . Util::formatMoney($fixedAssetFixedAssets->getStopValue()) . "
"; // string|null + echo "StopValue Locked (bool): {$fixedAssetFixedAssets->getStopValueLocked()}
"; // bool|null + echo "StopValue Locked (string): " . Util::formatBoolean($fixedAssetFixedAssets->getStopValueLocked()) . "
"; // string|null + echo "TransactionLines Locked (bool): {$fixedAssetFixedAssets->getTransactionLinesLocked()}
"; // bool|null + echo "TransactionLines Locked (string): " . Util::formatBoolean($fixedAssetFixedAssets->getTransactionLinesLocked()) . "
"; // string|null + + $fixedAssetTransactionLines = $fixedAssetFixedAssets->getTransactionLines(); // array|null Array of FixedAssetTransactionLine objects. + + foreach ($fixedAssetTransactionLines as $key => $fixedAssetTransactionLine) { + echo "FixedAssetTransactionLine {$key}
"; + + echo "Amount (\\Money\\Money):
" . print_r($fixedAssetTransactionLine->getAmount(), true) . "

"; // Money|null Transaction line amount. + echo "Amount (string): " . Util::formatMoney($fixedAssetTransactionLine->getAmount()) . "
"; // string|null + echo "Amount Locked (bool): {$fixedAssetTransactionLine->getAmountLocked()}
"; // bool|null + echo "Amount Locked (string): " . Util::formatBoolean($fixedAssetTransactionLine->getAmountLocked()) . "
"; // string|null + echo "Code (\\PhpTwinfield\\HasCodeInterface):
" . print_r($fixedAssetTransactionLine->getCode(), true) . "

"; // HasCodeInterface|null Transaction type code. + echo "Code (string): " . Util::objectToStr($fixedAssetTransactionLine->getCode()) . "
"; // string|null + echo "Code Locked (bool): {$fixedAssetTransactionLine->getCodeLocked()}
"; // bool|null + echo "Code Locked (string): " . Util::formatBoolean($fixedAssetTransactionLine->getCodeLocked()) . "
"; // string|null + echo "Dim1 (\\PhpTwinfield\\HasCodeInterface):
" . print_r($fixedAssetTransactionLine->getDim1(), true) . "

"; // HasCodeInterface|null Dimension 1 of the tranaction line. + echo "Dim1 (string): " . Util::objectToStr($fixedAssetTransactionLine->getDim1()) . "
"; // string|null + echo "Dim1 Locked (bool): {$fixedAssetTransactionLine->getDim1Locked()}
"; // bool|null + echo "Dim1 Locked (string): " . Util::formatBoolean($fixedAssetTransactionLine->getDim1Locked()) . "
"; // string|null + echo "Dim2 (\\PhpTwinfield\\HasCodeInterface):
" . print_r($fixedAssetTransactionLine->getDim2(), true) . "

"; // HasCodeInterface|null Dimension 2 of the tranaction line. + echo "Dim2 (string): " . Util::objectToStr($fixedAssetTransactionLine->getDim2()) . "
"; // string|null + echo "Dim2 Locked (bool): {$fixedAssetTransactionLine->getDim2Locked()}
"; // bool|null + echo "Dim2 Locked (string): " . Util::formatBoolean($fixedAssetTransactionLine->getDim2Locked()) . "
"; // string|null + echo "Dim3 (\\PhpTwinfield\\HasCodeInterface):
" . print_r($fixedAssetTransactionLine->getDim3(), true) . "

"; // HasCodeInterface|null Dimension 3 of the tranaction line. + echo "Dim3 (string): " . Util::objectToStr($fixedAssetTransactionLine->getDim3()) . "
"; // string|null + echo "Dim3 Locked (bool): {$fixedAssetTransactionLine->getDim3Locked()}
"; // bool|null + echo "Dim3 Locked (string): " . Util::formatBoolean($fixedAssetTransactionLine->getDim3Locked()) . "
"; // string|null + echo "Dim4 (\\PhpTwinfield\\HasCodeInterface):
" . print_r($fixedAssetTransactionLine->getDim4(), true) . "

"; // HasCodeInterface|null Dimension 4 of the tranaction line. + echo "Dim4 (string): " . Util::objectToStr($fixedAssetTransactionLine->getDim4()) . "
"; // string|null + echo "Dim4 Locked (bool): {$fixedAssetTransactionLine->getDim4Locked()}
"; // bool|null + echo "Dim4 Locked (string): " . Util::formatBoolean($fixedAssetTransactionLine->getDim4Locked()) . "
"; // string|null + echo "Dim5 (\\PhpTwinfield\\HasCodeInterface):
" . print_r($fixedAssetTransactionLine->getDim5(), true) . "

"; // HasCodeInterface|null Dimension 5 of the tranaction line. + echo "Dim5 (string): " . Util::objectToStr($fixedAssetTransactionLine->getDim5()) . "
"; // string|null + echo "Dim5 Locked (bool): {$fixedAssetTransactionLine->getDim5Locked()}
"; // bool|null + echo "Dim5 Locked (string): " . Util::formatBoolean($fixedAssetTransactionLine->getDim5Locked()) . "
"; // string|null + echo "Dim6 (\\PhpTwinfield\\HasCodeInterface):
" . print_r($fixedAssetTransactionLine->getDim6(), true) . "

"; // HasCodeInterface|null Dimension 6 of the tranaction line. + echo "Dim6 (string): " . Util::objectToStr($fixedAssetTransactionLine->getDim6()) . "
"; // string|null + echo "Dim6 Locked (bool): {$fixedAssetTransactionLine->getDim6Locked()}
"; // bool|null + echo "Dim6 Locked (string): " . Util::formatBoolean($fixedAssetTransactionLine->getDim6Locked()) . "
"; // string|null + echo "Line: {$fixedAssetTransactionLine->getLine()}
"; // int|null Transaction line number. + echo "Line Locked (bool): {$fixedAssetTransactionLine->getLineLocked()}
"; // bool|null + echo "Line Locked (string): " . Util::formatBoolean($fixedAssetTransactionLine->getLineLocked()) . "
"; // string|null + + if ($fixedAssetTransactionLine->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($fixedAssetTransactionLine->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Number: {$fixedAssetTransactionLine->getNumber()}
"; // int|null Transaction number. + echo "Number Locked (bool): {$fixedAssetTransactionLine->getNumberLocked()}
"; // bool|null + echo "Number Locked (string): " . Util::formatBoolean($fixedAssetTransactionLine->getNumberLocked()) . "
"; // string|null + echo "Period: {$fixedAssetTransactionLine->getPeriod()}
"; // string|null Period in YYYY/PP format. Period of the transaction. + echo "Period Locked (bool): {$fixedAssetTransactionLine->getPeriodLocked()}
"; // bool|null + echo "Period Locked (string): " . Util::formatBoolean($fixedAssetTransactionLine->getPeriodLocked()) . "
"; // string|null + echo "Result: {$fixedAssetTransactionLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + } +} + +// Copy an existing FixedAsset to a new entity +if ($executeCopy) { + try { + $fixedAsset = $fixedAssetApiConnector->get("60001", $office); + } catch (ResponseException $e) { + $fixedAsset = $e->getReturnedObject(); + } + + $fixedAsset->setCode(null); // string|null Set to null to let Twinfield assign a Dimension code based on the Dimension type mask + //$fixedAsset->setCode('60002'); // string|null Dimension code, must be compliant with the mask of the AST Dimension type. + + try { + $fixedAssetCopy = $fixedAssetApiConnector->send($fixedAsset); + } catch (ResponseException $e) { + $fixedAssetCopy = $e->getReturnedObject(); + } + + echo "
";
+    print_r($fixedAssetCopy);
+    echo "
"; + + echo "Result of copy process: {$fixedAssetCopy->getResult()}
"; + echo "Code of copied FixedAsset: {$fixedAssetCopy->getCode()}
"; + echo "Status of copied FixedAsset: {$fixedAssetCopy->getStatus()}
"; +} + +// Create a new FixedAsset from scratch, alternatively read an existing FixedAsset as shown above and than modify the values in the same way as shown below +if ($executeNew) { + $fixedAsset = new \PhpTwinfield\FixedAsset; + + // Required values for creating a new FixedAsset + $fixedAsset->setCode(null); // string|null Set to null to let Twinfield assign a Dimension code based on the Dimension type mask + //$fixedAsset->setCode('60002'); // string|null Dimension code, must be compliant with the mask of the AST Dimension type. + $fixedAsset->setName("Example FixedAsset"); // string|null Name of the dimension. + $fixedAsset->setOffice($office); // Office|null Office code. + $fixedAsset->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null + + // Optional values for creating a new FixedAsset + //$fixedAsset->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating status may be left empty. For deleting deleted should be used. + //$fixedAsset->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null In case a dimension that is used in a transaction is deleted, its status has been changed into hide. Hidden dimensions can be activated by using active. + + $dimensionGroup = new \PhpTwinfield\DimensionGroup; + $dimensionGroup->setCode('DIMGROUP'); + //$fixedAsset->setGroup($dimensionGroup); // DimensionGroup|null Sets the dimension group. See Dimension group. + //$fixedAsset->setGroup(\PhpTwinfield\DimensionGroup::fromCode("DIMGROUP")); // string|null + + $fixedAssetFinancials = new \PhpTwinfield\FixedAssetFinancials; + $substituteWith = new \PhpTwinfield\CostCenter; + $substituteWith->getCode('00001'); + $fixedAssetFinancials->setSubstituteWith($substituteWith); // CostCenter|null Dimension code of the cost center. + $fixedAssetFinancials->setSubstituteWith(\PhpTwinfield\CostCenter::fromCode('00001')); // string|null + $vatCode = new \PhpTwinfield\VatCode; + $vatCode->setCode('VH'); + $fixedAssetFinancials->setVatCode($vatCode); // VatCode|null Default VAT code. + $fixedAssetFinancials->setVatCode(\PhpTwinfield\VatCode::fromCode('VH')); // string|null + + $fixedAsset->setFinancials($fixedAssetFinancials); // FixedAssetFinancials Set the FixedAssetFinancials object tot the FixedAsset object + + $fixedAssetFixedAssets = new \PhpTwinfield\FixedAssetFixedAssets; + $fixedAssetFixedAssets->setBeginPeriod('2019/01'); // string|null Period in YYYY/PP format. The period from which the depreciation to begin. + $fixedAssetFixedAssets->setFreeText1('1'); // string|null Free text field 1 as set on the asset method. + $fixedAssetFixedAssets->setFreeText2('3'); // string|null Free text field 2 as set on the asset method. + $fixedAssetFixedAssets->setFreeText3('3'); // string|null Free text field 3 as set on the asset method. + $fixedAssetFixedAssets->setFreeText4('4'); // string|null Free text field 4 as set on the asset method. + $fixedAssetFixedAssets->setFreeText5('5'); // string|null Free text field 5 as set on the asset method. + $fixedAssetFixedAssets->setLastDepreciation('2019/12'); // string|null Period in YYYY/PP format. The period of the last depreciation of the asset. + $method = new \PhpTwinfield\AssetMethod; + $method->setCode('101'); + $fixedAssetFixedAssets->setMethod($currency); // AssetMethod|null The asset method. See Asset methods. + $fixedAssetFixedAssets->setMethod(\PhpTwinfield\AssetMethod::fromCode('101')); // string|null + $fixedAssetFixedAssets->setNrOfPeriods(12); // int|null The number of periods over which the asset should be depreciated. + //$fixedAssetFixedAssets->setPercentage(8); // int|null The depreciation percentage. + $purchaseDate = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); + $fixedAssetFixedAssets->setPurchaseDate($purchaseDate); // DateTimeInterface|null The purchase date of the asset. + $fixedAssetFixedAssets->setPurchaseDate(Util::parseDate('20190101')); // string|null + $fixedAssetFixedAssets->setResidualValue(\Money\Money::EUR(50000)); // Money|null The residual value of the asset at the end of the depreciation duration. (Equals 500.00 EUR) + $sellDate = \DateTime::createFromFormat('d-m-Y', '01-01-2019'); + //$fixedAssetFixedAssets->setSellDate($sellDate); // DateTimeInterface|null The date the asset is sold. + //$fixedAssetFixedAssets->setSellDate(Util::parseDate('20190101')); // string|null + $fixedAssetFixedAssets->setStopValue(\Money\Money::EUR(0)); // Money|null The value future depreciation should stop at. (Equals 0.00 EUR) + + $fixedAsset->setFixedAssets($fixedAssetFixedAssets); // FixedAssetFixedAssets Set the FixedAssetFixedAssets object tot the FixedAsset object + + try { + $fixedAssetNew = $fixedAssetApiConnector->send($fixedAsset); + } catch (ResponseException $e) { + $fixedAssetNew = $e->getReturnedObject(); + } + + echo "
";
+    print_r($fixedAssetNew);
+    echo "
"; + + echo "Result of creation process: {$fixedAssetNew->getResult()}
"; + echo "Code of new FixedAsset: {$fixedAssetNew->getCode()}
"; + echo "Status of new FixedAsset: {$fixedAssetNew->getStatus()}
"; +} + +// Delete a FixedAsset based off the passed in code and optionally the office. +if ($executeDelete) { + try { + $fixedAssetDeleted = $fixedAssetApiConnector->delete("60002", $office); + } catch (ResponseException $e) { + $fixedAssetDeleted = $e->getReturnedObject(); + } + + echo "
";
+    print_r($fixedAssetDeleted);
+    echo "
"; + + echo "Result of deletion process: {$fixedAssetDeleted->getResult()}
"; + echo "Code of deleted FixedAsset: {$fixedAssetDeleted->getCode()}
"; + echo "Status of deleted FixedAsset: {$fixedAssetDeleted->getStatus()}
"; +} \ No newline at end of file diff --git a/examples/GeneralLedger.php b/examples/GeneralLedger.php index c56992bd..1d0dad9e 100644 --- a/examples/GeneralLedger.php +++ b/examples/GeneralLedger.php @@ -225,6 +225,7 @@ echo "Result of copy process: {$generalLedgerCopy->getResult()}
"; echo "Code of copied GeneralLedger: {$generalLedgerCopy->getCode()}
"; + echo "Status of copied GeneralLedger: {$generalLedgerCopy->getStatus()}
"; } // Create a new GeneralLedger from scratch, alternatively read an existing GeneralLedger as shown above and than modify the values in the same way as shown below @@ -280,6 +281,7 @@ echo "Result of creation process: {$generalLedgerNew->getResult()}
"; echo "Code of new GeneralLedger: {$generalLedgerNew->getCode()}
"; + echo "Status of new GeneralLedger: {$generalLedgerNew->getStatus()}
"; } // Delete a GeneralLedger based off the passed in code, dimension type and optionally the office. @@ -295,4 +297,6 @@ echo ""; echo "Result of deletion process: {$generalLedgerDeleted->getResult()}
"; + echo "Code of deleted GeneralLedger: {$generalLedgerDeleted->getCode()}
"; + echo "Status of deleted GeneralLedger: {$generalLedgerDeleted->getStatus()}
"; } \ No newline at end of file diff --git a/examples/Invoice.php b/examples/Invoice.php index 3cca3160..7208ae13 100644 --- a/examples/Invoice.php +++ b/examples/Invoice.php @@ -113,8 +113,8 @@ /* InvoiceLine * \PhpTwinfield\InvoiceLine - * Available getters: getAllowDiscountOrPremium, getArticle, getDescription, getDim1, getFreetext1, getFreetext2, getFreetext3, getID, getMessages, getPerformanceDate, getPerformanceType, getQuantity, getResult, getSubArticle, getSubArticleToString, getUnits, getUnitsPriceExcl, getUnitsPriceInc, getValueExcl, getValueInc, getVatCode, getVatValue, hasMessages - * Available setters: setAllowDiscountOrPremium, setArticle, setDescription, setDim1, setFreetext1, setFreetext2, setFreetext3, setID, setPerformanceDate, setPerformanceType, setQuantity, setSubArticle, setUnits, setUnitsPriceExcl, setUnitsPriceInc, setValueExcl, setValueInc, setVatCode, setVatValue + * Available getters: getAllowDiscountOrPremium, getArticle, getDescription, getDim1, getFreeText1, getFreeText2, getFreeText3, getID, getMessages, getPerformanceDate, getPerformanceType, getQuantity, getResult, getSubArticle, getSubArticleToString, getUnits, getUnitsPriceExcl, getUnitsPriceInc, getValueExcl, getValueInc, getVatCode, getVatValue, hasMessages + * Available setters: setAllowDiscountOrPremium, setArticle, setDescription, setDim1, setFreeText1, setFreeText2, setFreeText3, setID, setPerformanceDate, setPerformanceType, setQuantity, setSubArticle, setUnits, setUnitsPriceExcl, setUnitsPriceInc, setValueExcl, setValueInc, setVatCode, setVatValue */ /* InvoiceVatLine @@ -213,9 +213,9 @@ echo "Description: {$invoiceLine->getDescription()}
"; // string|null Invoice line description, only on the lines with article ‘0’ or ‘-‘. echo "Dim1 (\\PhpTwinfield\\GeneralLedger):
" . print_r($invoiceLine->getDim1(), true) . "

"; // GeneralLedger|null Balance account. echo "Dim1 (string): " . Util::objectToStr($invoiceLine->getDim1()) . "
"; // string|null - echo "FreeText1: {$invoiceLine->getFreetext1()}
"; // string|null Free text field 1 as entered on the invoice type. - echo "FreeText2: {$invoiceLine->getFreetext2()}
"; // string|null Free text field 2 as entered on the invoice type. - echo "FreeText3: {$invoiceLine->getFreetext3()}
"; // string|null Free text field 3 as entered on the invoice type. + echo "FreeText1: {$invoiceLine->getFreeText1()}
"; // string|null Free text field 1 as entered on the invoice type. + echo "FreeText2: {$invoiceLine->getFreeText2()}
"; // string|null Free text field 2 as entered on the invoice type. + echo "FreeText3: {$invoiceLine->getFreeText3()}
"; // string|null Free text field 3 as entered on the invoice type. echo "ID: {$invoiceLine->getID()}
"; // int|null Line ID if ($invoiceLine->hasMessages()) { // bool Object contains (error) messages true/false. @@ -289,6 +289,7 @@ echo "Result of copy process: {$invoiceCopy->getResult()}
"; echo "Number of copied Invoice: {$invoiceCopy->getInvoiceNumber()}
"; + echo "Status of copied Invoice: {$invoiceCopy->getStatus()}
"; } // Create a new Invoice from scratch, alternatively read an existing Invoice as shown above and than modify the values in the same way as shown below @@ -352,7 +353,7 @@ $invoiceLine->setDim1(\PhpTwinfield\GeneralLedger::fromCode('9060')); // string|null //$invoiceLine->setFreeText1('Example Free Text 1'); // string|null Free text field 1 as entered on the invoice type. //$invoiceLine->setFreeText2('Example Free Text 2'); // string|null Free text field 2 as entered on the invoice type. - //$invoiceLine->setFreetext3("Example Free Text 3"); // string|null Free text field 3 as entered on the invoice type. + //$invoiceLine->setFreeText3("Example Free Text 3"); // string|null Free text field 3 as entered on the invoice type. $invoiceLine->setID(1); // int|null Line ID. //$invoiceLine->setPerformanceType(\PhpTwinfield\Enums\PerformanceType::SERVICES()); // PerformanceType|null The performance type in case of an ICT sales invoice. //$invoiceLine->setPerformanceDate($performanceDate); // DateTimeInterface|null Performance date, when set-up on invoice lines. @@ -385,4 +386,5 @@ echo "Result of creation process: {$invoiceNew->getResult()}
"; echo "Number of new Invoice: {$invoiceNew->getInvoiceNumber()}
"; + echo "Status of new Invoice: {$invoiceNew->getStatus()}
"; } \ No newline at end of file diff --git a/examples/Project.php b/examples/Project.php index 139c2671..45b0fd0b 100644 --- a/examples/Project.php +++ b/examples/Project.php @@ -252,6 +252,7 @@ echo "Result of copy process: {$projectCopy->getResult()}
"; echo "Code of copied Project: {$projectCopy->getCode()}
"; + echo "Status of copied Project: {$projectCopy->getStatus()}
"; } // Create a new Project from scratch, alternatively read an existing Project as shown above and than modify the values in the same way as shown below @@ -334,6 +335,7 @@ echo "Result of creation process: {$projectNew->getResult()}
"; echo "Code of new Project: {$projectNew->getCode()}
"; + echo "Status of new Project: {$projectNew->getStatus()}
"; } // Delete a Project based off the passed in code and optionally the office. @@ -349,4 +351,6 @@ echo ""; echo "Result of deletion process: {$projectDeleted->getResult()}
"; + echo "Code of deleted Project: {$projectDeleted->getCode()}
"; + echo "Status of deleted Project: {$projectDeleted->getStatus()}
"; } \ No newline at end of file diff --git a/examples/Rate.php b/examples/Rate.php index a1820560..d86e81af 100644 --- a/examples/Rate.php +++ b/examples/Rate.php @@ -191,6 +191,7 @@ echo "Result of copy process: {$rateCopy->getResult()}
"; echo "Code of copied Rate: {$rateCopy->getCode()}
"; + echo "Status of copied Rate: {$rateCopy->getStatus()}
"; } // Create a new Rate from scratch, alternatively read an existing Rate as shown above and than modify the values in the same way as shown below @@ -244,7 +245,7 @@ echo "Result of creation process: {$rateNew->getResult()}
"; echo "Code of new Rate: {$rateNew->getCode()}
"; - /* */ + echo "Status of new Rate: {$rateNew->getStatus()}
"; } // Delete a Rate based off the passed in code and optionally the office. @@ -260,4 +261,6 @@ echo ""; echo "Result of deletion process: {$rateDeleted->getResult()}
"; + echo "Code of deleted Rate: {$rateDeleted->getCode()}
"; + echo "Status of deleted Rate: {$rateDeleted->getStatus()}
"; } \ No newline at end of file diff --git a/examples/Supplier.php b/examples/Supplier.php index 2e5a9445..a2dbe832 100644 --- a/examples/Supplier.php +++ b/examples/Supplier.php @@ -181,12 +181,12 @@ echo "BeginPeriod: {$supplier->getBeginPeriod()}
"; // int|null Determines together with beginyear the period from which the dimension may be used. echo "BeginYear: {$supplier->getBeginYear()}
"; // int|null Determines together with beginperiod the period from which the dimension may be used. echo "Behaviour: {$supplier->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. - echo "Code: {$supplier->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the DEB Dimension type. + echo "Code: {$supplier->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the CRD Dimension type. echo "EndPeriod: {$supplier->getEndPeriod()}
"; // int|null Determines together with endyear the period till which the dimension may be used. echo "EndYear: {$supplier->getEndYear()}
"; // int|null Determines together with endperiod the period till which the dimension may be used. echo "Group (\\PhpTwinfield\\DimensionGroup):
" . print_r($supplier->getGroup(), true) . "

"; // DimensionGroup|null Sets the dimension group. See Dimension group. echo "Group (string): " . Util::objectToStr($supplier->getGroup()) . "
"; // string|null - echo "InUse (bool): {$supplier->getInUse()}
"; // bool|null Indicates whether the balancesheet is used in a financial transaction or not. Read-only attribute. + echo "InUse (bool): {$supplier->getInUse()}
"; // bool|null Indicates whether the dimension is used in a financial transaction or not. Read-only attribute. echo "InUse (string): " . Util::formatBoolean($supplier->getInUse()) . "
"; // string|null if ($supplier->hasMessages()) { // bool Object contains (error) messages true/false. @@ -206,7 +206,7 @@ echo "ShortName: {$supplier->getShortName()}
"; // string|null Short name of the dimension. echo "Status: {$supplier->getStatus()}
"; // Status|null Status of the supplier. echo "Touched: {$supplier->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. - echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($supplier->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of suppliers is DEB. + echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($supplier->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of suppliers is CRD. echo "Type (string): " . Util::objectToStr($supplier->getType()) . "
"; // string|null echo "UID: {$supplier->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. echo "Website: {$supplier->getWebsite()}
"; // string|null Website of the dimension. @@ -378,7 +378,7 @@ } $supplier->setCode(null); // string|null Set to null to let Twinfield assign a Dimension code based on the Dimension type mask - //$supplier->setCode('2100'); // string|null Dimension code, must be compliant with the mask of the DEB Dimension type. + //$supplier->setCode('2100'); // string|null Dimension code, must be compliant with the mask of the CRD Dimension type. //Twinfield does not accept BankID's on new entities $supplierBanks = $supplier->getBanks(); @@ -399,6 +399,7 @@ echo "Result of copy process: {$supplierCopy->getResult()}
"; echo "Code of copied Supplier: {$supplierCopy->getCode()}
"; + echo "Status of copied Supplier: {$supplierCopy->getStatus()}
"; } // Create a new Supplier from scratch, alternatively read an existing Supplier as shown above and than modify the values in the same way as shown below @@ -407,7 +408,7 @@ // Required values for creating a new Supplier $supplier->setCode(null); // string|null Set to null to let Twinfield assign a Dimension code based on the Dimension type mask - //$supplier->setCode('2100'); // string|null Dimension code, must be compliant with the mask of the DEB Dimension type. + //$supplier->setCode('2100'); // string|null Dimension code, must be compliant with the mask of the CRD Dimension type. $supplier->setName("Example Supplier"); // string|null Name of the dimension. $supplier->setOffice($office); // Office|null Office code. $supplier->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null @@ -551,6 +552,7 @@ echo "Result of creation process: {$supplierNew->getResult()}
"; echo "Code of new Supplier: {$supplierNew->getCode()}
"; + echo "Status of new Supplier: {$supplierNew->getStatus()}
"; } // Delete a Supplier based off the passed in code and optionally the office. @@ -566,4 +568,6 @@ echo ""; echo "Result of deletion process: {$supplierDeleted->getResult()}
"; + echo "Code of deleted Supplier: {$supplierDeleted->getCode()}
"; + echo "Status of deleted Supplier: {$supplierDeleted->getStatus()}
"; } \ No newline at end of file diff --git a/examples/VatCode.php b/examples/VatCode.php index 9cff7d8d..48f6a4e1 100644 --- a/examples/VatCode.php +++ b/examples/VatCode.php @@ -216,6 +216,7 @@ echo "Result of copy process: {$vatCodeCopy->getResult()}
"; echo "Code of copied VatCode: {$vatCodeCopy->getCode()}
"; + echo "Status of copied VatCode: {$vatCodeCopy->getStatus()}
"; } // Create a new VatCode from scratch, alternatively read an existing VatCode as shown above and than modify the values in the same way as shown below @@ -282,6 +283,7 @@ echo "Result of creation process: {$vatCodeNew->getResult()}
"; echo "Code of new VatCode: {$vatCodeNew->getCode()}
"; + echo "Status of new VatCode: {$vatCodeNew->getStatus()}
"; } // Delete a VatCode based off the passed in code and optionally the office. @@ -297,4 +299,6 @@ echo ""; echo "Result of deletion process: {$vatCodeDeleted->getResult()}
"; + echo "Code of deleted VatCode: {$vatCodeDeleted->getCode()}
"; + echo "Status of deleted VatCode: {$vatCodeDeleted->getStatus()}
"; } \ No newline at end of file diff --git a/src/DomDocuments/TransactionsDocument.php b/src/DomDocuments/TransactionsDocument.php index 702433e9..c7bc0aeb 100644 --- a/src/DomDocuments/TransactionsDocument.php +++ b/src/DomDocuments/TransactionsDocument.php @@ -112,16 +112,16 @@ public function addTransaction(BaseTransaction $transaction) $headerElement->appendChild($this->createNodeWithTextContent('paymentreference', $transaction->getPaymentReference())); } - if ($transaction->getFreetext1() !== null) { - $headerElement->appendChild($this->createNodeWithTextContent("freetext1", $transaction->getFreetext1())); + if ($transaction->getFreeText1() !== null) { + $headerElement->appendChild($this->createNodeWithTextContent("freetext1", $transaction->getFreeText1())); } - if ($transaction->getFreetext2() !== null) { - $headerElement->appendChild($this->createNodeWithTextContent("freetext2", $transaction->getFreetext2())); + if ($transaction->getFreeText2() !== null) { + $headerElement->appendChild($this->createNodeWithTextContent("freetext2", $transaction->getFreeText2())); } - if ($transaction->getFreetext3() !== null) { - $headerElement->appendChild($this->createNodeWithTextContent("freetext3", $transaction->getFreetext3())); + if ($transaction->getFreeText3() !== null) { + $headerElement->appendChild($this->createNodeWithTextContent("freetext3", $transaction->getFreeText3())); } $linesElement = $this->createElement('lines'); diff --git a/src/Fields/Dimensions/Level34/FixedAsset/FreeText4Field.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText4Field.php index 955e86b1..aba88eab 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/FreeText4Field.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText4Field.php @@ -15,7 +15,7 @@ trait FreeText4Field /** * @return null|string */ - public function getFreetext4(): ?string + public function getFreeText4(): ?string { return $this->freeText4; } @@ -24,7 +24,7 @@ public function getFreetext4(): ?string * @param null|string $freeText4 * @return $this */ - public function setFreetext4(?string $freeText4): self + public function setFreeText4(?string $freeText4): self { $this->freeText4 = $freeText4; return $this; diff --git a/src/Fields/Dimensions/Level34/FixedAsset/FreeText5Field.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText5Field.php index 5701b455..8379aeec 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/FreeText5Field.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText5Field.php @@ -15,7 +15,7 @@ trait FreeText5Field /** * @return null|string */ - public function getFreetext5(): ?string + public function getFreeText5(): ?string { return $this->freeText5; } @@ -24,7 +24,7 @@ public function getFreetext5(): ?string * @param null|string $freeText5 * @return $this */ - public function setFreetext5(?string $freeText5): self + public function setFreeText5(?string $freeText5): self { $this->freeText5 = $freeText5; return $this; diff --git a/src/Fields/FreeText1Field.php b/src/Fields/FreeText1Field.php index 32d2b7d1..9327613e 100644 --- a/src/Fields/FreeText1Field.php +++ b/src/Fields/FreeText1Field.php @@ -15,7 +15,7 @@ trait FreeText1Field /** * @return null|string */ - public function getFreetext1(): ?string + public function getFreeText1(): ?string { return $this->freeText1; } @@ -24,7 +24,7 @@ public function getFreetext1(): ?string * @param null|string $freeText1 * @return $this */ - public function setFreetext1(?string $freeText1): self + public function setFreeText1(?string $freeText1): self { $this->freeText1 = $freeText1; return $this; diff --git a/src/Fields/FreeText2Field.php b/src/Fields/FreeText2Field.php index 4ae0b79c..2acdf4b6 100644 --- a/src/Fields/FreeText2Field.php +++ b/src/Fields/FreeText2Field.php @@ -15,7 +15,7 @@ trait FreeText2Field /** * @return null|string */ - public function getFreetext2(): ?string + public function getFreeText2(): ?string { return $this->freeText2; } @@ -24,7 +24,7 @@ public function getFreetext2(): ?string * @param null|string $freeText2 * @return $this */ - public function setFreetext2(?string $freeText2): self + public function setFreeText2(?string $freeText2): self { $this->freeText2 = $freeText2; return $this; diff --git a/src/Fields/FreeText3Field.php b/src/Fields/FreeText3Field.php index 385794b6..563c085a 100644 --- a/src/Fields/FreeText3Field.php +++ b/src/Fields/FreeText3Field.php @@ -15,7 +15,7 @@ trait FreeText3Field /** * @return null|string */ - public function getFreetext3(): ?string + public function getFreeText3(): ?string { return $this->freeText3; } @@ -24,7 +24,7 @@ public function getFreetext3(): ?string * @param null|string $freeText3 * @return $this */ - public function setFreetext3(?string $freeText3): self + public function setFreeText3(?string $freeText3): self { $this->freeText3 = $freeText3; return $this; diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index d7e54b9f..e7a1ac2b 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -90,9 +90,9 @@ public static function map(string $transactionClassName, Response $response, Aut $transaction->setCode(self::getField($transactionElement, 'code', $transaction)) ->setCurrency(self::parseObjectAttribute(\PhpTwinfield\Currency::class, $transaction, $transactionElement, 'currency')) ->setDate(self::parseDateAttribute(self::getField($transactionElement, 'date', $transaction))) - ->setFreetext1(self::getField($transactionElement, 'freetext1', $transaction)) - ->setFreetext2(self::getField($transactionElement, 'freetext2', $transaction)) - ->setFreetext3(self::getField($transactionElement, 'freetext3', $transaction)) + ->setFreeText1(self::getField($transactionElement, 'freetext1', $transaction)) + ->setFreeText2(self::getField($transactionElement, 'freetext2', $transaction)) + ->setFreeText3(self::getField($transactionElement, 'freetext3', $transaction)) ->setOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $transaction, $transactionElement, 'office')) ->setOrigin(self::getField($transactionElement, 'origin', $transaction)) ->setNumber(self::getField($transactionElement, 'number', $transaction)) diff --git a/tests/IntegrationTests/BankTransactionIntegrationTest.php b/tests/IntegrationTests/BankTransactionIntegrationTest.php index 8fce7674..f7838eeb 100644 --- a/tests/IntegrationTests/BankTransactionIntegrationTest.php +++ b/tests/IntegrationTests/BankTransactionIntegrationTest.php @@ -63,9 +63,9 @@ public function testGetBankTransactionWorks() $this->assertEquals('EUR', Util::objectToStr($bankTransaction->getCurrency())); $this->assertEquals(new DateTimeImmutable('2013-11-04'), $bankTransaction->getDate()); $this->assertSame('import', $bankTransaction->getOrigin()); - $this->assertNull($bankTransaction->getFreetext1()); - $this->assertNull($bankTransaction->getFreetext2()); - $this->assertNull($bankTransaction->getFreetext3()); + $this->assertNull($bankTransaction->getFreeText1()); + $this->assertNull($bankTransaction->getFreeText2()); + $this->assertNull($bankTransaction->getFreeText3()); $this->assertSame(4, $bankTransaction->getStatementNumber()); $this->assertTrue(Money::EUR(97401)->equals($bankTransaction->getStartValue())); $this->assertTrue(Money::EUR(140956)->equals($bankTransaction->getCloseValue())); diff --git a/tests/IntegrationTests/CashTransactionIntegrationTest.php b/tests/IntegrationTests/CashTransactionIntegrationTest.php index fd7556a2..3ddc12f2 100644 --- a/tests/IntegrationTests/CashTransactionIntegrationTest.php +++ b/tests/IntegrationTests/CashTransactionIntegrationTest.php @@ -63,9 +63,9 @@ public function testGetCashTransactionWorks() $this->assertEquals('EUR', Util::objectToStr($cashTransaction->getCurrency())); $this->assertEquals(new DateTimeImmutable('2013-11-04'), $cashTransaction->getDate()); $this->assertSame('import', $cashTransaction->getOrigin()); - $this->assertNull($cashTransaction->getFreetext1()); - $this->assertNull($cashTransaction->getFreetext2()); - $this->assertNull($cashTransaction->getFreetext3()); + $this->assertNull($cashTransaction->getFreeText1()); + $this->assertNull($cashTransaction->getFreeText2()); + $this->assertNull($cashTransaction->getFreeText3()); $this->assertSame(4, $cashTransaction->getStatementNumber()); $this->assertTrue(Money::EUR(97401)->equals($cashTransaction->getStartValue())); $this->assertTrue(Money::EUR(140956)->equals($cashTransaction->getCloseValue())); diff --git a/tests/IntegrationTests/JournalTransactionIntegrationTest.php b/tests/IntegrationTests/JournalTransactionIntegrationTest.php index 3e933a57..61384e25 100644 --- a/tests/IntegrationTests/JournalTransactionIntegrationTest.php +++ b/tests/IntegrationTests/JournalTransactionIntegrationTest.php @@ -62,9 +62,9 @@ public function testGetJournalTransactionWorks() $this->assertEquals('EUR', Util::objectToStr($journalTransaction->getCurrency())); $this->assertEquals(new \DateTimeImmutable('2013-11-04'), $journalTransaction->getDate()); $this->assertSame('import', $journalTransaction->getOrigin()); - $this->assertNull($journalTransaction->getFreetext1()); - $this->assertNull($journalTransaction->getFreetext2()); - $this->assertNull($journalTransaction->getFreetext3()); + $this->assertNull($journalTransaction->getFreeText1()); + $this->assertNull($journalTransaction->getFreeText2()); + $this->assertNull($journalTransaction->getFreeText3()); $this->assertNull($journalTransaction->getRegime()); /** @var JournalTransactionLine[] $journalTransactionLines */ diff --git a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php index 5e991827..80fba92b 100644 --- a/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php +++ b/tests/IntegrationTests/PurchaseTransactionIntegrationTest.php @@ -61,9 +61,9 @@ public function testGetPurchaseTransactionWorks() $this->assertEquals('EUR', Util::objectToStr($purchaseTransaction->getCurrency())); $this->assertEquals(new \DateTimeImmutable('2013-05-02'), $purchaseTransaction->getDate()); $this->assertSame('import', $purchaseTransaction->getOrigin()); - $this->assertNull($purchaseTransaction->getFreetext1()); - $this->assertNull($purchaseTransaction->getFreetext2()); - $this->assertNull($purchaseTransaction->getFreetext3()); + $this->assertNull($purchaseTransaction->getFreeText1()); + $this->assertNull($purchaseTransaction->getFreeText2()); + $this->assertNull($purchaseTransaction->getFreeText3()); $this->assertEquals(new \DateTimeImmutable('2013-05-06'), $purchaseTransaction->getDueDate()); $this->assertSame('20130-5481', $purchaseTransaction->getInvoiceNumber()); $this->assertSame('+++100/0160/01495+++', $purchaseTransaction->getPaymentReference()); diff --git a/tests/IntegrationTests/SalesTransactionIntegrationTest.php b/tests/IntegrationTests/SalesTransactionIntegrationTest.php index e85b0519..e923922d 100644 --- a/tests/IntegrationTests/SalesTransactionIntegrationTest.php +++ b/tests/IntegrationTests/SalesTransactionIntegrationTest.php @@ -61,9 +61,9 @@ public function testGetSalesTransactionWorks() $this->assertEquals('EUR', Util::objectToStr($salesTransaction->getCurrency())); $this->assertEquals(new \DateTimeImmutable('2013-05-02'), $salesTransaction->getDate()); $this->assertSame('import', $salesTransaction->getOrigin()); - $this->assertNull($salesTransaction->getFreetext1()); - $this->assertNull($salesTransaction->getFreetext2()); - $this->assertNull($salesTransaction->getFreetext3()); + $this->assertNull($salesTransaction->getFreeText1()); + $this->assertNull($salesTransaction->getFreeText2()); + $this->assertNull($salesTransaction->getFreeText3()); $this->assertEquals(new \DateTimeImmutable('2013-05-06'), $salesTransaction->getDueDate()); $this->assertSame('20130-6000', $salesTransaction->getInvoiceNumber()); $this->assertSame('+++100/0160/01495+++', $salesTransaction->getPaymentReference()); From a64f25a3266d0f29cb4a3a42a176f19f944e1d39 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 27 Jun 2019 13:10:54 +0200 Subject: [PATCH 365/388] Upload --- examples/Activity.php | 50 +++++++-------- examples/Article.php | 46 +++++++------- examples/AssetMethod.php | 50 +++++++-------- examples/BrowseData.php | 68 ++++++++++---------- examples/Customer.php | 106 ++++++++++++++++---------------- examples/DimensionGroup.php | 22 +++---- examples/DimensionType.php | 50 +++++++-------- examples/FixedAsset.php | 54 ++++++++-------- examples/GeneralLedger.php | 56 ++++++++--------- examples/Invoice.php | 68 ++++++++++---------- examples/Office.php | 24 ++++---- examples/Project.php | 50 +++++++-------- examples/Rate.php | 36 +++++------ examples/RenewAuthorization.php | 2 +- examples/Supplier.php | 94 ++++++++++++++-------------- examples/User.php | 52 ++++++++-------- examples/VatCode.php | 68 ++++++++++---------- 17 files changed, 448 insertions(+), 448 deletions(-) diff --git a/examples/Activity.php b/examples/Activity.php index 9cae6cd0..a10e7274 100644 --- a/examples/Activity.php +++ b/examples/Activity.php @@ -144,21 +144,21 @@ echo ""; echo "Activity
"; - echo "Behaviour: {$activity->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. - echo "Code: {$activity->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the ACT Dimension type. - echo "InUse (bool): {$activity->getInUse()}
"; // bool|null Indicates whether the activity is used in a transaction or not. Read-only attribute. + echo "Behaviour: {$activity->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. + echo "Code: {$activity->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the ACT Dimension type. + echo "InUse (bool): {$activity->getInUse()}
"; // bool|null Indicates whether the activity is used in a transaction or not. Read-only attribute. echo "InUse (string): " . Util::formatBoolean($activity->getInUse()) . "
"; // string|null - if ($activity->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($activity->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($activity->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($activity->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Name: {$activity->getName()}
"; // string|null Activity description. - echo "Office (\\PhpTwinfield\\Office):
" . print_r($activity->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): " . Util::objectToStr($activity->getOffice()) . "
"; // string|null - echo "Result: {$activity->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "ShortName: {$activity->getShortName()}
"; // string|null Short activity description. - echo "Status: {$activity->getStatus()}
"; // Status|null Status of the activity. + echo "Name: {$activity->getName()}
"; // string|null Activity description. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($activity->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): " . Util::objectToStr($activity->getOffice()) . "
"; // string|null + echo "Result: {$activity->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$activity->getShortName()}
"; // string|null Short activity description. + echo "Status: {$activity->getStatus()}
"; // Status|null Status of the activity. echo "Touched: {$activity->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($activity->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of activities is ACT. echo "Type (string): " . Util::objectToStr($activity->getType()) . "
"; // string|null @@ -166,9 +166,9 @@ echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($activity->getVatCode(), true) . "

"; // VatCode|null The VAT code if one code will apply for all activities within the project. Note that if any VAT codes are echo "VatCode (string): " . Util::objectToStr($activity->getVatCode()) . "
"; // string|null defined on activity level, these will apply regardless of what is defined on project level. - $activityProjects = $activity->getProjects(); // ActivityProjects|null ActivityProjects object. + $activityProjects = $activity->getProjects(); // ActivityProjects|null ActivityProjects object. - echo "Authoriser (\\PhpTwinfield\\User):
" . print_r($activityProjects->getAuthoriser(), true) . "

"; // User|null A specific authoriser for an activity. + echo "Authoriser (\\PhpTwinfield\\User):
" . print_r($activityProjects->getAuthoriser(), true) . "

"; // User|null A specific authoriser for an activity. echo "Authoriser (string): " . Util::objectToStr($activityProjects->getAuthoriser()) . "
"; // string|null If "change" = allow then locked = false and inherit = false echo "Authoriser Inherit (bool): {$activityProjects->getAuthoriserInherit()}
"; // bool|null echo "Authoriser Inherit (string): " . Util::formatBoolean($activityProjects->getAuthoriserInherit()) . "
"; // string|null If "change" = disallow then locked = true and inherit = false @@ -182,7 +182,7 @@ echo "Billable Inherit (string): " . Util::formatBoolean($activityProjects->getBillableInherit()) . "
"; // string|null If "change" = disallow then locked = true and inherit = false. echo "Billable Locked (bool): {$activityProjects->getBillableLocked()}
"; // bool|null echo "Billable Locked (string): " . Util::formatBoolean($activityProjects->getBillableLocked()) . "
"; // string|null If "change" = inherit then locked = true and inherit = true - echo "Customer (\\PhpTwinfield\\Customer):
" . print_r($activityProjects->getCustomer(), true) . "

"; // Customer|null An activity always needs to be linked to a customer. + echo "Customer (\\PhpTwinfield\\Customer):
" . print_r($activityProjects->getCustomer(), true) . "

"; // Customer|null An activity always needs to be linked to a customer. echo "Customer (string): " . Util::objectToStr($activityProjects->getCustomer()) . "
"; // string|null Choose to have the customer ‘inherited’ (from a project) or you can specify the customer here. echo "Customer Inherit (bool): {$activityProjects->getCustomerInherit()}
"; // bool|null echo "Customer Inherit (string): " . Util::formatBoolean($activityProjects->getCustomerInherit()) . "
"; // string|null If "change" = allow then locked = false and inherit = false @@ -190,11 +190,11 @@ echo "Customer Locked (string): " . Util::formatBoolean($activityProjects->getCustomerLocked()) . "
"; // string|null If "change" = inherit then locked = true and inherit = true echo "Invoice Description: {$activityProjects->getInvoiceDescription()}
"; // string|null This field can be used to enter a longer activity description which will be available on the invoice template. - if ($activityProjects->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($activityProjects->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($activityProjects->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($activityProjects->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Rate (\\PhpTwinfield\\Rate):
" . print_r($activityProjects->getRate(), true) . "

"; // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). + echo "Rate (\\PhpTwinfield\\Rate):
" . print_r($activityProjects->getRate(), true) . "

"; // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). echo "Rate (string): " . Util::objectToStr($activityProjects->getRate()) . "
"; // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). echo "Rate Inherit (bool): {$activityProjects->getRateInherit()}
"; // bool|null echo "Rate Inherit (string): " . Util::formatBoolean($activityProjects->getRateInherit()) . "
"; // string|null If "change" = allow then locked = false and inherit = false @@ -216,11 +216,11 @@ echo "Billable Locked (bool): {$activityQuantity->getBillableLocked()}
"; // bool|null If "billable" = true and "change is allowed" then locked = false echo "Billable Locked (string): " . Util::formatBoolean($activityQuantity->getBillableLocked()) . "
"; // string|null - if ($activityQuantity->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($activityQuantity->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($activityQuantity->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($activityQuantity->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Label: {$activityQuantity->getLabel()}
"; // string|null The label of the quantity. + echo "Label: {$activityQuantity->getLabel()}
"; // string|null The label of the quantity. echo "Mandatory (bool): {$activityQuantity->getMandatory()}
"; // bool|null Is the quantity line mandatory or not. echo "Mandatory (string): " . Util::formatBoolean($activityQuantity->getMandatory()) . "
"; // string|null echo "Rate (\\PhpTwinfield\\Rate):
" . print_r($activityQuantity->getRate(), true) . "

"; // Rate|null The rate. @@ -279,7 +279,7 @@ $authoriser = new \PhpTwinfield\User; $authoriser->setCode('TWINAPPS'); - $activityProjects->setAuthoriser($authoriser); // User|null A specific authoriser for an activity. + $activityProjects->setAuthoriser($authoriser); // User|null A specific authoriser for an activity. $activityProjects->setAuthoriser(\PhpTwinfield\User::fromCode('TWINAPPS')); // string|null If "change" = allow then locked = false and inherit = false $activityProjects->setAuthoriserInherit(false); // bool|null $activityProjects->setAuthoriserLocked(false); // bool|null @@ -296,7 +296,7 @@ $activityProjects->setInvoiceDescription('Example Invoice Description'); // string|null This field can be used to enter a longer activity description which will be available on the invoice template. $rate = new \PhpTwinfield\Rate; $rate->setCode('DIRECT'); - $activityProjects->setRate($rate); // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). + $activityProjects->setRate($rate); // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). $activityProjects->setRate(\PhpTwinfield\Rate::fromCode('DIRECT')); // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). $activityProjects->setRateInherit(false); // bool|null $activityProjects->setRateLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false @@ -311,12 +311,12 @@ $activityQuantity = new \PhpTwinfield\ActivityQuantity; $activityQuantity->setBillable(false); // bool|null Is the quantity line billable or not. $activityQuantity->setBillableLocked(false); // bool|null - $activityQuantity->setLabel('Example Quantity'); // string|null + $activityQuantity->setLabel('Example Quantity'); // string|null $activityQuantity->setMandatory(false); // bool|null Is the quantity line mandatory or not. $rate = new \PhpTwinfield\Rate; $rate->setCode('KILOMETERS'); - $activityQuantity->setRate($rate); // Rate|null The rate. - $activityQuantity->setRate(\PhpTwinfield\Rate::fromCode('KILOMETERS')); // string|null + $activityQuantity->setRate($rate); // Rate|null The rate. + $activityQuantity->setRate(\PhpTwinfield\Rate::fromCode('KILOMETERS')); // string|null $activityProjects->addQuantity($activityQuantity); // ActivityQuantity Add an ActivityQuantity object to the ActivityProjects object //$activityProjects->removeQuantity(0); // int Remove a quantity based on the index of the quantity within the array diff --git a/examples/Article.php b/examples/Article.php index 469f7d56..e6386961 100644 --- a/examples/Article.php +++ b/examples/Article.php @@ -138,24 +138,24 @@ echo "AllowDecimalQuantity (string): " . Util::formatBoolean($article->getAllowDecimalQuantity()) . "
"; // string|null echo "AllowDiscountOrPremium (bool): {$article->getAllowDiscountOrPremium()}
"; // bool|null Is discount or premium allowed. echo "AllowDiscountOrPremium (string): " . Util::formatBoolean($article->getAllowDiscountOrPremium()) . "
"; // string|null - echo "Code: {$article->getCode()}
"; // string|null Article code. + echo "Code: {$article->getCode()}
"; // string|null Article code. - if ($article->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($article->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($article->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($article->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Name: {$article->getName()}
"; // string|null Article description. - echo "Office (\\PhpTwinfield\\Office):
" . print_r($article->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): " . Util::objectToStr($article->getOffice()) . "
"; // string|null + echo "Name: {$article->getName()}
"; // string|null Article description. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($article->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): " . Util::objectToStr($article->getOffice()) . "
"; // string|null echo "Percentage (bool): {$article->getPercentage()}
"; // bool|null Only available when article type is discount or premium. echo "Percentage (string): " . Util::formatBoolean($article->getPercentage()) . "
"; // string|null - echo "PerformanceType: {$article->getPerformanceType()}
"; // PerformanceType|null The performance type. - echo "Result: {$article->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "ShortName: {$article->getShortName()}
"; // string|null Short article description. - echo "Status: {$article->getStatus()}
"; // Status|null Status of the article. + echo "PerformanceType: {$article->getPerformanceType()}
"; // PerformanceType|null The performance type. + echo "Result: {$article->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$article->getShortName()}
"; // string|null Short article description. + echo "Status: {$article->getStatus()}
"; // Status|null Status of the article. echo "Type: {$article->getType()}
"; // ArticleType|null Set to normal in case special item is none. Set to either discount or premium in case special item is deduction or premium respectively. - echo "UnitNamePlural: {$article->getUnitNamePlural()}
"; // string|null Unit name for multiple items. - echo "UnitNameSingular: {$article->getUnitNameSingular()}
"; // string|null Unit name for a single item. + echo "UnitNamePlural: {$article->getUnitNamePlural()}
"; // string|null Unit name for multiple items. + echo "UnitNameSingular: {$article->getUnitNameSingular()}
"; // string|null Unit name for a single item. echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($article->getVatCode(), true) . "

"; // VatCode|null Default VAT code. echo "VatCode (string): " . Util::objectToStr($article->getVatCode()) . "
"; // string|null @@ -173,16 +173,16 @@ echo "InUse (bool): {$articleLine->getInUse()}
"; // bool|null Read-only attribute. Indicates that the sub item has been used in an invoice. echo "InUse (string): " . Util::formatBoolean($articleLine->getInUse()) . "
"; // string|null - if ($articleLine->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($articleLine->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($articleLine->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($articleLine->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Name: {$articleLine->getName()}
"; // string|null Sub article name. + echo "Name: {$articleLine->getName()}
"; // string|null Sub article name. echo "Result: {$articleLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "ShortName: {$articleLine->getShortName()}
"; // string|null Sub article short name. - echo "Status: {$articleLine->getStatus()}
"; // Status|null Status of the sub article. - echo "SubCode: {$articleLine->getSubCode()}
"; // string|null Can only be empty if there is just one sub article - echo "Units: {$articleLine->getUnits()}
"; // int|null The number of units of the article per quantity + echo "ShortName: {$articleLine->getShortName()}
"; // string|null Sub article short name. + echo "Status: {$articleLine->getStatus()}
"; // Status|null Status of the sub article. + echo "SubCode: {$articleLine->getSubCode()}
"; // string|null Can only be empty if there is just one sub article + echo "Units: {$articleLine->getUnits()}
"; // int|null The number of units of the article per quantity echo "UnitsPriceExcl (\\Money\\Money):
" . print_r($articleLine->getUnitsPriceExcl(), true) . "

"; // Money|null Price excluding VAT echo "UnitsPriceExcl (string): " . Util::formatMoney($articleLine->getUnitsPriceExcl()) . "
"; // string|null echo "UnitsPriceInc (\\Money\\Money):
" . print_r($articleLine->getUnitsPriceInc(), true) . "

"; // Money|null Price including VAT @@ -249,12 +249,12 @@ $freeText1 = new \PhpTwinfield\GeneralLedger; $freeText1->setCode('9060'); - $articleLine->setFreeText1($freeText1); // GeneralLedger|null Mandatory. The general ledger code linked to the article. - $articleLine->setFreeText1(\PhpTwinfield\GeneralLedger::fromCode('9060')); // string|null + $articleLine->setFreeText1($freeText1); // GeneralLedger|null Mandatory. The general ledger code linked to the article. + $articleLine->setFreeText1(\PhpTwinfield\GeneralLedger::fromCode('9060')); // string|null $freeText2 = new \PhpTwinfield\CostCenter; $freeText2->setCode('00000'); - //$articleLine->setFreeText2($freeText1); // CostCenter|null Optional. The cost center linked to the article. - //$articleLine->setFreeText2(\PhpTwinfield\CostCenter::fromCode('00000')); // string|null + //$articleLine->setFreeText2($freeText1); // CostCenter|null Optional. The cost center linked to the article. + //$articleLine->setFreeText2(\PhpTwinfield\CostCenter::fromCode('00000')); // string|null //$articleLine->setFreeText3(""); // string|null Free text element 3 $articleLine->setID(1); // int|null Line ID. $articleLine->setName("Example Sub Article"); // string|null Sub article name. diff --git a/examples/AssetMethod.php b/examples/AssetMethod.php index 78b0cd9c..cd41b470 100644 --- a/examples/AssetMethod.php +++ b/examples/AssetMethod.php @@ -127,34 +127,34 @@ echo ""; echo "AssetMethod
"; - echo "CalcMethod: {$assetMethod->getCalcMethod()}
"; // CalcMethod|null The calculation method. - echo "Code: {$assetMethod->getCode()}
"; // string|null Asset method code. - echo "Created (\\DateTimeInterface):
" . print_r($assetMethod->getCreated(), true) . "

"; // \DateTimeInterface|null Date/time the asset method is created. - echo "Created (string): " . Util::formatDate($assetMethod->getCreated()) . "
"; // string|null + echo "CalcMethod: {$assetMethod->getCalcMethod()}
"; // CalcMethod|null The calculation method. + echo "Code: {$assetMethod->getCode()}
"; // string|null Asset method code. + echo "Created (\\DateTimeInterface):
" . print_r($assetMethod->getCreated(), true) . "

"; // \DateTimeInterface|null Date/time the asset method is created. + echo "Created (string): " . Util::formatDate($assetMethod->getCreated()) . "
"; // string|null echo "DepreciateReconciliation: {$assetMethod->getDepreciateReconciliation()}
"; // DepreciateReconciliation|null Depreciate as of the revaluation date. Depreciate in retrospect, back to the purchase date. - echo "InUse (bool): {$assetMethod->getInUse()}
"; // bool|null + echo "InUse (bool): {$assetMethod->getInUse()}
"; // bool|null echo "InUse (string): " . Util::formatBoolean($assetMethod->getInUse()) . "
"; // string|null - if ($assetMethod->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($assetMethod->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($assetMethod->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($assetMethod->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Modified (\\DateTimeInterface):
" . print_r($assetMethod->getModified(), true) . "

"; // \DateTimeInterface|null Date/time the asset method is modified the last time. - echo "Modified (string): " . Util::formatDate($assetMethod->getModified()) . "
"; // string|null - echo "Name: {$assetMethod->getName()}
"; // string|null The name of the asset method. - echo "NrOfPeriods: {$assetMethod->getNrOfPeriods()}
"; // int|null The number of periods over which the asset linked to the asset method should be depreciated. - echo "Office (\\PhpTwinfield\\Office):
" . print_r($assetMethod->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): " . Util::objectToStr($assetMethod->getOffice()) . "
"; // string|null - echo "Percentage: {$assetMethod->getPercentage()}
"; // int|null - echo "Result: {$assetMethod->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "ShortName: {$assetMethod->getShortName()}
"; // string|null The short name of the asset method. - echo "Status: {$assetMethod->getStatus()}
"; // Status|null Status of the asset method. + echo "Modified (\\DateTimeInterface):
" . print_r($assetMethod->getModified(), true) . "

"; // \DateTimeInterface|null Date/time the asset method is modified the last time. + echo "Modified (string): " . Util::formatDate($assetMethod->getModified()) . "
"; // string|null + echo "Name: {$assetMethod->getName()}
"; // string|null The name of the asset method. + echo "NrOfPeriods: {$assetMethod->getNrOfPeriods()}
"; // int|null The number of periods over which the asset linked to the asset method should be depreciated. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($assetMethod->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): " . Util::objectToStr($assetMethod->getOffice()) . "
"; // string|null + echo "Percentage: {$assetMethod->getPercentage()}
"; // int|null + echo "Result: {$assetMethod->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$assetMethod->getShortName()}
"; // string|null The short name of the asset method. + echo "Status: {$assetMethod->getStatus()}
"; // Status|null Status of the asset method. echo "Touched: {$assetMethod->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. echo "User (\\PhpTwinfield\\User):
" . print_r($assetMethod->getUser(), true) . "

"; // User|null The user who modified the asset method the last time. echo "User (string): " . Util::objectToStr($assetMethod->getUser()) . "
"; // string|null echo "AssetMethodBalanceAccounts
"; - $assetMethodBalanceAccounts = $assetMethod->getBalanceAccounts(); // AssetMethodBalanceAccounts|null AssetMethodBalanceAccounts object. + $assetMethodBalanceAccounts = $assetMethod->getBalanceAccounts(); // AssetMethodBalanceAccounts|null AssetMethodBalanceAccounts object. echo "AssetsToActivate (\\PhpTwinfield\\GeneralLedger):
" . print_r($assetMethodBalanceAccounts->getAssetsToActivate(), true) . "

"; // GeneralLedger|null Assets to activate balance sheet. echo "AssetsToActivate (string): " . Util::objectToStr($assetMethodBalanceAccounts->getAssetsToActivate()) . "
"; // string|null @@ -163,8 +163,8 @@ echo "DepreciationGroup (\\PhpTwinfield\\DimensionGroup):
" . print_r($assetMethodBalanceAccounts->getDepreciationGroup(), true) . "

"; // DimensionGroup|null Depreciation group. echo "DepreciationGroup (string): " . Util::objectToStr($assetMethodBalanceAccounts->getDepreciationGroup()) . "
"; // string|null - if ($assetMethodBalanceAccounts->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($assetMethodBalanceAccounts->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($assetMethodBalanceAccounts->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($assetMethodBalanceAccounts->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "PurchaseValue (\\PhpTwinfield\\GeneralLedger):
" . print_r($assetMethodBalanceAccounts->getPurchaseValue(), true) . "

"; // GeneralLedger|null Purchase value balance sheet. @@ -178,13 +178,13 @@ echo "ToBeInvoiced (string): " . Util::objectToStr($assetMethodBalanceAccounts->getToBeInvoiced()) . "
"; // string|null echo "AssetMethodProfitLossAccounts
"; - $assetMethodProfitLossAccounts = $assetMethod->getProfitLossAccounts(); // AssetMethodProfitLossAccounts|null AssetMethodProfitLossAccounts object. + $assetMethodProfitLossAccounts = $assetMethod->getProfitLossAccounts(); // AssetMethodProfitLossAccounts|null AssetMethodProfitLossAccounts object. echo "Depreciation (\\PhpTwinfield\\GeneralLedger):
" . print_r($assetMethodProfitLossAccounts->getDepreciation(), true) . "

"; // GeneralLedger|null Depreciation costs profit and loss account. echo "Depreciation (string): " . Util::objectToStr($assetMethodProfitLossAccounts->getDepreciation()) . "
"; // string|null - if ($assetMethodProfitLossAccounts->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($assetMethodProfitLossAccounts->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($assetMethodProfitLossAccounts->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($assetMethodProfitLossAccounts->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "Reconciliation (\\PhpTwinfield\\GeneralLedger):
" . print_r($assetMethodProfitLossAccounts->getReconciliation(), true) . "

"; // GeneralLedger|null Revaluation reserve profit and loss account. @@ -201,8 +201,8 @@ echo "ElementValue: {$assetMethodFreeText->getElementValue()}
"; // string|null Free text. echo "ID: {$assetMethodFreeText->getID()}
"; // int|null Free text id. In total, five free text fields are available. - if ($assetMethodFreeText->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($assetMethodFreeText->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($assetMethodFreeText->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($assetMethodFreeText->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "Result: {$assetMethodFreeText->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). diff --git a/examples/BrowseData.php b/examples/BrowseData.php index 51cf9a3d..69d196cf 100644 --- a/examples/BrowseData.php +++ b/examples/BrowseData.php @@ -32,40 +32,40 @@ /* Codes of all available Browse Definitions Browse code Description - 000 General ledger transactions - 010 Transactions still to be matched - 020 Transaction list - 100 Customer transactions - 200 Supplier transactions - 300 Project transactions - 301 Asset transactions - 400 Cash transactions - 410 Bank transactions - 900 Cost centers - 030_1 General Ledger (details) - 030_2 General Ledger (details) (v2) - 031 General Ledger (intercompany) - 040_1 Annual Report (totals) - 050_1 Annual Report (YTD) - 060 Annual Report (totals multicurrency) - 130_1 Customers - 130_2 Customers (v2) - 164 Credit Management - 230_1 Suppliers - 230_2 Suppliers (v2) - 302_1 Fixed Assets - 610_1 Time & Expenses (Totals) - 620 Time & Expenses (Multicurrency) - 650_1 Time & Expenses (Details) - 651_1 Time & Expenses (Totals per week) - 652_1 Time & Expenses (Totals per period) - 660_1 Time & Expenses (Billing details) - 661_1 Time & Expenses (Billing per week) - 662_1 Time & Expenses (Billing per period) - 670 Transaction summary - 680 Bank link details - 690 Vat Return status - 700 Hierarchy access + 000 General ledger transactions + 010 Transactions still to be matched + 020 Transaction list + 100 Customer transactions + 200 Supplier transactions + 300 Project transactions + 301 Asset transactions + 400 Cash transactions + 410 Bank transactions + 900 Cost centers + 030_1 General Ledger (details) + 030_2 General Ledger (details) (v2) + 031 General Ledger (intercompany) + 040_1 Annual Report (totals) + 050_1 Annual Report (YTD) + 060 Annual Report (totals multicurrency) + 130_1 Customers + 130_2 Customers (v2) + 164 Credit Management + 230_1 Suppliers + 230_2 Suppliers (v2) + 302_1 Fixed Assets + 610_1 Time & Expenses (Totals) + 620 Time & Expenses (Multicurrency) + 650_1 Time & Expenses (Details) + 651_1 Time & Expenses (Totals per week) + 652_1 Time & Expenses (Totals per period) + 660_1 Time & Expenses (Billing details) + 661_1 Time & Expenses (Billing per week) + 662_1 Time & Expenses (Billing per period) + 670 Transaction summary + 680 Bank link details + 690 Vat Return status + 700 Hierarchy access */ /* BrowseDefinition diff --git a/examples/Customer.php b/examples/Customer.php index 7bb73f2b..577525d5 100644 --- a/examples/Customer.php +++ b/examples/Customer.php @@ -58,25 +58,25 @@ * office Sets the office code. * Usage: $options['office'] = 'SomeOfficeCode'; * - * level Specifies the dimension level. + * level Specifies the dimension level. * Available values: 1, 2, 3, 4, 5, 6 * Usage: $options['level'] = 2; * - * section Restricts to financial or time & expenses dimensions. + * section Restricts to financial or time & expenses dimensions. * Available values: financials, teq * Usage: $options['section'] = 'financials'; * - * dimtype Specifies the dimension type. + * dimtype Specifies the dimension type. * Available values: BAS, PNL, DEB, CRD, KPL, PRJ, AST, ACT * Usage: $options['dimtype'] = 'DEB'; * - * modifiedsince Restricts to dimensions modified after or at the specified date (and time), format yyyyMMddHHmmss or yyyyMMdd + * modifiedsince Restricts to dimensions modified after or at the specified date (and time), format yyyyMMddHHmmss or yyyyMMdd * Usage: $options['modifiedsince'] = '20190101170000' or $options['modifiedsince'] = '20190101'; * - * group Specifies the dimension group (wildcards allowed). + * group Specifies the dimension group (wildcards allowed). * Usage: $options['group'] = 'DIMGROUP'; * - * matchtype This option will show only the relations (dimension type: DEB and/or CRD). + * matchtype This option will show only the relations (dimension type: DEB and/or CRD). * Usage: $options['matchtype'] = 'relation'; * */ @@ -192,36 +192,36 @@ echo ""; echo "Customer
"; - echo "BeginPeriod: {$customer->getBeginPeriod()}
"; // int|null Determines together with beginyear the period from which the dimension may be used. - echo "BeginYear: {$customer->getBeginYear()}
"; // int|null Determines together with beginperiod the period from which the dimension may be used. - echo "Behaviour: {$customer->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. - echo "Code: {$customer->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the DEB Dimension type. + echo "BeginPeriod: {$customer->getBeginPeriod()}
"; // int|null Determines together with beginyear the period from which the dimension may be used. + echo "BeginYear: {$customer->getBeginYear()}
"; // int|null Determines together with beginperiod the period from which the dimension may be used. + echo "Behaviour: {$customer->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. + echo "Code: {$customer->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the DEB Dimension type. echo "DiscountArticle (\\PhpTwinfield\\Article):
" . print_r($customer->getDiscountArticle(), true) . "

"; // Article|null The discount or premium article. echo "DiscountArticle (string): " . Util::objectToStr($customer->getDiscountArticle()) . "
"; // string|null echo "DiscountArticleID: {$customer->getDiscountArticleID()}
"; // string|null - echo "EndPeriod: {$customer->getEndPeriod()}
"; // int|null Determines together with endyear the period till which the dimension may be used. - echo "EndYear: {$customer->getEndYear()}
"; // int|null Determines together with endperiod the period till which the dimension may be used. - echo "Group (\\PhpTwinfield\\DimensionGroup):
" . print_r($customer->getGroup(), true) . "

"; // DimensionGroup|null Sets the dimension group. See Dimension group. - echo "Group (string): " . Util::objectToStr($customer->getGroup()) . "
"; // string|null - echo "InUse (bool): {$customer->getInUse()}
"; // bool|null Indicates whether the dimension is used in a financial transaction or not. Read-only attribute. + echo "EndPeriod: {$customer->getEndPeriod()}
"; // int|null Determines together with endyear the period till which the dimension may be used. + echo "EndYear: {$customer->getEndYear()}
"; // int|null Determines together with endperiod the period till which the dimension may be used. + echo "Group (\\PhpTwinfield\\DimensionGroup):
" . print_r($customer->getGroup(), true) . "

"; // DimensionGroup|null Sets the dimension group. See Dimension group. + echo "Group (string): " . Util::objectToStr($customer->getGroup()) . "
"; // string|null + echo "InUse (bool): {$customer->getInUse()}
"; // bool|null Indicates whether the dimension is used in a financial transaction or not. Read-only attribute. echo "InUse (string): " . Util::formatBoolean($customer->getInUse()) . "
"; // string|null - if ($customer->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($customer->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($customer->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($customer->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Name: {$customer->getName()}
"; // string|null Name of the dimension. - echo "Office (\\PhpTwinfield\\Office):
" . print_r($customer->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): " . Util::objectToStr($customer->getOffice()) . "
"; // string|null + echo "Name: {$customer->getName()}
"; // string|null Name of the dimension. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($customer->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): " . Util::objectToStr($customer->getOffice()) . "
"; // string|null echo "PaymentCondition:
"; // Sets the payment condition of a dimension. echo "PaymentCondition DiscountDays: {$customer->getPaymentConditionDiscountDays()}
"; // int|null Number of discount days. echo "PaymentCondition DiscountPercentage: {$customer->getPaymentConditionDiscountPercentage()}
"; // float|null Discount percentage. echo "RemittanceAdvice:
"; // echo "RemittanceAdvice SendMail: {$customer->getRemittanceAdviceSendMail()}
"; // string|null Mandatory if sendtype = ByEmail, remittance advice will be sent using this e-mail address. echo "RemittanceAdvice SendType: {$customer->getRemittanceAdviceSendType()}
"; // RemittanceAdviceSendType|null To file manager, By e-mail - echo "Result: {$customer->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "ShortName: {$customer->getShortName()}
"; // string|null Short name of the dimension. - echo "Status: {$customer->getStatus()}
"; // Status|null Status of the customer. + echo "Result: {$customer->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$customer->getShortName()}
"; // string|null Short name of the dimension. + echo "Status: {$customer->getStatus()}
"; // Status|null Status of the customer. echo "Touched: {$customer->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($customer->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of customers is DEB. echo "Type (string): " . Util::objectToStr($customer->getType()) . "
"; // string|null @@ -234,7 +234,7 @@ echo "CustomerAddress {$key}
"; echo "City: {$customerAddress->getCity()}
"; // string|null City. - echo "Country (\\PhpTwinfield\\Country):
" . print_r($customerAddress->getCountry(), true) . "

"; // Country|null Country code. The ISO country codes are used. + echo "Country (\\PhpTwinfield\\Country):
" . print_r($customerAddress->getCountry(), true) . "

"; // Country|null Country code. The ISO country codes are used. echo "Country (string): " . Util::objectToStr($customerAddress->getCountry()) . "
"; // string|null echo "Default (bool): {$customerAddress->getDefault()}
"; // bool|null Is this the default address, only one default address is possible. echo "Default (string): " . Util::formatBoolean($customerAddress->getDefault()) . "
"; // string|null @@ -247,15 +247,15 @@ echo "Field6: {$customerAddress->getField6()}
"; // string|null User defined fields, the labels are configured in the Dimension type. echo "ID: {$customerAddress->getID()}
"; // int|null Sequence number of the address line. - if ($customerAddress->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($customerAddress->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($customerAddress->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($customerAddress->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Name: {$customerAddress->getName()}
"; // string|null Company name. + echo "Name: {$customerAddress->getName()}
"; // string|null Company name. echo "Postcode: {$customerAddress->getPostcode()}
"; // string|null Postcode. echo "Result: {$customerAddress->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "Telefax: {$customerAddress->getTelefax()}
"; // string|null Fax number. - echo "Telephone: {$customerAddress->getTelephone()}
"; // string|null Telephone number. + echo "Telefax: {$customerAddress->getTelefax()}
"; // string|null Fax number. + echo "Telephone: {$customerAddress->getTelephone()}
"; // string|null Telephone number. echo "Type: {$customerAddress->getType()}
"; // AddressType|null The type of the address. } @@ -274,24 +274,24 @@ echo "Blocked (bool): {$customerBank->getBlocked()}
"; // bool|null echo "Blocked (string): " . Util::formatBoolean($customerBank->getBlocked()) . "
"; // string|null echo "City: {$customerBank->getCity()}
"; // string|null City. - echo "Country (\\PhpTwinfield\\Country):
" . print_r($customerBank->getCountry(), true) . "

"; // Country|null Bank country code. The ISO country codes are used. + echo "Country (\\PhpTwinfield\\Country):
" . print_r($customerBank->getCountry(), true) . "

"; // Country|null Bank country code. The ISO country codes are used. echo "Country (string): " . Util::objectToStr($customerBank->getCountry()) . "
"; // string|null echo "Default (bool): {$customerBank->getDefault()}
"; // bool|null Is this the default bank account, only one default bank account is possible. echo "Default (string): " . Util::formatBoolean($customerBank->getDefault()) . "
"; // string|null echo "ID: {$customerBank->getID()}
"; // int|null Sequence number of the bank account line. When adding a new bank, do not supply the @id. When changing a bank account, supply the corresponding @id. echo "IBAN: {$customerBank->getIban()}
"; // string|null IBAN account number. - if ($customerBank->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($customerBank->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($customerBank->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($customerBank->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "NatBicCode: {$customerBank->getNatBicCode()}
"; // string|null National bank code. + echo "NatBicCode: {$customerBank->getNatBicCode()}
"; // string|null National bank code. echo "Postcode: {$customerBank->getPostcode()}
"; // string|null Postcode. echo "Result: {$customerBank->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "State: {$customerBank->getState()}
"; // string|null State. + echo "State: {$customerBank->getState()}
"; // string|null State. } - $customerCreditManagement = $customer->getCreditManagement(); // CustomerCreditManagement|null CustomerCreditManagement object. + $customerCreditManagement = $customer->getCreditManagement(); // CustomerCreditManagement|null CustomerCreditManagement object. echo "CustomerCreditManagement
"; echo "BaseCreditLimit (\\Money\\Money):
" . print_r($customerCreditManagement->getBaseCreditLimit(), true) . "

"; // Money|null The credit limit amount. @@ -308,8 +308,8 @@ echo "Freetext2: {$customerCreditManagement->getFreeText2()}
"; // string|null Segment code. echo "Freetext3: {$customerCreditManagement->getFreeText3()}
"; // string|null Not in use. - if ($customerCreditManagement->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($customerCreditManagement->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($customerCreditManagement->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($customerCreditManagement->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "ReminderEmail: {$customerCreditManagement->getReminderEmail()}
"; // string|null Mandatory if sendreminder is email. @@ -319,7 +319,7 @@ echo "SendReminder: {$customerCreditManagement->getSendReminder()}
"; // SendReminder|null Determines if and how a customer will be reminded. echo "CustomerFinancials
"; - $customerFinancials = $customer->getFinancials(); // CustomerFinancials|null CustomerFinancials object. + $customerFinancials = $customer->getFinancials(); // CustomerFinancials|null CustomerFinancials object. echo "AccountType: {$customerFinancials->getAccountType()}
"; // AccountType|null Fixed value inherit. echo "CollectionSchema: {$customerFinancials->getCollectionSchema()}
"; // CollectionSchema|null Collection schema information. Apply this information only when the customer invoices are collected by SEPA direct debit. @@ -327,12 +327,12 @@ echo "EBillMail: {$customerFinancials->getEBillMail()}
"; // string|null The mail address the electronic sales invoice is sent to. echo "EBilling (bool): {$customerFinancials->getEBilling()}
"; // bool|null Determines if the sales invoices will be sent electronically to the customer. echo "EBilling (string): " . Util::formatBoolean($customerFinancials->getEBilling()) . "
"; // string|null - echo "Level: {$customerFinancials->getLevel()}
"; // int|null Specifies the dimension level. Normally the level of customers is level 2. Read-only attribute. + echo "Level: {$customerFinancials->getLevel()}
"; // int|null Specifies the dimension level. Normally the level of customers is level 2. Read-only attribute. echo "MatchType: {$customerFinancials->getMatchType()}
"; // MatchType|null Fixed value customersupplier. echo "MeansOfPayment: {$customerFinancials->getMeansOfPayment()}
"; // MeansOfPayment|null The option none is only allowed in case payavailable is set to false. The option paymentfile is only allowed in case payavailable is set to true. - if ($customerFinancials->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($customerFinancials->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($customerFinancials->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($customerFinancials->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "PayAvailable (bool): {$customerFinancials->getPayAvailable()}
"; // bool|null Determines if direct debit is possible. @@ -359,23 +359,23 @@ echo "ElementValue: {$customerChildValidation->getElementValue()}
"; // string|null echo "Level: {$customerChildValidation->getLevel()}
"; // int|null - if ($customerChildValidation->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($customerChildValidation->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($customerChildValidation->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($customerChildValidation->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "Result: {$customerChildValidation->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "Type: {$customerChildValidation->getType()}
"; // ChildValidationType|null } - $customerCollectMandate = $customerFinancials->getCollectMandate(); // CollectMandate|null CollectMandate object. + $customerCollectMandate = $customerFinancials->getCollectMandate(); // CollectMandate|null CollectMandate object. echo "CustomerCollectMandate
"; echo "FirstRunDate (\\DateTimeInterface):
" . print_r($customerCollectMandate->getFirstRunDate(), true) . "

"; // \DateTimeInterface|null Date on which the first run was collected. echo "FirstRunDate (string): " . Util::formatDate($customerCollectMandate->getFirstRunDate()) . "
"; // string|null echo "ID: {$customerCollectMandate->getID()}
"; // string|null Mandate id which the debtor can collect with. - if ($customerCollectMandate->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($customerCollectMandate->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($customerCollectMandate->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($customerCollectMandate->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "SignatureDate (\\DateTimeInterface):
" . print_r($customerCollectMandate->getSignatureDate(), true) . "

"; // \DateTimeInterface|null Date on which the mandate is signed. @@ -393,12 +393,12 @@ echo "Description: {$customerPostingRule->getDescription()}
"; // string|null Description. echo "ID: {$customerPostingRule->getID()}
"; // int|null Sequence number of the posting rule. Fixed value 1. - if ($customerPostingRule->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($customerPostingRule->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($customerPostingRule->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($customerPostingRule->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "Result: {$customerPostingRule->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "Status: {$customerPostingRule->getStatus()}
"; // Status|null Status of the posting rule. + echo "Status: {$customerPostingRule->getStatus()}
"; // Status|null Status of the posting rule. $customerLines = $customerPostingRule->getLines(); // array|null Array of CustomerLine objects. @@ -416,11 +416,11 @@ echo "Dimension3 (string): " . Util::objectToStr($customerLine->getDimension3()) . "
"; // string|null echo "Dimension3ID: {$customerLine->getDimension3ID()}
"; // string|null - if ($customerLine->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($customerLine->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($customerLine->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($customerLine->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Office (\\PhpTwinfield\\Office):
" . print_r($customerLine->getOffice(), true) . "

"; // Office|null Destination company. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($customerLine->getOffice(), true) . "

"; // Office|null Destination company. echo "Office (string): " . Util::objectToStr($customerLine->getOffice()) . "
"; // string|null echo "Ratio: {$customerLine->getRatio()}
"; // float|null The ratio of the posting rule line. echo "Result: {$customerLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). @@ -556,7 +556,7 @@ $country->setCode('NL'); $customerAddress->setCountry($country); // Country|null Country code. The ISO country codes are used. $customerAddress->setCountry(\PhpTwinfield\Country::fromCode('NL')); // string|null - $customerAddress->setDefault(true); // bool|null Is this the default address, only one default address is possible. + $customerAddress->setDefault(true); // bool|null Is this the default address, only one default address is possible. $customerAddress->setEmail('test@example.com'); // string|null $customerAddress->setField1(''); // string|null User defined fields, the labels are configured in the Dimension type. $customerAddress->setField2(''); // string|null User defined fields, the labels are configured in the Dimension type. diff --git a/examples/DimensionGroup.php b/examples/DimensionGroup.php index b71551b6..c7dd71ce 100644 --- a/examples/DimensionGroup.php +++ b/examples/DimensionGroup.php @@ -126,26 +126,26 @@ echo ""; echo "DimensionGroup
"; - echo "Code: {$dimensionGroup->getCode()}
"; // string|null Dimension group code. + echo "Code: {$dimensionGroup->getCode()}
"; // string|null Dimension group code. - if ($dimensionGroup->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($dimensionGroup->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($dimensionGroup->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($dimensionGroup->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Name: {$dimensionGroup->getName()}
"; // string|null Name of the dimension group. - echo "Office (\\PhpTwinfield\\Office):
" . print_r($dimensionGroup->getOffice(), true) . "

"; // Office|null Office code. + echo "Name: {$dimensionGroup->getName()}
"; // string|null Name of the dimension group. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($dimensionGroup->getOffice(), true) . "

"; // Office|null Office code. echo "Office (string): " . Util::objectToStr($dimensionGroup->getOffice()) . "
"; // string|null - echo "Result: {$dimensionGroup->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "ShortName: {$dimensionGroup->getShortName()}
"; // string|null Short name of the dimension group. - echo "Status: {$dimensionGroup->getStatus()}
"; // Status|null Status of the dimension group. + echo "Result: {$dimensionGroup->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$dimensionGroup->getShortName()}
"; // string|null Short name of the dimension group. + echo "Status: {$dimensionGroup->getStatus()}
"; // Status|null Status of the dimension group. - $dimensionGroupDimensions = $dimensionGroup->getDimensions(); // Array|null Array of DimensionGroupDimension objects. + $dimensionGroupDimensions = $dimensionGroup->getDimensions(); // Array|null Array of DimensionGroupDimension objects. foreach ($dimensionGroupDimensions as $key => $dimensionGroupDimension) { echo "DimensionGroupDimension {$key}
"; - if ($dimensionGroupDimension->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($dimensionGroupDimension->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($dimensionGroupDimension->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($dimensionGroupDimension->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "Code:
" . print_r($dimensionGroupDimension->getCode(), true) . "

"; // object|null Code of the dimension. diff --git a/examples/DimensionType.php b/examples/DimensionType.php index a17be814..714d51bd 100644 --- a/examples/DimensionType.php +++ b/examples/DimensionType.php @@ -130,45 +130,45 @@ echo ""; echo "DimensionType
"; - echo "Code: {$dimensionType->getCode()}
"; // string|null Dimension type. - echo "Mask: {$dimensionType->getMask()}
"; // string|null Dimension type mask. + echo "Code: {$dimensionType->getCode()}
"; // string|null Dimension type. + echo "Mask: {$dimensionType->getMask()}
"; // string|null Dimension type mask. - if ($dimensionType->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($dimensionType->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($dimensionType->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($dimensionType->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Name: {$dimensionType->getName()}
"; // string|null Dimension type name. - echo "Office (\\PhpTwinfield\\Office):
" . print_r($dimensionType->getOffice(), true) . "

"; // Office|null Office code. + echo "Name: {$dimensionType->getName()}
"; // string|null Dimension type name. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($dimensionType->getOffice(), true) . "

"; // Office|null Office code. echo "Office (string): " . Util::objectToStr($dimensionType->getOffice()) . "
"; // string|null - echo "Result: {$dimensionType->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "ShortName: {$dimensionType->getShortName()}
"; // string|null Dimension type short name. - echo "Status: {$dimensionType->getStatus()}
"; // Status|null Status of the dimension type. + echo "Result: {$dimensionType->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$dimensionType->getShortName()}
"; // string|null Dimension type short name. + echo "Status: {$dimensionType->getStatus()}
"; // Status|null Status of the dimension type. - $dimensionTypeLevels = $dimensionType->getLevels(); // DimensionTypeLevels|null DimensionTypeLevels object. + $dimensionTypeLevels = $dimensionType->getLevels(); // DimensionTypeLevels|null DimensionTypeLevels object. - echo "Financials: {$dimensionTypeLevels->getFinancials()}
"; // int|null Read-only attribute. Financial level. + echo "Financials: {$dimensionTypeLevels->getFinancials()}
"; // int|null Read-only attribute. Financial level. - if ($dimensionTypeLevels->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($dimensionTypeLevels->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($dimensionTypeLevels->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($dimensionTypeLevels->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Result: {$dimensionTypeLevels->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "Time: {$dimensionTypeLevels->getTime()}
"; // int|null Read-only attribute. Level in time & expenses. + echo "Result: {$dimensionTypeLevels->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Time: {$dimensionTypeLevels->getTime()}
"; // int|null Read-only attribute. Level in time & expenses. - $dimensionTypeAddress = $dimensionType->getAddress(); // DimensionTypeAddress|null DimensionTypeAddress object. + $dimensionTypeAddress = $dimensionType->getAddress(); // DimensionTypeAddress|null DimensionTypeAddress object. - echo "Label 1: {$dimensionTypeAddress->getLabel1()}
"; // string|null Address labels, description of field1 in the dimension address element. - echo "Label 2: {$dimensionTypeAddress->getLabel2()}
"; // string|null Address labels, description of field2 in the dimension address element. - echo "Label 3: {$dimensionTypeAddress->getLabel3()}
"; // string|null Address labels, description of field3 in the dimension address element. - echo "Label 4: {$dimensionTypeAddress->getLabel4()}
"; // string|null Address labels, description of field4 in the dimension address element. - echo "Label 5: {$dimensionTypeAddress->getLabel5()}
"; // string|null Address labels, description of field5 in the dimension address element. - echo "Label 6: {$dimensionTypeAddress->getLabel6()}
"; // string|null Address labels, description of field6 in the dimension address element. + echo "Label 1: {$dimensionTypeAddress->getLabel1()}
"; // string|null Address labels, description of field1 in the dimension address element. + echo "Label 2: {$dimensionTypeAddress->getLabel2()}
"; // string|null Address labels, description of field2 in the dimension address element. + echo "Label 3: {$dimensionTypeAddress->getLabel3()}
"; // string|null Address labels, description of field3 in the dimension address element. + echo "Label 4: {$dimensionTypeAddress->getLabel4()}
"; // string|null Address labels, description of field4 in the dimension address element. + echo "Label 5: {$dimensionTypeAddress->getLabel5()}
"; // string|null Address labels, description of field5 in the dimension address element. + echo "Label 6: {$dimensionTypeAddress->getLabel6()}
"; // string|null Address labels, description of field6 in the dimension address element. - if ($dimensionTypeAddress->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($dimensionTypeAddress->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($dimensionTypeAddress->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($dimensionTypeAddress->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Result: {$dimensionTypeAddress->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Result: {$dimensionTypeAddress->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). } // Copy an existing DimensionType to a new entity diff --git a/examples/FixedAsset.php b/examples/FixedAsset.php index fb14a15c..dfff171e 100644 --- a/examples/FixedAsset.php +++ b/examples/FixedAsset.php @@ -57,22 +57,22 @@ * office Sets the office code. * Usage: $options['office'] = 'SomeOfficeCode'; * - * level Specifies the dimension level. + * level Specifies the dimension level. * Available values: 1, 2, 3, 4, 5, 6 * Usage: $options['level'] = 3; * - * section Restricts to financial or time & expenses dimensions. + * section Restricts to financial or time & expenses dimensions. * Available values: financials, teq * Usage: $options['section'] = 'financials'; * - * dimtype Specifies the dimension type. + * dimtype Specifies the dimension type. * Available values: BAS, PNL, DEB, CRD, KPL, PRJ, AST, ACT * Usage: $options['dimtype'] = 'AST'; * - * modifiedsince Restricts to dimensions modified after or at the specified date (and time), format yyyyMMddHHmmss or yyyyMMdd + * modifiedsince Restricts to dimensions modified after or at the specified date (and time), format yyyyMMddHHmmss or yyyyMMdd * Usage: $options['modifiedsince'] = '20190101170000' or $options['modifiedsince'] = '20190101'; * - * group Specifies the dimension group (wildcards allowed). + * group Specifies the dimension group (wildcards allowed). * Usage: $options['group'] = 'DIMGROUP'; * */ @@ -154,37 +154,37 @@ echo ""; echo "FixedAsset
"; - echo "Behaviour: {$fixedAsset->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. - echo "Code: {$fixedAsset->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the AST Dimension type. - echo "Group (\\PhpTwinfield\\DimensionGroup):
" . print_r($fixedAsset->getGroup(), true) . "

"; // DimensionGroup|null Sets the dimension group. See Dimension group. - echo "Group (string): " . Util::objectToStr($fixedAsset->getGroup()) . "
"; // string|null - echo "InUse (bool): {$fixedAsset->getInUse()}
"; // bool|null Indicates whether the fixed asset is used in a financial transaction or not. Read-only attribute. + echo "Behaviour: {$fixedAsset->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. + echo "Code: {$fixedAsset->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the AST Dimension type. + echo "Group (\\PhpTwinfield\\DimensionGroup):
" . print_r($fixedAsset->getGroup(), true) . "

"; // DimensionGroup|null Sets the dimension group. See Dimension group. + echo "Group (string): " . Util::objectToStr($fixedAsset->getGroup()) . "
"; // string|null + echo "InUse (bool): {$fixedAsset->getInUse()}
"; // bool|null Indicates whether the fixed asset is used in a financial transaction or not. Read-only attribute. echo "InUse (string): " . Util::formatBoolean($fixedAsset->getInUse()) . "
"; // string|null - if ($fixedAsset->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($fixedAsset->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($fixedAsset->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($fixedAsset->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Name: {$fixedAsset->getName()}
"; // string|null Name of the dimension. - echo "Office (\\PhpTwinfield\\Office):
" . print_r($fixedAsset->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): " . Util::objectToStr($fixedAsset->getOffice()) . "
"; // string|null - echo "Result: {$fixedAsset->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "ShortName: {$fixedAsset->getShortName()}
"; // string|null Not in use. - echo "Status: {$fixedAsset->getStatus()}
"; // Status|null Status of the fixed asset. + echo "Name: {$fixedAsset->getName()}
"; // string|null Name of the dimension. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($fixedAsset->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): " . Util::objectToStr($fixedAsset->getOffice()) . "
"; // string|null + echo "Result: {$fixedAsset->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$fixedAsset->getShortName()}
"; // string|null Not in use. + echo "Status: {$fixedAsset->getStatus()}
"; // Status|null Status of the fixed asset. echo "Touched: {$fixedAsset->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($fixedAsset->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of fixed assets is AST. echo "Type (string): " . Util::objectToStr($fixedAsset->getType()) . "
"; // string|null echo "UID: {$fixedAsset->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. echo "FixedAssetFinancials
"; - $fixedAssetFinancials = $fixedAsset->getFinancials(); // FixedAssetFinancials|null FixedAssetFinancials object. + $fixedAssetFinancials = $fixedAsset->getFinancials(); // FixedAssetFinancials|null FixedAssetFinancials object. echo "AccountType: {$fixedAssetFinancials->getAccountType()}
"; // AccountType|null Fixed value inherit. Read-only attribute. - echo "Level: {$fixedAssetFinancials->getLevel()}
"; // int|null Specifies the dimension level. Normally the level of fixed assets is level 3. Read-only attribute. + echo "Level: {$fixedAssetFinancials->getLevel()}
"; // int|null Specifies the dimension level. Normally the level of fixed assets is level 3. Read-only attribute. echo "MatchType: {$fixedAssetFinancials->getMatchType()}
"; // MatchType|null The matchable value of the balance account. Read-only attribute. - if ($fixedAssetFinancials->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($fixedAssetFinancials->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($fixedAssetFinancials->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($fixedAssetFinancials->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "Result: {$fixedAssetFinancials->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). @@ -224,8 +224,8 @@ echo "LastDepreciation Locked (bool): {$fixedAssetFixedAssets->getLastDepreciationLocked()}
"; // bool|null echo "LastDepreciation Locked (string): " . Util::formatBoolean($fixedAssetFixedAssets->getLastDepreciationLocked()) . "
"; // string|null - if ($fixedAssetFixedAssets->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($fixedAssetFixedAssets->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($fixedAssetFixedAssets->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($fixedAssetFixedAssets->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "Method (\\PhpTwinfield\\AssetMethod):
" . print_r($fixedAssetFixedAssets->getMethod(), true) . "

"; // AssetMethod|null The asset method. See Asset methods. @@ -253,7 +253,7 @@ echo "SellDate (string): " . Util::formatDate($fixedAssetFixedAssets->getSellDate()) . "
"; // string|null echo "SellDate Locked (bool): {$fixedAssetFixedAssets->getSellDateLocked()}
"; // bool|null echo "SellDate Locked (string): " . Util::formatBoolean($fixedAssetFixedAssets->getSellDateLocked()) . "
"; // string|null - echo "Status: {$fixedAssetFixedAssets->getStatus()}
"; // FixedAssetsStatus|null The status of the asset. + echo "Status: {$fixedAssetFixedAssets->getStatus()}
"; // FixedAssetsStatus|null The status of the asset. echo "Status Locked (bool): {$fixedAssetFixedAssets->getStatusLocked()}
"; // bool|null The value future depreciation should stop at. echo "Status Locked (string): " . Util::formatBoolean($fixedAssetFixedAssets->getStatusLocked()) . "
"; // string|null echo "StopValue (\\Money\\Money):
" . print_r($fixedAssetFixedAssets->getStopValue(), true) . "

"; // Money|null Transaction line amount. @@ -304,8 +304,8 @@ echo "Line Locked (bool): {$fixedAssetTransactionLine->getLineLocked()}
"; // bool|null echo "Line Locked (string): " . Util::formatBoolean($fixedAssetTransactionLine->getLineLocked()) . "
"; // string|null - if ($fixedAssetTransactionLine->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($fixedAssetTransactionLine->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($fixedAssetTransactionLine->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($fixedAssetTransactionLine->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "Number: {$fixedAssetTransactionLine->getNumber()}
"; // int|null Transaction number. diff --git a/examples/GeneralLedger.php b/examples/GeneralLedger.php index 1d0dad9e..7f41bcd1 100644 --- a/examples/GeneralLedger.php +++ b/examples/GeneralLedger.php @@ -54,22 +54,22 @@ * office Sets the office code. * Usage: $options['office'] = 'SomeOfficeCode'; * - * level Specifies the dimension level. + * level Specifies the dimension level. * Available values: 1, 2, 3, 4, 5, 6 * Usage: $options['level'] = 2; * - * section Restricts to financial or time & expenses dimensions. + * section Restricts to financial or time & expenses dimensions. * Available values: financials, teq * Usage: $options['section'] = 'financials'; * - * dimtype Specifies the dimension type. + * dimtype Specifies the dimension type. * Available values: BAS, PNL, DEB, CRD, KPL, PRJ, AST, ACT * Usage: $options['dimtype'] = 'BAS'; * - * modifiedsince Restricts to dimensions modified after or at the specified date (and time), format yyyyMMddHHmmss or yyyyMMdd + * modifiedsince Restricts to dimensions modified after or at the specified date (and time), format yyyyMMddHHmmss or yyyyMMdd * Usage: $options['modifiedsince'] = '20190101170000' or $options['modifiedsince'] = '20190101'; * - * group Specifies the dimension group (wildcards allowed). + * group Specifies the dimension group (wildcards allowed). * Usage: $options['group'] = 'DIMGROUP'; * */ @@ -141,41 +141,41 @@ echo ""; echo "GeneralLedger
"; - echo "BeginPeriod: {$generalLedger->getBeginPeriod()}
"; // int|null Determines together with beginyear the period from which the dimension may be used. - echo "BeginYear: {$generalLedger->getBeginYear()}
"; // int|null Determines together with beginperiod the period from which the dimension may be used. - echo "Behaviour: {$generalLedger->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. - echo "Code: {$generalLedger->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the BAS or PNL Dimension type. - echo "EndPeriod: {$generalLedger->getEndPeriod()}
"; // int|null Determines together with endyear the period till which the dimension may be used. - echo "EndYear: {$generalLedger->getEndYear()}
"; // int|null Determines together with endperiod the period till which the dimension may be used. - echo "Group (\\PhpTwinfield\\DimensionGroup):
" . print_r($generalLedger->getGroup(), true) . "

"; // DimensionGroup|null Sets the dimension group. See Dimension group. - echo "Group (string): " . Util::objectToStr($generalLedger->getGroup()) . "
"; // string|null - echo "InUse (bool): {$generalLedger->getInUse()}
"; // bool|null Indicates if the balance or profit and loss account is used in a financial transaction or linked to a VAT code or linked to an article or not in use at all. Read-only attribute. + echo "BeginPeriod: {$generalLedger->getBeginPeriod()}
"; // int|null Determines together with beginyear the period from which the dimension may be used. + echo "BeginYear: {$generalLedger->getBeginYear()}
"; // int|null Determines together with beginperiod the period from which the dimension may be used. + echo "Behaviour: {$generalLedger->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. + echo "Code: {$generalLedger->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the BAS or PNL Dimension type. + echo "EndPeriod: {$generalLedger->getEndPeriod()}
"; // int|null Determines together with endyear the period till which the dimension may be used. + echo "EndYear: {$generalLedger->getEndYear()}
"; // int|null Determines together with endperiod the period till which the dimension may be used. + echo "Group (\\PhpTwinfield\\DimensionGroup):
" . print_r($generalLedger->getGroup(), true) . "

"; // DimensionGroup|null Sets the dimension group. See Dimension group. + echo "Group (string): " . Util::objectToStr($generalLedger->getGroup()) . "
"; // string|null + echo "InUse (bool): {$generalLedger->getInUse()}
"; // bool|null Indicates if the balance or profit and loss account is used in a financial transaction or linked to a VAT code or linked to an article or not in use at all. Read-only attribute. echo "InUse (string): " . Util::formatBoolean($generalLedger->getInUse()) . "
"; // string|null - if ($generalLedger->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($generalLedger->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($generalLedger->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($generalLedger->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Name: {$generalLedger->getName()}
"; // string|null Name of the dimension. - echo "Office (\\PhpTwinfield\\Office):
" . print_r($generalLedger->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): " . Util::objectToStr($generalLedger->getOffice()) . "
"; // string|null - echo "Result: {$generalLedger->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "ShortName: {$generalLedger->getShortName()}
"; // string|null Short name of the dimension. - echo "Status: {$generalLedger->getStatus()}
"; // Status|null Status of the generalLedger. + echo "Name: {$generalLedger->getName()}
"; // string|null Name of the dimension. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($generalLedger->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): " . Util::objectToStr($generalLedger->getOffice()) . "
"; // string|null + echo "Result: {$generalLedger->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$generalLedger->getShortName()}
"; // string|null Short name of the dimension. + echo "Status: {$generalLedger->getStatus()}
"; // Status|null Status of the generalLedger. echo "Touched: {$generalLedger->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($generalLedger->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of balance accounts is BAS and type of profit and loss is PNL. echo "Type (string): " . Util::objectToStr($generalLedger->getType()) . "
"; // string|null echo "UID: {$generalLedger->getUID()}
"; // string|null Unique identification of the dimension. Read-only attribute. echo "GeneralLedgerFinancials
"; - $generalLedgerFinancials = $generalLedger->getFinancials(); // GeneralLedgerFinancials|null GeneralLedgerFinancials object. + $generalLedgerFinancials = $generalLedger->getFinancials(); // GeneralLedgerFinancials|null GeneralLedgerFinancials object. echo "AccountType: {$generalLedgerFinancials->getAccountType()}
"; // AccountType|null Fixed value balance. - echo "Level: {$generalLedgerFinancials->getLevel()}
"; // int|null Specifies the dimension level. Normally the level of balance accounts is level 1. Read-only attribute. + echo "Level: {$generalLedgerFinancials->getLevel()}
"; // int|null Specifies the dimension level. Normally the level of balance accounts is level 1. Read-only attribute. echo "MatchType: {$generalLedgerFinancials->getMatchType()}
"; // MatchType|null Sets the matchable value of the balance account. - if ($generalLedgerFinancials->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($generalLedgerFinancials->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($generalLedgerFinancials->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($generalLedgerFinancials->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "Result: {$generalLedgerFinancials->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). @@ -193,8 +193,8 @@ echo "ElementValue: {$generalLedgerChildValidation->getElementValue()}
"; // string|null echo "Level: {$generalLedgerChildValidation->getLevel()}
"; // int|null - if ($generalLedgerChildValidation->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($generalLedgerChildValidation->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($generalLedgerChildValidation->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($generalLedgerChildValidation->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "Result: {$generalLedgerChildValidation->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). diff --git a/examples/Invoice.php b/examples/Invoice.php index 7208ae13..d89de4e2 100644 --- a/examples/Invoice.php +++ b/examples/Invoice.php @@ -149,11 +149,11 @@ echo ""; echo "Invoice
"; - echo "Bank (\\PhpTwinfield\\CashBankBook):
" . print_r($invoice->getBank(), true) . "

"; // CashBankBook|null Bank code. - echo "Bank (string): " . Util::objectToStr($invoice->getBank()) . "
"; // string|null - echo "Currency (\\PhpTwinfield\\Currency):
" . print_r($invoice->getCurrency(), true) . "

"; // Currency|null Currency code. + echo "Bank (\\PhpTwinfield\\CashBankBook):
" . print_r($invoice->getBank(), true) . "

"; // CashBankBook|null Bank code. + echo "Bank (string): " . Util::objectToStr($invoice->getBank()) . "
"; // string|null + echo "Currency (\\PhpTwinfield\\Currency):
" . print_r($invoice->getCurrency(), true) . "

"; // Currency|null Currency code. echo "Currency (string): " . Util::objectToStr($invoice->getCurrency()) . "
"; // string|null - echo "Customer (\\PhpTwinfield\\Customer):
" . print_r($invoice->getCustomer(), true) . "

"; // Customer|null Customer code. + echo "Customer (\\PhpTwinfield\\Customer):
" . print_r($invoice->getCustomer(), true) . "

"; // Customer|null Customer code. echo "Customer (string): " . Util::objectToStr($invoice->getCustomer()) . "
"; // string|null echo "DeliverAddressNumber: {$invoice->getDeliverAddressNumber()}
"; // int|null echo "DueDate (\\DateTimeInterface):
" . print_r($invoice->getDueDate(), true) . "

"; // DateTimeInterface|null Due date. @@ -166,31 +166,31 @@ echo "InvoiceDate (\\DateTimeInterface):
" . print_r($invoice->getInvoiceDate(), true) . "

"; // DateTimeInterface|null Invoice date. echo "InvoiceDate (string): " . Util::formatDate($invoice->getInvoiceDate()) . "
"; // string|null echo "InvoiceNumber: {$invoice->getInvoiceNumber()}
"; // string|null Invoice Number. - echo "InvoiceType (\\PhpTwinfield\\InvoiceType):
" . print_r($invoice->getInvoiceType(), true) . "

"; // InvoiceType|null Invoice type code. + echo "InvoiceType (\\PhpTwinfield\\InvoiceType):
" . print_r($invoice->getInvoiceType(), true) . "

"; // InvoiceType|null Invoice type code. echo "InvoiceType (string): " . Util::objectToStr($invoice->getInvoiceType()) . "
"; // string|null - if ($invoice->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($invoice->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($invoice->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($invoice->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "PaymentMethod: {$invoice->getPaymentMethod()}
"; // PaymentMethod|null The payment method. + echo "PaymentMethod: {$invoice->getPaymentMethod()}
"; // PaymentMethod|null The payment method. echo "PerformanceDate (\\DateTimeInterface):
" . print_r($invoice->getPerformanceDate(), true) . "

"; // DateTimeInterface|null Performance date, when set-up on the invoice header. echo "PerformanceDate (string): " . Util::formatDate($invoice->getPerformanceDate()) . "
"; // string|null echo "Period: {$invoice->getPeriod()}
"; // string|null Period in YYYY/PP format. - echo "Office (\\PhpTwinfield\\Office):
" . print_r($invoice->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): " . Util::objectToStr($invoice->getOffice()) . "
"; // string|null - echo "Result: {$invoice->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "Status: {$invoice->getStatus()}
"; // Status|null Status of the invoice. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($invoice->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): " . Util::objectToStr($invoice->getOffice()) . "
"; // string|null + echo "Result: {$invoice->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Status: {$invoice->getStatus()}
"; // Status|null Status of the invoice. $invoiceTotals = $invoice->getTotals(); echo "InvoiceTotals
"; - if ($invoiceTotals->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($invoiceTotals->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($invoiceTotals->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($invoiceTotals->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Result: {$invoiceTotals->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Result: {$invoiceTotals->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "ValueExcl (\\Money\\Money):
" . print_r($invoiceTotals->getValueExcl(), true) . "

"; // Money|null Value without VAT. Read-only attribute. echo "ValueExcl (string): " . Util::formatMoney($invoiceTotals->getValueExcl()) . "
"; // string|null echo "ValueInc (\\Money\\Money):
" . print_r($invoiceTotals->getValueInc(), true) . "

"; // Money|null Value with VAT. Read-only attribute. @@ -198,7 +198,7 @@ if ($invoice->getFinancialCode() != null && $invoice->getFinancialNumber != null) { $match = $invoice->getMatchReference(); - echo "Match (\\PhpTwinfield\\MatchReference):
" . print_r($match, true) . "

"; // MatchReference|null + echo "Match (\\PhpTwinfield\\MatchReference):
" . print_r($match, true) . "

"; // MatchReference|null } $invoiceLines = $invoice->getLines(); // array|null Array of InvoiceLine objects. @@ -208,7 +208,7 @@ echo "AllowDiscountOrPremium (bool): {$invoiceLine->getAllowDiscountOrPremium()}
"; // bool|null Calculate discount on this line. echo "AllowDiscountOrPremium (string): " . Util::formatBoolean($invoiceLine->getAllowDiscountOrPremium()) . "
"; // string|null - echo "Article (\\PhpTwinfield\\Article):
" . print_r($invoiceLine->getArticle(), true) . "

"; // Article|null Article code. + echo "Article (\\PhpTwinfield\\Article):
" . print_r($invoiceLine->getArticle(), true) . "

"; // Article|null Article code. echo "Article (string): " . Util::objectToStr($invoiceLine->getArticle()) . "
"; // string|null echo "Description: {$invoiceLine->getDescription()}
"; // string|null Invoice line description, only on the lines with article ‘0’ or ‘-‘. echo "Dim1 (\\PhpTwinfield\\GeneralLedger):
" . print_r($invoiceLine->getDim1(), true) . "

"; // GeneralLedger|null Balance account. @@ -218,18 +218,18 @@ echo "FreeText3: {$invoiceLine->getFreeText3()}
"; // string|null Free text field 3 as entered on the invoice type. echo "ID: {$invoiceLine->getID()}
"; // int|null Line ID - if ($invoiceLine->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($invoiceLine->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($invoiceLine->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($invoiceLine->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "PerformanceDate (\\DateTimeInterface):
" . print_r($invoiceLine->getPerformanceDate(), true) . "

"; // DateTimeInterface|null Performance date, when set-up on invoice lines. echo "PerformanceDate (string): " . Util::formatDate($invoiceLine->getPerformanceDate()) . "
"; // string|null echo "PerformanceType: {$invoiceLine->getPerformanceType()}
"; // PerformanceType|null The performance type in case of an ICT sales invoice. - echo "Quantity: {$invoiceLine->getQuantity()}
"; // int|null The quantity on the sales invoice line. + echo "Quantity: {$invoiceLine->getQuantity()}
"; // int|null The quantity on the sales invoice line. echo "Result: {$invoiceLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "SubArticle (\\PhpTwinfield\\ArticleLine):
" . print_r($invoiceLine->getSubArticle(), true) . "

"; // ArticleLine|null Sub-article code. echo "SubArticle (string): {$invoiceLine->getSubArticleToString()}
"; // string|null - echo "Units: {$invoiceLine->getUnits()}
"; // int|null The number of units per quantity. + echo "Units: {$invoiceLine->getUnits()}
"; // int|null The number of units per quantity. echo "UnitsPriceExcl (\\Money\\Money):
" . print_r($invoiceLine->getUnitsPriceExcl(), true) . "

"; // Money|null Only valid for invoice types with VAT exclusive units prices. echo "UnitsPriceExcl (string): " . Util::formatMoney($invoiceLine->getUnitsPriceExcl()) . "
"; // string|null Only add this tag to an XML request if the setting Prices can be changed on an item is set to true. Otherwise, the price will be determined by the system. echo "UnitsPriceInc (\\Money\\Money):
" . print_r($invoiceLine->getUnitsPriceInc(), true) . "

"; // Money|null Only valid for invoice types with VAT inclusive units prices. @@ -238,7 +238,7 @@ echo "ValueExcl (string): " . Util::formatMoney($invoiceLine->getValueExcl()) . "
"; // string|null echo "ValueInc (\\Money\\Money):
" . print_r($invoiceLine->getValueInc(), true) . "

"; // Money|null Calculated element. Read-only attribute. echo "ValueInc (string): " . Util::formatMoney($invoiceLine->getValueInc()) . "
"; // string|null - echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($invoiceLine->getVatCode(), true) . "

"; // VatCode|null VAT code. + echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($invoiceLine->getVatCode(), true) . "

"; // VatCode|null VAT code. echo "VatCode (string): " . Util::objectToStr($invoiceLine->getVatCode()) . "
"; // string|null echo "VatValue (\\Money\\Money):
" . print_r($invoiceLine->getVatValue(), true) . "

"; // Money|null Calculated element. Read-only attribute. echo "VatValue (string): " . Util::formatMoney($invoiceLine->getVatValue()) . "
"; // string|null @@ -249,15 +249,15 @@ foreach ($invoiceVatLines as $key => $invoiceVatLine) { echo "InvoiceVatLine {$key}
"; - if ($invoiceVatLine->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($invoiceVatLine->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($invoiceVatLine->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($invoiceVatLine->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "PerformanceDate (\\DateTimeInterface):
" . print_r($invoiceVatLine->getPerformanceDate(), true) . "

"; // DateTimeInterface|null The performance date. Only in case performancetype = services. Read-only attribute. echo "PerformanceDate (string): " . Util::formatDate($invoiceVatLine->getPerformanceDate()) . "
"; // string|null echo "PerformanceType: {$invoiceVatLine->getPerformanceType()}
"; // PerformanceType|null The performance type. Read-only attribute. echo "Result: {$invoiceVatLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($invoiceVatLine->getVatCode(), true) . "

"; // VatCode|null VAT code. Read-only attribute. + echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($invoiceVatLine->getVatCode(), true) . "

"; // VatCode|null VAT code. Read-only attribute. echo "VatCode (string): " . Util::objectToStr($invoiceVatLine->getVatCode()) . "
"; // string|null echo "VatValue (\\Money\\Money):
" . print_r($invoiceVatLine->getVatValue(), true) . "

"; // Money|null VAT amount. Read-only attribute. echo "VatValue (string): " . Util::formatMoney($invoiceVatLine->getVatValue()) . "
"; // string|null @@ -344,15 +344,15 @@ $invoiceLine->setAllowDiscountOrPremium(true); // bool|null Calculate discount on this line. $article = new \PhpTwinfield\Article; $article->setCode('9060'); - $invoiceLine->setArticle($article); // Article|null Article code. - $invoiceLine->setArticle(\PhpTwinfield\Article::fromCode('9060')); // string|null - //$invoiceLine->setDescription('Example Description'); // string|null Invoice line description, only on the lines with article ‘0’ or ‘-‘. + $invoiceLine->setArticle($article); // Article|null Article code. + $invoiceLine->setArticle(\PhpTwinfield\Article::fromCode('9060')); // string|null + //$invoiceLine->setDescription('Example Description'); // string|null Invoice line description, only on the lines with article ‘0’ or ‘-‘. $dim1 = new \PhpTwinfield\GeneralLedger; $dim1->setCode('9060'); - $invoiceLine->setDim1($dim1); // GeneralLedger|null Balance account. - $invoiceLine->setDim1(\PhpTwinfield\GeneralLedger::fromCode('9060')); // string|null - //$invoiceLine->setFreeText1('Example Free Text 1'); // string|null Free text field 1 as entered on the invoice type. - //$invoiceLine->setFreeText2('Example Free Text 2'); // string|null Free text field 2 as entered on the invoice type. + $invoiceLine->setDim1($dim1); // GeneralLedger|null Balance account. + $invoiceLine->setDim1(\PhpTwinfield\GeneralLedger::fromCode('9060')); // string|null + //$invoiceLine->setFreeText1('Example Free Text 1'); // string|null Free text field 1 as entered on the invoice type. + //$invoiceLine->setFreeText2('Example Free Text 2'); // string|null Free text field 2 as entered on the invoice type. //$invoiceLine->setFreeText3("Example Free Text 3"); // string|null Free text field 3 as entered on the invoice type. $invoiceLine->setID(1); // int|null Line ID. //$invoiceLine->setPerformanceType(\PhpTwinfield\Enums\PerformanceType::SERVICES()); // PerformanceType|null The performance type in case of an ICT sales invoice. @@ -361,8 +361,8 @@ $invoiceLine->setQuantity(1); // int|null The quantity on the sales invoice line. $subArticle = new \PhpTwinfield\ArticleLine; $subArticle->setSubCode('9060'); - $invoiceLine->setSubArticle($subArticle); // ArticleLine|null Sub-article code. - $invoiceLine->setSubArticle(\PhpTwinfield\ArticleLine::fromCode('9060')); // string|null + $invoiceLine->setSubArticle($subArticle); // ArticleLine|null Sub-article code. + $invoiceLine->setSubArticle(\PhpTwinfield\ArticleLine::fromCode('9060')); // string|null $invoiceLine->setUnits(1); // int|null The number of units per quantity. $invoiceLine->setUnitsPriceExcl(\Money\Money::EUR(1000)); // Money|null Only valid for invoice types with VAT exclusive units prices. Only add this tag to an XML request if the setting Prices can be changed on an item is set to true. Otherwise, the price will be determined by the system. (Equals 10.00 EUR) //$invoiceLine->setUnitsPriceInc(\Money\Money::EUR(1210)); // Money|null Only valid for invoice types with VAT inclusive units prices. Only add this tag to an XML request if the setting Prices can be changed on an item is set to true. Otherwise, the price will be determined by the system. (Equals 12.10 EUR) diff --git a/examples/Office.php b/examples/Office.php index 83713db4..da403639 100644 --- a/examples/Office.php +++ b/examples/Office.php @@ -137,27 +137,27 @@ echo "Office
"; echo "BaseCurrency (\\PhpTwinfield\\Currency):
" . print_r($office->getBaseCurrency(), true) . "

"; // Currency|null The base currency echo "BaseCurrency (string): " . Util::objectToStr($office->getBaseCurrency()) . "
"; // string|null - echo "Code: {$office}
"; // string|null - echo "Code: {$office->getCode()}
"; // string|null + echo "Code: {$office}
"; // string|null + echo "Code: {$office->getCode()}
"; // string|null //echo "CountryCode (\\PhpTwinfield\\Country):
" . print_r($office->getCountryCode(), true) . "

"; // Country|null //echo "CountryCode (string): " . Util::objectToStr($office->getCountryCode()) . "
"; // string|null - echo "Created (\\DateTimeInterface):
" . print_r($office->getCreated(), true) . "

"; // DateTimeInterface|null The date/time the office was created. + echo "Created (\\DateTimeInterface):
" . print_r($office->getCreated(), true) . "

"; // DateTimeInterface|null The date/time the office was created. echo "Created (string): " . Util::formatDateTime($office->getCreated()) . "
"; // string|null - if ($office->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($office->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($office->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($office->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Modified (\\DateTimeInterface):
" . print_r($office->getModified(), true) . "

"; // DateTimeInterface|null The date/time the office was modified. + echo "Modified (\\DateTimeInterface):
" . print_r($office->getModified(), true) . "

"; // DateTimeInterface|null The date/time the office was modified. echo "Modified (string): " . Util::formatDateTime($office->getModified()) . "
"; // string|null - echo "Name: {$office->getName()}
"; // string|null + echo "Name: {$office->getName()}
"; // string|null echo "ReportingCurrency (\\PhpTwinfield\\Currency):
" . print_r($office->getReportingCurrency(), true) . "

"; // Currency|null The reporting currency echo "ReportingCurrency (string): " . Util::objectToStr($office->getReportingCurrency()) . "
"; // string|null - echo "Result: {$office->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "ShortName: {$office->getShortName()}
"; // string|null - echo "Status: {$office->getStatus()}
"; // Status|null - echo "Touched: {$office->getTouched()}
"; // int|null The number of times the office is modified. - echo "User (\\PhpTwinfield\\User):
" . print_r($office->getUser(), true) . "

"; // User|null The code of the user who created or modified the Office. + echo "Result: {$office->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$office->getShortName()}
"; // string|null + echo "Status: {$office->getStatus()}
"; // Status|null + echo "Touched: {$office->getTouched()}
"; // int|null The number of times the office is modified. + echo "User (\\PhpTwinfield\\User):
" . print_r($office->getUser(), true) . "

"; // User|null The code of the user who created or modified the Office. echo "User (string): " . Util::objectToStr($office->getUser()) . "
"; // string|null //echo "VatFirstQuarterStartsIn: {$office->getVatFirstQuarterStartsIn()}
"; // string|null //echo "VatPeriod: {$office->getVatPeriod()}
"; // string|null diff --git a/examples/Project.php b/examples/Project.php index 45b0fd0b..328cf1e0 100644 --- a/examples/Project.php +++ b/examples/Project.php @@ -144,21 +144,21 @@ echo ""; echo "Project
"; - echo "Behaviour: {$project->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. - echo "Code: {$project->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the ACT Dimension type. - echo "InUse (bool): {$project->getInUse()}
"; // bool|null Indicates whether the project is used in a transaction or not. Read-only attribute. + echo "Behaviour: {$project->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. + echo "Code: {$project->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the ACT Dimension type. + echo "InUse (bool): {$project->getInUse()}
"; // bool|null Indicates whether the project is used in a transaction or not. Read-only attribute. echo "InUse (string): " . Util::formatBoolean($project->getInUse()) . "
"; // string|null - if ($project->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($project->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($project->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($project->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Name: {$project->getName()}
"; // string|null Project description. - echo "Office (\\PhpTwinfield\\Office):
" . print_r($project->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): " . Util::objectToStr($project->getOffice()) . "
"; // string|null - echo "Result: {$project->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "ShortName: {$project->getShortName()}
"; // string|null Short project description. - echo "Status: {$project->getStatus()}
"; // Status|null Status of the project. + echo "Name: {$project->getName()}
"; // string|null Project description. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($project->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): " . Util::objectToStr($project->getOffice()) . "
"; // string|null + echo "Result: {$project->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$project->getShortName()}
"; // string|null Short project description. + echo "Status: {$project->getStatus()}
"; // Status|null Status of the project. echo "Touched: {$project->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($project->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of projects is ACT. echo "Type (string): " . Util::objectToStr($project->getType()) . "
"; // string|null @@ -166,9 +166,9 @@ echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($project->getVatCode(), true) . "

"; // VatCode|null The VAT code if one code will apply for all projects within the project. Note that if any VAT codes are echo "VatCode (string): " . Util::objectToStr($project->getVatCode()) . "
"; // string|null defined on project level, these will apply regardless of what is defined on project level. - $projectProjects = $project->getProjects(); // ProjectProjects|null ProjectProjects object. + $projectProjects = $project->getProjects(); // ProjectProjects|null ProjectProjects object. - echo "Authoriser (\\PhpTwinfield\\User):
" . print_r($projectProjects->getAuthoriser(), true) . "

"; // User|null A specific authoriser for an project. + echo "Authoriser (\\PhpTwinfield\\User):
" . print_r($projectProjects->getAuthoriser(), true) . "

"; // User|null A specific authoriser for an project. echo "Authoriser (string): " . Util::objectToStr($projectProjects->getAuthoriser()) . "
"; // string|null If "change" = allow then locked = false and inherit = false echo "Authoriser Inherit (bool): {$projectProjects->getAuthoriserInherit()}
"; // bool|null echo "Authoriser Inherit (string): " . Util::formatBoolean($projectProjects->getAuthoriserInherit()) . "
"; // string|null If "change" = disallow then locked = true and inherit = false @@ -182,7 +182,7 @@ echo "Billable Inherit (string): " . Util::formatBoolean($projectProjects->getBillableInherit()) . "
"; // string|null If "change" = disallow then locked = true and inherit = false. echo "Billable Locked (bool): {$projectProjects->getBillableLocked()}
"; // bool|null echo "Billable Locked (string): " . Util::formatBoolean($projectProjects->getBillableLocked()) . "
"; // string|null If "change" = inherit then locked = true and inherit = true - echo "Customer (\\PhpTwinfield\\Customer):
" . print_r($projectProjects->getCustomer(), true) . "

"; // Customer|null An project always needs to be linked to a customer. + echo "Customer (\\PhpTwinfield\\Customer):
" . print_r($projectProjects->getCustomer(), true) . "

"; // Customer|null An project always needs to be linked to a customer. echo "Customer (string): " . Util::objectToStr($projectProjects->getCustomer()) . "
"; // string|null Choose to have the customer ‘inherited’ (from a project) or you can specify the customer here. echo "Customer Inherit (bool): {$projectProjects->getCustomerInherit()}
"; // bool|null echo "Customer Inherit (string): " . Util::formatBoolean($projectProjects->getCustomerInherit()) . "
"; // string|null If "change" = allow then locked = false and inherit = false @@ -190,11 +190,11 @@ echo "Customer Locked (string): " . Util::formatBoolean($projectProjects->getCustomerLocked()) . "
"; // string|null If "change" = inherit then locked = true and inherit = true echo "Invoice Description: {$projectProjects->getInvoiceDescription()}
"; // string|null This field can be used to enter a longer project description which will be available on the invoice template. - if ($projectProjects->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($projectProjects->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($projectProjects->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($projectProjects->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Rate (\\PhpTwinfield\\Rate):
" . print_r($projectProjects->getRate(), true) . "

"; // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). + echo "Rate (\\PhpTwinfield\\Rate):
" . print_r($projectProjects->getRate(), true) . "

"; // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). echo "Rate (string): " . Util::objectToStr($projectProjects->getRate()) . "
"; // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). echo "Rate Inherit (bool): {$projectProjects->getRateInherit()}
"; // bool|null echo "Rate Inherit (string): " . Util::formatBoolean($projectProjects->getRateInherit()) . "
"; // string|null If "change" = allow then locked = false and inherit = false @@ -216,11 +216,11 @@ echo "Billable Locked (bool): {$projectQuantity->getBillableLocked()}
"; // bool|null If "billable" = true and "change is allowed" then locked = false echo "Billable Locked (string): " . Util::formatBoolean($projectQuantity->getBillableLocked()) . "
"; // string|null - if ($projectQuantity->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($projectQuantity->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($projectQuantity->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($projectQuantity->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Label: {$projectQuantity->getLabel()}
"; // string|null The label of the quantity. + echo "Label: {$projectQuantity->getLabel()}
"; // string|null The label of the quantity. echo "Mandatory (bool): {$projectQuantity->getMandatory()}
"; // bool|null Is the quantity line mandatory or not. echo "Mandatory (string): " . Util::formatBoolean($projectQuantity->getMandatory()) . "
"; // string|null echo "Rate (\\PhpTwinfield\\Rate):
" . print_r($projectQuantity->getRate(), true) . "

"; // Rate|null The rate. @@ -279,7 +279,7 @@ $authoriser = new \PhpTwinfield\User; $authoriser->setCode('TWINAPPS'); - $projectProjects->setAuthoriser($authoriser); // User|null A specific authoriser for an project. + $projectProjects->setAuthoriser($authoriser); // User|null A specific authoriser for an project. $projectProjects->setAuthoriser(\PhpTwinfield\User::fromCode('TWINAPPS')); // string|null If "change" = allow then locked = false and inherit = false $projectProjects->setAuthoriserInherit(false); // bool|null $projectProjects->setAuthoriserLocked(false); // bool|null @@ -296,7 +296,7 @@ $projectProjects->setInvoiceDescription('Example Invoice Description'); // string|null This field can be used to enter a longer project description which will be available on the invoice template. $rate = new \PhpTwinfield\Rate; $rate->setCode('DIRECT'); - $projectProjects->setRate($rate); // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). + $projectProjects->setRate($rate); // Rate|null Choose to define a specific rate code here or you could also decide that these settings should be inherited from project or user level (@inherit). $projectProjects->setRate(\PhpTwinfield\Rate::fromCode('DIRECT')); // string|null You can also set whether a change of the rate code is allowed or disallowed when a user is entering their timesheet (@locked). $projectProjects->setRateInherit(false); // bool|null $projectProjects->setRateLocked(true); // bool|null If "change" = disallow then locked = true and inherit = false @@ -311,12 +311,12 @@ $projectQuantity = new \PhpTwinfield\ProjectQuantity; $projectQuantity->setBillable(false); // bool|null Is the quantity line billable or not. $projectQuantity->setBillableLocked(false); // bool|null - $projectQuantity->setLabel('Example Quantity'); // string|null + $projectQuantity->setLabel('Example Quantity'); // string|null $projectQuantity->setMandatory(false); // bool|null Is the quantity line mandatory or not. $rate = new \PhpTwinfield\Rate; $rate->setCode('KILOMETERS'); - $projectQuantity->setRate($rate); // Rate|null The rate. - $projectQuantity->setRate(\PhpTwinfield\Rate::fromCode('KILOMETERS')); // string|null + $projectQuantity->setRate($rate); // Rate|null The rate. + $projectQuantity->setRate(\PhpTwinfield\Rate::fromCode('KILOMETERS')); // string|null $projectProjects->addQuantity($projectQuantity); // ProjectQuantity Add an ProjectQuantity object to the ProjectProjects object //$projectProjects->removeQuantity(0); // int Remove a quantity based on the index of the quantity within the array diff --git a/examples/Rate.php b/examples/Rate.php index d86e81af..29f51dc2 100644 --- a/examples/Rate.php +++ b/examples/Rate.php @@ -122,32 +122,32 @@ echo ""; echo "Rate
"; - echo "Code: {$rate->getCode()}
"; // string|null Rate code. - echo "Created (\\DateTimeInterface):
" . print_r($rate->getCreated(), true) . "

"; // DateTimeInterface|null The date/time the rate was created. Read-only attribute. + echo "Code: {$rate->getCode()}
"; // string|null Rate code. + echo "Created (\\DateTimeInterface):
" . print_r($rate->getCreated(), true) . "

"; // DateTimeInterface|null The date/time the rate was created. Read-only attribute. echo "Created (string): " . Util::formatDateTime($rate->getCreated()) . "
"; // string|null - echo "Currency (\\PhpTwinfield\\Currency):
" . print_r($rate->getCurrency(), true) . "

"; // Currency|null Currency code. + echo "Currency (\\PhpTwinfield\\Currency):
" . print_r($rate->getCurrency(), true) . "

"; // Currency|null Currency code. echo "Currency (string): " . Util::objectToStr($rate->getCurrency()) . "
"; // string|null - if ($rate->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($rate->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($rate->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($rate->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Modified (\\DateTimeInterface):
" . print_r($rate->getModified(), true) . "

"; // DateTimeInterface|null The date/time the rate was modified. Read-only attribute. + echo "Modified (\\DateTimeInterface):
" . print_r($rate->getModified(), true) . "

"; // DateTimeInterface|null The date/time the rate was modified. Read-only attribute. echo "Modified (string): " . Util::formatDateTime($rate->getModified()) . "
"; // string|null - echo "Name: {$rate->getName()}
"; // string|null Rate description. - echo "Office (\\PhpTwinfield\\Office):
" . print_r($rate->getOffice(), true) . "

"; // Office|null Office code. + echo "Name: {$rate->getName()}
"; // string|null Rate description. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($rate->getOffice(), true) . "

"; // Office|null Office code. echo "Office (string): " . Util::objectToStr($rate->getOffice()) . "
"; // string|null - echo "Result: {$rate->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "ShortName: {$rate->getShortName()}
"; // string|null Short rate description. - echo "Status: {$rate->getStatus()}
"; // Status|null Status of the rate. - echo "Touched: {$rate->getTouched()}
"; // int|null The number of times the rate is modified. Read-only attribute. - echo "Type: {$rate->getType()}
"; // RateType|null The rate type. - echo "Unit: {$rate->getUnit()}
"; // int|null How will be charged e.g. if charged per hour Time, set it to 60. If charged per 8 hours, set it to 8 * 60 = 460. - // Quantities refers to items such as kilometers. If charged per kilometer set it to 1. - echo "User (\\PhpTwinfield\\User):
" . print_r($rate->getUser(), true) . "

"; // User|null The code of the user who created or modified the Rate. Read-only attribute. + echo "Result: {$rate->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$rate->getShortName()}
"; // string|null Short rate description. + echo "Status: {$rate->getStatus()}
"; // Status|null Status of the rate. + echo "Touched: {$rate->getTouched()}
"; // int|null The number of times the rate is modified. Read-only attribute. + echo "Type: {$rate->getType()}
"; // RateType|null The rate type. + echo "Unit: {$rate->getUnit()}
"; // int|null How will be charged e.g. if charged per hour Time, set it to 60. If charged per 8 hours, set it to 8 * 60 = 460. + // Quantities refers to items such as kilometers. If charged per kilometer set it to 1. + echo "User (\\PhpTwinfield\\User):
" . print_r($rate->getUser(), true) . "

"; // User|null The code of the user who created or modified the Rate. Read-only attribute. echo "User (string): " . Util::objectToStr($rate->getUser()) . "
"; // string|null - $rateRateChanges = $rate->getRateChanges(); // Array|null Array of RateRateChange objects. + $rateRateChanges = $rate->getRateChanges(); // Array|null Array of RateRateChange objects. foreach ($rateRateChanges as $key => $rateRateChange) { echo "RateRateChange {$key}
"; @@ -207,7 +207,7 @@ $rate->setName("Example Rate"); // string|null Rate description. $rate->setOffice($office); // Office|null Office code. $rate->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null - $rate->setType(\PhpTwinfield\Enums\RateType::TIME()); // RateType|null The rate type. + $rate->setType(\PhpTwinfield\Enums\RateType::TIME()); // RateType|null The rate type. $rate->setUnit(60); // int|null How will be charged e.g. if charged per hour Time, set it to 60. If charged per 8 hours, set it to 8 * 60 = 460. // Quantities refers to items such as kilometers. If charged per kilometer set it to 1. // Optional values for creating a new Rate diff --git a/examples/RenewAuthorization.php b/examples/RenewAuthorization.php index 8650572b..39ac6b33 100644 --- a/examples/RenewAuthorization.php +++ b/examples/RenewAuthorization.php @@ -46,6 +46,6 @@ function SendEmail(string $toEmail, string $fromEmail, string $subject, string $ You will receive this email once a week until the authorization is renewed."; if ($refreshTokenStorage['refresh_expiry'] < (time() + ($daysLeftAfterWhichRequestRenewal * 60 * 60 * 24))) { - SendEmail($accountingAdminEmail, $fromEmail, $subject, $body); + SendEmail($accountingAdminEmail, $fromEmail, $subject, $body); } ?> \ No newline at end of file diff --git a/examples/Supplier.php b/examples/Supplier.php index a2dbe832..871369e1 100644 --- a/examples/Supplier.php +++ b/examples/Supplier.php @@ -58,25 +58,25 @@ * office Sets the office code. * Usage: $options['office'] = 'SomeOfficeCode'; * - * level Specifies the dimension level. + * level Specifies the dimension level. * Available values: 1, 2, 3, 4, 5, 6 * Usage: $options['level'] = 2; * - * section Restricts to financial or time & expenses dimensions. + * section Restricts to financial or time & expenses dimensions. * Available values: financials, teq * Usage: $options['section'] = 'financials'; * - * dimtype Specifies the dimension type. + * dimtype Specifies the dimension type. * Available values: BAS, PNL, DEB, CRD, KPL, PRJ, AST, ACT * Usage: $options['dimtype'] = 'CRD'; * - * modifiedsince Restricts to dimensions modified after or at the specified date (and time), format yyyyMMddHHmmss or yyyyMMdd + * modifiedsince Restricts to dimensions modified after or at the specified date (and time), format yyyyMMddHHmmss or yyyyMMdd * Usage: $options['modifiedsince'] = '20190101170000' or $options['modifiedsince'] = '20190101'; * - * group Specifies the dimension group (wildcards allowed). + * group Specifies the dimension group (wildcards allowed). * Usage: $options['group'] = 'DIMGROUP'; * - * matchtype This option will show only the relations (dimension type: DEB and/or CRD). + * matchtype This option will show only the relations (dimension type: DEB and/or CRD). * Usage: $options['matchtype'] = 'relation'; * */ @@ -178,33 +178,33 @@ echo ""; echo "Supplier
"; - echo "BeginPeriod: {$supplier->getBeginPeriod()}
"; // int|null Determines together with beginyear the period from which the dimension may be used. - echo "BeginYear: {$supplier->getBeginYear()}
"; // int|null Determines together with beginperiod the period from which the dimension may be used. - echo "Behaviour: {$supplier->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. - echo "Code: {$supplier->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the CRD Dimension type. - echo "EndPeriod: {$supplier->getEndPeriod()}
"; // int|null Determines together with endyear the period till which the dimension may be used. - echo "EndYear: {$supplier->getEndYear()}
"; // int|null Determines together with endperiod the period till which the dimension may be used. - echo "Group (\\PhpTwinfield\\DimensionGroup):
" . print_r($supplier->getGroup(), true) . "

"; // DimensionGroup|null Sets the dimension group. See Dimension group. - echo "Group (string): " . Util::objectToStr($supplier->getGroup()) . "
"; // string|null - echo "InUse (bool): {$supplier->getInUse()}
"; // bool|null Indicates whether the dimension is used in a financial transaction or not. Read-only attribute. + echo "BeginPeriod: {$supplier->getBeginPeriod()}
"; // int|null Determines together with beginyear the period from which the dimension may be used. + echo "BeginYear: {$supplier->getBeginYear()}
"; // int|null Determines together with beginperiod the period from which the dimension may be used. + echo "Behaviour: {$supplier->getBehaviour()}
"; // Behaviour|null Determines the behaviour of dimensions. Read-only attribute. + echo "Code: {$supplier->getCode()}
"; // string|null Dimension code, must be compliant with the mask of the CRD Dimension type. + echo "EndPeriod: {$supplier->getEndPeriod()}
"; // int|null Determines together with endyear the period till which the dimension may be used. + echo "EndYear: {$supplier->getEndYear()}
"; // int|null Determines together with endperiod the period till which the dimension may be used. + echo "Group (\\PhpTwinfield\\DimensionGroup):
" . print_r($supplier->getGroup(), true) . "

"; // DimensionGroup|null Sets the dimension group. See Dimension group. + echo "Group (string): " . Util::objectToStr($supplier->getGroup()) . "
"; // string|null + echo "InUse (bool): {$supplier->getInUse()}
"; // bool|null Indicates whether the dimension is used in a financial transaction or not. Read-only attribute. echo "InUse (string): " . Util::formatBoolean($supplier->getInUse()) . "
"; // string|null - if ($supplier->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($supplier->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($supplier->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($supplier->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Name: {$supplier->getName()}
"; // string|null Name of the dimension. - echo "Office (\\PhpTwinfield\\Office):
" . print_r($supplier->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): " . Util::objectToStr($supplier->getOffice()) . "
"; // string|null + echo "Name: {$supplier->getName()}
"; // string|null Name of the dimension. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($supplier->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): " . Util::objectToStr($supplier->getOffice()) . "
"; // string|null echo "PaymentCondition:
"; // Sets the payment condition of a dimension. echo "PaymentCondition DiscountDays: {$supplier->getPaymentConditionDiscountDays()}
"; // int|null Number of discount days. echo "PaymentCondition DiscountPercentage: {$supplier->getPaymentConditionDiscountPercentage()}
"; // float|null Discount percentage. echo "RemittanceAdvice:
"; // echo "RemittanceAdvice SendMail: {$supplier->getRemittanceAdviceSendMail()}
"; // string|null Mandatory if sendtype = ByEmail, remittance advice will be sent using this e-mail address. echo "RemittanceAdvice SendType: {$supplier->getRemittanceAdviceSendType()}
"; // RemittanceAdviceSendType|null To file manager, By e-mail - echo "Result: {$supplier->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "ShortName: {$supplier->getShortName()}
"; // string|null Short name of the dimension. - echo "Status: {$supplier->getStatus()}
"; // Status|null Status of the supplier. + echo "Result: {$supplier->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$supplier->getShortName()}
"; // string|null Short name of the dimension. + echo "Status: {$supplier->getStatus()}
"; // Status|null Status of the supplier. echo "Touched: {$supplier->getTouched()}
"; // int|null Count of the number of times the dimension settings are changed. Read-only attribute. echo "Type (\\PhpTwinfield\\DimensionType):
" . print_r($supplier->getType(), true) . "

"; // DimensionType|null Dimension type. See Dimension type. Dimension type of suppliers is CRD. echo "Type (string): " . Util::objectToStr($supplier->getType()) . "
"; // string|null @@ -217,7 +217,7 @@ echo "SupplierAddress {$key}
"; echo "City: {$supplierAddress->getCity()}
"; // string|null City. - echo "Country (\\PhpTwinfield\\Country):
" . print_r($supplierAddress->getCountry(), true) . "

"; // Country|null Country code. The ISO country codes are used. + echo "Country (\\PhpTwinfield\\Country):
" . print_r($supplierAddress->getCountry(), true) . "

"; // Country|null Country code. The ISO country codes are used. echo "Country (string): " . Util::objectToStr($supplierAddress->getCountry()) . "
"; // string|null echo "Default (bool): {$supplierAddress->getDefault()}
"; // bool|null Is this the default address, only one default address is possible. echo "Default (string): " . Util::formatBoolean($supplierAddress->getDefault()) . "
"; // string|null @@ -230,15 +230,15 @@ echo "Field6: {$supplierAddress->getField6()}
"; // string|null User defined fields, the labels are configured in the Dimension type. echo "ID: {$supplierAddress->getID()}
"; // int|null Sequence number of the address line. - if ($supplierAddress->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($supplierAddress->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($supplierAddress->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($supplierAddress->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Name: {$supplierAddress->getName()}
"; // string|null Company name. + echo "Name: {$supplierAddress->getName()}
"; // string|null Company name. echo "Postcode: {$supplierAddress->getPostcode()}
"; // string|null Postcode. echo "Result: {$supplierAddress->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "Telefax: {$supplierAddress->getTelefax()}
"; // string|null Fax number. - echo "Telephone: {$supplierAddress->getTelephone()}
"; // string|null Telephone number. + echo "Telefax: {$supplierAddress->getTelefax()}
"; // string|null Fax number. + echo "Telephone: {$supplierAddress->getTelephone()}
"; // string|null Telephone number. echo "Type: {$supplierAddress->getType()}
"; // AddressType|null The type of the address. } @@ -257,34 +257,34 @@ echo "Blocked (bool): {$supplierBank->getBlocked()}
"; // bool|null echo "Blocked (string): " . Util::formatBoolean($supplierBank->getBlocked()) . "
"; // string|null echo "City: {$supplierBank->getCity()}
"; // string|null City. - echo "Country (\\PhpTwinfield\\Country):
" . print_r($supplierBank->getCountry(), true) . "

"; // Country|null Bank country code. The ISO country codes are used. + echo "Country (\\PhpTwinfield\\Country):
" . print_r($supplierBank->getCountry(), true) . "

"; // Country|null Bank country code. The ISO country codes are used. echo "Country (string): " . Util::objectToStr($supplierBank->getCountry()) . "
"; // string|null echo "Default (bool): {$supplierBank->getDefault()}
"; // bool|null Is this the default bank account, only one default bank account is possible. echo "Default (string): " . Util::formatBoolean($supplierBank->getDefault()) . "
"; // string|null echo "ID: {$supplierBank->getID()}
"; // int|null Sequence number of the bank account line. When adding a new bank, do not supply the @id. When changing a bank account, supply the corresponding @id. echo "IBAN: {$supplierBank->getIban()}
"; // string|null IBAN account number. - if ($supplierBank->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($supplierBank->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($supplierBank->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($supplierBank->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "NatBicCode: {$supplierBank->getNatBicCode()}
"; // string|null National bank code. + echo "NatBicCode: {$supplierBank->getNatBicCode()}
"; // string|null National bank code. echo "Postcode: {$supplierBank->getPostcode()}
"; // string|null Postcode. echo "Result: {$supplierBank->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "State: {$supplierBank->getState()}
"; // string|null State. + echo "State: {$supplierBank->getState()}
"; // string|null State. } echo "SupplierFinancials
"; - $supplierFinancials = $supplier->getFinancials(); // SupplierFinancials|null SupplierFinancials object. + $supplierFinancials = $supplier->getFinancials(); // SupplierFinancials|null SupplierFinancials object. echo "AccountType: {$supplierFinancials->getAccountType()}
"; // AccountType|null Fixed value inherit. echo "DueDays: {$supplierFinancials->getDueDays()}
"; // int|null The number of due days. - echo "Level: {$supplierFinancials->getLevel()}
"; // int|null Specifies the dimension level. Normally the level of suppliers is level 2. Read-only attribute. + echo "Level: {$supplierFinancials->getLevel()}
"; // int|null Specifies the dimension level. Normally the level of suppliers is level 2. Read-only attribute. echo "MatchType: {$supplierFinancials->getMatchType()}
"; // MatchType|null Fixed value customersupplier. echo "MeansOfPayment: {$supplierFinancials->getMeansOfPayment()}
"; // MeansOfPayment|null The option none is only allowed in case payavailable is set to false. The option paymentfile is only allowed in case payavailable is set to true. - if ($supplierFinancials->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($supplierFinancials->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($supplierFinancials->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($supplierFinancials->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "PayAvailable (bool): {$supplierFinancials->getPayAvailable()}
"; // bool|null Determines if direct debit is possible. @@ -312,8 +312,8 @@ echo "ElementValue: {$supplierChildValidation->getElementValue()}
"; // string|null echo "Level: {$supplierChildValidation->getLevel()}
"; // int|null - if ($supplierChildValidation->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($supplierChildValidation->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($supplierChildValidation->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($supplierChildValidation->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "Result: {$supplierChildValidation->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). @@ -332,12 +332,12 @@ echo "Description: {$supplierPostingRule->getDescription()}
"; // string|null Description. echo "ID: {$supplierPostingRule->getID()}
"; // int|null Sequence number of the posting rule. Fixed value 1. - if ($supplierPostingRule->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($supplierPostingRule->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($supplierPostingRule->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($supplierPostingRule->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "Result: {$supplierPostingRule->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "Status: {$supplierPostingRule->getStatus()}
"; // Status|null Status of the posting rule. + echo "Status: {$supplierPostingRule->getStatus()}
"; // Status|null Status of the posting rule. $supplierLines = $supplierPostingRule->getLines(); // array|null Array of SupplierLine objects. @@ -355,11 +355,11 @@ echo "Dimension3 (string): " . Util::objectToStr($supplierLine->getDimension3()) . "
"; // string|null echo "Dimension3ID: {$supplierLine->getDimension3ID()}
"; // string|null - if ($supplierLine->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($supplierLine->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($supplierLine->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($supplierLine->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Office (\\PhpTwinfield\\Office):
" . print_r($supplierLine->getOffice(), true) . "

"; // Office|null Destination company. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($supplierLine->getOffice(), true) . "

"; // Office|null Destination company. echo "Office (string): " . Util::objectToStr($supplierLine->getOffice()) . "
"; // string|null echo "Ratio: {$supplierLine->getRatio()}
"; // float|null The ratio of the posting rule line. echo "Result: {$supplierLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). @@ -459,7 +459,7 @@ $country->setCode('NL'); $supplierAddress->setCountry($country); // Country|null Country code. The ISO country codes are used. $supplierAddress->setCountry(\PhpTwinfield\Country::fromCode('NL')); // string|null - $supplierAddress->setDefault(true); // bool|null Is this the default address, only one default address is possible. + $supplierAddress->setDefault(true); // bool|null Is this the default address, only one default address is possible. $supplierAddress->setEmail('test@example.com'); // string|null $supplierAddress->setField1(''); // string|null User defined fields, the labels are configured in the Dimension type. $supplierAddress->setField2(''); // string|null User defined fields, the labels are configured in the Dimension type. diff --git a/examples/User.php b/examples/User.php index 27663cac..06503522 100644 --- a/examples/User.php +++ b/examples/User.php @@ -53,7 +53,7 @@ * office Sets the office code. * Usage: $options['office'] = 'SomeOfficeCode'; * - * accessrules Disabling the access rules is only possible if the user has access to user management. + * accessrules Disabling the access rules is only possible if the user has access to user management. * Available values: 0 = false, 1 = true * Usage: $options['accessrules'] = 0; * @@ -123,44 +123,44 @@ echo "User
"; echo "AcceptExtraCost (bool): {$user->getAcceptExtraCost()}
"; // bool|null Are extra costs accepted when changing the role (subscription) of the user. echo "AcceptExtraCost (string): " . Util::formatBoolean($user->getAcceptExtraCost()) . "
"; // string|null - echo "Code: {$user->getCode()}
"; // string|null Code of the user. - echo "Created (\\DateTimeInterface):
" . print_r($user->getCreated(), true) . "

"; // DateTimeInterface|null The date/time the user was created. Read-only attribute. + echo "Code: {$user->getCode()}
"; // string|null Code of the user. + echo "Created (\\DateTimeInterface):
" . print_r($user->getCreated(), true) . "

"; // DateTimeInterface|null The date/time the user was created. Read-only attribute. echo "Created (string): " . Util::formatDateTime($user->getCreated()) . "
"; // string|null - echo "Culture: {$user->getCulture()}
"; // Culture|null The culture in which Twinfield is shown. - echo "CultureName: {$user->getCultureName()}
"; // string|null - echo "CultureNativeName: {$user->getCultureNativeName()}
"; // string|null - echo "Demo (bool): {$user->getDemo()}
"; // bool|null Indicates whether the user will be used only for training purposes. Only available when type is equal to Client of accountant. + echo "Culture: {$user->getCulture()}
"; // Culture|null The culture in which Twinfield is shown. + echo "CultureName: {$user->getCultureName()}
"; // string|null + echo "CultureNativeName: {$user->getCultureNativeName()}
"; // string|null + echo "Demo (bool): {$user->getDemo()}
"; // bool|null Indicates whether the user will be used only for training purposes. Only available when type is equal to Client of accountant. echo "Demo (string): " . Util::formatBoolean($user->getDemo()) . "
"; // string|null - echo "DemoLocked (bool): {$user->getDemoLocked()}
"; // bool|null + echo "DemoLocked (bool): {$user->getDemoLocked()}
"; // bool|null echo "DemoLocked (string): " . Util::formatBoolean($user->getDemoLocked()) . "
"; // string|null - echo "Email: {$user->getEmail()}
"; // string|null The user’s email address. - echo "ExchangeQuota: {$user->getExchangeQuota()}
"; // int|null Twinfield Analysis quota. - echo "ExchangeQuotaLocked (bool): {$user->getExchangeQuotaLocked()}
"; // bool|null + echo "Email: {$user->getEmail()}
"; // string|null The user’s email address. + echo "ExchangeQuota: {$user->getExchangeQuota()}
"; // int|null Twinfield Analysis quota. + echo "ExchangeQuotaLocked (bool): {$user->getExchangeQuotaLocked()}
"; // bool|null echo "ExchangeQuotaLocked (string): " . Util::formatBoolean($user->getExchangeQuotaLocked()) . "
"; // string|null echo "FileManagerQuota: {$user->getFileManagerQuota()}
"; // int|null File Manager quota. - echo "FileManagerQuotaLocked (bool): {$user->getFileManagerQuotaLocked()}
"; // bool|null + echo "FileManagerQuotaLocked (bool): {$user->getFileManagerQuotaLocked()}
"; // bool|null echo "FileManagerQuotaLocked (string): " . Util::formatBoolean($user->getFileManagerQuotaLocked()) . "
"; // string|null - echo "IsCurrentUser (bool): {$user->getIsCurrentUser()}
"; // bool|null + echo "IsCurrentUser (bool): {$user->getIsCurrentUser()}
"; // bool|null echo "IsCurrentUser (string): " . Util::formatBoolean($user->getIsCurrentUser()) . "
"; // string|null echo "Level: {$user->getLevel()}
"; // int|null - if ($user->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($user->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($user->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($user->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Modified (\\DateTimeInterface):
" . print_r($user->getModified(), true) . "

"; // DateTimeInterface|null The last date/time the user was modified. Read-only attribute. + echo "Modified (\\DateTimeInterface):
" . print_r($user->getModified(), true) . "

"; // DateTimeInterface|null The last date/time the user was modified. Read-only attribute. echo "Modified (string): " . Util::formatDateTime($user->getModified()) . "
"; // string|null - echo "Name: {$user->getName()}
"; // string|null The name of the user. - echo "Password: {$user->getPassword()}
"; // string|null The password for the user. - echo "Result: {$user->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "Role (\\PhpTwinfield\\UserRole):
" . print_r($user->getRole(), true) . "

"; // UserRole|null The role the user is linked to. + echo "Name: {$user->getName()}
"; // string|null The name of the user. + echo "Password: {$user->getPassword()}
"; // string|null The password for the user. + echo "Result: {$user->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "Role (\\PhpTwinfield\\UserRole):
" . print_r($user->getRole(), true) . "

"; // UserRole|null The role the user is linked to. echo "Role (string): " . Util::objectToStr($user->getRole()) . "
"; // string|null - echo "RoleLocked (bool): {$user->getRoleLocked()}
"; // bool|null + echo "RoleLocked (bool): {$user->getRoleLocked()}
"; // bool|null echo "RoleLocked (string): " . Util::formatBoolean($user->getRoleLocked()) . "
"; // string|null - echo "ShortName: {$user->getShortName()}
"; // string|null The short name of the user. - echo "Status: {$user->getStatus()}
"; // Status|null For creating and updating status may be left empty. For deleting deleted should be used. In case a user that is used in a transaction is deleted, its status has been changed into hide. Hidden users can be activated by using active. - echo "Touched: {$user->getTouched()}
"; // int|null Count of the number of times the user settings are changed. Read-only attribute. - echo "Type: {$user->getType()}
"; // UserType|null User type, will be validated with the office type. Use regular in case of a non-accountancy organisation. - echo "TypeLocked (bool): {$user->getTypeLocked()}
"; // bool|null + echo "ShortName: {$user->getShortName()}
"; // string|null The short name of the user. + echo "Status: {$user->getStatus()}
"; // Status|null For creating and updating status may be left empty. For deleting deleted should be used. In case a user that is used in a transaction is deleted, its status has been changed into hide. Hidden users can be activated by using active. + echo "Touched: {$user->getTouched()}
"; // int|null Count of the number of times the user settings are changed. Read-only attribute. + echo "Type: {$user->getType()}
"; // UserType|null User type, will be validated with the office type. Use regular in case of a non-accountancy organisation. + echo "TypeLocked (bool): {$user->getTypeLocked()}
"; // bool|null echo "TypeLocked (string): " . Util::formatBoolean($user->getTypeLocked()) . "
"; // string|null } \ No newline at end of file diff --git a/examples/VatCode.php b/examples/VatCode.php index 48f6a4e1..66386ae4 100644 --- a/examples/VatCode.php +++ b/examples/VatCode.php @@ -129,55 +129,55 @@ echo ""; echo "VatCode
"; - echo "Code: {$vatCode->getCode()}
"; // string|null VAT code. - echo "Created (\\DateTimeInterface):
" . print_r($vatCode->getCreated(), true) . "

"; // \DateTimeInterface|null The date/time the VAT code was created. Read-only attribute. - echo "Created (string): " . Util::formatDate($vatCode->getCreated()) . "
"; // string|null + echo "Code: {$vatCode->getCode()}
"; // string|null VAT code. + echo "Created (\\DateTimeInterface):
" . print_r($vatCode->getCreated(), true) . "

"; // \DateTimeInterface|null The date/time the VAT code was created. Read-only attribute. + echo "Created (string): " . Util::formatDate($vatCode->getCreated()) . "
"; // string|null - if ($vatCode->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($vatCode->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($vatCode->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($vatCode->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Modified (\\DateTimeInterface):
" . print_r($vatCode->getModified(), true) . "

"; // \DateTimeInterface|null The most recent date/time the VAT code was modified. Read-only attribute. - echo "Modified (string): " . Util::formatDate($vatCode->getModified()) . "
"; // string|null - echo "Name: {$vatCode->getName()}
"; // string|null Name of the VAT. - echo "Office (\\PhpTwinfield\\Office):
" . print_r($vatCode->getOffice(), true) . "

"; // Office|null Office code. + echo "Modified (\\DateTimeInterface):
" . print_r($vatCode->getModified(), true) . "

"; // \DateTimeInterface|null The most recent date/time the VAT code was modified. Read-only attribute. + echo "Modified (string): " . Util::formatDate($vatCode->getModified()) . "
"; // string|null + echo "Name: {$vatCode->getName()}
"; // string|null Name of the VAT. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($vatCode->getOffice(), true) . "

"; // Office|null Office code. echo "Office (string): " . Util::objectToStr($vatCode->getOffice()) . "
"; // string|null - echo "Result: {$vatCode->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "ShortName: {$vatCode->getShortName()}
"; // string|null Short name of the VAT. - echo "Status: {$vatCode->getStatus()}
"; // Status|null Status of the VAT. - echo "Touched: {$vatCode->getTouched()}
"; // int|null The number of times the VAT code is modified. Read-only attribute. - echo "Type: {$vatCode->getType()}
"; // VatType|null The VAT type. - echo "UID: {$vatCode->getUID()}
"; // string|null Unique identification of the VAT code. Read-only attribute. - echo "User (\\PhpTwinfield\\User):
" . print_r($vatCode->getUser(), true) . "

"; // User|null The code of the user who created or modified the VAT code. Read-only attribute. - echo "User (string): " . Util::objectToStr($vatCode->getUser()) . "
"; // string|null + echo "Result: {$vatCode->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$vatCode->getShortName()}
"; // string|null Short name of the VAT. + echo "Status: {$vatCode->getStatus()}
"; // Status|null Status of the VAT. + echo "Touched: {$vatCode->getTouched()}
"; // int|null The number of times the VAT code is modified. Read-only attribute. + echo "Type: {$vatCode->getType()}
"; // VatType|null The VAT type. + echo "UID: {$vatCode->getUID()}
"; // string|null Unique identification of the VAT code. Read-only attribute. + echo "User (\\PhpTwinfield\\User):
" . print_r($vatCode->getUser(), true) . "

"; // User|null The code of the user who created or modified the VAT code. Read-only attribute. + echo "User (string): " . Util::objectToStr($vatCode->getUser()) . "
"; // string|null - $vatCodePercentages = $vatCode->getPercentages(); // Array|null Array of VatCodePercentage objects. + $vatCodePercentages = $vatCode->getPercentages(); // Array|null Array of VatCodePercentage objects. foreach ($vatCodePercentages as $key => $vatCodePercentage) { echo "VatCodePercentage {$key}
"; - if ($vatCodePercentage->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($vatCodePercentage->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($vatCodePercentage->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($vatCodePercentage->getMessages(), true) . "
"; // Array|null (Error) messages. } - echo "Created (\\DateTimeInterface):
" . print_r($vatCodePercentage->getCreated(), true) . "

"; // \DateTimeInterface|null The date/time the VAT line was created. Read-only attribute. - echo "Created (string): " . Util::formatDate($vatCodePercentage->getCreated()) . "
"; // string|null - echo "Date (\\DateTimeInterface):
" . print_r($vatCodePercentage->getDate(), true) . "

"; // \DateTimeInterface|null Effective date. - echo "Date (string): " . Util::formatDate($vatCodePercentage->getDate()) . "
"; // string|null - echo "Name: {$vatCodePercentage->getName()}
"; // string|null Name of the VAT line. - echo "Percentage: {$vatCodePercentage->getPercentage()}
"; // float|null Percentage of the VAT line. - echo "Result: {$vatCodePercentage->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). - echo "ShortName: {$vatCodePercentage->getShortName()}
"; // string|null Short name of the VAT line. - echo "User (\\PhpTwinfield\\User):
" . print_r($vatCodePercentage->getUser(), true) . "

"; // User|null The code of the user who created or modified the VAT line. Read-only attribute. - echo "User (string): " . Util::objectToStr($vatCodePercentage->getUser()) . "
"; // string|null + echo "Created (\\DateTimeInterface):
" . print_r($vatCodePercentage->getCreated(), true) . "

"; // \DateTimeInterface|null The date/time the VAT line was created. Read-only attribute. + echo "Created (string): " . Util::formatDate($vatCodePercentage->getCreated()) . "
"; // string|null + echo "Date (\\DateTimeInterface):
" . print_r($vatCodePercentage->getDate(), true) . "

"; // \DateTimeInterface|null Effective date. + echo "Date (string): " . Util::formatDate($vatCodePercentage->getDate()) . "
"; // string|null + echo "Name: {$vatCodePercentage->getName()}
"; // string|null Name of the VAT line. + echo "Percentage: {$vatCodePercentage->getPercentage()}
"; // float|null Percentage of the VAT line. + echo "Result: {$vatCodePercentage->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "ShortName: {$vatCodePercentage->getShortName()}
"; // string|null Short name of the VAT line. + echo "User (\\PhpTwinfield\\User):
" . print_r($vatCodePercentage->getUser(), true) . "

"; // User|null The code of the user who created or modified the VAT line. Read-only attribute. + echo "User (string): " . Util::objectToStr($vatCodePercentage->getUser()) . "
"; // string|null - $vatCodeAccounts = $vatCodePercentage->getAccounts(); // Array|null Array of VatCodeAccount objects. + $vatCodeAccounts = $vatCodePercentage->getAccounts(); // Array|null Array of VatCodeAccount objects. foreach ($vatCodeAccounts as $key => $vatCodeAccount) { echo "VatCodeAccount {$key}
"; - if ($vatCodeAccount->hasMessages()) { // bool Object contains (error) messages true/false. - echo "Messages: " . print_r($vatCodeAccount->getMessages(), true) . "
"; // Array|null (Error) messages. + if ($vatCodeAccount->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($vatCodeAccount->getMessages(), true) . "
"; // Array|null (Error) messages. } echo "Dim1 (\\PhpTwinfield\\GeneralLedger):
" . print_r($vatCodeAccount->getDim1(), true) . "

"; // GeneralLedger|null General ledger account on which the VAT amount will be posted. @@ -186,7 +186,7 @@ echo "Group (string): " . Util::objectToStr($vatCodeAccount->getGroup()) . "
"; // string|null echo "GroupCountry (\\PhpTwinfield\\VatGroupCountry):
" . print_r($vatCodeAccount->getGroupCountry(), true) . "

"; // VatGroupCountry|null Country code of the VAT group. echo "GroupCountry (string): " . Util::objectToStr($vatCodeAccount->getGroupCountry()) . "
"; // string|null - echo "ID: {$vatCodeAccount->getID()}
"; // int|null Line ID. + echo "ID: {$vatCodeAccount->getID()}
"; // int|null Line ID. echo "LineType: {$vatCodeAccount->getLineType()}
"; // LineType|null Is it a vat line or not detail. Use detail in case a part of the calculated vat value should be posted on a different general ledger account. echo "Percentage: {$vatCodeAccount->getPercentage()}
"; // float|null The VAT percentage. echo "Result: {$vatCodeAccount->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). From 1f23450198670a9dfbb6541f5c850071cb6b8e57 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 28 Jun 2019 12:23:59 +0200 Subject: [PATCH 366/388] Upload --- examples/VatCode.php | 9 +++- readme.md | 2 +- src/ApiConnectors/BaseApiConnector.php | 42 ++++++++++++++++ src/ApiConnectors/RateApiConnector.php | 58 ++++++++++++++++++++++- src/ApiConnectors/VatCodeApiConnector.php | 58 ++++++++++++++++++++++- src/DomDocuments/ArticlesDocument.php | 2 +- src/DomDocuments/InvoicesDocument.php | 2 +- src/DomDocuments/VatCodesDocument.php | 6 +++ src/Fields/InUseField.php | 2 +- src/Mappers/VatCodeMapper.php | 12 ++++- src/VatCodePercentage.php | 14 ++++-- 11 files changed, 191 insertions(+), 16 deletions(-) diff --git a/examples/VatCode.php b/examples/VatCode.php index 66386ae4..93dcb16b 100644 --- a/examples/VatCode.php +++ b/examples/VatCode.php @@ -98,8 +98,8 @@ /* VatCodePercentage * \PhpTwinfield\VatCodePercentage - * Available getters: getCreated, getDate, getMessages, getName, getPercentage, getResult, getShortName, getUser, hasMessages, getAccounts - * Available setters: setDate, setName, setPercentage, setShortName, addAccount, removeAccount + * Available getters: getCreated, getDate, getInUse, getMessages, getName, getPercentage, getResult, getShortName, getStatus, getUser, hasMessages, getAccounts + * Available setters: setDate, setName, setPercentage, setShortName, setStatus, addAccount, removeAccount */ /* VatCodeAccount @@ -164,10 +164,13 @@ echo "Created (string): " . Util::formatDate($vatCodePercentage->getCreated()) . "
"; // string|null echo "Date (\\DateTimeInterface):
" . print_r($vatCodePercentage->getDate(), true) . "

"; // \DateTimeInterface|null Effective date. echo "Date (string): " . Util::formatDate($vatCodePercentage->getDate()) . "
"; // string|null + echo "InUse (bool):
" . print_r($vatCodePercentage->getInUse(), true) . "

"; // bool|null + echo "InUse (string): " . Util::formatBoolean($vatCodePercentage->getInUse() . "
"; // string|null echo "Name: {$vatCodePercentage->getName()}
"; // string|null Name of the VAT line. echo "Percentage: {$vatCodePercentage->getPercentage()}
"; // float|null Percentage of the VAT line. echo "Result: {$vatCodePercentage->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "ShortName: {$vatCodePercentage->getShortName()}
"; // string|null Short name of the VAT line. + echo "Status: {$vatCodePercentage->getStatus()}
"; // Status|null Status of the percentage. echo "User (\\PhpTwinfield\\User):
" . print_r($vatCodePercentage->getUser(), true) . "

"; // User|null The code of the user who created or modified the VAT line. Read-only attribute. echo "User (string): " . Util::objectToStr($vatCodePercentage->getUser()) . "
"; // string|null @@ -244,6 +247,8 @@ $vatCodePercentage->setName("BTW 21%"); // string|null Name of the VAT line. $vatCodePercentage->setPercentage(21); // float|null Percentage of the VAT line. $vatCodePercentage->setShortName("VH 21%"); // string|null Short name of the VAT line. + $vatCodePercentage->setStatus(\PhpTwinfield\Enums\Status::ACTIVE()); // Status|null For creating and updating active should be used. For deleting deleted should be used. + //$vatCodePercentage->setStatus(\PhpTwinfield\Enums\Status::DELETED()); // Status|null // The minimum amount of VatCodeAccounts linked to a VatCodePercentage object is 1 $vatCodeAccount = new \PhpTwinfield\VatCodeAccount; diff --git a/readme.md b/readme.md index 5c76c6e0..40aeed4e 100644 --- a/readme.md +++ b/readme.md @@ -40,7 +40,7 @@ support for another resource. | [Customers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Customer](examples/Customer.php) | | [Dimension Groups](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionGroups) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Dimension Group](examples/DimensionGroup.php) | | [Dimension Types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/DimensionTypes) | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | [Dimension Type](examples/DimensionType.php) | -| [Electronic Bank Statements](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankStatements) | | :white_check_mark: | | | | | +| [Electronic Bank Statements](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankStatements) | | | :white_check_mark: | | | | | [Fixed Assets](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/FixedAssets) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Fixed Asset](examples/FixedAsset.php) | | [General Ledger Accounts](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/BalanceSheets) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | [General Ledger Account](examples/GeneralLedger.php) | | [Matching](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Miscellaneous/Matching) | | | :white_check_mark: | | :white_check_mark: | | diff --git a/src/ApiConnectors/BaseApiConnector.php b/src/ApiConnectors/BaseApiConnector.php index c007426a..f89cdbd9 100644 --- a/src/ApiConnectors/BaseApiConnector.php +++ b/src/ApiConnectors/BaseApiConnector.php @@ -4,7 +4,9 @@ use PhpTwinfield\Enums\Services; use PhpTwinfield\Exception; +use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; +use PhpTwinfield\Response\ResponseException; use PhpTwinfield\Secure\AuthenticatedConnection; use PhpTwinfield\Services\FinderService; use PhpTwinfield\Services\ProcessXmlService; @@ -240,4 +242,44 @@ public function mapListAll(string $objectClass, $data, array $methodToAttributeM return $objects; } + + /** + * @param array $sentObjects + * @param MappedResponseCollection $mappedResponseCollection + * @return MappedResponseCollection + */ + public function testSentEqualsResponse(array $sentObjects, MappedResponseCollection $mappedResponseCollection): MappedResponseCollection + { + $checkedMappedResponseCollection = new MappedResponseCollection(); + + foreach($mappedResponseCollection as $key => $individualMappedResponse) { + $returnedObject = $individualMappedResponse->unwrap(); + $sentObject = $sentObjects[$key]; + + if ($returnedObject->getResult() == 1) { + $testResult = $this->testEqual($returnedObject, $sentObject); + $equal = $testResult[0]; + $returnedObject = $testResult[1]; + + if ($equal === false) { + $individualMappedResponse = $this->sendAll([$returnedObject], true)[0]; + $returnedObject = $individualMappedResponse->unwrap(); + + if ($returnedObject->getResult() == 1) { + $testResult = $this->testEqual($returnedObject, $sentObject); + $equal = $testResult[0]; + $returnedObject = $testResult[1]; + + if ($equal === false) { + $individualMappedResponse = $this->getMappedResponse($returnedObject); + } + } + } + } + + $checkedMappedResponseCollection->append($individualMappedResponse); + } + + return $checkedMappedResponseCollection; + } } \ No newline at end of file diff --git a/src/ApiConnectors/RateApiConnector.php b/src/ApiConnectors/RateApiConnector.php index d6ac3d22..e7939d30 100644 --- a/src/ApiConnectors/RateApiConnector.php +++ b/src/ApiConnectors/RateApiConnector.php @@ -64,10 +64,11 @@ public function send(Rate $rate): Rate /** * @param Rate[] $rates + * @param bool|null $reSend * @return MappedResponseCollection * @throws Exception */ - public function sendAll(array $rates): MappedResponseCollection + public function sendAll(array $rates, bool $reSend = false): MappedResponseCollection { Assert::allIsInstanceOf($rates, Rate::class); @@ -85,9 +86,62 @@ public function sendAll(array $rates): MappedResponseCollection $responses[] = $this->sendXmlDocument($ratesDocument); } - return $this->getProcessXmlService()->mapAll($responses, "projectrate", function(Response $response): Rate { + $mappedResponseCollection = $this->getProcessXmlService()->mapAll($responses, "projectrate", function(Response $response): Rate { return RateMapper::map($response); }); + + if ($reSend) { + return $mappedResponseCollection; + } + + return self::testSentEqualsResponse($rates, $mappedResponseCollection); + } + + /** + * @param Rate $returnedObject + * @param Rate $returnedObject + * @return array + */ + public function testEqual(Rate $returnedObject, Rate $sentObject): array + { + $equal = true; + $idArray = []; + + $returnedRateChanges = $returnedObject->getRateChanges(); + $sentRateChanges = $sentObject->getRateChanges(); + + foreach ($sentRateChanges as $key => $sentRateChange) { + $idArray[] = $sentRateChange->getID(); + } + + foreach ($returnedRateChanges as $key => $returnedRateChange) { + $id = $returnedRateChange->getID(); + + if (!in_array($id, $idArray)) { + $returnedRateChange->setStatus(\PhpTwinfield\Enums\Status::DELETED()); + $equal = false; + } + } + + return [$equal, $returnedObject]; + } + + /** + * @param Rate $rate + * @return IndividualMappedResponse + */ + public function getMappedResponse(Rate $rate): IndividualMappedResponse + { + $request_rate = new Request\Read\Rate(); + $request_rate->setOffice($rate->getOffice()) + ->setCode($rate->getCode()); + $response = $this->sendXmlDocument($request_rate); + + $mappedResponseCollection = $this->getProcessXmlService()->mapAll([$response], "projectrate", function(Response $response): Rate { + return RateMapper::map($response); + }); + + return ($mappedResponseCollection[0]); } /** diff --git a/src/ApiConnectors/VatCodeApiConnector.php b/src/ApiConnectors/VatCodeApiConnector.php index f7f2e6f4..9e62909d 100644 --- a/src/ApiConnectors/VatCodeApiConnector.php +++ b/src/ApiConnectors/VatCodeApiConnector.php @@ -64,10 +64,11 @@ public function send(VatCode $vatCode): VatCode /** * @param VatCode[] $vatCodes + * @param bool|null $reSend * @return MappedResponseCollection * @throws Exception */ - public function sendAll(array $vatCodes): MappedResponseCollection + public function sendAll(array $vatCodes, bool $reSend = false): MappedResponseCollection { Assert::allIsInstanceOf($vatCodes, VatCode::class); @@ -85,9 +86,62 @@ public function sendAll(array $vatCodes): MappedResponseCollection $responses[] = $this->sendXmlDocument($vatCodesDocument); } - return $this->getProcessXmlService()->mapAll($responses, "vat", function(Response $response): VatCode { + $mappedResponseCollection = $this->getProcessXmlService()->mapAll($responses, "vat", function(Response $response): VatCode { return VatCodeMapper::map($response); }); + + if ($reSend) { + return $mappedResponseCollection; + } + + return self::testSentEqualsResponse($vatCodes, $mappedResponseCollection); + } + + /** + * @param VatCode $returnedObject + * @param VatCode $returnedObject + * @return array + */ + public function testEqual(VatCode $returnedObject, VatCode $sentObject): array + { + $equal = false; + $dateArray = []; + + $returnedPercentages = $returnedObject->getPercentages(); + $sentPercentages = $sentObject->getPercentages(); + + foreach ($sentPercentages as $key => $sentPercentage) { + $dateArray[] = Util::formatDate($sentPercentage->getDate()); + } + + foreach ($returnedPercentages as $key => $returnedPercentage) { + $date = Util::formatDate($returnedPercentage->getDate()); + + if (!in_array($date, $dateArray)) { + $returnedPercentage->setStatus(\PhpTwinfield\Enums\Status::DELETED()); + $equal = true; + } + } + + return [$equal, $returnedObject]; + } + + /** + * @param VatCode $vatCode + * @return IndividualMappedResponse + */ + public function getMappedResponse(VatCode $vatCode): IndividualMappedResponse + { + $request_vatCode = new Request\Read\VatCode(); + $request_vatCode->setOffice($office) + ->setCode($code); + $response = $this->sendXmlDocument($request_vatCode); + + $mappedResponseCollection = $this->getProcessXmlService()->mapAll([$response], "vat", function(Response $response): VatCode { + return VatCodeMapper::map($response); + }); + + return ($mappedResponseCollection[0]); } /** diff --git a/src/DomDocuments/ArticlesDocument.php b/src/DomDocuments/ArticlesDocument.php index 88367196..f7e67836 100644 --- a/src/DomDocuments/ArticlesDocument.php +++ b/src/DomDocuments/ArticlesDocument.php @@ -64,7 +64,7 @@ public function addArticle(Article $article) $headerElement->appendChild($this->createNodeWithTextContent('vatcode', Util::objectToStr($article->getVatCode()))); //Clear VAT code in case of a discount/premium article with percentage set to true to prevent errors - if ($article->getType() != "normal" && $article->getPercentage() == true) { + if ($article->getType() != "normal" && $article->getPercentage()) { $headerElement->getElementsByTagName('vatcode')->item(0)->nodeValue = ""; } diff --git a/src/DomDocuments/InvoicesDocument.php b/src/DomDocuments/InvoicesDocument.php index 4f767f56..7485e949 100644 --- a/src/DomDocuments/InvoicesDocument.php +++ b/src/DomDocuments/InvoicesDocument.php @@ -128,7 +128,7 @@ public function addInvoice(Invoice $invoice, AuthenticatedConnection $connection $article->setAllowChangeVatCode(true); } - if ($article->getAllowChangeVatCode() == true) { + if ($article->getAllowChangeVatCode()) { $lineElement->appendChild($this->createNodeWithTextContent('vatcode', Util::objectToStr($line->getVatCode()))); } } diff --git a/src/DomDocuments/VatCodesDocument.php b/src/DomDocuments/VatCodesDocument.php index 1200eddc..a06e0f33 100644 --- a/src/DomDocuments/VatCodesDocument.php +++ b/src/DomDocuments/VatCodesDocument.php @@ -59,6 +59,12 @@ public function addVatCode(VatCode $vatCode) // Makes percentage element $percentageElement = $this->createElement('percentage'); $percentagesElement->appendChild($percentageElement); + + $status = $percentage->getStatus(); + + if (!empty($status)) { + $percentageElement->setAttribute('status', $status); + } $percentageElement->appendChild($this->createNodeWithTextContent('date', Util::formatDate($percentage->getDate()))); $percentageElement->appendChild($this->createNodeWithTextContent('name', $percentage->getName())); diff --git a/src/Fields/InUseField.php b/src/Fields/InUseField.php index 1654fc14..dbf8ba24 100644 --- a/src/Fields/InUseField.php +++ b/src/Fields/InUseField.php @@ -6,7 +6,7 @@ trait InUseField { /** * In use field - * Used by: Activity, ArticleLine, AssetMethod, CostCenter, Customer, FixedAsset, GeneralLedger, Project, Supplier + * Used by: Activity, ArticleLine, AssetMethod, CostCenter, Customer, FixedAsset, GeneralLedger, Project, Supplier, VatCodePercentage * * @var bool */ diff --git a/src/Mappers/VatCodeMapper.php b/src/Mappers/VatCodeMapper.php index c01c8a29..9cf6d8ef 100644 --- a/src/Mappers/VatCodeMapper.php +++ b/src/Mappers/VatCodeMapper.php @@ -63,6 +63,14 @@ public static function map(Response $response) // Make a new temporary VatCodePercentage class $vatCodePercentage = new VatCodePercentage(); + + if (!empty($percentageElement->getAttribute('inuse'))) { + $vatCodePercentage->setInUse($percentageElement->getAttribute('inuse')); + } + + if (!empty($percentageElement->getAttribute('status'))) { + $vatCodePercentage->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $percentageElement->getAttribute('status'))); + } // Set the vat code percentage elements from the percentage element $vatCodePercentage->setCreated(self::parseDateTimeAttribute(self::getField($percentageElement, 'created', $vatCodePercentage))) @@ -86,7 +94,9 @@ public static function map(Response $response) $vatCodeAccount = new VatCodeAccount(); // Set the ID attribute - $vatCodeAccount->setID($accountElement->getAttribute('id')); + if (!empty($accountElement->getAttribute('id'))) { + $vatCodeAccount->setID($accountElement->getAttribute('id')); + } // Set the vat code percentage account elements from the account element $vatCodeAccount->setDim1(self::parseObjectAttribute(\PhpTwinfield\GeneralLedger::class, $vatCodeAccount, $accountElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) diff --git a/src/VatCodePercentage.php b/src/VatCodePercentage.php index 36cbbb24..59d6b3a4 100644 --- a/src/VatCodePercentage.php +++ b/src/VatCodePercentage.php @@ -4,9 +4,11 @@ use PhpTwinfield\Fields\CreatedField; use PhpTwinfield\Fields\DateField; +use PhpTwinfield\Fields\InUseField; use PhpTwinfield\Fields\NameField; use PhpTwinfield\Fields\PercentageField; use PhpTwinfield\Fields\ShortNameField; +use PhpTwinfield\Fields\StatusField; use PhpTwinfield\Fields\UserField; /** @@ -17,9 +19,11 @@ class VatCodePercentage extends BaseObject { use CreatedField; use DateField; + use InUseField; use PercentageField; use NameField; use ShortNameField; + use StatusField; use UserField; private $accounts = []; @@ -44,22 +48,22 @@ public function removeAccount($index) return false; } } - + public function removeAccountByID($id) { $found = false; - + foreach ($this->accounts as $index => $account) { if ($id == $account->getID()) { unset($this->accounts[$index]); $found = true; } } - + if ($found) { return true; } - + return false; } -} +} \ No newline at end of file From 0ecd76fded56cd231192e6723a797e1cd8ed1139 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 28 Jun 2019 12:52:16 +0200 Subject: [PATCH 367/388] Upload --- src/ApiConnectors/RateApiConnector.php | 1 + src/ApiConnectors/VatCodeApiConnector.php | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ApiConnectors/RateApiConnector.php b/src/ApiConnectors/RateApiConnector.php index e7939d30..d020458d 100644 --- a/src/ApiConnectors/RateApiConnector.php +++ b/src/ApiConnectors/RateApiConnector.php @@ -8,6 +8,7 @@ use PhpTwinfield\Office; use PhpTwinfield\Rate; use PhpTwinfield\Request as Request; +use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; use PhpTwinfield\Response\ResponseException; diff --git a/src/ApiConnectors/VatCodeApiConnector.php b/src/ApiConnectors/VatCodeApiConnector.php index 9e62909d..00e8ee06 100644 --- a/src/ApiConnectors/VatCodeApiConnector.php +++ b/src/ApiConnectors/VatCodeApiConnector.php @@ -7,10 +7,12 @@ use PhpTwinfield\Mappers\VatCodeMapper; use PhpTwinfield\Office; use PhpTwinfield\Request as Request; +use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; use PhpTwinfield\Response\ResponseException; use PhpTwinfield\Services\FinderService; +use PhpTwinfield\Util; use PhpTwinfield\VatCode; use Webmozart\Assert\Assert; @@ -133,8 +135,7 @@ public function testEqual(VatCode $returnedObject, VatCode $sentObject): array public function getMappedResponse(VatCode $vatCode): IndividualMappedResponse { $request_vatCode = new Request\Read\VatCode(); - $request_vatCode->setOffice($office) - ->setCode($code); + $request_vatCode->setCode($vatCode->getCode()); $response = $this->sendXmlDocument($request_vatCode); $mappedResponseCollection = $this->getProcessXmlService()->mapAll([$response], "vat", function(Response $response): VatCode { From 313ccd80852debb08af596c5013a011f6380a022 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 28 Jun 2019 13:09:15 +0200 Subject: [PATCH 368/388] Upload --- src/ApiConnectors/BaseApiConnector.php | 30 +++++++++++++++-------- src/ApiConnectors/RateApiConnector.php | 2 +- src/ApiConnectors/VatCodeApiConnector.php | 2 +- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/ApiConnectors/BaseApiConnector.php b/src/ApiConnectors/BaseApiConnector.php index f89cdbd9..895c9678 100644 --- a/src/ApiConnectors/BaseApiConnector.php +++ b/src/ApiConnectors/BaseApiConnector.php @@ -177,7 +177,7 @@ protected function getFinderService(): FinderService /** * Convert options array to an ArrayOfString which is accepted by Twinfield. - * + * * In some cases you are not allowed to change certain options (such as the dimtype, which should always be DEB when using CustomerApiConnector->ListAll()), * in which case the $forcedOptions parameter will be set by the ApiConnector for this option, which will override any user settings in $options * @@ -190,7 +190,7 @@ public function convertOptionsToArrayOfString(array $options, array $forcedOptio if (isset($options['ArrayOfString'])) { return $options; } - + $optionsArrayOfString = ['ArrayOfString' => []]; foreach ($forcedOptions as $key => $value) { @@ -242,7 +242,17 @@ public function mapListAll(string $objectClass, $data, array $methodToAttributeM return $objects; } - + + /** + * @param HasMessageInterface $returnedObject + * @param HasMessageInterface $returnedObject + * @return array + */ + public function testEqual(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): array + { + return parent::testEqual; + } + /** * @param array $sentObjects * @param MappedResponseCollection $mappedResponseCollection @@ -251,7 +261,7 @@ public function mapListAll(string $objectClass, $data, array $methodToAttributeM public function testSentEqualsResponse(array $sentObjects, MappedResponseCollection $mappedResponseCollection): MappedResponseCollection { $checkedMappedResponseCollection = new MappedResponseCollection(); - + foreach($mappedResponseCollection as $key => $individualMappedResponse) { $returnedObject = $individualMappedResponse->unwrap(); $sentObject = $sentObjects[$key]; @@ -260,26 +270,26 @@ public function testSentEqualsResponse(array $sentObjects, MappedResponseCollect $testResult = $this->testEqual($returnedObject, $sentObject); $equal = $testResult[0]; $returnedObject = $testResult[1]; - + if ($equal === false) { - $individualMappedResponse = $this->sendAll([$returnedObject], true)[0]; + $individualMappedResponse = $this->sendAll([$returnedObject], true)[0]; $returnedObject = $individualMappedResponse->unwrap(); - + if ($returnedObject->getResult() == 1) { $testResult = $this->testEqual($returnedObject, $sentObject); $equal = $testResult[0]; $returnedObject = $testResult[1]; - + if ($equal === false) { $individualMappedResponse = $this->getMappedResponse($returnedObject); } } } } - + $checkedMappedResponseCollection->append($individualMappedResponse); } - + return $checkedMappedResponseCollection; } } \ No newline at end of file diff --git a/src/ApiConnectors/RateApiConnector.php b/src/ApiConnectors/RateApiConnector.php index d020458d..4d6e81d0 100644 --- a/src/ApiConnectors/RateApiConnector.php +++ b/src/ApiConnectors/RateApiConnector.php @@ -100,7 +100,7 @@ public function sendAll(array $rates, bool $reSend = false): MappedResponseColle /** * @param Rate $returnedObject - * @param Rate $returnedObject + * @param Rate $sentObject * @return array */ public function testEqual(Rate $returnedObject, Rate $sentObject): array diff --git a/src/ApiConnectors/VatCodeApiConnector.php b/src/ApiConnectors/VatCodeApiConnector.php index 00e8ee06..e8fff7f0 100644 --- a/src/ApiConnectors/VatCodeApiConnector.php +++ b/src/ApiConnectors/VatCodeApiConnector.php @@ -101,7 +101,7 @@ public function sendAll(array $vatCodes, bool $reSend = false): MappedResponseCo /** * @param VatCode $returnedObject - * @param VatCode $returnedObject + * @param VatCode $sentObject * @return array */ public function testEqual(VatCode $returnedObject, VatCode $sentObject): array From 04511beba202866eeb5a36a4af2a1e9615d91bd1 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 28 Jun 2019 13:44:13 +0200 Subject: [PATCH 369/388] Upload --- src/ApiConnectors/BaseApiConnector.php | 21 ++++++--------------- src/ApiConnectors/HasEqualInterface.php | 20 ++++++++++++++++++++ src/ApiConnectors/RateApiConnector.php | 20 +++++++++++++------- src/ApiConnectors/VatCodeApiConnector.php | 20 +++++++++++++------- 4 files changed, 52 insertions(+), 29 deletions(-) create mode 100644 src/ApiConnectors/HasEqualInterface.php diff --git a/src/ApiConnectors/BaseApiConnector.php b/src/ApiConnectors/BaseApiConnector.php index 895c9678..57fae483 100644 --- a/src/ApiConnectors/BaseApiConnector.php +++ b/src/ApiConnectors/BaseApiConnector.php @@ -244,21 +244,12 @@ public function mapListAll(string $objectClass, $data, array $methodToAttributeM } /** - * @param HasMessageInterface $returnedObject - * @param HasMessageInterface $returnedObject - * @return array - */ - public function testEqual(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): array - { - return parent::testEqual; - } - - /** + * @param HasEqualInterface $apiConnector * @param array $sentObjects * @param MappedResponseCollection $mappedResponseCollection * @return MappedResponseCollection */ - public function testSentEqualsResponse(array $sentObjects, MappedResponseCollection $mappedResponseCollection): MappedResponseCollection + public function testSentEqualsResponse(HasEqualInterface $apiConnector, array $sentObjects, MappedResponseCollection $mappedResponseCollection): MappedResponseCollection { $checkedMappedResponseCollection = new MappedResponseCollection(); @@ -267,21 +258,21 @@ public function testSentEqualsResponse(array $sentObjects, MappedResponseCollect $sentObject = $sentObjects[$key]; if ($returnedObject->getResult() == 1) { - $testResult = $this->testEqual($returnedObject, $sentObject); + $testResult = $apiConnector->testEqual($returnedObject, $sentObject); $equal = $testResult[0]; $returnedObject = $testResult[1]; if ($equal === false) { - $individualMappedResponse = $this->sendAll([$returnedObject], true)[0]; + $individualMappedResponse = $apiConnector->sendAll([$returnedObject], true)[0]; $returnedObject = $individualMappedResponse->unwrap(); if ($returnedObject->getResult() == 1) { - $testResult = $this->testEqual($returnedObject, $sentObject); + $testResult = $apiConnector->testEqual($returnedObject, $sentObject); $equal = $testResult[0]; $returnedObject = $testResult[1]; if ($equal === false) { - $individualMappedResponse = $this->getMappedResponse($returnedObject); + $individualMappedResponse = $apiConnector->getMappedResponse($returnedObject); } } } diff --git a/src/ApiConnectors/HasEqualInterface.php b/src/ApiConnectors/HasEqualInterface.php new file mode 100644 index 00000000..de5bf60f --- /dev/null +++ b/src/ApiConnectors/HasEqualInterface.php @@ -0,0 +1,20 @@ + */ -class RateApiConnector extends BaseApiConnector +class RateApiConnector extends BaseApiConnector implements HasEqualInterface { /** * Requests a specific Rate based off the passed in code and optionally the office. @@ -95,16 +96,19 @@ public function sendAll(array $rates, bool $reSend = false): MappedResponseColle return $mappedResponseCollection; } - return self::testSentEqualsResponse($rates, $mappedResponseCollection); + return self::testSentEqualsResponse($this, $rates, $mappedResponseCollection); } /** - * @param Rate $returnedObject - * @param Rate $sentObject + * @param HasMessageInterface $returnedObject + * @param HasMessageInterface $sentObject * @return array */ - public function testEqual(Rate $returnedObject, Rate $sentObject): array + public function testEqual(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): array { + Assert::IsInstanceOf($returnedObject, Rate::class); + Assert::IsInstanceOf($sentObject, Rate::class); + $equal = true; $idArray = []; @@ -128,11 +132,13 @@ public function testEqual(Rate $returnedObject, Rate $sentObject): array } /** - * @param Rate $rate + * @param HasMessageInterface $rate * @return IndividualMappedResponse */ - public function getMappedResponse(Rate $rate): IndividualMappedResponse + public function getMappedResponse(HasMessageInterface $rate): IndividualMappedResponse { + Assert::IsInstanceOf($rate, Rate::class); + $request_rate = new Request\Read\Rate(); $request_rate->setOffice($rate->getOffice()) ->setCode($rate->getCode()); diff --git a/src/ApiConnectors/VatCodeApiConnector.php b/src/ApiConnectors/VatCodeApiConnector.php index e8fff7f0..19b728f6 100644 --- a/src/ApiConnectors/VatCodeApiConnector.php +++ b/src/ApiConnectors/VatCodeApiConnector.php @@ -4,6 +4,7 @@ use PhpTwinfield\DomDocuments\VatCodesDocument; use PhpTwinfield\Exception; +use PhpTwinfield\HasMessageInterface; use PhpTwinfield\Mappers\VatCodeMapper; use PhpTwinfield\Office; use PhpTwinfield\Request as Request; @@ -25,7 +26,7 @@ * * @author Emile Bons , extended by Yannick Aerssens */ -class VatCodeApiConnector extends BaseApiConnector +class VatCodeApiConnector extends BaseApiConnector implements HasEqualInterface { /** * Requests a specific VatCode based off the passed in code and optionally the office. @@ -96,16 +97,19 @@ public function sendAll(array $vatCodes, bool $reSend = false): MappedResponseCo return $mappedResponseCollection; } - return self::testSentEqualsResponse($vatCodes, $mappedResponseCollection); + return self::testSentEqualsResponse($this, $vatCodes, $mappedResponseCollection); } /** - * @param VatCode $returnedObject - * @param VatCode $sentObject + * @param HasMessageInterface $returnedObject + * @param HasMessageInterface $sentObject * @return array */ - public function testEqual(VatCode $returnedObject, VatCode $sentObject): array + public function testEqual(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): array { + Assert::IsInstanceOf($returnedObject, VatCode::class); + Assert::IsInstanceOf($sentObject, VatCode::class); + $equal = false; $dateArray = []; @@ -129,11 +133,13 @@ public function testEqual(VatCode $returnedObject, VatCode $sentObject): array } /** - * @param VatCode $vatCode + * @param HasMessageInterface $vatCode * @return IndividualMappedResponse */ - public function getMappedResponse(VatCode $vatCode): IndividualMappedResponse + public function getMappedResponse(HasMessageInterface $vatCode): IndividualMappedResponse { + Assert::IsInstanceOf($vatCode, VatCode::class); + $request_vatCode = new Request\Read\VatCode(); $request_vatCode->setCode($vatCode->getCode()); $response = $this->sendXmlDocument($request_vatCode); From 0de6e156858509c59418b212986f0ec4809b8234 Mon Sep 17 00:00:00 2001 From: iranl Date: Fri, 28 Jun 2019 13:53:47 +0200 Subject: [PATCH 370/388] Update RateApiConnectorTest.php --- tests/UnitTests/ApiConnectors/RateApiConnectorTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/UnitTests/ApiConnectors/RateApiConnectorTest.php b/tests/UnitTests/ApiConnectors/RateApiConnectorTest.php index fc1025b0..c1e01007 100644 --- a/tests/UnitTests/ApiConnectors/RateApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/RateApiConnectorTest.php @@ -4,6 +4,7 @@ use PhpTwinfield\ApiConnectors\RateApiConnector; use PhpTwinfield\Rate; +use PhpTwinfield\RateRateChange; use PhpTwinfield\Response\Response; use PhpTwinfield\Secure\AuthenticatedConnection; use PhpTwinfield\Services\ProcessXmlService; @@ -43,6 +44,9 @@ protected function setUp() private function createRate(): Rate { $rate = new Rate(); + $rateChange = new RateRateChange(); + $rateChange->setID(2); + $rate->addRateChange($rateChange); return $rate; } From 73461aaf82047d3aa061d6fcdb49eeef2973d624 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 29 Jun 2019 10:55:23 +0200 Subject: [PATCH 371/388] Upload --- src/ApiConnectors/ArticleApiConnector.php | 67 ++++++++++++++++++++++- src/ApiConnectors/BaseApiConnector.php | 4 +- src/Article.php | 2 + 3 files changed, 68 insertions(+), 5 deletions(-) diff --git a/src/ApiConnectors/ArticleApiConnector.php b/src/ApiConnectors/ArticleApiConnector.php index 8cf1247b..41a3ae22 100644 --- a/src/ApiConnectors/ArticleApiConnector.php +++ b/src/ApiConnectors/ArticleApiConnector.php @@ -5,9 +5,11 @@ use PhpTwinfield\Article; use PhpTwinfield\DomDocuments\ArticlesDocument; use PhpTwinfield\Exception; +use PhpTwinfield\HasMessageInterface; use PhpTwinfield\Mappers\ArticleMapper; use PhpTwinfield\Office; use PhpTwinfield\Request as Request; +use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; use PhpTwinfield\Response\ResponseException; @@ -23,7 +25,7 @@ * * @author Willem van de Sande , extended by Yannick Aerssens */ -class ArticleApiConnector extends BaseApiConnector +class ArticleApiConnector extends BaseApiConnector implements HasEqualInterface { /** * Requests a specific Article based off the passed in code and optionally the office. @@ -64,10 +66,11 @@ public function send(Article $article): Article /** * @param Article[] $articles + * @param bool|null $reSend * @return MappedResponseCollection * @throws Exception */ - public function sendAll(array $articles): MappedResponseCollection + public function sendAll(array $articles, bool $reSend = false): MappedResponseCollection { Assert::allIsInstanceOf($articles, Article::class); @@ -84,9 +87,67 @@ public function sendAll(array $articles): MappedResponseCollection $responses[] = $this->sendXmlDocument($articlesDocument); } - return $this->getProcessXmlService()->mapAll($responses, "article", function(Response $response): Article { + $mappedResponseCollection = $this->getProcessXmlService()->mapAll($responses, "article", function(Response $response): Article { return ArticleMapper::map($response, $this->getConnection()); }); + + if ($reSend) { + return $mappedResponseCollection; + } + + return self::testSentEqualsResponse($this, $articles, $mappedResponseCollection); + } + + /** + * @param HasMessageInterface $returnedObject + * @param HasMessageInterface $sentObject + * @return array + */ + public function testEqual(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): array + { + Assert::IsInstanceOf($returnedObject, Article::class); + Assert::IsInstanceOf($sentObject, Article::class); + + $equal = true; + $idArray = []; + + $returnedLines = $returnedObject->getLines(); + $sentLines = $sentObject->getLines(); + + foreach ($sentLines as $key => $sentLine) { + $idArray[] = $sentLine->getID(); + } + + foreach ($returnedLines as $key => $returnedLine) { + $id = $returnedLine->getID(); + + if (!in_array($id, $idArray)) { + $returnedLine->setStatus(\PhpTwinfield\Enums\Status::DELETED()); + $equal = false; + } + } + + return [$equal, $returnedObject]; + } + + /** + * @param HasMessageInterface $article + * @return IndividualMappedResponse + */ + public function getMappedResponse(HasMessageInterface $article): IndividualMappedResponse + { + Assert::IsInstanceOf($article, Article::class); + + $request_article = new Request\Read\Article(); + $request_article->setOffice($article->getOffice()) + ->setCode($article->getCode()); + $response = $this->sendXmlDocument($request_article); + + $mappedResponseCollection = $this->getProcessXmlService()->mapAll([$response], "article", function(Response $response): Article { + return ArticleMapper::map($response, $this->getConnection()); + }); + + return ($mappedResponseCollection[0]); } /** diff --git a/src/ApiConnectors/BaseApiConnector.php b/src/ApiConnectors/BaseApiConnector.php index 57fae483..fe4517f9 100644 --- a/src/ApiConnectors/BaseApiConnector.php +++ b/src/ApiConnectors/BaseApiConnector.php @@ -262,7 +262,7 @@ public function testSentEqualsResponse(HasEqualInterface $apiConnector, array $s $equal = $testResult[0]; $returnedObject = $testResult[1]; - if ($equal === false) { + if (!$equal) { $individualMappedResponse = $apiConnector->sendAll([$returnedObject], true)[0]; $returnedObject = $individualMappedResponse->unwrap(); @@ -271,7 +271,7 @@ public function testSentEqualsResponse(HasEqualInterface $apiConnector, array $s $equal = $testResult[0]; $returnedObject = $testResult[1]; - if ($equal === false) { + if (!$equal) { $individualMappedResponse = $apiConnector->getMappedResponse($returnedObject); } } diff --git a/src/Article.php b/src/Article.php index 83fa68e6..25376b02 100644 --- a/src/Article.php +++ b/src/Article.php @@ -46,10 +46,12 @@ class Article extends BaseObject implements HasCodeInterface public function __construct() { + $this->setAllowChangePerformanceType(true); $this->setAllowChangeUnitsPrice(false); $this->setAllowChangeVatCode(false); $this->setAllowDecimalQuantity(false); $this->setAllowDiscountorPremium(true); + $this->setPercentage(false); $this->setType(\PhpTwinfield\Enums\ArticleType::NORMAL()); } From 910fb2a18a05667ece79ee2ba8120a6c01ee13d8 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 29 Jun 2019 12:09:38 +0200 Subject: [PATCH 372/388] Upload --- src/ApiConnectors/ArticleApiConnector.php | 22 +------- src/ApiConnectors/BaseApiConnector.php | 18 ++----- src/ApiConnectors/CurrencyApiConnector.php | 59 ++++++++++++++++++++-- src/ApiConnectors/RateApiConnector.php | 20 -------- src/ApiConnectors/VatCodeApiConnector.php | 23 +-------- 5 files changed, 63 insertions(+), 79 deletions(-) diff --git a/src/ApiConnectors/ArticleApiConnector.php b/src/ApiConnectors/ArticleApiConnector.php index 41a3ae22..ff80431d 100644 --- a/src/ApiConnectors/ArticleApiConnector.php +++ b/src/ApiConnectors/ArticleApiConnector.php @@ -97,7 +97,7 @@ public function sendAll(array $articles, bool $reSend = false): MappedResponseCo return self::testSentEqualsResponse($this, $articles, $mappedResponseCollection); } - + /** * @param HasMessageInterface $returnedObject * @param HasMessageInterface $sentObject @@ -130,26 +130,6 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa return [$equal, $returnedObject]; } - /** - * @param HasMessageInterface $article - * @return IndividualMappedResponse - */ - public function getMappedResponse(HasMessageInterface $article): IndividualMappedResponse - { - Assert::IsInstanceOf($article, Article::class); - - $request_article = new Request\Read\Article(); - $request_article->setOffice($article->getOffice()) - ->setCode($article->getCode()); - $response = $this->sendXmlDocument($request_article); - - $mappedResponseCollection = $this->getProcessXmlService()->mapAll([$response], "article", function(Response $response): Article { - return ArticleMapper::map($response, $this->getConnection()); - }); - - return ($mappedResponseCollection[0]); - } - /** * List all articles. * diff --git a/src/ApiConnectors/BaseApiConnector.php b/src/ApiConnectors/BaseApiConnector.php index fe4517f9..2becf40c 100644 --- a/src/ApiConnectors/BaseApiConnector.php +++ b/src/ApiConnectors/BaseApiConnector.php @@ -255,26 +255,16 @@ public function testSentEqualsResponse(HasEqualInterface $apiConnector, array $s foreach($mappedResponseCollection as $key => $individualMappedResponse) { $returnedObject = $individualMappedResponse->unwrap(); - $sentObject = $sentObjects[$key]; if ($returnedObject->getResult() == 1) { - $testResult = $apiConnector->testEqual($returnedObject, $sentObject); + $testResult = $apiConnector->testEqual($returnedObject, $sentObjects[$key]); $equal = $testResult[0]; $returnedObject = $testResult[1]; if (!$equal) { - $individualMappedResponse = $apiConnector->sendAll([$returnedObject], true)[0]; - $returnedObject = $individualMappedResponse->unwrap(); - - if ($returnedObject->getResult() == 1) { - $testResult = $apiConnector->testEqual($returnedObject, $sentObject); - $equal = $testResult[0]; - $returnedObject = $testResult[1]; - - if (!$equal) { - $individualMappedResponse = $apiConnector->getMappedResponse($returnedObject); - } - } + $apiConnector->sendAll([$returnedObject], true)[0]; + sleep(2); + $individualMappedResponse = $this->sendAll([$sentObjects[$key]], true)[0]; } } diff --git a/src/ApiConnectors/CurrencyApiConnector.php b/src/ApiConnectors/CurrencyApiConnector.php index 336e0853..b1fbe62c 100644 --- a/src/ApiConnectors/CurrencyApiConnector.php +++ b/src/ApiConnectors/CurrencyApiConnector.php @@ -5,13 +5,16 @@ use PhpTwinfield\Currency; use PhpTwinfield\DomDocuments\CurrenciesDocument; use PhpTwinfield\Exception; +use PhpTwinfield\HasMessageInterface; use PhpTwinfield\Mappers\CurrencyMapper; use PhpTwinfield\Office; use PhpTwinfield\Request as Request; +use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; use PhpTwinfield\Response\ResponseException; use PhpTwinfield\Services\FinderService; +use PhpTwinfield\Util; use Webmozart\Assert\Assert; /** @@ -23,7 +26,7 @@ * * @author Yannick Aerssens */ -class CurrencyApiConnector extends BaseApiConnector +class CurrencyApiConnector extends BaseApiConnector implements HasEqualInterface { /** * Requests a specific Currency based off the passed in code and optionally the office. @@ -91,10 +94,11 @@ public function send(Currency $currency): Currency /** * @param Currency[] $currencies + * @param bool|null $reSend * @return MappedResponseCollection * @throws Exception */ - public function sendAll(array $currencies): MappedResponseCollection + public function sendAll(array $currencies, bool $reSend = false): MappedResponseCollection { Assert::allIsInstanceOf($currencies, Currency::class); @@ -112,9 +116,58 @@ public function sendAll(array $currencies): MappedResponseCollection $responses[] = $this->sendXmlDocument($currenciesDocument); } - return $this->getProcessXmlService()->mapAll($responses, "currency", function(Response $response): Currency { + $mappedResponseCollection = $this->getProcessXmlService()->mapAll($responses, "currency", function(Response $response): Currency { return CurrencyMapper::map($response); }); + + if ($reSend) { + return $mappedResponseCollection; + } + + return self::testSentEqualsResponse($this, $currencies, $mappedResponseCollection); + } + + /** + * @param HasMessageInterface $returnedObject + * @param HasMessageInterface $sentObject + * @return array + */ + public function testEqual(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): array + { + Assert::IsInstanceOf($returnedObject, Currency::class); + Assert::IsInstanceOf($sentObject, Currency::class); + + $currencyResponse = $this->get($returnedObject->getCode(), $returnedObject->getOffice()); + + foreach ($returnedObject->getRates() as $key => $rate) { + $returnedObject->removeRate($key); + } + + foreach ($currencyResponse->getRates() as $key => $rate) { + $returnedObject->addRate($rate); + } + + $equal = true; + + $dateArray = []; + + $returnedRates = $returnedObject->getRates(); + $sentRates = $sentObject->getRates(); + + foreach ($sentRates as $sentRate) { + $dateArray[] = Util::formatDate($sentRate->getStartDate()); + } + + foreach ($returnedRates as $returnedRate) { + $date = Util::formatDate($returnedRate->getStartDate()); + + if (!in_array($date, $dateArray)) { + $returnedRate->setStatus(\PhpTwinfield\Enums\Status::DELETED()); + $equal = false; + } + } + + return [$equal, $returnedObject]; } /** diff --git a/src/ApiConnectors/RateApiConnector.php b/src/ApiConnectors/RateApiConnector.php index 681a2adb..bbdce09a 100644 --- a/src/ApiConnectors/RateApiConnector.php +++ b/src/ApiConnectors/RateApiConnector.php @@ -131,26 +131,6 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa return [$equal, $returnedObject]; } - /** - * @param HasMessageInterface $rate - * @return IndividualMappedResponse - */ - public function getMappedResponse(HasMessageInterface $rate): IndividualMappedResponse - { - Assert::IsInstanceOf($rate, Rate::class); - - $request_rate = new Request\Read\Rate(); - $request_rate->setOffice($rate->getOffice()) - ->setCode($rate->getCode()); - $response = $this->sendXmlDocument($request_rate); - - $mappedResponseCollection = $this->getProcessXmlService()->mapAll([$response], "projectrate", function(Response $response): Rate { - return RateMapper::map($response); - }); - - return ($mappedResponseCollection[0]); - } - /** * List all rates. * diff --git a/src/ApiConnectors/VatCodeApiConnector.php b/src/ApiConnectors/VatCodeApiConnector.php index 19b728f6..918ece6f 100644 --- a/src/ApiConnectors/VatCodeApiConnector.php +++ b/src/ApiConnectors/VatCodeApiConnector.php @@ -110,7 +110,7 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa Assert::IsInstanceOf($returnedObject, VatCode::class); Assert::IsInstanceOf($sentObject, VatCode::class); - $equal = false; + $equal = true; $dateArray = []; $returnedPercentages = $returnedObject->getPercentages(); @@ -125,32 +125,13 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa if (!in_array($date, $dateArray)) { $returnedPercentage->setStatus(\PhpTwinfield\Enums\Status::DELETED()); - $equal = true; + $equal = false; } } return [$equal, $returnedObject]; } - /** - * @param HasMessageInterface $vatCode - * @return IndividualMappedResponse - */ - public function getMappedResponse(HasMessageInterface $vatCode): IndividualMappedResponse - { - Assert::IsInstanceOf($vatCode, VatCode::class); - - $request_vatCode = new Request\Read\VatCode(); - $request_vatCode->setCode($vatCode->getCode()); - $response = $this->sendXmlDocument($request_vatCode); - - $mappedResponseCollection = $this->getProcessXmlService()->mapAll([$response], "vat", function(Response $response): VatCode { - return VatCodeMapper::map($response); - }); - - return ($mappedResponseCollection[0]); - } - /** * List all VAT codes. * From 4413e285b7d1f2ccb11e3fc494508adf240979f9 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 29 Jun 2019 12:13:31 +0200 Subject: [PATCH 373/388] Upload --- examples/Activity.php | 2 +- examples/Article.php | 2 +- examples/AssetMethod.php | 2 +- examples/Authorization.php | 2 +- examples/BrowseData.php | 22 +++++++------- examples/CashBankBook.php | 2 +- examples/Connection.php | 6 ++-- examples/CostCenter.php | 2 +- examples/Country.php | 2 +- examples/Currency.php | 2 +- examples/Customer.php | 2 +- examples/DimensionGroup.php | 2 +- examples/DimensionType.php | 2 +- examples/FixedAsset.php | 4 +-- examples/GeneralLedger.php | 6 ++-- examples/Invoice.php | 2 +- examples/InvoiceType.php | 2 +- examples/Office.php | 2 +- examples/PayCode.php | 2 +- examples/Project.php | 2 +- examples/Rate.php | 2 +- examples/RenewAccessToken.php | 2 +- examples/RenewAuthorization.php | 4 +-- examples/Supplier.php | 2 +- examples/User.php | 2 +- examples/UserRole.php | 2 +- examples/VatCode.php | 2 +- examples/VatGroup.php | 2 +- examples/VatGroupCountry.php | 2 +- src/Activity.php | 6 ++-- src/ApiConnectors/ActivityApiConnector.php | 2 +- src/ApiConnectors/ArticleApiConnector.php | 2 +- src/ApiConnectors/AssetMethodApiConnector.php | 2 +- src/ApiConnectors/BaseApiConnector.php | 2 +- .../BookingReferenceDeletionTrait.php | 2 +- .../CashBankBookApiConnector.php | 2 +- src/ApiConnectors/CostCenterApiConnector.php | 2 +- src/ApiConnectors/CountryApiConnector.php | 2 +- src/ApiConnectors/CurrencyApiConnector.php | 2 +- src/ApiConnectors/CustomerApiConnector.php | 2 +- .../DimensionGroupApiConnector.php | 2 +- .../DimensionTypeApiConnector.php | 2 +- .../ElectronicBankStatementApiConnector.php | 2 +- src/ApiConnectors/FixedAssetApiConnector.php | 2 +- .../GeneralLedgerApiConnector.php | 2 +- src/ApiConnectors/HasEqualInterface.php | 6 ++-- src/ApiConnectors/InvoiceTypeApiConnector.php | 2 +- src/ApiConnectors/MatchesApiConnector.php | 2 +- src/ApiConnectors/PayCodeApiConnector.php | 2 +- src/ApiConnectors/ProjectApiConnector.php | 2 +- src/ApiConnectors/RateApiConnector.php | 2 +- src/ApiConnectors/SupplierApiConnector.php | 2 +- src/ApiConnectors/TransactionApiConnector.php | 2 +- src/ApiConnectors/UserRoleApiConnector.php | 2 +- src/ApiConnectors/VatCodeApiConnector.php | 2 +- src/ApiConnectors/VatGroupApiConnector.php | 2 +- .../VatGroupCountryApiConnector.php | 2 +- src/Article.php | 10 +++---- src/ArticleLine.php | 2 +- src/AssetMethod.php | 10 +++---- src/BaseObject.php | 2 +- src/BaseTransaction.php | 2 +- src/BookingReference.php | 2 +- src/BookingReferenceInterface.php | 2 +- src/CashBankBook.php | 4 +-- src/CostCenter.php | 2 +- src/Country.php | 4 +-- src/Currency.php | 2 +- src/Customer.php | 26 ++++++++-------- src/DomDocuments/ActivitiesDocument.php | 4 +-- .../BookingReferenceDeletionDocument.php | 2 +- src/DomDocuments/CostCentersDocument.php | 2 +- src/DomDocuments/CustomersDocument.php | 2 +- .../ElectronicBankStatementDocument.php | 2 +- src/DomDocuments/GeneralLedgersDocument.php | 4 +-- src/DomDocuments/InvoicesDocument.php | 6 ++-- src/DomDocuments/MatchDocument.php | 2 +- src/DomDocuments/ProjectsDocument.php | 6 ++-- src/DomDocuments/SuppliersDocument.php | 4 +-- src/DomDocuments/TransactionsDocument.php | 30 +++++++++---------- src/DomDocuments/VatCodesDocument.php | 4 +-- src/Enums/AccountType.php | 2 +- src/Enums/AddressType.php | 2 +- src/Enums/ArticleType.php | 2 +- src/Enums/Behaviour.php | 2 +- ...ckedAccountPaymentConditionsIncludeVat.php | 2 +- src/Enums/BrowseColumnOperator.php | 2 +- src/Enums/CalcMethod.php | 2 +- src/Enums/ChildValidationType.php | 2 +- src/Enums/CollectionSchema.php | 2 +- src/Enums/Culture.php | 2 +- src/Enums/DebitCredit.php | 2 +- src/Enums/DepreciateReconciliation.php | 2 +- src/Enums/Destiny.php | 2 +- src/Enums/FixedAssetsStatus.php | 2 +- src/Enums/FreeTextType.php | 2 +- src/Enums/InvoiceDebitCredit.php | 2 +- src/Enums/InvoiceStatus.php | 2 +- src/Enums/LineType.php | 2 +- src/Enums/MatchCode.php | 2 +- src/Enums/MatchStatus.php | 2 +- src/Enums/MatchType.php | 2 +- src/Enums/MeansOfPayment.php | 2 +- src/Enums/Order.php | 2 +- src/Enums/PaymentMethod.php | 2 +- src/Enums/PerformanceType.php | 2 +- src/Enums/RateType.php | 2 +- src/Enums/Regime.php | 2 +- src/Enums/RemittanceAdviceSendType.php | 2 +- src/Enums/SendReminder.php | 2 +- src/Enums/Services.php | 2 +- src/Enums/Status.php | 2 +- src/Enums/SubAnalyse.php | 2 +- src/Enums/UserType.php | 2 +- src/Enums/VatType.php | 2 +- src/Enums/WriteOffType.php | 2 +- .../AssetMethod/AssetsToActivateField.php | 2 +- src/Fields/AssetMethod/CalcMethodField.php | 2 +- .../DepreciateReconciliationField.php | 2 +- src/Fields/AssetMethod/DepreciationField.php | 4 +-- .../AssetMethod/DepreciationGroupField.php | 2 +- src/Fields/AssetMethod/FreeTextTypeField.php | 2 +- src/Fields/AssetMethod/PurchaseValueField.php | 2 +- .../AssetMethod/PurchaseValueGroupField.php | 2 +- .../AssetMethod/ReconciliationField.php | 2 +- src/Fields/AssetMethod/SalesField.php | 4 +-- src/Fields/AssetMethod/ToBeInvoicedField.php | 4 +-- src/Fields/BehaviourField.php | 2 +- src/Fields/CodeField.php | 2 +- src/Fields/CommentField.php | 2 +- src/Fields/CreatedField.php | 2 +- src/Fields/Currency/CurrencyRateRateField.php | 2 +- src/Fields/Currency/StartDateField.php | 2 +- src/Fields/CurrencyField.php | 2 +- src/Fields/DateField.php | 2 +- src/Fields/DescriptionField.php | 2 +- src/Fields/Dim1Field.php | 2 +- src/Fields/Dim4Field.php | 2 +- src/Fields/Dimensions/AccountTypeField.php | 2 +- src/Fields/Dimensions/AmountField.php | 2 +- src/Fields/Dimensions/BeginPeriodField.php | 2 +- src/Fields/Dimensions/BeginYearField.php | 2 +- .../Dimensions/DimensionGroup/CodeField.php | 2 +- .../DimensionType/FinancialsField.php | 2 +- .../Dimensions/DimensionType/Label1Field.php | 2 +- .../Dimensions/DimensionType/Label2Field.php | 2 +- .../Dimensions/DimensionType/Label3Field.php | 2 +- .../Dimensions/DimensionType/Label4Field.php | 2 +- .../Dimensions/DimensionType/Label5Field.php | 2 +- .../Dimensions/DimensionType/Label6Field.php | 2 +- .../Dimensions/DimensionType/MaskField.php | 2 +- .../Dimensions/DimensionType/TimeField.php | 2 +- src/Fields/Dimensions/EndPeriodField.php | 2 +- src/Fields/Dimensions/EndYearField.php | 2 +- .../Dimensions/Level2/AccountNumberField.php | 2 +- .../Dimensions/Level2/AddressField2Field.php | 2 +- .../Dimensions/Level2/AddressField3Field.php | 2 +- .../Dimensions/Level2/AscriptionField.php | 2 +- .../Dimensions/Level2/BankBlockedField.php | 2 +- .../Dimensions/Level2/BankNameField.php | 2 +- src/Fields/Dimensions/Level2/BicCodeField.php | 2 +- src/Fields/Dimensions/Level2/CityField.php | 2 +- .../Level2/Customer/BaseCreditLimitField.php | 2 +- .../Level2/Customer/BlockedField.php | 4 +-- .../Level2/Customer/BlockedLockedField.php | 2 +- .../Level2/Customer/BlockedModifiedField.php | 2 +- .../Level2/Customer/CollectionSchemaField.php | 2 +- .../Customer/DiscountArticleIDField.php | 2 +- .../Level2/Customer/EBillMailField.php | 2 +- .../Level2/Customer/EBillingField.php | 2 +- .../Level2/Customer/FirstRunDateField.php | 2 +- .../Level2/Customer/FreeText1Field.php | 2 +- .../Dimensions/Level2/Customer/IDField.php | 2 +- .../Level2/Customer/ReminderEmailField.php | 2 +- .../Level2/Customer/SendReminderField.php | 2 +- .../Level2/Customer/SignatureDateField.php | 2 +- src/Fields/Dimensions/Level2/DefaultField.php | 2 +- .../Dimensions/Level2/Dimension1Field.php | 2 +- .../Dimensions/Level2/Dimension1IDField.php | 2 +- .../Dimensions/Level2/Dimension2Field.php | 2 +- .../Dimensions/Level2/Dimension2IDField.php | 2 +- .../Dimensions/Level2/Dimension3Field.php | 2 +- .../Dimensions/Level2/Dimension3IDField.php | 2 +- src/Fields/Dimensions/Level2/DueDaysField.php | 2 +- src/Fields/Dimensions/Level2/Field1Field.php | 2 +- src/Fields/Dimensions/Level2/Field2Field.php | 2 +- src/Fields/Dimensions/Level2/Field3Field.php | 2 +- src/Fields/Dimensions/Level2/Field4Field.php | 2 +- src/Fields/Dimensions/Level2/Field5Field.php | 2 +- src/Fields/Dimensions/Level2/Field6Field.php | 2 +- src/Fields/Dimensions/Level2/IbanField.php | 2 +- .../Dimensions/Level2/MeansOfPaymentField.php | 2 +- .../Dimensions/Level2/NatBicCodeField.php | 2 +- .../Dimensions/Level2/PayAvailableField.php | 2 +- .../Dimensions/Level2/PayCodeIDField.php | 2 +- .../PaymentConditionDiscountDaysField.php | 2 +- ...aymentConditionDiscountPercentageField.php | 2 +- .../Dimensions/Level2/PostcodeField.php | 2 +- src/Fields/Dimensions/Level2/RatioField.php | 2 +- .../Level2/RemittanceAdviceSendMailField.php | 2 +- .../Level2/RemittanceAdviceSendTypeField.php | 2 +- src/Fields/Dimensions/Level2/StateField.php | 2 +- ...ccountPaymentConditionsIncludeVatField.php | 2 +- ...ccountPaymentConditionsPercentageField.php | 2 +- .../Supplier/RelationsReferenceField.php | 2 +- src/Fields/Dimensions/Level2/TelefaxField.php | 2 +- .../Dimensions/Level2/TelephoneField.php | 2 +- src/Fields/Dimensions/Level2/TypeField.php | 2 +- src/Fields/Dimensions/Level2/WebsiteField.php | 2 +- .../Level34/AuthoriserInheritField.php | 2 +- .../Level34/AuthoriserLockedField.php | 2 +- .../Dimensions/Level34/BillableField.php | 2 +- .../Level34/BillableForRatioField.php | 2 +- .../Level34/BillableInheritField.php | 2 +- .../Level34/BillableLockedField.php | 2 +- .../Level34/CustomerInheritField.php | 2 +- .../Level34/CustomerLockedField.php | 2 +- .../Level34/FixedAsset/AmountLockedField.php | 2 +- .../FixedAsset/BeginPeriodLockedField.php | 2 +- .../Level34/FixedAsset/CodeLockedField.php | 2 +- .../Level34/FixedAsset/Dim1LockedField.php | 4 +-- .../Level34/FixedAsset/Dim2LockedField.php | 2 +- .../Level34/FixedAsset/Dim3LockedField.php | 2 +- .../Level34/FixedAsset/Dim4LockedField.php | 2 +- .../Level34/FixedAsset/Dim5LockedField.php | 4 +-- .../Level34/FixedAsset/Dim6LockedField.php | 2 +- .../FixedAsset/FreeText1LockedField.php | 2 +- .../FixedAsset/FreeText2LockedField.php | 2 +- .../FixedAsset/FreeText3LockedField.php | 4 +-- .../Level34/FixedAsset/FreeText4Field.php | 2 +- .../FixedAsset/FreeText4LockedField.php | 2 +- .../Level34/FixedAsset/FreeText5Field.php | 2 +- .../FixedAsset/FreeText5LockedField.php | 2 +- .../LastDepreciationLockedField.php | 2 +- .../Level34/FixedAsset/LineField.php | 2 +- .../Level34/FixedAsset/LineLockedField.php | 2 +- .../Level34/FixedAsset/MethodLockedField.php | 2 +- .../FixedAsset/NrOfPeriodsInheritedField.php | 2 +- .../FixedAsset/NrOfPeriodsLockedField.php | 2 +- .../Level34/FixedAsset/NumberField.php | 2 +- .../Level34/FixedAsset/NumberLockedField.php | 2 +- .../FixedAsset/PercentageLockedField.php | 2 +- .../Level34/FixedAsset/PeriodLockedField.php | 2 +- .../Level34/FixedAsset/PurchaseDateField.php | 2 +- .../FixedAsset/PurchaseDateLockedField.php | 2 +- .../Level34/FixedAsset/ResidualValueField.php | 2 +- .../FixedAsset/ResidualValueLockedField.php | 2 +- .../Level34/FixedAsset/SellDateField.php | 2 +- .../FixedAsset/SellDateLockedField.php | 2 +- .../Level34/FixedAsset/StatusField.php | 2 +- .../Level34/FixedAsset/StatusLockedField.php | 2 +- .../Level34/FixedAsset/StopValueField.php | 2 +- .../FixedAsset/StopValueLockedField.php | 2 +- .../TransactionLinesLockedField.php | 2 +- .../Level34/InvoiceDescriptionField.php | 2 +- src/Fields/Dimensions/Level34/LabelField.php | 2 +- .../Dimensions/Level34/MandatoryField.php | 2 +- .../Dimensions/Level34/RateInheritField.php | 2 +- .../Dimensions/Level34/RateLockedField.php | 2 +- .../Dimensions/Level34/ValidFromField.php | 2 +- .../Dimensions/Level34/ValidTillField.php | 2 +- src/Fields/Dimensions/MatchTypeField.php | 2 +- src/Fields/Dimensions/SubAnalyseField.php | 2 +- .../Dimensions/SubstituteWithIDField.php | 2 +- .../Dimensions/SubstitutionLevelField.php | 2 +- src/Fields/Dimensions/TypeField.php | 2 +- src/Fields/Dimensions/VatCodeFixedField.php | 2 +- src/Fields/DueDateField.php | 2 +- src/Fields/ElementValueField.php | 2 +- src/Fields/EmailField.php | 2 +- src/Fields/FreeText1Field.php | 2 +- src/Fields/FreeText2Field.php | 2 +- src/Fields/FreeText3Field.php | 2 +- src/Fields/IDField.php | 2 +- src/Fields/InUseField.php | 2 +- .../Invoice/AllowDiscountOrPremiumField.php | 4 +-- .../AllowChangePerformanceTypeField.php | 2 +- .../Article/AllowChangeUnitsPriceField.php | 4 +-- .../Article/AllowChangeVatCodeField.php | 4 +-- .../Article/AllowDecimalQuantityField.php | 4 +-- .../Invoice/Article/PercentageField.php | 2 +- src/Fields/Invoice/Article/SubCodeField.php | 2 +- src/Fields/Invoice/Article/TypeField.php | 2 +- .../Invoice/Article/UnitNamePluralField.php | 2 +- .../Invoice/Article/UnitNameSingularField.php | 2 +- src/Fields/Invoice/ArticleField.php | 2 +- src/Fields/Invoice/CalculateOnlyField.php | 2 +- src/Fields/Invoice/CustomerNameField.php | 2 +- src/Fields/Invoice/DebitCreditField.php | 2 +- .../Invoice/DeliverAddressNumberField.php | 2 +- src/Fields/Invoice/FinancialCodeField.php | 2 +- src/Fields/Invoice/FinancialNumberField.php | 2 +- src/Fields/Invoice/FooterTextField.php | 2 +- src/Fields/Invoice/HeaderTextField.php | 2 +- .../Invoice/InvoiceAddressNumberField.php | 2 +- src/Fields/Invoice/InvoiceAmountField.php | 4 +-- src/Fields/Invoice/InvoiceDateField.php | 2 +- src/Fields/Invoice/PaymentMethodField.php | 2 +- .../Invoice/PeriodRaiseWarningField.php | 4 +-- src/Fields/Invoice/QuantityField.php | 2 +- src/Fields/Invoice/RaiseWarningField.php | 2 +- src/Fields/Invoice/StatusField.php | 2 +- src/Fields/Invoice/SubArticleField.php | 4 +-- src/Fields/Invoice/UnitsField.php | 2 +- src/Fields/Invoice/UnitsPriceExclField.php | 4 +-- src/Fields/Invoice/UnitsPriceIncField.php | 2 +- src/Fields/Invoice/ValueExclField.php | 2 +- src/Fields/Invoice/ValueIncField.php | 2 +- src/Fields/InvoiceNumberField.php | 2 +- src/Fields/LevelField.php | 2 +- src/Fields/LineTypeField.php | 2 +- src/Fields/ModifiedField.php | 2 +- src/Fields/NameField.php | 2 +- src/Fields/NrOfPeriodsField.php | 2 +- src/Fields/Office/BaseCurrencyField.php | 2 +- src/Fields/Office/CountryCodeField.php | 4 +-- src/Fields/Office/ReportingCurrencyField.php | 4 +-- .../Office/VatFirstQuarterStartsInField.php | 2 +- src/Fields/Office/VatPeriodField.php | 2 +- src/Fields/PercentageField.php | 2 +- src/Fields/PerformanceDateField.php | 2 +- src/Fields/PerformanceTypeField.php | 2 +- src/Fields/Rate/BeginDateField.php | 2 +- src/Fields/Rate/EndDateField.php | 4 +-- src/Fields/Rate/ExternalRateField.php | 2 +- src/Fields/Rate/InternalRateField.php | 2 +- src/Fields/Rate/TypeField.php | 2 +- src/Fields/Rate/UnitField.php | 2 +- src/Fields/ShortNameField.php | 2 +- src/Fields/StatusField.php | 2 +- src/Fields/TouchedField.php | 2 +- .../Transaction/AutoBalanceVatField.php | 2 +- .../Transaction/CloseAndStartValueFields.php | 2 +- .../Transaction/DateRaiseWarningField.php | 2 +- src/Fields/Transaction/DestinyField.php | 2 +- src/Fields/Transaction/InputDateField.php | 2 +- .../InvoiceNumberRaiseWarningField.php | 2 +- .../Transaction/ModificationDateField.php | 2 +- src/Fields/Transaction/NumberField.php | 2 +- src/Fields/Transaction/OriginField.php | 2 +- .../Transaction/OriginReferenceField.php | 2 +- .../Transaction/PaymentReferenceField.php | 2 +- src/Fields/Transaction/RaiseWarningField.php | 2 +- src/Fields/Transaction/RegimeField.php | 2 +- .../Transaction/StatementNumberField.php | 2 +- .../TransactionLine/BaseValueField.php | 2 +- .../TransactionLine/BaseValueOpenField.php | 4 +-- .../TransactionLine/BaselineField.php | 2 +- .../TransactionLine/CurrencyDateField.php | 2 +- .../TransactionLine/MatchDateField.php | 2 +- .../TransactionLine/MatchLevelField.php | 2 +- .../TransactionLine/MatchStatusField.php | 2 +- .../PerformanceCountryField.php | 2 +- .../PerformanceVatNumberField.php | 2 +- .../Transaction/TransactionLine/RateField.php | 2 +- .../TransactionLine/RelationField.php | 2 +- .../TransactionLine/RepRateField.php | 2 +- .../TransactionLine/RepValueField.php | 2 +- .../TransactionLine/RepValueOpenField.php | 2 +- .../TransactionLine/ValueFields.php | 2 +- .../TransactionLine/ValueOpenField.php | 2 +- .../TransactionLine/VatBaseTotalField.php | 2 +- .../TransactionLine/VatBaseTurnoverField.php | 2 +- .../TransactionLine/VatBaseValueField.php | 2 +- .../TransactionLine/VatRepTotalField.php | 2 +- .../TransactionLine/VatRepTurnoverField.php | 2 +- .../TransactionLine/VatRepValueField.php | 2 +- .../TransactionLine/VatTotalField.php | 2 +- .../TransactionLine/VatTurnoverField.php | 2 +- src/Fields/UIDField.php | 2 +- src/Fields/User/AcceptExtraCostField.php | 2 +- src/Fields/User/CultureField.php | 2 +- src/Fields/User/CultureNameField.php | 2 +- src/Fields/User/CultureNativeNameField.php | 2 +- src/Fields/User/DemoField.php | 2 +- src/Fields/User/DemoLockedField.php | 4 +-- src/Fields/User/ExchangeQuotaField.php | 2 +- src/Fields/User/ExchangeQuotaLockedField.php | 2 +- src/Fields/User/FileManagerQuotaField.php | 2 +- .../User/FileManagerQuotaLockedField.php | 2 +- src/Fields/User/IsCurrentUserField.php | 2 +- src/Fields/User/LevelField.php | 2 +- src/Fields/User/PasswordField.php | 2 +- src/Fields/User/RoleLockedField.php | 4 +-- src/Fields/User/TypeField.php | 2 +- src/Fields/User/TypeLockedField.php | 2 +- src/Fields/VatCode/GroupCountryField.php | 2 +- src/Fields/VatCode/GroupField.php | 2 +- src/Fields/VatCode/TypeField.php | 2 +- src/Fields/VatCodeField.php | 2 +- src/Fields/VatValueField.php | 2 +- src/Mappers/ActivityMapper.php | 2 +- src/Mappers/ArticleMapper.php | 4 +-- src/Mappers/AssetMethodMapper.php | 2 +- src/Mappers/BaseMapper.php | 16 +++++----- src/Mappers/BrowseDataMapper.php | 2 +- src/Mappers/BrowseFieldMapper.php | 2 +- src/Mappers/CashBankBookMapper.php | 2 +- src/Mappers/CostCenterMapper.php | 2 +- src/Mappers/CustomerMapper.php | 2 +- src/Mappers/DimensionTypeMapper.php | 2 +- src/Mappers/FixedAssetMapper.php | 2 +- src/Mappers/InvoiceMapper.php | 2 +- src/Mappers/InvoiceTypeMapper.php | 2 +- src/Mappers/MatchSetMapper.php | 2 +- src/Mappers/OfficeMapper.php | 2 +- src/Mappers/RateMapper.php | 2 +- src/Mappers/SupplierMapper.php | 2 +- src/Mappers/TransactionMapper.php | 4 +-- src/Mappers/UserMapper.php | 2 +- src/Mappers/VatCodeMapper.php | 6 ++-- src/Mappers/VatGroupCountryMapper.php | 2 +- src/Mappers/VatGroupMapper.php | 2 +- src/Request/Catalog/Office.php | 2 +- src/Request/Read/Activity.php | 2 +- src/Request/Read/Article.php | 2 +- src/Request/Read/CostCenter.php | 4 +-- src/Request/Read/Currency.php | 2 +- src/Request/Read/Customer.php | 2 +- src/Request/Read/FixedAsset.php | 2 +- src/Request/Read/GeneralLedger.php | 2 +- src/Request/Read/Office.php | 2 +- src/Request/Read/Project.php | 2 +- src/Request/Read/Rate.php | 2 +- src/Request/Read/User.php | 2 +- src/Request/Read/VatCode.php | 2 +- src/Response/IndividualMappedResponse.php | 2 +- src/Response/MappedResponseCollection.php | 2 +- src/Response/Response.php | 2 +- src/Response/ResponseException.php | 2 +- src/Secure/OpenIdConnectAuthentication.php | 2 +- .../Provider/InvalidAccessTokenException.php | 2 +- src/Secure/Provider/OAuthException.php | 2 +- src/Secure/Provider/ResourceOwner.php | 2 +- src/Secure/WebservicesAuthentication.php | 2 +- src/Services/FinderService.php | 2 +- src/Services/ProcessXmlService.php | 2 +- 437 files changed, 534 insertions(+), 534 deletions(-) diff --git a/examples/Activity.php b/examples/Activity.php index a10e7274..e4623ec2 100644 --- a/examples/Activity.php +++ b/examples/Activity.php @@ -353,4 +353,4 @@ echo "Result of deletion process: {$activityDeleted->getResult()}
"; echo "Code of deleted Activity: {$activityDeleted->getCode()}
"; echo "Status of deleted Activity: {$activityDeleted->getStatus()}
"; -} \ No newline at end of file +} diff --git a/examples/Article.php b/examples/Article.php index e6386961..510605b2 100644 --- a/examples/Article.php +++ b/examples/Article.php @@ -300,4 +300,4 @@ echo "Result of deletion process: {$articleDeleted->getResult()}
"; echo "Code of deleted Article: {$articleDeleted->getCode()}
"; echo "Status of deleted Article: {$articleDeleted->getStatus()}
"; -} \ No newline at end of file +} diff --git a/examples/AssetMethod.php b/examples/AssetMethod.php index cd41b470..72b13a5c 100644 --- a/examples/AssetMethod.php +++ b/examples/AssetMethod.php @@ -350,4 +350,4 @@ echo "Result of deletion process: {$assetMethodDeleted->getResult()}
"; echo "Code of deleted AssetMethod: {$assetMethodDeleted->getCode()}
"; echo "Status of deleted AssetMethod: {$assetMethodDeleted->getStatus()}
"; -} \ No newline at end of file +} diff --git a/examples/Authorization.php b/examples/Authorization.php index 59a57452..6df937b5 100644 --- a/examples/Authorization.php +++ b/examples/Authorization.php @@ -107,4 +107,4 @@ function SaveAccessTokenToStore(array $accessTokenStorage) { // Failed to get the access token or user details. exit($e->getMessage()); } -} \ No newline at end of file +} diff --git a/examples/BrowseData.php b/examples/BrowseData.php index 69d196cf..a2d31964 100644 --- a/examples/BrowseData.php +++ b/examples/BrowseData.php @@ -205,39 +205,39 @@ } catch (ResponseException $e) { $browseData = $e->getReturnedObject(); } - + echo "
";
     print_r($browseData);
-    echo "
"; - + echo ""; + echo "Browse Data
"; echo "First: {$browseData->getFirst()}
"; echo "Last: {$browseData->getLast()}
"; echo "Total: {$browseData->getTotal()}

"; - + $browseDataHeaders = $browseData->getHeaders(); $tableHeader = array("Result #", "Office", "Code", "Number", "Line"); - + foreach ($browseDataHeaders as $browseDataHeader) { $tableHeader[] = $browseDataHeader->getLabel(); } - + $browseDataRows = $browseData->getRows(); - + foreach ($browseDataRows as $key => $browseDataRow) { $tableRows[$key][] = $key; $tableRows[$key][] = $browseDataRow->getOffice(); $tableRows[$key][] = $browseDataRow->getCode(); $tableRows[$key][] = $browseDataRow->getNumber(); $tableRows[$key][] = $browseDataRow->getLine(); - + $browseDataCells = $browseDataRow->getCells(); - + foreach ($browseDataCells as $browseDataCell) { $tableRows[$key][] = $browseDataCell->getValue(); } } - + ?> @@ -263,4 +263,4 @@ } getCode()}
"; echo "Name: {$cashBankBook->getName()}

"; } -} \ No newline at end of file +} diff --git a/examples/Connection.php b/examples/Connection.php index caf47d6c..78db7813 100644 --- a/examples/Connection.php +++ b/examples/Connection.php @@ -1,8 +1,8 @@ getResult()}
"; echo "Code of deleted CostCenter: {$costCenterDeleted->getCode()}
"; echo "Status of deleted CostCenter: {$costCenterDeleted->getStatus()}
"; -} \ No newline at end of file +} diff --git a/examples/Country.php b/examples/Country.php index 5dfdcbba..ac9e5aaf 100644 --- a/examples/Country.php +++ b/examples/Country.php @@ -82,4 +82,4 @@ echo "Code: {$country->getCode()}
"; echo "Name: {$country->getName()}

"; } -} \ No newline at end of file +} diff --git a/examples/Currency.php b/examples/Currency.php index 02e82d28..7947bc3d 100644 --- a/examples/Currency.php +++ b/examples/Currency.php @@ -230,4 +230,4 @@ echo "Result of deletion process: {$currencyDeleted->getResult()}
"; echo "Code of deleted Currency: {$currencyDeleted->getCode()}
"; echo "Status of deleted Currency: {$currencyDeleted->getStatus()}
"; -} \ No newline at end of file +} diff --git a/examples/Customer.php b/examples/Customer.php index 577525d5..5f88c1c7 100644 --- a/examples/Customer.php +++ b/examples/Customer.php @@ -667,4 +667,4 @@ echo "Result of deletion process: {$customerDeleted->getResult()}
"; echo "Code of deleted Customer: {$customerDeleted->getCode()}
"; echo "Status of deleted Customer: {$customerDeleted->getStatus()}
"; -} \ No newline at end of file +} diff --git a/examples/DimensionGroup.php b/examples/DimensionGroup.php index c7dd71ce..0cd889fb 100644 --- a/examples/DimensionGroup.php +++ b/examples/DimensionGroup.php @@ -240,4 +240,4 @@ echo "Result of deletion process: {$dimensionGroupDeleted->getResult()}
"; echo "Code of deleted DimensionGroup: {$dimensionGroupDeleted->getCode()}
"; echo "Status of deleted DimensionGroup: {$dimensionGroupDeleted->getStatus()}
"; -} \ No newline at end of file +} diff --git a/examples/DimensionType.php b/examples/DimensionType.php index 714d51bd..95d4472f 100644 --- a/examples/DimensionType.php +++ b/examples/DimensionType.php @@ -203,4 +203,4 @@ echo "Result of modify process: {$dimensionTypeModify->getResult()}
"; echo "Code of modified DimensionType: {$dimensionTypeModify->getCode()}
"; echo "Status of modified DimensionType: {$dimensionTypeModify->getStatus()}
"; -} \ No newline at end of file +} diff --git a/examples/FixedAsset.php b/examples/FixedAsset.php index dfff171e..5ae32043 100644 --- a/examples/FixedAsset.php +++ b/examples/FixedAsset.php @@ -398,7 +398,7 @@ //$fixedAssetFixedAssets->setSellDate($sellDate); // DateTimeInterface|null The date the asset is sold. //$fixedAssetFixedAssets->setSellDate(Util::parseDate('20190101')); // string|null $fixedAssetFixedAssets->setStopValue(\Money\Money::EUR(0)); // Money|null The value future depreciation should stop at. (Equals 0.00 EUR) - + $fixedAsset->setFixedAssets($fixedAssetFixedAssets); // FixedAssetFixedAssets Set the FixedAssetFixedAssets object tot the FixedAsset object try { @@ -431,4 +431,4 @@ echo "Result of deletion process: {$fixedAssetDeleted->getResult()}
"; echo "Code of deleted FixedAsset: {$fixedAssetDeleted->getCode()}
"; echo "Status of deleted FixedAsset: {$fixedAssetDeleted->getStatus()}
"; -} \ No newline at end of file +} diff --git a/examples/GeneralLedger.php b/examples/GeneralLedger.php index 7f41bcd1..84be995f 100644 --- a/examples/GeneralLedger.php +++ b/examples/GeneralLedger.php @@ -240,8 +240,8 @@ $dimensionType->setCode('BAS'); //$dimensionType->setCode('PNL'); $generalLedger->setType($dimensionType); // DimensionType|null - $generalLedger->setType(\PhpTwinfield\DimensionType::fromCode('BAS')); // string|null - //$generalLedger->setType(\PhpTwinfield\DimensionType::fromCode('PNL')); // string|null + $generalLedger->setType(\PhpTwinfield\DimensionType::fromCode('BAS')); // string|null + //$generalLedger->setType(\PhpTwinfield\DimensionType::fromCode('PNL')); // string|null $generalLedger->setOffice($office); // Office|null Office code. $generalLedger->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null @@ -299,4 +299,4 @@ echo "Result of deletion process: {$generalLedgerDeleted->getResult()}
"; echo "Code of deleted GeneralLedger: {$generalLedgerDeleted->getCode()}
"; echo "Status of deleted GeneralLedger: {$generalLedgerDeleted->getStatus()}
"; -} \ No newline at end of file +} diff --git a/examples/Invoice.php b/examples/Invoice.php index d89de4e2..696e2396 100644 --- a/examples/Invoice.php +++ b/examples/Invoice.php @@ -387,4 +387,4 @@ echo "Result of creation process: {$invoiceNew->getResult()}
"; echo "Number of new Invoice: {$invoiceNew->getInvoiceNumber()}
"; echo "Status of new Invoice: {$invoiceNew->getStatus()}
"; -} \ No newline at end of file +} diff --git a/examples/InvoiceType.php b/examples/InvoiceType.php index a7ac5f70..9ebf23e7 100644 --- a/examples/InvoiceType.php +++ b/examples/InvoiceType.php @@ -89,4 +89,4 @@ echo "Name: {$invoiceType->getName()}
"; echo "VAT: {$invoiceTypeApiConnector->getInvoiceTypeVatType($invoiceType->getCode())}

"; } -} \ No newline at end of file +} diff --git a/examples/Office.php b/examples/Office.php index da403639..a47b2709 100644 --- a/examples/Office.php +++ b/examples/Office.php @@ -161,4 +161,4 @@ echo "User (string): " . Util::objectToStr($office->getUser()) . "
"; // string|null //echo "VatFirstQuarterStartsIn: {$office->getVatFirstQuarterStartsIn()}
"; // string|null //echo "VatPeriod: {$office->getVatPeriod()}
"; // string|null -} \ No newline at end of file +} diff --git a/examples/PayCode.php b/examples/PayCode.php index 4a40d6ee..8d553f8d 100644 --- a/examples/PayCode.php +++ b/examples/PayCode.php @@ -88,4 +88,4 @@ echo "Code: {$payCode->getCode()}
"; echo "Name: {$payCode->getName()}

"; } -} \ No newline at end of file +} diff --git a/examples/Project.php b/examples/Project.php index 328cf1e0..f1e9bea5 100644 --- a/examples/Project.php +++ b/examples/Project.php @@ -353,4 +353,4 @@ echo "Result of deletion process: {$projectDeleted->getResult()}
"; echo "Code of deleted Project: {$projectDeleted->getCode()}
"; echo "Status of deleted Project: {$projectDeleted->getStatus()}
"; -} \ No newline at end of file +} diff --git a/examples/Rate.php b/examples/Rate.php index 29f51dc2..d1f4b693 100644 --- a/examples/Rate.php +++ b/examples/Rate.php @@ -263,4 +263,4 @@ echo "Result of deletion process: {$rateDeleted->getResult()}
"; echo "Code of deleted Rate: {$rateDeleted->getCode()}
"; echo "Status of deleted Rate: {$rateDeleted->getStatus()}
"; -} \ No newline at end of file +} diff --git a/examples/RenewAccessToken.php b/examples/RenewAccessToken.php index 87a9f707..96689284 100644 --- a/examples/RenewAccessToken.php +++ b/examples/RenewAccessToken.php @@ -88,4 +88,4 @@ function LastRunThreeQuartersAgo () { // Update the last renewal successful run time to right now touch('renewaccesstoken.timestamp'); -} \ No newline at end of file +} diff --git a/examples/RenewAuthorization.php b/examples/RenewAuthorization.php index 39ac6b33..d226f193 100644 --- a/examples/RenewAuthorization.php +++ b/examples/RenewAuthorization.php @@ -10,7 +10,7 @@ function RetrieveRefreshTokenFromStore() { $refreshTokenStorage = array(); $refreshTokenStorage['refresh_expiry'] = 'SavedRefreshExpiryTimeStamp'; - + return $refreshTokenStorage; } @@ -48,4 +48,4 @@ function SendEmail(string $toEmail, string $fromEmail, string $subject, string $ if ($refreshTokenStorage['refresh_expiry'] < (time() + ($daysLeftAfterWhichRequestRenewal * 60 * 60 * 24))) { SendEmail($accountingAdminEmail, $fromEmail, $subject, $body); } -?> \ No newline at end of file +?> diff --git a/examples/Supplier.php b/examples/Supplier.php index 871369e1..c9876b05 100644 --- a/examples/Supplier.php +++ b/examples/Supplier.php @@ -570,4 +570,4 @@ echo "Result of deletion process: {$supplierDeleted->getResult()}
"; echo "Code of deleted Supplier: {$supplierDeleted->getCode()}
"; echo "Status of deleted Supplier: {$supplierDeleted->getStatus()}
"; -} \ No newline at end of file +} diff --git a/examples/User.php b/examples/User.php index 06503522..4f6be2e1 100644 --- a/examples/User.php +++ b/examples/User.php @@ -163,4 +163,4 @@ echo "Type: {$user->getType()}
"; // UserType|null User type, will be validated with the office type. Use regular in case of a non-accountancy organisation. echo "TypeLocked (bool): {$user->getTypeLocked()}
"; // bool|null echo "TypeLocked (string): " . Util::formatBoolean($user->getTypeLocked()) . "
"; // string|null -} \ No newline at end of file +} diff --git a/examples/UserRole.php b/examples/UserRole.php index 1ebbfc0c..05abc052 100644 --- a/examples/UserRole.php +++ b/examples/UserRole.php @@ -82,4 +82,4 @@ echo "Code: {$userRole->getCode()}
"; echo "Name: {$userRole->getName()}

"; } -} \ No newline at end of file +} diff --git a/examples/VatCode.php b/examples/VatCode.php index 93dcb16b..9676430c 100644 --- a/examples/VatCode.php +++ b/examples/VatCode.php @@ -306,4 +306,4 @@ echo "Result of deletion process: {$vatCodeDeleted->getResult()}
"; echo "Code of deleted VatCode: {$vatCodeDeleted->getCode()}
"; echo "Status of deleted VatCode: {$vatCodeDeleted->getStatus()}
"; -} \ No newline at end of file +} diff --git a/examples/VatGroup.php b/examples/VatGroup.php index f33c02df..6d392670 100644 --- a/examples/VatGroup.php +++ b/examples/VatGroup.php @@ -82,4 +82,4 @@ echo "Code: {$vatGroup->getCode()}
"; echo "Name: {$vatGroup->getName()}

"; } -} \ No newline at end of file +} diff --git a/examples/VatGroupCountry.php b/examples/VatGroupCountry.php index 7704ed8f..c6960f38 100644 --- a/examples/VatGroupCountry.php +++ b/examples/VatGroupCountry.php @@ -87,4 +87,4 @@ echo "Code: {$vatGroupCountry->getCode()}
"; echo "Name: {$vatGroupCountry->getName()}

"; } -} \ No newline at end of file +} diff --git a/src/Activity.php b/src/Activity.php index 960652b3..59ca84f8 100644 --- a/src/Activity.php +++ b/src/Activity.php @@ -38,10 +38,10 @@ class Activity extends BaseObject implements HasCodeInterface public function __construct() { $this->setType(\PhpTwinfield\DimensionType::fromCode('ACT')); - + $this->setProjects(new ActivityProjects); } - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); @@ -59,4 +59,4 @@ public function setProjects(ActivityProjects $projects) $this->projects = $projects; return $this; } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/ActivityApiConnector.php b/src/ApiConnectors/ActivityApiConnector.php index aec4fdf6..fa4cd6aa 100644 --- a/src/ApiConnectors/ActivityApiConnector.php +++ b/src/ApiConnectors/ActivityApiConnector.php @@ -152,4 +152,4 @@ public function delete(string $code, Office $office): Activity return $activity; } } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/ArticleApiConnector.php b/src/ApiConnectors/ArticleApiConnector.php index ff80431d..40b6f073 100644 --- a/src/ApiConnectors/ArticleApiConnector.php +++ b/src/ApiConnectors/ArticleApiConnector.php @@ -191,4 +191,4 @@ public function delete(string $code, Office $office): Article return $article; } } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/AssetMethodApiConnector.php b/src/ApiConnectors/AssetMethodApiConnector.php index 7b114ccd..08d7f738 100644 --- a/src/ApiConnectors/AssetMethodApiConnector.php +++ b/src/ApiConnectors/AssetMethodApiConnector.php @@ -151,4 +151,4 @@ public function delete(string $code, Office $office): AssetMethod return $assetMethod; } } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/BaseApiConnector.php b/src/ApiConnectors/BaseApiConnector.php index 2becf40c..56c34886 100644 --- a/src/ApiConnectors/BaseApiConnector.php +++ b/src/ApiConnectors/BaseApiConnector.php @@ -273,4 +273,4 @@ public function testSentEqualsResponse(HasEqualInterface $apiConnector, array $s return $checkedMappedResponseCollection; } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/BookingReferenceDeletionTrait.php b/src/ApiConnectors/BookingReferenceDeletionTrait.php index 87d9ca1c..016bfd9f 100644 --- a/src/ApiConnectors/BookingReferenceDeletionTrait.php +++ b/src/ApiConnectors/BookingReferenceDeletionTrait.php @@ -25,4 +25,4 @@ public function delete(BookingReference $bookingReference, string $reason): void $response = $this->getProcessXmlService()->sendDocument($document); $response->assertSuccessful(); } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/CashBankBookApiConnector.php b/src/ApiConnectors/CashBankBookApiConnector.php index d3a22f24..5693d6db 100644 --- a/src/ApiConnectors/CashBankBookApiConnector.php +++ b/src/ApiConnectors/CashBankBookApiConnector.php @@ -50,4 +50,4 @@ public function listAll( return $this->mapListAll(CashBankBook::class, $response->data, $cashBankBookListAllTags); } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/CostCenterApiConnector.php b/src/ApiConnectors/CostCenterApiConnector.php index c777b97e..795be882 100644 --- a/src/ApiConnectors/CostCenterApiConnector.php +++ b/src/ApiConnectors/CostCenterApiConnector.php @@ -152,4 +152,4 @@ public function delete(string $code, Office $office): CostCenter return $costCenter; } } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/CountryApiConnector.php b/src/ApiConnectors/CountryApiConnector.php index b2f89b97..ab5ee1ac 100644 --- a/src/ApiConnectors/CountryApiConnector.php +++ b/src/ApiConnectors/CountryApiConnector.php @@ -50,4 +50,4 @@ public function listAll( return $this->mapListAll(Country::class, $response->data, $countryListAllTags); } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/CurrencyApiConnector.php b/src/ApiConnectors/CurrencyApiConnector.php index b1fbe62c..8bf9be06 100644 --- a/src/ApiConnectors/CurrencyApiConnector.php +++ b/src/ApiConnectors/CurrencyApiConnector.php @@ -231,4 +231,4 @@ public function delete(string $code, Office $office): Currency return $currency; } } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/CustomerApiConnector.php b/src/ApiConnectors/CustomerApiConnector.php index 06003075..243d7bcd 100644 --- a/src/ApiConnectors/CustomerApiConnector.php +++ b/src/ApiConnectors/CustomerApiConnector.php @@ -152,4 +152,4 @@ public function delete(string $code, Office $office): Customer return $customer; } } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/DimensionGroupApiConnector.php b/src/ApiConnectors/DimensionGroupApiConnector.php index 476f4ba3..d12c9a80 100644 --- a/src/ApiConnectors/DimensionGroupApiConnector.php +++ b/src/ApiConnectors/DimensionGroupApiConnector.php @@ -151,4 +151,4 @@ public function delete(string $code, Office $office): DimensionGroup return $dimensionGroup; } } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/DimensionTypeApiConnector.php b/src/ApiConnectors/DimensionTypeApiConnector.php index 2c51cc80..b7bea89d 100644 --- a/src/ApiConnectors/DimensionTypeApiConnector.php +++ b/src/ApiConnectors/DimensionTypeApiConnector.php @@ -122,4 +122,4 @@ public function listAll( return $this->mapListAll(DimensionType::class, $response->data, $dimensionTypeListAllTags); } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/ElectronicBankStatementApiConnector.php b/src/ApiConnectors/ElectronicBankStatementApiConnector.php index 2fe46275..b7ce37d0 100644 --- a/src/ApiConnectors/ElectronicBankStatementApiConnector.php +++ b/src/ApiConnectors/ElectronicBankStatementApiConnector.php @@ -48,4 +48,4 @@ public function sendAll(array $statements): void $response->assertSuccessful(); } } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/FixedAssetApiConnector.php b/src/ApiConnectors/FixedAssetApiConnector.php index 61c173b3..3dc1107f 100644 --- a/src/ApiConnectors/FixedAssetApiConnector.php +++ b/src/ApiConnectors/FixedAssetApiConnector.php @@ -151,4 +151,4 @@ public function delete(string $code, Office $office): FixedAsset return $fixedAsset; } } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/GeneralLedgerApiConnector.php b/src/ApiConnectors/GeneralLedgerApiConnector.php index e6130b16..ceec9c4e 100644 --- a/src/ApiConnectors/GeneralLedgerApiConnector.php +++ b/src/ApiConnectors/GeneralLedgerApiConnector.php @@ -154,4 +154,4 @@ public function delete(string $code, string $dimType, Office $office): GeneralLe return $generalLedger; } } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/HasEqualInterface.php b/src/ApiConnectors/HasEqualInterface.php index de5bf60f..4efaa027 100644 --- a/src/ApiConnectors/HasEqualInterface.php +++ b/src/ApiConnectors/HasEqualInterface.php @@ -13,8 +13,8 @@ interface HasEqualInterface { public function testEqual(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): array; - + public function sendAll(array $objects, bool $reSend): MappedResponseCollection; - + public function getMappedResponse(HasMessageInterface $object): IndividualMappedResponse; -} \ No newline at end of file +} diff --git a/src/ApiConnectors/InvoiceTypeApiConnector.php b/src/ApiConnectors/InvoiceTypeApiConnector.php index 4f47e8c6..71f448e1 100644 --- a/src/ApiConnectors/InvoiceTypeApiConnector.php +++ b/src/ApiConnectors/InvoiceTypeApiConnector.php @@ -84,4 +84,4 @@ public function getInvoiceTypeVatType( return 'exclusive'; } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/MatchesApiConnector.php b/src/ApiConnectors/MatchesApiConnector.php index ddc74fa4..8c03384f 100644 --- a/src/ApiConnectors/MatchesApiConnector.php +++ b/src/ApiConnectors/MatchesApiConnector.php @@ -53,4 +53,4 @@ public function sendAll(array $matchSets): MappedResponseCollection return MatchSetMapper::map($subResponse->getResponseDocument()); }); } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/PayCodeApiConnector.php b/src/ApiConnectors/PayCodeApiConnector.php index c437dcb9..0837b9cd 100644 --- a/src/ApiConnectors/PayCodeApiConnector.php +++ b/src/ApiConnectors/PayCodeApiConnector.php @@ -50,4 +50,4 @@ public function listAll( return $this->mapListAll(PayCode::class, $response->data, $payCodeListAllTags); } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/ProjectApiConnector.php b/src/ApiConnectors/ProjectApiConnector.php index bfb00e30..5a9b2639 100644 --- a/src/ApiConnectors/ProjectApiConnector.php +++ b/src/ApiConnectors/ProjectApiConnector.php @@ -152,4 +152,4 @@ public function delete(string $code, Office $office): Project return $project; } } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/RateApiConnector.php b/src/ApiConnectors/RateApiConnector.php index bbdce09a..93527ebe 100644 --- a/src/ApiConnectors/RateApiConnector.php +++ b/src/ApiConnectors/RateApiConnector.php @@ -192,4 +192,4 @@ public function delete(string $code, Office $office): Rate return $rate; } } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/SupplierApiConnector.php b/src/ApiConnectors/SupplierApiConnector.php index b638ba6f..d25f5a22 100644 --- a/src/ApiConnectors/SupplierApiConnector.php +++ b/src/ApiConnectors/SupplierApiConnector.php @@ -152,4 +152,4 @@ public function delete(string $code, Office $office): Supplier return $supplier; } } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/TransactionApiConnector.php b/src/ApiConnectors/TransactionApiConnector.php index af7fbd8a..1678d2c7 100644 --- a/src/ApiConnectors/TransactionApiConnector.php +++ b/src/ApiConnectors/TransactionApiConnector.php @@ -89,4 +89,4 @@ public function sendAll(array $transactions): MappedResponseCollection return TransactionMapper::map($classname, $subresponse, $this->getConnection()); }); } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/UserRoleApiConnector.php b/src/ApiConnectors/UserRoleApiConnector.php index cbbb395b..dab89984 100644 --- a/src/ApiConnectors/UserRoleApiConnector.php +++ b/src/ApiConnectors/UserRoleApiConnector.php @@ -50,4 +50,4 @@ public function listAll( return $this->mapListAll(UserRole::class, $response->data, $userRoleListAllTags); } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/VatCodeApiConnector.php b/src/ApiConnectors/VatCodeApiConnector.php index 918ece6f..579431f2 100644 --- a/src/ApiConnectors/VatCodeApiConnector.php +++ b/src/ApiConnectors/VatCodeApiConnector.php @@ -193,4 +193,4 @@ public function delete(string $code, Office $office): VatCode return $vatCode; } } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/VatGroupApiConnector.php b/src/ApiConnectors/VatGroupApiConnector.php index 4de5923c..e9373f33 100644 --- a/src/ApiConnectors/VatGroupApiConnector.php +++ b/src/ApiConnectors/VatGroupApiConnector.php @@ -50,4 +50,4 @@ public function listAll( return $this->mapListAll(VatGroup::class, $response->data, $vatGroupListAllTags); } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/VatGroupCountryApiConnector.php b/src/ApiConnectors/VatGroupCountryApiConnector.php index 3431380a..059ba088 100644 --- a/src/ApiConnectors/VatGroupCountryApiConnector.php +++ b/src/ApiConnectors/VatGroupCountryApiConnector.php @@ -50,4 +50,4 @@ public function listAll( return $this->mapListAll(VatGroupCountry::class, $response->data, $vatGroupCountryListAllTags); } -} \ No newline at end of file +} diff --git a/src/Article.php b/src/Article.php index 25376b02..66abf84c 100644 --- a/src/Article.php +++ b/src/Article.php @@ -54,7 +54,7 @@ public function __construct() $this->setPercentage(false); $this->setType(\PhpTwinfield\Enums\ArticleType::NORMAL()); } - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); @@ -82,22 +82,22 @@ public function removeLine($index) return false; } } - + public function removeLineByID($id) { $found = false; - + foreach ($this->lines as $index => $line) { if ($id == $line->getID()) { unset($this->lines[$index]); $found = true; } } - + if ($found) { return true; } - + return false; } } diff --git a/src/ArticleLine.php b/src/ArticleLine.php index 5c5a9ebe..fd166dc7 100644 --- a/src/ArticleLine.php +++ b/src/ArticleLine.php @@ -33,7 +33,7 @@ class ArticleLine extends BaseObject use UnitsField; use UnitsPriceExclField; use UnitsPriceIncField; - + public static function fromCode(string $code) { $instance = new self; $instance->setSubCode($code); diff --git a/src/AssetMethod.php b/src/AssetMethod.php index 1155fd38..01870a6d 100644 --- a/src/AssetMethod.php +++ b/src/AssetMethod.php @@ -48,7 +48,7 @@ public function __construct() $this->setBalanceAccounts(new AssetMethodBalanceAccounts); $this->setProfitLossAccounts(new AssetMethodProfitLossAccounts); } - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); @@ -98,22 +98,22 @@ public function removeFreeText($index) return false; } } - + public function removeFreeTextByID($id) { $found = false; - + foreach ($this->freeTexts as $index => $freeText) { if ($id == $freeText->getID()) { unset($this->freeTexts[$index]); $found = true; } } - + if ($found) { return true; } - + return false; } } diff --git a/src/BaseObject.php b/src/BaseObject.php index 424be098..d756fcf4 100644 --- a/src/BaseObject.php +++ b/src/BaseObject.php @@ -35,7 +35,7 @@ public function addMessage(Message $message): void { $this->messages[] = $message; } - + public function setMessages($messages) { $this->messages = $messages; diff --git a/src/BaseTransaction.php b/src/BaseTransaction.php index 9490f81c..541af34b 100644 --- a/src/BaseTransaction.php +++ b/src/BaseTransaction.php @@ -47,4 +47,4 @@ public function getBookingReference(): BookingReference { return new BookingReference($this->office, $this->code, $this->number); } -} \ No newline at end of file +} diff --git a/src/BookingReference.php b/src/BookingReference.php index 4a37bcfa..fd6c910b 100644 --- a/src/BookingReference.php +++ b/src/BookingReference.php @@ -57,4 +57,4 @@ public function getNumber(): int { return $this->number; } -} \ No newline at end of file +} diff --git a/src/BookingReferenceInterface.php b/src/BookingReferenceInterface.php index 0a8cb7df..26a54c75 100644 --- a/src/BookingReferenceInterface.php +++ b/src/BookingReferenceInterface.php @@ -27,4 +27,4 @@ public function getCode(): string; * References the transaction. */ public function getNumber(): int; -} \ No newline at end of file +} diff --git a/src/CashBankBook.php b/src/CashBankBook.php index 3cc46610..287e0c80 100644 --- a/src/CashBankBook.php +++ b/src/CashBankBook.php @@ -16,11 +16,11 @@ class CashBankBook extends BaseObject implements HasCodeInterface use CodeField; use NameField; use ShortNameField; - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); return $instance; } -} \ No newline at end of file +} diff --git a/src/CostCenter.php b/src/CostCenter.php index ffd6028f..7cf6017d 100644 --- a/src/CostCenter.php +++ b/src/CostCenter.php @@ -35,7 +35,7 @@ public function __construct() { $this->setType(\PhpTwinfield\DimensionType::fromCode('KPL')); } - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); diff --git a/src/Country.php b/src/Country.php index 3ac76be1..4fd9bbe9 100644 --- a/src/Country.php +++ b/src/Country.php @@ -16,11 +16,11 @@ class Country extends BaseObject implements HasCodeInterface use CodeField; use NameField; use ShortNameField; - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); return $instance; } -} \ No newline at end of file +} diff --git a/src/Currency.php b/src/Currency.php index 203d9ac9..9538eb8c 100644 --- a/src/Currency.php +++ b/src/Currency.php @@ -21,7 +21,7 @@ class Currency extends BaseObject implements HasCodeInterface use StatusField; private $rates = []; - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); diff --git a/src/Customer.php b/src/Customer.php index 4c989397..e5ca8bbd 100644 --- a/src/Customer.php +++ b/src/Customer.php @@ -72,7 +72,7 @@ public function __construct() $this->setCreditManagement(new CustomerCreditManagement); $this->setFinancials(new CustomerFinancials); } - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); @@ -122,22 +122,22 @@ public function removeAddress($index) return false; } } - + public function removeAddressByID($id) { $found = false; - + foreach ($this->addresses as $index => $address) { if ($id == $address->getID()) { unset($this->addresses[$index]); $found = true; } } - + if ($found) { return true; } - + return false; } @@ -161,22 +161,22 @@ public function removeBank($index) return false; } } - + public function removeBankByID($id) { $found = false; - + foreach ($this->banks as $index => $bank) { if ($id == $bank->getID()) { unset($this->banks[$index]); $found = true; } } - + if ($found) { return true; } - + return false; } @@ -200,22 +200,22 @@ public function removePostingRule($index) return false; } } - + public function removePostingRuleByID($id) { $found = false; - + foreach ($this->postingRules as $index => $postingRule) { if ($id == $postingRule->getID()) { unset($this->postingRules[$index]); $found = true; } } - + if ($found) { return true; } - + return false; } } diff --git a/src/DomDocuments/ActivitiesDocument.php b/src/DomDocuments/ActivitiesDocument.php index 24d7d3e8..16425c64 100644 --- a/src/DomDocuments/ActivitiesDocument.php +++ b/src/DomDocuments/ActivitiesDocument.php @@ -42,7 +42,7 @@ public function addActivity(Activity $activity) if (!empty($status)) { $activityElement->setAttribute('status', $status); } - + if (!empty($activity->getCode())) { $activityElement->appendChild($this->createNodeWithTextContent('code', $activity->getCode())); } @@ -110,4 +110,4 @@ public function addActivity(Activity $activity) } } } -} \ No newline at end of file +} diff --git a/src/DomDocuments/BookingReferenceDeletionDocument.php b/src/DomDocuments/BookingReferenceDeletionDocument.php index 839b43b5..3f5fb33e 100644 --- a/src/DomDocuments/BookingReferenceDeletionDocument.php +++ b/src/DomDocuments/BookingReferenceDeletionDocument.php @@ -29,4 +29,4 @@ public function __construct(BookingReference $bookingReference, string $reason) $this->createNodeWithTextContent("number", $bookingReference->getNumber()) ); } -} \ No newline at end of file +} diff --git a/src/DomDocuments/CostCentersDocument.php b/src/DomDocuments/CostCentersDocument.php index 1e709f77..c62c2a41 100644 --- a/src/DomDocuments/CostCentersDocument.php +++ b/src/DomDocuments/CostCentersDocument.php @@ -42,7 +42,7 @@ public function addCostCenter(CostCenter $costCenter) if (!empty($status)) { $costCenterElement->setAttribute('status', $status); } - + if (!empty($costCenter->getCode())) { $costCenterElement->appendChild($this->createNodeWithTextContent('code', $costCenter->getCode())); } diff --git a/src/DomDocuments/CustomersDocument.php b/src/DomDocuments/CustomersDocument.php index a6ef0058..54f0e52f 100644 --- a/src/DomDocuments/CustomersDocument.php +++ b/src/DomDocuments/CustomersDocument.php @@ -288,4 +288,4 @@ public function addCustomer(Customer $customer) $paymentconditionElement->appendChild($this->createNodeWithTextContent('discountdays', $customer->getPaymentConditionDiscountDays())); $paymentconditionElement->appendChild($this->createNodeWithTextContent('discountpercentage', $customer->getPaymentConditionDiscountPercentage())); } -} \ No newline at end of file +} diff --git a/src/DomDocuments/ElectronicBankStatementDocument.php b/src/DomDocuments/ElectronicBankStatementDocument.php index b805dd27..ea2f8200 100644 --- a/src/DomDocuments/ElectronicBankStatementDocument.php +++ b/src/DomDocuments/ElectronicBankStatementDocument.php @@ -67,4 +67,4 @@ public function addStatement(ElectronicBankStatement $electronicBankStatement) $statement->appendChild($transactions); $this->rootElement->appendChild($statement); } -} \ No newline at end of file +} diff --git a/src/DomDocuments/GeneralLedgersDocument.php b/src/DomDocuments/GeneralLedgersDocument.php index 9b10f1a7..b0c10549 100644 --- a/src/DomDocuments/GeneralLedgersDocument.php +++ b/src/DomDocuments/GeneralLedgersDocument.php @@ -45,11 +45,11 @@ public function addGeneralLedger(GeneralLedger $generalLedger) $generalLedgerElement->appendChild($this->createNodeWithTextContent('beginperiod', $generalLedger->getBeginPeriod())); $generalLedgerElement->appendChild($this->createNodeWithTextContent('beginyear', $generalLedger->getBeginYear())); - + if (!empty($generalLedger->getCode())) { $generalLedgerElement->appendChild($this->createNodeWithTextContent('code', $generalLedger->getCode())); } - + $generalLedgerElement->appendChild($this->createNodeWithTextContent('endperiod', $generalLedger->getEndPeriod())); $generalLedgerElement->appendChild($this->createNodeWithTextContent('endyear', $generalLedger->getEndYear())); $generalLedgerElement->appendChild($this->createNodeWithTextContent('name', $generalLedger->getName())); diff --git a/src/DomDocuments/InvoicesDocument.php b/src/DomDocuments/InvoicesDocument.php index 7485e949..62edba08 100644 --- a/src/DomDocuments/InvoicesDocument.php +++ b/src/DomDocuments/InvoicesDocument.php @@ -67,11 +67,11 @@ public function addInvoice(Invoice $invoice, AuthenticatedConnection $connection $headerElement->appendChild($this->createNodeWithTextContent('headertext', $invoice->getHeaderText())); $headerElement->appendChild($this->createNodeWithTextContent('invoiceaddressnumber', $invoice->getInvoiceAddressNumber())); $headerElement->appendChild($this->createNodeWithTextContent('invoicedate', Util::formatDate($invoice->getInvoiceDate()))); - + if (!empty($invoice->getInvoiceNumber())) { $headerElement->appendChild($this->createNodeWithTextContent('invoicenumber', $invoice->getInvoiceNumber())); } - + $headerElement->appendChild($this->createNodeWithTextContent('invoicetype', Util::objectToStr($invoice->getInvoiceType()))); $headerElement->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($invoice->getOffice()))); $headerElement->appendChild($this->createNodeWithTextContent('paymentmethod', $invoice->getPaymentMethod())); @@ -134,4 +134,4 @@ public function addInvoice(Invoice $invoice, AuthenticatedConnection $connection } } } -} \ No newline at end of file +} diff --git a/src/DomDocuments/MatchDocument.php b/src/DomDocuments/MatchDocument.php index 4108b116..bec3c9f0 100644 --- a/src/DomDocuments/MatchDocument.php +++ b/src/DomDocuments/MatchDocument.php @@ -59,4 +59,4 @@ protected function getRootTagName(): string { return "match"; } -} \ No newline at end of file +} diff --git a/src/DomDocuments/ProjectsDocument.php b/src/DomDocuments/ProjectsDocument.php index 5036a927..4a777bd3 100644 --- a/src/DomDocuments/ProjectsDocument.php +++ b/src/DomDocuments/ProjectsDocument.php @@ -42,11 +42,11 @@ public function addProject(Project $project) if (!empty($status)) { $projectElement->setAttribute('status', $status); } - + if (!empty($project->getCode())) { $projectElement->appendChild($this->createNodeWithTextContent('code', $project->getCode())); } - + $projectElement->appendChild($this->createNodeWithTextContent('name', $project->getName())); $projectElement->appendChild($this->createNodeWithTextContent('office', Util::objectToStr($project->getOffice()))); $projectElement->appendChild($this->createNodeWithTextContent('shortname', $project->getShortName())); @@ -110,4 +110,4 @@ public function addProject(Project $project) } } } -} \ No newline at end of file +} diff --git a/src/DomDocuments/SuppliersDocument.php b/src/DomDocuments/SuppliersDocument.php index bdf3885e..bca24128 100644 --- a/src/DomDocuments/SuppliersDocument.php +++ b/src/DomDocuments/SuppliersDocument.php @@ -45,11 +45,11 @@ public function addSupplier(Supplier $supplier) $supplierElement->appendChild($this->createNodeWithTextContent('beginperiod', $supplier->getBeginPeriod())); $supplierElement->appendChild($this->createNodeWithTextContent('beginyear', $supplier->getBeginYear())); - + if (!empty($supplier->getCode())) { $supplierElement->appendChild($this->createNodeWithTextContent('code', $supplier->getCode())); } - + $supplierElement->appendChild($this->createNodeWithTextContent('endperiod', $supplier->getEndPeriod())); $supplierElement->appendChild($this->createNodeWithTextContent('endyear', $supplier->getEndYear())); $supplierElement->appendChild($this->createNodeWithTextContent('name', $supplier->getName())); diff --git a/src/DomDocuments/TransactionsDocument.php b/src/DomDocuments/TransactionsDocument.php index c7bc0aeb..e9efc571 100644 --- a/src/DomDocuments/TransactionsDocument.php +++ b/src/DomDocuments/TransactionsDocument.php @@ -153,15 +153,15 @@ public function addTransaction(BaseTransaction $transaction) if (Util::objectUses(BaselineField::class, $transactionLine) && !empty($transactionLine->getBaseline())) { $lineElement->appendChild($this->createNodeWithTextContent('baseline', $transactionLine->getBaseline())); } - + if (!empty($transactionLine->getBaseValue())) { $lineElement->appendChild($this->createNodeWithTextContent('basevalue', Util::formatMoney($transactionLine->getBaseValue()))); } - + if (!empty($transactionLine->getComment())) { $lineElement->appendChild($this->createNodeWithTextContent('comment', $transactionLine->getComment())); } - + if (Util::objectUses(CurrencyDateField::class, $transactionLine) && !empty($transactionLine->getCurrencyDate())) { $lineElement->appendChild($this->createNodeWithTextContent("currencydate", Util::formatDate($transactionLine->getCurrencyDate()))); } @@ -169,7 +169,7 @@ public function addTransaction(BaseTransaction $transaction) if (!empty($transactionLine->getDescription())) { $lineElement->appendChild($this->createNodeWithTextContent('description', $transactionLine->getDescription())); } - + if (!empty($transactionLine->getDestOffice())) { $lineElement->appendChild($this->createNodeWithTextContent('destoffice', Util::objectToStr($transactionLine->getDestOffice()))); } @@ -197,27 +197,27 @@ public function addTransaction(BaseTransaction $transaction) if (Util::objectUses(PerformanceVatNumberField::class, $transactionLine) && !empty($transactionLine->getPerformanceVatNumber())) { $lineElement->appendChild($this->createNodeWithTextContent('performancevatnumber', $transactionLine->getPerformanceVatNumber())); } - + if (!empty($transactionLine->getRate())) { $lineElement->appendChild($this->createNodeWithTextContent('rate', $transactionLine->getRate())); } - + if (!empty($transactionLine->getRepRate())) { $lineElement->appendChild($this->createNodeWithTextContent('reprate', $transactionLine->getRepRate())); } - + if (!empty($transactionLine->getRepValue())) { $lineElement->appendChild($this->createNodeWithTextContent('repvalue', Util::formatMoney($transactionLine->getRepValue()))); } - + if (Util::objectUses(VatBaseTotalField::class, $transactionLine) && !empty($transactionLine->getVatBaseTotal())) { $lineElement->appendChild($this->createNodeWithTextContent('vatbasetotal', Util::formatMoney($transactionLine->getVatBaseTotal()))); } - + if (!empty($transactionLine->getVatBaseTurnover())) { $lineElement->appendChild($this->createNodeWithTextContent('vatbaseturnover', Util::formatMoney($transactionLine->getVatBaseTurnover()))); } - + if (!empty($transactionLine->getVatBaseValue())) { $lineElement->appendChild($this->createNodeWithTextContent('vatbasevalue', Util::formatMoney($transactionLine->getVatBaseValue()))); } @@ -225,15 +225,15 @@ public function addTransaction(BaseTransaction $transaction) if (!empty($transactionLine->getVatCode())) { $lineElement->appendChild($this->createNodeWithTextContent('vatcode', Util::objectToStr($transactionLine->getVatCode()))); } - + if (Util::objectUses(VatRepTotalField::class, $transactionLine) && !empty($transactionLine->getVatRepTotal())) { $lineElement->appendChild($this->createNodeWithTextContent('vatreptotal', Util::formatMoney($transactionLine->getVatRepTotal()))); } - + if (!empty($transactionLine->getVatRepValue())) { $lineElement->appendChild($this->createNodeWithTextContent('vatrepvalue', Util::formatMoney($transactionLine->getVatRepValue()))); } - + if (!empty($transactionLine->getVatRepTurnover())) { $lineElement->appendChild($this->createNodeWithTextContent('vatrepturnover', Util::formatMoney($transactionLine->getVatRepTurnover()))); } @@ -241,11 +241,11 @@ public function addTransaction(BaseTransaction $transaction) if (Util::objectUses(VatTotalField::class, $transactionLine) && !empty($transactionLine->getVatTotal())) { $lineElement->appendChild($this->createNodeWithTextContent('vattotal', Util::formatMoney($transactionLine->getVatTotal()))); } - + if (!empty($transactionLine->getVatTurnover())) { $lineElement->appendChild($this->createNodeWithTextContent('vatturnover', Util::formatMoney($transactionLine->getVatTurnover()))); } - + if (!empty($transactionLine->getVatValue())) { $lineElement->appendChild($this->createNodeWithTextContent('vatvalue', Util::formatMoney($transactionLine->getVatValue()))); } diff --git a/src/DomDocuments/VatCodesDocument.php b/src/DomDocuments/VatCodesDocument.php index a06e0f33..43a223b7 100644 --- a/src/DomDocuments/VatCodesDocument.php +++ b/src/DomDocuments/VatCodesDocument.php @@ -59,9 +59,9 @@ public function addVatCode(VatCode $vatCode) // Makes percentage element $percentageElement = $this->createElement('percentage'); $percentagesElement->appendChild($percentageElement); - + $status = $percentage->getStatus(); - + if (!empty($status)) { $percentageElement->setAttribute('status', $status); } diff --git a/src/Enums/AccountType.php b/src/Enums/AccountType.php index 7379b703..210449d3 100644 --- a/src/Enums/AccountType.php +++ b/src/Enums/AccountType.php @@ -16,4 +16,4 @@ class AccountType extends Enum public const EMPTY = ''; public const INHERIT = 'inherit'; public const PROFITANDLOSS = 'profitandloss'; -} \ No newline at end of file +} diff --git a/src/Enums/AddressType.php b/src/Enums/AddressType.php index d0743156..de97b5e5 100644 --- a/src/Enums/AddressType.php +++ b/src/Enums/AddressType.php @@ -16,4 +16,4 @@ class AddressType extends Enum public const EMPTY = ''; public const INVOICE = 'invoice'; public const POSTAL = 'postal'; -} \ No newline at end of file +} diff --git a/src/Enums/ArticleType.php b/src/Enums/ArticleType.php index 528f1033..9189f18c 100644 --- a/src/Enums/ArticleType.php +++ b/src/Enums/ArticleType.php @@ -16,4 +16,4 @@ class ArticleType extends Enum public const EMPTY = ""; public const NORMAL = "normal"; public const PREMIUM = "premium"; -} \ No newline at end of file +} diff --git a/src/Enums/Behaviour.php b/src/Enums/Behaviour.php index 4d13e18b..abe34fb1 100644 --- a/src/Enums/Behaviour.php +++ b/src/Enums/Behaviour.php @@ -16,4 +16,4 @@ class Behaviour extends Enum public const NORMAL = 'normal'; public const SYSTEM = 'system'; public const TEMPLATE = 'template'; -} \ No newline at end of file +} diff --git a/src/Enums/BlockedAccountPaymentConditionsIncludeVat.php b/src/Enums/BlockedAccountPaymentConditionsIncludeVat.php index 9fdb40c3..9312a7a2 100644 --- a/src/Enums/BlockedAccountPaymentConditionsIncludeVat.php +++ b/src/Enums/BlockedAccountPaymentConditionsIncludeVat.php @@ -14,4 +14,4 @@ class BlockedAccountPaymentConditionsIncludeVat extends Enum public const EMPTY = ''; public const FALSE = 'false'; public const TRUE = 'true'; -} \ No newline at end of file +} diff --git a/src/Enums/BrowseColumnOperator.php b/src/Enums/BrowseColumnOperator.php index d3c23433..8ec0373c 100644 --- a/src/Enums/BrowseColumnOperator.php +++ b/src/Enums/BrowseColumnOperator.php @@ -16,4 +16,4 @@ class BrowseColumnOperator extends Enum public const EMPTY = ''; public const EQUAL = 'equal'; public const NONE = 'none'; -} \ No newline at end of file +} diff --git a/src/Enums/CalcMethod.php b/src/Enums/CalcMethod.php index 17916f72..418c98d7 100644 --- a/src/Enums/CalcMethod.php +++ b/src/Enums/CalcMethod.php @@ -18,4 +18,4 @@ class CalcMethod extends Enum public const LINEARPERCENTAGE = "linearpercentage"; public const NONE = "none"; public const REDUCEBALANCE = "reducebalance"; -} \ No newline at end of file +} diff --git a/src/Enums/ChildValidationType.php b/src/Enums/ChildValidationType.php index a8afb00a..fa1965cb 100644 --- a/src/Enums/ChildValidationType.php +++ b/src/Enums/ChildValidationType.php @@ -16,4 +16,4 @@ class ChildValidationType extends Enum public const EMPTY = ""; public const GROUP = "group"; public const TYPE = "type"; -} \ No newline at end of file +} diff --git a/src/Enums/CollectionSchema.php b/src/Enums/CollectionSchema.php index 98f88624..19a5e7c2 100644 --- a/src/Enums/CollectionSchema.php +++ b/src/Enums/CollectionSchema.php @@ -14,4 +14,4 @@ class CollectionSchema extends Enum public const B2B = "b2b"; public const CORE = "core"; public const EMPTY = ""; -} \ No newline at end of file +} diff --git a/src/Enums/Culture.php b/src/Enums/Culture.php index 4e09253c..1aac34a6 100644 --- a/src/Enums/Culture.php +++ b/src/Enums/Culture.php @@ -24,4 +24,4 @@ class Culture extends Enum public const FRANCAIS = "fr-FR"; public const MAGYAR = "hu-HU"; public const NEDERLANDS = "nl-NL"; -} \ No newline at end of file +} diff --git a/src/Enums/DebitCredit.php b/src/Enums/DebitCredit.php index 7b5102cf..b07d8ea0 100644 --- a/src/Enums/DebitCredit.php +++ b/src/Enums/DebitCredit.php @@ -20,4 +20,4 @@ final public function invert(): self } return self::DEBIT(); } -} \ No newline at end of file +} diff --git a/src/Enums/DepreciateReconciliation.php b/src/Enums/DepreciateReconciliation.php index 7b6794d9..2f908ab9 100644 --- a/src/Enums/DepreciateReconciliation.php +++ b/src/Enums/DepreciateReconciliation.php @@ -14,4 +14,4 @@ class DepreciateReconciliation extends Enum public const EMPTY = ""; public const FROMPURCHASEDATE = "from_purchase_date"; public const FROMRECONCILIATION = "from_reconciliation"; -} \ No newline at end of file +} diff --git a/src/Enums/Destiny.php b/src/Enums/Destiny.php index 397a2dcd..695cdb0f 100644 --- a/src/Enums/Destiny.php +++ b/src/Enums/Destiny.php @@ -14,4 +14,4 @@ class Destiny extends Enum public const EMPTY = ''; public const FINAL = 'final'; public const TEMPORARY = 'temporary'; // Also called 'provisional' -} \ No newline at end of file +} diff --git a/src/Enums/FixedAssetsStatus.php b/src/Enums/FixedAssetsStatus.php index 2059b1dc..b5685ee4 100644 --- a/src/Enums/FixedAssetsStatus.php +++ b/src/Enums/FixedAssetsStatus.php @@ -18,4 +18,4 @@ class FixedAssetsStatus extends Enum public const INACTIVE = "inactive"; public const SOLD = "sold"; public const TOBEACTIVATED = "tobeactivated"; -} \ No newline at end of file +} diff --git a/src/Enums/FreeTextType.php b/src/Enums/FreeTextType.php index 6be1e5a3..ae69eceb 100644 --- a/src/Enums/FreeTextType.php +++ b/src/Enums/FreeTextType.php @@ -14,4 +14,4 @@ class FreeTextType extends Enum public const AMOUNT = 'amount'; public const EMPTY = ''; public const TEXT = 'text'; -} \ No newline at end of file +} diff --git a/src/Enums/InvoiceDebitCredit.php b/src/Enums/InvoiceDebitCredit.php index 603aa86c..ecb707f3 100644 --- a/src/Enums/InvoiceDebitCredit.php +++ b/src/Enums/InvoiceDebitCredit.php @@ -14,4 +14,4 @@ class InvoiceDebitCredit extends Enum public const CREDIT = "C"; public const DEBIT = "D"; public const EMPTY = ""; -} \ No newline at end of file +} diff --git a/src/Enums/InvoiceStatus.php b/src/Enums/InvoiceStatus.php index 21a58aeb..181d7277 100644 --- a/src/Enums/InvoiceStatus.php +++ b/src/Enums/InvoiceStatus.php @@ -16,4 +16,4 @@ class InvoiceStatus extends Enum public const DEFAULT = "default"; public const EMPTY = ""; public const FINAL = "final"; -} \ No newline at end of file +} diff --git a/src/Enums/LineType.php b/src/Enums/LineType.php index 70c4036b..cbde46b5 100644 --- a/src/Enums/LineType.php +++ b/src/Enums/LineType.php @@ -16,4 +16,4 @@ class LineType extends Enum public const EMPTY = ""; public const TOTAL = "total"; public const VAT = "vat"; -} \ No newline at end of file +} diff --git a/src/Enums/MatchCode.php b/src/Enums/MatchCode.php index d85a8d04..d4905017 100644 --- a/src/Enums/MatchCode.php +++ b/src/Enums/MatchCode.php @@ -23,4 +23,4 @@ final class MatchCode extends Enum private const PROJECTS = "370"; private const SUPPLIERS = "270"; private const SUSPENSE_ACCOUNTS = "070"; -} \ No newline at end of file +} diff --git a/src/Enums/MatchStatus.php b/src/Enums/MatchStatus.php index 4711a518..e892ca69 100644 --- a/src/Enums/MatchStatus.php +++ b/src/Enums/MatchStatus.php @@ -20,4 +20,4 @@ class MatchStatus extends Enum public const MATCHED = "matched"; public const NOTMATCHABLE = "notmatchable"; public const PROPOSED = "proposed"; -} \ No newline at end of file +} diff --git a/src/Enums/MatchType.php b/src/Enums/MatchType.php index 0ac1a0d1..f28cde23 100644 --- a/src/Enums/MatchType.php +++ b/src/Enums/MatchType.php @@ -17,4 +17,4 @@ class MatchType extends Enum public const MATCHABLE = "matchable"; public const NOTMATCHABLE = "notmatchable"; -} \ No newline at end of file +} diff --git a/src/Enums/MeansOfPayment.php b/src/Enums/MeansOfPayment.php index d4bb5193..6d18179e 100644 --- a/src/Enums/MeansOfPayment.php +++ b/src/Enums/MeansOfPayment.php @@ -16,4 +16,4 @@ class MeansOfPayment extends Enum public const EMPTY = ''; public const NONE = 'none'; public const PAYMENTFILE = 'paymentfile'; -} \ No newline at end of file +} diff --git a/src/Enums/Order.php b/src/Enums/Order.php index b9cf06f8..f6f89a18 100644 --- a/src/Enums/Order.php +++ b/src/Enums/Order.php @@ -12,4 +12,4 @@ class Order extends Enum { public const ASCENDING = 'ascending'; public const DESCENDING = 'descending'; -} \ No newline at end of file +} diff --git a/src/Enums/PaymentMethod.php b/src/Enums/PaymentMethod.php index 47e2ef53..06fea028 100644 --- a/src/Enums/PaymentMethod.php +++ b/src/Enums/PaymentMethod.php @@ -20,4 +20,4 @@ class PaymentMethod extends Enum public const CHEQUE = 'cheque'; public const DA = 'da'; public const EMPTY = ''; -} \ No newline at end of file +} diff --git a/src/Enums/PerformanceType.php b/src/Enums/PerformanceType.php index 62238c14..ae712795 100644 --- a/src/Enums/PerformanceType.php +++ b/src/Enums/PerformanceType.php @@ -14,4 +14,4 @@ class PerformanceType extends Enum public const EMPTY = ""; public const GOODS = "goods"; public const SERVICES = "services"; -} \ No newline at end of file +} diff --git a/src/Enums/RateType.php b/src/Enums/RateType.php index bc7086c6..f3a9b5aa 100644 --- a/src/Enums/RateType.php +++ b/src/Enums/RateType.php @@ -14,4 +14,4 @@ class RateType extends Enum public const EMPTY = ""; public const QUANTITY = "quantity"; public const TIME = "time"; -} \ No newline at end of file +} diff --git a/src/Enums/Regime.php b/src/Enums/Regime.php index 518f50a5..8469e27e 100644 --- a/src/Enums/Regime.php +++ b/src/Enums/Regime.php @@ -18,4 +18,4 @@ class Regime extends Enum public const EMPTY = ''; public const FISCAL = 'Fiscal'; public const GENERIC = 'Generic'; -} \ No newline at end of file +} diff --git a/src/Enums/RemittanceAdviceSendType.php b/src/Enums/RemittanceAdviceSendType.php index f7b0fdc0..87554067 100644 --- a/src/Enums/RemittanceAdviceSendType.php +++ b/src/Enums/RemittanceAdviceSendType.php @@ -14,4 +14,4 @@ class RemittanceAdviceSendType extends Enum public const BYEMAIL = 'ByEmail'; public const EMPTY = ''; public const TOFILEMANAGER = 'ToFileManager'; -} \ No newline at end of file +} diff --git a/src/Enums/SendReminder.php b/src/Enums/SendReminder.php index e95ed053..7f12b3b1 100644 --- a/src/Enums/SendReminder.php +++ b/src/Enums/SendReminder.php @@ -16,4 +16,4 @@ class SendReminder extends Enum public const EMPTY = ""; public const FALSE = "false"; public const TRUE = "true"; -} \ No newline at end of file +} diff --git a/src/Enums/Services.php b/src/Enums/Services.php index 8f30bd9b..cc3835c2 100644 --- a/src/Enums/Services.php +++ b/src/Enums/Services.php @@ -28,4 +28,4 @@ class Services extends \MyCLabs\Enum\Enum * Twinfield Process XML web service methods. See below for an overview of the supported XML messages. */ public const PROCESSXML = ProcessXmlService::class; -} \ No newline at end of file +} diff --git a/src/Enums/Status.php b/src/Enums/Status.php index afa049c3..ab6baf57 100644 --- a/src/Enums/Status.php +++ b/src/Enums/Status.php @@ -16,4 +16,4 @@ class Status extends Enum public const DELETED = 'deleted'; public const EMPTY = ''; public const HIDDEN = 'hide'; -} \ No newline at end of file +} diff --git a/src/Enums/SubAnalyse.php b/src/Enums/SubAnalyse.php index c3bb5462..0e851fb5 100644 --- a/src/Enums/SubAnalyse.php +++ b/src/Enums/SubAnalyse.php @@ -16,4 +16,4 @@ class SubAnalyse extends Enum public const FALSE = 'false'; public const MAYBE = 'maybe'; public const TRUE = 'true'; -} \ No newline at end of file +} diff --git a/src/Enums/UserType.php b/src/Enums/UserType.php index 7542dc72..14d2f50f 100644 --- a/src/Enums/UserType.php +++ b/src/Enums/UserType.php @@ -16,4 +16,4 @@ class UserType extends Enum public const ACCOUNTANTCUSTOMER = 'accountantcustomer'; public const EMPTY = ''; public const REGULAR = 'regular'; -} \ No newline at end of file +} diff --git a/src/Enums/VatType.php b/src/Enums/VatType.php index f07a1bc3..7637de40 100644 --- a/src/Enums/VatType.php +++ b/src/Enums/VatType.php @@ -14,4 +14,4 @@ class VatType extends Enum public const EMPTY = ""; public const PURCHASE = "purchase"; public const SALES = "sales"; -} \ No newline at end of file +} diff --git a/src/Enums/WriteOffType.php b/src/Enums/WriteOffType.php index 48979bb1..6fce82ca 100644 --- a/src/Enums/WriteOffType.php +++ b/src/Enums/WriteOffType.php @@ -22,4 +22,4 @@ final class WriteOffType extends Enum private const DISCOUNT = "discount"; private const EMPTY = ""; private const WRITEOFF = "writeoff"; -} \ No newline at end of file +} diff --git a/src/Fields/AssetMethod/AssetsToActivateField.php b/src/Fields/AssetMethod/AssetsToActivateField.php index 857542ab..f1560c67 100644 --- a/src/Fields/AssetMethod/AssetsToActivateField.php +++ b/src/Fields/AssetMethod/AssetsToActivateField.php @@ -30,4 +30,4 @@ public function setAssetsToActivate(?GeneralLedger $assetsToActivate): self $this->assetsToActivate = $assetsToActivate; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/AssetMethod/CalcMethodField.php b/src/Fields/AssetMethod/CalcMethodField.php index b69ad1e1..7f06805a 100644 --- a/src/Fields/AssetMethod/CalcMethodField.php +++ b/src/Fields/AssetMethod/CalcMethodField.php @@ -28,4 +28,4 @@ public function setCalcMethod(?CalcMethod $calcMethod): self $this->calcMethod = $calcMethod; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/AssetMethod/DepreciateReconciliationField.php b/src/Fields/AssetMethod/DepreciateReconciliationField.php index 54fe2dee..59000d5c 100644 --- a/src/Fields/AssetMethod/DepreciateReconciliationField.php +++ b/src/Fields/AssetMethod/DepreciateReconciliationField.php @@ -28,4 +28,4 @@ public function setDepreciateReconciliation(?DepreciateReconciliation $depreciat $this->depreciateReconciliation = $depreciateReconciliation; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/AssetMethod/DepreciationField.php b/src/Fields/AssetMethod/DepreciationField.php index a190ec72..6001ea5d 100644 --- a/src/Fields/AssetMethod/DepreciationField.php +++ b/src/Fields/AssetMethod/DepreciationField.php @@ -21,7 +21,7 @@ public function getDepreciation(): ?GeneralLedger { return $this->depreciation; } - + /** * @return $this */ @@ -30,4 +30,4 @@ public function setDepreciation(?GeneralLedger $depreciation): self $this->depreciation = $depreciation; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/AssetMethod/DepreciationGroupField.php b/src/Fields/AssetMethod/DepreciationGroupField.php index d2e7288e..fcca80b3 100644 --- a/src/Fields/AssetMethod/DepreciationGroupField.php +++ b/src/Fields/AssetMethod/DepreciationGroupField.php @@ -30,4 +30,4 @@ public function setDepreciationGroup(?DimensionGroup $depreciationGroup): self $this->depreciationGroup = $depreciationGroup; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/AssetMethod/FreeTextTypeField.php b/src/Fields/AssetMethod/FreeTextTypeField.php index eeb316eb..7997186f 100644 --- a/src/Fields/AssetMethod/FreeTextTypeField.php +++ b/src/Fields/AssetMethod/FreeTextTypeField.php @@ -28,4 +28,4 @@ public function setType(?FreeTextType $type): self $this->type = $type; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/AssetMethod/PurchaseValueField.php b/src/Fields/AssetMethod/PurchaseValueField.php index e7477279..1ed37b94 100644 --- a/src/Fields/AssetMethod/PurchaseValueField.php +++ b/src/Fields/AssetMethod/PurchaseValueField.php @@ -30,4 +30,4 @@ public function setPurchaseValue(?GeneralLedger $purchaseValue): self $this->purchaseValue = $purchaseValue; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/AssetMethod/PurchaseValueGroupField.php b/src/Fields/AssetMethod/PurchaseValueGroupField.php index 68747bfe..d1723cf7 100644 --- a/src/Fields/AssetMethod/PurchaseValueGroupField.php +++ b/src/Fields/AssetMethod/PurchaseValueGroupField.php @@ -30,4 +30,4 @@ public function setPurchaseValueGroup(?DimensionGroup $purchaseValueGroup): self $this->purchaseValueGroup = $purchaseValueGroup; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/AssetMethod/ReconciliationField.php b/src/Fields/AssetMethod/ReconciliationField.php index 5514acab..d7d53d73 100644 --- a/src/Fields/AssetMethod/ReconciliationField.php +++ b/src/Fields/AssetMethod/ReconciliationField.php @@ -30,4 +30,4 @@ public function setReconciliation(?GeneralLedger $reconciliation): self $this->reconciliation = $reconciliation; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/AssetMethod/SalesField.php b/src/Fields/AssetMethod/SalesField.php index 032dbf4b..71508363 100644 --- a/src/Fields/AssetMethod/SalesField.php +++ b/src/Fields/AssetMethod/SalesField.php @@ -21,7 +21,7 @@ public function getSales(): ?GeneralLedger { return $this->sales; } - + /** * @return $this */ @@ -30,4 +30,4 @@ public function setSales(?GeneralLedger $sales): self $this->sales = $sales; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/AssetMethod/ToBeInvoicedField.php b/src/Fields/AssetMethod/ToBeInvoicedField.php index 6c1d5c24..f3401e59 100644 --- a/src/Fields/AssetMethod/ToBeInvoicedField.php +++ b/src/Fields/AssetMethod/ToBeInvoicedField.php @@ -21,7 +21,7 @@ public function getToBeInvoiced(): ?GeneralLedger { return $this->toBeInvoiced; } - + /** * @return $this */ @@ -30,4 +30,4 @@ public function setToBeInvoiced(?GeneralLedger $toBeInvoiced): self $this->toBeInvoiced = $toBeInvoiced; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/BehaviourField.php b/src/Fields/BehaviourField.php index ade7885a..4019267f 100644 --- a/src/Fields/BehaviourField.php +++ b/src/Fields/BehaviourField.php @@ -28,4 +28,4 @@ public function setBehaviour(?Behaviour $behaviour): self $this->behaviour = $behaviour; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/CodeField.php b/src/Fields/CodeField.php index aa883829..a637203c 100644 --- a/src/Fields/CodeField.php +++ b/src/Fields/CodeField.php @@ -28,4 +28,4 @@ public function setCode(?string $code): self $this->code = $code; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/CommentField.php b/src/Fields/CommentField.php index 74d31f17..62313c7a 100644 --- a/src/Fields/CommentField.php +++ b/src/Fields/CommentField.php @@ -29,4 +29,4 @@ public function setComment(?string $comment) $this->comment = $comment; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/CreatedField.php b/src/Fields/CreatedField.php index 67417b14..2e8f7fd7 100644 --- a/src/Fields/CreatedField.php +++ b/src/Fields/CreatedField.php @@ -32,4 +32,4 @@ public function setCreated(?\DateTimeInterface $created) $this->created = $created; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Currency/CurrencyRateRateField.php b/src/Fields/Currency/CurrencyRateRateField.php index 71398cf3..a89db12b 100644 --- a/src/Fields/Currency/CurrencyRateRateField.php +++ b/src/Fields/Currency/CurrencyRateRateField.php @@ -29,4 +29,4 @@ public function setRate(?float $rate): self $this->rate = $rate; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Currency/StartDateField.php b/src/Fields/Currency/StartDateField.php index 26986f4a..b46b5ef0 100644 --- a/src/Fields/Currency/StartDateField.php +++ b/src/Fields/Currency/StartDateField.php @@ -31,4 +31,4 @@ public function setStartDate(?\DateTimeInterface $startDate) $this->startDate = $startDate; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/CurrencyField.php b/src/Fields/CurrencyField.php index 797a5c5c..2a19425a 100644 --- a/src/Fields/CurrencyField.php +++ b/src/Fields/CurrencyField.php @@ -30,4 +30,4 @@ public function setCurrency(?Currency $currency): self $this->currency = $currency; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/DateField.php b/src/Fields/DateField.php index f9229554..b78ef17d 100644 --- a/src/Fields/DateField.php +++ b/src/Fields/DateField.php @@ -34,4 +34,4 @@ public function setDate(?\DateTimeInterface $date) $this->date = $date; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/DescriptionField.php b/src/Fields/DescriptionField.php index ba659eb6..9b6e4258 100644 --- a/src/Fields/DescriptionField.php +++ b/src/Fields/DescriptionField.php @@ -29,4 +29,4 @@ public function setDescription(?string $description): self $this->description = $description; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dim1Field.php b/src/Fields/Dim1Field.php index f4856b4e..6f193df2 100644 --- a/src/Fields/Dim1Field.php +++ b/src/Fields/Dim1Field.php @@ -30,4 +30,4 @@ public function setDim1(?GeneralLedger $dim1): self $this->dim1 = $dim1; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dim4Field.php b/src/Fields/Dim4Field.php index 6c8f213d..4bdbe163 100644 --- a/src/Fields/Dim4Field.php +++ b/src/Fields/Dim4Field.php @@ -19,7 +19,7 @@ public function getDim4() { return $this->dim4; } - + /** * @return $this */ diff --git a/src/Fields/Dimensions/AccountTypeField.php b/src/Fields/Dimensions/AccountTypeField.php index 1a1be04a..abdbb6ef 100644 --- a/src/Fields/Dimensions/AccountTypeField.php +++ b/src/Fields/Dimensions/AccountTypeField.php @@ -28,4 +28,4 @@ public function setAccountType(?AccountType $accountType): self $this->accountType = $accountType; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/AmountField.php b/src/Fields/Dimensions/AmountField.php index e8de6f50..a9a69362 100644 --- a/src/Fields/Dimensions/AmountField.php +++ b/src/Fields/Dimensions/AmountField.php @@ -32,4 +32,4 @@ public function setAmount(?Money $amount) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/BeginPeriodField.php b/src/Fields/Dimensions/BeginPeriodField.php index ff1285e5..a72bb466 100644 --- a/src/Fields/Dimensions/BeginPeriodField.php +++ b/src/Fields/Dimensions/BeginPeriodField.php @@ -29,4 +29,4 @@ public function setBeginPeriod(?int $beginPeriod): self $this->beginPeriod = $beginPeriod; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/BeginYearField.php b/src/Fields/Dimensions/BeginYearField.php index 26840191..44a9287f 100644 --- a/src/Fields/Dimensions/BeginYearField.php +++ b/src/Fields/Dimensions/BeginYearField.php @@ -29,4 +29,4 @@ public function setBeginYear(?int $beginYear): self $this->beginYear = $beginYear; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/DimensionGroup/CodeField.php b/src/Fields/Dimensions/DimensionGroup/CodeField.php index 9920bba6..9e51e880 100644 --- a/src/Fields/Dimensions/DimensionGroup/CodeField.php +++ b/src/Fields/Dimensions/DimensionGroup/CodeField.php @@ -19,7 +19,7 @@ public function getCode() { return $this->code; } - + /** * @return $this */ diff --git a/src/Fields/Dimensions/DimensionType/FinancialsField.php b/src/Fields/Dimensions/DimensionType/FinancialsField.php index 511c358f..5fe6e825 100644 --- a/src/Fields/Dimensions/DimensionType/FinancialsField.php +++ b/src/Fields/Dimensions/DimensionType/FinancialsField.php @@ -29,4 +29,4 @@ public function setFinancials(?int $financials): self $this->financials = $financials; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/DimensionType/Label1Field.php b/src/Fields/Dimensions/DimensionType/Label1Field.php index 0544dc7f..974f940e 100644 --- a/src/Fields/Dimensions/DimensionType/Label1Field.php +++ b/src/Fields/Dimensions/DimensionType/Label1Field.php @@ -29,4 +29,4 @@ public function setLabel1(?string $label1): self $this->label1 = $label1; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/DimensionType/Label2Field.php b/src/Fields/Dimensions/DimensionType/Label2Field.php index e31f8543..736bcd67 100644 --- a/src/Fields/Dimensions/DimensionType/Label2Field.php +++ b/src/Fields/Dimensions/DimensionType/Label2Field.php @@ -29,4 +29,4 @@ public function setLabel2(?string $label2): self $this->label2 = $label2; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/DimensionType/Label3Field.php b/src/Fields/Dimensions/DimensionType/Label3Field.php index 5a93cd4d..1d475680 100644 --- a/src/Fields/Dimensions/DimensionType/Label3Field.php +++ b/src/Fields/Dimensions/DimensionType/Label3Field.php @@ -29,4 +29,4 @@ public function setLabel3(?string $label3): self $this->label3 = $label3; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/DimensionType/Label4Field.php b/src/Fields/Dimensions/DimensionType/Label4Field.php index 438a42b3..6f821533 100644 --- a/src/Fields/Dimensions/DimensionType/Label4Field.php +++ b/src/Fields/Dimensions/DimensionType/Label4Field.php @@ -29,4 +29,4 @@ public function setLabel4(?string $label4): self $this->label4 = $label4; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/DimensionType/Label5Field.php b/src/Fields/Dimensions/DimensionType/Label5Field.php index 27bcfdfa..383c9f33 100644 --- a/src/Fields/Dimensions/DimensionType/Label5Field.php +++ b/src/Fields/Dimensions/DimensionType/Label5Field.php @@ -29,4 +29,4 @@ public function setLabel5(?string $label5): self $this->label5 = $label5; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/DimensionType/Label6Field.php b/src/Fields/Dimensions/DimensionType/Label6Field.php index c50d18b3..5072ff0e 100644 --- a/src/Fields/Dimensions/DimensionType/Label6Field.php +++ b/src/Fields/Dimensions/DimensionType/Label6Field.php @@ -29,4 +29,4 @@ public function setLabel6(?string $label6): self $this->label6 = $label6; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/DimensionType/MaskField.php b/src/Fields/Dimensions/DimensionType/MaskField.php index 3872ac54..d7e6bd51 100644 --- a/src/Fields/Dimensions/DimensionType/MaskField.php +++ b/src/Fields/Dimensions/DimensionType/MaskField.php @@ -29,4 +29,4 @@ public function setMask(?string $mask): self $this->mask = $mask; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/DimensionType/TimeField.php b/src/Fields/Dimensions/DimensionType/TimeField.php index 77969d63..293ad0df 100644 --- a/src/Fields/Dimensions/DimensionType/TimeField.php +++ b/src/Fields/Dimensions/DimensionType/TimeField.php @@ -29,4 +29,4 @@ public function setTime(?int $time): self $this->time = $time; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/EndPeriodField.php b/src/Fields/Dimensions/EndPeriodField.php index d26a1cda..799f27e1 100644 --- a/src/Fields/Dimensions/EndPeriodField.php +++ b/src/Fields/Dimensions/EndPeriodField.php @@ -29,4 +29,4 @@ public function setEndPeriod(?int $endPeriod): self $this->endPeriod = $endPeriod; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/EndYearField.php b/src/Fields/Dimensions/EndYearField.php index c72edf98..eb9d4c46 100644 --- a/src/Fields/Dimensions/EndYearField.php +++ b/src/Fields/Dimensions/EndYearField.php @@ -29,4 +29,4 @@ public function setEndYear(?int $endYear): self $this->endYear = $endYear; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/AccountNumberField.php b/src/Fields/Dimensions/Level2/AccountNumberField.php index 03f76603..30b87bf7 100644 --- a/src/Fields/Dimensions/Level2/AccountNumberField.php +++ b/src/Fields/Dimensions/Level2/AccountNumberField.php @@ -29,4 +29,4 @@ public function setAccountNumber(?string $accountNumber): self $this->accountNumber = $accountNumber; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/AddressField2Field.php b/src/Fields/Dimensions/Level2/AddressField2Field.php index 173d64c2..d978afdf 100644 --- a/src/Fields/Dimensions/Level2/AddressField2Field.php +++ b/src/Fields/Dimensions/Level2/AddressField2Field.php @@ -29,4 +29,4 @@ public function setAddressField2(?string $addressField2): self $this->addressField2 = $addressField2; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/AddressField3Field.php b/src/Fields/Dimensions/Level2/AddressField3Field.php index caf36f14..75b22cf6 100644 --- a/src/Fields/Dimensions/Level2/AddressField3Field.php +++ b/src/Fields/Dimensions/Level2/AddressField3Field.php @@ -29,4 +29,4 @@ public function setAddressField3(?string $addressField3): self $this->addressField3 = $addressField3; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/AscriptionField.php b/src/Fields/Dimensions/Level2/AscriptionField.php index 417992ac..4f3715b1 100644 --- a/src/Fields/Dimensions/Level2/AscriptionField.php +++ b/src/Fields/Dimensions/Level2/AscriptionField.php @@ -29,4 +29,4 @@ public function setAscription(?string $ascription): self $this->ascription = $ascription; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/BankBlockedField.php b/src/Fields/Dimensions/Level2/BankBlockedField.php index d1dc7a06..0f675d65 100644 --- a/src/Fields/Dimensions/Level2/BankBlockedField.php +++ b/src/Fields/Dimensions/Level2/BankBlockedField.php @@ -29,4 +29,4 @@ public function setBlocked(?bool $blocked): self $this->blocked = $blocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/BankNameField.php b/src/Fields/Dimensions/Level2/BankNameField.php index 59c19779..cca57205 100644 --- a/src/Fields/Dimensions/Level2/BankNameField.php +++ b/src/Fields/Dimensions/Level2/BankNameField.php @@ -29,4 +29,4 @@ public function setBankName(?string $bankName): self $this->bankName = $bankName; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/BicCodeField.php b/src/Fields/Dimensions/Level2/BicCodeField.php index 3f52d274..ad66e8b8 100644 --- a/src/Fields/Dimensions/Level2/BicCodeField.php +++ b/src/Fields/Dimensions/Level2/BicCodeField.php @@ -29,4 +29,4 @@ public function setBicCode(?string $bicCode): self $this->bicCode = $bicCode; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/CityField.php b/src/Fields/Dimensions/Level2/CityField.php index 3b4e83a3..b27d3cb5 100644 --- a/src/Fields/Dimensions/Level2/CityField.php +++ b/src/Fields/Dimensions/Level2/CityField.php @@ -29,4 +29,4 @@ public function setCity(?string $city): self $this->city = $city; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Customer/BaseCreditLimitField.php b/src/Fields/Dimensions/Level2/Customer/BaseCreditLimitField.php index 6e64c32d..f2da123e 100644 --- a/src/Fields/Dimensions/Level2/Customer/BaseCreditLimitField.php +++ b/src/Fields/Dimensions/Level2/Customer/BaseCreditLimitField.php @@ -32,4 +32,4 @@ public function setBaseCreditLimit(?Money $baseCreditLimit) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Customer/BlockedField.php b/src/Fields/Dimensions/Level2/Customer/BlockedField.php index a2c566c7..e021dd9d 100644 --- a/src/Fields/Dimensions/Level2/Customer/BlockedField.php +++ b/src/Fields/Dimensions/Level2/Customer/BlockedField.php @@ -19,7 +19,7 @@ public function getBlocked(): ?bool { return $this->blocked; } - + /** * @param bool $blocked * @return $this @@ -29,4 +29,4 @@ public function setBlocked(?bool $blocked): self $this->blocked = $blocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Customer/BlockedLockedField.php b/src/Fields/Dimensions/Level2/Customer/BlockedLockedField.php index 82ad1a65..b9a8488d 100644 --- a/src/Fields/Dimensions/Level2/Customer/BlockedLockedField.php +++ b/src/Fields/Dimensions/Level2/Customer/BlockedLockedField.php @@ -29,4 +29,4 @@ public function setBlockedLocked(?bool $blockedLocked): self $this->blockedLocked = $blockedLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Customer/BlockedModifiedField.php b/src/Fields/Dimensions/Level2/Customer/BlockedModifiedField.php index f22f643a..849c5b22 100644 --- a/src/Fields/Dimensions/Level2/Customer/BlockedModifiedField.php +++ b/src/Fields/Dimensions/Level2/Customer/BlockedModifiedField.php @@ -32,4 +32,4 @@ public function setBlockedModified(?\DateTimeInterface $blockedModified) $this->blockedModified = $blockedModified; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Customer/CollectionSchemaField.php b/src/Fields/Dimensions/Level2/Customer/CollectionSchemaField.php index e3e72d79..5f6ee790 100644 --- a/src/Fields/Dimensions/Level2/Customer/CollectionSchemaField.php +++ b/src/Fields/Dimensions/Level2/Customer/CollectionSchemaField.php @@ -28,4 +28,4 @@ public function setCollectionSchema(?CollectionSchema $collectionSchema): self $this->collectionSchema = $collectionSchema; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Customer/DiscountArticleIDField.php b/src/Fields/Dimensions/Level2/Customer/DiscountArticleIDField.php index 7aaf3bcb..d0dd3adc 100644 --- a/src/Fields/Dimensions/Level2/Customer/DiscountArticleIDField.php +++ b/src/Fields/Dimensions/Level2/Customer/DiscountArticleIDField.php @@ -29,4 +29,4 @@ public function setDiscountArticleID(?string $discountArticleID): self $this->discountArticleID = $discountArticleID; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Customer/EBillMailField.php b/src/Fields/Dimensions/Level2/Customer/EBillMailField.php index 7290e9f4..df793962 100644 --- a/src/Fields/Dimensions/Level2/Customer/EBillMailField.php +++ b/src/Fields/Dimensions/Level2/Customer/EBillMailField.php @@ -29,4 +29,4 @@ public function setEBillMail(?string $eBillMail): self $this->eBillMail = $eBillMail; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Customer/EBillingField.php b/src/Fields/Dimensions/Level2/Customer/EBillingField.php index 63ad2de5..10d72281 100644 --- a/src/Fields/Dimensions/Level2/Customer/EBillingField.php +++ b/src/Fields/Dimensions/Level2/Customer/EBillingField.php @@ -29,4 +29,4 @@ public function setEBilling(?bool $eBilling): self $this->eBilling = $eBilling; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Customer/FirstRunDateField.php b/src/Fields/Dimensions/Level2/Customer/FirstRunDateField.php index c8507066..19c00166 100644 --- a/src/Fields/Dimensions/Level2/Customer/FirstRunDateField.php +++ b/src/Fields/Dimensions/Level2/Customer/FirstRunDateField.php @@ -32,4 +32,4 @@ public function setFirstRunDate(?\DateTimeInterface $firstRunDate) $this->firstRunDate = $firstRunDate; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Customer/FreeText1Field.php b/src/Fields/Dimensions/Level2/Customer/FreeText1Field.php index e8d2ebf9..028175ee 100644 --- a/src/Fields/Dimensions/Level2/Customer/FreeText1Field.php +++ b/src/Fields/Dimensions/Level2/Customer/FreeText1Field.php @@ -29,4 +29,4 @@ public function setFreeText1(?bool $freeText1): self $this->freeText1 = $freeText1; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Customer/IDField.php b/src/Fields/Dimensions/Level2/Customer/IDField.php index a1b12e7a..a78044d1 100644 --- a/src/Fields/Dimensions/Level2/Customer/IDField.php +++ b/src/Fields/Dimensions/Level2/Customer/IDField.php @@ -29,4 +29,4 @@ public function setID(?string $ID): self $this->ID = $ID; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Customer/ReminderEmailField.php b/src/Fields/Dimensions/Level2/Customer/ReminderEmailField.php index eea17c76..958b913a 100644 --- a/src/Fields/Dimensions/Level2/Customer/ReminderEmailField.php +++ b/src/Fields/Dimensions/Level2/Customer/ReminderEmailField.php @@ -29,4 +29,4 @@ public function setReminderEmail(?string $reminderEmail): self $this->reminderEmail = $reminderEmail; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Customer/SendReminderField.php b/src/Fields/Dimensions/Level2/Customer/SendReminderField.php index 640db04a..9ae1cc5c 100644 --- a/src/Fields/Dimensions/Level2/Customer/SendReminderField.php +++ b/src/Fields/Dimensions/Level2/Customer/SendReminderField.php @@ -28,4 +28,4 @@ public function setSendReminder(?SendReminder $sendReminder): self $this->sendReminder = $sendReminder; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Customer/SignatureDateField.php b/src/Fields/Dimensions/Level2/Customer/SignatureDateField.php index 6612d932..194eaf83 100644 --- a/src/Fields/Dimensions/Level2/Customer/SignatureDateField.php +++ b/src/Fields/Dimensions/Level2/Customer/SignatureDateField.php @@ -32,4 +32,4 @@ public function setSignatureDate(?\DateTimeInterface $signatureDate) $this->signatureDate = $signatureDate; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/DefaultField.php b/src/Fields/Dimensions/Level2/DefaultField.php index 3c319698..b6f17f50 100644 --- a/src/Fields/Dimensions/Level2/DefaultField.php +++ b/src/Fields/Dimensions/Level2/DefaultField.php @@ -29,4 +29,4 @@ public function setDefault(?bool $default): self $this->default = $default; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Dimension1Field.php b/src/Fields/Dimensions/Level2/Dimension1Field.php index 5bb875ac..04c0b089 100644 --- a/src/Fields/Dimensions/Level2/Dimension1Field.php +++ b/src/Fields/Dimensions/Level2/Dimension1Field.php @@ -30,4 +30,4 @@ public function setDimension1(?GeneralLedger $dimension1): self $this->dimension1 = $dimension1; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Dimension1IDField.php b/src/Fields/Dimensions/Level2/Dimension1IDField.php index c7b71bef..25b5fe2d 100644 --- a/src/Fields/Dimensions/Level2/Dimension1IDField.php +++ b/src/Fields/Dimensions/Level2/Dimension1IDField.php @@ -29,4 +29,4 @@ public function setDimension1ID(?string $dimension1ID): self $this->dimension1ID = $dimension1ID; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Dimension2Field.php b/src/Fields/Dimensions/Level2/Dimension2Field.php index 75c75ed4..4faa64f8 100644 --- a/src/Fields/Dimensions/Level2/Dimension2Field.php +++ b/src/Fields/Dimensions/Level2/Dimension2Field.php @@ -30,4 +30,4 @@ public function setDimension2(?CostCenter $dimension2): self $this->dimension2 = $dimension2; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Dimension2IDField.php b/src/Fields/Dimensions/Level2/Dimension2IDField.php index 802c1ee2..af08e427 100644 --- a/src/Fields/Dimensions/Level2/Dimension2IDField.php +++ b/src/Fields/Dimensions/Level2/Dimension2IDField.php @@ -29,4 +29,4 @@ public function setDimension2ID(?string $dimension2ID): self $this->dimension2ID = $dimension2ID; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Dimension3Field.php b/src/Fields/Dimensions/Level2/Dimension3Field.php index 3f7a1369..d10bb6d1 100644 --- a/src/Fields/Dimensions/Level2/Dimension3Field.php +++ b/src/Fields/Dimensions/Level2/Dimension3Field.php @@ -28,4 +28,4 @@ public function setDimension3($dimension3): self $this->dimension3 = $dimension3; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Dimension3IDField.php b/src/Fields/Dimensions/Level2/Dimension3IDField.php index 3a98d687..0f826bcf 100644 --- a/src/Fields/Dimensions/Level2/Dimension3IDField.php +++ b/src/Fields/Dimensions/Level2/Dimension3IDField.php @@ -29,4 +29,4 @@ public function setDimension3ID(?string $dimension3ID): self $this->dimension3ID = $dimension3ID; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/DueDaysField.php b/src/Fields/Dimensions/Level2/DueDaysField.php index f964b89b..9a1a9061 100644 --- a/src/Fields/Dimensions/Level2/DueDaysField.php +++ b/src/Fields/Dimensions/Level2/DueDaysField.php @@ -29,4 +29,4 @@ public function setDueDays(?int $dueDays): self $this->dueDays = $dueDays; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Field1Field.php b/src/Fields/Dimensions/Level2/Field1Field.php index 54115f1d..873b4139 100644 --- a/src/Fields/Dimensions/Level2/Field1Field.php +++ b/src/Fields/Dimensions/Level2/Field1Field.php @@ -29,4 +29,4 @@ public function setField1(?string $field1): self $this->field1 = $field1; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Field2Field.php b/src/Fields/Dimensions/Level2/Field2Field.php index dee47816..2bf4b673 100644 --- a/src/Fields/Dimensions/Level2/Field2Field.php +++ b/src/Fields/Dimensions/Level2/Field2Field.php @@ -29,4 +29,4 @@ public function setField2(?string $field2): self $this->field2 = $field2; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Field3Field.php b/src/Fields/Dimensions/Level2/Field3Field.php index 7b7d761f..75d78bf4 100644 --- a/src/Fields/Dimensions/Level2/Field3Field.php +++ b/src/Fields/Dimensions/Level2/Field3Field.php @@ -29,4 +29,4 @@ public function setField3(?string $field3): self $this->field3 = $field3; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Field4Field.php b/src/Fields/Dimensions/Level2/Field4Field.php index 4c21a66c..8d726c16 100644 --- a/src/Fields/Dimensions/Level2/Field4Field.php +++ b/src/Fields/Dimensions/Level2/Field4Field.php @@ -29,4 +29,4 @@ public function setField4(?string $field4): self $this->field4 = $field4; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Field5Field.php b/src/Fields/Dimensions/Level2/Field5Field.php index f87166b4..f790df01 100644 --- a/src/Fields/Dimensions/Level2/Field5Field.php +++ b/src/Fields/Dimensions/Level2/Field5Field.php @@ -29,4 +29,4 @@ public function setField5(?string $field5): self $this->field5 = $field5; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Field6Field.php b/src/Fields/Dimensions/Level2/Field6Field.php index eef92278..d3f1f946 100644 --- a/src/Fields/Dimensions/Level2/Field6Field.php +++ b/src/Fields/Dimensions/Level2/Field6Field.php @@ -29,4 +29,4 @@ public function setField6(?string $field6): self $this->field6 = $field6; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/IbanField.php b/src/Fields/Dimensions/Level2/IbanField.php index 59e38e55..674c7ea5 100644 --- a/src/Fields/Dimensions/Level2/IbanField.php +++ b/src/Fields/Dimensions/Level2/IbanField.php @@ -29,4 +29,4 @@ public function setIban(?string $iban): self $this->iban = $iban; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/MeansOfPaymentField.php b/src/Fields/Dimensions/Level2/MeansOfPaymentField.php index 7c11d8c6..693802b6 100644 --- a/src/Fields/Dimensions/Level2/MeansOfPaymentField.php +++ b/src/Fields/Dimensions/Level2/MeansOfPaymentField.php @@ -28,4 +28,4 @@ public function setMeansOfPayment(?MeansOfPayment $meansOfPayment): self $this->meansOfPayment = $meansOfPayment; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/NatBicCodeField.php b/src/Fields/Dimensions/Level2/NatBicCodeField.php index 13ff2e8f..f364a6c1 100644 --- a/src/Fields/Dimensions/Level2/NatBicCodeField.php +++ b/src/Fields/Dimensions/Level2/NatBicCodeField.php @@ -29,4 +29,4 @@ public function setNatBicCode(?string $natBicCode): self $this->natBicCode = $natBicCode; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/PayAvailableField.php b/src/Fields/Dimensions/Level2/PayAvailableField.php index 0843d454..cc6c6e43 100644 --- a/src/Fields/Dimensions/Level2/PayAvailableField.php +++ b/src/Fields/Dimensions/Level2/PayAvailableField.php @@ -29,4 +29,4 @@ public function setPayAvailable(?bool $payAvailable): self $this->payAvailable = $payAvailable; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/PayCodeIDField.php b/src/Fields/Dimensions/Level2/PayCodeIDField.php index 10c146d7..72a58928 100644 --- a/src/Fields/Dimensions/Level2/PayCodeIDField.php +++ b/src/Fields/Dimensions/Level2/PayCodeIDField.php @@ -29,4 +29,4 @@ public function setPayCodeID(?string $payCodeID): self $this->payCodeID = $payCodeID; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/PaymentConditionDiscountDaysField.php b/src/Fields/Dimensions/Level2/PaymentConditionDiscountDaysField.php index 64f20727..64a534a5 100644 --- a/src/Fields/Dimensions/Level2/PaymentConditionDiscountDaysField.php +++ b/src/Fields/Dimensions/Level2/PaymentConditionDiscountDaysField.php @@ -29,4 +29,4 @@ public function setPaymentConditionDiscountDays(?int $paymentConditionDiscountDa $this->paymentConditionDiscountDays = $paymentConditionDiscountDays; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/PaymentConditionDiscountPercentageField.php b/src/Fields/Dimensions/Level2/PaymentConditionDiscountPercentageField.php index 8a8beb82..3540324c 100644 --- a/src/Fields/Dimensions/Level2/PaymentConditionDiscountPercentageField.php +++ b/src/Fields/Dimensions/Level2/PaymentConditionDiscountPercentageField.php @@ -29,4 +29,4 @@ public function setPaymentConditionDiscountPercentage(?float $paymentConditionDi $this->paymentConditionDiscountPercentage = $paymentConditionDiscountPercentage; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/PostcodeField.php b/src/Fields/Dimensions/Level2/PostcodeField.php index 7738943d..4b8b1768 100644 --- a/src/Fields/Dimensions/Level2/PostcodeField.php +++ b/src/Fields/Dimensions/Level2/PostcodeField.php @@ -29,4 +29,4 @@ public function setPostcode(?string $postcode): self $this->postcode = $postcode; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/RatioField.php b/src/Fields/Dimensions/Level2/RatioField.php index bf6d6b19..ddadd9cd 100644 --- a/src/Fields/Dimensions/Level2/RatioField.php +++ b/src/Fields/Dimensions/Level2/RatioField.php @@ -29,4 +29,4 @@ public function setRatio(?float $ratio): self $this->ratio = $ratio; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/RemittanceAdviceSendMailField.php b/src/Fields/Dimensions/Level2/RemittanceAdviceSendMailField.php index 2c2790dc..ccf83686 100644 --- a/src/Fields/Dimensions/Level2/RemittanceAdviceSendMailField.php +++ b/src/Fields/Dimensions/Level2/RemittanceAdviceSendMailField.php @@ -29,4 +29,4 @@ public function setRemittanceAdviceSendMail(?string $remittanceAdviceSendMail): $this->remittanceAdviceSendMail = $remittanceAdviceSendMail; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/RemittanceAdviceSendTypeField.php b/src/Fields/Dimensions/Level2/RemittanceAdviceSendTypeField.php index d23e8e85..0342be7e 100644 --- a/src/Fields/Dimensions/Level2/RemittanceAdviceSendTypeField.php +++ b/src/Fields/Dimensions/Level2/RemittanceAdviceSendTypeField.php @@ -28,4 +28,4 @@ public function setRemittanceAdviceSendType(?RemittanceAdviceSendType $remittanc $this->remittanceAdviceSendType = $remittanceAdviceSendType; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/StateField.php b/src/Fields/Dimensions/Level2/StateField.php index ec393548..da7c255f 100644 --- a/src/Fields/Dimensions/Level2/StateField.php +++ b/src/Fields/Dimensions/Level2/StateField.php @@ -29,4 +29,4 @@ public function setState(?string $state): self $this->state = $state; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Supplier/BlockedAccountPaymentConditionsIncludeVatField.php b/src/Fields/Dimensions/Level2/Supplier/BlockedAccountPaymentConditionsIncludeVatField.php index b0092ac0..c23a8918 100644 --- a/src/Fields/Dimensions/Level2/Supplier/BlockedAccountPaymentConditionsIncludeVatField.php +++ b/src/Fields/Dimensions/Level2/Supplier/BlockedAccountPaymentConditionsIncludeVatField.php @@ -28,4 +28,4 @@ public function setBlockedAccountPaymentConditionsIncludeVat(?BlockedAccountPaym $this->blockedAccountPaymentConditionsIncludeVat = $blockedAccountPaymentConditionsIncludeVat; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Supplier/BlockedAccountPaymentConditionsPercentageField.php b/src/Fields/Dimensions/Level2/Supplier/BlockedAccountPaymentConditionsPercentageField.php index ddcd9db9..1aabba11 100644 --- a/src/Fields/Dimensions/Level2/Supplier/BlockedAccountPaymentConditionsPercentageField.php +++ b/src/Fields/Dimensions/Level2/Supplier/BlockedAccountPaymentConditionsPercentageField.php @@ -29,4 +29,4 @@ public function setBlockedAccountPaymentConditionsPercentage(?float $blockedAcco $this->blockedAccountPaymentConditionsPercentage = $blockedAccountPaymentConditionsPercentage; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/Supplier/RelationsReferenceField.php b/src/Fields/Dimensions/Level2/Supplier/RelationsReferenceField.php index 43289ab7..59ac69a0 100644 --- a/src/Fields/Dimensions/Level2/Supplier/RelationsReferenceField.php +++ b/src/Fields/Dimensions/Level2/Supplier/RelationsReferenceField.php @@ -29,4 +29,4 @@ public function setRelationsReference(?string $relationsReference): self $this->relationsReference = $relationsReference; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/TelefaxField.php b/src/Fields/Dimensions/Level2/TelefaxField.php index bec83d24..71d00097 100644 --- a/src/Fields/Dimensions/Level2/TelefaxField.php +++ b/src/Fields/Dimensions/Level2/TelefaxField.php @@ -29,4 +29,4 @@ public function setTelefax(?string $telefax): self $this->telefax = $telefax; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/TelephoneField.php b/src/Fields/Dimensions/Level2/TelephoneField.php index ec50331c..369d9db8 100644 --- a/src/Fields/Dimensions/Level2/TelephoneField.php +++ b/src/Fields/Dimensions/Level2/TelephoneField.php @@ -29,4 +29,4 @@ public function setTelephone(?string $telephone): self $this->telephone = $telephone; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/TypeField.php b/src/Fields/Dimensions/Level2/TypeField.php index 3d935c3f..26cafc68 100644 --- a/src/Fields/Dimensions/Level2/TypeField.php +++ b/src/Fields/Dimensions/Level2/TypeField.php @@ -28,4 +28,4 @@ public function setType(?AddressType $type): self $this->type = $type; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level2/WebsiteField.php b/src/Fields/Dimensions/Level2/WebsiteField.php index 58f6137a..ab22d8b6 100644 --- a/src/Fields/Dimensions/Level2/WebsiteField.php +++ b/src/Fields/Dimensions/Level2/WebsiteField.php @@ -29,4 +29,4 @@ public function setWebsite(?string $website): self $this->website = $website; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/AuthoriserInheritField.php b/src/Fields/Dimensions/Level34/AuthoriserInheritField.php index 298ce24f..bda09935 100644 --- a/src/Fields/Dimensions/Level34/AuthoriserInheritField.php +++ b/src/Fields/Dimensions/Level34/AuthoriserInheritField.php @@ -34,4 +34,4 @@ public function setAuthoriserInherit(?bool $authoriserInherit): self $this->authoriserInherit = $authoriserInherit; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/AuthoriserLockedField.php b/src/Fields/Dimensions/Level34/AuthoriserLockedField.php index 4e5a63b4..35862083 100644 --- a/src/Fields/Dimensions/Level34/AuthoriserLockedField.php +++ b/src/Fields/Dimensions/Level34/AuthoriserLockedField.php @@ -34,4 +34,4 @@ public function setAuthoriserLocked(?bool $authoriserLocked): self $this->authoriserLocked = $authoriserLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/BillableField.php b/src/Fields/Dimensions/Level34/BillableField.php index 9680c836..84c406aa 100644 --- a/src/Fields/Dimensions/Level34/BillableField.php +++ b/src/Fields/Dimensions/Level34/BillableField.php @@ -34,4 +34,4 @@ public function setBillable(?bool $billable): self $this->billable = $billable; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/BillableForRatioField.php b/src/Fields/Dimensions/Level34/BillableForRatioField.php index b23f5cee..6a7374fa 100644 --- a/src/Fields/Dimensions/Level34/BillableForRatioField.php +++ b/src/Fields/Dimensions/Level34/BillableForRatioField.php @@ -34,4 +34,4 @@ public function setBillableForRatio(?bool $billableForRatio): self $this->billableForRatio = $billableForRatio; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/BillableInheritField.php b/src/Fields/Dimensions/Level34/BillableInheritField.php index 1c3329ce..7b695316 100644 --- a/src/Fields/Dimensions/Level34/BillableInheritField.php +++ b/src/Fields/Dimensions/Level34/BillableInheritField.php @@ -34,4 +34,4 @@ public function setBillableInherit(?bool $billableInherit): self $this->billableInherit = $billableInherit; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/BillableLockedField.php b/src/Fields/Dimensions/Level34/BillableLockedField.php index b05162ce..fec600e9 100644 --- a/src/Fields/Dimensions/Level34/BillableLockedField.php +++ b/src/Fields/Dimensions/Level34/BillableLockedField.php @@ -34,4 +34,4 @@ public function setBillableLocked(?bool $billableLocked): self $this->billableLocked = $billableLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/CustomerInheritField.php b/src/Fields/Dimensions/Level34/CustomerInheritField.php index 60ece07f..1191f37f 100644 --- a/src/Fields/Dimensions/Level34/CustomerInheritField.php +++ b/src/Fields/Dimensions/Level34/CustomerInheritField.php @@ -34,4 +34,4 @@ public function setCustomerInherit(?bool $customerInherit): self $this->customerInherit = $customerInherit; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/CustomerLockedField.php b/src/Fields/Dimensions/Level34/CustomerLockedField.php index a6a8f22f..7cf47f2c 100644 --- a/src/Fields/Dimensions/Level34/CustomerLockedField.php +++ b/src/Fields/Dimensions/Level34/CustomerLockedField.php @@ -34,4 +34,4 @@ public function setCustomerLocked(?bool $customerLocked): self $this->customerLocked = $customerLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/AmountLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/AmountLockedField.php index 12a1c033..4448fb8b 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/AmountLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/AmountLockedField.php @@ -29,4 +29,4 @@ public function setAmountLocked(?bool $amountLocked): self $this->amountLocked = $amountLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/BeginPeriodLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/BeginPeriodLockedField.php index a02e3bc4..285ead2a 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/BeginPeriodLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/BeginPeriodLockedField.php @@ -29,4 +29,4 @@ public function setBeginPeriodLocked(?bool $beginPeriodLocked): self $this->beginPeriodLocked = $beginPeriodLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/CodeLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/CodeLockedField.php index b0302a3d..dc9ccfa0 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/CodeLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/CodeLockedField.php @@ -29,4 +29,4 @@ public function setCodeLocked(?bool $codeLocked): self $this->codeLocked = $codeLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/Dim1LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim1LockedField.php index fe12dc9e..462dab39 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/Dim1LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim1LockedField.php @@ -19,7 +19,7 @@ public function getDim1Locked(): ?bool { return $this->dim1Locked; } - + /** * @param bool $dim1Locked * @return $this @@ -29,4 +29,4 @@ public function setDim1Locked(?bool $dim1Locked): self $this->dim1Locked = $dim1Locked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/Dim2LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim2LockedField.php index 34bb7ad8..37995f0a 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/Dim2LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim2LockedField.php @@ -29,4 +29,4 @@ public function setDim2Locked(?bool $dim2Locked): self $this->dim2Locked = $dim2Locked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/Dim3LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim3LockedField.php index 6323bf2b..61f99750 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/Dim3LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim3LockedField.php @@ -29,4 +29,4 @@ public function setDim3Locked(?bool $dim3Locked): self $this->dim3Locked = $dim3Locked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/Dim4LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim4LockedField.php index a734225b..d35f0201 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/Dim4LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim4LockedField.php @@ -29,4 +29,4 @@ public function setDim4Locked(?bool $dim4Locked): self $this->dim4Locked = $dim4Locked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/Dim5LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim5LockedField.php index a9677d69..f1f84916 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/Dim5LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim5LockedField.php @@ -19,7 +19,7 @@ public function getDim5Locked(): ?bool { return $this->dim5Locked; } - + /** * @param bool $dim5Locked * @return $this @@ -29,4 +29,4 @@ public function setDim5Locked(?bool $dim5Locked): self $this->dim5Locked = $dim5Locked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/Dim6LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/Dim6LockedField.php index 724103ba..479a53d4 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/Dim6LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/Dim6LockedField.php @@ -29,4 +29,4 @@ public function setDim6Locked(?bool $dim6Locked): self $this->dim6Locked = $dim6Locked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/FreeText1LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText1LockedField.php index a3080d23..6d345454 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/FreeText1LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText1LockedField.php @@ -29,4 +29,4 @@ public function setFreeText1Locked(?bool $freeText1Locked): self $this->freeText1Locked = $freeText1Locked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/FreeText2LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText2LockedField.php index ac0d012c..dc6696ef 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/FreeText2LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText2LockedField.php @@ -29,4 +29,4 @@ public function setFreeText2Locked(?bool $freeText2Locked): self $this->freeText2Locked = $freeText2Locked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/FreeText3LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText3LockedField.php index 23704b29..15df407a 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/FreeText3LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText3LockedField.php @@ -19,7 +19,7 @@ public function getFreeText3Locked(): ?bool { return $this->freeText3Locked; } - + /** * @param bool $freeText3Locked * @return $this @@ -29,4 +29,4 @@ public function setFreeText3Locked(?bool $freeText3Locked): self $this->freeText3Locked = $freeText3Locked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/FreeText4Field.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText4Field.php index aba88eab..a6018ab0 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/FreeText4Field.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText4Field.php @@ -29,4 +29,4 @@ public function setFreeText4(?string $freeText4): self $this->freeText4 = $freeText4; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/FreeText4LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText4LockedField.php index 8cbf120f..6997c671 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/FreeText4LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText4LockedField.php @@ -29,4 +29,4 @@ public function setFreeText4Locked(?bool $freeText4Locked): self $this->freeText4Locked = $freeText4Locked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/FreeText5Field.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText5Field.php index 8379aeec..e1059181 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/FreeText5Field.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText5Field.php @@ -29,4 +29,4 @@ public function setFreeText5(?string $freeText5): self $this->freeText5 = $freeText5; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/FreeText5LockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/FreeText5LockedField.php index ac201b00..c9763112 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/FreeText5LockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/FreeText5LockedField.php @@ -29,4 +29,4 @@ public function setFreeText5Locked(?bool $freeText5Locked): self $this->freeText5Locked = $freeText5Locked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/LastDepreciationLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/LastDepreciationLockedField.php index 86729e17..4063d20c 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/LastDepreciationLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/LastDepreciationLockedField.php @@ -29,4 +29,4 @@ public function setLastDepreciationLocked(?bool $lastDepreciationLocked): self $this->lastDepreciationLocked = $lastDepreciationLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/LineField.php b/src/Fields/Dimensions/Level34/FixedAsset/LineField.php index 2d6a756f..d4d532d7 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/LineField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/LineField.php @@ -29,4 +29,4 @@ public function setLine(?int $line): self $this->line = $line; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/LineLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/LineLockedField.php index 8ab29e02..74db813a 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/LineLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/LineLockedField.php @@ -29,4 +29,4 @@ public function setLineLocked(?bool $lineLocked): self $this->lineLocked = $lineLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/MethodLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/MethodLockedField.php index 1415ca53..0200cbad 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/MethodLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/MethodLockedField.php @@ -29,4 +29,4 @@ public function setMethodLocked(?bool $methodLocked): self $this->methodLocked = $methodLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/NrOfPeriodsInheritedField.php b/src/Fields/Dimensions/Level34/FixedAsset/NrOfPeriodsInheritedField.php index 8425748a..9a1b8f0e 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/NrOfPeriodsInheritedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/NrOfPeriodsInheritedField.php @@ -29,4 +29,4 @@ public function setNrOfPeriodsInherited(?bool $nrOfPeriodsInherited): self $this->nrOfPeriodsInherited = $nrOfPeriodsInherited; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/NrOfPeriodsLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/NrOfPeriodsLockedField.php index a3efe6d3..7aa22ace 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/NrOfPeriodsLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/NrOfPeriodsLockedField.php @@ -29,4 +29,4 @@ public function setNrOfPeriodsLocked(?bool $nrOfPeriodsLocked): self $this->nrOfPeriodsLocked = $nrOfPeriodsLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/NumberField.php b/src/Fields/Dimensions/Level34/FixedAsset/NumberField.php index 195b2df1..0398284f 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/NumberField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/NumberField.php @@ -29,4 +29,4 @@ public function setNumber(?int $number): self $this->number = $number; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/NumberLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/NumberLockedField.php index 39c65f3c..169c7978 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/NumberLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/NumberLockedField.php @@ -29,4 +29,4 @@ public function setNumberLocked(?bool $numberLocked): self $this->numberLocked = $numberLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/PercentageLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/PercentageLockedField.php index 2355f0ec..8508f371 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/PercentageLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/PercentageLockedField.php @@ -29,4 +29,4 @@ public function setPercentageLocked(?bool $percentageLocked): self $this->percentageLocked = $percentageLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/PeriodLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/PeriodLockedField.php index c00f98d9..2d932ff5 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/PeriodLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/PeriodLockedField.php @@ -29,4 +29,4 @@ public function setPeriodLocked(?bool $periodLocked): self $this->periodLocked = $periodLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateField.php b/src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateField.php index 5b10e6fd..a2f5b5f6 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateField.php @@ -32,4 +32,4 @@ public function setPurchaseDate(?\DateTimeInterface $purchaseDate) $this->purchaseDate = $purchaseDate; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateLockedField.php index e900b818..b783520c 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/PurchaseDateLockedField.php @@ -29,4 +29,4 @@ public function setPurchaseDateLocked(?bool $purchaseDateLocked): self $this->purchaseDateLocked = $purchaseDateLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/ResidualValueField.php b/src/Fields/Dimensions/Level34/FixedAsset/ResidualValueField.php index 0beac05f..03c437e5 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/ResidualValueField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/ResidualValueField.php @@ -32,4 +32,4 @@ public function setResidualValue(?Money $residualValue) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/ResidualValueLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/ResidualValueLockedField.php index dd11abb7..79480565 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/ResidualValueLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/ResidualValueLockedField.php @@ -29,4 +29,4 @@ public function setResidualValueLocked(?bool $residualValueLocked): self $this->residualValueLocked = $residualValueLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/SellDateField.php b/src/Fields/Dimensions/Level34/FixedAsset/SellDateField.php index a215b7c0..e6ae1d08 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/SellDateField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/SellDateField.php @@ -32,4 +32,4 @@ public function setSellDate(?\DateTimeInterface $sellDate) $this->sellDate = $sellDate; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/SellDateLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/SellDateLockedField.php index 3edb4417..e989f2d0 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/SellDateLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/SellDateLockedField.php @@ -29,4 +29,4 @@ public function setSellDateLocked(?bool $sellDateLocked): self $this->sellDateLocked = $sellDateLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/StatusField.php b/src/Fields/Dimensions/Level34/FixedAsset/StatusField.php index 3ea16c66..615c3a39 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/StatusField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/StatusField.php @@ -28,4 +28,4 @@ public function setStatus(?FixedAssetsStatus $status): self $this->status = $status; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/StatusLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/StatusLockedField.php index 6f5739e1..2ddffd8d 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/StatusLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/StatusLockedField.php @@ -29,4 +29,4 @@ public function setStatusLocked(?bool $statusLocked): self $this->statusLocked = $statusLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/StopValueField.php b/src/Fields/Dimensions/Level34/FixedAsset/StopValueField.php index 839368f3..48a17432 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/StopValueField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/StopValueField.php @@ -32,4 +32,4 @@ public function setStopValue(?Money $stopValue) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/StopValueLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/StopValueLockedField.php index a3e5f779..639184db 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/StopValueLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/StopValueLockedField.php @@ -29,4 +29,4 @@ public function setStopValueLocked(?bool $stopValueLocked): self $this->stopValueLocked = $stopValueLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/FixedAsset/TransactionLinesLockedField.php b/src/Fields/Dimensions/Level34/FixedAsset/TransactionLinesLockedField.php index e2ae86be..e52d277e 100644 --- a/src/Fields/Dimensions/Level34/FixedAsset/TransactionLinesLockedField.php +++ b/src/Fields/Dimensions/Level34/FixedAsset/TransactionLinesLockedField.php @@ -29,4 +29,4 @@ public function setTransactionLinesLocked(?bool $transactionLinesLocked): self $this->transactionLinesLocked = $transactionLinesLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/InvoiceDescriptionField.php b/src/Fields/Dimensions/Level34/InvoiceDescriptionField.php index 8e5e9a2f..67a261af 100644 --- a/src/Fields/Dimensions/Level34/InvoiceDescriptionField.php +++ b/src/Fields/Dimensions/Level34/InvoiceDescriptionField.php @@ -29,4 +29,4 @@ public function setInvoiceDescription(?string $invoiceDescription): self $this->invoiceDescription = $invoiceDescription; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/LabelField.php b/src/Fields/Dimensions/Level34/LabelField.php index 49c8325a..dde21a16 100644 --- a/src/Fields/Dimensions/Level34/LabelField.php +++ b/src/Fields/Dimensions/Level34/LabelField.php @@ -29,4 +29,4 @@ public function setLabel(?string $label): self $this->label = $label; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/MandatoryField.php b/src/Fields/Dimensions/Level34/MandatoryField.php index 02117d04..8e298bd1 100644 --- a/src/Fields/Dimensions/Level34/MandatoryField.php +++ b/src/Fields/Dimensions/Level34/MandatoryField.php @@ -29,4 +29,4 @@ public function setMandatory(?bool $mandatory): self $this->mandatory = $mandatory; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/RateInheritField.php b/src/Fields/Dimensions/Level34/RateInheritField.php index a1ce65e3..fe0804c4 100644 --- a/src/Fields/Dimensions/Level34/RateInheritField.php +++ b/src/Fields/Dimensions/Level34/RateInheritField.php @@ -34,4 +34,4 @@ public function setRateInherit(?bool $rateInherit): self $this->rateInherit = $rateInherit; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/RateLockedField.php b/src/Fields/Dimensions/Level34/RateLockedField.php index 78ab4832..c78c3a11 100644 --- a/src/Fields/Dimensions/Level34/RateLockedField.php +++ b/src/Fields/Dimensions/Level34/RateLockedField.php @@ -34,4 +34,4 @@ public function setRateLocked(?bool $rateLocked): self $this->rateLocked = $rateLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/ValidFromField.php b/src/Fields/Dimensions/Level34/ValidFromField.php index f971670e..18a92bd6 100644 --- a/src/Fields/Dimensions/Level34/ValidFromField.php +++ b/src/Fields/Dimensions/Level34/ValidFromField.php @@ -32,4 +32,4 @@ public function setValidFrom(?\DateTimeInterface $validFrom) $this->validFrom = $validFrom; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/Level34/ValidTillField.php b/src/Fields/Dimensions/Level34/ValidTillField.php index f81452c1..38543817 100644 --- a/src/Fields/Dimensions/Level34/ValidTillField.php +++ b/src/Fields/Dimensions/Level34/ValidTillField.php @@ -32,4 +32,4 @@ public function setValidTill(?\DateTimeInterface $validTill) $this->validTill = $validTill; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/MatchTypeField.php b/src/Fields/Dimensions/MatchTypeField.php index 22d1c8d2..2ed54457 100644 --- a/src/Fields/Dimensions/MatchTypeField.php +++ b/src/Fields/Dimensions/MatchTypeField.php @@ -28,4 +28,4 @@ public function setMatchType(?MatchType $matchType): self $this->matchType = $matchType; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/SubAnalyseField.php b/src/Fields/Dimensions/SubAnalyseField.php index 994382ff..37bc9c9f 100644 --- a/src/Fields/Dimensions/SubAnalyseField.php +++ b/src/Fields/Dimensions/SubAnalyseField.php @@ -28,4 +28,4 @@ public function setSubAnalyse(?SubAnalyse $subAnalyse): self $this->subAnalyse = $subAnalyse; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/SubstituteWithIDField.php b/src/Fields/Dimensions/SubstituteWithIDField.php index 3fc8ac19..c05a827b 100644 --- a/src/Fields/Dimensions/SubstituteWithIDField.php +++ b/src/Fields/Dimensions/SubstituteWithIDField.php @@ -29,4 +29,4 @@ public function setSubstituteWithID(?string $substituteWithID): self $this->substituteWithID = $substituteWithID; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/SubstitutionLevelField.php b/src/Fields/Dimensions/SubstitutionLevelField.php index 493ee162..d6fe4c5a 100644 --- a/src/Fields/Dimensions/SubstitutionLevelField.php +++ b/src/Fields/Dimensions/SubstitutionLevelField.php @@ -29,4 +29,4 @@ public function setSubstitutionLevel(?int $substitutionLevel): self $this->substitutionLevel = $substitutionLevel; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/TypeField.php b/src/Fields/Dimensions/TypeField.php index 648c80ae..68eda6bd 100644 --- a/src/Fields/Dimensions/TypeField.php +++ b/src/Fields/Dimensions/TypeField.php @@ -28,4 +28,4 @@ public function setType(?ChildValidationType $type): self $this->type = $type; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Dimensions/VatCodeFixedField.php b/src/Fields/Dimensions/VatCodeFixedField.php index 7282343c..12b1f63a 100644 --- a/src/Fields/Dimensions/VatCodeFixedField.php +++ b/src/Fields/Dimensions/VatCodeFixedField.php @@ -29,4 +29,4 @@ public function setVatCodeFixed(?bool $vatCodeFixed): self $this->vatCodeFixed = $vatCodeFixed; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/DueDateField.php b/src/Fields/DueDateField.php index c5201eba..29b2fe26 100644 --- a/src/Fields/DueDateField.php +++ b/src/Fields/DueDateField.php @@ -32,4 +32,4 @@ public function setDueDate(?\DateTimeInterface $dueDate) $this->dueDate = $dueDate; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/ElementValueField.php b/src/Fields/ElementValueField.php index ba8adf61..67eaf852 100644 --- a/src/Fields/ElementValueField.php +++ b/src/Fields/ElementValueField.php @@ -29,4 +29,4 @@ public function setElementValue(?string $value): self $this->value = $value; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/EmailField.php b/src/Fields/EmailField.php index 9e0d4094..a6786280 100644 --- a/src/Fields/EmailField.php +++ b/src/Fields/EmailField.php @@ -29,4 +29,4 @@ public function setEmail(?string $email): self $this->email = $email; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/FreeText1Field.php b/src/Fields/FreeText1Field.php index 9327613e..327b1200 100644 --- a/src/Fields/FreeText1Field.php +++ b/src/Fields/FreeText1Field.php @@ -29,4 +29,4 @@ public function setFreeText1(?string $freeText1): self $this->freeText1 = $freeText1; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/FreeText2Field.php b/src/Fields/FreeText2Field.php index 2acdf4b6..89500d91 100644 --- a/src/Fields/FreeText2Field.php +++ b/src/Fields/FreeText2Field.php @@ -29,4 +29,4 @@ public function setFreeText2(?string $freeText2): self $this->freeText2 = $freeText2; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/FreeText3Field.php b/src/Fields/FreeText3Field.php index 563c085a..717ab6f1 100644 --- a/src/Fields/FreeText3Field.php +++ b/src/Fields/FreeText3Field.php @@ -29,4 +29,4 @@ public function setFreeText3(?string $freeText3): self $this->freeText3 = $freeText3; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/IDField.php b/src/Fields/IDField.php index 28b4df21..8d6cac73 100644 --- a/src/Fields/IDField.php +++ b/src/Fields/IDField.php @@ -29,4 +29,4 @@ public function setID(?int $ID): self $this->ID = $ID; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/InUseField.php b/src/Fields/InUseField.php index dbf8ba24..36fbe655 100644 --- a/src/Fields/InUseField.php +++ b/src/Fields/InUseField.php @@ -29,4 +29,4 @@ public function setInUse(?bool $inUse): self $this->inUse = $inUse; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/AllowDiscountOrPremiumField.php b/src/Fields/Invoice/AllowDiscountOrPremiumField.php index fc8eea09..b2dc356d 100644 --- a/src/Fields/Invoice/AllowDiscountOrPremiumField.php +++ b/src/Fields/Invoice/AllowDiscountOrPremiumField.php @@ -19,7 +19,7 @@ public function getAllowDiscountOrPremium(): ?bool { return $this->allowDiscountOrPremium; } - + /** * @param bool $allowDiscountOrPremium * @return $this @@ -29,4 +29,4 @@ public function setAllowDiscountOrPremium(?bool $allowDiscountOrPremium): self $this->allowDiscountOrPremium = $allowDiscountOrPremium; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/Article/AllowChangePerformanceTypeField.php b/src/Fields/Invoice/Article/AllowChangePerformanceTypeField.php index 7ac1b0c2..dafd9701 100644 --- a/src/Fields/Invoice/Article/AllowChangePerformanceTypeField.php +++ b/src/Fields/Invoice/Article/AllowChangePerformanceTypeField.php @@ -29,4 +29,4 @@ public function setAllowChangePerformanceType(?bool $allowChangePerformanceType) $this->allowChangePerformanceType = $allowChangePerformanceType; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/Article/AllowChangeUnitsPriceField.php b/src/Fields/Invoice/Article/AllowChangeUnitsPriceField.php index 4b53502e..103ae714 100644 --- a/src/Fields/Invoice/Article/AllowChangeUnitsPriceField.php +++ b/src/Fields/Invoice/Article/AllowChangeUnitsPriceField.php @@ -19,7 +19,7 @@ public function getAllowChangeUnitsPrice(): ?bool { return $this->allowChangeUnitsPrice; } - + /** * @param bool $allowChangeUnitsPrice * @return $this @@ -29,4 +29,4 @@ public function setAllowChangeUnitsPrice(?bool $allowChangeUnitsPrice): self $this->allowChangeUnitsPrice = $allowChangeUnitsPrice; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/Article/AllowChangeVatCodeField.php b/src/Fields/Invoice/Article/AllowChangeVatCodeField.php index 5f821b4b..8d5f24c2 100644 --- a/src/Fields/Invoice/Article/AllowChangeVatCodeField.php +++ b/src/Fields/Invoice/Article/AllowChangeVatCodeField.php @@ -19,7 +19,7 @@ public function getAllowChangeVatCode(): ?bool { return $this->allowChangeVatCode; } - + /** * @param bool $allowChangeVatCode * @return $this @@ -29,4 +29,4 @@ public function setAllowChangeVatCode(?bool $allowChangeVatCode): self $this->allowChangeVatCode = $allowChangeVatCode; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/Article/AllowDecimalQuantityField.php b/src/Fields/Invoice/Article/AllowDecimalQuantityField.php index 206603fa..e88b691b 100644 --- a/src/Fields/Invoice/Article/AllowDecimalQuantityField.php +++ b/src/Fields/Invoice/Article/AllowDecimalQuantityField.php @@ -19,7 +19,7 @@ public function getAllowDecimalQuantity(): ?bool { return $this->allowDecimalQuantity; } - + /** * @param bool $allowDecimalQuantity * @return $this @@ -29,4 +29,4 @@ public function setAllowDecimalQuantity(?bool $allowDecimalQuantity): self $this->allowDecimalQuantity = $allowDecimalQuantity; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/Article/PercentageField.php b/src/Fields/Invoice/Article/PercentageField.php index e8467321..890325ca 100644 --- a/src/Fields/Invoice/Article/PercentageField.php +++ b/src/Fields/Invoice/Article/PercentageField.php @@ -29,4 +29,4 @@ public function setPercentage(?bool $percentage): self $this->percentage = $percentage; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/Article/SubCodeField.php b/src/Fields/Invoice/Article/SubCodeField.php index c283bf5d..7b8cfcce 100644 --- a/src/Fields/Invoice/Article/SubCodeField.php +++ b/src/Fields/Invoice/Article/SubCodeField.php @@ -29,4 +29,4 @@ public function setSubCode(?string $subCode): self $this->subCode = $subCode; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/Article/TypeField.php b/src/Fields/Invoice/Article/TypeField.php index 8136551e..0d76d838 100644 --- a/src/Fields/Invoice/Article/TypeField.php +++ b/src/Fields/Invoice/Article/TypeField.php @@ -28,4 +28,4 @@ public function setType(?ArticleType $type): self $this->type = $type; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/Article/UnitNamePluralField.php b/src/Fields/Invoice/Article/UnitNamePluralField.php index 01100be2..1950a804 100644 --- a/src/Fields/Invoice/Article/UnitNamePluralField.php +++ b/src/Fields/Invoice/Article/UnitNamePluralField.php @@ -29,4 +29,4 @@ public function setUnitNamePlural(?string $unitNamePlural): self $this->unitNamePlural = $unitNamePlural; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/Article/UnitNameSingularField.php b/src/Fields/Invoice/Article/UnitNameSingularField.php index 058a8758..b2b1fafa 100644 --- a/src/Fields/Invoice/Article/UnitNameSingularField.php +++ b/src/Fields/Invoice/Article/UnitNameSingularField.php @@ -29,4 +29,4 @@ public function setUnitNameSingular(?string $unitNameSingular): self $this->unitNameSingular = $unitNameSingular; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/ArticleField.php b/src/Fields/Invoice/ArticleField.php index f412b76c..bb68a67a 100644 --- a/src/Fields/Invoice/ArticleField.php +++ b/src/Fields/Invoice/ArticleField.php @@ -6,7 +6,7 @@ /** * The article - * Used by: InvoiceLine + * Used by: InvoiceLine * * @package PhpTwinfield\Traits */ diff --git a/src/Fields/Invoice/CalculateOnlyField.php b/src/Fields/Invoice/CalculateOnlyField.php index db36dcc4..589d6310 100644 --- a/src/Fields/Invoice/CalculateOnlyField.php +++ b/src/Fields/Invoice/CalculateOnlyField.php @@ -29,4 +29,4 @@ public function setCalculateOnly(?bool $calculateOnly): self $this->calculateOnly = $calculateOnly; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/CustomerNameField.php b/src/Fields/Invoice/CustomerNameField.php index 088ea076..1edad3a1 100644 --- a/src/Fields/Invoice/CustomerNameField.php +++ b/src/Fields/Invoice/CustomerNameField.php @@ -29,4 +29,4 @@ public function setCustomerName(?string $customerName): self $this->customerName = $customerName; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/DebitCreditField.php b/src/Fields/Invoice/DebitCreditField.php index 1091fb58..be0a67b7 100644 --- a/src/Fields/Invoice/DebitCreditField.php +++ b/src/Fields/Invoice/DebitCreditField.php @@ -38,4 +38,4 @@ public function setDebitCreditFromString(?string $debitCreditString) { return $this->setDebitCredit(new InvoiceDebitCredit((string)$debitCreditString)); } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/DeliverAddressNumberField.php b/src/Fields/Invoice/DeliverAddressNumberField.php index 6eca97dc..94615620 100644 --- a/src/Fields/Invoice/DeliverAddressNumberField.php +++ b/src/Fields/Invoice/DeliverAddressNumberField.php @@ -29,4 +29,4 @@ public function setDeliverAddressNumber(?int $deliverAddressNumber): self $this->deliverAddressNumber = $deliverAddressNumber; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/FinancialCodeField.php b/src/Fields/Invoice/FinancialCodeField.php index 44888729..c6641acd 100644 --- a/src/Fields/Invoice/FinancialCodeField.php +++ b/src/Fields/Invoice/FinancialCodeField.php @@ -29,4 +29,4 @@ public function setFinancialCode(?string $financialCode): self $this->financialCode = $financialCode; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/FinancialNumberField.php b/src/Fields/Invoice/FinancialNumberField.php index f517b16f..5562715a 100644 --- a/src/Fields/Invoice/FinancialNumberField.php +++ b/src/Fields/Invoice/FinancialNumberField.php @@ -29,4 +29,4 @@ public function setFinancialNumber(?int $financialNumber): self $this->financialNumber = $financialNumber; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/FooterTextField.php b/src/Fields/Invoice/FooterTextField.php index 1984a35d..f0772237 100644 --- a/src/Fields/Invoice/FooterTextField.php +++ b/src/Fields/Invoice/FooterTextField.php @@ -29,4 +29,4 @@ public function setFooterText(?string $footerText): self $this->footerText = $footerText; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/HeaderTextField.php b/src/Fields/Invoice/HeaderTextField.php index a8e480d1..977ee938 100644 --- a/src/Fields/Invoice/HeaderTextField.php +++ b/src/Fields/Invoice/HeaderTextField.php @@ -29,4 +29,4 @@ public function setHeaderText(?string $headerText): self $this->headerText = $headerText; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/InvoiceAddressNumberField.php b/src/Fields/Invoice/InvoiceAddressNumberField.php index 66e58741..4742fc0f 100644 --- a/src/Fields/Invoice/InvoiceAddressNumberField.php +++ b/src/Fields/Invoice/InvoiceAddressNumberField.php @@ -29,4 +29,4 @@ public function setInvoiceAddressNumber(?int $invoiceAddressNumber): self $this->invoiceAddressNumber = $invoiceAddressNumber; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/InvoiceAmountField.php b/src/Fields/Invoice/InvoiceAmountField.php index 6789aa1c..c0a1335f 100644 --- a/src/Fields/Invoice/InvoiceAmountField.php +++ b/src/Fields/Invoice/InvoiceAmountField.php @@ -22,7 +22,7 @@ public function getInvoiceAmount(): ?Money { return $this->invoiceAmount; } - + /** * @param Money|null $invoiceAmount * @return $this @@ -47,4 +47,4 @@ public function setInvoiceAmountFromFloat(?float $invoiceAmountFloat) return $this->setInvoiceAmount(Money::EUR(0)); } } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/InvoiceDateField.php b/src/Fields/Invoice/InvoiceDateField.php index a53474cd..27e96f5e 100644 --- a/src/Fields/Invoice/InvoiceDateField.php +++ b/src/Fields/Invoice/InvoiceDateField.php @@ -32,4 +32,4 @@ public function setInvoiceDate(?\DateTimeInterface $invoiceDate) $this->invoiceDate = $invoiceDate; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/PaymentMethodField.php b/src/Fields/Invoice/PaymentMethodField.php index 62e3e467..644b898c 100644 --- a/src/Fields/Invoice/PaymentMethodField.php +++ b/src/Fields/Invoice/PaymentMethodField.php @@ -28,4 +28,4 @@ public function setPaymentMethod(?PaymentMethod $paymentMethod): self $this->paymentMethod = $paymentMethod; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/PeriodRaiseWarningField.php b/src/Fields/Invoice/PeriodRaiseWarningField.php index 650fccc8..8bcbe56d 100644 --- a/src/Fields/Invoice/PeriodRaiseWarningField.php +++ b/src/Fields/Invoice/PeriodRaiseWarningField.php @@ -19,7 +19,7 @@ public function getPeriodRaiseWarning(): ?bool { return $this->periodRaiseWarning; } - + /** * @param bool $periodRaiseWarning * @return $this @@ -29,4 +29,4 @@ public function setPeriodRaiseWarning(?bool $periodRaiseWarning): self $this->periodRaiseWarning = $periodRaiseWarning; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/QuantityField.php b/src/Fields/Invoice/QuantityField.php index cdcee930..7804c80f 100644 --- a/src/Fields/Invoice/QuantityField.php +++ b/src/Fields/Invoice/QuantityField.php @@ -29,4 +29,4 @@ public function setQuantity(?float $quantity): self $this->quantity = $quantity; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/RaiseWarningField.php b/src/Fields/Invoice/RaiseWarningField.php index 0206349d..f56abbdc 100644 --- a/src/Fields/Invoice/RaiseWarningField.php +++ b/src/Fields/Invoice/RaiseWarningField.php @@ -29,4 +29,4 @@ public function setRaiseWarning(?bool $raiseWarning): self $this->raiseWarning = $raiseWarning; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/StatusField.php b/src/Fields/Invoice/StatusField.php index ccc2fc82..f39536dc 100644 --- a/src/Fields/Invoice/StatusField.php +++ b/src/Fields/Invoice/StatusField.php @@ -28,4 +28,4 @@ public function setStatus(?InvoiceStatus $status): self $this->status = $status; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/SubArticleField.php b/src/Fields/Invoice/SubArticleField.php index 402f3e67..b89d7df2 100644 --- a/src/Fields/Invoice/SubArticleField.php +++ b/src/Fields/Invoice/SubArticleField.php @@ -6,7 +6,7 @@ /** * The sub article - * Used by: InvoiceLine + * Used by: InvoiceLine * * @package PhpTwinfield\Traits */ @@ -39,7 +39,7 @@ public function setSubArticle(?ArticleLine $subArticle): self $this->subArticle = $subArticle; return $this; } - + /** * @param string|null $subArticleString * @return $this diff --git a/src/Fields/Invoice/UnitsField.php b/src/Fields/Invoice/UnitsField.php index 7aa0a54d..7054b04b 100644 --- a/src/Fields/Invoice/UnitsField.php +++ b/src/Fields/Invoice/UnitsField.php @@ -29,4 +29,4 @@ public function setUnits(?int $units): self $this->units = $units; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/UnitsPriceExclField.php b/src/Fields/Invoice/UnitsPriceExclField.php index 860b5c60..db2649f9 100644 --- a/src/Fields/Invoice/UnitsPriceExclField.php +++ b/src/Fields/Invoice/UnitsPriceExclField.php @@ -21,7 +21,7 @@ public function getUnitsPriceExcl(): ?Money { return $this->unitsPriceExcl; } - + /** * @param Money|null $unitsPriceExcl * @return $this @@ -32,4 +32,4 @@ public function setUnitsPriceExcl(?Money $unitsPriceExcl) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/UnitsPriceIncField.php b/src/Fields/Invoice/UnitsPriceIncField.php index 04aabd62..3932b504 100644 --- a/src/Fields/Invoice/UnitsPriceIncField.php +++ b/src/Fields/Invoice/UnitsPriceIncField.php @@ -32,4 +32,4 @@ public function setUnitsPriceInc(?Money $unitsPriceInc) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/ValueExclField.php b/src/Fields/Invoice/ValueExclField.php index a4694254..c45eca25 100644 --- a/src/Fields/Invoice/ValueExclField.php +++ b/src/Fields/Invoice/ValueExclField.php @@ -32,4 +32,4 @@ public function setValueExcl(?Money $valueExcl) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Invoice/ValueIncField.php b/src/Fields/Invoice/ValueIncField.php index f8ef58d3..1a24dc97 100644 --- a/src/Fields/Invoice/ValueIncField.php +++ b/src/Fields/Invoice/ValueIncField.php @@ -32,4 +32,4 @@ public function setValueInc(?Money $valueInc) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/InvoiceNumberField.php b/src/Fields/InvoiceNumberField.php index 70d09bc5..d9486ba0 100644 --- a/src/Fields/InvoiceNumberField.php +++ b/src/Fields/InvoiceNumberField.php @@ -29,4 +29,4 @@ public function setInvoiceNumber(?string $invoiceNumber): self $this->invoiceNumber = $invoiceNumber; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/LevelField.php b/src/Fields/LevelField.php index feb4873f..82936160 100644 --- a/src/Fields/LevelField.php +++ b/src/Fields/LevelField.php @@ -29,4 +29,4 @@ public function setLevel(?int $level): self $this->level = $level; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/LineTypeField.php b/src/Fields/LineTypeField.php index 8ae87b39..db93ee3b 100644 --- a/src/Fields/LineTypeField.php +++ b/src/Fields/LineTypeField.php @@ -28,4 +28,4 @@ public function setLineType(?LineType $lineType): self $this->lineType = $lineType; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/ModifiedField.php b/src/Fields/ModifiedField.php index 00042d7c..51460f04 100644 --- a/src/Fields/ModifiedField.php +++ b/src/Fields/ModifiedField.php @@ -32,4 +32,4 @@ public function setModified(?\DateTimeInterface $modified) $this->modified = $modified; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/NameField.php b/src/Fields/NameField.php index d542794d..d53640e4 100644 --- a/src/Fields/NameField.php +++ b/src/Fields/NameField.php @@ -28,4 +28,4 @@ public function setName(?string $name): self $this->name = $name; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/NrOfPeriodsField.php b/src/Fields/NrOfPeriodsField.php index 4cf207d2..77092b3c 100644 --- a/src/Fields/NrOfPeriodsField.php +++ b/src/Fields/NrOfPeriodsField.php @@ -29,4 +29,4 @@ public function setNrOfPeriods(?int $nrOfPeriods): self $this->nrOfPeriods = $nrOfPeriods; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Office/BaseCurrencyField.php b/src/Fields/Office/BaseCurrencyField.php index c414d222..443a0164 100644 --- a/src/Fields/Office/BaseCurrencyField.php +++ b/src/Fields/Office/BaseCurrencyField.php @@ -30,4 +30,4 @@ public function setBaseCurrency(?Currency $baseCurrency): self $this->baseCurrency = $baseCurrency; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Office/CountryCodeField.php b/src/Fields/Office/CountryCodeField.php index f3d8389c..eaee87dd 100644 --- a/src/Fields/Office/CountryCodeField.php +++ b/src/Fields/Office/CountryCodeField.php @@ -21,7 +21,7 @@ public function getCountryCode(): ?Country { return $this->countryCode; } - + /** * @return $this */ @@ -42,4 +42,4 @@ public function setCountryCodeFromString(?string $countryCodeString) $countryCode->setCode($countryCodeString); return $this->setCountryCode($countryCode); } -} \ No newline at end of file +} diff --git a/src/Fields/Office/ReportingCurrencyField.php b/src/Fields/Office/ReportingCurrencyField.php index 47a7ce64..2cd3f87e 100644 --- a/src/Fields/Office/ReportingCurrencyField.php +++ b/src/Fields/Office/ReportingCurrencyField.php @@ -21,7 +21,7 @@ public function getReportingCurrency(): ?Currency { return $this->reportingCurrency; } - + /** * @return $this */ @@ -30,4 +30,4 @@ public function setReportingCurrency(?Currency $reportingCurrency): self $this->reportingCurrency = $reportingCurrency; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Office/VatFirstQuarterStartsInField.php b/src/Fields/Office/VatFirstQuarterStartsInField.php index 9121db8a..8716b90c 100644 --- a/src/Fields/Office/VatFirstQuarterStartsInField.php +++ b/src/Fields/Office/VatFirstQuarterStartsInField.php @@ -29,4 +29,4 @@ public function setVatFirstQuarterStartsIn(?string $vatFirstQuarterStartsIn): se $this->vatFirstQuarterStartsIn = $vatFirstQuarterStartsIn; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Office/VatPeriodField.php b/src/Fields/Office/VatPeriodField.php index 91659020..9f754ddd 100644 --- a/src/Fields/Office/VatPeriodField.php +++ b/src/Fields/Office/VatPeriodField.php @@ -29,4 +29,4 @@ public function setVatPeriod(?string $vatPeriod): self $this->vatPeriod = $vatPeriod; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/PercentageField.php b/src/Fields/PercentageField.php index 6a067250..22f8de0d 100644 --- a/src/Fields/PercentageField.php +++ b/src/Fields/PercentageField.php @@ -29,4 +29,4 @@ public function setPercentage(?float $percentage): self $this->percentage = $percentage; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/PerformanceDateField.php b/src/Fields/PerformanceDateField.php index 863eb6e4..eea29cba 100644 --- a/src/Fields/PerformanceDateField.php +++ b/src/Fields/PerformanceDateField.php @@ -34,4 +34,4 @@ public function setPerformanceDate(?\DateTimeInterface $performanceDate) $this->performanceDate = $performanceDate; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/PerformanceTypeField.php b/src/Fields/PerformanceTypeField.php index 80cdcb18..ff497ed0 100644 --- a/src/Fields/PerformanceTypeField.php +++ b/src/Fields/PerformanceTypeField.php @@ -28,4 +28,4 @@ public function setPerformanceType(?PerformanceType $performanceType): self $this->performanceType = $performanceType; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Rate/BeginDateField.php b/src/Fields/Rate/BeginDateField.php index 7cb38ff3..750ead1c 100644 --- a/src/Fields/Rate/BeginDateField.php +++ b/src/Fields/Rate/BeginDateField.php @@ -33,4 +33,4 @@ public function setBeginDate(?\DateTimeInterface $beginDate) $this->beginDate = $beginDate; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Rate/EndDateField.php b/src/Fields/Rate/EndDateField.php index cab719b4..a9e0e6c7 100644 --- a/src/Fields/Rate/EndDateField.php +++ b/src/Fields/Rate/EndDateField.php @@ -22,7 +22,7 @@ public function getEndDate(): ?\DateTimeInterface { return $this->endDate; } - + /** * @param \DateTimeInterface|null $endDate * @return $this @@ -32,4 +32,4 @@ public function setEndDate(?\DateTimeInterface $endDate) $this->endDate = $endDate; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Rate/ExternalRateField.php b/src/Fields/Rate/ExternalRateField.php index bbb6fb55..8c52d7f0 100644 --- a/src/Fields/Rate/ExternalRateField.php +++ b/src/Fields/Rate/ExternalRateField.php @@ -29,4 +29,4 @@ public function setExternalRate(?float $externalRate): self $this->externalRate = $externalRate; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Rate/InternalRateField.php b/src/Fields/Rate/InternalRateField.php index 821688b2..3e61f833 100644 --- a/src/Fields/Rate/InternalRateField.php +++ b/src/Fields/Rate/InternalRateField.php @@ -29,4 +29,4 @@ public function setInternalRate(?float $internalRate): self $this->internalRate = $internalRate; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Rate/TypeField.php b/src/Fields/Rate/TypeField.php index 15e2b20c..32894aa0 100644 --- a/src/Fields/Rate/TypeField.php +++ b/src/Fields/Rate/TypeField.php @@ -28,4 +28,4 @@ public function setType(?RateType $type): self $this->type = $type; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Rate/UnitField.php b/src/Fields/Rate/UnitField.php index 6bd5e173..7094abde 100644 --- a/src/Fields/Rate/UnitField.php +++ b/src/Fields/Rate/UnitField.php @@ -29,4 +29,4 @@ public function setUnit(?int $unit): self $this->unit = $unit; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/ShortNameField.php b/src/Fields/ShortNameField.php index d32c7fe7..f0f14a87 100644 --- a/src/Fields/ShortNameField.php +++ b/src/Fields/ShortNameField.php @@ -28,4 +28,4 @@ public function setShortName(?string $shortName): self $this->shortName = $shortName; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/StatusField.php b/src/Fields/StatusField.php index 1f25d8e8..6eaec94d 100644 --- a/src/Fields/StatusField.php +++ b/src/Fields/StatusField.php @@ -27,4 +27,4 @@ public function setStatus(?Status $status): self $this->status = $status; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/TouchedField.php b/src/Fields/TouchedField.php index 80296788..59387dfb 100644 --- a/src/Fields/TouchedField.php +++ b/src/Fields/TouchedField.php @@ -29,4 +29,4 @@ public function setTouched(?int $touched): self $this->touched = $touched; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/AutoBalanceVatField.php b/src/Fields/Transaction/AutoBalanceVatField.php index ef76c128..34a61255 100644 --- a/src/Fields/Transaction/AutoBalanceVatField.php +++ b/src/Fields/Transaction/AutoBalanceVatField.php @@ -29,4 +29,4 @@ public function setAutoBalanceVat(?bool $autoBalanceVat): self $this->autoBalanceVat = $autoBalanceVat; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/CloseAndStartValueFields.php b/src/Fields/Transaction/CloseAndStartValueFields.php index 685fcaec..9f57fe80 100644 --- a/src/Fields/Transaction/CloseAndStartValueFields.php +++ b/src/Fields/Transaction/CloseAndStartValueFields.php @@ -75,4 +75,4 @@ public function getCloseValue(): Money { return $this->closeValue ?? new Money(0, new \Money\Currency($this->getCurrency()->getCode())); } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/DateRaiseWarningField.php b/src/Fields/Transaction/DateRaiseWarningField.php index 573da7e0..5a56d073 100644 --- a/src/Fields/Transaction/DateRaiseWarningField.php +++ b/src/Fields/Transaction/DateRaiseWarningField.php @@ -34,4 +34,4 @@ public function setDateRaiseWarning(?bool $dateRaiseWarning): self $this->dateRaiseWarning = $dateRaiseWarning; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/DestinyField.php b/src/Fields/Transaction/DestinyField.php index 5932acb5..f96be78b 100644 --- a/src/Fields/Transaction/DestinyField.php +++ b/src/Fields/Transaction/DestinyField.php @@ -28,4 +28,4 @@ public function setDestiny(?Destiny $destiny): self $this->destiny = $destiny; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/InputDateField.php b/src/Fields/Transaction/InputDateField.php index c8ed49e9..30a213b3 100644 --- a/src/Fields/Transaction/InputDateField.php +++ b/src/Fields/Transaction/InputDateField.php @@ -32,4 +32,4 @@ public function setInputDate(?\DateTimeInterface $inputDate) $this->inputDate = $inputDate; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/InvoiceNumberRaiseWarningField.php b/src/Fields/Transaction/InvoiceNumberRaiseWarningField.php index 524ba0b7..459ee440 100644 --- a/src/Fields/Transaction/InvoiceNumberRaiseWarningField.php +++ b/src/Fields/Transaction/InvoiceNumberRaiseWarningField.php @@ -34,4 +34,4 @@ public function setInvoiceNumberRaiseWarning(?bool $invoiceNumberRaiseWarning): $this->invoiceNumberRaiseWarning = $invoiceNumberRaiseWarning; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/ModificationDateField.php b/src/Fields/Transaction/ModificationDateField.php index 24ca8f1b..fab37f1e 100644 --- a/src/Fields/Transaction/ModificationDateField.php +++ b/src/Fields/Transaction/ModificationDateField.php @@ -32,4 +32,4 @@ public function setModificationDate(?\DateTimeInterface $modificationDate) $this->modificationDate = $modificationDate; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/NumberField.php b/src/Fields/Transaction/NumberField.php index 67247915..548e1116 100644 --- a/src/Fields/Transaction/NumberField.php +++ b/src/Fields/Transaction/NumberField.php @@ -29,4 +29,4 @@ public function setNumber(?int $number): self $this->number = $number; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/OriginField.php b/src/Fields/Transaction/OriginField.php index f64111f7..91c574cd 100644 --- a/src/Fields/Transaction/OriginField.php +++ b/src/Fields/Transaction/OriginField.php @@ -29,4 +29,4 @@ public function setOrigin(?string $origin): self $this->origin = $origin; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/OriginReferenceField.php b/src/Fields/Transaction/OriginReferenceField.php index 6e9c2557..8efc259c 100644 --- a/src/Fields/Transaction/OriginReferenceField.php +++ b/src/Fields/Transaction/OriginReferenceField.php @@ -29,4 +29,4 @@ public function setOriginReference(?string $originReference): self $this->originReference = $originReference; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/PaymentReferenceField.php b/src/Fields/Transaction/PaymentReferenceField.php index fcca6770..dc58b413 100644 --- a/src/Fields/Transaction/PaymentReferenceField.php +++ b/src/Fields/Transaction/PaymentReferenceField.php @@ -29,4 +29,4 @@ public function setPaymentReference(?string $paymentReference): self $this->paymentReference = $paymentReference; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/RaiseWarningField.php b/src/Fields/Transaction/RaiseWarningField.php index dcd0af3e..782c09ff 100644 --- a/src/Fields/Transaction/RaiseWarningField.php +++ b/src/Fields/Transaction/RaiseWarningField.php @@ -29,4 +29,4 @@ public function setRaiseWarning(?bool $raiseWarning): self $this->raiseWarning = $raiseWarning; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/RegimeField.php b/src/Fields/Transaction/RegimeField.php index 11e791a6..ce03e896 100644 --- a/src/Fields/Transaction/RegimeField.php +++ b/src/Fields/Transaction/RegimeField.php @@ -28,4 +28,4 @@ public function setRegime(?Regime $regime): self $this->regime = $regime; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/StatementNumberField.php b/src/Fields/Transaction/StatementNumberField.php index ba3f23eb..0b11eead 100644 --- a/src/Fields/Transaction/StatementNumberField.php +++ b/src/Fields/Transaction/StatementNumberField.php @@ -29,4 +29,4 @@ public function setStatementNumber(?int $statementNumber): self $this->statementNumber = $statementNumber; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/BaseValueField.php b/src/Fields/Transaction/TransactionLine/BaseValueField.php index b975f736..ede0778b 100644 --- a/src/Fields/Transaction/TransactionLine/BaseValueField.php +++ b/src/Fields/Transaction/TransactionLine/BaseValueField.php @@ -32,4 +32,4 @@ public function setBaseValue(?Money $baseValue) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/BaseValueOpenField.php b/src/Fields/Transaction/TransactionLine/BaseValueOpenField.php index 02d64435..a8e4ea6d 100644 --- a/src/Fields/Transaction/TransactionLine/BaseValueOpenField.php +++ b/src/Fields/Transaction/TransactionLine/BaseValueOpenField.php @@ -21,7 +21,7 @@ public function getBaseValueOpen(): ?Money { return $this->baseValueOpen; } - + /** * @param Money|null $baseValueOpen * @return $this @@ -32,4 +32,4 @@ public function setBaseValueOpen(?Money $baseValueOpen) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/BaselineField.php b/src/Fields/Transaction/TransactionLine/BaselineField.php index ec0f0c88..64364e4b 100644 --- a/src/Fields/Transaction/TransactionLine/BaselineField.php +++ b/src/Fields/Transaction/TransactionLine/BaselineField.php @@ -29,4 +29,4 @@ public function setBaseline(?int $baseline): self $this->baseline = $baseline; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/CurrencyDateField.php b/src/Fields/Transaction/TransactionLine/CurrencyDateField.php index ff5022d2..f6c49a7d 100644 --- a/src/Fields/Transaction/TransactionLine/CurrencyDateField.php +++ b/src/Fields/Transaction/TransactionLine/CurrencyDateField.php @@ -32,4 +32,4 @@ public function setCurrencyDate(?\DateTimeInterface $currencyDate) $this->currencyDate = $currencyDate; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/MatchDateField.php b/src/Fields/Transaction/TransactionLine/MatchDateField.php index dfcc7e6f..d9f4b565 100644 --- a/src/Fields/Transaction/TransactionLine/MatchDateField.php +++ b/src/Fields/Transaction/TransactionLine/MatchDateField.php @@ -32,4 +32,4 @@ public function setMatchDate(?\DateTimeInterface $matchDate) $this->matchDate = $matchDate; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/MatchLevelField.php b/src/Fields/Transaction/TransactionLine/MatchLevelField.php index ed3019fb..0d98e33f 100644 --- a/src/Fields/Transaction/TransactionLine/MatchLevelField.php +++ b/src/Fields/Transaction/TransactionLine/MatchLevelField.php @@ -29,4 +29,4 @@ public function setMatchLevel(?int $matchLevel): self $this->matchLevel = $matchLevel; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/MatchStatusField.php b/src/Fields/Transaction/TransactionLine/MatchStatusField.php index 68bf37fd..8679e60a 100644 --- a/src/Fields/Transaction/TransactionLine/MatchStatusField.php +++ b/src/Fields/Transaction/TransactionLine/MatchStatusField.php @@ -27,4 +27,4 @@ public function setMatchStatus(?MatchStatus $matchStatus): self $this->matchStatus = $matchStatus; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/PerformanceCountryField.php b/src/Fields/Transaction/TransactionLine/PerformanceCountryField.php index 96bb9a37..9efd578f 100644 --- a/src/Fields/Transaction/TransactionLine/PerformanceCountryField.php +++ b/src/Fields/Transaction/TransactionLine/PerformanceCountryField.php @@ -30,4 +30,4 @@ public function setPerformanceCountry(?Country $performanceCountry): self $this->performanceCountry = $performanceCountry; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/PerformanceVatNumberField.php b/src/Fields/Transaction/TransactionLine/PerformanceVatNumberField.php index fee4c6db..e10a1647 100644 --- a/src/Fields/Transaction/TransactionLine/PerformanceVatNumberField.php +++ b/src/Fields/Transaction/TransactionLine/PerformanceVatNumberField.php @@ -29,4 +29,4 @@ public function setPerformanceVatNumber(?string $performanceVatNumber): self $this->performanceVatNumber = $performanceVatNumber; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/RateField.php b/src/Fields/Transaction/TransactionLine/RateField.php index 68dca839..d742c842 100644 --- a/src/Fields/Transaction/TransactionLine/RateField.php +++ b/src/Fields/Transaction/TransactionLine/RateField.php @@ -29,4 +29,4 @@ public function setRate(?float $rate): self $this->rate = $rate; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/RelationField.php b/src/Fields/Transaction/TransactionLine/RelationField.php index 98cb533a..9f35e09c 100644 --- a/src/Fields/Transaction/TransactionLine/RelationField.php +++ b/src/Fields/Transaction/TransactionLine/RelationField.php @@ -29,4 +29,4 @@ public function setRelation(?int $relation): self $this->relation = $relation; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/RepRateField.php b/src/Fields/Transaction/TransactionLine/RepRateField.php index 99038ffb..54996c49 100644 --- a/src/Fields/Transaction/TransactionLine/RepRateField.php +++ b/src/Fields/Transaction/TransactionLine/RepRateField.php @@ -29,4 +29,4 @@ public function setRepRate(?float $repRate): self $this->repRate = $repRate; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/RepValueField.php b/src/Fields/Transaction/TransactionLine/RepValueField.php index d6e373f5..04910aca 100644 --- a/src/Fields/Transaction/TransactionLine/RepValueField.php +++ b/src/Fields/Transaction/TransactionLine/RepValueField.php @@ -32,4 +32,4 @@ public function setRepValue(?Money $repValue) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/RepValueOpenField.php b/src/Fields/Transaction/TransactionLine/RepValueOpenField.php index 8988525c..e0f01d5a 100644 --- a/src/Fields/Transaction/TransactionLine/RepValueOpenField.php +++ b/src/Fields/Transaction/TransactionLine/RepValueOpenField.php @@ -32,4 +32,4 @@ public function setRepValueOpen(?Money $repValueOpen) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/ValueFields.php b/src/Fields/Transaction/TransactionLine/ValueFields.php index 6585508e..a405c7f8 100644 --- a/src/Fields/Transaction/TransactionLine/ValueFields.php +++ b/src/Fields/Transaction/TransactionLine/ValueFields.php @@ -112,4 +112,4 @@ public function setValue(Money $value) $this->value = $value; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/ValueOpenField.php b/src/Fields/Transaction/TransactionLine/ValueOpenField.php index e703bffa..4e053397 100644 --- a/src/Fields/Transaction/TransactionLine/ValueOpenField.php +++ b/src/Fields/Transaction/TransactionLine/ValueOpenField.php @@ -32,4 +32,4 @@ public function setValueOpen(?Money $valueOpen) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/VatBaseTotalField.php b/src/Fields/Transaction/TransactionLine/VatBaseTotalField.php index 845a2e74..b760f58d 100644 --- a/src/Fields/Transaction/TransactionLine/VatBaseTotalField.php +++ b/src/Fields/Transaction/TransactionLine/VatBaseTotalField.php @@ -32,4 +32,4 @@ public function setVatBaseTotal(?Money $vatBaseTotal) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/VatBaseTurnoverField.php b/src/Fields/Transaction/TransactionLine/VatBaseTurnoverField.php index bb2d396a..8ddb15a0 100644 --- a/src/Fields/Transaction/TransactionLine/VatBaseTurnoverField.php +++ b/src/Fields/Transaction/TransactionLine/VatBaseTurnoverField.php @@ -32,4 +32,4 @@ public function setVatBaseTurnover(?Money $vatBaseTurnover) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/VatBaseValueField.php b/src/Fields/Transaction/TransactionLine/VatBaseValueField.php index 0b948aa5..6190a248 100644 --- a/src/Fields/Transaction/TransactionLine/VatBaseValueField.php +++ b/src/Fields/Transaction/TransactionLine/VatBaseValueField.php @@ -32,4 +32,4 @@ public function setVatBaseValue(?Money $vatBaseValue) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/VatRepTotalField.php b/src/Fields/Transaction/TransactionLine/VatRepTotalField.php index 500c4b0f..334af949 100644 --- a/src/Fields/Transaction/TransactionLine/VatRepTotalField.php +++ b/src/Fields/Transaction/TransactionLine/VatRepTotalField.php @@ -32,4 +32,4 @@ public function setVatRepTotal(?Money $vatRepTotal) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/VatRepTurnoverField.php b/src/Fields/Transaction/TransactionLine/VatRepTurnoverField.php index 117607eb..621bcbca 100644 --- a/src/Fields/Transaction/TransactionLine/VatRepTurnoverField.php +++ b/src/Fields/Transaction/TransactionLine/VatRepTurnoverField.php @@ -32,4 +32,4 @@ public function setVatRepTurnover(?Money $vatRepTurnover) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/VatRepValueField.php b/src/Fields/Transaction/TransactionLine/VatRepValueField.php index 1a152921..23f751df 100644 --- a/src/Fields/Transaction/TransactionLine/VatRepValueField.php +++ b/src/Fields/Transaction/TransactionLine/VatRepValueField.php @@ -32,4 +32,4 @@ public function setVatRepValue(?Money $vatRepValue) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/VatTotalField.php b/src/Fields/Transaction/TransactionLine/VatTotalField.php index eeb90e0b..0c4514cb 100644 --- a/src/Fields/Transaction/TransactionLine/VatTotalField.php +++ b/src/Fields/Transaction/TransactionLine/VatTotalField.php @@ -32,4 +32,4 @@ public function setVatTotal(?Money $vatTotal) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/Transaction/TransactionLine/VatTurnoverField.php b/src/Fields/Transaction/TransactionLine/VatTurnoverField.php index 8a5c4669..1a6bcb2f 100644 --- a/src/Fields/Transaction/TransactionLine/VatTurnoverField.php +++ b/src/Fields/Transaction/TransactionLine/VatTurnoverField.php @@ -32,4 +32,4 @@ public function setVatTurnover(?Money $vatTurnover) return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/UIDField.php b/src/Fields/UIDField.php index f0f9d20a..e7758ab6 100644 --- a/src/Fields/UIDField.php +++ b/src/Fields/UIDField.php @@ -29,4 +29,4 @@ public function setUID(?string $UID): self $this->UID = $UID; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/User/AcceptExtraCostField.php b/src/Fields/User/AcceptExtraCostField.php index 735463e4..0106eb66 100644 --- a/src/Fields/User/AcceptExtraCostField.php +++ b/src/Fields/User/AcceptExtraCostField.php @@ -29,4 +29,4 @@ public function setAcceptExtraCost(?bool $acceptExtraCost): self $this->acceptExtraCost = $acceptExtraCost; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/User/CultureField.php b/src/Fields/User/CultureField.php index 5dbf2e0d..115b6c87 100644 --- a/src/Fields/User/CultureField.php +++ b/src/Fields/User/CultureField.php @@ -27,4 +27,4 @@ public function setCulture(?Culture $culture): self $this->culture = $culture; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/User/CultureNameField.php b/src/Fields/User/CultureNameField.php index acf2e011..8ebde913 100644 --- a/src/Fields/User/CultureNameField.php +++ b/src/Fields/User/CultureNameField.php @@ -28,4 +28,4 @@ public function setCultureName(?string $cultureName): self $this->cultureName = $cultureName; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/User/CultureNativeNameField.php b/src/Fields/User/CultureNativeNameField.php index aa72820b..5216f2fa 100644 --- a/src/Fields/User/CultureNativeNameField.php +++ b/src/Fields/User/CultureNativeNameField.php @@ -28,4 +28,4 @@ public function setCultureNativeName(?string $cultureNativeName): self $this->cultureNativeName = $cultureNativeName; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/User/DemoField.php b/src/Fields/User/DemoField.php index c202f30c..68734bea 100644 --- a/src/Fields/User/DemoField.php +++ b/src/Fields/User/DemoField.php @@ -29,4 +29,4 @@ public function setDemo(?bool $demo): self $this->demo = $demo; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/User/DemoLockedField.php b/src/Fields/User/DemoLockedField.php index c70aadbb..61428276 100644 --- a/src/Fields/User/DemoLockedField.php +++ b/src/Fields/User/DemoLockedField.php @@ -19,7 +19,7 @@ public function getDemoLocked(): ?bool { return $this->demoLocked; } - + /** * @param bool $demoLocked * @return $this @@ -29,4 +29,4 @@ public function setDemoLocked(?bool $demoLocked): self $this->demoLocked = $demoLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/User/ExchangeQuotaField.php b/src/Fields/User/ExchangeQuotaField.php index b69eeb61..0f31ce67 100644 --- a/src/Fields/User/ExchangeQuotaField.php +++ b/src/Fields/User/ExchangeQuotaField.php @@ -29,4 +29,4 @@ public function setExchangeQuota(?int $exchangeQuota): self $this->exchangeQuota = $exchangeQuota; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/User/ExchangeQuotaLockedField.php b/src/Fields/User/ExchangeQuotaLockedField.php index 9ad6483b..5433f50d 100644 --- a/src/Fields/User/ExchangeQuotaLockedField.php +++ b/src/Fields/User/ExchangeQuotaLockedField.php @@ -29,4 +29,4 @@ public function setExchangeQuotaLocked(?bool $exchangeQuotaLocked): self $this->exchangeQuotaLocked = $exchangeQuotaLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/User/FileManagerQuotaField.php b/src/Fields/User/FileManagerQuotaField.php index 84dd2e07..047d588c 100644 --- a/src/Fields/User/FileManagerQuotaField.php +++ b/src/Fields/User/FileManagerQuotaField.php @@ -29,4 +29,4 @@ public function setFileManagerQuota(?int $fileManagerQuota): self $this->fileManagerQuota = $fileManagerQuota; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/User/FileManagerQuotaLockedField.php b/src/Fields/User/FileManagerQuotaLockedField.php index 06c8293c..b8512ed4 100644 --- a/src/Fields/User/FileManagerQuotaLockedField.php +++ b/src/Fields/User/FileManagerQuotaLockedField.php @@ -29,4 +29,4 @@ public function setFileManagerQuotaLocked(?bool $fileManagerQuotaLocked): self $this->fileManagerQuotaLocked = $fileManagerQuotaLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/User/IsCurrentUserField.php b/src/Fields/User/IsCurrentUserField.php index 96cb124f..7d38f5c9 100644 --- a/src/Fields/User/IsCurrentUserField.php +++ b/src/Fields/User/IsCurrentUserField.php @@ -29,4 +29,4 @@ public function setIsCurrentUser(?bool $isCurrentUser): self $this->isCurrentUser = $isCurrentUser; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/User/LevelField.php b/src/Fields/User/LevelField.php index 94805fda..b8d85ebd 100644 --- a/src/Fields/User/LevelField.php +++ b/src/Fields/User/LevelField.php @@ -29,4 +29,4 @@ public function setLevel(?string $level): self $this->level = $level; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/User/PasswordField.php b/src/Fields/User/PasswordField.php index 19af96a8..0bb1f6af 100644 --- a/src/Fields/User/PasswordField.php +++ b/src/Fields/User/PasswordField.php @@ -28,4 +28,4 @@ public function setPassword(?string $password): self $this->password = $password; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/User/RoleLockedField.php b/src/Fields/User/RoleLockedField.php index e65651ae..6d535b82 100644 --- a/src/Fields/User/RoleLockedField.php +++ b/src/Fields/User/RoleLockedField.php @@ -19,7 +19,7 @@ public function getRoleLocked(): ?bool { return $this->roleLocked; } - + /** * @param bool $roleLocked * @return $this @@ -29,4 +29,4 @@ public function setRoleLocked(?bool $roleLocked): self $this->roleLocked = $roleLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/User/TypeField.php b/src/Fields/User/TypeField.php index 9dace761..a9b745d0 100644 --- a/src/Fields/User/TypeField.php +++ b/src/Fields/User/TypeField.php @@ -27,4 +27,4 @@ public function setType(?UserType $type): self $this->type = $type; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/User/TypeLockedField.php b/src/Fields/User/TypeLockedField.php index 281923f1..124d9347 100644 --- a/src/Fields/User/TypeLockedField.php +++ b/src/Fields/User/TypeLockedField.php @@ -29,4 +29,4 @@ public function setTypeLocked(?bool $typeLocked): self $this->typeLocked = $typeLocked; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/VatCode/GroupCountryField.php b/src/Fields/VatCode/GroupCountryField.php index 2c5491a8..c532a5e3 100644 --- a/src/Fields/VatCode/GroupCountryField.php +++ b/src/Fields/VatCode/GroupCountryField.php @@ -30,4 +30,4 @@ public function setGroupCountry(?VatGroupCountry $groupCountry): self $this->groupCountry = $groupCountry; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/VatCode/GroupField.php b/src/Fields/VatCode/GroupField.php index 04dd8232..aa87f528 100644 --- a/src/Fields/VatCode/GroupField.php +++ b/src/Fields/VatCode/GroupField.php @@ -30,4 +30,4 @@ public function setGroup(?VatGroup $group): self $this->group = $group; return $this; } -} \ No newline at end of file +} diff --git a/src/Fields/VatCode/TypeField.php b/src/Fields/VatCode/TypeField.php index d685c0c1..e9e42aec 100644 --- a/src/Fields/VatCode/TypeField.php +++ b/src/Fields/VatCode/TypeField.php @@ -38,4 +38,4 @@ public function setTypeFromString(?string $typeString) { return $this->setType(new VatType((string)$typeString)); } -} \ No newline at end of file +} diff --git a/src/Fields/VatCodeField.php b/src/Fields/VatCodeField.php index 17a44cae..e54d785b 100644 --- a/src/Fields/VatCodeField.php +++ b/src/Fields/VatCodeField.php @@ -21,7 +21,7 @@ public function getVatCode(): ?VatCode { return $this->vatCode; } - + /** * @return $this */ diff --git a/src/Fields/VatValueField.php b/src/Fields/VatValueField.php index a8e8df18..de9070f2 100644 --- a/src/Fields/VatValueField.php +++ b/src/Fields/VatValueField.php @@ -32,4 +32,4 @@ public function setVatValue(?Money $vatValue) return $this; } -} \ No newline at end of file +} diff --git a/src/Mappers/ActivityMapper.php b/src/Mappers/ActivityMapper.php index 584d31e9..7b049aaa 100644 --- a/src/Mappers/ActivityMapper.php +++ b/src/Mappers/ActivityMapper.php @@ -117,4 +117,4 @@ public static function map(Response $response) // Return the complete object return $activity; } -} \ No newline at end of file +} diff --git a/src/Mappers/ArticleMapper.php b/src/Mappers/ArticleMapper.php index f46697ef..ac392e04 100644 --- a/src/Mappers/ArticleMapper.php +++ b/src/Mappers/ArticleMapper.php @@ -63,7 +63,7 @@ public static function map(Response $response, AuthenticatedConnection $connecti ->setUnitNameSingular(self::getField($headerElement, 'unitnamesingular', $article)) ->setUnitNamePlural(self::getField($headerElement, 'unitnameplural', $article)) ->setVatCode(self::parseObjectAttribute(\PhpTwinfield\VatCode::class, $article, $headerElement, 'vatcode')); - + if ($article->getOffice() !== null) { $currencies = self::getOfficeCurrencies($connection, $article->getOffice()); } @@ -119,4 +119,4 @@ public static function map(Response $response, AuthenticatedConnection $connecti // Return the complete object return $article; } -} \ No newline at end of file +} diff --git a/src/Mappers/AssetMethodMapper.php b/src/Mappers/AssetMethodMapper.php index 445c7380..a3af3939 100644 --- a/src/Mappers/AssetMethodMapper.php +++ b/src/Mappers/AssetMethodMapper.php @@ -124,4 +124,4 @@ public static function map(Response $response) // Return the complete object return $assetmethod; } -} \ No newline at end of file +} diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index 29c12ba9..c0494389 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -60,19 +60,19 @@ protected static function getField(\DOMElement $element, string $fieldTagName, $ return $fieldElement->textContent; } - + protected static function getOfficeCurrencies(AuthenticatedConnection $connection, Office $office): array { $currencies = ["base" => '', "reporting" => '']; - + $officeApiConnector = new OfficeApiConnector($connection); $fullOffice = $officeApiConnector->get($office->getCode()); - + if ($fullOffice->getResult() == 1) { $currencies['base'] = Util::objectToStr($fullOffice->getBaseCurrency()); $currencies['reporting'] = Util::objectToStr($fullOffice->getReportingCurrency()); } - + return $currencies; } @@ -159,15 +159,15 @@ protected static function parseUnknownEntity(HasMessageInterface $object, \DOMEl protected static function parseObjectAttribute(?string $objectClass, HasMessageInterface $object, \DOMElement $element, string $fieldTagName, array $attributes = []) { $value = self::getField($element, $fieldTagName, $object); - + if ($value === null) { return null; } - + if ($objectClass === null) { $objectClass = self::parseUnknownEntity($object, $element, $fieldTagName); } - + $object2 = new $objectClass(); $object2->setCode($value); @@ -177,4 +177,4 @@ protected static function parseObjectAttribute(?string $objectClass, HasMessageI return $object2; } -} \ No newline at end of file +} diff --git a/src/Mappers/BrowseDataMapper.php b/src/Mappers/BrowseDataMapper.php index e6b76fab..3e3aa4e8 100644 --- a/src/Mappers/BrowseDataMapper.php +++ b/src/Mappers/BrowseDataMapper.php @@ -104,4 +104,4 @@ private static function parseBrowseDataValue(string $type, string $value) return $value; } } -} \ No newline at end of file +} diff --git a/src/Mappers/BrowseFieldMapper.php b/src/Mappers/BrowseFieldMapper.php index ec593375..c9d78993 100644 --- a/src/Mappers/BrowseFieldMapper.php +++ b/src/Mappers/BrowseFieldMapper.php @@ -55,4 +55,4 @@ public static function map(Response $response) return $browseFields; } -} \ No newline at end of file +} diff --git a/src/Mappers/CashBankBookMapper.php b/src/Mappers/CashBankBookMapper.php index 92995029..1c37d177 100644 --- a/src/Mappers/CashBankBookMapper.php +++ b/src/Mappers/CashBankBookMapper.php @@ -42,4 +42,4 @@ public static function map(Response $response) // Return the complete object return $cashBankBook; } -} \ No newline at end of file +} diff --git a/src/Mappers/CostCenterMapper.php b/src/Mappers/CostCenterMapper.php index 2ec2f81f..d40eefec 100644 --- a/src/Mappers/CostCenterMapper.php +++ b/src/Mappers/CostCenterMapper.php @@ -52,4 +52,4 @@ public static function map(Response $response) // Return the complete object return $costCenter; } -} \ No newline at end of file +} diff --git a/src/Mappers/CustomerMapper.php b/src/Mappers/CustomerMapper.php index bc423583..dc986d58 100644 --- a/src/Mappers/CustomerMapper.php +++ b/src/Mappers/CustomerMapper.php @@ -343,4 +343,4 @@ public static function map(Response $response, AuthenticatedConnection $connecti // Return the complete object return $customer; } -} \ No newline at end of file +} diff --git a/src/Mappers/DimensionTypeMapper.php b/src/Mappers/DimensionTypeMapper.php index 8a725fc6..cf610a2e 100644 --- a/src/Mappers/DimensionTypeMapper.php +++ b/src/Mappers/DimensionTypeMapper.php @@ -84,4 +84,4 @@ public static function map(Response $response) // Return the complete object return $dimensiontype; } -} \ No newline at end of file +} diff --git a/src/Mappers/FixedAssetMapper.php b/src/Mappers/FixedAssetMapper.php index d6c50a41..34ebdd4a 100644 --- a/src/Mappers/FixedAssetMapper.php +++ b/src/Mappers/FixedAssetMapper.php @@ -53,7 +53,7 @@ public static function map(Response $response, AuthenticatedConnection $connecti ->setTouched(self::getField($fixedAssetElement, 'touched', $fixedAsset)) ->setType(self::parseObjectAttribute(\PhpTwinfield\DimensionType::class, $fixedAsset, $fixedAssetElement, 'type', array('name' => 'setName', 'shortname' => 'setShortName'))) ->setUID(self::getField($fixedAssetElement, 'uid', $fixedAsset)); - + if ($fixedAsset->getOffice() !== null) { $currencies = self::getOfficeCurrencies($connection, $fixedAsset->getOffice()); } diff --git a/src/Mappers/InvoiceMapper.php b/src/Mappers/InvoiceMapper.php index 89ad9ca6..5e123036 100644 --- a/src/Mappers/InvoiceMapper.php +++ b/src/Mappers/InvoiceMapper.php @@ -151,4 +151,4 @@ public static function map(Response $response) //Return the complete object return $invoice; } -} \ No newline at end of file +} diff --git a/src/Mappers/InvoiceTypeMapper.php b/src/Mappers/InvoiceTypeMapper.php index 51536d86..da4ca044 100644 --- a/src/Mappers/InvoiceTypeMapper.php +++ b/src/Mappers/InvoiceTypeMapper.php @@ -42,4 +42,4 @@ public static function map(Response $response) // Return the complete object return $invoiceType; } -} \ No newline at end of file +} diff --git a/src/Mappers/MatchSetMapper.php b/src/Mappers/MatchSetMapper.php index 5e4174f0..a8e6ce1b 100644 --- a/src/Mappers/MatchSetMapper.php +++ b/src/Mappers/MatchSetMapper.php @@ -74,4 +74,4 @@ private static function getMatchValueFrom(\DOMElement $lineElement): ?Money // TODO: Perhaps not hard code this to EUR, but the element doesn't seem to contain a currency return Util::parseMoney($matchValue, new Currency('EUR')); } -} \ No newline at end of file +} diff --git a/src/Mappers/OfficeMapper.php b/src/Mappers/OfficeMapper.php index 71dddcaa..414a3875 100644 --- a/src/Mappers/OfficeMapper.php +++ b/src/Mappers/OfficeMapper.php @@ -80,4 +80,4 @@ public static function mapElement(\DOMElement $officeElement): Office return $office; } -} \ No newline at end of file +} diff --git a/src/Mappers/RateMapper.php b/src/Mappers/RateMapper.php index 2683a67b..29076596 100644 --- a/src/Mappers/RateMapper.php +++ b/src/Mappers/RateMapper.php @@ -85,4 +85,4 @@ public static function map(Response $response) // Return the complete object return $rate; } -} \ No newline at end of file +} diff --git a/src/Mappers/SupplierMapper.php b/src/Mappers/SupplierMapper.php index 2ed9d494..5cf3f706 100644 --- a/src/Mappers/SupplierMapper.php +++ b/src/Mappers/SupplierMapper.php @@ -293,4 +293,4 @@ public static function map(Response $response) // Return the complete object return $supplier; } -} \ No newline at end of file +} diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index e7a1ac2b..02a934fd 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -97,7 +97,7 @@ public static function map(string $transactionClassName, Response $response, Aut ->setOrigin(self::getField($transactionElement, 'origin', $transaction)) ->setNumber(self::getField($transactionElement, 'number', $transaction)) ->setPeriod(self::getField($transactionElement, 'period', $transaction)); - + if ($transaction->getOffice() !== null) { $currencies = self::getOfficeCurrencies($connection, $transaction->getOffice()); } @@ -279,4 +279,4 @@ public static function map(string $transactionClassName, Response $response, Aut return $transaction; } -} \ No newline at end of file +} diff --git a/src/Mappers/UserMapper.php b/src/Mappers/UserMapper.php index 61e89d54..e005b879 100644 --- a/src/Mappers/UserMapper.php +++ b/src/Mappers/UserMapper.php @@ -71,4 +71,4 @@ public static function map(Response $response) // Return the complete object return $user; } -} \ No newline at end of file +} diff --git a/src/Mappers/VatCodeMapper.php b/src/Mappers/VatCodeMapper.php index 9cf6d8ef..0feb4785 100644 --- a/src/Mappers/VatCodeMapper.php +++ b/src/Mappers/VatCodeMapper.php @@ -63,11 +63,11 @@ public static function map(Response $response) // Make a new temporary VatCodePercentage class $vatCodePercentage = new VatCodePercentage(); - + if (!empty($percentageElement->getAttribute('inuse'))) { $vatCodePercentage->setInUse($percentageElement->getAttribute('inuse')); } - + if (!empty($percentageElement->getAttribute('status'))) { $vatCodePercentage->setStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\Status::class, $percentageElement->getAttribute('status'))); } @@ -124,4 +124,4 @@ public static function map(Response $response) // Return the complete object return $vatCode; } -} \ No newline at end of file +} diff --git a/src/Mappers/VatGroupCountryMapper.php b/src/Mappers/VatGroupCountryMapper.php index 4d2efce1..ce492434 100644 --- a/src/Mappers/VatGroupCountryMapper.php +++ b/src/Mappers/VatGroupCountryMapper.php @@ -42,4 +42,4 @@ public static function map(Response $response) // Return the complete object return $vatGroupCountry; } -} \ No newline at end of file +} diff --git a/src/Mappers/VatGroupMapper.php b/src/Mappers/VatGroupMapper.php index 9af8f0e9..18c3a2d2 100644 --- a/src/Mappers/VatGroupMapper.php +++ b/src/Mappers/VatGroupMapper.php @@ -42,4 +42,4 @@ public static function map(Response $response) // Return the complete object return $vatGroup; } -} \ No newline at end of file +} diff --git a/src/Request/Catalog/Office.php b/src/Request/Catalog/Office.php index 14035f5b..5865add7 100644 --- a/src/Request/Catalog/Office.php +++ b/src/Request/Catalog/Office.php @@ -24,4 +24,4 @@ public function __construct() parent::__construct(); $this->add('type', 'offices'); } -} \ No newline at end of file +} diff --git a/src/Request/Read/Activity.php b/src/Request/Read/Activity.php index 50beb32d..cf504a8c 100644 --- a/src/Request/Read/Activity.php +++ b/src/Request/Read/Activity.php @@ -18,7 +18,7 @@ class Activity extends Read * * @access public * @param Office|null $office - * @param string $code + * @param string $code */ public function __construct(?Office $office = null, $code = null) diff --git a/src/Request/Read/Article.php b/src/Request/Read/Article.php index 151f4be2..5fe60527 100644 --- a/src/Request/Read/Article.php +++ b/src/Request/Read/Article.php @@ -18,7 +18,7 @@ class Article extends Read * * @access public * @param Office|null $office - * @param string $code + * @param string $code */ public function __construct(?Office $office = null, $code = null) { diff --git a/src/Request/Read/CostCenter.php b/src/Request/Read/CostCenter.php index 325a7dec..095c0c85 100644 --- a/src/Request/Read/CostCenter.php +++ b/src/Request/Read/CostCenter.php @@ -18,7 +18,7 @@ class CostCenter extends Read * * @access public * @param Office|null $office - * @param string $code + * @param string $code */ public function __construct(?Office $office = null, $code = null) { @@ -35,4 +35,4 @@ public function __construct(?Office $office = null, $code = null) $this->setCode($code); } } -} \ No newline at end of file +} diff --git a/src/Request/Read/Currency.php b/src/Request/Read/Currency.php index b764af79..b43b0cbf 100644 --- a/src/Request/Read/Currency.php +++ b/src/Request/Read/Currency.php @@ -18,7 +18,7 @@ class Currency extends Read * * @access public * @param Office|null $office - * @param string $code + * @param string $code */ public function __construct(?Office $office = null, $code = null) { diff --git a/src/Request/Read/Customer.php b/src/Request/Read/Customer.php index a8d9f3fa..8ff8327a 100644 --- a/src/Request/Read/Customer.php +++ b/src/Request/Read/Customer.php @@ -21,7 +21,7 @@ class Customer extends Read * * @access public * @param Office|null $office - * @param string $code + * @param string $code */ public function __construct(?Office $office = null, $code = null) { diff --git a/src/Request/Read/FixedAsset.php b/src/Request/Read/FixedAsset.php index 73f66e8a..c1123e38 100644 --- a/src/Request/Read/FixedAsset.php +++ b/src/Request/Read/FixedAsset.php @@ -35,4 +35,4 @@ public function __construct(?Office $office = null, $code = null) $this->setCode($code); } } -} \ No newline at end of file +} diff --git a/src/Request/Read/GeneralLedger.php b/src/Request/Read/GeneralLedger.php index 0e1ea019..37539e85 100644 --- a/src/Request/Read/GeneralLedger.php +++ b/src/Request/Read/GeneralLedger.php @@ -38,4 +38,4 @@ public function __construct(?Office $office = null, $code = null, $dimType = nul $this->setDimType($dimType); } } -} \ No newline at end of file +} diff --git a/src/Request/Read/Office.php b/src/Request/Read/Office.php index f129a09f..07f73eaf 100644 --- a/src/Request/Read/Office.php +++ b/src/Request/Read/Office.php @@ -15,7 +15,7 @@ class Office extends Read * Sets office and code if they are present. * * @access public - * @param string $code + * @param string $code */ public function __construct($code = null) { diff --git a/src/Request/Read/Project.php b/src/Request/Read/Project.php index 13f1de8d..1b3253da 100644 --- a/src/Request/Read/Project.php +++ b/src/Request/Read/Project.php @@ -35,4 +35,4 @@ public function __construct(?Office $office = null, $code = null) $this->setCode($code); } } -} \ No newline at end of file +} diff --git a/src/Request/Read/Rate.php b/src/Request/Read/Rate.php index 28256266..e93b35e0 100644 --- a/src/Request/Read/Rate.php +++ b/src/Request/Read/Rate.php @@ -34,4 +34,4 @@ public function __construct(?Office $office = null, $code = null) $this->setCode($code); } } -} \ No newline at end of file +} diff --git a/src/Request/Read/User.php b/src/Request/Read/User.php index 6516d164..7bbe7b20 100644 --- a/src/Request/Read/User.php +++ b/src/Request/Read/User.php @@ -18,7 +18,7 @@ class User extends Read * * @access public * @param Office|null $office - * @param string $code + * @param string $code */ public function __construct(?Office $office = null, $code = null) { diff --git a/src/Request/Read/VatCode.php b/src/Request/Read/VatCode.php index 90a6dfc4..d8d3d0af 100644 --- a/src/Request/Read/VatCode.php +++ b/src/Request/Read/VatCode.php @@ -18,7 +18,7 @@ class VatCode extends Read * * @access public * @param Office|null $office - * @param string $code + * @param string $code */ public function __construct(?Office $office = null, $code = null) { diff --git a/src/Response/IndividualMappedResponse.php b/src/Response/IndividualMappedResponse.php index 127b7d3a..e9f68efd 100644 --- a/src/Response/IndividualMappedResponse.php +++ b/src/Response/IndividualMappedResponse.php @@ -69,4 +69,4 @@ public function getErrorMessages(): array { return $this->response->getErrorMessages(); } -} \ No newline at end of file +} diff --git a/src/Response/MappedResponseCollection.php b/src/Response/MappedResponseCollection.php index 779e17e7..0c953615 100644 --- a/src/Response/MappedResponseCollection.php +++ b/src/Response/MappedResponseCollection.php @@ -95,4 +95,4 @@ private function countResponses(bool $successful): int return $count; } -} \ No newline at end of file +} diff --git a/src/Response/Response.php b/src/Response/Response.php index 9e842a82..accbdb8f 100644 --- a/src/Response/Response.php +++ b/src/Response/Response.php @@ -145,4 +145,4 @@ public function getWarningMessages(): array { return $this->getMessages('warning'); } -} \ No newline at end of file +} diff --git a/src/Response/ResponseException.php b/src/Response/ResponseException.php index 486b3c60..c1a12590 100644 --- a/src/Response/ResponseException.php +++ b/src/Response/ResponseException.php @@ -29,4 +29,4 @@ public function getReturnedObject() { return $this->returnedObject; } -} \ No newline at end of file +} diff --git a/src/Secure/OpenIdConnectAuthentication.php b/src/Secure/OpenIdConnectAuthentication.php index 61c5b1db..d60e438b 100644 --- a/src/Secure/OpenIdConnectAuthentication.php +++ b/src/Secure/OpenIdConnectAuthentication.php @@ -143,4 +143,4 @@ protected function refreshToken(): void $this->accessToken = $accessToken->getToken(); } -} \ No newline at end of file +} diff --git a/src/Secure/Provider/InvalidAccessTokenException.php b/src/Secure/Provider/InvalidAccessTokenException.php index 8134776f..e484e98f 100644 --- a/src/Secure/Provider/InvalidAccessTokenException.php +++ b/src/Secure/Provider/InvalidAccessTokenException.php @@ -4,4 +4,4 @@ class InvalidAccessTokenException extends OAuthException { -} \ No newline at end of file +} diff --git a/src/Secure/Provider/OAuthException.php b/src/Secure/Provider/OAuthException.php index 77188280..44999e38 100644 --- a/src/Secure/Provider/OAuthException.php +++ b/src/Secure/Provider/OAuthException.php @@ -4,4 +4,4 @@ class OAuthException extends \Exception { -} \ No newline at end of file +} diff --git a/src/Secure/Provider/ResourceOwner.php b/src/Secure/Provider/ResourceOwner.php index 6baf79f9..c4774789 100644 --- a/src/Secure/Provider/ResourceOwner.php +++ b/src/Secure/Provider/ResourceOwner.php @@ -31,4 +31,4 @@ public function toArray(): array { return $this->response; } -} \ No newline at end of file +} diff --git a/src/Secure/WebservicesAuthentication.php b/src/Secure/WebservicesAuthentication.php index eca9085c..3d725fc5 100644 --- a/src/Secure/WebservicesAuthentication.php +++ b/src/Secure/WebservicesAuthentication.php @@ -121,4 +121,4 @@ protected function getCluster(): string { return $this->cluster; } -} \ No newline at end of file +} diff --git a/src/Services/FinderService.php b/src/Services/FinderService.php index 1da663b6..8bcd3ae4 100644 --- a/src/Services/FinderService.php +++ b/src/Services/FinderService.php @@ -96,4 +96,4 @@ public function searchFinder( ] ); } -} \ No newline at end of file +} diff --git a/src/Services/ProcessXmlService.php b/src/Services/ProcessXmlService.php index 2c230c94..4a8e0e4f 100644 --- a/src/Services/ProcessXmlService.php +++ b/src/Services/ProcessXmlService.php @@ -86,4 +86,4 @@ public function mapAll(array $responses, string $individualTag, callable $mapCal return $mappedResponses; } -} \ No newline at end of file +} From 7e66b9cf364bbb6ca6354a1242423dba5fa9e0b8 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 29 Jun 2019 12:13:42 +0200 Subject: [PATCH 374/388] Upload --- src/CustomerAddress.php | 2 +- src/CustomerBank.php | 2 +- src/CustomerLine.php | 2 +- src/DimensionGroup.php | 2 +- src/DimensionType.php | 4 +-- src/ElectronicBankStatement.php | 2 +- src/Exception.php | 2 +- src/FixedAsset.php | 4 +-- src/GeneralLedger.php | 2 +- src/HasCodeInterface.php | 4 +-- src/HasMessageInterface.php | 2 +- src/Invoice.php | 10 +++---- src/InvoiceType.php | 4 +-- src/MatchLine.php | 2 +- src/MatchReference.php | 2 +- src/MatchReferenceInterface.php | 2 +- src/PayCode.php | 4 +-- src/Project.php | 4 +-- src/Rate.php | 10 +++---- src/Supplier.php | 26 +++++++++---------- src/SupplierBank.php | 2 +- src/SupplierLine.php | 2 +- src/TransactionLineInterface.php | 2 +- src/User.php | 2 +- src/UserRole.php | 4 +-- src/Util.php | 20 +++++++------- src/VatCode.php | 4 +-- src/VatCodePercentage.php | 2 +- src/VatGroup.php | 4 +-- src/VatGroupCountry.php | 4 +-- .../IntegrationTests/BaseIntegrationTest.php | 4 +-- .../BrowseDataApiConnectorTest.php | 2 +- .../InvoiceIntegrationTest.php | 12 ++++----- .../OfficeIntegrationTest.php | 6 ++--- .../ApiConnectors/BaseApiConnectorTest.php | 2 +- .../BrowseDataApiConnectorTest.php | 2 +- .../CustomerApiConnectorTest.php | 2 +- .../FixedAssetApiConnectorTest.php | 2 +- .../ApiConnectors/InvoiceApiConnectorTest.php | 4 +-- .../TransactionApiConnectorTest.php | 2 +- ...lectronicBankStatementDocumentUnitTest.php | 2 +- .../DomDocuments/MatchDocumentUnitTest.php | 2 +- .../UnitTests/Request/BrowseDataUnitTest.php | 2 +- tests/UnitTests/SalesTransactionUnitTest.php | 2 +- .../OpenIdConnectionAuthenticationTest.php | 2 +- .../Secure/Provider/OAuthProviderTest.php | 2 +- 46 files changed, 94 insertions(+), 94 deletions(-) diff --git a/src/CustomerAddress.php b/src/CustomerAddress.php index 316cbbe3..641cdf07 100644 --- a/src/CustomerAddress.php +++ b/src/CustomerAddress.php @@ -41,4 +41,4 @@ class CustomerAddress extends BaseObject use TelefaxField; use TelephoneField; use TypeField; -} \ No newline at end of file +} diff --git a/src/CustomerBank.php b/src/CustomerBank.php index bf91599a..f97d390f 100644 --- a/src/CustomerBank.php +++ b/src/CustomerBank.php @@ -39,4 +39,4 @@ class CustomerBank extends BaseObject use NatBicCodeField; use PostcodeField; use StateField; -} \ No newline at end of file +} diff --git a/src/CustomerLine.php b/src/CustomerLine.php index ce802d19..5237a333 100644 --- a/src/CustomerLine.php +++ b/src/CustomerLine.php @@ -29,4 +29,4 @@ class CustomerLine extends BaseObject use OfficeField; use RatioField; use VatCodeField; -} \ No newline at end of file +} diff --git a/src/DimensionGroup.php b/src/DimensionGroup.php index f2614e24..615e006f 100644 --- a/src/DimensionGroup.php +++ b/src/DimensionGroup.php @@ -21,7 +21,7 @@ class DimensionGroup extends BaseObject implements HasCodeInterface use StatusField; private $dimensions = []; - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); diff --git a/src/DimensionType.php b/src/DimensionType.php index b8e24311..d22b558a 100644 --- a/src/DimensionType.php +++ b/src/DimensionType.php @@ -30,7 +30,7 @@ public function __construct() $this->setAddress(new DimensionTypeAddress); $this->setLevels(new DimensionTypeLevels); } - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); @@ -59,4 +59,4 @@ public function setLevels(DimensionTypeLevels $levels) $this->levels = $levels; return $this; } -} \ No newline at end of file +} diff --git a/src/ElectronicBankStatement.php b/src/ElectronicBankStatement.php index 881ea6bd..9e9443b5 100644 --- a/src/ElectronicBankStatement.php +++ b/src/ElectronicBankStatement.php @@ -145,4 +145,4 @@ public function setTransactions(array $transactions): void } } -} \ No newline at end of file +} diff --git a/src/Exception.php b/src/Exception.php index eb9c4ded..4eafbd4f 100644 --- a/src/Exception.php +++ b/src/Exception.php @@ -60,4 +60,4 @@ public static function invalidMatchStatusForLineType( $transactionLine->getLineType() )); } -} \ No newline at end of file +} diff --git a/src/FixedAsset.php b/src/FixedAsset.php index c1c72fe3..5c8acc1b 100644 --- a/src/FixedAsset.php +++ b/src/FixedAsset.php @@ -42,7 +42,7 @@ public function __construct() $this->setFinancials(new FixedAssetFinancials); $this->setFixedAssets(new FixedAssetFixedAssets); } - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); @@ -71,4 +71,4 @@ public function setFixedAssets(FixedAssetFixedAssets $fixedAssets) $this->fixedAssets = $fixedAssets; return $this; } -} \ No newline at end of file +} diff --git a/src/GeneralLedger.php b/src/GeneralLedger.php index dd5e8831..26c6874a 100644 --- a/src/GeneralLedger.php +++ b/src/GeneralLedger.php @@ -52,7 +52,7 @@ public function __construct() $this->setFinancials(new GeneralLedgerFinancials); } - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); diff --git a/src/HasCodeInterface.php b/src/HasCodeInterface.php index e98e19b9..fc412224 100644 --- a/src/HasCodeInterface.php +++ b/src/HasCodeInterface.php @@ -12,5 +12,5 @@ interface HasCodeInterface * Gets the code from an object */ public function getCode(): ?string; - -} \ No newline at end of file + +} diff --git a/src/HasMessageInterface.php b/src/HasMessageInterface.php index 4da62e58..228dd683 100644 --- a/src/HasMessageInterface.php +++ b/src/HasMessageInterface.php @@ -17,4 +17,4 @@ interface HasMessageInterface * Adds an error message to an object */ public function addMessage(Message $message): void; -} \ No newline at end of file +} diff --git a/src/Invoice.php b/src/Invoice.php index 26b6b267..1fd78996 100644 --- a/src/Invoice.php +++ b/src/Invoice.php @@ -112,22 +112,22 @@ public function removeLine($index) return false; } } - + public function removeLineByID($id) { $found = false; - + foreach ($this->lines as $index => $line) { if ($id == $line->getID()) { unset($this->lines[$index]); $found = true; } } - + if ($found) { return true; } - + return false; } @@ -159,4 +159,4 @@ public function getMatchReference(): MatchReferenceInterface { return new MatchReference($this->getOffice(), $this->getFinancialCode(), $this->getFinancialNumber(), 1); } -} \ No newline at end of file +} diff --git a/src/InvoiceType.php b/src/InvoiceType.php index e56afe09..116650d1 100644 --- a/src/InvoiceType.php +++ b/src/InvoiceType.php @@ -16,11 +16,11 @@ class InvoiceType extends BaseObject implements HasCodeInterface use CodeField; use NameField; use ShortNameField; - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); return $instance; } -} \ No newline at end of file +} diff --git a/src/MatchLine.php b/src/MatchLine.php index d215e1cc..6f9a37eb 100644 --- a/src/MatchLine.php +++ b/src/MatchLine.php @@ -126,4 +126,4 @@ public function getWriteOffType(): ?Enums\WriteOffType { return $this->writeOffType; } -} \ No newline at end of file +} diff --git a/src/MatchReference.php b/src/MatchReference.php index 4e5fd9b1..ff186929 100644 --- a/src/MatchReference.php +++ b/src/MatchReference.php @@ -48,4 +48,4 @@ public function getLineId(): int { return $this->lineId; } -} \ No newline at end of file +} diff --git a/src/MatchReferenceInterface.php b/src/MatchReferenceInterface.php index 071c7a78..39385a4b 100644 --- a/src/MatchReferenceInterface.php +++ b/src/MatchReferenceInterface.php @@ -35,4 +35,4 @@ public function getNumber(): int; * Reference the exact line in the transaction. */ public function getLineId(): int; -} \ No newline at end of file +} diff --git a/src/PayCode.php b/src/PayCode.php index d1f12e03..117f2f0b 100644 --- a/src/PayCode.php +++ b/src/PayCode.php @@ -16,11 +16,11 @@ class PayCode extends BaseObject implements HasCodeInterface use CodeField; use NameField; use ShortNameField; - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); return $instance; } -} \ No newline at end of file +} diff --git a/src/Project.php b/src/Project.php index 88c1d1e2..571dde77 100644 --- a/src/Project.php +++ b/src/Project.php @@ -40,7 +40,7 @@ public function __construct() $this->setType(\PhpTwinfield\DimensionType::fromCode('PRJ')); $this->setProjects(new ProjectProjects); } - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); @@ -58,4 +58,4 @@ public function setProjects(ProjectProjects $projects) $this->projects = $projects; return $this; } -} \ No newline at end of file +} diff --git a/src/Rate.php b/src/Rate.php index 06cd78c3..08475065 100644 --- a/src/Rate.php +++ b/src/Rate.php @@ -36,7 +36,7 @@ class Rate extends BaseObject implements HasCodeInterface use UserField; private $rateChanges = []; - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); @@ -64,22 +64,22 @@ public function removeRateChange($index) return false; } } - + public function removeRateChangeByID($id) { $found = false; - + foreach ($this->rateChanges as $index => $rateChange) { if ($id == $rateChange->getID()) { unset($this->rateChanges[$index]); $found = true; } } - + if ($found) { return true; } - + return false; } } diff --git a/src/Supplier.php b/src/Supplier.php index 26e690f2..120e8b41 100644 --- a/src/Supplier.php +++ b/src/Supplier.php @@ -70,7 +70,7 @@ public function __construct() $this->setFinancials(new SupplierFinancials); } - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); @@ -109,22 +109,22 @@ public function removeAddress($index) return false; } } - + public function removeAddressByID($id) { $found = false; - + foreach ($this->addresses as $index => $address) { if ($id == $address->getID()) { unset($this->addresses[$index]); $found = true; } } - + if ($found) { return true; } - + return false; } @@ -148,22 +148,22 @@ public function removeBank($index) return false; } } - + public function removeBankByID($id) { $found = false; - + foreach ($this->banks as $index => $bank) { if ($id == $bank->getID()) { unset($this->banks[$index]); $found = true; } } - + if ($found) { return true; } - + return false; } @@ -187,22 +187,22 @@ public function removePostingRule($index) return false; } } - + public function removePostingRuleByID($id) { $found = false; - + foreach ($this->postingRules as $index => $postingRule) { if ($id == $postingRule->getID()) { unset($this->postingRules[$index]); $found = true; } } - + if ($found) { return true; } - + return false; } } diff --git a/src/SupplierBank.php b/src/SupplierBank.php index 5c245186..1f9c3613 100644 --- a/src/SupplierBank.php +++ b/src/SupplierBank.php @@ -39,4 +39,4 @@ class SupplierBank extends BaseObject use NatBicCodeField; use PostcodeField; use StateField; -} \ No newline at end of file +} diff --git a/src/SupplierLine.php b/src/SupplierLine.php index 63e46cef..c56a035d 100644 --- a/src/SupplierLine.php +++ b/src/SupplierLine.php @@ -29,4 +29,4 @@ class SupplierLine extends BaseObject use OfficeField; use RatioField; use VatCodeField; -} \ No newline at end of file +} diff --git a/src/TransactionLineInterface.php b/src/TransactionLineInterface.php index f5b7a0d7..6a52df91 100644 --- a/src/TransactionLineInterface.php +++ b/src/TransactionLineInterface.php @@ -33,4 +33,4 @@ public function getTransaction(); * @return MatchReferenceInterface */ public function getReference(): MatchReferenceInterface; -} \ No newline at end of file +} diff --git a/src/User.php b/src/User.php index 5b3562b6..c9248753 100644 --- a/src/User.php +++ b/src/User.php @@ -55,7 +55,7 @@ class User extends BaseObject implements HasCodeInterface use TouchedField; use TypeField; use TypeLockedField; - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); diff --git a/src/UserRole.php b/src/UserRole.php index 1497ceaa..1ecfa5d6 100644 --- a/src/UserRole.php +++ b/src/UserRole.php @@ -18,11 +18,11 @@ class UserRole extends BaseObject implements HasCodeInterface use LevelField; use NameField; use ShortNameField; - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); return $instance; } -} \ No newline at end of file +} diff --git a/src/Util.php b/src/Util.php index cb64e2b3..6f2260fe 100644 --- a/src/Util.php +++ b/src/Util.php @@ -22,7 +22,7 @@ public static function formatMoney(?Money $money): ?string if ($money === null) { return null; } - + $decimalformatter = new DecimalMoneyFormatter(new ISOCurrencies()); return $decimalformatter->format($money); @@ -40,7 +40,7 @@ public static function parseMoney(?string $moneyString, ?Currency $currency): ?M if ($moneyString === null || $currency === null) { return null; } - + $parser = new DecimalMoneyParser(new ISOCurrencies()); return $parser->parse($moneyString, $currency); } @@ -56,7 +56,7 @@ public static function formatDate(?\DateTimeInterface $date): ?string if ($date === null) { return null; } - + return $date->format("Ymd"); } @@ -72,7 +72,7 @@ public static function parseDate(?string $dateString): ?\DateTimeImmutable if ($dateString === null) { return null; } - + $date = \DateTimeImmutable::createFromFormat("Ymd|", $dateString); if (false === $date) { @@ -93,7 +93,7 @@ public static function formatDateTime(?\DateTimeInterface $datetime): ?string if ($datetime === null) { return null; } - + return $datetime->format("YmdHis"); } @@ -109,7 +109,7 @@ public static function parseDateTime(?string $dateString): ?\DateTimeImmutable if ($dateString === null) { return null; } - + $date = \DateTimeImmutable::createFromFormat("YmdHis", $dateString); if (false === $date) { @@ -128,7 +128,7 @@ public static function formatBoolean(?bool $boolean): ?string if ($boolean === null) { return null; } - + return $boolean ? "true" : "false"; } @@ -141,7 +141,7 @@ public static function parseBoolean(?string $value): ?bool if ($value === null) { return null; } - + return filter_var($value, FILTER_VALIDATE_BOOLEAN); } @@ -154,7 +154,7 @@ public static function objectToStr(?HasCodeInterface $object): ?string if ($object === null) { return null; } - + return $object->getCode(); } @@ -195,4 +195,4 @@ public static function getPrettyXml(\DOMDocument $document): string return $xml_string ?: ''; } -} \ No newline at end of file +} diff --git a/src/VatCode.php b/src/VatCode.php index a0db2031..50e28362 100644 --- a/src/VatCode.php +++ b/src/VatCode.php @@ -34,7 +34,7 @@ class VatCode extends BaseObject implements HasCodeInterface use UserField; private $percentages = []; - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); @@ -62,4 +62,4 @@ public function removePercentage($index) return false; } } -} \ No newline at end of file +} diff --git a/src/VatCodePercentage.php b/src/VatCodePercentage.php index 59d6b3a4..a56995d1 100644 --- a/src/VatCodePercentage.php +++ b/src/VatCodePercentage.php @@ -66,4 +66,4 @@ public function removeAccountByID($id) return false; } -} \ No newline at end of file +} diff --git a/src/VatGroup.php b/src/VatGroup.php index 75e38c87..bdaa4145 100644 --- a/src/VatGroup.php +++ b/src/VatGroup.php @@ -16,11 +16,11 @@ class VatGroup extends BaseObject implements HasCodeInterface use CodeField; use NameField; use ShortNameField; - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); return $instance; } -} \ No newline at end of file +} diff --git a/src/VatGroupCountry.php b/src/VatGroupCountry.php index 951c81ea..13fa5809 100644 --- a/src/VatGroupCountry.php +++ b/src/VatGroupCountry.php @@ -16,11 +16,11 @@ class VatGroupCountry extends BaseObject implements HasCodeInterface use CodeField; use NameField; use ShortNameField; - + public static function fromCode(string $code) { $instance = new self; $instance->setCode($code); return $instance; } -} \ No newline at end of file +} diff --git a/tests/IntegrationTests/BaseIntegrationTest.php b/tests/IntegrationTests/BaseIntegrationTest.php index b4112974..df3a7461 100644 --- a/tests/IntegrationTests/BaseIntegrationTest.php +++ b/tests/IntegrationTests/BaseIntegrationTest.php @@ -58,7 +58,7 @@ protected function setUp() throw new \InvalidArgumentException("Unknown service {$service->getValue()}"); }); - + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { $office = new Office; @@ -73,4 +73,4 @@ protected function getSuccessfulResponse(): Response { return Response::fromString(''); } -} \ No newline at end of file +} diff --git a/tests/IntegrationTests/BrowseDataApiConnectorTest.php b/tests/IntegrationTests/BrowseDataApiConnectorTest.php index d34c0e7a..9301dd9c 100644 --- a/tests/IntegrationTests/BrowseDataApiConnectorTest.php +++ b/tests/IntegrationTests/BrowseDataApiConnectorTest.php @@ -233,4 +233,4 @@ public function testGetBrowseData() $this->assertEquals(false, $cell7->isHideForUser()); $this->assertEquals(-121.00, $cell7->getValue()); } -} \ No newline at end of file +} diff --git a/tests/IntegrationTests/InvoiceIntegrationTest.php b/tests/IntegrationTests/InvoiceIntegrationTest.php index 0e6556a0..0231f15b 100644 --- a/tests/IntegrationTests/InvoiceIntegrationTest.php +++ b/tests/IntegrationTests/InvoiceIntegrationTest.php @@ -39,12 +39,12 @@ protected function setUp() parent::setUp(); $this->invoiceApiConnector = new InvoiceApiConnector($this->connection); - + $mockInvoiceTypeApiConnector = \Mockery::mock('overload:'.InvoiceTypeApiConnector::class)->makePartial(); $mockInvoiceTypeApiConnector->shouldReceive('getInvoiceTypeVatType')->andReturnUsing(function() { return 'exclusive'; }); - + $mockArticleApiConnector = \Mockery::mock('overload:'.ArticleApiConnector::class)->makePartial(); $mockArticleApiConnector->shouldReceive('get')->andReturnUsing(function() { $article = new Article; @@ -52,11 +52,11 @@ protected function setUp() return $article; }); } - + protected function tearDown() - { + { unset($mockInvoiceTypeApiConnector, $mockArticleApiConnector); - + \Mockery::close(); } @@ -197,7 +197,7 @@ public function testGetFinalInvoiceWorks() } public function testSendInvoiceWorks() - { + { $customer = new Customer(); $customer->setCode('1000'); diff --git a/tests/IntegrationTests/OfficeIntegrationTest.php b/tests/IntegrationTests/OfficeIntegrationTest.php index e10307ec..160e7926 100644 --- a/tests/IntegrationTests/OfficeIntegrationTest.php +++ b/tests/IntegrationTests/OfficeIntegrationTest.php @@ -21,7 +21,7 @@ class OfficeIntegrationTest extends TestCase * @var OfficeApiConnector|\PHPUnit_Framework_MockObject_MockObject */ private $officeApiConnector; - + /** * @var Office */ @@ -66,7 +66,7 @@ protected function setUp() throw new \InvalidArgumentException("Unknown service {$service->getValue()}"); }); - + $this->officeApiConnector = new OfficeApiConnector($this->connection); } @@ -94,4 +94,4 @@ public function testListOfficesWithoutCompanyId() $this->assertSame('010', $offices[1]->getCode()); $this->assertSame('More&Zo Holding', $offices[1]->getName()); } -} \ No newline at end of file +} diff --git a/tests/UnitTests/ApiConnectors/BaseApiConnectorTest.php b/tests/UnitTests/ApiConnectors/BaseApiConnectorTest.php index b3d6b121..c7b201be 100644 --- a/tests/UnitTests/ApiConnectors/BaseApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/BaseApiConnectorTest.php @@ -286,4 +286,4 @@ public function testResendXmlDocumentStopsAfterMaxRetries(\Exception $exception) $numRetries = $this->getObjectAttribute($this->service, "numRetries"); $this->assertEquals(0, $numRetries); } -} \ No newline at end of file +} diff --git a/tests/UnitTests/ApiConnectors/BrowseDataApiConnectorTest.php b/tests/UnitTests/ApiConnectors/BrowseDataApiConnectorTest.php index 5bc87c16..584e4061 100644 --- a/tests/UnitTests/ApiConnectors/BrowseDataApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/BrowseDataApiConnectorTest.php @@ -73,4 +73,4 @@ public function testFailureResponseForGetBrowseDataWithWrongSortFieldsObjects() $this->apiConnector->getBrowseData('001', $columns, $columns); } -} \ No newline at end of file +} diff --git a/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php b/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php index 047ab933..f50866bd 100644 --- a/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/CustomerApiConnectorTest.php @@ -45,7 +45,7 @@ protected function setUp() ->willReturn($this->processXmlService); $this->apiConnector = new CustomerApiConnector($connection); - + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { $office = new Office; diff --git a/tests/UnitTests/ApiConnectors/FixedAssetApiConnectorTest.php b/tests/UnitTests/ApiConnectors/FixedAssetApiConnectorTest.php index e1e6cd43..0e332861 100644 --- a/tests/UnitTests/ApiConnectors/FixedAssetApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/FixedAssetApiConnectorTest.php @@ -45,7 +45,7 @@ protected function setUp() ->willReturn($this->processXmlService); $this->apiConnector = new FixedAssetApiConnector($connection); - + $mockOfficeApiConnector = \Mockery::mock('overload:'.OfficeApiConnector::class)->makePartial(); $mockOfficeApiConnector->shouldReceive('get')->andReturnUsing(function() { $office = new Office; diff --git a/tests/UnitTests/ApiConnectors/InvoiceApiConnectorTest.php b/tests/UnitTests/ApiConnectors/InvoiceApiConnectorTest.php index 076e5180..d340ee09 100644 --- a/tests/UnitTests/ApiConnectors/InvoiceApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/InvoiceApiConnectorTest.php @@ -46,12 +46,12 @@ protected function setUp() ->willReturn($this->processXmlService); $this->apiConnector = new InvoiceApiConnector($connection); - + $mockInvoiceTypeApiConnector = \Mockery::mock('overload:'.InvoiceTypeApiConnector::class)->makePartial(); $mockInvoiceTypeApiConnector->shouldReceive('getInvoiceTypeVatType')->andReturnUsing(function() { return 'exclusive'; }); - + $mockArticleApiConnector = \Mockery::mock('overload:'.ArticleApiConnector::class)->makePartial(); $mockArticleApiConnector->shouldReceive('get')->andReturnUsing(function() { $article = new Article; diff --git a/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php b/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php index f308a83a..279ecfa6 100644 --- a/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/TransactionApiConnectorTest.php @@ -140,4 +140,4 @@ public function testSendReturnsMappedObjects() $this->assertEquals("INV123458", $mapped->getInvoiceNumber()); $this->assertEquals(new \DateTimeImmutable("2017-09-01"), $mapped->getDate()); } -} \ No newline at end of file +} diff --git a/tests/UnitTests/DomDocuments/ElectronicBankStatementDocumentUnitTest.php b/tests/UnitTests/DomDocuments/ElectronicBankStatementDocumentUnitTest.php index bd4715af..06ffbb92 100644 --- a/tests/UnitTests/DomDocuments/ElectronicBankStatementDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/ElectronicBankStatementDocumentUnitTest.php @@ -118,4 +118,4 @@ public function testNegativeBalanceIsPossible() ,$domdocument->saveXML()); } -} \ No newline at end of file +} diff --git a/tests/UnitTests/DomDocuments/MatchDocumentUnitTest.php b/tests/UnitTests/DomDocuments/MatchDocumentUnitTest.php index 03c40c0f..e78138da 100644 --- a/tests/UnitTests/DomDocuments/MatchDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/MatchDocumentUnitTest.php @@ -170,4 +170,4 @@ public function testDiscount() $matchdocument->saveXML() ); } -} \ No newline at end of file +} diff --git a/tests/UnitTests/Request/BrowseDataUnitTest.php b/tests/UnitTests/Request/BrowseDataUnitTest.php index 0ceda138..57caffa8 100644 --- a/tests/UnitTests/Request/BrowseDataUnitTest.php +++ b/tests/UnitTests/Request/BrowseDataUnitTest.php @@ -68,4 +68,4 @@ public function testFailureResponseForConstructorWithWrongSortFieldsObjects() new BrowseData('000', $columns, $columns); } -} \ No newline at end of file +} diff --git a/tests/UnitTests/SalesTransactionUnitTest.php b/tests/UnitTests/SalesTransactionUnitTest.php index 0267205e..1028ce62 100644 --- a/tests/UnitTests/SalesTransactionUnitTest.php +++ b/tests/UnitTests/SalesTransactionUnitTest.php @@ -87,4 +87,4 @@ private static function assertLinesInOrderBasedOnDescription( self::assertSame($expected_line_count, $i, 'Number of returned lines does not match number of added lines'); } -} \ No newline at end of file +} diff --git a/tests/UnitTests/Secure/OpenIdConnectionAuthenticationTest.php b/tests/UnitTests/Secure/OpenIdConnectionAuthenticationTest.php index f43192bc..15f1e9b4 100644 --- a/tests/UnitTests/Secure/OpenIdConnectionAuthenticationTest.php +++ b/tests/UnitTests/Secure/OpenIdConnectionAuthenticationTest.php @@ -122,4 +122,4 @@ public function testInvalidTokenLogin() $this->assertEquals("someClusterUrl", $openIdConnect->getCluster()); } -} \ No newline at end of file +} diff --git a/tests/UnitTests/Secure/Provider/OAuthProviderTest.php b/tests/UnitTests/Secure/Provider/OAuthProviderTest.php index 93692643..6fe48bcb 100644 --- a/tests/UnitTests/Secure/Provider/OAuthProviderTest.php +++ b/tests/UnitTests/Secure/Provider/OAuthProviderTest.php @@ -146,4 +146,4 @@ public function testGetResourceOwnerDetails() $this->assertEquals("someId", $account->getId()); $this->assertEquals(["sub" => "someId", "twf.organisationId" => "someOrganisationId"], $account->toArray()); } -} \ No newline at end of file +} From 32e221c7479b4cb9b79ed526f24c050400c68489 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 29 Jun 2019 12:14:25 +0200 Subject: [PATCH 375/388] Update HasEqualInterface.php --- src/ApiConnectors/HasEqualInterface.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/ApiConnectors/HasEqualInterface.php b/src/ApiConnectors/HasEqualInterface.php index 4efaa027..08fb75d9 100644 --- a/src/ApiConnectors/HasEqualInterface.php +++ b/src/ApiConnectors/HasEqualInterface.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\ApiConnectors; use PhpTwinfield\HasMessageInterface; -use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; /** @@ -15,6 +14,4 @@ interface HasEqualInterface public function testEqual(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): array; public function sendAll(array $objects, bool $reSend): MappedResponseCollection; - - public function getMappedResponse(HasMessageInterface $object): IndividualMappedResponse; } From 52f401c2bcdc1b2906016938548ed4ec31374d64 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 29 Jun 2019 12:18:03 +0200 Subject: [PATCH 376/388] Upload --- src/ApiConnectors/BaseApiConnector.php | 2 +- tests/UnitTests/ApiConnectors/VatCodeApiConnectorTest.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ApiConnectors/BaseApiConnector.php b/src/ApiConnectors/BaseApiConnector.php index 56c34886..735318fe 100644 --- a/src/ApiConnectors/BaseApiConnector.php +++ b/src/ApiConnectors/BaseApiConnector.php @@ -264,7 +264,7 @@ public function testSentEqualsResponse(HasEqualInterface $apiConnector, array $s if (!$equal) { $apiConnector->sendAll([$returnedObject], true)[0]; sleep(2); - $individualMappedResponse = $this->sendAll([$sentObjects[$key]], true)[0]; + $individualMappedResponse = $apiConnector->sendAll([$sentObjects[$key]], true)[0]; } } diff --git a/tests/UnitTests/ApiConnectors/VatCodeApiConnectorTest.php b/tests/UnitTests/ApiConnectors/VatCodeApiConnectorTest.php index cd63624b..ed9d5567 100644 --- a/tests/UnitTests/ApiConnectors/VatCodeApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/VatCodeApiConnectorTest.php @@ -4,6 +4,7 @@ use PhpTwinfield\ApiConnectors\VatCodeApiConnector; use PhpTwinfield\VatCode; +use PhpTwinfield\VatCodePercentage; use PhpTwinfield\Response\Response; use PhpTwinfield\Secure\AuthenticatedConnection; use PhpTwinfield\Services\ProcessXmlService; @@ -43,6 +44,8 @@ protected function setUp() private function createVatCode(): VatCode { $vatCode = new VatCode(); + $vatCodePercentage = new VatCodePercentage(); + $vatCode->addPercentage($vatCodePercentage); return $vatCode; } From eefc402780121a2404ded55d0ad9d8e613d89757 Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 29 Jun 2019 12:49:22 +0200 Subject: [PATCH 377/388] Update VatCodeApiConnectorTest.php --- tests/UnitTests/ApiConnectors/VatCodeApiConnectorTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/UnitTests/ApiConnectors/VatCodeApiConnectorTest.php b/tests/UnitTests/ApiConnectors/VatCodeApiConnectorTest.php index ed9d5567..c5ac1b42 100644 --- a/tests/UnitTests/ApiConnectors/VatCodeApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/VatCodeApiConnectorTest.php @@ -45,6 +45,7 @@ private function createVatCode(): VatCode { $vatCode = new VatCode(); $vatCodePercentage = new VatCodePercentage(); + $vatCodePercentage->setDate(\PhpTwinfield\Util::parseDate('20121001')); $vatCode->addPercentage($vatCodePercentage); return $vatCode; } From f49a93d41fa1cff08ad54bce03c2d3a050aba2fe Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 30 Jun 2019 11:04:16 +0200 Subject: [PATCH 378/388] Upload --- src/ApiConnectors/ArticleApiConnector.php | 1 - src/ApiConnectors/AssetMethodApiConnector.php | 48 +++++++++++++++++-- src/ApiConnectors/CurrencyApiConnector.php | 1 - src/ApiConnectors/RateApiConnector.php | 1 - src/ApiConnectors/VatCodeApiConnector.php | 1 - 5 files changed, 45 insertions(+), 7 deletions(-) diff --git a/src/ApiConnectors/ArticleApiConnector.php b/src/ApiConnectors/ArticleApiConnector.php index 40b6f073..5dc41c30 100644 --- a/src/ApiConnectors/ArticleApiConnector.php +++ b/src/ApiConnectors/ArticleApiConnector.php @@ -9,7 +9,6 @@ use PhpTwinfield\Mappers\ArticleMapper; use PhpTwinfield\Office; use PhpTwinfield\Request as Request; -use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; use PhpTwinfield\Response\ResponseException; diff --git a/src/ApiConnectors/AssetMethodApiConnector.php b/src/ApiConnectors/AssetMethodApiConnector.php index 08d7f738..ae31646c 100644 --- a/src/ApiConnectors/AssetMethodApiConnector.php +++ b/src/ApiConnectors/AssetMethodApiConnector.php @@ -5,6 +5,7 @@ use PhpTwinfield\AssetMethod; use PhpTwinfield\DomDocuments\AssetMethodsDocument; use PhpTwinfield\Exception; +use PhpTwinfield\HasMessageInterface; use PhpTwinfield\Mappers\AssetMethodMapper; use PhpTwinfield\Office; use PhpTwinfield\Request as Request; @@ -23,7 +24,7 @@ * * @author Yannick Aerssens */ -class AssetMethodApiConnector extends BaseApiConnector +class AssetMethodApiConnector extends BaseApiConnector implements HasEqualInterface { /** * Requests a specific AssetMethod based off the passed in code and optionally the office. @@ -64,10 +65,11 @@ public function send(AssetMethod $assetMethod): AssetMethod /** * @param AssetMethod[] $assetMethods + * @param bool|null $reSend * @return MappedResponseCollection * @throws Exception */ - public function sendAll(array $assetMethods): MappedResponseCollection + public function sendAll(array $assetMethods, bool $reSend = false): MappedResponseCollection { Assert::allIsInstanceOf($assetMethods, AssetMethod::class); @@ -85,9 +87,49 @@ public function sendAll(array $assetMethods): MappedResponseCollection $responses[] = $this->sendXmlDocument($assetMethodsDocument); } - return $this->getProcessXmlService()->mapAll($responses, "assetmethod", function(Response $response): AssetMethod { + $mappedResponseCollection = $this->getProcessXmlService()->mapAll($responses, "assetmethod", function(Response $response): AssetMethod { return AssetMethodMapper::map($response); }); + + if ($reSend) { + return $mappedResponseCollection; + } + + return self::testSentEqualsResponse($this, $assetMethods, $mappedResponseCollection); + } + + /** + * @param HasMessageInterface $returnedObject + * @param HasMessageInterface $sentObject + * @return array + */ + public function testEqual(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): array + { + Assert::IsInstanceOf($returnedObject, AssetMethod::class); + Assert::IsInstanceOf($sentObject, AssetMethod::class); + + $equal = true; + + $idArray = []; + + $returnedFreeTexts = $returnedObject->getFreeTexts(); + $sentFreeTexts = $sentObject->getFreeTexts(); + + foreach ($sentFreeTexts as $key => $sentFreeText) { + $idArray[] = $sentFreeText->getID(); + } + + foreach ($returnedFreeTexts as $key => $returnedFreeText) { + $id = $returnedFreeText->getID(); + + if (!in_array($id, $idArray)) { + $returnedFreeText->setType(\PhpTwinfield\Enums\FreeTextType::TEXT()); + $returnedFreeText->setElementValue(''); + $equal = false; + } + } + + return [$equal, $returnedObject]; } /** diff --git a/src/ApiConnectors/CurrencyApiConnector.php b/src/ApiConnectors/CurrencyApiConnector.php index 8bf9be06..ab29165b 100644 --- a/src/ApiConnectors/CurrencyApiConnector.php +++ b/src/ApiConnectors/CurrencyApiConnector.php @@ -9,7 +9,6 @@ use PhpTwinfield\Mappers\CurrencyMapper; use PhpTwinfield\Office; use PhpTwinfield\Request as Request; -use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; use PhpTwinfield\Response\ResponseException; diff --git a/src/ApiConnectors/RateApiConnector.php b/src/ApiConnectors/RateApiConnector.php index 93527ebe..191ca2fe 100644 --- a/src/ApiConnectors/RateApiConnector.php +++ b/src/ApiConnectors/RateApiConnector.php @@ -9,7 +9,6 @@ use PhpTwinfield\Office; use PhpTwinfield\Rate; use PhpTwinfield\Request as Request; -use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; use PhpTwinfield\Response\ResponseException; diff --git a/src/ApiConnectors/VatCodeApiConnector.php b/src/ApiConnectors/VatCodeApiConnector.php index 579431f2..79f1a0ad 100644 --- a/src/ApiConnectors/VatCodeApiConnector.php +++ b/src/ApiConnectors/VatCodeApiConnector.php @@ -8,7 +8,6 @@ use PhpTwinfield\Mappers\VatCodeMapper; use PhpTwinfield\Office; use PhpTwinfield\Request as Request; -use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; use PhpTwinfield\Response\ResponseException; From aba5b585dd41e7af9a144f63285076e6d0a591c0 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 30 Jun 2019 12:07:23 +0200 Subject: [PATCH 379/388] Update AssetMethodApiConnectorTest.php --- .../ApiConnectors/AssetMethodApiConnectorTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/UnitTests/ApiConnectors/AssetMethodApiConnectorTest.php b/tests/UnitTests/ApiConnectors/AssetMethodApiConnectorTest.php index 595b4e2f..8110a924 100644 --- a/tests/UnitTests/ApiConnectors/AssetMethodApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/AssetMethodApiConnectorTest.php @@ -4,6 +4,7 @@ use PhpTwinfield\ApiConnectors\AssetMethodApiConnector; use PhpTwinfield\AssetMethod; +use PhpTwinfield\AssetMethodFreeText; use PhpTwinfield\Response\Response; use PhpTwinfield\Secure\AuthenticatedConnection; use PhpTwinfield\Services\ProcessXmlService; @@ -43,6 +44,16 @@ protected function setUp() private function createAssetMethod(): AssetMethod { $assetMethod = new AssetMethod(); + $freeTexts = []; + + for ($i = 1; $i <=5; $i++) { + $freeTexts[$i] = new AssetMethodFreeText; + $freeTexts[$i]->setID($i) + ->setElementValue($i) + ->setType(\PhpTwinfield\Enums\FreeTextType::TEXT()); + $assetMethod->addFreeText($freeTexts[$i]); + } + return $assetMethod; } From e622718f4d46bb3554154d4da61a808f24958f0f Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 3 Jul 2019 18:36:10 +0200 Subject: [PATCH 380/388] Update readme.md --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 40aeed4e..5965207d 100644 --- a/readme.md +++ b/readme.md @@ -57,7 +57,7 @@ support for another resource. [Cash Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/CashTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Cash Transaction](examples/CashTransaction.php) | [Journal Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/JournalTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Journal Transaction](examples/JournalTransaction.php) | [Purchase Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Purchase Transaction](examples/PurchaseTransaction.php) | -[Sale Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Sales Transaction](examples/SalesTransaction.php) | +[Sales Transactions](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions) | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | [Sales Transaction](examples/SalesTransaction.php) | | | | | | | | | | [Users](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Users) | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | [User](examples/User.php) | | User Roles | | :white_check_mark: | | | :white_check_mark: | [User Role](examples/UserRole.php) | From 58b219285f3efe7d51410ce8407d69255d3eb6dd Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 3 Jul 2019 20:07:09 +0200 Subject: [PATCH 381/388] Upload --- src/Mappers/TransactionMapper.php | 3 ++- src/SalesTransactionLine.php | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 02a934fd..75fea63b 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -148,6 +148,8 @@ public static function map(string $transactionClassName, Response $response, Aut $transactionLine = new $transactionLineClassName(); $lineType = $lineElement->getAttribute('type'); + + $transactionLine->setLineType(self::parseEnumAttribute(\PhpTwinfield\Enums\LineType::class, $lineType)); $transactionLine ->setBaseValue(self::parseMoneyAttribute(self::getField($lineElement, 'basevalue', $transactionLine), $currencies['base'])) @@ -158,7 +160,6 @@ public static function map(string $transactionClassName, Response $response, Aut ->setDestOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $transactionLine, $lineElement, 'destoffice')) ->setDim1(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) ->setId($lineElement->getAttribute('id')) - ->setLineType(self::parseEnumAttribute(\PhpTwinfield\Enums\LineType::class, $lineType)) ->setMatchStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\MatchStatus::class, self::getField($lineElement, 'matchstatus', $transactionLine))) ->setRate(self::getField($lineElement, 'rate', $transactionLine)) ->setRepRate(self::getField($lineElement, 'reprate', $transactionLine)) diff --git a/src/SalesTransactionLine.php b/src/SalesTransactionLine.php index fcefdf5c..1366e501 100644 --- a/src/SalesTransactionLine.php +++ b/src/SalesTransactionLine.php @@ -160,6 +160,7 @@ public function setMatchLevel(?int $matchLevel): parent /* * Payment status of the transaction. If line type detail or vat always notmatchable. Read-only attribute. + * NOTE: The above statement from the Twinfield API documentation is incorrect as detail lines can also have other match statuses than notmatchable * * @param MatchStatus|null $matchStatus * @return $this @@ -167,7 +168,8 @@ public function setMatchLevel(?int $matchLevel): parent */ public function setMatchStatus(?MatchStatus $matchStatus): parent { - if ($matchStatus !== null && in_array($this->getLineType(), [LineType::DETAIL(), LineType::VAT()]) && $matchStatus != MatchStatus::NOTMATCHABLE()) { + //if ($matchStatus !== null && in_array($this->getLineType(), [LineType::DETAIL(), LineType::VAT()]) && $matchStatus != MatchStatus::NOTMATCHABLE()) { + if ($matchStatus !== null && in_array($this->getLineType(), [LineType::VAT()]) && $matchStatus != MatchStatus::NOTMATCHABLE()) { throw Exception::invalidMatchStatusForLineType($matchStatus, $this); } From 20f10eccd4c51ff3ab75c1509b5473c81234aa13 Mon Sep 17 00:00:00 2001 From: iranl Date: Thu, 4 Jul 2019 20:00:34 +0200 Subject: [PATCH 382/388] Upload --- src/ApiConnectors/ArticleApiConnector.php | 23 +++++++++++++++- src/ApiConnectors/AssetMethodApiConnector.php | 23 +++++++++++++++- src/ApiConnectors/BaseApiConnector.php | 26 ++++++++++++++++--- src/ApiConnectors/CurrencyApiConnector.php | 12 ++++++++- src/ApiConnectors/HasEqualInterface.php | 3 +++ src/ApiConnectors/RateApiConnector.php | 23 +++++++++++++++- src/ApiConnectors/VatCodeApiConnector.php | 22 +++++++++++++++- src/Mappers/TransactionMapper.php | 2 +- 8 files changed, 125 insertions(+), 9 deletions(-) diff --git a/src/ApiConnectors/ArticleApiConnector.php b/src/ApiConnectors/ArticleApiConnector.php index 5dc41c30..d4ba546d 100644 --- a/src/ApiConnectors/ArticleApiConnector.php +++ b/src/ApiConnectors/ArticleApiConnector.php @@ -9,6 +9,7 @@ use PhpTwinfield\Mappers\ArticleMapper; use PhpTwinfield\Office; use PhpTwinfield\Request as Request; +use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; use PhpTwinfield\Response\ResponseException; @@ -120,7 +121,7 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa foreach ($returnedLines as $key => $returnedLine) { $id = $returnedLine->getID(); - if (!in_array($id, $idArray)) { + if (!in_array($id, $idArray) && $returnedLine->getStatus() != 'deleted') { $returnedLine->setStatus(\PhpTwinfield\Enums\Status::DELETED()); $equal = false; } @@ -129,6 +130,26 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa return [$equal, $returnedObject]; } + /** + * @param HasMessageInterface $returnedObject + * @return IndividualMappedResponse + */ + public function getMappedResponse(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): IndividualMappedResponse + { + Assert::IsInstanceOf($returnedObject, Article::class); + + $request_article = new Request\Read\Article(); + $request_article->setOffice($returnedObject->getOffice()) + ->setCode($returnedObject->getCode()); + $response = $this->sendXmlDocument($request_article); + + $mappedResponseCollection = $this->getProcessXmlService()->mapAll([$response], "article", function(Response $response): Article { + return ArticleMapper::map($response, $this->getConnection()); + }); + + return ($mappedResponseCollection[0]); + } + /** * List all articles. * diff --git a/src/ApiConnectors/AssetMethodApiConnector.php b/src/ApiConnectors/AssetMethodApiConnector.php index ae31646c..823b3920 100644 --- a/src/ApiConnectors/AssetMethodApiConnector.php +++ b/src/ApiConnectors/AssetMethodApiConnector.php @@ -9,6 +9,7 @@ use PhpTwinfield\Mappers\AssetMethodMapper; use PhpTwinfield\Office; use PhpTwinfield\Request as Request; +use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; use PhpTwinfield\Response\ResponseException; @@ -122,7 +123,7 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa foreach ($returnedFreeTexts as $key => $returnedFreeText) { $id = $returnedFreeText->getID(); - if (!in_array($id, $idArray)) { + if (!in_array($id, $idArray) && (!empty($returnedFreeText->getElementValue()) || $returnedFreeText->getType() != 'text')) { $returnedFreeText->setType(\PhpTwinfield\Enums\FreeTextType::TEXT()); $returnedFreeText->setElementValue(''); $equal = false; @@ -132,6 +133,26 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa return [$equal, $returnedObject]; } + /** + * @param HasMessageInterface $returnedObject + * @return IndividualMappedResponse + */ + public function getMappedResponse(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): IndividualMappedResponse + { + Assert::IsInstanceOf($returnedObject, AssetMethod::class); + + $request_assetMethod = new Request\AssetMethod(); + $request_assetMethod->setOffice($returnedObject->getOffice()) + ->setCode($returnedObject->getCode()); + $response = $this->sendXmlDocument($request_assetMethod); + + $mappedResponseCollection = $this->getProcessXmlService()->mapAll([$response], "assetmethod", function(Response $response): AssetMethod { + return AssetMethodMapper::map($response); + }); + + return ($mappedResponseCollection[0]); + } + /** * List all asset methods. * diff --git a/src/ApiConnectors/BaseApiConnector.php b/src/ApiConnectors/BaseApiConnector.php index 735318fe..1a1872cc 100644 --- a/src/ApiConnectors/BaseApiConnector.php +++ b/src/ApiConnectors/BaseApiConnector.php @@ -262,9 +262,29 @@ public function testSentEqualsResponse(HasEqualInterface $apiConnector, array $s $returnedObject = $testResult[1]; if (!$equal) { - $apiConnector->sendAll([$returnedObject], true)[0]; - sleep(2); - $individualMappedResponse = $apiConnector->sendAll([$sentObjects[$key]], true)[0]; + $tempMappedResponse = $apiConnector->sendAll([$returnedObject], true)[0]; + $tempReturnedObject = $tempMappedResponse->unwrap(); + + if ($tempReturnedObject->getResult() == 1) { + $individualMappedResponse = $tempMappedResponse; + $returnedObject = $tempReturnedObject; + + $testResult = $apiConnector->testEqual($returnedObject, $sentObjects[$key]); + $equal = $testResult[0]; + $returnedObject = $testResult[1]; + + if (!$equal || is_a($returnedObject, \PhpTwinfield\Currency::class)) { + sleep(2); + + $tempMappedResponse = $apiConnector->getMappedResponse($returnedObject, $sentObjects[$key]); + $tempReturnedObject = $tempMappedResponse->unwrap(); + + if ($returnedObject->getResult() == 1) { + $individualMappedResponse = $tempMappedResponse; + $returnedObject = $tempReturnedObject; + } + } + } } } diff --git a/src/ApiConnectors/CurrencyApiConnector.php b/src/ApiConnectors/CurrencyApiConnector.php index ab29165b..42188182 100644 --- a/src/ApiConnectors/CurrencyApiConnector.php +++ b/src/ApiConnectors/CurrencyApiConnector.php @@ -9,6 +9,7 @@ use PhpTwinfield\Mappers\CurrencyMapper; use PhpTwinfield\Office; use PhpTwinfield\Request as Request; +use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; use PhpTwinfield\Response\ResponseException; @@ -160,7 +161,7 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa foreach ($returnedRates as $returnedRate) { $date = Util::formatDate($returnedRate->getStartDate()); - if (!in_array($date, $dateArray)) { + if (!in_array($date, $dateArray) && $returnedRate->getStatus() != 'deleted') { $returnedRate->setStatus(\PhpTwinfield\Enums\Status::DELETED()); $equal = false; } @@ -169,6 +170,15 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa return [$equal, $returnedObject]; } + /** + * @param HasMessageInterface $returnedObject + * @return IndividualMappedResponse + */ + public function getMappedResponse(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): IndividualMappedResponse + { + return $this->sendAll([$sentObject], true)[0]; + } + /** * List all currencies. * diff --git a/src/ApiConnectors/HasEqualInterface.php b/src/ApiConnectors/HasEqualInterface.php index 08fb75d9..8b2dbfd8 100644 --- a/src/ApiConnectors/HasEqualInterface.php +++ b/src/ApiConnectors/HasEqualInterface.php @@ -3,6 +3,7 @@ namespace PhpTwinfield\ApiConnectors; use PhpTwinfield\HasMessageInterface; +use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; /** @@ -14,4 +15,6 @@ interface HasEqualInterface public function testEqual(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): array; public function sendAll(array $objects, bool $reSend): MappedResponseCollection; + + public function getMappedResponse(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): IndividualMappedResponse; } diff --git a/src/ApiConnectors/RateApiConnector.php b/src/ApiConnectors/RateApiConnector.php index 191ca2fe..9ad8300c 100644 --- a/src/ApiConnectors/RateApiConnector.php +++ b/src/ApiConnectors/RateApiConnector.php @@ -9,6 +9,7 @@ use PhpTwinfield\Office; use PhpTwinfield\Rate; use PhpTwinfield\Request as Request; +use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; use PhpTwinfield\Response\ResponseException; @@ -121,7 +122,7 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa foreach ($returnedRateChanges as $key => $returnedRateChange) { $id = $returnedRateChange->getID(); - if (!in_array($id, $idArray)) { + if (!in_array($id, $idArray) && $returnedRateChange->getStatus() != 'deleted') { $returnedRateChange->setStatus(\PhpTwinfield\Enums\Status::DELETED()); $equal = false; } @@ -130,6 +131,26 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa return [$equal, $returnedObject]; } + /** + * @param HasMessageInterface $returnedObject + * @return IndividualMappedResponse + */ + public function getMappedResponse(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): IndividualMappedResponse + { + Assert::IsInstanceOf($returnedObject, Rate::class); + + $request_rate = new Request\Read\Rate(); + $request_rate->setOffice($returnedObject->getOffice()) + ->setCode($returnedObject->getCode()); + $response = $this->sendXmlDocument($request_rate); + + $mappedResponseCollection = $this->getProcessXmlService()->mapAll([$response], "projectrate", function(Response $response): Rate { + return RateMapper::map($response); + }); + + return ($mappedResponseCollection[0]); + } + /** * List all rates. * diff --git a/src/ApiConnectors/VatCodeApiConnector.php b/src/ApiConnectors/VatCodeApiConnector.php index 79f1a0ad..79b24c88 100644 --- a/src/ApiConnectors/VatCodeApiConnector.php +++ b/src/ApiConnectors/VatCodeApiConnector.php @@ -8,6 +8,7 @@ use PhpTwinfield\Mappers\VatCodeMapper; use PhpTwinfield\Office; use PhpTwinfield\Request as Request; +use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; use PhpTwinfield\Response\ResponseException; @@ -122,7 +123,7 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa foreach ($returnedPercentages as $key => $returnedPercentage) { $date = Util::formatDate($returnedPercentage->getDate()); - if (!in_array($date, $dateArray)) { + if (!in_array($date, $dateArray) && $returnedPercentage->getStatus() != 'deleted') { $returnedPercentage->setStatus(\PhpTwinfield\Enums\Status::DELETED()); $equal = false; } @@ -131,6 +132,25 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa return [$equal, $returnedObject]; } + /** + * @param HasMessageInterface $returnedObject + * @return IndividualMappedResponse + */ + public function getMappedResponse(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): IndividualMappedResponse + { + Assert::IsInstanceOf($returnedObject, VatCode::class); + + $request_vatCode = new Request\Read\VatCode(); + $request_vatCode->setCode($returnedObject->getCode()); + $response = $this->sendXmlDocument($request_vatCode); + + $mappedResponseCollection = $this->getProcessXmlService()->mapAll([$response], "vat", function(Response $response): VatCode { + return VatCodeMapper::map($response); + }); + + return ($mappedResponseCollection[0]); + } + /** * List all VAT codes. * diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 75fea63b..c3a113c1 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -148,7 +148,7 @@ public static function map(string $transactionClassName, Response $response, Aut $transactionLine = new $transactionLineClassName(); $lineType = $lineElement->getAttribute('type'); - + $transactionLine->setLineType(self::parseEnumAttribute(\PhpTwinfield\Enums\LineType::class, $lineType)); $transactionLine From 9b629458de1f63f87af0cc766759758660dbc89d Mon Sep 17 00:00:00 2001 From: iranl Date: Sat, 6 Jul 2019 21:50:03 +0200 Subject: [PATCH 383/388] Upload --- examples/Activity.php | 4 +- examples/Article.php | 4 +- examples/AssetMethod.php | 4 +- examples/Authorization.php | 3 + examples/BankTransaction.php | 344 ++++++++++++++++++ examples/BrowseData.php | 4 +- examples/CashBankBook.php | 4 +- examples/CashTransaction.php | 344 ++++++++++++++++++ examples/Connection.php | 3 + examples/CostCenter.php | 4 +- examples/Country.php | 4 +- examples/Currency.php | 4 +- examples/Customer.php | 4 +- examples/DimensionGroup.php | 4 +- examples/DimensionType.php | 4 +- examples/FixedAsset.php | 4 +- examples/GeneralLedger.php | 4 +- examples/Invoice.php | 10 +- examples/InvoiceType.php | 4 +- examples/Office.php | 4 +- examples/PayCode.php | 4 +- examples/Project.php | 4 +- examples/Rate.php | 4 +- examples/RenewAccessToken.php | 3 + examples/RenewAuthorization.php | 3 + examples/Supplier.php | 4 +- examples/User.php | 4 +- examples/UserRole.php | 4 +- examples/VatCode.php | 4 +- examples/VatGroup.php | 4 +- examples/VatGroupCountry.php | 4 +- src/BaseObject.php | 4 + .../Transaction/CloseAndStartValueFields.php | 15 +- src/InvoiceLine.php | 1 + src/Mappers/BaseMapper.php | 6 + src/Mappers/TransactionMapper.php | 14 +- 36 files changed, 807 insertions(+), 39 deletions(-) create mode 100644 examples/BankTransaction.php create mode 100644 examples/CashTransaction.php diff --git a/examples/Activity.php b/examples/Activity.php index e4623ec2..0252d4e6 100644 --- a/examples/Activity.php +++ b/examples/Activity.php @@ -1,5 +1,4 @@ get(\PhpTwinfield\BankTransaction::class, "BNK", 201900011, $office); + } catch (ResponseException $e) { + $bankTransaction = $e->getReturnedObject(); + } + + echo "
";
+    print_r($bankTransaction);
+    echo "
"; + + echo "BankTransaction
"; + echo "AutoBalanceVat (bool): {$bankTransaction->getAutoBalanceVat()}
"; // bool|null Should VAT be rounded true or not false? Rounding will only be done with a maximum of two cents. + echo "AutoBalanceVat (string): " . Util::formatBoolean($bankTransaction->getAutoBalanceVat()) . "
"; // string|null + echo "BookingReference (\\PhpTwinfield\\BookingReference):
" . print_r($bankTransaction->getBookingReference(), true) . "

"; // BookingReference|null The Booking reference + echo "CloseValue (\\Money\\Money):
" . print_r($bankTransaction->getCloseValue(), true) . "

"; // Money|null Closing balance. If not provided, the closing balance is set to zero. + echo "CloseValue (string): " . Util::formatMoney($bankTransaction->getCloseValue()) . "
"; // string|null + echo "Code: {$bankTransaction->getCode()}
"; // string|null Transaction type code. + echo "Currency (\\PhpTwinfield\\Currency):
" . print_r($bankTransaction->getCurrency(), true) . "

"; // Currency|null Currency code. + echo "Currency (string): " . Util::objectToStr($bankTransaction->getCurrency()) . "
"; // string|null + echo "Date (\\DateTimeInterface):
" . print_r($bankTransaction->getDate(), true) . "

"; // DateTimeInterface|null Transaction date. + echo "Date (string): " . Util::formatDate($bankTransaction->getDate()) . "
"; // string|null + echo "DateRaiseWarning (bool): {$bankTransaction->getDateRaiseWarning()}
"; // bool|null Optionally, it is possible to suppress warnings about 'date out of range for the given period' by adding the raisewarning attribute and set its value to false. + echo "DateRaiseWarning (string): {$bankTransaction->getDateRaiseWarningToString()}
"; // string|null This overwrites the value of the raisewarning attribute as set on the root element. + echo "Destiny: {$bankTransaction->getDestiny()}
"; // Destiny|null Attribute to indicate the destiny of the bank transaction. Only used in the request XML. temporary = bank transaction will be saved as provisional. final = bank transaction will be saved as final. + echo "FreeText1: {$bankTransaction->getFreeText1()}
"; // string|null Free text field 1 as entered on the transaction type. + echo "FreeText2: {$bankTransaction->getFreeText2()}
"; // string|null Free text field 2 as entered on the transaction type. + echo "FreeText3: {$bankTransaction->getFreeText3()}
"; // string|null Free text field 3 as entered on the transaction type. + echo "InputDate (\\DateTimeInterface):
" . print_r($bankTransaction->getInputDate(), true) . "

"; // DateTimeInterface|null The date/time on which the transaction was created. Read-only attribute. + echo "InputDate (string): " . Util::formatDate($bankTransaction->getInputDate()) . "
"; // string|null + + if ($bankTransaction->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($bankTransaction->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "ModificationDate (\\DateTimeInterface):
" . print_r($bankTransaction->getModificationDate(), true) . "

"; // DateTimeInterface|null The date/time on which the bank transaction was modified the last time. Read-only attribute. + echo "ModificationDate (string): " . Util::formatDate($bankTransaction->getModificationDate()) . "
"; // string|null + echo "Number: {$bankTransaction->getNumber()}
"; // int|null Transaction number. When creating a new bank transaction, don't include this tag as the transaction number is determined by the system. When updating a bank transaction, the related transaction number should be provided. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($bankTransaction->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): " . Util::objectToStr($bankTransaction->getOffice()) . "
"; // string|null + echo "Origin: {$bankTransaction->getOrigin()}
"; // string|null The bank transaction origin. Read-only attribute. + echo "Period: {$bankTransaction->getPeriod()}
"; // string|null Period in YYYY/PP format. If this tag is not included or if it is left empty, the period is determined by the system based on the provided transaction date. + echo "RaiseWarning (bool): {$bankTransaction->getRaiseWarning()}
"; // bool|null Should warnings be given true or not false? Default true. + echo "RaiseWarning (string): " . Util::formatBoolean($bankTransaction->getRaiseWarning()) . "
"; // string|null + echo "Result: {$bankTransaction->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "StartValue (\\Money\\Money):
" . print_r($bankTransaction->getStartValue(), true) . "

"; // Money|null Opening balance. If not provided, the opening balance is set to zero. + echo "StartValue (string): " . Util::formatMoney($bankTransaction->getStartValue()) . "
"; // string|null + echo "StatementNumber: {$bankTransaction->getStatementNumber()}
"; // int|null Number of the bank statement. Don't confuse this number with the transaction number. + + $bankTransactionLines = $bankTransaction->getLines(); // array|null Array of BankTransactionLine objects. + + foreach ($bankTransactionLines as $key => $bankTransactionLine) { + echo "BankTransactionLine {$key}
"; + + echo "BaseValue (\\Money\\Money):
" . print_r($bankTransactionLine->getBaseValue(), true) . "

"; // Money|null Amount in the base currency. + echo "BaseValue (string): " . Util::formatMoney($bankTransactionLine->getBaseValue()) . "
"; // string|null + echo "BaseValueOpen (\\Money\\Money):
" . print_r($bankTransactionLine->getBaseValueOpen(), true) . "

"; // Money|null Only if line type is detail. The amount still owed in base currency. Read-only attribute. + echo "BaseValueOpen (string): " . Util::formatMoney($bankTransactionLine->getBaseValueOpen()) . "
"; // string|null + echo "Comment: {$bankTransactionLine->getComment()}
"; // string|null Comment set on the transaction line. + echo "CurrencyDate (\\DateTimeInterface):
" . print_r($bankTransactionLine->getCurrencyDate(), true) . "

"; // DateTimeInterface|null Only if line type is detail. The line date. Only allowed if the line date in the bank book is set to Allowed or Mandatory. + echo "CurrencyDate (string): " . Util::formatDate($bankTransactionLine->getCurrencyDate()) . "
"; // string|null + echo "DebitCredit: {$bankTransactionLine->getDebitCredit()}
"; // DebitCredit|null If line type = total, based on the sum of the individual bank transaction lines. In case of a bank addition debit. In case of a bank withdrawal credit. If line type = detail, credit in case money is received and debit in case money is paid. If line type = vat, based on the sum of the vat amounts of the individual bank transaction lins. In case of a bank addition credit. In case of a bank withdrawal debit. + echo "Description: {$bankTransactionLine->getDescription()}
"; // string|null Description of the transaction line. + echo "DestOffice (\\PhpTwinfield\\Office):
" . print_r($bankTransactionLine->getDestOffice(), true) . "

"; // Office|null Office code. Used for inter company transactions – here you define in which company the transaction line should be posted. + echo "DestOffice (string): " . Util::objectToStr($bankTransactionLine->getDestOffice()) . "
"; // string|null + echo "Dim1:
" . print_r($bankTransactionLine->getDim1(), true) . "

"; // object|null If line type = total the bank balance account. If line type = detail the customer or supplier balance account or profit and loss account. + echo "Dim1 (string): " . Util::objectToStr($bankTransactionLine->getDim1()) . "
"; // string|null If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account will be taken as entered at the VAT code in Twinfield. + echo "Dim2:
" . print_r($bankTransactionLine->getDim2(), true) . "

"; // object|null If line type = total empty. If line type = detail the customer or supplier or the cost center or empty. + echo "Dim2 (string): " . Util::objectToStr($bankTransactionLine->getDim2()) . "
"; // string|null If line type = vat empty. + echo "Dim3:
" . print_r($bankTransactionLine->getDim2(), true) . "

"; // object|null If line type = total empty. If line type = detail the project or asset or empty. + echo "Dim3 (string): " . Util::objectToStr($bankTransactionLine->getDim3()) . "
"; // string|null If line type = vat empty. + echo "FreeChar: {$bankTransactionLine->getFreeChar()}
"; // string|null Free character field. + echo "ID: {$bankTransactionLine->getID()}
"; // int|null Line ID. + echo "LineType: {$bankTransactionLine->getLineType()}
"; // LineType|null Line type. + echo "MatchLevel: {$bankTransactionLine->getMatchLevel()}
"; // int|null Only if line type is detail. The level of the matchable dimension. Read-only attribute. + echo "MatchStatus: {$bankTransactionLine->getMatchStatus()}
"; // MatchStatus|null Payment status of the bank transaction. If line type total or vat always notmatchable. Read-only attribute. + + if ($bankTransactionLine->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($bankTransactionLine->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "PerformanceCountry (\\PhpTwinfield\\Country):
" . print_r($bankTransactionLine->getPerformanceCountry(), true) . "

"; // Country|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The ISO country codes are used. If not added to the request, by default the country code of the customer will be taken. + echo "PerformanceCountry (string): " . Util::objectToStr($bankTransactionLine->getPerformanceCountry()) . "
"; // string|null + echo "PerformanceDate (\\DateTimeInterface):
" . print_r($bankTransactionLine->getPerformanceDate(), true) . "

"; // DateTimeInterface|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code but only if performancetype is services. + echo "PerformanceDate (string): " . Util::formatDate($bankTransactionLine->getPerformanceDate()) . "
"; // string|null + echo "PerformanceType: {$bankTransactionLine->getPerformanceType()}
"; // PerformanceType|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The performance type. + echo "PerformanceVatNumber: {$bankTransactionLine->getPerformanceVatNumber()}
"; // string|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. If not added to the request, by default the VAT number of the customer will be taken. + echo "Rate: {$bankTransactionLine->getRate()}
"; // float|null The exchange rate used for the calculation of the base amount. + echo "Reference (\\PhpTwinfield\\MatchReference):
" . print_r($bankTransactionLine->getReference(), true) . "

"; // MatchReference|null Match reference + echo "Relation: {$bankTransactionLine->getRelation()}
"; // int|null Only if line type is detail. Read-only attribute. + echo "RepRate: {$bankTransactionLine->getRepRate()}
"; // float|null The exchange rate used for the calculation of the reporting amount. + echo "RepValue (\\Money\\Money):
" . print_r($bankTransactionLine->getRepValue(), true) . "

"; // Money|null Amount in the reporting currency. + echo "RepValue (string): " . Util::formatMoney($bankTransactionLine->getRepValue()) . "
"; // string|null + echo "RepValueOpen (\\Money\\Money):
" . print_r($bankTransactionLine->getRepValueOpen(), true) . "

"; // Money|null Only if line type is detail. The amount still owed in reporting currency. Read-only attribute. + echo "RepValueOpen (string): " . Util::formatMoney($bankTransactionLine->getRepValueOpen()) . "
"; // string|null + echo "Result: {$bankTransactionLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "SignedValue (\\Money\\Money):
" . print_r($bankTransactionLine->getSignedValue(), true) . "

"; // Money|null + echo "SignedValue (string): " . Util::formatMoney($bankTransactionLine->getSignedValue()) . "
"; // string|null + echo "Value (\\Money\\Money):
" . print_r($bankTransactionLine->getValue(), true) . "

"; // Money|null If line type = total amount including VAT. If line type = detail amount without VAT. If line type = vat VAT amount. + echo "Value (string): " . Util::formatMoney($bankTransactionLine->getValue()) . "
"; // string|null + echo "VatBaseTotal (\\Money\\Money):
" . print_r($bankTransactionLine->getVatBaseTotal(), true) . "

"; // Money|null Only if line type is total. The total VAT amount in base currency. + echo "VatBaseTotal (string): " . Util::formatMoney($bankTransactionLine->getVatBaseTotal()) . "
"; // string|null + echo "VatBaseTurnover (\\Money\\Money):
" . print_r($bankTransactionLine->getVatBaseTurnover(), true) . "

"; // Money|null Only if line type is vat. Amount on which VAT was calculated in base currency. + echo "VatBaseTurnover (string): " . Util::formatMoney($bankTransactionLine->getVatBaseTurnover()) . "
"; // string|null + echo "VatBaseValue (\\Money\\Money):
" . print_r($bankTransactionLine->getVatBaseValue(), true) . "

"; // Money|null Only if line type is detail. VAT amount in base currency. + echo "VatBaseValue (string): " . Util::formatMoney($bankTransactionLine->getVatBaseValue()) . "
"; // string|null + echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($bankTransactionLine->getVatCode(), true) . "

"; // VatCode|null Only if line type is detail or vat. VAT code. + echo "VatCode (string): " . Util::objectToStr($bankTransactionLine->getVatCode()) . "
"; // string|null + echo "VatRepTotal (\\Money\\Money):
" . print_r($bankTransactionLine->getVatRepTotal(), true) . "

"; // Money|null Only if line type is detail. VAT amount in reporting currency. + echo "VatRepTotal (string): " . Util::formatMoney($bankTransactionLine->getVatRepTotal()) . "
"; // string|null + echo "VatRepTurnover (\\Money\\Money):
" . print_r($bankTransactionLine->getVatRepTurnover(), true) . "

"; // Money|null Only if line type is vat. Amount on which VAT was calculated in reporting currency. + echo "VatRepTurnover (string): " . Util::formatMoney($bankTransactionLine->getVatRepTurnover()) . "
"; // string|null + echo "VatRepValue (\\Money\\Money):
" . print_r($bankTransactionLine->getVatRepValue(), true) . "

"; // Money|null Only if line type is detail. VAT amount in reporting currency. + echo "VatRepValue (string): " . Util::formatMoney($bankTransactionLine->getVatRepValue()) . "
"; // string|null + echo "VatTotal (\\Money\\Money):
" . print_r($bankTransactionLine->getVatTotal(), true) . "

"; // Money|null Only if line type is total. The total VAT amount in the currency of the bank transaction. + echo "VatTotal (string): " . Util::formatMoney($bankTransactionLine->getVatTotal()) . "
"; // string|null + echo "VatTurnover (\\Money\\Money):
" . print_r($bankTransactionLine->getVatTurnover(), true) . "

"; // Money|null Only if line type is vat. Amount on which VAT was calculated in the currency of the bank transaction. + echo "VatTurnover (string): " . Util::formatMoney($bankTransactionLine->getVatTurnover()) . "
"; // string|null + echo "VatValue (\\Money\\Money):
" . print_r($bankTransactionLine->getVatValue(), true) . "

"; // Money|null Only if line type is detail. VAT amount in the currency of the bank transaction. + echo "VatValue (string): " . Util::formatMoney($bankTransactionLine->getVatValue()) . "
"; // string|null + } +} + +// Copy an existing BankTransaction to a new entity +if ($executeCopy) { + try { + $bankTransaction = $transactionApiConnector->get(\PhpTwinfield\BankTransaction::class, "BNK", 201900011, $office); + } catch (ResponseException $e) { + $bankTransaction = $e->getReturnedObject(); + } + + $bankTransaction->setNumber(null); + + //Optional, but recommended so your copy is not posted to final immediately + $bankTransaction->setDestiny(\PhpTwinfield\Enums\Destiny::TEMPORARY()); + + try { + $bankTransactionCopy = $transactionApiConnector->send($bankTransaction); + } catch (ResponseException $e) { + $bankTransactionCopy = $e->getReturnedObject(); + } + + echo "
";
+    print_r($bankTransactionCopy);
+    echo "
"; + + echo "Result of copy process: {$bankTransactionCopy->getResult()}
"; + echo "Number of copied BankTransaction: {$bankTransactionCopy->getNumber()}
"; +} + +// Create a new BankTransaction from scratch, alternatively read an existing BankTransaction as shown above and than modify the values in the same way as shown below +if ($executeNew) { + $bankTransaction = new \PhpTwinfield\BankTransaction; + + // Required values for creating a new BankTransaction + $bankTransaction->setCode('BNK'); // string|null Transaction type code. + $currency = new \PhpTwinfield\Currency; + $currency->setCode('EUR'); + $bankTransaction->setCurrency($currency); // Currency|null Currency code. + //$bankTransaction->setCurrency(\PhpTwinfield\Currency::fromCode("EUR")); // string|null + $bankTransaction->setDestiny(\PhpTwinfield\Enums\Destiny::TEMPORARY()); // Destiny|null Attribute to indicate the destiny of the bank transaction. Only used in the request XML. temporary = bank transaction will be saved as provisional. + //$bankTransaction->setDestiny(\PhpTwinfield\Enums\Destiny::FINAL()); // Destiny|null final = bank transaction will be saved as final. + $bankTransaction->setOffice($office); // Office|null Office code. + $bankTransaction->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null + + // Optional values for creating a new BankTransaction + $bankTransaction->setAutoBalanceVat(true); // bool|null Should VAT be rounded true or not false? Rounding will only be done with a maximum of two cents. + $date = \DateTime::createFromFormat('d-m-Y', '01-09-2019'); + $bankTransaction->setDate($date); // DateTimeInterface|null Transaction date. Optionally, it is possible to suppress warnings about 'date out of range for the given period' by adding the raisewarning attribute and set its value to false. + $bankTransaction->setDate(Util::parseDate("20190901")); // string|null This overwrites the value of the raisewarning attribute as set on the root element. + $bankTransaction->setDateRaiseWarning(false); // bool|null + //$bankTransaction->setFreeText1('Example FreeText 1'); // string|null Free text field 1 as entered on the transaction type. + //$bankTransaction->setFreeText2('Example FreeText 2'); // string|null Free text field 2 as entered on the transaction type. + //$bankTransaction->setFreeText3('Example FreeText 3'); // string|null Free text field 3 as entered on the transaction type. + //$bankTransaction->setNumber(201900011); // int|null Transaction number. When creating a new bank transaction, don't include this tag as the transaction number is determined by the system. When updating a bank transaction, the related transaction number should be provided. + //$bankTransaction->setPeriod("2019/07"); // string|null Period in YYYY/PP format. If this tag is not included or if it is left empty, the period is determined by the system based on the provided transaction date. + $bankTransaction->setRaiseWarning(true); // bool|null Should warnings be given true or not false? Default true. + //$bankTransactionLine->setStartValue(\Money\Money::EUR(1000)); // Money|null Opening balance. If not provided, the opening balance is set to zero. (Equals 10.00 EUR) + $bankTransaction->setStatementNumber(20); // int|null Number of the bank statement. Don't confuse this number with the transaction number. + + // The minimum amount of BankTransactionLines linked to an BankTransaction object is 2 (1 total, 1 detail) + $bankTransactionLine1 = new \PhpTwinfield\BankTransactionLine; + $bankTransactionLine1->setLineType(\PhpTwinfield\Enums\LineType::TOTAL()); // LineType|null Line type. + + $dim1 = new \PhpTwinfield\GeneralLedger; + $dim1->setCode('1010'); + $bankTransactionLine1->setDim1($dim1); // object|null If line type = total the bank balance account. If line type = detail the customer or supplier balance account or profit and loss account. + $bankTransactionLine1->setDim1(\PhpTwinfield\GeneralLedger::fromCode('1010')); // string|null If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account will be taken as entered at the VAT code in Twinfield. + $bankTransactionLine1->setID(1); // int|null Line ID. + $bankTransactionLine1->setValue(\Money\Money::EUR(-10000)); // Money|null If line type = total amount including VAT. If line type = detail amount without VAT. If line type = vat VAT amount. + //$bankTransactionLine1->setVatBaseTotal(\Money\Money::EUR(-10000)); // Money|null Only if line type is total. The total VAT amount in base currency. + //$bankTransactionLine1->setVatRepTotal(\Money\Money::EUR(-10000)); // Money|null Only if line type is total. The total VAT amount in reporting currency. + //$bankTransactionLine1->setVatTotal(\Money\Money::EUR(-10000)); // Money|null Only if line type is total. The total VAT amount in the currency of the bank transaction. + + $bankTransaction->addLine($bankTransactionLine1); // BankTransactionLine Add a BankTransactionLine object to the BankTransaction object + + $bankTransactionLine2 = new \PhpTwinfield\BankTransactionLine; + $bankTransactionLine2->setLineType(\PhpTwinfield\Enums\LineType::DETAIL()); // LineType|null Line type. + + $bankTransactionLine2->setBaseValue(\Money\Money::EUR(10000)); // Money|null Amount in the base currency. + $bankTransactionLine2->setDescription("Example Description on line with ID 2"); // string|null Description of the transaction line. + $dim1 = new \PhpTwinfield\GeneralLedger; + $dim1->setCode('2500'); + $bankTransactionLine2->setDim1($dim1); // object|null If line type = total the bank balance account. If line type = detail the customer or supplier balance account or profit and loss account. + $bankTransactionLine2->setDim1(\PhpTwinfield\GeneralLedger::fromCode('2500')); // string|null If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account will be taken as entered at the VAT code in Twinfield. + $bankTransactionLine2->setID(2); // int|null Line ID. + $bankTransactionLine2->setValue(\Money\Money::EUR(-10000)); // Money|null If line type = total amount including VAT. If line type = detail amount without VAT. If line type = vat VAT amount. + + //$bankTransactionLine2->setComment('Example Comments'); // string|null Comment set on the transaction line. + $currencyDate = \DateTime::createFromFormat('d-m-Y', '01-09-2019'); + //$bankTransaction->setCurrencyDate($currencyDate); // DateTimeInterface|null Only if line type is detail. The line date. Only allowed if the line date in the bank book is set to Allowed or Mandatory. + //$bankTransaction->setCurrencyDate(Util::parseDate("20190901")); // string|null + $destOffice = new \PhpTwinfield\Office; + $destOffice->setCode('1234'); + //$bankTransaction->setDestOffice($destOffice); // Office|null Office code. Used for inter company transactions – here you define in which company the transaction line should be posted. + //$bankTransaction->setDestOffice(\PhpTwinfield\Office::fromCode('1234')); // string|null + $dim2 = new \PhpTwinfield\Customer; + $dim2->setCode('1001'); + //$bankTransactionLine2->setDim2($dim2); // object|null If line type = total empty. If line type = detail the customer or supplier or the cost center or empty. If line type = vat empty. + //$bankTransactionLine2->setDim2(\PhpTwinfield\Customer::fromCode('1001')); // string|null + $dim3 = new \PhpTwinfield\Project; + $dim3->setCode('P0000'); + //$bankTransactionLine2->setDim3($dim3); // object|null If line type = total empty. If line type = detail the project or asset or empty. If line type = vat empty. + //$bankTransactionLine2->setDim3(\PhpTwinfield\Project::fromCode('P0000')); // string|null + //$bankTransactionLine2->setFreeChar('A'); // string|null Free character field. + $performanceCountry = new \PhpTwinfield\Country; + $performanceCountry->setCode('NL'); + //$bankTransactionLine2->setPerformanceCountry($performanceCountry); // Country|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The ISO country codes are used. If not added to the request, by default the country code of the customer will be taken. + //$bankTransactionLine2->setPerformanceCountry(\PhpTwinfield\Country::fromCode('NL')); // string|null + $performanceDate = \DateTime::createFromFormat('d-m-Y', '01-09-2019'); + //$bankTransactionLine2->setPerformanceDate($performanceDate); // DateTimeInterface|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code but only if performancetype is services. + //$bankTransactionLine2->setPerformanceDate(Util::parseDate("20190901")); // string|null + //$bankTransactionLine2->setPerformanceType(\PhpTwinfield\Enums\PerformanceType::SERVICES()); // PerformanceType|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The performance type. + //$bankTransactionLine2->setPerformanceVatNumber('NL1234567890B01'); // string|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. If not added to the request, by default the VAT number of the customer will be taken. + //$bankTransactionLine2->setRepValue(\Money\Money::EUR(-10000)); // Money|null Amount in the reporting currency. + //$bankTransactionLine2->setRate(1); // float|null The exchange rate used for the calculation of the base amount. + //$bankTransactionLine2->setRepRate(1); // float|null The exchange rate used for the calculation of the reporting amount. + //$bankTransactionLine2->setVatBaseValue(\Money\Money::EUR(-10000)); // Money|null Only if line type is detail. VAT amount in base currency. + $vatCode = new \PhpTwinfield\VatCode; + $vatCode->setCode('VN'); + //$bankTransactionLine2->setVatCode($vatCode); // VatCode|null Only if line type is detail or vat. VAT code. + //$bankTransactionLine2->setVatCode(\PhpTwinfield\VatCode::fromCode('VN')); // string|null + //$bankTransactionLine2->setVatRepValue(\Money\Money::EUR(-10000)); // Money|null Only if line type is detail. VAT amount in reporting currency. + //$bankTransactionLine2->setVatValue(\Money\Money::EUR(-10000)); // Money|null Only if line type is detail. VAT amount in the currency of the bank transaction. + + $bankTransaction->addLine($bankTransactionLine2); + + //$bankTransactionLine3 = new \PhpTwinfield\BankTransactionLine; + //$bankTransactionLine3->setLineType(\PhpTwinfield\Enums\LineType::VAT()); // LineType|null Line type. + //$bankTransactionLine3->setVatBaseTurnover(\Money\Money::EUR(-10000)); // Money|null Only if line type is vat. Amount on which VAT was calculated in base currency. + //$bankTransactionLine3->setVatRepTurnover(\Money\Money::EUR(-10000)); // Money|null Only if line type is vat. Amount on which VAT was calculated in reporting currency. + //$bankTransactionLine3->setVatTurnover(\Money\Money::EUR(-10000)); // Money|null Only if line type is vat. Amount on which VAT was calculated in the currency of the bank transaction. + + try { + $bankTransactionNew = $transactionApiConnector->send($bankTransaction); + } catch (ResponseException $e) { + $bankTransactionNew = $e->getReturnedObject(); + } + + echo "
";
+    print_r($bankTransactionNew);
+    echo "
"; + + echo "Result of creation process: {$bankTransactionNew->getResult()}
"; + echo "Number of new BankTransaction: {$bankTransactionNew->getNumber()}
"; +} + +// Delete a BrankTransaction based off the passed in office, code, number and given reason +if ($executeDelete) { + $bookingReference = new \PhpTwinfield\BookingReference($office, 'BNK', 201900026); + + try { + $bankTransactionDeleted = $transactionApiConnector->delete($bookingReference, 'Example reason'); + } catch (ResponseException $e) { + $bankTransactionDeleted = $e->getReturnedObject(); + } + + echo "
";
+    print_r($bankTransactionDeleted);
+    echo "
"; +} diff --git a/examples/BrowseData.php b/examples/BrowseData.php index a2d31964..c33fe90d 100644 --- a/examples/BrowseData.php +++ b/examples/BrowseData.php @@ -1,5 +1,4 @@ get(\PhpTwinfield\CashTransaction::class, "KAS", 201900011, $office); + } catch (ResponseException $e) { + $cashTransaction = $e->getReturnedObject(); + } + + echo "
";
+    print_r($cashTransaction);
+    echo "
"; + + echo "CashTransaction
"; + echo "AutoBalanceVat (bool): {$cashTransaction->getAutoBalanceVat()}
"; // bool|null Should VAT be rounded true or not false? Rounding will only be done with a maximum of two cents. + echo "AutoBalanceVat (string): " . Util::formatBoolean($cashTransaction->getAutoBalanceVat()) . "
"; // string|null + echo "BookingReference (\\PhpTwinfield\\BookingReference):
" . print_r($cashTransaction->getBookingReference(), true) . "

"; // BookingReference|null The Booking reference + echo "CloseValue (\\Money\\Money):
" . print_r($cashTransaction->getCloseValue(), true) . "

"; // Money|null Closing balance. If not provided, the closing balance is set to zero. + echo "CloseValue (string): " . Util::formatMoney($cashTransaction->getCloseValue()) . "
"; // string|null + echo "Code: {$cashTransaction->getCode()}
"; // string|null Transaction type code. + echo "Currency (\\PhpTwinfield\\Currency):
" . print_r($cashTransaction->getCurrency(), true) . "

"; // Currency|null Currency code. + echo "Currency (string): " . Util::objectToStr($cashTransaction->getCurrency()) . "
"; // string|null + echo "Date (\\DateTimeInterface):
" . print_r($cashTransaction->getDate(), true) . "

"; // DateTimeInterface|null Transaction date. + echo "Date (string): " . Util::formatDate($cashTransaction->getDate()) . "
"; // string|null + echo "DateRaiseWarning (bool): {$cashTransaction->getDateRaiseWarning()}
"; // bool|null Optionally, it is possible to suppress warnings about 'date out of range for the given period' by adding the raisewarning attribute and set its value to false. + echo "DateRaiseWarning (string): {$cashTransaction->getDateRaiseWarningToString()}
"; // string|null This overwrites the value of the raisewarning attribute as set on the root element. + echo "Destiny: {$cashTransaction->getDestiny()}
"; // Destiny|null Attribute to indicate the destiny of the cash transaction. Only used in the request XML. temporary = cash transaction will be saved as provisional. final = cash transaction will be saved as final. + echo "FreeText1: {$cashTransaction->getFreeText1()}
"; // string|null Free text field 1 as entered on the transaction type. + echo "FreeText2: {$cashTransaction->getFreeText2()}
"; // string|null Free text field 2 as entered on the transaction type. + echo "FreeText3: {$cashTransaction->getFreeText3()}
"; // string|null Free text field 3 as entered on the transaction type. + echo "InputDate (\\DateTimeInterface):
" . print_r($cashTransaction->getInputDate(), true) . "

"; // DateTimeInterface|null The date/time on which the transaction was created. Read-only attribute. + echo "InputDate (string): " . Util::formatDate($cashTransaction->getInputDate()) . "
"; // string|null + + if ($cashTransaction->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($cashTransaction->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "ModificationDate (\\DateTimeInterface):
" . print_r($cashTransaction->getModificationDate(), true) . "

"; // DateTimeInterface|null The date/time on which the cash transaction was modified the last time. Read-only attribute. + echo "ModificationDate (string): " . Util::formatDate($cashTransaction->getModificationDate()) . "
"; // string|null + echo "Number: {$cashTransaction->getNumber()}
"; // int|null Transaction number. When creating a new cash transaction, don't include this tag as the transaction number is determined by the system. When updating a cash transaction, the related transaction number should be provided. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($cashTransaction->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): " . Util::objectToStr($cashTransaction->getOffice()) . "
"; // string|null + echo "Origin: {$cashTransaction->getOrigin()}
"; // string|null The cash transaction origin. Read-only attribute. + echo "Period: {$cashTransaction->getPeriod()}
"; // string|null Period in YYYY/PP format. If this tag is not included or if it is left empty, the period is determined by the system based on the provided transaction date. + echo "RaiseWarning (bool): {$cashTransaction->getRaiseWarning()}
"; // bool|null Should warnings be given true or not false? Default true. + echo "RaiseWarning (string): " . Util::formatBoolean($cashTransaction->getRaiseWarning()) . "
"; // string|null + echo "Result: {$cashTransaction->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "StartValue (\\Money\\Money):
" . print_r($cashTransaction->getStartValue(), true) . "

"; // Money|null Opening balance. If not provided, the opening balance is set to zero. + echo "StartValue (string): " . Util::formatMoney($cashTransaction->getStartValue()) . "
"; // string|null + echo "StatementNumber: {$cashTransaction->getStatementNumber()}
"; // int|null Number of the cash statement. Don't confuse this number with the transaction number. + + $cashTransactionLines = $cashTransaction->getLines(); // array|null Array of CashTransactionLine objects. + + foreach ($cashTransactionLines as $key => $cashTransactionLine) { + echo "CashTransactionLine {$key}
"; + + echo "BaseValue (\\Money\\Money):
" . print_r($cashTransactionLine->getBaseValue(), true) . "

"; // Money|null Amount in the base currency. + echo "BaseValue (string): " . Util::formatMoney($cashTransactionLine->getBaseValue()) . "
"; // string|null + echo "BaseValueOpen (\\Money\\Money):
" . print_r($cashTransactionLine->getBaseValueOpen(), true) . "

"; // Money|null Only if line type is detail. The amount still owed in base currency. Read-only attribute. + echo "BaseValueOpen (string): " . Util::formatMoney($cashTransactionLine->getBaseValueOpen()) . "
"; // string|null + echo "Comment: {$cashTransactionLine->getComment()}
"; // string|null Comment set on the transaction line. + echo "CurrencyDate (\\DateTimeInterface):
" . print_r($cashTransactionLine->getCurrencyDate(), true) . "

"; // DateTimeInterface|null Only if line type is detail. The line date. Only allowed if the line date in the cash book is set to Allowed or Mandatory. + echo "CurrencyDate (string): " . Util::formatDate($cashTransactionLine->getCurrencyDate()) . "
"; // string|null + echo "DebitCredit: {$cashTransactionLine->getDebitCredit()}
"; // DebitCredit|null If line type = total, based on the sum of the individual cash transaction lines. In case of a cash addition debit. In case of a cash withdrawal credit. If line type = detail, credit in case money is received and debit in case money is paid. If line type = vat, based on the sum of the vat amounts of the individual cash transaction lins. In case of a cash addition credit. In case of a cash withdrawal debit. + echo "Description: {$cashTransactionLine->getDescription()}
"; // string|null Description of the transaction line. + echo "DestOffice (\\PhpTwinfield\\Office):
" . print_r($cashTransactionLine->getDestOffice(), true) . "

"; // Office|null Office code. Used for inter company transactions – here you define in which company the transaction line should be posted. + echo "DestOffice (string): " . Util::objectToStr($cashTransactionLine->getDestOffice()) . "
"; // string|null + echo "Dim1:
" . print_r($cashTransactionLine->getDim1(), true) . "

"; // object|null If line type = total the cash balance account. If line type = detail the customer or supplier balance account or profit and loss account. + echo "Dim1 (string): " . Util::objectToStr($cashTransactionLine->getDim1()) . "
"; // string|null If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account will be taken as entered at the VAT code in Twinfield. + echo "Dim2:
" . print_r($cashTransactionLine->getDim2(), true) . "

"; // object|null If line type = total empty. If line type = detail the customer or supplier or the cost center or empty. + echo "Dim2 (string): " . Util::objectToStr($cashTransactionLine->getDim2()) . "
"; // string|null If line type = vat empty. + echo "Dim3:
" . print_r($cashTransactionLine->getDim2(), true) . "

"; // object|null If line type = total empty. If line type = detail the project or asset or empty. + echo "Dim3 (string): " . Util::objectToStr($cashTransactionLine->getDim3()) . "
"; // string|null If line type = vat empty. + echo "FreeChar: {$cashTransactionLine->getFreeChar()}
"; // string|null Free character field. + echo "ID: {$cashTransactionLine->getID()}
"; // int|null Line ID. + echo "LineType: {$cashTransactionLine->getLineType()}
"; // LineType|null Line type. + echo "MatchLevel: {$cashTransactionLine->getMatchLevel()}
"; // int|null Only if line type is detail. The level of the matchable dimension. Read-only attribute. + echo "MatchStatus: {$cashTransactionLine->getMatchStatus()}
"; // MatchStatus|null Payment status of the cash transaction. If line type total or vat always notmatchable. Read-only attribute. + + if ($cashTransactionLine->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($cashTransactionLine->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "PerformanceCountry (\\PhpTwinfield\\Country):
" . print_r($cashTransactionLine->getPerformanceCountry(), true) . "

"; // Country|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The ISO country codes are used. If not added to the request, by default the country code of the customer will be taken. + echo "PerformanceCountry (string): " . Util::objectToStr($cashTransactionLine->getPerformanceCountry()) . "
"; // string|null + echo "PerformanceDate (\\DateTimeInterface):
" . print_r($cashTransactionLine->getPerformanceDate(), true) . "

"; // DateTimeInterface|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code but only if performancetype is services. + echo "PerformanceDate (string): " . Util::formatDate($cashTransactionLine->getPerformanceDate()) . "
"; // string|null + echo "PerformanceType: {$cashTransactionLine->getPerformanceType()}
"; // PerformanceType|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The performance type. + echo "PerformanceVatNumber: {$cashTransactionLine->getPerformanceVatNumber()}
"; // string|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. If not added to the request, by default the VAT number of the customer will be taken. + echo "Rate: {$cashTransactionLine->getRate()}
"; // float|null The exchange rate used for the calculation of the base amount. + echo "Reference (\\PhpTwinfield\\MatchReference):
" . print_r($cashTransactionLine->getReference(), true) . "

"; // MatchReference|null Match reference + echo "Relation: {$cashTransactionLine->getRelation()}
"; // int|null Only if line type is detail. Read-only attribute. + echo "RepRate: {$cashTransactionLine->getRepRate()}
"; // float|null The exchange rate used for the calculation of the reporting amount. + echo "RepValue (\\Money\\Money):
" . print_r($cashTransactionLine->getRepValue(), true) . "

"; // Money|null Amount in the reporting currency. + echo "RepValue (string): " . Util::formatMoney($cashTransactionLine->getRepValue()) . "
"; // string|null + echo "RepValueOpen (\\Money\\Money):
" . print_r($cashTransactionLine->getRepValueOpen(), true) . "

"; // Money|null Only if line type is detail. The amount still owed in reporting currency. Read-only attribute. + echo "RepValueOpen (string): " . Util::formatMoney($cashTransactionLine->getRepValueOpen()) . "
"; // string|null + echo "Result: {$cashTransactionLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "SignedValue (\\Money\\Money):
" . print_r($cashTransactionLine->getSignedValue(), true) . "

"; // Money|null + echo "SignedValue (string): " . Util::formatMoney($cashTransactionLine->getSignedValue()) . "
"; // string|null + echo "Value (\\Money\\Money):
" . print_r($cashTransactionLine->getValue(), true) . "

"; // Money|null If line type = total amount including VAT. If line type = detail amount without VAT. If line type = vat VAT amount. + echo "Value (string): " . Util::formatMoney($cashTransactionLine->getValue()) . "
"; // string|null + echo "VatBaseTotal (\\Money\\Money):
" . print_r($cashTransactionLine->getVatBaseTotal(), true) . "

"; // Money|null Only if line type is total. The total VAT amount in base currency. + echo "VatBaseTotal (string): " . Util::formatMoney($cashTransactionLine->getVatBaseTotal()) . "
"; // string|null + echo "VatBaseTurnover (\\Money\\Money):
" . print_r($cashTransactionLine->getVatBaseTurnover(), true) . "

"; // Money|null Only if line type is vat. Amount on which VAT was calculated in base currency. + echo "VatBaseTurnover (string): " . Util::formatMoney($cashTransactionLine->getVatBaseTurnover()) . "
"; // string|null + echo "VatBaseValue (\\Money\\Money):
" . print_r($cashTransactionLine->getVatBaseValue(), true) . "

"; // Money|null Only if line type is detail. VAT amount in base currency. + echo "VatBaseValue (string): " . Util::formatMoney($cashTransactionLine->getVatBaseValue()) . "
"; // string|null + echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($cashTransactionLine->getVatCode(), true) . "

"; // VatCode|null Only if line type is detail or vat. VAT code. + echo "VatCode (string): " . Util::objectToStr($cashTransactionLine->getVatCode()) . "
"; // string|null + echo "VatRepTotal (\\Money\\Money):
" . print_r($cashTransactionLine->getVatRepTotal(), true) . "

"; // Money|null Only if line type is detail. VAT amount in reporting currency. + echo "VatRepTotal (string): " . Util::formatMoney($cashTransactionLine->getVatRepTotal()) . "
"; // string|null + echo "VatRepTurnover (\\Money\\Money):
" . print_r($cashTransactionLine->getVatRepTurnover(), true) . "

"; // Money|null Only if line type is vat. Amount on which VAT was calculated in reporting currency. + echo "VatRepTurnover (string): " . Util::formatMoney($cashTransactionLine->getVatRepTurnover()) . "
"; // string|null + echo "VatRepValue (\\Money\\Money):
" . print_r($cashTransactionLine->getVatRepValue(), true) . "

"; // Money|null Only if line type is detail. VAT amount in reporting currency. + echo "VatRepValue (string): " . Util::formatMoney($cashTransactionLine->getVatRepValue()) . "
"; // string|null + echo "VatTotal (\\Money\\Money):
" . print_r($cashTransactionLine->getVatTotal(), true) . "

"; // Money|null Only if line type is total. The total VAT amount in the currency of the cash transaction. + echo "VatTotal (string): " . Util::formatMoney($cashTransactionLine->getVatTotal()) . "
"; // string|null + echo "VatTurnover (\\Money\\Money):
" . print_r($cashTransactionLine->getVatTurnover(), true) . "

"; // Money|null Only if line type is vat. Amount on which VAT was calculated in the currency of the cash transaction. + echo "VatTurnover (string): " . Util::formatMoney($cashTransactionLine->getVatTurnover()) . "
"; // string|null + echo "VatValue (\\Money\\Money):
" . print_r($cashTransactionLine->getVatValue(), true) . "

"; // Money|null Only if line type is detail. VAT amount in the currency of the cash transaction. + echo "VatValue (string): " . Util::formatMoney($cashTransactionLine->getVatValue()) . "
"; // string|null + } +} + +// Copy an existing CashTransaction to a new entity +if ($executeCopy) { + try { + $cashTransaction = $transactionApiConnector->get(\PhpTwinfield\CashTransaction::class, "KAS", 201900011, $office); + } catch (ResponseException $e) { + $cashTransaction = $e->getReturnedObject(); + } + + $cashTransaction->setNumber(null); + + //Optional, but recommended so your copy is not posted to final immediately + $cashTransaction->setDestiny(\PhpTwinfield\Enums\Destiny::TEMPORARY()); + + try { + $cashTransactionCopy = $transactionApiConnector->send($cashTransaction); + } catch (ResponseException $e) { + $cashTransactionCopy = $e->getReturnedObject(); + } + + echo "
";
+    print_r($cashTransactionCopy);
+    echo "
"; + + echo "Result of copy process: {$cashTransactionCopy->getResult()}
"; + echo "Number of copied CashTransaction: {$cashTransactionCopy->getNumber()}
"; +} + +// Create a new CashTransaction from scratch, alternatively read an existing CashTransaction as shown above and than modify the values in the same way as shown below +if ($executeNew) { + $cashTransaction = new \PhpTwinfield\CashTransaction; + + // Required values for creating a new CashTransaction + $cashTransaction->setCode('KAS'); // string|null Transaction type code. + $currency = new \PhpTwinfield\Currency; + $currency->setCode('EUR'); + $cashTransaction->setCurrency($currency); // Currency|null Currency code. + //$cashTransaction->setCurrency(\PhpTwinfield\Currency::fromCode("EUR")); // string|null + $cashTransaction->setDestiny(\PhpTwinfield\Enums\Destiny::TEMPORARY()); // Destiny|null Attribute to indicate the destiny of the cash transaction. Only used in the request XML. temporary = cash transaction will be saved as provisional. + //$cashTransaction->setDestiny(\PhpTwinfield\Enums\Destiny::FINAL()); // Destiny|null final = cash transaction will be saved as final. + $cashTransaction->setOffice($office); // Office|null Office code. + $cashTransaction->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null + + // Optional values for creating a new CashTransaction + $cashTransaction->setAutoBalanceVat(true); // bool|null Should VAT be rounded true or not false? Rounding will only be done with a maximum of two cents. + $date = \DateTime::createFromFormat('d-m-Y', '01-09-2019'); + $cashTransaction->setDate($date); // DateTimeInterface|null Transaction date. Optionally, it is possible to suppress warnings about 'date out of range for the given period' by adding the raisewarning attribute and set its value to false. + $cashTransaction->setDate(Util::parseDate("20190901")); // string|null This overwrites the value of the raisewarning attribute as set on the root element. + $cashTransaction->setDateRaiseWarning(false); // bool|null + //$cashTransaction->setFreeText1('Example FreeText 1'); // string|null Free text field 1 as entered on the transaction type. + //$cashTransaction->setFreeText2('Example FreeText 2'); // string|null Free text field 2 as entered on the transaction type. + //$cashTransaction->setFreeText3('Example FreeText 3'); // string|null Free text field 3 as entered on the transaction type. + //$cashTransaction->setNumber(201900011); // int|null Transaction number. When creating a new cash transaction, don't include this tag as the transaction number is determined by the system. When updating a cash transaction, the related transaction number should be provided. + //$cashTransaction->setPeriod("2019/07"); // string|null Period in YYYY/PP format. If this tag is not included or if it is left empty, the period is determined by the system based on the provided transaction date. + $cashTransaction->setRaiseWarning(true); // bool|null Should warnings be given true or not false? Default true. + //$cashTransactionLine->setStartValue(\Money\Money::EUR(1000)); // Money|null Opening balance. If not provided, the opening balance is set to zero. (Equals 10.00 EUR) + $cashTransaction->setStatementNumber(20); // int|null Number of the cash statement. Don't confuse this number with the transaction number. + + // The minimum amount of CashTransactionLines linked to an CashTransaction object is 2 (1 total, 1 detail) + $cashTransactionLine1 = new \PhpTwinfield\CashTransactionLine; + $cashTransactionLine1->setLineType(\PhpTwinfield\Enums\LineType::TOTAL()); // LineType|null Line type. + + $dim1 = new \PhpTwinfield\GeneralLedger; + $dim1->setCode('1010'); + $cashTransactionLine1->setDim1($dim1); // object|null If line type = total the cash balance account. If line type = detail the customer or supplier balance account or profit and loss account. + $cashTransactionLine1->setDim1(\PhpTwinfield\GeneralLedger::fromCode('1010')); // string|null If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account will be taken as entered at the VAT code in Twinfield. + $cashTransactionLine1->setID(1); // int|null Line ID. + $cashTransactionLine1->setValue(\Money\Money::EUR(-10000)); // Money|null If line type = total amount including VAT. If line type = detail amount without VAT. If line type = vat VAT amount. + //$cashTransactionLine1->setVatBaseTotal(\Money\Money::EUR(-10000)); // Money|null Only if line type is total. The total VAT amount in base currency. + //$cashTransactionLine1->setVatRepTotal(\Money\Money::EUR(-10000)); // Money|null Only if line type is total. The total VAT amount in reporting currency. + //$cashTransactionLine1->setVatTotal(\Money\Money::EUR(-10000)); // Money|null Only if line type is total. The total VAT amount in the currency of the cash transaction. + + $cashTransaction->addLine($cashTransactionLine1); // CashTransactionLine Add a CashTransactionLine object to the CashTransaction object + + $cashTransactionLine2 = new \PhpTwinfield\CashTransactionLine; + $cashTransactionLine2->setLineType(\PhpTwinfield\Enums\LineType::DETAIL()); // LineType|null Line type. + + $cashTransactionLine2->setBaseValue(\Money\Money::EUR(10000)); // Money|null Amount in the base currency. + $cashTransactionLine2->setDescription("Example Description on line with ID 2"); // string|null Description of the transaction line. + $dim1 = new \PhpTwinfield\GeneralLedger; + $dim1->setCode('2500'); + $cashTransactionLine2->setDim1($dim1); // object|null If line type = total the cash balance account. If line type = detail the customer or supplier balance account or profit and loss account. + $cashTransactionLine2->setDim1(\PhpTwinfield\GeneralLedger::fromCode('2500')); // string|null If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account will be taken as entered at the VAT code in Twinfield. + $cashTransactionLine2->setID(2); // int|null Line ID. + $cashTransactionLine2->setValue(\Money\Money::EUR(-10000)); // Money|null If line type = total amount including VAT. If line type = detail amount without VAT. If line type = vat VAT amount. + + //$cashTransactionLine2->setComment('Example Comments'); // string|null Comment set on the transaction line. + $currencyDate = \DateTime::createFromFormat('d-m-Y', '01-09-2019'); + //$cashTransaction->setCurrencyDate($currencyDate); // DateTimeInterface|null Only if line type is detail. The line date. Only allowed if the line date in the cash book is set to Allowed or Mandatory. + //$cashTransaction->setCurrencyDate(Util::parseDate("20190901")); // string|null + $destOffice = new \PhpTwinfield\Office; + $destOffice->setCode('1234'); + //$cashTransaction->setDestOffice($destOffice); // Office|null Office code. Used for inter company transactions – here you define in which company the transaction line should be posted. + //$cashTransaction->setDestOffice(\PhpTwinfield\Office::fromCode('1234')); // string|null + $dim2 = new \PhpTwinfield\Customer; + $dim2->setCode('1001'); + //$cashTransactionLine2->setDim2($dim2); // object|null If line type = total empty. If line type = detail the customer or supplier or the cost center or empty. If line type = vat empty. + //$cashTransactionLine2->setDim2(\PhpTwinfield\Customer::fromCode('1001')); // string|null + $dim3 = new \PhpTwinfield\Project; + $dim3->setCode('P0000'); + //$cashTransactionLine2->setDim3($dim3); // object|null If line type = total empty. If line type = detail the project or asset or empty. If line type = vat empty. + //$cashTransactionLine2->setDim3(\PhpTwinfield\Project::fromCode('P0000')); // string|null + //$cashTransactionLine2->setFreeChar('A'); // string|null Free character field. + $performanceCountry = new \PhpTwinfield\Country; + $performanceCountry->setCode('NL'); + //$cashTransactionLine2->setPerformanceCountry($performanceCountry); // Country|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The ISO country codes are used. If not added to the request, by default the country code of the customer will be taken. + //$cashTransactionLine2->setPerformanceCountry(\PhpTwinfield\Country::fromCode('NL')); // string|null + $performanceDate = \DateTime::createFromFormat('d-m-Y', '01-09-2019'); + //$cashTransactionLine2->setPerformanceDate($performanceDate); // DateTimeInterface|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code but only if performancetype is services. + //$cashTransactionLine2->setPerformanceDate(Util::parseDate("20190901")); // string|null + //$cashTransactionLine2->setPerformanceType(\PhpTwinfield\Enums\PerformanceType::SERVICES()); // PerformanceType|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The performance type. + //$cashTransactionLine2->setPerformanceVatNumber('NL1234567890B01'); // string|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. If not added to the request, by default the VAT number of the customer will be taken. + //$cashTransactionLine2->setRepValue(\Money\Money::EUR(-10000)); // Money|null Amount in the reporting currency. + //$cashTransactionLine2->setRate(1); // float|null The exchange rate used for the calculation of the base amount. + //$cashTransactionLine2->setRepRate(1); // float|null The exchange rate used for the calculation of the reporting amount. + //$cashTransactionLine2->setVatBaseValue(\Money\Money::EUR(-10000)); // Money|null Only if line type is detail. VAT amount in base currency. + $vatCode = new \PhpTwinfield\VatCode; + $vatCode->setCode('VN'); + //$cashTransactionLine2->setVatCode($vatCode); // VatCode|null Only if line type is detail or vat. VAT code. + //$cashTransactionLine2->setVatCode(\PhpTwinfield\VatCode::fromCode('VN')); // string|null + //$cashTransactionLine2->setVatRepValue(\Money\Money::EUR(-10000)); // Money|null Only if line type is detail. VAT amount in reporting currency. + //$cashTransactionLine2->setVatValue(\Money\Money::EUR(-10000)); // Money|null Only if line type is detail. VAT amount in the currency of the cash transaction. + + $cashTransaction->addLine($cashTransactionLine2); + + //$cashTransactionLine3 = new \PhpTwinfield\CashTransactionLine; + //$cashTransactionLine3->setLineType(\PhpTwinfield\Enums\LineType::VAT()); // LineType|null Line type. + //$cashTransactionLine3->setVatBaseTurnover(\Money\Money::EUR(-10000)); // Money|null Only if line type is vat. Amount on which VAT was calculated in base currency. + //$cashTransactionLine3->setVatRepTurnover(\Money\Money::EUR(-10000)); // Money|null Only if line type is vat. Amount on which VAT was calculated in reporting currency. + //$cashTransactionLine3->setVatTurnover(\Money\Money::EUR(-10000)); // Money|null Only if line type is vat. Amount on which VAT was calculated in the currency of the cash transaction. + + try { + $cashTransactionNew = $transactionApiConnector->send($cashTransaction); + } catch (ResponseException $e) { + $cashTransactionNew = $e->getReturnedObject(); + } + + echo "
";
+    print_r($cashTransactionNew);
+    echo "
"; + + echo "Result of creation process: {$cashTransactionNew->getResult()}
"; + echo "Number of new CashTransaction: {$cashTransactionNew->getNumber()}
"; +} + +// Delete a BrankTransaction based off the passed in office, code, number and given reason +if ($executeDelete) { + $bookingReference = new \PhpTwinfield\BookingReference($office, 'KAS', 201900026); + + try { + $cashTransactionDeleted = $transactionApiConnector->delete($bookingReference, 'Example reason'); + } catch (ResponseException $e) { + $cashTransactionDeleted = $e->getReturnedObject(); + } + + echo "
";
+    print_r($cashTransactionDeleted);
+    echo "
"; +} diff --git a/examples/Connection.php b/examples/Connection.php index 78db7813..0430c415 100644 --- a/examples/Connection.php +++ b/examples/Connection.php @@ -1,5 +1,8 @@ getMessages(), true) . "
"; // Array|null (Error) messages. } + echo "Office (\\PhpTwinfield\\Office):
" . print_r($invoice->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): " . Util::objectToStr($invoice->getOffice()) . "
"; // string|null echo "PaymentMethod: {$invoice->getPaymentMethod()}
"; // PaymentMethod|null The payment method. echo "PerformanceDate (\\DateTimeInterface):
" . print_r($invoice->getPerformanceDate(), true) . "

"; // DateTimeInterface|null Performance date, when set-up on the invoice header. echo "PerformanceDate (string): " . Util::formatDate($invoice->getPerformanceDate()) . "
"; // string|null echo "Period: {$invoice->getPeriod()}
"; // string|null Period in YYYY/PP format. - echo "Office (\\PhpTwinfield\\Office):
" . print_r($invoice->getOffice(), true) . "

"; // Office|null Office code. - echo "Office (string): " . Util::objectToStr($invoice->getOffice()) . "
"; // string|null echo "Result: {$invoice->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). echo "Status: {$invoice->getStatus()}
"; // Status|null Status of the invoice. @@ -368,7 +370,7 @@ //$invoiceLine->setUnitsPriceInc(\Money\Money::EUR(1210)); // Money|null Only valid for invoice types with VAT inclusive units prices. Only add this tag to an XML request if the setting Prices can be changed on an item is set to true. Otherwise, the price will be determined by the system. (Equals 12.10 EUR) $vatCode = new \PhpTwinfield\VatCode; $vatCode->setCode('VH'); - //$invoiceLine->getVatCode($vatCode); // VatCode|null VAT code. + //$invoiceLine->setVatCode($vatCode); // VatCode|null VAT code. //$invoiceLine->setVatCode(\PhpTwinfield\VatCode::fromCode('VH')); // string|null $invoice->addLine($invoiceLine); // InvoiceLine Add an InvoiceLine object to the Invoice object diff --git a/examples/InvoiceType.php b/examples/InvoiceType.php index 9ebf23e7..964c3d71 100644 --- a/examples/InvoiceType.php +++ b/examples/InvoiceType.php @@ -1,10 +1,12 @@ messages)) { + return false; + } + return count($this->messages) > 0; } } diff --git a/src/Fields/Transaction/CloseAndStartValueFields.php b/src/Fields/Transaction/CloseAndStartValueFields.php index 9f57fe80..350c3787 100644 --- a/src/Fields/Transaction/CloseAndStartValueFields.php +++ b/src/Fields/Transaction/CloseAndStartValueFields.php @@ -63,16 +63,23 @@ public function getStartValue(): ?Money */ public function setStartValue(?Money $startValue): void { - $currency = new Currency(); - $currency->setCode($startValue->getCurrency()); + if (!empty($startValue->getCurrency())) { + $currency = \PhpTwinfield\Currency::fromCode($startValue->getCurrency()); + $this->currency = $currency; + } - $this->currency = $currency; $this->startValue = $startValue; $this->closeValue = $startValue; } public function getCloseValue(): Money { - return $this->closeValue ?? new Money(0, new \Money\Currency($this->getCurrency()->getCode())); + if (!empty($this->getCurrency())) { + $currencyCode = $this->getCurrency()->getCode(); + } else { + $currencyCode = 'EUR'; + } + + return $this->closeValue ?? new Money(0, new \Money\Currency($currencyCode)); } } diff --git a/src/InvoiceLine.php b/src/InvoiceLine.php index 44ebc6f4..6f40558f 100644 --- a/src/InvoiceLine.php +++ b/src/InvoiceLine.php @@ -53,5 +53,6 @@ public function __construct($quantity = null, $article = null, $freeText1 = null $this->article = $article; $this->setFreeText1($freeText1); $this->setFreeText2($freeText2); + $this->setAllowDiscountOrPremium(true); } } diff --git a/src/Mappers/BaseMapper.php b/src/Mappers/BaseMapper.php index c0494389..a294358b 100644 --- a/src/Mappers/BaseMapper.php +++ b/src/Mappers/BaseMapper.php @@ -120,6 +120,8 @@ protected static function parseUnknownEntity(HasMessageInterface $object, \DOMEl { if (is_a($object, \PhpTwinfield\DimensionGroupDimension::class)) { $type = self::getField($element, "type", $object); + } elseif (is_a($object, \PhpTwinfield\TransactionLineInterface::class)) { + $type = self::getAttribute($element, $fieldTagName, "type"); } else { $type = self::getAttribute($element, $fieldTagName, "dimensiontype"); } @@ -142,6 +144,10 @@ protected static function parseUnknownEntity(HasMessageInterface $object, \DOMEl case "PRJ": return \PhpTwinfield\Project::class; default: + if (is_a($object, \PhpTwinfield\TransactionLineInterface::class)) { + return \PhpTwinfield\GeneralLedger::class; + } + throw new \InvalidArgumentException("parseUnknownEntity function was unable to determine class name from \"{$type}\""); } } diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index c3a113c1..3ef2773d 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -158,7 +158,7 @@ public static function map(string $transactionClassName, Response $response, Aut ->setDebitCredit(self::parseEnumAttribute(\PhpTwinfield\Enums\DebitCredit::class, self::getField($lineElement, 'debitcredit', $transactionLine))) ->setDescription(self::getField($lineElement, 'description', $transactionLine)) ->setDestOffice(self::parseObjectAttribute(\PhpTwinfield\Office::class, $transactionLine, $lineElement, 'destoffice')) - ->setDim1(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))) + ->setDim1(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim1', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))) ->setId($lineElement->getAttribute('id')) ->setMatchStatus(self::parseEnumAttribute(\PhpTwinfield\Enums\MatchStatus::class, self::getField($lineElement, 'matchstatus', $transactionLine))) ->setRate(self::getField($lineElement, 'rate', $transactionLine)) @@ -179,8 +179,8 @@ public static function map(string $transactionClassName, Response $response, Aut $transactionLine->setBaseValueOpen(self::parseMoneyAttribute($baseValueOpen, $currencies['base'])); } - $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))); - $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))); + $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); + $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); $transactionLine->setMatchLevel(self::getField($lineElement, 'matchlevel', $transactionLine)); $transactionLine->setRelation(self::getField($lineElement, 'relation', $transactionLine)); $transactionLine->setRepValueOpen(self::parseMoneyAttribute(self::getField($lineElement, 'repvalueopen', $transactionLine), $currencies['reporting'])); @@ -189,12 +189,12 @@ public static function map(string $transactionClassName, Response $response, Aut if ($transaction instanceof PurchaseTransaction || $transaction instanceof SalesTransaction) { if ($lineType == LineType::DETAIL()) { - $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))); - $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))); + $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); + $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); } elseif ($transaction instanceof PurchaseTransaction && $lineType == LineType::VAT()) { - $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))); + $transactionLine->setDim3(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim3', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); } elseif ($lineType == LineType::TOTAL()) { - $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'dimensiontype' => 'setTypeFromString'))); + $transactionLine->setDim2(self::parseObjectAttribute(null, $transactionLine, $lineElement, 'dim2', array('name' => 'setName', 'shortname' => 'setShortName', 'type' => 'setTypeFromString'))); $baseValueOpen = self::getField($lineElement, 'basevalueopen', $transactionLine) ?: self::getField($lineElement, 'openbasevalue', $transactionLine); From a366c7716a7b76dc77d41c827a5c5c3cf89de6c6 Mon Sep 17 00:00:00 2001 From: iranl Date: Tue, 9 Jul 2019 18:24:59 +0200 Subject: [PATCH 384/388] Upload --- src/ApiConnectors/ArticleApiConnector.php | 21 --------------- src/ApiConnectors/AssetMethodApiConnector.php | 21 --------------- src/ApiConnectors/BaseApiConnector.php | 27 +++---------------- src/ApiConnectors/CurrencyApiConnector.php | 10 ------- src/ApiConnectors/HasEqualInterface.php | 3 --- src/ApiConnectors/RateApiConnector.php | 21 --------------- src/ApiConnectors/VatCodeApiConnector.php | 20 -------------- 7 files changed, 4 insertions(+), 119 deletions(-) diff --git a/src/ApiConnectors/ArticleApiConnector.php b/src/ApiConnectors/ArticleApiConnector.php index d4ba546d..b397edfb 100644 --- a/src/ApiConnectors/ArticleApiConnector.php +++ b/src/ApiConnectors/ArticleApiConnector.php @@ -9,7 +9,6 @@ use PhpTwinfield\Mappers\ArticleMapper; use PhpTwinfield\Office; use PhpTwinfield\Request as Request; -use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; use PhpTwinfield\Response\ResponseException; @@ -130,26 +129,6 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa return [$equal, $returnedObject]; } - /** - * @param HasMessageInterface $returnedObject - * @return IndividualMappedResponse - */ - public function getMappedResponse(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): IndividualMappedResponse - { - Assert::IsInstanceOf($returnedObject, Article::class); - - $request_article = new Request\Read\Article(); - $request_article->setOffice($returnedObject->getOffice()) - ->setCode($returnedObject->getCode()); - $response = $this->sendXmlDocument($request_article); - - $mappedResponseCollection = $this->getProcessXmlService()->mapAll([$response], "article", function(Response $response): Article { - return ArticleMapper::map($response, $this->getConnection()); - }); - - return ($mappedResponseCollection[0]); - } - /** * List all articles. * diff --git a/src/ApiConnectors/AssetMethodApiConnector.php b/src/ApiConnectors/AssetMethodApiConnector.php index 823b3920..cba801be 100644 --- a/src/ApiConnectors/AssetMethodApiConnector.php +++ b/src/ApiConnectors/AssetMethodApiConnector.php @@ -9,7 +9,6 @@ use PhpTwinfield\Mappers\AssetMethodMapper; use PhpTwinfield\Office; use PhpTwinfield\Request as Request; -use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; use PhpTwinfield\Response\ResponseException; @@ -133,26 +132,6 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa return [$equal, $returnedObject]; } - /** - * @param HasMessageInterface $returnedObject - * @return IndividualMappedResponse - */ - public function getMappedResponse(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): IndividualMappedResponse - { - Assert::IsInstanceOf($returnedObject, AssetMethod::class); - - $request_assetMethod = new Request\AssetMethod(); - $request_assetMethod->setOffice($returnedObject->getOffice()) - ->setCode($returnedObject->getCode()); - $response = $this->sendXmlDocument($request_assetMethod); - - $mappedResponseCollection = $this->getProcessXmlService()->mapAll([$response], "assetmethod", function(Response $response): AssetMethod { - return AssetMethodMapper::map($response); - }); - - return ($mappedResponseCollection[0]); - } - /** * List all asset methods. * diff --git a/src/ApiConnectors/BaseApiConnector.php b/src/ApiConnectors/BaseApiConnector.php index 1a1872cc..c70cc81d 100644 --- a/src/ApiConnectors/BaseApiConnector.php +++ b/src/ApiConnectors/BaseApiConnector.php @@ -262,29 +262,10 @@ public function testSentEqualsResponse(HasEqualInterface $apiConnector, array $s $returnedObject = $testResult[1]; if (!$equal) { - $tempMappedResponse = $apiConnector->sendAll([$returnedObject], true)[0]; - $tempReturnedObject = $tempMappedResponse->unwrap(); - - if ($tempReturnedObject->getResult() == 1) { - $individualMappedResponse = $tempMappedResponse; - $returnedObject = $tempReturnedObject; - - $testResult = $apiConnector->testEqual($returnedObject, $sentObjects[$key]); - $equal = $testResult[0]; - $returnedObject = $testResult[1]; - - if (!$equal || is_a($returnedObject, \PhpTwinfield\Currency::class)) { - sleep(2); - - $tempMappedResponse = $apiConnector->getMappedResponse($returnedObject, $sentObjects[$key]); - $tempReturnedObject = $tempMappedResponse->unwrap(); - - if ($returnedObject->getResult() == 1) { - $individualMappedResponse = $tempMappedResponse; - $returnedObject = $tempReturnedObject; - } - } - } + $apiConnector->sendAll([$returnedObject], true)[0]; + sleep(2); + $sentObjects[$key]->setCode($returnedObject->getCode()); + $individualMappedResponse = $apiConnector->sendAll([$sentObjects[$key]], true)[0]; } } diff --git a/src/ApiConnectors/CurrencyApiConnector.php b/src/ApiConnectors/CurrencyApiConnector.php index 42188182..acbe5bf3 100644 --- a/src/ApiConnectors/CurrencyApiConnector.php +++ b/src/ApiConnectors/CurrencyApiConnector.php @@ -9,7 +9,6 @@ use PhpTwinfield\Mappers\CurrencyMapper; use PhpTwinfield\Office; use PhpTwinfield\Request as Request; -use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; use PhpTwinfield\Response\ResponseException; @@ -170,15 +169,6 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa return [$equal, $returnedObject]; } - /** - * @param HasMessageInterface $returnedObject - * @return IndividualMappedResponse - */ - public function getMappedResponse(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): IndividualMappedResponse - { - return $this->sendAll([$sentObject], true)[0]; - } - /** * List all currencies. * diff --git a/src/ApiConnectors/HasEqualInterface.php b/src/ApiConnectors/HasEqualInterface.php index 8b2dbfd8..08fb75d9 100644 --- a/src/ApiConnectors/HasEqualInterface.php +++ b/src/ApiConnectors/HasEqualInterface.php @@ -3,7 +3,6 @@ namespace PhpTwinfield\ApiConnectors; use PhpTwinfield\HasMessageInterface; -use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; /** @@ -15,6 +14,4 @@ interface HasEqualInterface public function testEqual(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): array; public function sendAll(array $objects, bool $reSend): MappedResponseCollection; - - public function getMappedResponse(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): IndividualMappedResponse; } diff --git a/src/ApiConnectors/RateApiConnector.php b/src/ApiConnectors/RateApiConnector.php index 9ad8300c..c4895c2c 100644 --- a/src/ApiConnectors/RateApiConnector.php +++ b/src/ApiConnectors/RateApiConnector.php @@ -9,7 +9,6 @@ use PhpTwinfield\Office; use PhpTwinfield\Rate; use PhpTwinfield\Request as Request; -use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; use PhpTwinfield\Response\ResponseException; @@ -131,26 +130,6 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa return [$equal, $returnedObject]; } - /** - * @param HasMessageInterface $returnedObject - * @return IndividualMappedResponse - */ - public function getMappedResponse(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): IndividualMappedResponse - { - Assert::IsInstanceOf($returnedObject, Rate::class); - - $request_rate = new Request\Read\Rate(); - $request_rate->setOffice($returnedObject->getOffice()) - ->setCode($returnedObject->getCode()); - $response = $this->sendXmlDocument($request_rate); - - $mappedResponseCollection = $this->getProcessXmlService()->mapAll([$response], "projectrate", function(Response $response): Rate { - return RateMapper::map($response); - }); - - return ($mappedResponseCollection[0]); - } - /** * List all rates. * diff --git a/src/ApiConnectors/VatCodeApiConnector.php b/src/ApiConnectors/VatCodeApiConnector.php index 79b24c88..5bf33578 100644 --- a/src/ApiConnectors/VatCodeApiConnector.php +++ b/src/ApiConnectors/VatCodeApiConnector.php @@ -8,7 +8,6 @@ use PhpTwinfield\Mappers\VatCodeMapper; use PhpTwinfield\Office; use PhpTwinfield\Request as Request; -use PhpTwinfield\Response\IndividualMappedResponse; use PhpTwinfield\Response\MappedResponseCollection; use PhpTwinfield\Response\Response; use PhpTwinfield\Response\ResponseException; @@ -132,25 +131,6 @@ public function testEqual(HasMessageInterface $returnedObject, HasMessageInterfa return [$equal, $returnedObject]; } - /** - * @param HasMessageInterface $returnedObject - * @return IndividualMappedResponse - */ - public function getMappedResponse(HasMessageInterface $returnedObject, HasMessageInterface $sentObject): IndividualMappedResponse - { - Assert::IsInstanceOf($returnedObject, VatCode::class); - - $request_vatCode = new Request\Read\VatCode(); - $request_vatCode->setCode($returnedObject->getCode()); - $response = $this->sendXmlDocument($request_vatCode); - - $mappedResponseCollection = $this->getProcessXmlService()->mapAll([$response], "vat", function(Response $response): VatCode { - return VatCodeMapper::map($response); - }); - - return ($mappedResponseCollection[0]); - } - /** * List all VAT codes. * From a04d0d303205e50e963df0ec16ffcec2dec31afe Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 10 Jul 2019 21:41:14 +0200 Subject: [PATCH 385/388] Upload --- breaking262.md => breaking270.md | 2 +- readme.md | 2 +- src/ApiConnectors/ApiOptions.php | 101 +++++++ src/ApiConnectors/BaseApiConnector.php | 38 +-- src/CustomerCreditManagement.php | 1 + src/DomDocuments/CustomersDocument.php | 7 +- .../ApiConnectors/BaseApiConnectorTest.php | 286 +++++++++++++++++- usage.md | 70 +++++ 8 files changed, 477 insertions(+), 30 deletions(-) rename breaking262.md => breaking270.md (97%) create mode 100644 src/ApiConnectors/ApiOptions.php diff --git a/breaking262.md b/breaking270.md similarity index 97% rename from breaking262.md rename to breaking270.md index 68de117f..df6c9b90 100644 --- a/breaking262.md +++ b/breaking270.md @@ -1,4 +1,4 @@ -# Breaking changes since 2.6.2 +# Breaking changes since 2.7.0 Release ... added multiple new resources, but also broke several existing ones. Breaking changes are present in: diff --git a/readme.md b/readme.md index 5965207d..1adbf446 100644 --- a/readme.md +++ b/readme.md @@ -21,7 +21,7 @@ composer require 'league/oauth2-client' ## Usage See [Usage](usage.md). -For breaking changes since 2.6.2 see [Breaking Changes since 2.6.2](breaking262.md). +For breaking changes since 2.7.0 see [Breaking Changes since 2.7.0](breaking270.md). ### Supported resources Not all resources from the Twinfield API are currently implemented. Feel free to create a pull request when you need diff --git a/src/ApiConnectors/ApiOptions.php b/src/ApiConnectors/ApiOptions.php new file mode 100644 index 00000000..8c28023d --- /dev/null +++ b/src/ApiConnectors/ApiOptions.php @@ -0,0 +1,101 @@ +validateMessages($messages); + $this->retriableExceptionMessages = $messages; + } + if ($maxRetries !== null) { + $this->validateMaxRetries($maxRetries); + $this->maxRetries = $maxRetries; + } + } + + /** + * @throws \InvalidArgumentException + */ + private function validateMaxRetries(int $maxRetries): void + { + if ($maxRetries < 0) { + throw new \InvalidArgumentException('The max retries should be a positive integer.'); + } + } + + /** + * @throws \InvalidArgumentException + */ + private function validateMessages(array $messages): void + { + foreach ($messages as $key => $message) { + if (trim($message) === '') { + throw new \InvalidArgumentException( + sprintf('The exception message should not be empty. Key: [%s]', $key) + ); + } + } + } + + /** + * @return array + */ + public function getRetriableExceptionMessages(): array + { + return $this->retriableExceptionMessages; + } + + /** + * @throws \InvalidArgumentException + */ + public function setRetriableExceptionMessages(array $retriableExceptionMessages): ApiOptions + { + return new self( + $retriableExceptionMessages, + $this->maxRetries + ); + } + + /** + * @throws \InvalidArgumentException + */ + public function addMessages(array $messages): ApiOptions + { + return new self( + array_merge($messages, $this->retriableExceptionMessages), + $this->maxRetries + ); + } + + /** + * @return int + */ + public function getMaxRetries(): int + { + return $this->maxRetries; + } + + /** + * @throws \InvalidArgumentException + */ + public function setMaxRetries(int $maxRetries): ApiOptions + { + return new self( + $this->retriableExceptionMessages, + $maxRetries + ); + } +} \ No newline at end of file diff --git a/src/ApiConnectors/BaseApiConnector.php b/src/ApiConnectors/BaseApiConnector.php index c70cc81d..615142d9 100644 --- a/src/ApiConnectors/BaseApiConnector.php +++ b/src/ApiConnectors/BaseApiConnector.php @@ -19,34 +19,32 @@ abstract class BaseApiConnector implements LoggerAwareInterface use LoggerAwareTrait; /** - * Make sure to only add error messages for failure cases that caused the server not to accept / receive the - * request. Else the automatic retry will cause the request to be understood by the server twice. - * - * @var string[] + * @var AuthenticatedConnection */ - private const RETRY_REQUEST_EXCEPTION_MESSAGES = [ - "SSL: Connection reset by peer", - "Your logon credentials are not valid anymore. Try to log on again." - ]; + private $connection; /** * @var int */ - private const MAX_RETRIES = 3; + private $numRetries = 0; /** - * @var AuthenticatedConnection + * @var ApiOptions */ - private $connection; + private $options; /** - * @var int + * @throws \InvalidArgumentException */ - private $numRetries = 0; - - public function __construct(AuthenticatedConnection $connection) + public function __construct(AuthenticatedConnection $connection, ?ApiOptions $options = null) { $this->connection = $connection; + + if ($options === null) { + $this->options = new ApiOptions(); + } else { + $this->options = $options; + } } /** @@ -59,6 +57,11 @@ public function getConnection(): AuthenticatedConnection { return $this->connection; } + + public function getOptions(): ApiOptions + { + return $this->options; + } /** * @see sendXmlDocument() @@ -77,6 +80,7 @@ protected function getProcessXmlService(): ProcessXmlService * @param \DOMDocument $document * @return \PhpTwinfield\Response\Response * @throws Exception + * @throws \RuntimeException */ public function sendXmlDocument(\DOMDocument $document) { $this->logSendingDocument($document); @@ -96,13 +100,13 @@ public function sendXmlDocument(\DOMDocument $document) { $this->connection->resetClient(Services::PROCESSXML()); /* For a given set of exception messages, always retry the request. */ - foreach (self::RETRY_REQUEST_EXCEPTION_MESSAGES as $message) { + foreach ($this->getOptions()->getRetriableExceptionMessages() as $message) { if (stripos($exception->getMessage(), $message) === false) { continue; } $this->numRetries++; - if ($this->numRetries > self::MAX_RETRIES) { + if ($this->numRetries > $this->getOptions()->getMaxRetries()) { break; } diff --git a/src/CustomerCreditManagement.php b/src/CustomerCreditManagement.php index 270539c3..9979d2b0 100644 --- a/src/CustomerCreditManagement.php +++ b/src/CustomerCreditManagement.php @@ -34,6 +34,7 @@ class CustomerCreditManagement extends BaseObject public function __construct() { + $this->setBlocked(false); $this->setSendReminder(\PhpTwinfield\Enums\SendReminder::TRUE()); } } diff --git a/src/DomDocuments/CustomersDocument.php b/src/DomDocuments/CustomersDocument.php index 54f0e52f..4c037a00 100644 --- a/src/DomDocuments/CustomersDocument.php +++ b/src/DomDocuments/CustomersDocument.php @@ -105,7 +105,12 @@ public function addCustomer(Customer $customer) $creditManagementElement = $this->createElement('creditmanagement'); $customerElement->appendChild($creditManagementElement); - $creditManagementElement->appendChild($this->createNodeWithTextContent('basecreditlimit', Util::formatMoney($creditManagement->getBaseCreditLimit()))); + if ($creditManagement->getBaseCreditLimit() !== null) { + $creditManagementElement->appendChild($this->createNodeWithTextContent('basecreditlimit', Util::formatMoney($creditManagement->getBaseCreditLimit()))); + } else { + $creditManagementElement->appendChild($this->createNodeWithTextContent('basecreditlimit', 0)); + } + $creditManagementElement->appendChild($this->createNodeWithTextContent('blocked', Util::formatBoolean($creditManagement->getBlocked()))); $creditManagementElement->appendChild($this->createNodeWithTextContent('comment', $creditManagement->getComment())); $creditManagementElement->appendChild($this->createNodeWithTextContent('freetext1', Util::formatBoolean($creditManagement->getFreeText1()))); diff --git a/tests/UnitTests/ApiConnectors/BaseApiConnectorTest.php b/tests/UnitTests/ApiConnectors/BaseApiConnectorTest.php index c7b201be..83f5c1d1 100644 --- a/tests/UnitTests/ApiConnectors/BaseApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/BaseApiConnectorTest.php @@ -2,6 +2,7 @@ namespace PhpTwinfield\UnitTests; +use PhpTwinfield\ApiConnectors\ApiOptions; use PhpTwinfield\ApiConnectors\BaseApiConnector; use PhpTwinfield\Enums\Services; use PhpTwinfield\Exception; @@ -57,30 +58,29 @@ protected function setUp() public function soapFaultProvider(): array { - return array_map(function($message) { + return array_map(function ($message) { return [new \SoapFault("xx", "[soap:Client] {$message}", "client")]; }, $this->getResendErrorMessages()); } public function errorExceptionProvider(): array { - return array_map(function($message) { + return array_map(function ($message) { return [new \ErrorException("[soap:Client] {$message}")]; }, $this->getResendErrorMessages()); } private function getResendErrorMessages(): array { - return (new \ReflectionClassConstant( - BaseApiConnector::class, - "RETRY_REQUEST_EXCEPTION_MESSAGES" - ))->getValue(); + return [ + "SSL: Connection reset by peer", + "Your logon credentials are not valid anymore. Try to log on again." + ]; } private function getMaxNumRetries(): int { - $reflectionConstant = new \ReflectionClassConstant(BaseApiConnector::class,"MAX_RETRIES"); - return $reflectionConstant->getValue(); + return 3; } public function testSendDocumentLogsRequestAndResponse() @@ -162,7 +162,6 @@ public function testSendDocumentLogsRetries(\Throwable $e) $this->service->setLogger($this); $this->service->sendXmlDocument($request_document); - self::assertCount(6, $this->logs); [$level, $message, $context] = $this->logs[0]; @@ -286,4 +285,271 @@ public function testResendXmlDocumentStopsAfterMaxRetries(\Exception $exception) $numRetries = $this->getObjectAttribute($this->service, "numRetries"); $this->assertEquals(0, $numRetries); } -} + + /** + * @dataProvider soapFaultProvider + * @dataProvider errorExceptionProvider + */ + public function testResendXmlDocumentStopsAfterCustomMaxRetries(\Exception $exception) + { + $this->service = $this->getMockBuilder(BaseApiConnector::class) + ->setConstructorArgs( + [ + $this->connection, + new ApiOptions(null, 5) + ] + ) + ->getMockForAbstractClass(); + + $this->connection->expects($this->exactly(6)) + ->method("getAuthenticatedClient") + ->with(Services::PROCESSXML()) + ->willReturn($this->client); + + $this->connection->expects($this->exactly(6)) + ->method("resetClient") + ->with(Services::PROCESSXML()); + + $this->client->expects($this->exactly(6)) + ->method("sendDocument") + ->willThrowException($exception); + + $this->expectException(Exception::class); + try { + $this->service->sendXmlDocument(new \DOMDocument()); + } catch (\Exception $e) { + throw $e; + } finally { + $numRetries = $this->getObjectAttribute($this->service, "numRetries"); + $this->assertEquals(0, $numRetries); + } + } + + public function testSendDocumentRetryBadGateway() + { + $expectedErrorMessage = 'Bad Gateway'; + $this->service = $this->getMockBuilder(BaseApiConnector::class) + ->setConstructorArgs( + [ + $this->connection, + new ApiOptions([$expectedErrorMessage], 3) + ] + ) + ->getMockForAbstractClass(); + $request_document = new \DOMDocument(); + $request_document->loadXML('value'); + + $this->connection->expects($this->any()) + ->method("getAuthenticatedClient") + ->with(Services::PROCESSXML()) + ->willReturn($this->client); + + $this->client->expects($this->any()) + ->method("sendDocument") + ->will($this->throwException(new \SoapFault('Server', $expectedErrorMessage))); + + $this->service->setLogger($this); + try { + $this->service->sendXmlDocument($request_document); + } catch (\PhpTwinfield\Exception $e) { + } + + self::assertCount(8, $this->logs); + + [$level, $message, $context] = $this->logs[0]; + self::assertSame(LogLevel::DEBUG, $level); + self::assertSame('Sending request to Twinfield.', $message); + self::assertSame($this->completeXml('value'), $context['document_xml']); + + [$level, $message, $context] = $this->logs[1]; + self::assertSame(LogLevel::INFO, $level); + self::assertSame("Retrying request. Reason for initial failure: Bad Gateway", $message); + self::assertEmpty($context); + } + + public function testSendDocumentRetryCustomMessage() + { + $expectedErrorMessage = 'my custom error message'; + $this->service = $this->getMockForAbstractClass( + BaseApiConnector::class, + [ + $this->connection, + new ApiOptions([$expectedErrorMessage]) + ] + ); + + $request_document = new \DOMDocument(); + $request_document->loadXML('value'); + + $this->connection->expects($this->any()) + ->method("getAuthenticatedClient") + ->with(Services::PROCESSXML()) + ->willReturn($this->client); + + $this->client->expects($this->any()) + ->method("sendDocument") + ->will($this->throwException(new \SoapFault('Server', $expectedErrorMessage))); + + $this->service->setLogger($this); + try { + $this->service->sendXmlDocument($request_document); + } catch (\PhpTwinfield\Exception $e) { + } + + self::assertCount(8, $this->logs); + + [$level, $message, $context] = $this->logs[0]; + self::assertSame(LogLevel::DEBUG, $level); + self::assertSame('Sending request to Twinfield.', $message); + self::assertSame($this->completeXml('value'), $context['document_xml']); + + [$level, $message, $context] = $this->logs[1]; + self::assertSame(LogLevel::INFO, $level); + self::assertSame("Retrying request. Reason for initial failure: my custom error message", $message); + self::assertEmpty($context); + } + + public function testOverrideMessagesAndThrowSSLError() + { + $customErrorMessage = 'my custom error message'; + $baseErrorMessage = 'SSL: Connection reset by peer'; + + $this->service = $this->getMockForAbstractClass( + BaseApiConnector::class, + [ + $this->connection, + new ApiOptions([$customErrorMessage]) + ] + ); + + $request_document = new \DOMDocument(); + $request_document->loadXML('value'); + + $this->connection->expects($this->any()) + ->method("getAuthenticatedClient") + ->with(Services::PROCESSXML()) + ->willReturn($this->client); + + $this->client->expects($this->any()) + ->method("sendDocument") + ->will( + $this->onConsecutiveCalls( + $this->throwException(new \SoapFault('Server', $customErrorMessage)), + $this->throwException(new \SoapFault('Server', $baseErrorMessage)), + $this->throwException(new \SoapFault('Server', $baseErrorMessage)), + $this->throwException(new \SoapFault('Server', $baseErrorMessage)) + ) + ); + + $this->service->setLogger($this); + try { + $this->service->sendXmlDocument($request_document); + } catch (\PhpTwinfield\Exception $e) { + } + + self::assertCount(4, $this->logs); + + [$level, $message, $context] = $this->logs[1]; + self::assertSame(LogLevel::INFO, $level); + self::assertSame('Retrying request. Reason for initial failure: my custom error message', $message); + [$level, $message, $context] = $this->logs[3]; + self::assertSame(LogLevel::ERROR, $level); + self::assertSame('Request to Twinfield failed: SSL: Connection reset by peer', $message); + } + + public function testSendDocumentAddACustomMessage() + { + $customErrorMessage = 'my custom error message'; + $baseErrorMessage = 'SSL: Connection reset by peer'; + $options = new ApiOptions(); + $this->service = $this->getMockForAbstractClass( + BaseApiConnector::class, + [ + $this->connection, + $options->addMessages([$customErrorMessage]) + ] + ); + + $request_document = new \DOMDocument(); + $request_document->loadXML('value'); + + $this->connection->expects($this->any()) + ->method("getAuthenticatedClient") + ->with(Services::PROCESSXML()) + ->willReturn($this->client); + + $this->client->expects($this->any()) + ->method("sendDocument") + ->will( + $this->onConsecutiveCalls( + $this->throwException(new \SoapFault('Server', $customErrorMessage)), + $this->throwException(new \SoapFault('Server', $baseErrorMessage)), + $this->throwException(new \SoapFault('Server', $baseErrorMessage)), + $this->throwException(new \SoapFault('Server', $baseErrorMessage)) + ) + ); + + $this->service->setLogger($this); + try { + $this->service->sendXmlDocument($request_document); + } catch (\PhpTwinfield\Exception $e) { + } + + self::assertCount(8, $this->logs); + + [$level, $message, $context] = $this->logs[1]; + self::assertSame(LogLevel::INFO, $level); + self::assertSame('Retrying request. Reason for initial failure: my custom error message', $message); + [$level, $message, $context] = $this->logs[3]; + self::assertSame(LogLevel::INFO, $level); + self::assertSame('Retrying request. Reason for initial failure: SSL: Connection reset by peer', $message); + [$level, $message, $context] = $this->logs[5]; + self::assertSame(LogLevel::INFO, $level); + self::assertSame('Retrying request. Reason for initial failure: SSL: Connection reset by peer', $message); + [$level, $message, $context] = $this->logs[7]; + self::assertSame(LogLevel::ERROR, $level); + self::assertSame('Request to Twinfield failed: SSL: Connection reset by peer', $message); + } + + public function testSendDocumentZeroRetries() + { + $expectedErrorMessage = 'my custom error message'; + $this->service = $this->getMockForAbstractClass( + BaseApiConnector::class, + [ + $this->connection, + new ApiOptions(null, 0) + ] + ); + + $request_document = new \DOMDocument(); + $request_document->loadXML('value'); + + $this->connection->expects($this->any()) + ->method("getAuthenticatedClient") + ->with(Services::PROCESSXML()) + ->willReturn($this->client); + + $this->client->expects($this->any()) + ->method("sendDocument") + ->will($this->throwException(new \SoapFault('Server', $expectedErrorMessage))); + + $this->service->setLogger($this); + try { + $this->service->sendXmlDocument($request_document); + } catch (\PhpTwinfield\Exception $e) { + } + + self::assertCount(2, $this->logs); + + [$level, $message, $context] = $this->logs[0]; + self::assertSame(LogLevel::DEBUG, $level); + self::assertSame('Sending request to Twinfield.', $message); + self::assertSame($this->completeXml('value'), $context['document_xml']); + + [$level, $message, $context] = $this->logs[1]; + self::assertSame(LogLevel::ERROR, $level); + self::assertSame("Request to Twinfield failed: my custom error message", $message); + self::assertEmpty($context); + } +} \ No newline at end of file diff --git a/usage.md b/usage.md index 9c4d130d..e0c0b453 100644 --- a/usage.md +++ b/usage.md @@ -162,6 +162,76 @@ if ($accessTokenStorage['access_expiry'] > time()) { } ``` +#### ApiConnector Configuration +The ApiConnector has a constructor second parameter that can be used to configure some aspects of its operation. + +The ApiOptions has the following methods signature: + + ```php +/** + * This will allow you to enforce the messages or the number of max retries. + * Passing null you will use the default values. + */ +public function __construct(?array $messages = null, ?int $maxRetries = null); +/** + * This will allow you to get all the exception messages + */ +public function getRetriableExceptionMessages(): array +/** + * This will allow you to replace the exception messages that should be retried + */ +public function setRetriableExceptionMessages(array $retriableExceptionMessages): ApiOptions +/** + * This will allow you to add new messages to the array of exception messages + */ +public function addMessages(array $messages): ApiOptions +/** + * This will allow you to get the number of max retries + */ +public function getMaxRetries(): int +/** + * This will allow you to set the number of max retries + */ +public function setMaxRetries(int $maxRetries): ApiOptions +``` + +:exclamation: All the *get* methods will return a new instance with the configuration you changed. + +##### Configuration Examples +Below are some examples on how to use the configuration object + + ```php +$connector = new BrowseDataApiConnector( + $connection, + new ApiOptions( + [ + "SSL: Connection reset by peer", + "Bad Gateway" + ], + 3 + ) +); +``` + +The example below will look for the default messages plus the "Bad Gateway" message. + + ```php +$options = new ApiOptions( + null, + 3 +); +$connector = new BrowseDataApiConnector( + $connection, + $options->addMessages(["Bad Gateway"]) +); +``` + +##### Configuration default values +| Attribute | Default Value | Description | +| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | +| Max retries | 3 | The number of retries that should happen before throwing an error. | +| Retriable exception messages | [
"SSL: Connection reset by peer",
"Your logon credentials are not valid anymore. Try to log on again."
] | The exception messages that should be match in order to retry automatically. | + ## Getting data from the API See [Customer Example](examples/Customer.php) among others for a complete example. From 2c801423428a0fb8693c30ffde52b816bf5d23ea Mon Sep 17 00:00:00 2001 From: iranl Date: Wed, 10 Jul 2019 21:45:43 +0200 Subject: [PATCH 386/388] Upload --- src/ApiConnectors/ApiOptions.php | 2 +- src/ApiConnectors/BaseApiConnector.php | 2 +- src/DomDocuments/CustomersDocument.php | 2 +- tests/IntegrationTests/resources/customerSendRequest.xml | 4 ++-- tests/UnitTests/ApiConnectors/BaseApiConnectorTest.php | 2 +- tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ApiConnectors/ApiOptions.php b/src/ApiConnectors/ApiOptions.php index 8c28023d..106ba101 100644 --- a/src/ApiConnectors/ApiOptions.php +++ b/src/ApiConnectors/ApiOptions.php @@ -98,4 +98,4 @@ public function setMaxRetries(int $maxRetries): ApiOptions $maxRetries ); } -} \ No newline at end of file +} diff --git a/src/ApiConnectors/BaseApiConnector.php b/src/ApiConnectors/BaseApiConnector.php index 615142d9..fdeaab20 100644 --- a/src/ApiConnectors/BaseApiConnector.php +++ b/src/ApiConnectors/BaseApiConnector.php @@ -57,7 +57,7 @@ public function getConnection(): AuthenticatedConnection { return $this->connection; } - + public function getOptions(): ApiOptions { return $this->options; diff --git a/src/DomDocuments/CustomersDocument.php b/src/DomDocuments/CustomersDocument.php index 4c037a00..57689727 100644 --- a/src/DomDocuments/CustomersDocument.php +++ b/src/DomDocuments/CustomersDocument.php @@ -110,7 +110,7 @@ public function addCustomer(Customer $customer) } else { $creditManagementElement->appendChild($this->createNodeWithTextContent('basecreditlimit', 0)); } - + $creditManagementElement->appendChild($this->createNodeWithTextContent('blocked', Util::formatBoolean($creditManagement->getBlocked()))); $creditManagementElement->appendChild($this->createNodeWithTextContent('comment', $creditManagement->getComment())); $creditManagementElement->appendChild($this->createNodeWithTextContent('freetext1', Util::formatBoolean($creditManagement->getFreeText1()))); diff --git a/tests/IntegrationTests/resources/customerSendRequest.xml b/tests/IntegrationTests/resources/customerSendRequest.xml index 3f1a34fe..af5140f6 100644 --- a/tests/IntegrationTests/resources/customerSendRequest.xml +++ b/tests/IntegrationTests/resources/customerSendRequest.xml @@ -26,8 +26,8 @@ - - + 0 + false diff --git a/tests/UnitTests/ApiConnectors/BaseApiConnectorTest.php b/tests/UnitTests/ApiConnectors/BaseApiConnectorTest.php index 83f5c1d1..2e500800 100644 --- a/tests/UnitTests/ApiConnectors/BaseApiConnectorTest.php +++ b/tests/UnitTests/ApiConnectors/BaseApiConnectorTest.php @@ -552,4 +552,4 @@ public function testSendDocumentZeroRetries() self::assertSame("Request to Twinfield failed: my custom error message", $message); self::assertEmpty($context); } -} \ No newline at end of file +} diff --git a/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php index 730b4f01..299173f6 100644 --- a/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php +++ b/tests/UnitTests/DomDocuments/CustomerDocumentUnitTest.php @@ -212,8 +212,8 @@ public function testXmlIsCreatedPerSpec() - - + 0 + false From 479067f946ed53f9ed2228e544d04b58d90a46a2 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 21 Jul 2019 16:48:59 +0200 Subject: [PATCH 387/388] Upload --- examples/Activity.php | 2 +- examples/BankTransaction.php | 4 +- examples/CashTransaction.php | 2 +- examples/JournalTransaction.php | 336 ++++++++++++++++++++ examples/PurchaseTransaction.php | 347 ++++++++++++++++++++ examples/SalesTransaction.php | 352 +++++++++++++++++++++ src/ApiConnectors/ActivityApiConnector.php | 2 +- src/Mappers/TransactionMapper.php | 2 +- 8 files changed, 1041 insertions(+), 6 deletions(-) create mode 100644 examples/JournalTransaction.php create mode 100644 examples/PurchaseTransaction.php create mode 100644 examples/SalesTransaction.php diff --git a/examples/Activity.php b/examples/Activity.php index 0252d4e6..d71dcb1f 100644 --- a/examples/Activity.php +++ b/examples/Activity.php @@ -309,7 +309,7 @@ $activityProjects->setValidTill($validTill); // DateTimeInterface|null An activity can be set to only be valid for certain dates. Users will then only be able to book hours to the activity during these dates. $activityProjects->setValidTill(Util::parseDate('20191231')); // string|null - // The minimum amount of ActivityQuantities linked to a ActivityProjects object is 0, the maximum amount is 4 + // The minimum amount of ActivityQuantities linked to an ActivityProjects object is 0, the maximum amount is 4 $activityQuantity = new \PhpTwinfield\ActivityQuantity; $activityQuantity->setBillable(false); // bool|null Is the quantity line billable or not. $activityQuantity->setBillableLocked(false); // bool|null diff --git a/examples/BankTransaction.php b/examples/BankTransaction.php index 6ac74606..f1df5c80 100644 --- a/examples/BankTransaction.php +++ b/examples/BankTransaction.php @@ -57,7 +57,7 @@ */ /* Read a BankTransaction based off the passed in bank day book code, transaction number and optionally the office. - * The used transaction type, in the example below BNK depends on the administration. It is possible that there are multiple bank day book codes in an administration. + * The used transaction type, in the example below BNK, depends on the administration. It is possible that there are multiple bank day book codes in an administration. * See https://accounting.twinfield.com/UI/#/Settings/Company/TransactionTypes for available codes for (bank) day books in your office */ @@ -267,7 +267,7 @@ $bankTransactionLine2->setDim1($dim1); // object|null If line type = total the bank balance account. If line type = detail the customer or supplier balance account or profit and loss account. $bankTransactionLine2->setDim1(\PhpTwinfield\GeneralLedger::fromCode('2500')); // string|null If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account will be taken as entered at the VAT code in Twinfield. $bankTransactionLine2->setID(2); // int|null Line ID. - $bankTransactionLine2->setValue(\Money\Money::EUR(-10000)); // Money|null If line type = total amount including VAT. If line type = detail amount without VAT. If line type = vat VAT amount. + $bankTransactionLine2->setValue(\Money\Money::EUR(-10000)); // Money|null If line type = total amount including VAT. If line type = detail amount without VAT. If line type = vat VAT amount. //$bankTransactionLine2->setComment('Example Comments'); // string|null Comment set on the transaction line. $currencyDate = \DateTime::createFromFormat('d-m-Y', '01-09-2019'); diff --git a/examples/CashTransaction.php b/examples/CashTransaction.php index 68166452..ca7ffce7 100644 --- a/examples/CashTransaction.php +++ b/examples/CashTransaction.php @@ -57,7 +57,7 @@ */ /* Read a CashTransaction based off the passed in cash day book code, transaction number and optionally the office. - * The used transaction type, in the example below KAS depends on the administration. It is possible that there are multiple cash day book codes in an administration. + * The used transaction type, in the example below KAS, depends on the administration. It is possible that there are multiple cash day book codes in an administration. * See https://accounting.twinfield.com/UI/#/Settings/Company/TransactionTypes for available codes for (cash) day books in your office */ diff --git a/examples/JournalTransaction.php b/examples/JournalTransaction.php new file mode 100644 index 00000000..863fea75 --- /dev/null +++ b/examples/JournalTransaction.php @@ -0,0 +1,336 @@ +get(\PhpTwinfield\JournalTransaction::class, "MEMO", 201900003, $office); + } catch (ResponseException $e) { + $journalTransaction = $e->getReturnedObject(); + } + + echo "
";
+    print_r($journalTransaction);
+    echo "
"; + + echo "JournalTransaction
"; + echo "AutoBalanceVat (bool): {$journalTransaction->getAutoBalanceVat()}
"; // bool|null Should VAT be rounded true or not false? Rounding will only be done with a maximum of two cents. + echo "AutoBalanceVat (string): " . Util::formatBoolean($journalTransaction->getAutoBalanceVat()) . "
"; // string|null + echo "BookingReference (\\PhpTwinfield\\BookingReference):
" . print_r($journalTransaction->getBookingReference(), true) . "

"; // BookingReference|null The Booking reference + echo "Code: {$journalTransaction->getCode()}
"; // string|null Transaction type code. + echo "Currency (\\PhpTwinfield\\Currency):
" . print_r($journalTransaction->getCurrency(), true) . "

"; // Currency|null Currency code. + echo "Currency (string): " . Util::objectToStr($journalTransaction->getCurrency()) . "
"; // string|null + echo "Date (\\DateTimeInterface):
" . print_r($journalTransaction->getDate(), true) . "

"; // DateTimeInterface|null Transaction date. + echo "Date (string): " . Util::formatDate($journalTransaction->getDate()) . "
"; // string|null + echo "DateRaiseWarning (bool): {$journalTransaction->getDateRaiseWarning()}
"; // bool|null Optionally, it is possible to suppress warnings about 'date out of range for the given period' by adding the raisewarning attribute and set its value to false. + echo "DateRaiseWarning (string): {$journalTransaction->getDateRaiseWarningToString()}
"; // string|null This overwrites the value of the raisewarning attribute as set on the root element. + echo "Destiny: {$journalTransaction->getDestiny()}
"; // Destiny|null Attribute to indicate the destiny of the journal transaction. Only used in the request XML. temporary = journal transaction will be saved as provisional. final = journal transaction will be saved as final. + echo "FreeText1: {$journalTransaction->getFreeText1()}
"; // string|null Free text field 1 as entered on the transaction type. + echo "FreeText2: {$journalTransaction->getFreeText2()}
"; // string|null Free text field 2 as entered on the transaction type. + echo "FreeText3: {$journalTransaction->getFreeText3()}
"; // string|null Free text field 3 as entered on the transaction type. + echo "InputDate (\\DateTimeInterface):
" . print_r($journalTransaction->getInputDate(), true) . "

"; // DateTimeInterface|null The date/time on which the transaction was created. Read-only attribute. + echo "InputDate (string): " . Util::formatDate($journalTransaction->getInputDate()) . "
"; // string|null + + if ($journalTransaction->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($journalTransaction->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "ModificationDate (\\DateTimeInterface):
" . print_r($journalTransaction->getModificationDate(), true) . "

"; // DateTimeInterface|null The date/time on which the journal transaction was modified the last time. Read-only attribute. + echo "ModificationDate (string): " . Util::formatDate($journalTransaction->getModificationDate()) . "
"; // string|null + echo "Number: {$journalTransaction->getNumber()}
"; // int|null Transaction number. When creating a new journal transaction, don't include this tag as the transaction number is determined by the system. When updating a journal transaction, the related transaction number should be provided. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($journalTransaction->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): " . Util::objectToStr($journalTransaction->getOffice()) . "
"; // string|null + echo "Origin: {$journalTransaction->getOrigin()}
"; // string|null The journal transaction origin. Read-only attribute. + echo "Period: {$journalTransaction->getPeriod()}
"; // string|null Period in YYYY/PP format. If this tag is not included or if it is left empty, the period is determined by the system based on the provided transaction date. + echo "RaiseWarning (bool): {$journalTransaction->getRaiseWarning()}
"; // bool|null Should warnings be given true or not false? Default true. + echo "RaiseWarning (string): " . Util::formatBoolean($journalTransaction->getRaiseWarning()) . "
"; // string|null + echo "Regime: {$journalTransaction->getRegime()}
"; // Regime|null Type of regime. You can post transactions as 'Fiscal', 'Commercial', 'Economic' or 'Generic'. The default regime is 'Generic'. 'Generic' means that the transaction is visible for all regimes. + echo "Result: {$journalTransaction->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + + $journalTransactionLines = $journalTransaction->getLines(); // array|null Array of JournalTransactionLine objects. + + foreach ($journalTransactionLines as $key => $journalTransactionLine) { + echo "JournalTransactionLine {$key}
"; + + echo "Baseline: {$journalTransactionLine->getBaseline()}
"; // int|null Only if line type is vat. The value of the baseline tag is a reference to the line ID of the VAT rate. + echo "BaseValue (\\Money\\Money):
" . print_r($journalTransactionLine->getBaseValue(), true) . "

"; // Money|null Amount in the base currency. + echo "BaseValue (string): " . Util::formatMoney($journalTransactionLine->getBaseValue()) . "
"; // string|null + echo "BaseValueOpen (\\Money\\Money):
" . print_r($journalTransactionLine->getBaseValueOpen(), true) . "

"; // Money|null Only if line type is detail. The amount still owed in base currency. Read-only attribute. + echo "BaseValueOpen (string): " . Util::formatMoney($journalTransactionLine->getBaseValueOpen()) . "
"; // string|null + echo "Comment: {$journalTransactionLine->getComment()}
"; // string|null Comment set on the transaction line. + echo "CurrencyDate (\\DateTimeInterface):
" . print_r($journalTransactionLine->getCurrencyDate(), true) . "

"; // DateTimeInterface|null Only if line type is detail. The line date. Only allowed if the line date in the journal book is set to Allowed or Mandatory. + echo "CurrencyDate (string): " . Util::formatDate($journalTransactionLine->getCurrencyDate()) . "
"; // string|null + echo "DebitCredit: {$journalTransactionLine->getDebitCredit()}
"; // DebitCredit|null The debit/credit indicator of the journal transaction line. + echo "Description: {$journalTransactionLine->getDescription()}
"; // string|null Description of the transaction line. + echo "DestOffice (\\PhpTwinfield\\Office):
" . print_r($journalTransactionLine->getDestOffice(), true) . "

"; // Office|null Office code. Used for inter company transactions – here you define in which company the transaction line should be posted. + echo "DestOffice (string): " . Util::objectToStr($journalTransactionLine->getDestOffice()) . "
"; // string|null + echo "Dim1:
" . print_r($journalTransactionLine->getDim1(), true) . "

"; // object|null If line type = detail the journal balance account or profit and loss account. + echo "Dim1 (string): " . Util::objectToStr($journalTransactionLine->getDim1()) . "
"; // string|null If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account will be taken as entered at the VAT code in Twinfield. + echo "Dim2:
" . print_r($journalTransactionLine->getDim2(), true) . "

"; // object|null If line type = detail the customer or supplier or the cost center or empty. + echo "Dim2 (string): " . Util::objectToStr($journalTransactionLine->getDim2()) . "
"; // string|null If line type = vat empty. + echo "Dim3:
" . print_r($journalTransactionLine->getDim2(), true) . "

"; // object|null If line type = detail the project or asset or empty. + echo "Dim3 (string): " . Util::objectToStr($journalTransactionLine->getDim3()) . "
"; // string|null If line type = vat empty. + echo "FreeChar: {$journalTransactionLine->getFreeChar()}
"; // string|null Free character field. + echo "ID: {$journalTransactionLine->getID()}
"; // int|null Line ID. + echo "InvoiceNumber: {$journalTransactionLine->getInvoiceNumber()}
"; // string|null Invoice number. Only if line type is detail. + echo "LineType: {$journalTransactionLine->getLineType()}
"; // LineType|null Line type. + echo "MatchLevel: {$journalTransactionLine->getMatchLevel()}
"; // int|null Only if line type is detail. The level of the matchable dimension. Read-only attribute. + echo "MatchStatus: {$journalTransactionLine->getMatchStatus()}
"; // MatchStatus|null Payment status of the journal transaction. If line type vat always notmatchable. Read-only attribute. + + if ($journalTransactionLine->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($journalTransactionLine->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "PerformanceCountry (\\PhpTwinfield\\Country):
" . print_r($journalTransactionLine->getPerformanceCountry(), true) . "

"; // Country|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The ISO country codes are used. If not added to the request, by default the country code of the customer will be taken. + echo "PerformanceCountry (string): " . Util::objectToStr($journalTransactionLine->getPerformanceCountry()) . "
"; // string|null + echo "PerformanceDate (\\DateTimeInterface):
" . print_r($journalTransactionLine->getPerformanceDate(), true) . "

"; // DateTimeInterface|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code but only if performancetype is services. + echo "PerformanceDate (string): " . Util::formatDate($journalTransactionLine->getPerformanceDate()) . "
"; // string|null + echo "PerformanceType: {$journalTransactionLine->getPerformanceType()}
"; // PerformanceType|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The performance type. + echo "PerformanceVatNumber: {$journalTransactionLine->getPerformanceVatNumber()}
"; // string|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. If not added to the request, by default the VAT number of the customer will be taken. + echo "Rate: {$journalTransactionLine->getRate()}
"; // float|null The exchange rate used for the calculation of the base amount. + echo "Reference (\\PhpTwinfield\\MatchReference):
" . print_r($journalTransactionLine->getReference(), true) . "

"; // MatchReference|null Match reference + echo "Relation: {$journalTransactionLine->getRelation()}
"; // int|null Only if line type is detail. Read-only attribute. + echo "RepRate: {$journalTransactionLine->getRepRate()}
"; // float|null The exchange rate used for the calculation of the reporting amount. + echo "RepValue (\\Money\\Money):
" . print_r($journalTransactionLine->getRepValue(), true) . "

"; // Money|null Amount in the reporting currency. + echo "RepValue (string): " . Util::formatMoney($journalTransactionLine->getRepValue()) . "
"; // string|null + echo "RepValueOpen (\\Money\\Money):
" . print_r($journalTransactionLine->getRepValueOpen(), true) . "

"; // Money|null Only if line type is detail. The amount still owed in reporting currency. Read-only attribute. + echo "RepValueOpen (string): " . Util::formatMoney($journalTransactionLine->getRepValueOpen()) . "
"; // string|null + echo "Result: {$journalTransactionLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "SignedValue (\\Money\\Money):
" . print_r($journalTransactionLine->getSignedValue(), true) . "

"; // Money|null + echo "SignedValue (string): " . Util::formatMoney($journalTransactionLine->getSignedValue()) . "
"; // string|null + echo "Value (\\Money\\Money):
" . print_r($journalTransactionLine->getValue(), true) . "

"; // Money|null If line type = detail amount without VAT. If line type = vat VAT amount. + echo "Value (string): " . Util::formatMoney($journalTransactionLine->getValue()) . "
"; // string|null + echo "VatBaseTurnover (\\Money\\Money):
" . print_r($journalTransactionLine->getVatBaseTurnover(), true) . "

"; // Money|null Only if line type is vat. Amount on which VAT was calculated in base currency. + echo "VatBaseTurnover (string): " . Util::formatMoney($journalTransactionLine->getVatBaseTurnover()) . "
"; // string|null + echo "VatBaseValue (\\Money\\Money):
" . print_r($journalTransactionLine->getVatBaseValue(), true) . "

"; // Money|null Only if line type is detail. VAT amount in base currency. + echo "VatBaseValue (string): " . Util::formatMoney($journalTransactionLine->getVatBaseValue()) . "
"; // string|null + echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($journalTransactionLine->getVatCode(), true) . "

"; // VatCode|null Only if line type is detail or vat. VAT code. + echo "VatCode (string): " . Util::objectToStr($journalTransactionLine->getVatCode()) . "
"; // string|null + echo "VatRepTurnover (\\Money\\Money):
" . print_r($journalTransactionLine->getVatRepTurnover(), true) . "

"; // Money|null Only if line type is vat. Amount on which VAT was calculated in reporting currency. + echo "VatRepTurnover (string): " . Util::formatMoney($journalTransactionLine->getVatRepTurnover()) . "
"; // string|null + echo "VatRepValue (\\Money\\Money):
" . print_r($journalTransactionLine->getVatRepValue(), true) . "

"; // Money|null Only if line type is detail. VAT amount in reporting currency. + echo "VatRepValue (string): " . Util::formatMoney($journalTransactionLine->getVatRepValue()) . "
"; // string|null + echo "VatTurnover (\\Money\\Money):
" . print_r($journalTransactionLine->getVatTurnover(), true) . "

"; // Money|null Only if line type is vat. Amount on which VAT was calculated in the currency of the journal transaction. + echo "VatTurnover (string): " . Util::formatMoney($journalTransactionLine->getVatTurnover()) . "
"; // string|null + echo "VatValue (\\Money\\Money):
" . print_r($journalTransactionLine->getVatValue(), true) . "

"; // Money|null Only if line type is detail. VAT amount in the currency of the journal transaction. + echo "VatValue (string): " . Util::formatMoney($journalTransactionLine->getVatValue()) . "
"; // string|null + } +} + +// Copy an existing JournalTransaction to a new entity +if ($executeCopy) { + try { + $journalTransaction = $transactionApiConnector->get(\PhpTwinfield\JournalTransaction::class, "MEMO", 201900003, $office); + } catch (ResponseException $e) { + $journalTransaction = $e->getReturnedObject(); + } + + $journalTransaction->setNumber(null); + + //Optional, but recommended so your copy is not posted to final immediately + $journalTransaction->setDestiny(\PhpTwinfield\Enums\Destiny::TEMPORARY()); + + try { + $journalTransactionCopy = $transactionApiConnector->send($journalTransaction); + } catch (ResponseException $e) { + $journalTransactionCopy = $e->getReturnedObject(); + } + + echo "
";
+    print_r($journalTransactionCopy);
+    echo "
"; + + echo "Result of copy process: {$journalTransactionCopy->getResult()}
"; + echo "Number of copied JournalTransaction: {$journalTransactionCopy->getNumber()}
"; +} + +// Create a new JournalTransaction from scratch, alternatively read an existing JournalTransaction as shown above and than modify the values in the same way as shown below +if ($executeNew) { + $journalTransaction = new \PhpTwinfield\JournalTransaction; + + // Required values for creating a new JournalTransaction + $journalTransaction->setCode('MEMO'); // string|null Transaction type code. + $currency = new \PhpTwinfield\Currency; + $currency->setCode('EUR'); + $journalTransaction->setCurrency($currency); // Currency|null Currency code. + //$journalTransaction->setCurrency(\PhpTwinfield\Currency::fromCode("EUR")); // string|null + $journalTransaction->setDestiny(\PhpTwinfield\Enums\Destiny::TEMPORARY()); // Destiny|null Attribute to indicate the destiny of the journal transaction. Only used in the request XML. temporary = journal transaction will be saved as provisional. + //$journalTransaction->setDestiny(\PhpTwinfield\Enums\Destiny::FINAL()); // Destiny|null final = journal transaction will be saved as final. + $journalTransaction->setOffice($office); // Office|null Office code. + $journalTransaction->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null + + // Optional values for creating a new JournalTransaction + $journalTransaction->setAutoBalanceVat(true); // bool|null Should VAT be rounded true or not false? Rounding will only be done with a maximum of two cents. + $date = \DateTime::createFromFormat('d-m-Y', '01-09-2019'); + $journalTransaction->setDate($date); // DateTimeInterface|null Transaction date. Optionally, it is possible to suppress warnings about 'date out of range for the given period' by adding the raisewarning attribute and set its value to false. + $journalTransaction->setDate(Util::parseDate("20190901")); // string|null This overwrites the value of the raisewarning attribute as set on the root element. + $journalTransaction->setDateRaiseWarning(false); // bool|null + //$journalTransaction->setFreeText1('Example FreeText 1'); // string|null Free text field 1 as entered on the transaction type. + //$journalTransaction->setFreeText2('Example FreeText 2'); // string|null Free text field 2 as entered on the transaction type. + //$journalTransaction->setFreeText3('Example FreeText 3'); // string|null Free text field 3 as entered on the transaction type. + //$journalTransaction->setNumber(201900011); // int|null Transaction number. When creating a new journal transaction, don't include this tag as the transaction number is determined by the system. When updating a journal transaction, the related transaction number should be provided. + //$journalTransaction->setPeriod("2019/07"); // string|null Period in YYYY/PP format. If this tag is not included or if it is left empty, the period is determined by the system based on the provided transaction date. + $journalTransaction->setRaiseWarning(true); // bool|null Should warnings be given true or not false? Default true. + //$journalTransaction->setRegime(\PhpTwinfield\Enums\Regime::GENERIC()); // Regime|null Type of regime. You can post transactions as 'Fiscal', 'Commercial', 'Economic' or 'Generic'. The default regime is 'Generic'. 'Generic' means that the transaction is visible for all regimes. + + // The minimum amount of JournalTransactionLines linked to an JournalTransaction object is 2 + $journalTransactionLine1 = new \PhpTwinfield\JournalTransactionLine; + $journalTransactionLine1->setLineType(\PhpTwinfield\Enums\LineType::DETAIL()); // LineType|null Line type. + + $journalTransactionLine1->setBaseValue(\Money\Money::EUR(10000)); // Money|null Amount in the base currency. + $journalTransactionLine1->setDescription("Example Description on line with ID 1"); // string|null Description of the transaction line. + $dim1 = new \PhpTwinfield\GeneralLedger; + $dim1->setCode('2500'); + $journalTransactionLine1->setDim1($dim1); // object|null If line type = detail the journal balance account or profit and loss account. + $journalTransactionLine1->setDim1(\PhpTwinfield\GeneralLedger::fromCode('2500')); // string|null If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account will be taken as entered at the VAT code in Twinfield. + $journalTransactionLine1->setID(1); // int|null Line ID. + $journalTransactionLine1->setValue(\Money\Money::EUR(10000)); // Money|null If line type = detail amount without VAT. If line type = vat VAT amount. + + $journalTransaction->addLine($journalTransactionLine1); // JournalTransactionLine Add a JournalTransactionLine object to the JournalTransaction object + + $journalTransactionLine2 = new \PhpTwinfield\JournalTransactionLine; + $journalTransactionLine2->setLineType(\PhpTwinfield\Enums\LineType::DETAIL()); // LineType|null Line type. + + $journalTransactionLine2->setBaseValue(\Money\Money::EUR(10000)); // Money|null Amount in the base currency. + $journalTransactionLine2->setDescription("Example Description on line with ID 2"); // string|null Description of the transaction line. + $dim1 = new \PhpTwinfield\GeneralLedger; + $dim1->setCode('2500'); + $journalTransactionLine2->setDim1($dim1); // object|null If line type = detail the journal balance account or profit and loss account. + $journalTransactionLine2->setDim1(\PhpTwinfield\GeneralLedger::fromCode('2500')); // string|null If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account will be taken as entered at the VAT code in Twinfield. + $journalTransactionLine2->setID(2); // int|null Line ID. + $journalTransactionLine2->setValue(\Money\Money::EUR(-10000)); // Money|null If line type = detail amount without VAT. If line type = vat VAT amount. + + //$journalTransactionLine2->setInvoiceNumber(201900001); // string|null Invoice number. Only if line type is detail. + //$journalTransactionLine2->setComment('Example Comments'); // string|null Comment set on the transaction line. + $currencyDate = \DateTime::createFromFormat('d-m-Y', '01-09-2019'); + //$journalTransaction->setCurrencyDate($currencyDate); // DateTimeInterface|null Only if line type is detail. The line date. Only allowed if the line date in the journal book is set to Allowed or Mandatory. + //$journalTransaction->setCurrencyDate(Util::parseDate("20190901")); // string|null + $destOffice = new \PhpTwinfield\Office; + $destOffice->setCode('1234'); + //$journalTransaction->setDestOffice($destOffice); // Office|null Office code. Used for inter company transactions – here you define in which company the transaction line should be posted. + //$journalTransaction->setDestOffice(\PhpTwinfield\Office::fromCode('1234')); // string|null + $dim2 = new \PhpTwinfield\Customer; + $dim2->setCode('1001'); + //$journalTransactionLine2->setDim2($dim2); // object|null If line type = detail the customer or supplier or the cost center or empty. If line type = vat empty. + //$journalTransactionLine2->setDim2(\PhpTwinfield\Customer::fromCode('1001')); // string|null + $dim3 = new \PhpTwinfield\Project; + $dim3->setCode('P0000'); + //$journalTransactionLine2->setDim3($dim3); // object|null If line type = detail the project or asset or empty. If line type = vat empty. + //$journalTransactionLine2->setDim3(\PhpTwinfield\Project::fromCode('P0000')); // string|null + //$journalTransactionLine2->setFreeChar('A'); // string|null Free character field. + $performanceCountry = new \PhpTwinfield\Country; + $performanceCountry->setCode('NL'); + //$journalTransactionLine2->setPerformanceCountry($performanceCountry); // Country|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The ISO country codes are used. If not added to the request, by default the country code of the customer will be taken. + //$journalTransactionLine2->setPerformanceCountry(\PhpTwinfield\Country::fromCode('NL')); // string|null + $performanceDate = \DateTime::createFromFormat('d-m-Y', '01-09-2019'); + //$journalTransactionLine2->setPerformanceDate($performanceDate); // DateTimeInterface|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code but only if performancetype is services. + //$journalTransactionLine2->setPerformanceDate(Util::parseDate("20190901")); // string|null + //$journalTransactionLine2->setPerformanceType(\PhpTwinfield\Enums\PerformanceType::SERVICES()); // PerformanceType|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The performance type. + //$journalTransactionLine2->setPerformanceVatNumber('NL1234567890B01'); // string|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. If not added to the request, by default the VAT number of the customer will be taken. + //$journalTransactionLine2->setRepValue(\Money\Money::EUR(-10000)); // Money|null Amount in the reporting currency. + //$journalTransactionLine2->setRate(1); // float|null The exchange rate used for the calculation of the base amount. + //$journalTransactionLine2->setRepRate(1); // float|null The exchange rate used for the calculation of the reporting amount. + //$journalTransactionLine2->setVatBaseValue(\Money\Money::EUR(-10000)); // Money|null Only if line type is detail. VAT amount in base currency. + $vatCode = new \PhpTwinfield\VatCode; + $vatCode->setCode('VN'); + //$journalTransactionLine2->setVatCode($vatCode); // VatCode|null Only if line type is detail or vat. VAT code. + //$journalTransactionLine2->setVatCode(\PhpTwinfield\VatCode::fromCode('VN')); // string|null + //$journalTransactionLine2->setVatRepValue(\Money\Money::EUR(-10000)); // Money|null Only if line type is detail. VAT amount in reporting currency. + //$journalTransactionLine2->setVatValue(\Money\Money::EUR(-10000)); // Money|null Only if line type is detail. VAT amount in the currency of the journal transaction. + + $journalTransaction->addLine($journalTransactionLine2); + + //$journalTransactionLine3 = new \PhpTwinfield\JournalTransactionLine; + //$journalTransactionLine3->setLineType(\PhpTwinfield\Enums\LineType::VAT()); // LineType|null Line type. + //$journalTransactionLine3->setBaseline(1); // int|null Only if line type is vat. The value of the baseline tag is a reference to the line ID of the VAT rate. + //$journalTransactionLine3->setVatBaseTurnover(\Money\Money::EUR(-10000)); // Money|null Only if line type is vat. Amount on which VAT was calculated in base currency. + //$journalTransactionLine3->setVatRepTurnover(\Money\Money::EUR(-10000)); // Money|null Only if line type is vat. Amount on which VAT was calculated in reporting currency. + //$journalTransactionLine3->setVatTurnover(\Money\Money::EUR(-10000)); // Money|null Only if line type is vat. Amount on which VAT was calculated in the currency of the journal transaction. + + try { + $journalTransactionNew = $transactionApiConnector->send($journalTransaction); + } catch (ResponseException $e) { + $journalTransactionNew = $e->getReturnedObject(); + } + + echo "
";
+    print_r($journalTransactionNew);
+    echo "
"; + + echo "Result of creation process: {$journalTransactionNew->getResult()}
"; + echo "Number of new JournalTransaction: {$journalTransactionNew->getNumber()}
"; +} + +// Delete a BrankTransaction based off the passed in office, code, number and given reason +if ($executeDelete) { + $bookingReference = new \PhpTwinfield\BookingReference($office, 'MEMO', 201900005); + + try { + $journalTransactionDeleted = $transactionApiConnector->delete($bookingReference, 'Example reason'); + } catch (ResponseException $e) { + $journalTransactionDeleted = $e->getReturnedObject(); + } + + echo "
";
+    print_r($journalTransactionDeleted);
+    echo "
"; +} \ No newline at end of file diff --git a/examples/PurchaseTransaction.php b/examples/PurchaseTransaction.php new file mode 100644 index 00000000..0186475d --- /dev/null +++ b/examples/PurchaseTransaction.php @@ -0,0 +1,347 @@ +get(\PhpTwinfield\PurchaseTransaction::class, "INK", 201900003, $office); + } catch (ResponseException $e) { + $purchaseTransaction = $e->getReturnedObject(); + } + + echo "
";
+    print_r($purchaseTransaction);
+    echo "
"; + + echo "PurchaseTransaction
"; + echo "AutoBalanceVat (bool): {$purchaseTransaction->getAutoBalanceVat()}
"; // bool|null Should VAT be rounded true or not false? Rounding will only be done with a maximum of two cents. + echo "AutoBalanceVat (string): " . Util::formatBoolean($purchaseTransaction->getAutoBalanceVat()) . "
"; // string|null + echo "BookingReference (\\PhpTwinfield\\BookingReference):
" . print_r($purchaseTransaction->getBookingReference(), true) . "

"; // BookingReference|null The Booking reference + echo "Code: {$purchaseTransaction->getCode()}
"; // string|null Transaction type code. + echo "Currency (\\PhpTwinfield\\Currency):
" . print_r($purchaseTransaction->getCurrency(), true) . "

"; // Currency|null Currency code. + echo "Currency (string): " . Util::objectToStr($purchaseTransaction->getCurrency()) . "
"; // string|null + echo "Date (\\DateTimeInterface):
" . print_r($purchaseTransaction->getDate(), true) . "

"; // DateTimeInterface|null Transaction date. + echo "Date (string): " . Util::formatDate($purchaseTransaction->getDate()) . "
"; // string|null + echo "DateRaiseWarning (bool): {$purchaseTransaction->getDateRaiseWarning()}
"; // bool|null Optionally, it is possible to suppress warnings about 'date out of range for the given period' by adding the raisewarning attribute and set its value to false. + echo "DateRaiseWarning (string): {$purchaseTransaction->getDateRaiseWarningToString()}
"; // string|null This overwrites the value of the raisewarning attribute as set on the root element. + echo "Destiny: {$purchaseTransaction->getDestiny()}
"; // Destiny|null Attribute to indicate the destiny of the purchase transaction. Only used in the request XML. temporary = purchase transaction will be saved as provisional. final = purchase transaction will be saved as final + echo "DueDate (\\DateTimeInterface):
" . print_r($purchaseTransaction->getDueDate(), true) . "

"; // DateTimeInterface|null Due date. + echo "DueDate (string): " . Util::formatDate($purchaseTransaction->getDueDate()) . "
"; // string|null + echo "FreeText1: {$purchaseTransaction->getFreeText1()}
"; // string|null Free text field 1 as entered on the transaction type. + echo "FreeText2: {$purchaseTransaction->getFreeText2()}
"; // string|null Free text field 2 as entered on the transaction type. + echo "FreeText3: {$purchaseTransaction->getFreeText3()}
"; // string|null Free text field 3 as entered on the transaction type. + echo "InputDate (\\DateTimeInterface):
" . print_r($purchaseTransaction->getInputDate(), true) . "

"; // DateTimeInterface|null The date/time on which the transaction was created. Read-only attribute. + echo "InputDate (string): " . Util::formatDate($purchaseTransaction->getInputDate()) . "
"; // string|null + echo "InvoiceNumber: {$purchaseTransaction->getInvoiceNumber()}
"; // string|null Invoice number. + echo "InvoiceNumberRaiseWarning (bool): {$purchaseTransaction->getInvoiceNumberRaiseWarning()}
"; // bool|null Optionally, it is possible to suppress warnings about 'double invoice numbers' by adding the raisewarning attribute and set its value to false. + echo "InvoiceNumberRaiseWarning (string): {$purchaseTransaction->getInvoiceNumberRaiseWarningToString()}
"; // string|null This overwrites the value of the raisewarning attribute as set on the root element. + + if ($purchaseTransaction->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($purchaseTransaction->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "ModificationDate (\\DateTimeInterface):
" . print_r($purchaseTransaction->getModificationDate(), true) . "

"; // DateTimeInterface|null The date/time on which the purchase transaction was modified the last time. Read-only attribute. + echo "ModificationDate (string): " . Util::formatDate($purchaseTransaction->getModificationDate()) . "
"; // string|null + echo "Number: {$purchaseTransaction->getNumber()}
"; // int|null Transaction number. When creating a new purchase transaction, don't include this tag as the transaction number is determined by the system. When updating a purchase transaction, the related transaction number should be provided. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($purchaseTransaction->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): " . Util::objectToStr($purchaseTransaction->getOffice()) . "
"; // string|null + echo "Origin: {$purchaseTransaction->getOrigin()}
"; // string|null The purchase transaction origin. Read-only attribute. + echo "PaymentReference: {$purchaseTransaction->getPaymentReference()}
"; // string|null Payment reference of the transaction. If payment reference is not specified, the paymentreference section must be omitted + echo "Period: {$purchaseTransaction->getPeriod()}
"; // string|null Period in YYYY/PP format. If this tag is not included or if it is left empty, the period is determined by the system based on the provided transaction date. + echo "RaiseWarning (bool): {$purchaseTransaction->getRaiseWarning()}
"; // bool|null Should warnings be given true or not false? Default true. + echo "RaiseWarning (string): " . Util::formatBoolean($purchaseTransaction->getRaiseWarning()) . "
"; // string|null + echo "Result: {$purchaseTransaction->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + + $purchaseTransactionLines = $purchaseTransaction->getLines(); // array|null Array of PurchaseTransactionLine objects. + + foreach ($purchaseTransactionLines as $key => $purchaseTransactionLine) { + echo "PurchaseTransactionLine {$key}
"; + + echo "Baseline: {$purchaseTransactionLine->getBaseline()}
"; // int|null Only if line type is vat. The value of the baseline tag is a reference to the line ID of the VAT rate. + echo "BaseValue (\\Money\\Money):
" . print_r($purchaseTransactionLine->getBaseValue(), true) . "

"; // Money|null Amount in the base currency. + echo "BaseValue (string): " . Util::formatMoney($purchaseTransactionLine->getBaseValue()) . "
"; // string|null + echo "BaseValueOpen (\\Money\\Money):
" . print_r($purchaseTransactionLine->getBaseValueOpen(), true) . "

"; // Money|null Only if line type is total. The amount still to be paid in base currency. Read-only attribute. + echo "BaseValueOpen (string): " . Util::formatMoney($purchaseTransactionLine->getBaseValueOpen()) . "
"; // string|null + echo "Comment: {$purchaseTransactionLine->getComment()}
"; // string|null Comment set on the transaction line. + echo "DebitCredit: {$purchaseTransactionLine->getDebitCredit()}
"; // DebitCredit|null If line type = total. In case of a 'normal' purchase transaction credit. In case of a credit purchase transaction debit. If line type = detail or vat. In case of a 'normal' purchase transaction debit. In case of a credit purchase transaction credit. + echo "Description: {$purchaseTransactionLine->getDescription()}
"; // string|null Description of the transaction line. + echo "DestOffice (\\PhpTwinfield\\Office):
" . print_r($purchaseTransactionLine->getDestOffice(), true) . "

"; // Office|null Only if line type is detail. Office code. Used for inter company transactions – here you define in which company the transaction line should be posted. + echo "DestOffice (string): " . Util::objectToStr($purchaseTransactionLine->getDestOffice()) . "
"; // string|null + echo "Dim1:
" . print_r($purchaseTransactionLine->getDim1(), true) . "

"; // object|null If line type = total the accounts payable balance account. When dim1 is omitted, by default the general ledger account will be taken as entered at the supplier in Twinfield. If line type = detail the profit and loss account. + echo "Dim1 (string): " . Util::objectToStr($purchaseTransactionLine->getDim1()) . "
"; // string|null If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account will be taken as entered at the VAT code in Twinfield. + echo "Dim2:
" . print_r($purchaseTransactionLine->getDim2(), true) . "

"; // object|null If line type = total the account payable. If line type = detail the cost center or empty. + echo "Dim2 (string): " . Util::objectToStr($purchaseTransactionLine->getDim2()) . "
"; // string|null If line type = vat the cost center or empty. + echo "Dim3:
" . print_r($purchaseTransactionLine->getDim2(), true) . "

"; // object|null If line type = total empty. If line type = detail the project or asset or empty. + echo "Dim3 (string): " . Util::objectToStr($purchaseTransactionLine->getDim3()) . "
"; // string|null If line type = vat the project or asset or empty. + echo "FreeChar: {$purchaseTransactionLine->getFreeChar()}
"; // string|null Free character field. If line type is total and filled with N the purchase invoice is excluded from payment runs done in Twinfield. + echo "ID: {$purchaseTransactionLine->getID()}
"; // int|null Line ID. + echo "LineType: {$purchaseTransactionLine->getLineType()}
"; // LineType|null Line type. + echo "MatchDate (\\DateTimeInterface):
" . print_r($purchaseTransactionLine->getMatchDate(), true) . "

"; // DateTimeInterface|null Only if line type is total. The date on which the purchase invoice is matched. Read-only attribute. + echo "MatchDate (string): " . Util::formatDate($purchaseTransactionLine->getMatchDate()) . "
"; // string|null + echo "MatchLevel: {$purchaseTransactionLine->getMatchLevel()}
"; // int|null Only if line type is total. The level of the matchable dimension. Read-only attribute. + echo "MatchStatus: {$purchaseTransactionLine->getMatchStatus()}
"; // MatchStatus|null Payment status of the purchase transaction. If line type detail or vat always notmatchable. Read-only attribute. + + if ($purchaseTransactionLine->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($purchaseTransactionLine->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "Rate: {$purchaseTransactionLine->getRate()}
"; // float|null The exchange rate used for the calculation of the base amount. + echo "Reference (\\PhpTwinfield\\MatchReference):
" . print_r($purchaseTransactionLine->getReference(), true) . "

"; // MatchReference|null Match reference + echo "Relation: {$purchaseTransactionLine->getRelation()}
"; // int|null Only if line type is total. Read-only attribute. + echo "RepRate: {$purchaseTransactionLine->getRepRate()}
"; // float|null The exchange rate used for the calculation of the reporting amount. + echo "RepValue (\\Money\\Money):
" . print_r($purchaseTransactionLine->getRepValue(), true) . "

"; // Money|null Amount in the reporting currency. + echo "RepValue (string): " . Util::formatMoney($purchaseTransactionLine->getRepValue()) . "
"; // string|null + echo "RepValueOpen (\\Money\\Money):
" . print_r($purchaseTransactionLine->getRepValueOpen(), true) . "

"; // Money|null Only if line type is total. The amount still to be paid in reporting currency. Read-only attribute. + echo "RepValueOpen (string): " . Util::formatMoney($purchaseTransactionLine->getRepValueOpen()) . "
"; // string|null + echo "Result: {$purchaseTransactionLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "SignedValue (\\Money\\Money):
" . print_r($purchaseTransactionLine->getSignedValue(), true) . "

"; // Money|null + echo "SignedValue (string): " . Util::formatMoney($purchaseTransactionLine->getSignedValue()) . "
"; // string|null + echo "Value (\\Money\\Money):
" . print_r($purchaseTransactionLine->getValue(), true) . "

"; // Money|null If line type = total amount including VAT. If line type = detail amount without VAT. If line type = vat VAT amount. + echo "Value (string): " . Util::formatMoney($purchaseTransactionLine->getValue()) . "
"; // string|null + echo "ValueOpen (\\Money\\Money):
" . print_r($purchaseTransactionLine->getValueOpen(), true) . "

"; // Money|null Only if line type is total. The amount still to be paid in the currency of the purchase transaction. Read-only attribute. + echo "ValueOpen (string): " . Util::formatMoney($purchaseTransactionLine->getValueOpen()) . "
"; // string|null + echo "VatBaseTotal (\\Money\\Money):
" . print_r($purchaseTransactionLine->getVatBaseTotal(), true) . "

"; // Money|null Only if line type is total. The total VAT amount in base currency. + echo "VatBaseTotal (string): " . Util::formatMoney($purchaseTransactionLine->getVatBaseTotal()) . "
"; // string|null + echo "VatBaseTurnover (\\Money\\Money):
" . print_r($purchaseTransactionLine->getVatBaseTurnover(), true) . "

"; // Money|null Only if line type is vat. Amount on which VAT was calculated in base currency. + echo "VatBaseTurnover (string): " . Util::formatMoney($purchaseTransactionLine->getVatBaseTurnover()) . "
"; // string|null + echo "VatBaseValue (\\Money\\Money):
" . print_r($purchaseTransactionLine->getVatBaseValue(), true) . "

"; // Money|null Only if line type is detail. VAT amount in base currency. + echo "VatBaseValue (string): " . Util::formatMoney($purchaseTransactionLine->getVatBaseValue()) . "
"; // string|null + echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($purchaseTransactionLine->getVatCode(), true) . "

"; // VatCode|null Only if line type is detail or vat. VAT code. + echo "VatCode (string): " . Util::objectToStr($purchaseTransactionLine->getVatCode()) . "
"; // string|null + echo "VatRepTotal (\\Money\\Money):
" . print_r($purchaseTransactionLine->getVatRepTotal(), true) . "

"; // Money|null Only if line type is total. The total VAT amount in reporting currency. + echo "VatRepTotal (string): " . Util::formatMoney($purchaseTransactionLine->getVatRepTotal()) . "
"; // string|null + echo "VatRepTurnover (\\Money\\Money):
" . print_r($purchaseTransactionLine->getVatRepTurnover(), true) . "

"; // Money|null Only if line type is vat. Amount on which VAT was calculated in reporting currency. + echo "VatRepTurnover (string): " . Util::formatMoney($purchaseTransactionLine->getVatRepTurnover()) . "
"; // string|null + echo "VatRepValue (\\Money\\Money):
" . print_r($purchaseTransactionLine->getVatRepValue(), true) . "

"; // Money|null Only if line type is detail. VAT amount in reporting currency. + echo "VatRepValue (string): " . Util::formatMoney($purchaseTransactionLine->getVatRepValue()) . "
"; // string|null + echo "VatTotal (\\Money\\Money):
" . print_r($purchaseTransactionLine->getVatTotal(), true) . "

"; // Money|null Only if line type is total. The total VAT amount in the currency of the purchase transaction. + echo "VatTotal (string): " . Util::formatMoney($purchaseTransactionLine->getVatTotal()) . "
"; // string|null + echo "VatTurnover (\\Money\\Money):
" . print_r($purchaseTransactionLine->getVatTurnover(), true) . "

"; // Money|null Only if line type is vat. Amount on which VAT was calculated in the currency of the purchase transaction. + echo "VatTurnover (string): " . Util::formatMoney($purchaseTransactionLine->getVatTurnover()) . "
"; // string|null + echo "VatValue (\\Money\\Money):
" . print_r($purchaseTransactionLine->getVatValue(), true) . "

"; // Money|null Only if line type is detail. VAT amount in the currency of the purchase transaction. + echo "VatValue (string): " . Util::formatMoney($purchaseTransactionLine->getVatValue()) . "
"; // string|null + } +} + +// Copy an existing PurchaseTransaction to a new entity +if ($executeCopy) { + try { + $purchaseTransaction = $transactionApiConnector->get(\PhpTwinfield\PurchaseTransaction::class, "INK", 201900003, $office); + } catch (ResponseException $e) { + $purchaseTransaction = $e->getReturnedObject(); + } + + $purchaseTransaction->setNumber(null); + + //Optional, but recommended so your copy is not posted to final immediately + $purchaseTransaction->setDestiny(\PhpTwinfield\Enums\Destiny::TEMPORARY()); + + try { + $purchaseTransactionCopy = $transactionApiConnector->send($purchaseTransaction); + } catch (ResponseException $e) { + $purchaseTransactionCopy = $e->getReturnedObject(); + } + + echo "
";
+    print_r($purchaseTransactionCopy);
+    echo "
"; + + echo "Result of copy process: {$purchaseTransactionCopy->getResult()}
"; + echo "Number of copied PurchaseTransaction: {$purchaseTransactionCopy->getNumber()}
"; +} + +// Create a new PurchaseTransaction from scratch, alternatively read an existing PurchaseTransaction as shown above and than modify the values in the same way as shown below +if ($executeNew) { + $purchaseTransaction = new \PhpTwinfield\PurchaseTransaction; + + // Required values for creating a new PurchaseTransaction + $purchaseTransaction->setCode('INK'); // string|null Transaction type code. + $currency = new \PhpTwinfield\Currency; + $currency->setCode('EUR'); + $purchaseTransaction->setCurrency($currency); // Currency|null Currency code. + //$purchaseTransaction->setCurrency(\PhpTwinfield\Currency::fromCode("EUR")); // string|null + $purchaseTransaction->setDestiny(\PhpTwinfield\Enums\Destiny::TEMPORARY()); // Destiny|null Attribute to indicate the destiny of the purchase transaction. Only used in the request XML. + //$purchaseTransaction->setDestiny(\PhpTwinfield\Enums\Destiny::FINAL()); // Destiny|null temporary = purchase transaction will be saved as provisional. final = purchase transaction will be saved as final. + $purchaseTransaction->setInvoiceNumber(201900011); // string|null Invoice number. + $purchaseTransaction->setOffice($office); // Office|null Office code. + $purchaseTransaction->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null + + // Optional values for creating a new PurchaseTransaction + $purchaseTransaction->setAutoBalanceVat(true); // bool|null Should VAT be rounded true or not false? Rounding will only be done with a maximum of two cents. + $date = \DateTime::createFromFormat('d-m-Y', '01-09-2019'); + $purchaseTransaction->setDate($date); // DateTimeInterface|null Transaction date. Optionally, it is possible to suppress warnings about 'date out of range for the given period' by adding the raisewarning attribute and set its value to false. + $purchaseTransaction->setDate(Util::parseDate("20190901")); // string|null This overwrites the value of the raisewarning attribute as set on the root element. + $purchaseTransaction->setDateRaiseWarning(false); // bool|null + $dueDate = \DateTime::createFromFormat('d-m-Y', '01-10-2019'); + $purchaseTransaction->setDueDate($dueDate); // DateTimeInterface|null Due date. + $purchaseTransaction->setDueDate(Util::parseDate("20191001")); // string|null + //$purchaseTransaction->setFreeText1('Example FreeText 1'); // string|null Free text field 1 as entered on the transaction type. + //$purchaseTransaction->setFreeText2('Example FreeText 2'); // string|null Free text field 2 as entered on the transaction type. + //$purchaseTransaction->setFreeText3('Example FreeText 3'); // string|null Free text field 3 as entered on the transaction type. + $purchaseTransaction->setInvoiceNumberRaiseWarning(false); // bool|null Optionally, it is possible to suppress warnings about 'double invoice numbers' by adding the raisewarning attribute and set its value to false. This overwrites the value of the raisewarning attribute as set on the root element. + //$purchaseTransaction->setNumber(201900011); // int|null Transaction number. When creating a new purchase transaction, don't include this tag as the transaction number is determined by the system. When updating a purchase transaction, the related transaction number should be provided. + //$purchaseTransaction->setPeriod("2019/07"); // string|null Period in YYYY/PP format. If this tag is not included or if it is left empty, the period is determined by the system based on the provided transaction date. + $purchaseTransaction->setRaiseWarning(true); // bool|null Should warnings be given true or not false? Default true. + + // The minimum amount of PurchaseTransactionLines linked to an PurchaseTransaction object is 2 (1 total, 1 detail) + $purchaseTransactionLine1 = new \PhpTwinfield\PurchaseTransactionLine; + $purchaseTransactionLine1->setLineType(\PhpTwinfield\Enums\LineType::TOTAL()); // LineType|null Line type. + + $dim1 = new \PhpTwinfield\GeneralLedger; + $dim1->setCode('1600'); + $purchaseTransactionLine1->setDim1($dim1); // object|null If line type = total the accounts payable balance account. When dim1 is omitted, by default the general ledger account will be taken as entered at the supplier in Twinfield. If line type = detail the profit and loss account. + $purchaseTransactionLine1->setDim1(\PhpTwinfield\GeneralLedger::fromCode('1600')); // string|null If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account will be taken as entered at the VAT code in Twinfield. + $dim2 = new \PhpTwinfield\Supplier; + $dim2->setCode('2000'); + $purchaseTransactionLine1->setDim2($dim2); // object|null If line type = total the account payable. If line type = detail the cost center or empty. If line type = vat the cost center or empty. + $purchaseTransactionLine1->setDim2(\PhpTwinfield\Supplier::fromCode('2000')); // string|null + $purchaseTransactionLine1->setID(1); // int|null Line ID. + $purchaseTransactionLine1->setValue(\Money\Money::EUR(-10000)); // Money|null If line type = total amount including VAT. If line type = detail amount without VAT. If line type = vat VAT amount. + //$purchaseTransactionLine1->setVatBaseTotal(\Money\Money::EUR(-10000)); // Money|null Only if line type is total. The total VAT amount in base currency. + //$purchaseTransactionLine1->setVatRepTotal(\Money\Money::EUR(-10000)); // Money|null Only if line type is total. The total VAT amount in reporting currency. + //$purchaseTransactionLine1->setVatTotal(\Money\Money::EUR(-10000)); // Money|null Only if line type is total. The total VAT amount in the currency of the purchase transaction. + + $purchaseTransaction->addLine($purchaseTransactionLine1); // PurchaseTransactionLine Add a PurchaseTransactionLine object to the PurchaseTransaction object + + $purchaseTransactionLine2 = new \PhpTwinfield\PurchaseTransactionLine; + $purchaseTransactionLine2->setLineType(\PhpTwinfield\Enums\LineType::DETAIL()); // LineType|null Line type. + + $purchaseTransactionLine2->setBaseValue(\Money\Money::EUR(10000)); // Money|null Amount in the base currency. + $purchaseTransactionLine2->setDescription("Example Description on line with ID 2"); // string|null Description of the transaction line. + $dim1 = new \PhpTwinfield\GeneralLedger; + $dim1->setCode('2500'); + $purchaseTransactionLine2->setDim1($dim1); // object|null If line type = total the accounts payable balance account. When dim1 is omitted, by default the general ledger account will be taken as entered at the supplier in Twinfield. If line type = detail the profit and loss account. + $purchaseTransactionLine2->setDim1(\PhpTwinfield\GeneralLedger::fromCode('2500')); // string|null If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account will be taken as entered at the VAT code in Twinfield. + $purchaseTransactionLine2->setID(2); // int|null Line ID. + $purchaseTransactionLine2->setValue(\Money\Money::EUR(-10000)); // Money|null If line type = total amount including VAT. If line type = detail amount without VAT. If line type = vat VAT amount. + + //$purchaseTransactionLine2->setComment('Example Comments'); // string|null Comment set on the transaction line. + $destOffice = new \PhpTwinfield\Office; + $destOffice->setCode('1234'); + //$purchaseTransaction->setDestOffice($destOffice); // Office|null Only if line type is detail. Office code. Used for inter company transactions – here you define in which company the transaction line should be posted. + //$purchaseTransaction->setDestOffice(\PhpTwinfield\Office::fromCode('1234')); // string|null + $dim2 = new \PhpTwinfield\Customer; + $dim2->setCode('1001'); + //$purchaseTransactionLine2->setDim2($dim2); // object|null If line type = total the account payable. If line type = detail the cost center or empty. If line type = vat the cost center or empty. + //$purchaseTransactionLine2->setDim2(\PhpTwinfield\Customer::fromCode('1001')); // string|null + $dim3 = new \PhpTwinfield\Project; + $dim3->setCode('P0000'); + //$purchaseTransactionLine2->setDim3($dim3); // object|null If line type = total empty. If line type = detail the project or asset or empty. If line type = vat the project or asset or empty. + //$purchaseTransactionLine2->setDim3(\PhpTwinfield\Project::fromCode('P0000')); // string|null + //$purchaseTransactionLine2->setFreeChar('A'); // string|null Free character field. If line type is total and filled with N the purchase invoice is excluded from payment runs done in Twinfield. + $performanceCountry = new \PhpTwinfield\Country; + $performanceCountry->setCode('NL'); + //$purchaseTransactionLine2->setPerformanceCountry($performanceCountry); // Country|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The ISO country codes are used. If not added to the request, by default the country code of the customer will be taken. + //$purchaseTransactionLine2->setPerformanceCountry(\PhpTwinfield\Country::fromCode('NL')); // string|null + $performanceDate = \DateTime::createFromFormat('d-m-Y', '01-09-2019'); + //$purchaseTransactionLine2->setPerformanceDate($performanceDate); // DateTimeInterface|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code but only if performancetype is services. + //$purchaseTransactionLine2->setPerformanceDate(Util::parseDate("20190901")); // string|null + //$purchaseTransactionLine2->setPerformanceType(\PhpTwinfield\Enums\PerformanceType::SERVICES()); // PerformanceType|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The performance type. + //$purchaseTransactionLine2->setPerformanceVatNumber('NL1234567890B01'); // string|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. If not added to the request, by default the VAT number of the customer will be taken. + //$purchaseTransactionLine2->setRepValue(\Money\Money::EUR(-10000)); // Money|null Amount in the reporting currency. + //$purchaseTransactionLine2->setRate(1); // float|null The exchange rate used for the calculation of the base amount. + //$purchaseTransactionLine2->setRepRate(1); // float|null The exchange rate used for the calculation of the reporting amount. + //$purchaseTransactionLine2->setVatBaseValue(\Money\Money::EUR(-10000)); // Money|null Only if line type is detail. VAT amount in base currency. + $vatCode = new \PhpTwinfield\VatCode; + $vatCode->setCode('VN'); + //$purchaseTransactionLine2->setVatCode($vatCode); // VatCode|null Only if line type is detail or vat. VAT code. + //$purchaseTransactionLine2->setVatCode(\PhpTwinfield\VatCode::fromCode('VN')); // string|null + //$purchaseTransactionLine2->setVatRepValue(\Money\Money::EUR(-10000)); // Money|null Only if line type is detail. VAT amount in reporting currency. + //$purchaseTransactionLine2->setVatValue(\Money\Money::EUR(-10000)); // Money|null Only if line type is detail. VAT amount in the currency of the purchase transaction. + + $purchaseTransaction->addLine($purchaseTransactionLine2); + + //$purchaseTransactionLine3 = new \PhpTwinfield\PurchaseTransactionLine; + //$purchaseTransactionLine3->setLineType(\PhpTwinfield\Enums\LineType::VAT()); // LineType|null Line type. + //$purchaseTransactionLine3->setBaseline(1); // int|null Only if line type is vat. The value of the baseline tag is a reference to the line ID of the VAT rate. + //$purchaseTransactionLine3->setVatBaseTurnover(\Money\Money::EUR(-10000)); // Money|null Only if line type is vat. Amount on which VAT was calculated in base currency. + //$purchaseTransactionLine3->setVatRepTurnover(\Money\Money::EUR(-10000)); // Money|null Only if line type is vat. Amount on which VAT was calculated in reporting currency. + //$purchaseTransactionLine3->setVatTurnover(\Money\Money::EUR(-10000)); // Money|null Only if line type is vat. Amount on which VAT was calculated in the currency of the purchase transaction. + + try { + $purchaseTransactionNew = $transactionApiConnector->send($purchaseTransaction); + } catch (ResponseException $e) { + $purchaseTransactionNew = $e->getReturnedObject(); + } + + echo "
";
+    print_r($purchaseTransactionNew);
+    echo "
"; + + echo "Result of creation process: {$purchaseTransactionNew->getResult()}
"; + echo "Number of new PurchaseTransaction: {$purchaseTransactionNew->getNumber()}
"; +} + +// Delete a BrankTransaction based off the passed in office, code, number and given reason +if ($executeDelete) { + $bookingReference = new \PhpTwinfield\BookingReference($office, 'INK', 201900004); + + try { + $purchaseTransactionDeleted = $transactionApiConnector->delete($bookingReference, 'Example reason'); + } catch (ResponseException $e) { + $purchaseTransactionDeleted = $e->getReturnedObject(); + } + + echo "
";
+    print_r($purchaseTransactionDeleted);
+    echo "
"; +} \ No newline at end of file diff --git a/examples/SalesTransaction.php b/examples/SalesTransaction.php new file mode 100644 index 00000000..5d11b2d3 --- /dev/null +++ b/examples/SalesTransaction.php @@ -0,0 +1,352 @@ +get(\PhpTwinfield\SalesTransaction::class, "VRK", 201900011, $office); + } catch (ResponseException $e) { + $salesTransaction = $e->getReturnedObject(); + } + + echo "
";
+    print_r($salesTransaction);
+    echo "
"; + + echo "SalesTransaction
"; + echo "AutoBalanceVat (bool): {$salesTransaction->getAutoBalanceVat()}
"; // bool|null Should VAT be rounded true or not false? Rounding will only be done with a maximum of two cents. + echo "AutoBalanceVat (string): " . Util::formatBoolean($salesTransaction->getAutoBalanceVat()) . "
"; // string|null + echo "BookingReference (\\PhpTwinfield\\BookingReference):
" . print_r($salesTransaction->getBookingReference(), true) . "

"; // BookingReference|null The Booking reference + echo "Code: {$salesTransaction->getCode()}
"; // string|null Transaction type code. + echo "Currency (\\PhpTwinfield\\Currency):
" . print_r($salesTransaction->getCurrency(), true) . "

"; // Currency|null Currency code. + echo "Currency (string): " . Util::objectToStr($salesTransaction->getCurrency()) . "
"; // string|null + echo "Date (\\DateTimeInterface):
" . print_r($salesTransaction->getDate(), true) . "

"; // DateTimeInterface|null Transaction date. + echo "Date (string): " . Util::formatDate($salesTransaction->getDate()) . "
"; // string|null + echo "DateRaiseWarning (bool): {$salesTransaction->getDateRaiseWarning()}
"; // bool|null Optionally, it is possible to suppress warnings about 'date out of range for the given period' by adding the raisewarning attribute and set its value to false. + echo "DateRaiseWarning (string): {$salesTransaction->getDateRaiseWarningToString()}
"; // string|null This overwrites the value of the raisewarning attribute as set on the root element. + echo "Destiny: {$salesTransaction->getDestiny()}
"; // Destiny|null Attribute to indicate the destiny of the sales transaction. Only used in the request XML. temporary = sales transaction will be saved as provisional. final = sales transaction will be saved as final + echo "DueDate (\\DateTimeInterface):
" . print_r($salesTransaction->getDueDate(), true) . "

"; // DateTimeInterface|null Due date. + echo "DueDate (string): " . Util::formatDate($salesTransaction->getDueDate()) . "
"; // string|null + echo "FreeText1: {$salesTransaction->getFreeText1()}
"; // string|null Free text field 1 as entered on the transaction type. + echo "FreeText2: {$salesTransaction->getFreeText2()}
"; // string|null Free text field 2 as entered on the transaction type. + echo "FreeText3: {$salesTransaction->getFreeText3()}
"; // string|null Free text field 3 as entered on the transaction type. + echo "InputDate (\\DateTimeInterface):
" . print_r($salesTransaction->getInputDate(), true) . "

"; // DateTimeInterface|null The date/time on which the transaction was created. Read-only attribute. + echo "InputDate (string): " . Util::formatDate($salesTransaction->getInputDate()) . "
"; // string|null + echo "InvoiceNumber: {$salesTransaction->getInvoiceNumber()}
"; // string|null Invoice number. + echo "InvoiceNumberRaiseWarning (bool): {$salesTransaction->getInvoiceNumberRaiseWarning()}
"; // bool|null Optionally, it is possible to suppress warnings about 'double invoice numbers' by adding the raisewarning attribute and set its value to false. + echo "InvoiceNumberRaiseWarning (string): {$salesTransaction->getInvoiceNumberRaiseWarningToString()}
"; // string|null This overwrites the value of the raisewarning attribute as set on the root element. + + if ($salesTransaction->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($salesTransaction->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "ModificationDate (\\DateTimeInterface):
" . print_r($salesTransaction->getModificationDate(), true) . "

"; // DateTimeInterface|null The date/time on which the sales transaction was modified the last time. Read-only attribute. + echo "ModificationDate (string): " . Util::formatDate($salesTransaction->getModificationDate()) . "
"; // string|null + echo "Number: {$salesTransaction->getNumber()}
"; // int|null Transaction number. When creating a new sales transaction, don't include this tag as the transaction number is determined by the system. When updating a sales transaction, the related transaction number should be provided. + echo "Office (\\PhpTwinfield\\Office):
" . print_r($salesTransaction->getOffice(), true) . "

"; // Office|null Office code. + echo "Office (string): " . Util::objectToStr($salesTransaction->getOffice()) . "
"; // string|null + echo "Origin: {$salesTransaction->getOrigin()}
"; // string|null The sales transaction origin. Read-only attribute. + echo "OriginReference: {$salesTransaction->getOriginReference()}
"; // string|null The sales transaction origin reference (id). Provided in form of Guid. Read-only attribute. + echo "PaymentReference: {$salesTransaction->getPaymentReference()}
"; // string|null Payment reference of the transaction. If payment reference is not specified, the paymentreference section must be omitted + echo "Period: {$salesTransaction->getPeriod()}
"; // string|null Period in YYYY/PP format. If this tag is not included or if it is left empty, the period is determined by the system based on the provided transaction date. + echo "RaiseWarning (bool): {$salesTransaction->getRaiseWarning()}
"; // bool|null Should warnings be given true or not false? Default true. + echo "RaiseWarning (string): " . Util::formatBoolean($salesTransaction->getRaiseWarning()) . "
"; // string|null + echo "Result: {$salesTransaction->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + + $salesTransactionLines = $salesTransaction->getLines(); // array|null Array of SalesTransactionLine objects. + + foreach ($salesTransactionLines as $key => $salesTransactionLine) { + echo "SalesTransactionLine {$key}
"; + + echo "Baseline: {$salesTransactionLine->getBaseline()}
"; // int|null Only if line type is vat. The value of the baseline tag is a reference to the line ID of the VAT rate. + echo "BaseValue (\\Money\\Money):
" . print_r($salesTransactionLine->getBaseValue(), true) . "

"; // Money|null Amount in the base currency. + echo "BaseValue (string): " . Util::formatMoney($salesTransactionLine->getBaseValue()) . "
"; // string|null + echo "BaseValueOpen (\\Money\\Money):
" . print_r($salesTransactionLine->getBaseValueOpen(), true) . "

"; // Money|null Only if line type is total. The amount still owed in base currency. Read-only attribute. + echo "BaseValueOpen (string): " . Util::formatMoney($salesTransactionLine->getBaseValueOpen()) . "
"; // string|null + echo "Comment: {$salesTransactionLine->getComment()}
"; // string|null Comment set on the transaction line. + echo "DebitCredit: {$salesTransactionLine->getDebitCredit()}
"; // DebitCredit|null If line type = total. In case of a 'normal' sales transaction debit. In case of a credit sales transaction credit. If line type = detail or vat. In case of a 'normal' sales transaction credit. In case of a credit sales transaction debit. + echo "Description: {$salesTransactionLine->getDescription()}
"; // string|null Description of the transaction line. + echo "DestOffice (\\PhpTwinfield\\Office):
" . print_r($salesTransactionLine->getDestOffice(), true) . "

"; // Office|null Office code. Used for inter company transactions – here you define in which company the transaction line should be posted. + echo "DestOffice (string): " . Util::objectToStr($salesTransactionLine->getDestOffice()) . "
"; // string|null + echo "Dim1:
" . print_r($salesTransactionLine->getDim1(), true) . "

"; // object|null If line type = total the accounts receivable balance account. When dim1 is omitted, by default the general ledger account will be taken as entered at the customer in Twinfield. If line type = detail the profit and loss account. + echo "Dim1 (string): " . Util::objectToStr($salesTransactionLine->getDim1()) . "
"; // string|null If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account will be taken as entered at the VAT code in Twinfield. + echo "Dim2:
" . print_r($salesTransactionLine->getDim2(), true) . "

"; // object|null If line type = total the account receivable. If line type = detail the cost center or empty. + echo "Dim2 (string): " . Util::objectToStr($salesTransactionLine->getDim2()) . "
"; // string|null If line type = vat empty. + echo "Dim3:
" . print_r($salesTransactionLine->getDim2(), true) . "

"; // object|null If line type = total empty. If line type = detail the project or asset or empty. + echo "Dim3 (string): " . Util::objectToStr($salesTransactionLine->getDim3()) . "
"; // string|null If line type = vat empty. + echo "FreeChar: {$salesTransactionLine->getFreeChar()}
"; // string|null Free character field. If line type is total and filled with N the sales invoice is excluded from direct debit runs done in Twinfield. + echo "ID: {$salesTransactionLine->getID()}
"; // int|null Line ID. + echo "LineType: {$salesTransactionLine->getLineType()}
"; // LineType|null Line type. + echo "MatchLevel: {$salesTransactionLine->getMatchLevel()}
"; // int|null Only if line type is total. The level of the matchable dimension. Read-only attribute. + echo "MatchStatus: {$salesTransactionLine->getMatchStatus()}
"; // MatchStatus|null Payment status of the sales transaction. If line type detail or vat always notmatchable. Read-only attribute. + + if ($salesTransactionLine->hasMessages()) { // bool Object contains (error) messages true/false. + echo "Messages: " . print_r($salesTransactionLine->getMessages(), true) . "
"; // Array|null (Error) messages. + } + + echo "PerformanceCountry (\\PhpTwinfield\\Country):
" . print_r($salesTransactionLine->getPerformanceCountry(), true) . "

"; // Country|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The ISO country codes are used. If not added to the request, by default the country code of the customer will be taken. + echo "PerformanceCountry (string): " . Util::objectToStr($salesTransactionLine->getPerformanceCountry()) . "
"; // string|null + echo "PerformanceDate (\\DateTimeInterface):
" . print_r($salesTransactionLine->getPerformanceDate(), true) . "

"; // DateTimeInterface|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code but only if performancetype is services. + echo "PerformanceDate (string): " . Util::formatDate($salesTransactionLine->getPerformanceDate()) . "
"; // string|null + echo "PerformanceType: {$salesTransactionLine->getPerformanceType()}
"; // PerformanceType|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The performance type. + echo "PerformanceVatNumber: {$salesTransactionLine->getPerformanceVatNumber()}
"; // string|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. If not added to the request, by default the VAT number of the customer will be taken. + echo "Rate: {$salesTransactionLine->getRate()}
"; // float|null The exchange rate used for the calculation of the base amount. + echo "Reference (\\PhpTwinfield\\MatchReference):
" . print_r($salesTransactionLine->getReference(), true) . "

"; // MatchReference|null Match reference + echo "Relation: {$salesTransactionLine->getRelation()}
"; // int|null Only if line type is total. Read-only attribute. + echo "RepRate: {$salesTransactionLine->getRepRate()}
"; // float|null The exchange rate used for the calculation of the reporting amount. + echo "RepValue (\\Money\\Money):
" . print_r($salesTransactionLine->getRepValue(), true) . "

"; // Money|null Amount in the reporting currency. + echo "RepValue (string): " . Util::formatMoney($salesTransactionLine->getRepValue()) . "
"; // string|null + echo "RepValueOpen (\\Money\\Money):
" . print_r($salesTransactionLine->getRepValueOpen(), true) . "

"; // Money|null Only if line type is total. The amount still owed in reporting currency. Read-only attribute. + echo "RepValueOpen (string): " . Util::formatMoney($salesTransactionLine->getRepValueOpen()) . "
"; // string|null + echo "Result: {$salesTransactionLine->getResult()}
"; // int|null Result (0 = error, 1 or empty = success). + echo "SignedValue (\\Money\\Money):
" . print_r($salesTransactionLine->getSignedValue(), true) . "

"; // Money|null + echo "SignedValue (string): " . Util::formatMoney($salesTransactionLine->getSignedValue()) . "
"; // string|null + echo "Value (\\Money\\Money):
" . print_r($salesTransactionLine->getValue(), true) . "

"; // Money|null If line type = total amount including VAT. If line type = detail amount without VAT. If line type = vat VAT amount. + echo "Value (string): " . Util::formatMoney($salesTransactionLine->getValue()) . "
"; // string|null + echo "ValueOpen (\\Money\\Money):
" . print_r($salesTransactionLine->getValueOpen(), true) . "

"; // Money|null Only if line type is total. The amount still owed in the currency of the sales transaction. Read-only attribute. + echo "ValueOpen (string): " . Util::formatMoney($salesTransactionLine->getValueOpen()) . "
"; // string|null + echo "VatBaseTotal (\\Money\\Money):
" . print_r($salesTransactionLine->getVatBaseTotal(), true) . "

"; // Money|null Only if line type is total. The total VAT amount in base currency. + echo "VatBaseTotal (string): " . Util::formatMoney($salesTransactionLine->getVatBaseTotal()) . "
"; // string|null + echo "VatBaseTurnover (\\Money\\Money):
" . print_r($salesTransactionLine->getVatBaseTurnover(), true) . "

"; // Money|null Only if line type is vat. Amount on which VAT was calculated in base currency. + echo "VatBaseTurnover (string): " . Util::formatMoney($salesTransactionLine->getVatBaseTurnover()) . "
"; // string|null + echo "VatBaseValue (\\Money\\Money):
" . print_r($salesTransactionLine->getVatBaseValue(), true) . "

"; // Money|null Only if line type is detail. VAT amount in base currency. + echo "VatBaseValue (string): " . Util::formatMoney($salesTransactionLine->getVatBaseValue()) . "
"; // string|null + echo "VatCode (\\PhpTwinfield\\VatCode):
" . print_r($salesTransactionLine->getVatCode(), true) . "

"; // VatCode|null Only if line type is detail or vat. VAT code. + echo "VatCode (string): " . Util::objectToStr($salesTransactionLine->getVatCode()) . "
"; // string|null + echo "VatRepTotal (\\Money\\Money):
" . print_r($salesTransactionLine->getVatRepTotal(), true) . "

"; // Money|null Only if line type is total. The total VAT amount in reporting currency. + echo "VatRepTotal (string): " . Util::formatMoney($salesTransactionLine->getVatRepTotal()) . "
"; // string|null + echo "VatRepTurnover (\\Money\\Money):
" . print_r($salesTransactionLine->getVatRepTurnover(), true) . "

"; // Money|null Only if line type is vat. Amount on which VAT was calculated in reporting currency. + echo "VatRepTurnover (string): " . Util::formatMoney($salesTransactionLine->getVatRepTurnover()) . "
"; // string|null + echo "VatRepValue (\\Money\\Money):
" . print_r($salesTransactionLine->getVatRepValue(), true) . "

"; // Money|null Only if line type is detail. VAT amount in reporting currency. + echo "VatRepValue (string): " . Util::formatMoney($salesTransactionLine->getVatRepValue()) . "
"; // string|null + echo "VatTotal (\\Money\\Money):
" . print_r($salesTransactionLine->getVatTotal(), true) . "

"; // Money|null Only if line type is total. The total VAT amount in the currency of the sales transaction. + echo "VatTotal (string): " . Util::formatMoney($salesTransactionLine->getVatTotal()) . "
"; // string|null + echo "VatTurnover (\\Money\\Money):
" . print_r($salesTransactionLine->getVatTurnover(), true) . "

"; // Money|null Only if line type is vat. Amount on which VAT was calculated in the currency of the sales transaction. + echo "VatTurnover (string): " . Util::formatMoney($salesTransactionLine->getVatTurnover()) . "
"; // string|null + echo "VatValue (\\Money\\Money):
" . print_r($salesTransactionLine->getVatValue(), true) . "

"; // Money|null Only if line type is detail. VAT amount in the currency of the sales transaction. + echo "VatValue (string): " . Util::formatMoney($salesTransactionLine->getVatValue()) . "
"; // string|null + } +} + +// Copy an existing SalesTransaction to a new entity +if ($executeCopy) { + try { + $salesTransaction = $transactionApiConnector->get(\PhpTwinfield\SalesTransaction::class, "VRK", 201900011, $office); + } catch (ResponseException $e) { + $salesTransaction = $e->getReturnedObject(); + } + + $salesTransaction->setNumber(null); + + //Optional, but recommended so your copy is not posted to final immediately + $salesTransaction->setDestiny(\PhpTwinfield\Enums\Destiny::TEMPORARY()); + + try { + $salesTransactionCopy = $transactionApiConnector->send($salesTransaction); + } catch (ResponseException $e) { + $salesTransactionCopy = $e->getReturnedObject(); + } + + echo "
";
+    print_r($salesTransactionCopy);
+    echo "
"; + + echo "Result of copy process: {$salesTransactionCopy->getResult()}
"; + echo "Number of copied SalesTransaction: {$salesTransactionCopy->getNumber()}
"; +} + +// Create a new SalesTransaction from scratch, alternatively read an existing SalesTransaction as shown above and than modify the values in the same way as shown below +if ($executeNew) { + $salesTransaction = new \PhpTwinfield\SalesTransaction; + + // Required values for creating a new SalesTransaction + $salesTransaction->setCode('VRK'); // string|null Transaction type code. + $currency = new \PhpTwinfield\Currency; + $currency->setCode('EUR'); + $salesTransaction->setCurrency($currency); // Currency|null Currency code. + //$salesTransaction->setCurrency(\PhpTwinfield\Currency::fromCode("EUR")); // string|null + $salesTransaction->setDestiny(\PhpTwinfield\Enums\Destiny::TEMPORARY()); // Destiny|null Attribute to indicate the destiny of the sales transaction. Only used in the request XML. + //$salesTransaction->setDestiny(\PhpTwinfield\Enums\Destiny::FINAL()); // Destiny|null temporary = sales transaction will be saved as provisional. final = sales transaction will be saved as final. + $salesTransaction->setInvoiceNumber(201900011); // string|null Invoice number. + $salesTransaction->setOffice($office); // Office|null Office code. + $salesTransaction->setOffice(\PhpTwinfield\Office::fromCode($officeCode)); // string|null + + // Optional values for creating a new SalesTransaction + $salesTransaction->setAutoBalanceVat(true); // bool|null Should VAT be rounded true or not false? Rounding will only be done with a maximum of two cents. + $date = \DateTime::createFromFormat('d-m-Y', '01-09-2019'); + $salesTransaction->setDate($date); // DateTimeInterface|null Transaction date. Optionally, it is possible to suppress warnings about 'date out of range for the given period' by adding the raisewarning attribute and set its value to false. + $salesTransaction->setDate(Util::parseDate("20190901")); // string|null This overwrites the value of the raisewarning attribute as set on the root element. + $salesTransaction->setDateRaiseWarning(false); // bool|null + $dueDate = \DateTime::createFromFormat('d-m-Y', '01-10-2019'); + $salesTransaction->setDueDate($dueDate); // DateTimeInterface|null Due date. + $salesTransaction->setDueDate(Util::parseDate("20191001")); // string|null + //$salesTransaction->setFreeText1('Example FreeText 1'); // string|null Free text field 1 as entered on the transaction type. + //$salesTransaction->setFreeText2('Example FreeText 2'); // string|null Free text field 2 as entered on the transaction type. + //$salesTransaction->setFreeText3('Example FreeText 3'); // string|null Free text field 3 as entered on the transaction type. + $salesTransaction->setInvoiceNumberRaiseWarning(false); // bool|null Optionally, it is possible to suppress warnings about 'double invoice numbers' by adding the raisewarning attribute and set its value to false. This overwrites the value of the raisewarning attribute as set on the root element. + //$salesTransaction->setNumber(201900011); // int|null Transaction number. When creating a new sales transaction, don't include this tag as the transaction number is determined by the system. When updating a sales transaction, the related transaction number should be provided. + //$salesTransaction->setPeriod("2019/07"); // string|null Period in YYYY/PP format. If this tag is not included or if it is left empty, the period is determined by the system based on the provided transaction date. + $salesTransaction->setRaiseWarning(true); // bool|null Should warnings be given true or not false? Default true. + + // The minimum amount of SalesTransactionLines linked to an SalesTransaction object is 2 (1 total, 1 detail) + $salesTransactionLine1 = new \PhpTwinfield\SalesTransactionLine; + $salesTransactionLine1->setLineType(\PhpTwinfield\Enums\LineType::TOTAL()); // LineType|null Line type. + + $dim1 = new \PhpTwinfield\GeneralLedger; + $dim1->setCode('1300'); + $salesTransactionLine1->setDim1($dim1); // object|null If line type = total the accounts receivable balance account. When dim1 is omitted, by default the general ledger account will be taken as entered at the customer in Twinfield. If line type = detail the profit and loss account. + $salesTransactionLine1->setDim1(\PhpTwinfield\GeneralLedger::fromCode('1300')); // string|null If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account will be taken as entered at the VAT code in Twinfield. + $dim2 = new \PhpTwinfield\Customer; + $dim2->setCode('1000'); + $salesTransactionLine1->setDim2($dim2); // object|null If line type = total the account receivable. If line type = detail the cost center or empty. If line type = vat empty. + $salesTransactionLine1->setDim2(\PhpTwinfield\Customer::fromCode('1000')); // string|null + $salesTransactionLine1->setID(1); // int|null Line ID. + $salesTransactionLine1->setValue(\Money\Money::EUR(-10000)); // Money|null If line type = total amount including VAT. If line type = detail amount without VAT. If line type = vat VAT amount. + //$salesTransactionLine1->setVatBaseTotal(\Money\Money::EUR(-10000)); // Money|null Only if line type is total. The total VAT amount in base currency. + //$salesTransactionLine1->setVatRepTotal(\Money\Money::EUR(-10000)); // Money|null Only if line type is total. The total VAT amount in reporting currency. + //$salesTransactionLine1->setVatTotal(\Money\Money::EUR(-10000)); // Money|null Only if line type is total. The total VAT amount in the currency of the sales transaction. + + $salesTransaction->addLine($salesTransactionLine1); // SalesTransactionLine Add a SalesTransactionLine object to the SalesTransaction object + + $salesTransactionLine2 = new \PhpTwinfield\SalesTransactionLine; + $salesTransactionLine2->setLineType(\PhpTwinfield\Enums\LineType::DETAIL()); // LineType|null Line type. + + $salesTransactionLine2->setBaseValue(\Money\Money::EUR(10000)); // Money|null Amount in the base currency. + $salesTransactionLine2->setDescription("Example Description on line with ID 2"); // string|null Description of the transaction line. + $dim1 = new \PhpTwinfield\GeneralLedger; + $dim1->setCode('2500'); + $salesTransactionLine2->setDim1($dim1); // object|null If line type = total the accounts receivable balance account. When dim1 is omitted, by default the general ledger account will be taken as entered at the customer in Twinfield. If line type = detail the profit and loss account. + $salesTransactionLine2->setDim1(\PhpTwinfield\GeneralLedger::fromCode('2500')); // string|null If line type = vat the VAT balance account. When an empty dim1 is entered, by default the general ledger account will be taken as entered at the VAT code in Twinfield. + $salesTransactionLine2->setID(2); // int|null Line ID. + $salesTransactionLine2->setValue(\Money\Money::EUR(-10000)); // Money|null If line type = total amount including VAT. If line type = detail amount without VAT. If line type = vat VAT amount. + + //$salesTransactionLine2->setComment('Example Comments'); // string|null Comment set on the transaction line. + $destOffice = new \PhpTwinfield\Office; + $destOffice->setCode('1234'); + //$salesTransaction->setDestOffice($destOffice); // Office|null Office code. Used for inter company transactions – here you define in which company the transaction line should be posted. + //$salesTransaction->setDestOffice(\PhpTwinfield\Office::fromCode('1234')); // string|null + $dim2 = new \PhpTwinfield\Customer; + $dim2->setCode('1001'); + //$salesTransactionLine2->setDim2($dim2); // object|null If line type = total the account receivable. If line type = detail the cost center or empty. If line type = vat empty. + //$salesTransactionLine2->setDim2(\PhpTwinfield\Customer::fromCode('1001')); // string|null + $dim3 = new \PhpTwinfield\Project; + $dim3->setCode('P0000'); + //$salesTransactionLine2->setDim3($dim3); // object|null If line type = total empty. If line type = detail the project or asset or empty. If line type = vat empty. + //$salesTransactionLine2->setDim3(\PhpTwinfield\Project::fromCode('P0000')); // string|null + //$salesTransactionLine2->setFreeChar('A'); // string|null Free character field. If line type is total and filled with N the sales invoice is excluded from direct debit runs done in Twinfield. + $performanceCountry = new \PhpTwinfield\Country; + $performanceCountry->setCode('NL'); + //$salesTransactionLine2->setPerformanceCountry($performanceCountry); // Country|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The ISO country codes are used. If not added to the request, by default the country code of the customer will be taken. + //$salesTransactionLine2->setPerformanceCountry(\PhpTwinfield\Country::fromCode('NL')); // string|null + $performanceDate = \DateTime::createFromFormat('d-m-Y', '01-09-2019'); + //$salesTransactionLine2->setPerformanceDate($performanceDate); // DateTimeInterface|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code but only if performancetype is services. + //$salesTransactionLine2->setPerformanceDate(Util::parseDate("20190901")); // string|null + //$salesTransactionLine2->setPerformanceType(\PhpTwinfield\Enums\PerformanceType::SERVICES()); // PerformanceType|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. The performance type. + //$salesTransactionLine2->setPerformanceVatNumber('NL1234567890B01'); // string|null Only if line type is detail or vat. Mandatory in case of an ICT VAT code. If not added to the request, by default the VAT number of the customer will be taken. + //$salesTransactionLine2->setRepValue(\Money\Money::EUR(-10000)); // Money|null Amount in the reporting currency. + //$salesTransactionLine2->setRate(1); // float|null The exchange rate used for the calculation of the base amount. + //$salesTransactionLine2->setRepRate(1); // float|null The exchange rate used for the calculation of the reporting amount. + //$salesTransactionLine2->setVatBaseValue(\Money\Money::EUR(-10000)); // Money|null Only if line type is detail. VAT amount in base currency. + $vatCode = new \PhpTwinfield\VatCode; + $vatCode->setCode('VN'); + //$salesTransactionLine2->setVatCode($vatCode); // VatCode|null Only if line type is detail or vat. VAT code. + //$salesTransactionLine2->setVatCode(\PhpTwinfield\VatCode::fromCode('VN')); // string|null + //$salesTransactionLine2->setVatRepValue(\Money\Money::EUR(-10000)); // Money|null Only if line type is detail. VAT amount in reporting currency. + //$salesTransactionLine2->setVatValue(\Money\Money::EUR(-10000)); // Money|null Only if line type is detail. VAT amount in the currency of the sales transaction. + + $salesTransaction->addLine($salesTransactionLine2); + + //$salesTransactionLine3 = new \PhpTwinfield\SalesTransactionLine; + //$salesTransactionLine3->setLineType(\PhpTwinfield\Enums\LineType::VAT()); // LineType|null Line type. + //$salesTransactionLine3->setBaseline(1); // int|null Only if line type is vat. The value of the baseline tag is a reference to the line ID of the VAT rate. + //$salesTransactionLine3->setVatBaseTurnover(\Money\Money::EUR(-10000)); // Money|null Only if line type is vat. Amount on which VAT was calculated in base currency. + //$salesTransactionLine3->setVatRepTurnover(\Money\Money::EUR(-10000)); // Money|null Only if line type is vat. Amount on which VAT was calculated in reporting currency. + //$salesTransactionLine3->setVatTurnover(\Money\Money::EUR(-10000)); // Money|null Only if line type is vat. Amount on which VAT was calculated in the currency of the sales transaction. + + try { + $salesTransactionNew = $transactionApiConnector->send($salesTransaction); + } catch (ResponseException $e) { + $salesTransactionNew = $e->getReturnedObject(); + } + + echo "
";
+    print_r($salesTransactionNew);
+    echo "
"; + + echo "Result of creation process: {$salesTransactionNew->getResult()}
"; + echo "Number of new SalesTransaction: {$salesTransactionNew->getNumber()}
"; +} + +// Delete a BrankTransaction based off the passed in office, code, number and given reason +if ($executeDelete) { + $bookingReference = new \PhpTwinfield\BookingReference($office, 'VRK', 201900012); + + try { + $salesTransactionDeleted = $transactionApiConnector->delete($bookingReference, 'Example reason'); + } catch (ResponseException $e) { + $salesTransactionDeleted = $e->getReturnedObject(); + } + + echo "
";
+    print_r($salesTransactionDeleted);
+    echo "
"; +} \ No newline at end of file diff --git a/src/ApiConnectors/ActivityApiConnector.php b/src/ApiConnectors/ActivityApiConnector.php index fa4cd6aa..8e26cc42 100644 --- a/src/ApiConnectors/ActivityApiConnector.php +++ b/src/ApiConnectors/ActivityApiConnector.php @@ -49,7 +49,7 @@ public function get(string $code, Office $office): Activity } /** - * Sends a Activity instance to Twinfield to update or add. + * Sends an Activity instance to Twinfield to update or add. * * @param Activity $activity * @return Activity diff --git a/src/Mappers/TransactionMapper.php b/src/Mappers/TransactionMapper.php index 3ef2773d..af97f32e 100644 --- a/src/Mappers/TransactionMapper.php +++ b/src/Mappers/TransactionMapper.php @@ -124,7 +124,7 @@ public static function map(string $transactionClassName, Response $response, Aut } if (Util::objectUses(RegimeField::class, $transaction)) { - $transaction->setRegime(self::getField($transactionElement, 'regime', $transaction)); + $transaction->setRegime(self::parseEnumAttribute(\PhpTwinfield\Enums\Regime::class, self::getField($transactionElement, 'regime', $transaction))); } if (Util::objectUses(StatementNumberField::class, $transaction)) { From 984f66b30c6297a09e49b94878c1379fded032d1 Mon Sep 17 00:00:00 2001 From: iranl Date: Sun, 21 Jul 2019 16:56:46 +0200 Subject: [PATCH 388/388] Update readme.md --- readme.md | 75 ------------------------------------------------------- 1 file changed, 75 deletions(-) diff --git a/readme.md b/readme.md index e2f78b8c..6eb1c97d 100644 --- a/readme.md +++ b/readme.md @@ -23,81 +23,6 @@ composer require 'league/oauth2-client' See [Usage](usage.md). For breaking changes since 2.7.0 see [Breaking Changes since 2.7.0](breaking270.md). -### ApiConnector Configuration - -The ApiConnector has a constructor second parameter that can be used to configure some aspects of its operation. - -The ApiOptions has the following methods signature: - -```php -/** - * This will allow you to enfornce the messages or the number of max retries. - * Passing null you will use the default values. - */ -public function __construct(?array $messages = null, ?int $maxRetries = null); -/** - * This will allow you to get all the exception messages - */ -public function getRetriableExceptionMessages(): array -/** - * This will allow you to replace the exception messages that should be retried - */ -public function setRetriableExceptionMessages(array $retriableExceptionMessages): ApiOptions -/** - * This will allow you to add new messages to the array of exception messages - */ -public function addMessages(array $messages): ApiOptions -/** - * This will allow you to get the number of max retries - */ -public function getMaxRetries(): int -/** - * This will allow you to set the number of max retries - */ -public function setMaxRetries(int $maxRetries): ApiOptions -``` - - - -:exclamation: All the *get* methods will return a new instance with the configuration you changed. - -#### Configuration Examples - -Below are some examples on how to use the configuration object - -```php -$connector = new BrowseDataApiConnector( - $connection, - new ApiOptions( - [ - "SSL: Connection reset by peer", - "Bad Gateway" - ], - 3 - ) -); -``` - -The example below will look for the defaul messages plus the "Bad Gateway" message. - -```php -$options = new ApiOptions( - null, - 3 -); -$connector = new BrowseDataApiConnector( - $connection, - $options->addMessages(["Bad Gateway"]) -); -``` - -#### Configuration default values - -| Attribute | Default Value | Description | -| ---------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| Max retries | 3 | The number of retries that should happen before throwing an error. | -| Retriable exception messages | [
"SSL: Connection reset by peer",
"Your logon credentials are not valid anymore. Try to log on again."
] | The exception messages that should be match in order to retry automatically. | - ### Supported resources Not all resources from the Twinfield API are currently implemented. Feel free to create a pull request when you need