Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
54 / 54 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| TransactionTypeType | |
100.00% |
54 / 54 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| buildForm | |
100.00% |
54 / 54 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace App\Form; |
| 6 | |
| 7 | use App\Entity\PaymentMethod; |
| 8 | use App\Entity\Store; |
| 9 | use App\Entity\User; |
| 10 | use App\Type\TransactionType; |
| 11 | use Override; |
| 12 | use Symfony\Bridge\Doctrine\Form\Type\EntityType; |
| 13 | use Symfony\Component\Form\AbstractType; |
| 14 | use Symfony\Component\Form\Extension\Core\Type\EnumType; |
| 15 | use Symfony\Component\Form\Extension\Core\Type\MoneyType; |
| 16 | use Symfony\Component\Form\FormBuilderInterface; |
| 17 | use Symfony\Component\Translation\TranslatableMessage; |
| 18 | |
| 19 | class 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 | } |