Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
vendor/
composer.lock
phpunit.xml
tags
79 changes: 56 additions & 23 deletions Entity/BankTransactionExplanation.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ class BankTransactionExplanation extends AbstractEntity

/**
* @var string
* @Group({"get", "update"})
* @Groups({"get", "update"})
* @Type("string")
*/
protected $url;

/**
* @var string
* @Accessor(getter="getBankTransactionUrl", setter="setBankTransactionUrl")
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("string")
*/
protected $bankTransaction;
Expand All @@ -40,7 +40,7 @@ class BankTransactionExplanation extends AbstractEntity
/**
* @var string
* @Accessor(getter="getBankAccountUrl", setter="setBankAccountUrl")
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("string")
*/
protected $bankAccount;
Expand All @@ -53,7 +53,7 @@ class BankTransactionExplanation extends AbstractEntity
/**
* @var string
* @Accessor(getter="getCategoryUrl", setter="setCategoryUrl")
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("string")
*/
protected $category;
Expand All @@ -65,29 +65,29 @@ class BankTransactionExplanation extends AbstractEntity

/**
* @var \DateTime
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("DateTime<'Y-m-d'>")
*/
protected $datedOn;

/**
* @var string
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("string")
*/
protected $description;

/**
* @var float
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("double")
*/
protected $grossValue;

/**
* @var string
* @Accessor(getter="getProjectUrl", setter="setProjectUrl")
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("string")
*/
protected $project;
Expand All @@ -99,43 +99,43 @@ class BankTransactionExplanation extends AbstractEntity

/**
* @var string
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("string")
*/
protected $rebillType;

/**
* @var float
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("double")
*/
protected $rebillFactor;

/**
* @var Attachment
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("SixBySix\Freeagent\Entity\Attachment")
*/
protected $attachment;

/**
* @var float
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("double")
*/
protected $manualSalesTaxAmount;

/**
* @var float
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("double")
*/
protected $foreignCurrencyValue;

/**
* @var string
* @Accessor(getter="getPaidInvoiceUrl", setter="setPaidInvoiceUrl")
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("string")
*/
protected $paidInvoice;
Expand All @@ -148,7 +148,7 @@ class BankTransactionExplanation extends AbstractEntity
/**
* @var string
* @Accessor(getter="getPaidBillUrl", setter="setPaidBillUrl")
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("string")
*/
protected $paidBill;
Expand All @@ -161,7 +161,7 @@ class BankTransactionExplanation extends AbstractEntity
/**
* @var string
* @Accessor(getter="getPaidUserUrl", setter="setPaidUserUrl")
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("string")
*/
protected $paidUser;
Expand All @@ -174,7 +174,7 @@ class BankTransactionExplanation extends AbstractEntity
/**
* @var string
* @Accessor(getter="getTransferBankAccountUrl", setter="setTransferBankAccountUrl")
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("string")
*/
protected $transferBankAccount;
Expand All @@ -187,7 +187,7 @@ class BankTransactionExplanation extends AbstractEntity
/**
* @var string
* @Accessor(getter="getStockItemUrl", setter="setStockItemUrl")
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("string")
*/
protected $stockItem;
Expand All @@ -199,22 +199,22 @@ class BankTransactionExplanation extends AbstractEntity

/**
* @var integer
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("integer")
*/
protected $stockAlteringQuantity;

/**
* @var integer
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("integer")
*/
protected $assetLifeYears;

/**
* @var string
* @Accessor(getter="getDisposedAssetUrl", setter="setDisposedAssetUrl")
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("string")
*/
protected $disposedAsset;
Expand All @@ -226,18 +226,25 @@ class BankTransactionExplanation extends AbstractEntity

/**
* @var string
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("string")
*/
protected $ecStatus;

/**
* @var string
* @Group({"get", "post", "update"})
* @Groups({"get", "post", "update"})
* @Type("string")
*/
protected $placeOfSupply;

/**
* @var string
* @Groups({"get"})
* @Type("string")
*/
protected $type;

/**
* @return mixed
*/
Expand Down Expand Up @@ -336,6 +343,24 @@ public function setDescription($description)
return $this;
}

/**
* @return mixed
*/
public function getDisposedAssetUrl()
{
return $this->disposedAsset;
}

/**
* @param $disposedAsset
* @return $this
*/
public function setDisposedAssetUrl($disposedAsset)
{
$this->disposedAsset = $disposedAsset;
return $this;
}

/**
* @return mixed
*/
Expand Down Expand Up @@ -815,4 +840,12 @@ public function setPaidUser(User $paidUserEntity)
{
$this->paidUserEntity = $paidUserEntity;
}

/**
* @return string
*/
public function getType()
{
return $this->type;
}
}
126 changes: 126 additions & 0 deletions Tests/Entity/BankTransactionExplanationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?php

namespace SixBySix\Freeagent\Tests\Entity;

use DateTime;
use SixBySix\Freeagent\Entity\Company;
use SixBySix\Freeagent\Entity\InvoiceItem;
use SixBySix\Freeagent\Tests\TestCase;

class BankTransactionExplanationTest extends AbstractEntityTest
{
protected static $currentUrl;

public function getClassName()
{
return 'SixBySix\Freeagent\Entity\BankTransactionExplanation';
}

public function getApiMethodName()
{
return 'bankTransactionExplanation';
}

public function deserializeProvider()
{
return [
[
[
"bank_transaction" => "https://api.freeagent.com/v2/bank_transactions/8",
"bank_account" => "https://api.freeagent.com/v2/bank_accounts/1",
"dated_on" => "2010-05-01",
"description" => "harness end-to-end e-business",
"ec_status" => "EC Goods",
"gross_value" => "-730.0",
"place_of_supply" => "Greece",
"project" => "https://api.freeagent.com/v2/projects/1",
"rebill_type" => "markup",
"rebill_factor" => "0.25",
"type" => "Payment",
],
[
"getBankTransactionUrl" => "https://api.freeagent.com/v2/bank_transactions/8",
"getBankAccountUrl" => "https://api.freeagent.com/v2/bank_accounts/1",
"getDatedOn" => new DateTime("2010-05-01"),
"getDescription" => "harness end-to-end e-business",
"getEcStatus" => "EC Goods",
"getGrossValue" => "-730.0",
"getPlaceOfSupply" => "Greece",
"getProjectUrl" => "https://api.freeagent.com/v2/projects/1",
"getRebillType" => "markup",
"getRebillFactor" => "0.25",
"getType" => "Payment",
]
]
];
}

public function createOneProvider()
{
return [
[
[
'setGrossValue' => 123.45,
'setDatedOn' => new DateTime(),
'setDescription' => 'Test description.',
]
]
];
}

/**
* @test
* @depends createOne
*/
public function getOne()
{
$explanation = $this->api->bankTransactionExplanation()
->getByUrl(self::$currentUrl);

$this->assertEquals($explanation->getUrl(), self::$currentUrl);
}

/**
* @test
* @dataProvider createOneProvider
* @param $json
*/
public function createOne($json)
{
$bankAccount = $this->api->bankAccount()
->query()
->getFirst();

$contact = $this->api->contact()
->setOrganisationName('Totally Cool Ltd.')
->save();

$invoiceItem = (new InvoiceItem())
->setDescription('Services')
->setItemType(InvoiceItem::ITEM_TYPE_SERVICES)
->setPrice(123.45)
->setQuantity(1);

$invoice = $this->api->invoice()
->setInvoiceItems([$invoiceItem])
->setDatedOn(new \DateTime('now'))
->setPaymentTermsInDays(30)
->setContact($contact)
->save();

/** @var BankTransactionExplanation $explanation */
$explanation = $this->api->bankTransactionExplanation()
->setBankAccountUrl($bankAccount->getUrl())
->setPaidInvoiceUrl($invoice->getUrl());

foreach ($json as $methodName => $value) {
$explanation->{$methodName}($value);
}

$explanation->save();

self::$currentUrl = $explanation->getUrl();

$this->assertNotEmpty($explanation->getUrl());
}
}
2 changes: 1 addition & 1 deletion Tests/Entity/CompanyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ public function getOne()

$this->assertInstanceOf($this->getClassName(), $entity);
}
}
}
2 changes: 1 addition & 1 deletion Tests/Entity/InvoiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,4 @@ protected function getCurrentInvoice()
{
return $this->api->invoice()->getByUrl(self::$currentUrl);
}
}
}