Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
54 / 54
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
TransactionTypeType
100.00% covered (success)
100.00%
54 / 54
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 buildForm
100.00% covered (success)
100.00%
54 / 54
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace App\Form;
6
7use App\Entity\PaymentMethod;
8use App\Entity\Store;
9use App\Entity\User;
10use App\Type\TransactionType;
11use Override;
12use Symfony\Bridge\Doctrine\Form\Type\EntityType;
13use Symfony\Component\Form\AbstractType;
14use Symfony\Component\Form\Extension\Core\Type\EnumType;
15use Symfony\Component\Form\Extension\Core\Type\MoneyType;
16use Symfony\Component\Form\FormBuilderInterface;
17use Symfony\Component\Translation\TranslatableMessage;
18
19class TransactionTypeType extends AbstractType
20{
21    #[Override]
22    public function buildForm(
23        FormBuilderInterface $builder,
24        array $options
25    ): void
26    {
27        $builder
28            ->add(
29                'date',
30                null,
31                [
32                    'widget' => 'single_text',
33                    'format' => 'yyyy-MM-dd',
34                ]
35            )
36            ->add(
37                'type',
38                EnumType::class,
39                [
40                    'class' => TransactionType::class,
41                    'choice_label' => fn(
42                        TransactionType $choice
43                    ): TranslatableMessage => new TranslatableMessage(
44                        $choice->translationKey()
45                    ),
46                ]
47            )
48            ->add(
49                'store',
50                EntityType::class,
51                [
52                    'class' => Store::class,
53                    'choice_label' => fn(Store $store): string => $store->getId().' - '.$store->getDestination(),
54                ]
55            )
56            ->add(
57                'user',
58                EntityType::class,
59                [
60                    'class' => User::class,
61                    'choice_label' => 'name',
62                ]
63            )
64            ->add(
65                'method',
66                EntityType::class,
67                [
68                    'class' => PaymentMethod::class,
69                    'choice_label' => 'name',
70                ]
71            )
72            ->add('amount', MoneyType::class, ['currency' => 'usd'])
73            ->add('document')
74            ->add('comment')
75            ->add('depId', null, [
76                'label' => 'DepositoId',
77            ])
78            ->add('recipeNo', null, [
79                'label' => 'Factura',
80            ]);
81    }
82}