Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Remove BankTransactionApi and move functionality to TransactionsApi #141

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ea0edc7
Merge pull request #1 from php-twinfield/master
iranl Apr 26, 2019
3a0e4ef
Add files via upload
iranl Apr 28, 2019
723dc82
Add files via upload
iranl Apr 28, 2019
ebbdc0e
Add files via upload
iranl Apr 28, 2019
3033e40
Add files via upload
iranl Apr 28, 2019
c6f4d3d
Delete Base.php
iranl Apr 28, 2019
8a88ac0
Delete Detail.php
iranl Apr 28, 2019
d58d145
Delete Total.php
iranl Apr 28, 2019
13cd45d
Delete Vat.php
iranl Apr 28, 2019
c6c37d8
Add files via upload
iranl Apr 28, 2019
08bda32
Add files via upload
iranl Apr 28, 2019
415c04b
Add files via upload
iranl Apr 28, 2019
d1d39dd
Delete BankTransactionMapper.php
iranl Apr 28, 2019
9b4b6de
Delete BankTransactionDocument.php
iranl Apr 28, 2019
f295ea5
Add files via upload
iranl Apr 28, 2019
27b5733
Delete BankTransactionApiConnector.php
iranl Apr 28, 2019
26beab7
Delete TransactionsDocument.php
iranl Apr 28, 2019
b4abb11
Add files via upload
iranl Apr 28, 2019
4fef34e
Delete BankTransactionDocumentUnitTest.php
iranl Apr 28, 2019
8fb7a31
Delete BankTransactionApiConnectorTest.php
iranl Apr 28, 2019
2010f3b
Create BankTransactionLineUnitTest.php
iranl Apr 28, 2019
cd4cfa2
Update BankTransactionUnitTest.php
iranl Apr 28, 2019
2dd0e11
Create bankTransactionGetResponse.xml
iranl Apr 28, 2019
71eec80
Create bankTransactionSendRequest.xml
iranl Apr 28, 2019
63580cf
Create BankTransactionIntegrationTest.php
iranl Apr 28, 2019
9d6b6e4
Add files via upload
iranl Apr 28, 2019
b758c82
Update MappedResponseCollectionUnitTest.php
iranl Apr 28, 2019
60a1fe1
Update TransactionLine.php
iranl Apr 28, 2019
213edcc
Update TransactionLine.php
iranl Apr 28, 2019
a46ba4a
Update TransactionLine.php
iranl Apr 28, 2019
53117ab
Update TransactionLine.php
iranl Apr 28, 2019
eebaad9
Update TransactionMapper.php
iranl Apr 28, 2019
57f8ddf
Update TransactionsDocument.php
iranl Apr 29, 2019
9ef3877
Update BankTransactionIntegrationTest.php
iranl Apr 29, 2019
5ec14bb
Update TransactionMapper.php
iranl Apr 29, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 0 additions & 66 deletions src/ApiConnectors/BankTransactionApiConnector.php

This file was deleted.

100 changes: 24 additions & 76 deletions src/BankTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,117 +6,65 @@
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());
} else {
$this->closevalue = $this->getClosevalue()->subtract($line->getValue());
}
}

return $this;
}
}
Loading