Skip to content
Merged
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 .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @webgriffe/wg-devs
50 changes: 21 additions & 29 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'dependabot/**'
pull_request: ~
release:
types: [created]
types: [ created ]
schedule:
-
cron: "0 1 * * 6" # Run at 1am every Saturday
Expand All @@ -21,11 +21,11 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ["8.4"]
symfony: ["^7.3"]
sylius: ["~2.2.0"]
node: ["22.x"]
mysql: ["8.4"]
php: [ "8.3", "8.4" ]
symfony: [ "^7.4" ]
sylius: [ "~2.2.1" ]
node: [ "22.x" ]
mysql: [ "8.4" ]

env:
APP_ENV: test
Expand All @@ -42,7 +42,7 @@ jobs:
with:
php-version: "${{ matrix.php }}"
extensions: intl
tools: flex,symfony
tools: flex, symfony
coverage: none

-
Expand All @@ -66,10 +66,6 @@ jobs:
name: Output PHP version for Symfony CLI
run: php -v | head -n 1 | awk '{ print $2 }' > .php-version

-
name: Validate composer.json
run: composer validate --ansi --strict

-
name: Get Composer cache directory
id: composer-cache
Expand Down Expand Up @@ -102,11 +98,7 @@ jobs:
run: composer install --no-interaction

-
name: Validate container
run: vendor/bin/console lint:container

-
name: Run ECS
name: RUN EasyCodingStandard
run: vendor/bin/ecs check

-
Expand All @@ -117,10 +109,6 @@ jobs:
name: Run Psalm
run: vendor/bin/psalm

-
name: Run PHPSpec
run: vendor/bin/phpspec run --ansi -f progress --no-interaction

-
name: Run unit tests
run: vendor/bin/phpunit --colors=always --testsuite=unit
Expand Down Expand Up @@ -149,10 +137,6 @@ jobs:
(vendor/bin/console doctrine:database:create -vvv)
(vendor/bin/console doctrine:schema:create -vvv)

-
name: Validate database schema
run: vendor/bin/console doctrine:schema:validate

-
name: Prepare test application assets
run: |
Expand All @@ -168,24 +152,32 @@ jobs:
run: vendor/bin/console sylius:fixtures:load -n

-
name: Run Non-unit PHPUnit tests
run: vendor/bin/phpunit --colors=always --testsuite=non-unit
name: Validate composer.json
run: composer validate --ansi --strict

-
name: Install certificates
run: symfony server:ca:install || true
name: Validate container
run: vendor/bin/console lint:container

-
name: Run Non-unit PHPUnit tests
run: vendor/bin/phpunit --colors=always --testsuite=non-unit

-
name: Run Chrome Headless
run: google-chrome-stable --enable-automation --disable-background-networking --no-default-browser-check --no-first-run --disable-popup-blocking --disable-default-apps --allow-insecure-localhost --disable-translate --disable-extensions --no-sandbox --enable-features=Metal --headless --remote-debugging-port=9222 --window-size=2880,1800 --proxy-server='direct://' --proxy-bypass-list='*' http://127.0.0.1 > /dev/null 2>&1 &

-
name: Install certificates
run: symfony server:ca:install || true

-
name: Run webserver
run: symfony server:start --port=8080 --daemon

-
name: Run Behat
run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun
run: vendor/bin/behat --colors --strict -vvv --no-interaction -f progress || vendor/bin/behat --colors --strict -vvv --no-interaction -f progress --rerun

-
name: Upload Behat logs
Expand Down
54 changes: 24 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@

## Installation

0. This plugin requires the [MyOnlineStore/ViesBundle](https://github.com/MyOnlineStore/ViesBundle) but this is not actually compatible with Symfony 7, there is an open PR: https://github.com/MyOnlineStore/ViesBundle/pull/18

Thus, you have to run the following command to require a fork of the bundle which is compatible with Symfony 7:

```bash
composer config repositories.sandwich/vies-bundle git https://github.com/mmenozzi/ViesBundle.git
```

and you have to run this command too to allow "dev" versions of the bundle (we need the "dev-patch-1" version):

```bash
composer config minimum-stability dev
```

1. Require the plugin:

```bash
Expand All @@ -41,22 +27,22 @@
3. Add the plugin's configs by creating the `config/packages/webgriffe_sylius_italian_invoiceable_order_plugin.yaml` file with the following content:
```yaml
imports:
- { resource: "@WebgriffeSyliusItalianInvoiceableOrderPlugin/config/config.yaml" }
- { resource: "@WebgriffeSyliusItalianInvoiceableOrderPlugin/config/config.php" }
```

3. By default, the parameter `app.taxation.eu_zone_code` is set to "EU", as it must be the code of a zone representing the EU. This is used to determine if an order is invoiced to a company within the EU or not. Please change this parameter according to your Sylius's zone configuration if needed:
4. By default, the parameter `webgriffe_sylius_italian_invoiceable_order.taxation.eu_zone_code` is set to "EU", as it must be the code of a zone representing the EU. This is used to determine if an order is invoiced to a company within the EU or not. Please change this parameter according to your Sylius's zone configuration if needed:

```yaml
# config/services.yaml
parameters:
app.taxation.eu_zone_code: 'EU' # Change it if needed
webgriffe_sylius_italian_invoiceable_order.taxation.eu_zone_code: 'EU' # Change it if needed
```

4. Your `Address` entity must implement the `Webgriffe\SyliusItalianInvoiceableOrderPlugin\Model\ItalianInvoiceableAddressInterface` and the `Symfony\Component\Validator\GroupSequenceProviderInterface`. You can use the `Webgriffe\SyliusItalianInvoiceableOrderPlugin\Model\ItalianInvoiceableAddressTrait` as implementation for both interfaces.
5. Your `Address` entity must implement the `Webgriffe\SyliusItalianInvoiceableOrderPlugin\Model\ItalianInvoiceableAddressInterface` and the `Symfony\Component\Validator\GroupSequenceProviderInterface`. You can use the `Webgriffe\SyliusItalianInvoiceableOrderPlugin\Model\ItalianInvoiceableAddressTrait` as implementation for both interfaces.

5. Your `Order` entity must implement the `Webgriffe\SyliusItalianInvoiceableOrderPlugin\Model\ItalianInvoiceableOrderInterface`. You can use the `Webgriffe\SyliusItalianInvoiceableOrderPlugin\Model\ItalianInvoiceableOrderTrait` as default implementation for the interface.
6. Your `Order` entity must implement the `Webgriffe\SyliusItalianInvoiceableOrderPlugin\Model\ItalianInvoiceableOrderInterface`. You can use the `Webgriffe\SyliusItalianInvoiceableOrderPlugin\Model\ItalianInvoiceableOrderTrait` as default implementation for the interface.

6. You need to import the `Address` and `Order` validator configuration into your project by copying the configuration files provided by this plugin:
7. You need to import the `Address` and `Order` validator configuration into your project by copying the configuration files provided by this plugin:

```bash
mkdir -p config/validator/
Expand All @@ -77,12 +63,21 @@
```bash
sed -i '' 's/Tests\\Webgriffe\\SyliusItalianInvoiceableOrderPlugin/App/g' config/validator/Address.xml config/validator/Order.xml
```

If you already have some validator file for these entities you have to merge the configuration manually.

*NB* Please, note that currently these validation rules are applied in strict mode. This means that if the VIES
service is not available for some reason, the validation of the VAT number will fail. This could occur frequently on
specific countries like Germany or France due
to this problem: https://viesapi.eu/vies-problems-with-verifying-companies-from-germany-de/.
If you want to avoid this strict behavior you can change the `strict` option of the
`Webgriffe\SyliusItalianInvoiceableOrderPlugin\Validator\Constraints\EuropeanVatNumber` constraint to `false` in the
validation configuration file. This way, if the VIES service is not available, the VAT number will be considered
valid and the checkout will not be blocked.

If you alread have some validator file for these entities you have to merge the configuration manually.

7. Configure Sylius to use the `Italian tax calculation` tax calculation strategy.
8. Configure Sylius to use the `Italian tax calculation` tax calculation strategy.

8. To properly enable group sequence validation of your Address entity you must set the `Default` validation group instead of the `sylius` validation group:
9. To properly enable group sequence validation of your Address entity you must set the `Default` validation group instead of the `sylius` validation group:

```yaml
# config/parameters.yaml
Expand All @@ -93,28 +88,27 @@

For more information see [here](https://symfony.com/doc/current/validation/sequence_provider.html).

9. Run migration
10. Run migration

```bash
bin/console cache:clear
bin/console doctrine:migrations:migrate
```

10. Add invoiceable fields to the address show template for admin. To do so you have to override this template:
11. Add invoiceable fields to the address show template for admin. To do so you have to override this template:

```bash
vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/templates/shared/helper/address.html.twig
```

by copying directly our implementation provided in the plugin:

```bash
mkdir -p templates/bundles/SyliusAdminBundle/shared/helper/
cp vendor/webgriffe/sylius-italian-invoiceable-order-plugin/tests/TestApplication/templates/bundles/SyliusAdminBundle/shared/helper/address.html.twig templates/bundles/SyliusAdminBundle/shared/helper/address.html.twig
```

or by copying the original template and adding the invoiceable fields by yourself. In this case your template should look like the following:

```twig
{% macro address(address) %}
<address>
Expand Down
11 changes: 11 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Upgrade plugin guide

## Upgrade from version 1.x to 2.x

- The service `app.taxation.italian_tax_calculation_strategy` has been renamed to `webgriffe_sylius_italian_invoiceable_order.strategy.taxation.tax_calculation.italian_tax_calculation_strategy`.
- The class `Webgriffe\SyliusItalianInvoiceableOrderPlugin\Model\ItalianTaxCalculationStrategy` has been moved to `Webgriffe\SyliusItalianInvoiceableOrderPlugin\Taxation\ItalianTaxCalculationStrategy`.
- The package `sandwich/vies-bundle` has been removed.
- The constraint `Symfony\Component\Validator\Constraints\Sandwich\ViesBundle\Validator\Constraint\VatNumber` has been replaced with `Webgriffe\SyliusItalianInvoiceableOrderPlugin\Validator\Constraints\EuropeanVatNumber`. Please update your validation rules accordingly with search and replace.
Please, note also that now is available a new strict option that allows you to block the checkout step if the VIES service is not available. You can enable it by setting the `strict` option to `true` in your validation rules.
- The file `@WebgriffeSyliusItalianInvoiceableOrderPlugin/config/config.yaml` has been renamed to `@WebgriffeSyliusItalianInvoiceableOrderPlugin/config/config.php`.
- The parameter `app.taxation.eu_zone_code` has been renamed to `webgriffe_sylius_italian_invoiceable_order.taxation.eu_zone_code`.
25 changes: 8 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"require": {
"php": "^8.2",
"dragonbe/vies": "^2.3.2",
"sandwich/vies-bundle": "dev-patch-1",
"sylius/sylius": "^2.2",
"webmozart/assert": "^1.9"
},
Expand All @@ -30,7 +29,7 @@
"friends-of-behat/suite-settings-extension": "^1.1",
"friends-of-behat/symfony-extension": "^2.6",
"friends-of-behat/variadic-extension": "^1.6",
"phpspec/phpspec": "^8.0",
"payum/payum-bundle": "2.6.*",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.12",
"phpstan/phpstan-doctrine": "^1.3",
Expand All @@ -44,13 +43,13 @@
"sylius-labs/suite-tags-extension": "~0.2",
"sylius/sylius-rector": "^2.0",
"sylius/test-application": "^2.0.0@alpha",
"symfony/browser-kit": "^6.4 || ^7.1",
"symfony/debug-bundle": "^6.4 || ^7.1",
"symfony/dotenv": "^6.4 || ^7.1",
"symfony/http-client": "^6.4 || ^7.1",
"symfony/intl": "^6.4 || ^7.1",
"symfony/runtime": "^6.4 || ^7.1",
"symfony/web-profiler-bundle": "^6.4 || ^7.1",
"symfony/browser-kit": "^6.4 || ^7.4",
"symfony/debug-bundle": "^6.4 || ^7.4",
"symfony/dotenv": "^6.4 || ^7.4",
"symfony/http-client": "^6.4 || ^7.4",
"symfony/intl": "^6.4 || ^7.4",
"symfony/runtime": "^6.4 || ^7.4",
"symfony/web-profiler-bundle": "^6.4 || ^7.4",
"symfony/webpack-encore-bundle": "^2.2",
"vimeo/psalm": "^6.13"
},
Expand Down Expand Up @@ -82,12 +81,6 @@
}
}
},
"repositories": {
"sandwich/vies-bundle": {
"type": "git",
"url": "https://github.com/mmenozzi/ViesBundle.git"
}
},
"autoload": {
"psr-4": {
"Webgriffe\\SyliusItalianInvoiceableOrderPlugin\\": "src/"
Expand Down Expand Up @@ -116,13 +109,11 @@
"ecs": "ecs check src/ tests/Behat/",
"phpstan": "phpstan analyse -c phpstan.neon -l max src/",
"phpunit": "phpunit",
"phpspec": "phpspec run",
"behat": "behat --strict -vvv --no-interaction || behat --strict -vvv --no-interaction --rerun",
"suite": [
"@ecs",
"@phpstan",
"@phpunit",
"@phpspec",
"@behat"
],
"auto-scripts": {
Expand Down
13 changes: 13 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

declare(strict_types=1);

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $containerConfigurator) {
$parameters = $containerConfigurator->parameters();
$parameters->set('sylius.form.type.address.validation_groups', [ 'Default' ]);
$parameters->set('webgriffe_sylius_italian_invoiceable_order.taxation.eu_zone_code', 'EU');

$containerConfigurator->import('packages/*.php');
};
5 changes: 0 additions & 5 deletions config/config.yaml

This file was deleted.

32 changes: 32 additions & 0 deletions config/packages/sylius_admin_twig_hooks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container): void {
$container->extension('sylius_twig_hooks', [
'hooks' => [
'sylius_admin.order.update.content.form.billing_address' => [
'billingRecipientType' => [
'template' => '@WebgriffeSyliusItalianInvoiceableOrderPlugin/admin/shared/form/address/billingRecipientType.html.twig',
'priority' => 1000,
],
'invoiceableBillingData' => [
'template' => '@WebgriffeSyliusItalianInvoiceableOrderPlugin/admin/shared/form/address/invoiceableBillingData.html.twig',
'priority' => 650,
],
],
'sylius_admin.order.update.content.form.shipping_address' => [
'billingRecipientType' => [
'template' => '@WebgriffeSyliusItalianInvoiceableOrderPlugin/admin/shared/form/address/billingRecipientType.html.twig',
'priority' => 1000,
],
'invoiceableBillingData' => [
'template' => '@WebgriffeSyliusItalianInvoiceableOrderPlugin/admin/shared/form/address/invoiceableBillingData.html.twig',
'priority' => 650,
],
],
],
]);
};
34 changes: 34 additions & 0 deletions config/packages/sylius_shop_twig_hooks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container): void {
$container->extension('sylius_twig_hooks', [
'hooks' => [
'sylius_shop.shared.address' => [
'company' => [
'enabled' => false,
],
'name' => [
'enabled' => false,
],
'billingAddressInfo' => [
'template' => '@WebgriffeSyliusItalianInvoiceableOrderPlugin/shop/shared/address/billingAddressInfo.html.twig',
'priority' => 1000,
],
],
'sylius_shop.shared.form.address' => [
'billingRecipientType' => [
'template' => '@WebgriffeSyliusItalianInvoiceableOrderPlugin/shop/shared/form/address/billingRecipientType.html.twig',
'priority' => 1000,
],
'invoiceableBillingData' => [
'template' => '@WebgriffeSyliusItalianInvoiceableOrderPlugin/shop/shared/form/address/invoiceableBillingData.html.twig',
'priority' => 650,
],
],
],
]);
};
Loading
Loading