|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Gewebe\SyliusVATPlugin\DependencyInjection; |
|
6
|
|
|
|
|
7
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
8
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
9
|
|
|
|
|
10
|
|
|
final class Configuration implements ConfigurationInterface |
|
11
|
|
|
{ |
|
12
|
|
|
public function getConfigTreeBuilder(): TreeBuilder |
|
13
|
|
|
{ |
|
14
|
|
|
$treeBuilder = new TreeBuilder('gewebe_sylius_vat'); |
|
15
|
|
|
|
|
16
|
|
|
$treeBuilder->getRootNode() |
|
17
|
|
|
->children() |
|
18
|
|
|
->arrayNode('order') |
|
19
|
|
|
->children() |
|
20
|
|
|
->booleanNode('recalculate')->defaultValue(true) |
|
21
|
|
|
->info('Order will be recalculated without taxes if possible.') |
|
22
|
|
|
->end() |
|
23
|
|
|
->end() |
|
24
|
|
|
->end() // order |
|
25
|
|
|
->arrayNode('required') |
|
26
|
|
|
->children() |
|
27
|
|
|
->booleanNode('default')->defaultValue(false) |
|
28
|
|
|
->info('VAT number is required by default.') |
|
29
|
|
|
->end() |
|
30
|
|
|
->booleanNode('company')->defaultValue(true) |
|
31
|
|
|
->info('VAT number is required for a company address.') |
|
32
|
|
|
->end() |
|
33
|
|
|
->arrayNode('countries') |
|
34
|
|
|
->scalarPrototype()->end() |
|
35
|
|
|
->info('VAT number is required for the specified countries.') |
|
36
|
|
|
->end() |
|
37
|
|
|
->end() |
|
38
|
|
|
->end() // required |
|
39
|
|
|
->arrayNode('validate') |
|
40
|
|
|
->children() |
|
41
|
|
|
->booleanNode('format')->defaultValue(true) |
|
42
|
|
|
->info('Verify the country-specific VAT number format.') |
|
43
|
|
|
->end() |
|
44
|
|
|
->booleanNode('country')->defaultValue(true) |
|
45
|
|
|
->info('Verify that the VAT number matches the selected country.') |
|
46
|
|
|
->end() |
|
47
|
|
|
->booleanNode('registration')->defaultValue(true) |
|
48
|
|
|
->info('Verify that the VAT number is successfully registered online.') |
|
49
|
|
|
->end() |
|
50
|
|
|
->booleanNode('on_service_unavailable')->defaultValue(false) |
|
51
|
|
|
->info('Validation will not fail if the VAT service is unavailable, ' |
|
52
|
|
|
. 'but the VAT number is not verified, which can be tried again later.') |
|
53
|
|
|
->end() |
|
54
|
|
|
->end() |
|
55
|
|
|
->end() // validate |
|
56
|
|
|
->arrayNode('revalidate') |
|
57
|
|
|
->children() |
|
58
|
|
|
->booleanNode('on_login')->defaultValue(true) |
|
59
|
|
|
->info('VAT number will be revalidated again on login.') |
|
60
|
|
|
->end() |
|
61
|
|
|
->integerNode('expiration_days')->defaultValue(30) |
|
62
|
|
|
->info('Number of days after which the VAT number will be revalidated.') |
|
63
|
|
|
->end() |
|
64
|
|
|
->end() |
|
65
|
|
|
->end() // revalidate |
|
66
|
|
|
; |
|
67
|
|
|
|
|
68
|
|
|
return $treeBuilder; |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
|