您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. use App\Enums\Accounting\JournalEntryType;
  3. use App\Enums\Setting\EntityType;
  4. use App\Filament\Company\Pages\CreateCompany;
  5. use App\Models\Accounting\Account;
  6. use App\Models\Accounting\Transaction;
  7. use App\Models\Company;
  8. use function Pest\Livewire\livewire;
  9. function createCompany(string $name): Company
  10. {
  11. livewire(CreateCompany::class)
  12. ->fillForm([
  13. 'name' => $name,
  14. 'profile.email' => 'company@gmail.com',
  15. 'profile.entity_type' => EntityType::LimitedLiabilityCompany,
  16. 'profile.country' => 'US',
  17. 'locale.language' => 'en',
  18. 'currencies.code' => 'USD',
  19. ])
  20. ->call('register')
  21. ->assertHasNoErrors();
  22. return auth()->user()->currentCompany;
  23. }
  24. /**
  25. * Get the debit and credit accounts for a transaction.
  26. *
  27. * @return array<Account>
  28. */
  29. function getTransactionDebitAndCreditAccounts(Transaction $transaction): array
  30. {
  31. $debitAccount = $transaction->journalEntries->where('type', JournalEntryType::Debit)->firstOrFail()->account;
  32. $creditAccount = $transaction->journalEntries->where('type', JournalEntryType::Credit)->firstOrFail()->account;
  33. return [$debitAccount, $creditAccount];
  34. }