Files
InvoiceShelf/database/factories/PaymentFactory.php
Darko Gjorgjijoski 947d00a9f1 refactor(services): Documents→Document + ExchangeRate→Integrations/ExchangeRate
Two follow-ups to the Services reorg that landed in 6d1816bd.

**Documents → Document** (singular). Documents/ was the only plural subdir in app/Services/ — every other bucket (Company, Mail, Module, Pdf, Storage, Update, ExchangeRate) was singular. Renaming to Document/ normalizes the whole tree.

**ExchangeRate → Integrations/ExchangeRate**. Introduces Integrations/ as an umbrella for external-service adapter subsystems. Exchange rate providers move in first; AI providers, payment gateways, and any other driver-pattern integrations land as sibling subdirs (Integrations/Ai/, Integrations/Payment/) without another reorg. Integrations/ was chosen over Providers/ to avoid conceptual collision with Laravel's app/Providers/ — 'check the providers' shouldn't be ambiguous.

17 files moved, 21 consumer files rewritten to point at the new namespaces via literal-string replacement (same approach as the previous reorg). 350 tests pass, Pint clean.
2026-04-11 11:30:00 +02:00

48 lines
1.5 KiB
PHP

<?php
namespace Database\Factories;
use App\Models\Currency;
use App\Models\Customer;
use App\Models\Payment;
use App\Models\PaymentMethod;
use App\Models\User;
use App\Services\Document\SerialNumberService;
use Illuminate\Database\Eloquent\Factories\Factory;
class PaymentFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Payment::class;
/**
* Define the model's default state.
*/
public function definition(): array
{
$sequenceNumber = (new SerialNumberService)
->setModel(new Payment)
->setCompany(User::find(1)->companies()->first()->id)
->setNextNumbers();
return [
'company_id' => User::find(1)->companies()->first()->id,
'payment_date' => $this->faker->date('Y-m-d', 'now'),
'notes' => $this->faker->text(80),
'amount' => $this->faker->randomDigitNotNull(),
'sequence_number' => $sequenceNumber->nextSequenceNumber,
'customer_sequence_number' => $sequenceNumber->nextCustomerSequenceNumber,
'payment_number' => $sequenceNumber->getNextNumber(),
'unique_hash' => str_random(60),
'payment_method_id' => PaymentMethod::find(1)->id,
'customer_id' => Customer::factory(),
'base_amount' => $this->faker->randomDigitNotNull(),
'currency_id' => Currency::find(1)->id,
];
}
}