Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

DocumentTotals.php 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace App\Filament\Forms\Components;
  3. use App\Enums\Accounting\AdjustmentComputation;
  4. use App\Enums\Accounting\DocumentType;
  5. use Filament\Forms\Components\Grid;
  6. use Filament\Forms\Components\Select;
  7. use Filament\Forms\Components\TextInput;
  8. use Filament\Forms\Get;
  9. class DocumentTotals extends Grid
  10. {
  11. protected string $view = 'filament.forms.components.document-totals';
  12. protected DocumentType $documentType = DocumentType::Invoice;
  13. protected function setUp(): void
  14. {
  15. parent::setUp();
  16. $this->schema([
  17. Select::make('discount_computation')
  18. ->label('Discount computation')
  19. ->hiddenLabel()
  20. ->options(AdjustmentComputation::class)
  21. ->default(AdjustmentComputation::Percentage)
  22. ->selectablePlaceholder(false)
  23. ->live(),
  24. TextInput::make('discount_rate')
  25. ->label('Discount rate')
  26. ->hiddenLabel()
  27. ->live()
  28. ->extraInputAttributes(['class' => 'text-right'])
  29. ->rate(
  30. computation: static fn (Get $get) => $get('discount_computation'),
  31. currency: static fn (Get $get) => $get('currency_code'),
  32. ),
  33. ]);
  34. }
  35. public function type(DocumentType | string $type): static
  36. {
  37. if (is_string($type)) {
  38. $type = DocumentType::from($type);
  39. }
  40. $this->documentType = $type;
  41. return $this;
  42. }
  43. public function getType(): DocumentType
  44. {
  45. return $this->documentType;
  46. }
  47. }