Refactor the pricing calculation service and shipping rate import logic to improve consistency and reliability. This includes updating direction naming conventions, enhancing model casting, and adding comprehensive test suites. - Update `ShippingRatesImport` to use 'outbound' and 'inbound' instead of 'export' and 'import' - Refactor `PriceCalculatorService` to use a more modular calculation structure - Update `ShippingRate` model to use explicit property casting for zones - Add `HasFactory` trait to `Country` and `ShippingRate` models - Add new database factories for `Country` and `ShippingRate` - Implement new feature tests for API endpoints and service logic - Add new service tests for `PriceCalculatorService`
35 lines
1.3 KiB
PHP
35 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\ShippingRate;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\ShippingRate>
|
|
*/
|
|
class ShippingRateFactory extends Factory
|
|
{
|
|
protected $model = ShippingRate::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
// مقادیر باید دقیقاً با enum در migration یکسان باشند
|
|
'direction' => $this->faker->randomElement(['import', 'export']),
|
|
'type' => $this->faker->randomElement(['DOC_NORMAL', 'DOC_ECONOMY', 'PARCEL']),
|
|
'weight' => $this->faker->randomFloat(2, 0.1, 30),
|
|
'zone_1' => $this->faker->randomFloat(2, 10, 200),
|
|
'zone_2' => $this->faker->randomFloat(2, 10, 200),
|
|
'zone_3' => $this->faker->randomFloat(2, 10, 200),
|
|
'zone_4' => $this->faker->randomFloat(2, 10, 200),
|
|
'zone_5' => $this->faker->randomFloat(2, 10, 200),
|
|
'zone_6' => $this->faker->randomFloat(2, 10, 200),
|
|
'zone_7' => $this->faker->randomFloat(2, 10, 200),
|
|
'zone_8' => $this->faker->randomFloat(2, 10, 200),
|
|
'zone_9' => $this->faker->randomFloat(2, 10, 200),
|
|
'zone_10' => $this->faker->randomFloat(2, 10, 200),
|
|
];
|
|
}
|
|
}
|