| 1 |
<?php |
| 2 |
|
| 3 |
namespace App\Billingo\Factories; |
| 4 |
|
| 5 |
use App\Billingo\Enums\CorrectionTypeEnum; |
| 6 |
use App\Billingo\Enums\CurrencyEnum; |
| 7 |
use App\Billingo\Enums\Document\LanguageEnum; |
| 8 |
use App\Billingo\Enums\Document\NotificationStatusEnum; |
| 9 |
use App\Billingo\Enums\Document\TypeEnum; |
| 10 |
use App\Billingo\Enums\OnlineSzamlaStatusEnum; |
| 11 |
use App\Billingo\Enums\PaymentMethodEnum; |
| 12 |
use App\Billingo\Enums\PaymentStatusEnum; |
| 13 |
use App\Billingo\Models\Discount; |
| 14 |
use App\Billingo\Models\Document\DocumentAncestor; |
| 15 |
use App\Billingo\Models\Document\DocumentInstantPaymentRequest; |
| 16 |
use App\Billingo\Models\Document\DocumentItem; |
| 17 |
use App\Billingo\Models\Document\DocumentPartner; |
| 18 |
use App\Billingo\Models\Document\DocumentProductData; |
| 19 |
use App\Billingo\Models\Document\DocumentSettings; |
| 20 |
use App\Billingo\Models\Document\DocumentSummary; |
| 21 |
use App\Billingo\Models\Document\Organization; |
| 22 |
use App\Billingo\Models\Partner\Partner; |
| 23 |
|
| 24 |
class DocumentFactory extends BaseFactory |
| 25 |
{ |
| 26 |
|
| 27 |
public function definition(): array |
| 28 |
{ |
| 29 |
return [ |
| 30 |
'id' => $this->faker->numberBetween(1, 1000), |
| 31 |
'invoice_number' => $this->faker->regexify('202[0-9]-[0-9]{6}'), |
| 32 |
'type' => $this->faker->randomElement(getEnumValues(TypeEnum::class)), |
| 33 |
'cancelled' => $this->faker->boolean(), |
| 34 |
'block_id' => $this->faker->numberBetween(1, 10), |
| 35 |
'payment_status' => $this->faker->randomElement(getEnumValues(PaymentStatusEnum::class)), |
| 36 |
'payment_method' => $this->faker->randomElement(getEnumValues(PaymentMethodEnum::class)), |
| 37 |
'gross_total' => $this->faker->randomFloat(2, 100, 10000), |
| 38 |
'currency' => $this->faker->randomElement(getEnumValues(CurrencyEnum::class)), |
| 39 |
'conversion_rate' => $this->faker->randomFloat(2, 1, 100), |
| 40 |
'invoice_date' => $this->faker->date(), |
| 41 |
'fulfillment_date' => $this->faker->date(), |
| 42 |
'due_date' => $this->faker->date(), |
| 43 |
'paid_date' => $this->faker->date(), |
| 44 |
'organization' => Organization::factory(), |
| 45 |
'partner' => Partner::factory(), |
| 46 |
'document_partner' => DocumentPartner::factory(), |
| 47 |
'electronic' => $this->faker->boolean(), |
| 48 |
'comment' => $this->faker->sentence(), |
| 49 |
'tags' => [$this->faker->word(), $this->faker->word()], |
| 50 |
'notification_status' => $this->faker->randomElement(getEnumValues(NotificationStatusEnum::class)), |
| 51 |
'language' => $this->faker->randomElement(getEnumValues(LanguageEnum::class)), |
| 52 |
'items' => [DocumentItem::factory(), DocumentItem::factory()], |
| 53 |
'summary' => DocumentSummary::factory(), |
| 54 |
'settings' => DocumentSettings::factory(), |
| 55 |
'online_szamla_status' => $this->faker->randomElement(getEnumValues(OnlineSzamlaStatusEnum::class)), |
| 56 |
'related_documents' => [DocumentAncestor::factory(), DocumentAncestor::factory()], |
| 57 |
'discount' => Discount::factory(), |
| 58 |
'correction_type' => $this->faker->randomElement(getEnumValues(CorrectionTypeEnum::class)), |
| 59 |
'recurring_id' => $this->faker->numberBetween(1, 100), |
| 60 |
]; |
| 61 |
} |
| 62 |
|
| 63 |
public function insert(): array |
| 64 |
{ |
| 65 |
return [ |
| 66 |
'vendor_id' => $this->faker->optional()->word(), |
| 67 |
'partner_id' => $this->faker->numberBetween(1, 1000), |
| 68 |
'block_id' => $this->faker->numberBetween(1, 100), |
| 69 |
'bank_account_id' => $this->faker->optional()->numberBetween(1, 1000), |
| 70 |
'type' => $this->faker->randomElement(getEnumValues(TypeEnum::class)), |
| 71 |
'fulfillment_date' => $this->faker->dateTimeBetween('2010-01-01')->format('Y-m-d'), |
| 72 |
'due_date' => $this->faker->dateTimeBetween('2010-01-01')->format('Y-m-d'), |
| 73 |
'payment_method' => $this->faker->randomElement(getEnumValues(PaymentMethodEnum::class)), |
| 74 |
'language' => $this->faker->randomElement(getEnumValues(LanguageEnum::class)), |
| 75 |
'currency' => $this->faker->randomElement(getEnumValues(CurrencyEnum::class)), |
| 76 |
'conversion_rate' => $this->faker->optional(0.9, 1)->randomFloat(2, 0.5, 1.5), |
| 77 |
'electronic' => $this->faker->optional(0.9, false)->boolean(), |
| 78 |
'paid' => $this->faker->optional(0.9, false)->boolean(), |
| 79 |
'items' => [$this->faker |
| 80 |
->randomElement([ |
| 81 |
DocumentItem::factory(), |
| 82 |
DocumentProductData::factory()])], |
| 83 |
'comment' => $this->faker->optional()->sentence(), |
| 84 |
'settings' => $this->faker->boolean(40) |
| 85 |
? DocumentSettings::factory() |
| 86 |
: null, |
| 87 |
'advance_invoice' => [$this->faker->numberBetween(1, 1000)], |
| 88 |
'discount' => $this->faker->boolean(40) |
| 89 |
? Discount::factory() |
| 90 |
: null, |
| 91 |
'instant_payment' => $this->faker->optional()->boolean(), |
| 92 |
'instant_payment_request' => $this->faker->boolean(90) |
| 93 |
? DocumentInstantPaymentRequest::factory() |
| 94 |
: null, |
| 95 |
]; |
| 96 |
} |
| 97 |
} |
| 98 |
|