|
11 | 11 |
|
12 | 12 | ## Installation |
13 | 13 |
|
14 | | -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 |
15 | | - |
16 | | - Thus, you have to run the following command to require a fork of the bundle which is compatible with Symfony 7: |
17 | | - |
18 | | - ```bash |
19 | | - composer config repositories.sandwich/vies-bundle git https://github.com/mmenozzi/ViesBundle.git |
20 | | - ``` |
21 | | - |
22 | | - and you have to run this command too to allow "dev" versions of the bundle (we need the "dev-patch-1" version): |
23 | | - |
24 | | - ```bash |
25 | | - composer config minimum-stability dev |
26 | | - ``` |
27 | | - |
28 | 14 | 1. Require the plugin: |
29 | 15 |
|
30 | 16 | ```bash |
|
44 | 30 | - { resource: "@WebgriffeSyliusItalianInvoiceableOrderPlugin/config/config.yaml" } |
45 | 31 | ``` |
46 | 32 |
|
47 | | -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: |
| 33 | +4. 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: |
48 | 34 |
|
49 | 35 | ```yaml |
50 | 36 | # config/services.yaml |
51 | 37 | parameters: |
52 | 38 | app.taxation.eu_zone_code: 'EU' # Change it if needed |
53 | 39 | ``` |
54 | 40 |
|
55 | | -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. |
| 41 | +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. |
56 | 42 |
|
57 | | -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. |
| 43 | +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. |
58 | 44 |
|
59 | | -6. You need to import the `Address` and `Order` validator configuration into your project by copying the configuration files provided by this plugin: |
| 45 | +7. You need to import the `Address` and `Order` validator configuration into your project by copying the configuration files provided by this plugin: |
60 | 46 |
|
61 | 47 | ```bash |
62 | 48 | mkdir -p config/validator/ |
|
77 | 63 | ```bash |
78 | 64 | sed -i '' 's/Tests\\Webgriffe\\SyliusItalianInvoiceableOrderPlugin/App/g' config/validator/Address.xml config/validator/Order.xml |
79 | 65 | ``` |
| 66 | + |
| 67 | + If you already have some validator file for these entities you have to merge the configuration manually. |
| 68 | + |
| 69 | + *NB* Please, note that currently these validation rules are applied in strict mode. This means that if the VIES |
| 70 | + service is not available for some reason, the validation of the VAT number will fail. This could occur frequently on |
| 71 | + specific countries like Germany or France due |
| 72 | + to this problem: https://viesapi.eu/vies-problems-with-verifying-companies-from-germany-de/. |
| 73 | + If you want to avoid this strict behavior you can change the `strict` option of the |
| 74 | + `Webgriffe\SyliusItalianInvoiceableOrderPlugin\Validator\Constraints\EuropeanVatNumber` constraint to `false` in the |
| 75 | + validation configuration file. This way, if the VIES service is not available, the VAT number will be considered |
| 76 | + valid and the checkout will not be blocked. |
80 | 77 |
|
81 | | - If you alread have some validator file for these entities you have to merge the configuration manually. |
82 | | - |
83 | | -7. Configure Sylius to use the `Italian tax calculation` tax calculation strategy. |
| 78 | +8. Configure Sylius to use the `Italian tax calculation` tax calculation strategy. |
84 | 79 |
|
85 | | -8. To properly enable group sequence validation of your Address entity you must set the `Default` validation group instead of the `sylius` validation group: |
| 80 | +9. To properly enable group sequence validation of your Address entity you must set the `Default` validation group instead of the `sylius` validation group: |
86 | 81 |
|
87 | 82 | ```yaml |
88 | 83 | # config/parameters.yaml |
|
93 | 88 |
|
94 | 89 | For more information see [here](https://symfony.com/doc/current/validation/sequence_provider.html). |
95 | 90 |
|
96 | | -9. Run migration |
| 91 | +10. Run migration |
97 | 92 |
|
98 | 93 | ```bash |
99 | | - bin/console cache:clear |
100 | 94 | bin/console doctrine:migrations:migrate |
101 | 95 | ``` |
102 | 96 |
|
103 | | -10. Add invoiceable fields to the address show template for admin. To do so you have to override this template: |
| 97 | +11. Add invoiceable fields to the address show template for admin. To do so you have to override this template: |
104 | 98 |
|
105 | 99 | ```bash |
106 | 100 | vendor/sylius/sylius/src/Sylius/Bundle/AdminBundle/templates/shared/helper/address.html.twig |
107 | 101 | ``` |
108 | | - |
| 102 | + |
109 | 103 | by copying directly our implementation provided in the plugin: |
110 | 104 |
|
111 | 105 | ```bash |
112 | 106 | mkdir -p templates/bundles/SyliusAdminBundle/shared/helper/ |
113 | 107 | 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 |
114 | 108 | ``` |
115 | | - |
| 109 | + |
116 | 110 | or by copying the original template and adding the invoiceable fields by yourself. In this case your template should look like the following: |
117 | | - |
| 111 | + |
118 | 112 | ```twig |
119 | 113 | {% macro address(address) %} |
120 | 114 | <address> |
|
0 commit comments