-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add vat number field to channel billing data
- Loading branch information
Showing
20 changed files
with
417 additions
and
6 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
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,8 @@ | ||
App\Entity\Channel\ShopBillingData: | ||
type: entity | ||
table: sylius_shop_billing_data | ||
fields: | ||
vatNumber: | ||
type: string | ||
column: vat_number | ||
nullable: true |
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
25 changes: 25 additions & 0 deletions
25
features/channel/managing_channels/editing_shop_billing_data_on_channel.feature
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,25 @@ | ||
@channel_vat_number | ||
Feature: Editing shop billing data with vat number on channel | ||
In order to have proper shop billing data with vat number on shop-related documents | ||
As an Administrator | ||
I want to be able to edit shop billing data with vat number on a channel | ||
|
||
Background: | ||
Given the store operates on a channel named "Web" | ||
And the store ships to "Austria" | ||
And channel "Web" billing data is "Joda", "Burgring 1", "1010" "Vienna", "Austria" with "123" tax ID, "ATU" VAT No. | ||
And I am logged in as an administrator | ||
|
||
@ui | ||
Scenario: Editing shop billing data with vat number on channel | ||
When I want to modify a channel "Web" | ||
And I specify company as "Jodeliti" | ||
And I specify tax ID as "99-999/9999" | ||
And I specify VAT number as "ATU12345678" | ||
And I specify shop billing address as "Opernring 1", "8010" "Graz", "Austria" | ||
And I save my changes | ||
Then I should be notified that it has been successfully edited | ||
And this channel company should be "Jodeliti" | ||
And this channel tax ID should be "99-999/9999" | ||
And this channel VAT number should be "ATU12345678" | ||
And this channel shop billing address should be "Opernring 1", "8010" "Graz", "Austria" |
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,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\Gewebe\SyliusVATPlugin\Entity; | ||
|
||
use Gewebe\SyliusVATPlugin\Entity\ShopBillingData; | ||
use Gewebe\SyliusVATPlugin\Entity\ShopBillingDataVatNumberInterface; | ||
use PhpSpec\ObjectBehavior; | ||
|
||
final class ShopBillingDataSpec extends ObjectBehavior | ||
{ | ||
function it_is_address() | ||
{ | ||
$this->shouldHaveType(ShopBillingData::class); | ||
} | ||
|
||
function it_implements_address_interface(): void | ||
{ | ||
$this->shouldImplement(ShopBillingDataVatNumberInterface::class); | ||
} | ||
|
||
function it_has_vat_number(): void | ||
{ | ||
$this->getVatNumber()->shouldReturn(null); | ||
$this->hasVatNumber()->shouldReturn(false); | ||
|
||
$this->setVatNumber('ATU12345678'); | ||
$this->getVatNumber()->shouldReturn('ATU12345678'); | ||
$this->hasVatNumber()->shouldReturn(true); | ||
} | ||
} |
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,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Gewebe\SyliusVATPlugin\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use Sylius\Component\Core\Model\ShopBillingData as BaseShopBillingData; | ||
|
||
/** | ||
* Example ShopBillingData entity with vat number implemented as trait | ||
* | ||
* #@ORM\Entity | ||
* #@ORM\Table(name="sylius_shop_billing_data") | ||
*/ | ||
class ShopBillingData extends BaseShopBillingData implements ShopBillingDataVatNumberInterface | ||
{ | ||
use ShopBillingDataVatNumberAwareTrait; | ||
} |
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,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Gewebe\SyliusVATPlugin\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use Symfony\Component\Serializer\Annotation\Groups; | ||
|
||
/** | ||
* Trait that implements the shop billing data vat number functionality | ||
* Used in: | ||
* <li>@see ShopBillingData</li> | ||
*/ | ||
trait ShopBillingDataVatNumberAwareTrait | ||
{ | ||
/** | ||
* @ORM\Column(name="vat_number", type="string", nullable=true) | ||
* | ||
* @Groups({"admin:shop_billing_data:read"}) | ||
*/ | ||
protected ?string $vatNumber = null; | ||
|
||
public function getVatNumber(): ?string | ||
{ | ||
return $this->vatNumber; | ||
} | ||
|
||
public function setVatNumber(?string $vatNumber): void | ||
{ | ||
$this->vatNumber = $vatNumber; | ||
} | ||
|
||
public function hasVatNumber(): bool | ||
{ | ||
return is_string($this->vatNumber) && strlen($this->vatNumber) > 0; | ||
} | ||
} |
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,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Gewebe\SyliusVATPlugin\Entity; | ||
|
||
use Sylius\Component\Core\Model\ShopBillingDataInterface; | ||
|
||
/** | ||
* ShopBillingData model with vat number | ||
*/ | ||
interface ShopBillingDataVatNumberInterface extends ShopBillingDataInterface | ||
{ | ||
public function getVatNumber(): ?string; | ||
|
||
public function setVatNumber(?string $vatNumber): void; | ||
|
||
public function hasVatNumber(): bool; | ||
} |
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 | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Gewebe\SyliusVATPlugin\Form\Extension; | ||
|
||
use Sylius\Bundle\CoreBundle\Form\Type\ShopBillingDataType; | ||
use Symfony\Component\Form\AbstractTypeExtension; | ||
use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
|
||
class ShopBillingDataTypeExtension extends AbstractTypeExtension | ||
{ | ||
public function buildForm(FormBuilderInterface $builder, array $options): void | ||
{ | ||
$builder->add( | ||
'vatNumber', | ||
TextType::class, | ||
[ | ||
'label' => 'gewebe_sylius_vat_plugin.ui.vat_number', | ||
'required' => false, | ||
], | ||
); | ||
} | ||
|
||
public static function getExtendedTypes(): array | ||
{ | ||
return [ | ||
ShopBillingDataType::class, | ||
]; | ||
} | ||
} |
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
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,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Gewebe\SyliusVATPlugin\Application\src\Entity\Channel; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use Gewebe\SyliusVATPlugin\Entity\ShopBillingDataVatNumberAwareTrait; | ||
use Gewebe\SyliusVATPlugin\Entity\ShopBillingDataVatNumberInterface; | ||
use Sylius\Component\Core\Model\ShopBillingData as BaseShopBillingData; | ||
|
||
/** | ||
* ShopBillingData entity with vat number implemented as trait | ||
* | ||
* @ORM\Entity | ||
* @ORM\Table(name="sylius_shop_billing_data") | ||
*/ | ||
class ShopBillingData extends BaseShopBillingData implements ShopBillingDataVatNumberInterface | ||
{ | ||
use ShopBillingDataVatNumberAwareTrait; | ||
} |
16 changes: 16 additions & 0 deletions
16
tests/Application/templates/bundles/SyliusAdminBundle/Channel/Form/_billingData.html.twig
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,16 @@ | ||
<h4 class="ui top attached large header">{{ form_label(form.shopBillingData) }}</h4> | ||
<div class="ui attached segment"> | ||
<div class="three fields"> | ||
{{ form_row(form.shopBillingData.company) }} | ||
{{ form_row(form.shopBillingData.taxId) }} | ||
{{ form_row(form.shopBillingData.vatNumber) }} | ||
</div> | ||
<div class="two fields"> | ||
{{ form_row(form.shopBillingData.countryCode) }} | ||
{{ form_row(form.shopBillingData.street) }} | ||
</div> | ||
<div class="two fields"> | ||
{{ form_row(form.shopBillingData.city) }} | ||
{{ form_row(form.shopBillingData.postcode) }} | ||
</div> | ||
</div> |
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,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Gewebe\SyliusVATPlugin\Behat\Context\Setup; | ||
|
||
use Behat\Behat\Context\Context; | ||
use Doctrine\Persistence\ObjectManager; | ||
use Sylius\Component\Addressing\Model\CountryInterface; | ||
use Sylius\Component\Core\Model\ChannelInterface; | ||
use Tests\Gewebe\SyliusVATPlugin\Application\src\Entity\Channel\ShopBillingData; | ||
|
||
final class ChannelContext implements Context | ||
{ | ||
public function __construct( | ||
private ObjectManager $channelManager, | ||
) { | ||
} | ||
|
||
/** | ||
* @Given channel :channel billing data is :company, :street, :postcode :city, :country with :taxId tax ID, :vatNumber VAT No. | ||
*/ | ||
public function channelBillingDataWithVatNumberIs( | ||
ChannelInterface $channel, | ||
string $company, | ||
string $street, | ||
string $postcode, | ||
string $city, | ||
CountryInterface $country, | ||
string $taxId, | ||
string $vatNumber, | ||
): void { | ||
$shopBillingData = new ShopBillingData(); | ||
$shopBillingData->setCompany($company); | ||
$shopBillingData->setStreet($street); | ||
$shopBillingData->setPostcode($postcode); | ||
$shopBillingData->setCity($city); | ||
$shopBillingData->setCountryCode($country->getCode()); | ||
$shopBillingData->setTaxId($taxId); | ||
$shopBillingData->setVatNumber($vatNumber); | ||
|
||
$channel->setShopBillingData($shopBillingData); | ||
|
||
$this->channelManager->flush(); | ||
} | ||
} |
Oops, something went wrong.