-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
284 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
/** | ||
* This file is part of riesenia/pohoda package. | ||
* | ||
* Licensed under the MIT License | ||
* (c) RIESENIA.com | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\Riesenia\Pohoda; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
|
||
class BankSpec extends ObjectBehavior | ||
{ | ||
public function let() | ||
{ | ||
$this->beConstructedWith([ | ||
'bankType' => 'receipt', | ||
'account' => 'KB', | ||
'statementNumber' => [ | ||
'statementNumber' => '004', | ||
'numberMovement' => '0002' | ||
], | ||
'symVar' => '456', | ||
'symConst' => '555', | ||
'symSpec' => '666', | ||
'dateStatement' => '2021-12-20', | ||
'datePayment' => '2021-11-22', | ||
'text' => 'STORMWARE s.r.o.', | ||
'paymentAccount' => [ | ||
'accountNo' => '4660550217', | ||
'bankCode' => '5500' | ||
] | ||
], '123'); | ||
} | ||
|
||
public function it_is_initializable_and_extends_agenda() | ||
{ | ||
$this->shouldHaveType('Riesenia\Pohoda\Bank'); | ||
$this->shouldHaveType('Riesenia\Pohoda\Agenda'); | ||
} | ||
|
||
public function it_creates_correct_xml() | ||
{ | ||
$this->getXML()->asXML()->shouldReturn('<bnk:bank version="2.0"><bnk:bankHeader>' . $this->_defaultHeader() . '</bnk:bankHeader></bnk:bank>'); | ||
} | ||
|
||
public function it_can_set_summary() | ||
{ | ||
$this->addSummary([ | ||
'homeCurrency' => [ | ||
'priceNone' => 500 | ||
] | ||
]); | ||
|
||
$this->getXML()->asXML()->shouldReturn('<bnk:bank version="2.0"><bnk:bankHeader>' . $this->_defaultHeader() . '</bnk:bankHeader><bnk:bankSummary><bnk:homeCurrency><typ:priceNone>500</typ:priceNone></bnk:homeCurrency></bnk:bankSummary></bnk:bank>'); | ||
} | ||
|
||
public function it_can_set_parameters() | ||
{ | ||
$this->addParameter('IsOn', 'boolean', 'true'); | ||
$this->addParameter('VPrNum', 'number', 10.43); | ||
$this->addParameter('RefVPrCountry', 'list', 'SK', 'Country'); | ||
$this->addParameter('CustomList', 'list', ['id' => 5], ['id' => 6]); | ||
|
||
$this->getXML()->asXML()->shouldReturn('<bnk:bank version="2.0"><bnk:bankHeader>' . $this->_defaultHeader() . '<bnk:parameters><typ:parameter><typ:name>VPrIsOn</typ:name><typ:booleanValue>true</typ:booleanValue></typ:parameter><typ:parameter><typ:name>VPrNum</typ:name><typ:numberValue>10.43</typ:numberValue></typ:parameter><typ:parameter><typ:name>RefVPrCountry</typ:name><typ:listValueRef><typ:ids>SK</typ:ids></typ:listValueRef><typ:list><typ:ids>Country</typ:ids></typ:list></typ:parameter><typ:parameter><typ:name>RefVPrCustomList</typ:name><typ:listValueRef><typ:id>5</typ:id></typ:listValueRef><typ:list><typ:id>6</typ:id></typ:list></typ:parameter></bnk:parameters></bnk:bankHeader></bnk:bank>'); | ||
} | ||
|
||
protected function _defaultHeader() | ||
{ | ||
return '<bnk:bankType>receipt</bnk:bankType><bnk:account><typ:ids>KB</typ:ids></bnk:account><bnk:statementNumber><bnk:statementNumber>004</bnk:statementNumber><bnk:numberMovement>0002</bnk:numberMovement></bnk:statementNumber><bnk:symVar>456</bnk:symVar><bnk:dateStatement>2021-12-20</bnk:dateStatement><bnk:datePayment>2021-11-22</bnk:datePayment><bnk:text>STORMWARE s.r.o.</bnk:text><bnk:paymentAccount><typ:accountNo>4660550217</typ:accountNo><typ:bankCode>5500</typ:bankCode></bnk:paymentAccount><bnk:symConst>555</bnk:symConst><bnk:symSpec>666</bnk:symSpec>'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* This file is part of riesenia/pohoda package. | ||
* | ||
* Licensed under the MIT License | ||
* (c) RIESENIA.com | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Riesenia\Pohoda; | ||
|
||
class Bank extends Document | ||
{ | ||
/** @var string */ | ||
public static $importRoot = 'lst:bank'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function _getDocumentNamespace(): string | ||
{ | ||
return 'bnk'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function _getDocumentName(): string | ||
{ | ||
return 'bank'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
/** | ||
* This file is part of riesenia/pohoda package. | ||
* | ||
* Licensed under the MIT License | ||
* (c) RIESENIA.com | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Riesenia\Pohoda\Bank; | ||
|
||
use Riesenia\Pohoda\Common\OptionsResolver; | ||
use Riesenia\Pohoda\Document\Header as DocumentHeader; | ||
|
||
class Header extends DocumentHeader | ||
{ | ||
/** @var string[] */ | ||
protected $_refElements = ['account', 'accounting', 'classificationVAT', 'classificationKVDPH', 'paymentAccount', 'centre', 'activity', 'contract', 'MOSS', 'evidentiaryResourcesMOSS']; | ||
|
||
/** @var string[] */ | ||
protected $_elements = ['bankType', 'account', 'statementNumber', 'symVar', 'dateStatement', 'datePayment', 'accounting', 'classificationVAT', 'classificationKVDPH', 'text', 'partnerIdentity', 'myIdentity', 'paymentAccount', 'symConst', 'symSpec', 'symPar', 'centre', 'activity', 'contract', 'MOSS', 'evidentiaryResourcesMOSS', 'accountingPeriodMOSS', 'note', 'intNote']; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function __construct(array $data, string $ico, bool $resolveOptions = true) | ||
{ | ||
// process report | ||
if (isset($data['statementNumber'])) { | ||
$data['statementNumber'] = new StatementNumber($data['statementNumber'], $ico, $resolveOptions); | ||
} | ||
|
||
parent::__construct($data, $ico, $resolveOptions); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function _configureOptions(OptionsResolver $resolver) | ||
{ | ||
parent::_configureOptions($resolver); | ||
|
||
// validate / format options | ||
$resolver->setAllowedValues('bankType', ['receipt', 'expense']); | ||
$resolver->setNormalizer('symVar', $resolver->getNormalizer('string20')); | ||
$resolver->setNormalizer('dateStatement', $resolver->getNormalizer('date')); | ||
$resolver->setNormalizer('datePayment', $resolver->getNormalizer('date')); | ||
$resolver->setNormalizer('text', $resolver->getNormalizer('string96')); | ||
$resolver->setNormalizer('symConst', $resolver->getNormalizer('string4')); | ||
$resolver->setNormalizer('symSpec', $resolver->getNormalizer('string16')); | ||
$resolver->setNormalizer('symPar', $resolver->getNormalizer('string20')); | ||
$resolver->setNormalizer('accountingPeriodMOSS', $resolver->getNormalizer('string7')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/** | ||
* This file is part of riesenia/pohoda package. | ||
* | ||
* Licensed under the MIT License | ||
* (c) RIESENIA.com | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Riesenia\Pohoda\Bank; | ||
|
||
use Riesenia\Pohoda\Common\OptionsResolver; | ||
use Riesenia\Pohoda\Document\Item as DocumentItem; | ||
|
||
class Item extends DocumentItem | ||
{ | ||
/** @var string[] */ | ||
protected $_refElements = ['typeServiceMOSS', 'accounting', 'classificationVAT', 'classificationKVDPH', 'centre', 'activity', 'contract']; | ||
|
||
/** @var string[] */ | ||
protected $_elements = ['text', 'quantity', 'unit', 'coefficient', 'payVAT', 'rateVAT', 'discountPercentage', 'homeCurrency', 'foreignCurrency', 'typeServiceMOSS', 'note', 'symPar', 'accounting', 'classificationVAT', 'classificationKVDPH', 'centre', 'activity', 'contract']; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function _configureOptions(OptionsResolver $resolver) | ||
{ | ||
parent::_configureOptions($resolver); | ||
|
||
// validate / format options | ||
$resolver->setNormalizer('text', $resolver->getNormalizer('string90')); | ||
$resolver->setNormalizer('quantity', $resolver->getNormalizer('float')); | ||
$resolver->setNormalizer('unit', $resolver->getNormalizer('string10')); | ||
$resolver->setNormalizer('coefficient', $resolver->getNormalizer('float')); | ||
$resolver->setNormalizer('payVAT', $resolver->getNormalizer('bool')); | ||
$resolver->setAllowedValues('rateVAT', ['none', 'third', 'low', 'high']); | ||
$resolver->setNormalizer('discountPercentage', $resolver->getNormalizer('float')); | ||
$resolver->setNormalizer('note', $resolver->getNormalizer('string90')); | ||
$resolver->setNormalizer('symPar', $resolver->getNormalizer('string20')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/** | ||
* This file is part of riesenia/pohoda package. | ||
* | ||
* Licensed under the MIT License | ||
* (c) RIESENIA.com | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Riesenia\Pohoda\Bank; | ||
|
||
use Riesenia\Pohoda\Agenda; | ||
use Riesenia\Pohoda\Common\OptionsResolver; | ||
|
||
class StatementNumber extends Agenda | ||
{ | ||
/** @var string[] */ | ||
protected $_elements = ['statementNumber', 'numberMovement']; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getXML(): \SimpleXMLElement | ||
{ | ||
$xml = $this->_createXML()->addChild('bnk:statementNumber', '', $this->_namespace('bnk')); | ||
|
||
$this->_addElements($xml, $this->_elements, 'bnk'); | ||
|
||
return $xml; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function _configureOptions(OptionsResolver $resolver) | ||
{ | ||
// available options | ||
$resolver->setDefined($this->_elements); | ||
|
||
// validate / format options | ||
$resolver->setNormalizer('statementNumber', $resolver->getNormalizer('string10')); | ||
$resolver->setNormalizer('numberMovement', $resolver->getNormalizer('string6')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
/** | ||
* This file is part of riesenia/pohoda package. | ||
* | ||
* Licensed under the MIT License | ||
* (c) RIESENIA.com | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Riesenia\Pohoda\Bank; | ||
|
||
use Riesenia\Pohoda\Common\OptionsResolver; | ||
use Riesenia\Pohoda\Document\Summary as DocumentSummary; | ||
|
||
class Summary extends DocumentSummary | ||
{ | ||
/** @var string[] */ | ||
protected $_elements = ['roundingDocument', 'roundingVAT', 'homeCurrency', 'foreignCurrency']; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function _configureOptions(OptionsResolver $resolver) | ||
{ | ||
parent::_configureOptions($resolver); | ||
|
||
// validate / format options | ||
$resolver->setAllowedValues('roundingDocument', ['none']); | ||
$resolver->setAllowedValues('roundingVAT', ['none']); | ||
} | ||
} |