refactor: Remove point_per_ml and point_per_pcs fields from catalog entities.

This commit is contained in:
Yoga Pangestu 2025-12-20 09:20:55 +07:00
parent 29817744b3
commit d2578fff34
21 changed files with 0 additions and 24 deletions

View File

@ -141,7 +141,6 @@ private function prepareSavedData(): array
'size' => $this->size, 'size' => $this->size,
'cost_price' => parseRupiahToInt($this->cost_price == '' ? '0' : $this->cost_price), 'cost_price' => parseRupiahToInt($this->cost_price == '' ? '0' : $this->cost_price),
'sale_price' => parseRupiahToInt($this->sale_price), 'sale_price' => parseRupiahToInt($this->sale_price),
'point_per_pcs' => round($this->sale_price / 100),
'description' => $this->description, 'description' => $this->description,
]; ];
} }

View File

@ -184,7 +184,6 @@ private function prepareSavedData(): array
'sku' => $this->sku, 'sku' => $this->sku,
'cost_price' => parseRupiahToInt($this->cost_price == '' ? '0' : $this->cost_price), 'cost_price' => parseRupiahToInt($this->cost_price == '' ? '0' : $this->cost_price),
'sale_price' => parseRupiahToInt($this->sale_price), 'sale_price' => parseRupiahToInt($this->sale_price),
'point_per_ml' => round(parseRupiahToInt($this->sale_price) / 1000),
'base_notes' => $this->base_notes, 'base_notes' => $this->base_notes,
'middle_notes' => $this->middle_notes, 'middle_notes' => $this->middle_notes,
'top_notes' => $this->top_notes, 'top_notes' => $this->top_notes,

View File

@ -151,7 +151,6 @@ private function prepareSavedData(): array
'sku' => $this->sku, 'sku' => $this->sku,
'cost_price' => parseRupiahToInt($this->cost_price == '' ? '0' : $this->cost_price), 'cost_price' => parseRupiahToInt($this->cost_price == '' ? '0' : $this->cost_price),
'sale_price' => parseRupiahToInt($this->sale_price), 'sale_price' => parseRupiahToInt($this->sale_price),
'point_per_pcs' => round($this->sale_price / 100),
'description' => $this->description, 'description' => $this->description,
'outlet_ids' => $this->outlet_ids, 'outlet_ids' => $this->outlet_ids,
'image' => $this->image, 'image' => $this->image,

View File

@ -24,7 +24,6 @@ protected function casts(): array
return [ return [
'cost_price' => 'int', 'cost_price' => 'int',
'sale_price' => 'int', 'sale_price' => 'int',
'point_per_pcs' => 'int',
]; ];
} }

View File

@ -27,7 +27,6 @@ protected function casts(): array
'concentration' => Concentration::class, 'concentration' => Concentration::class,
'cost_price' => 'int', 'cost_price' => 'int',
'sale_price' => 'int', 'sale_price' => 'int',
'point_per_ml' => 'int',
]; ];
} }

View File

@ -24,7 +24,6 @@ protected function casts(): array
return [ return [
'cost_price' => 'int', 'cost_price' => 'int',
'sale_price' => 'int', 'sale_price' => 'int',
'point_per_pcs' => 'int',
]; ];
} }

View File

@ -19,7 +19,6 @@ public function definition(): array
'size' => $this->faker->randomNumber(2), 'size' => $this->faker->randomNumber(2),
'cost_price' => $this->faker->randomNumber(2), 'cost_price' => $this->faker->randomNumber(2),
'sale_price' => $this->faker->randomNumber(2), 'sale_price' => $this->faker->randomNumber(2),
'point_per_pcs' => round($costPrice / 100),
'description' => $this->faker->sentence(), 'description' => $this->faker->sentence(),
]; ];
} }

View File

@ -24,7 +24,6 @@ public function definition(): array
'concentration' => $this->faker->randomElement(Concentration::cases()), 'concentration' => $this->faker->randomElement(Concentration::cases()),
'cost_price' => $this->faker->numberBetween(50000, 250000), 'cost_price' => $this->faker->numberBetween(50000, 250000),
'sale_price' => $this->faker->numberBetween(80000, 400000), 'sale_price' => $this->faker->numberBetween(80000, 400000),
'point_per_ml' => $this->faker->numberBetween(1, 30),
'base_notes' => $this->faker->optional()->words(3, true), 'base_notes' => $this->faker->optional()->words(3, true),
'middle_notes' => $this->faker->optional()->words(3, true), 'middle_notes' => $this->faker->optional()->words(3, true),
'top_notes' => $this->faker->optional()->words(3, true), 'top_notes' => $this->faker->optional()->words(3, true),

View File

@ -20,7 +20,6 @@ public function definition(): array
'sku' => strtoupper($this->faker->unique()->bothify('PRD-#####')), 'sku' => strtoupper($this->faker->unique()->bothify('PRD-#####')),
'cost_price' => $this->faker->numberBetween(20000, 150000), 'cost_price' => $this->faker->numberBetween(20000, 150000),
'sale_price' => $this->faker->numberBetween(30000, 200000), 'sale_price' => $this->faker->numberBetween(30000, 200000),
'point_per_pcs' => $this->faker->numberBetween(1, 50),
'description' => $this->faker->optional()->paragraph(), 'description' => $this->faker->optional()->paragraph(),
]; ];
} }

View File

@ -21,7 +21,6 @@ public function up(): void
$table->enum('concentration', Concentration::values())->default(Concentration::EXTRAIT_DE_PERFUME)->comment(Concentration::comment()); $table->enum('concentration', Concentration::values())->default(Concentration::EXTRAIT_DE_PERFUME)->comment(Concentration::comment());
$table->unsignedInteger('cost_price')->default(0); $table->unsignedInteger('cost_price')->default(0);
$table->unsignedInteger('sale_price')->default(0); $table->unsignedInteger('sale_price')->default(0);
$table->unsignedInteger('point_per_ml');
$table->string('base_notes')->nullable(); $table->string('base_notes')->nullable();
$table->string('middle_notes')->nullable(); $table->string('middle_notes')->nullable();
$table->string('top_notes')->nullable(); $table->string('top_notes')->nullable();

View File

@ -18,7 +18,6 @@ public function up(): void
$table->string('sku', 20)->unique(); $table->string('sku', 20)->unique();
$table->unsignedInteger('cost_price')->default(0); $table->unsignedInteger('cost_price')->default(0);
$table->unsignedInteger('sale_price')->default(0); $table->unsignedInteger('sale_price')->default(0);
$table->unsignedInteger('point_per_pcs');
$table->text('description')->nullable(); $table->text('description')->nullable();
$table->timestamp('created_at')->useCurrent(); $table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();

View File

@ -18,7 +18,6 @@ public function up(): void
$table->unsignedInteger('size'); $table->unsignedInteger('size');
$table->unsignedInteger('cost_price')->default(0); $table->unsignedInteger('cost_price')->default(0);
$table->unsignedInteger('sale_price')->default(0); $table->unsignedInteger('sale_price')->default(0);
$table->unsignedInteger('point_per_pcs');
$table->text('description')->nullable(); $table->text('description')->nullable();
$table->timestamp('created_at')->useCurrent(); $table->timestamp('created_at')->useCurrent();
$table->timestamp('updated_at')->nullable()->useCurrentOnUpdate(); $table->timestamp('updated_at')->nullable()->useCurrentOnUpdate();

View File

@ -33,7 +33,6 @@ public function run(): void
'size' => $bottle['size'], 'size' => $bottle['size'],
'cost_price' => $bottle['cost_price'], 'cost_price' => $bottle['cost_price'],
'sale_price' => $bottle['cost_price'] * 2, 'sale_price' => $bottle['cost_price'] * 2,
'point_per_pcs' => round($bottle['cost_price'] / 100),
'description' => fake()->sentence(10), 'description' => fake()->sentence(10),
]); ]);

View File

@ -44,7 +44,6 @@ public function run(): void
'concentration' => fake()->randomElement(Concentration::values()), 'concentration' => fake()->randomElement(Concentration::values()),
'cost_price' => fake()->numberBetween(5, 11) * 100, 'cost_price' => fake()->numberBetween(5, 11) * 100,
'sale_price' => $salePrice, 'sale_price' => $salePrice,
'point_per_ml' => round($salePrice / 100),
'base_notes' => fake()->optional()->randomElement(['Amber', 'Musk', 'Vanilla', 'Sandalwood', 'Leather']), 'base_notes' => fake()->optional()->randomElement(['Amber', 'Musk', 'Vanilla', 'Sandalwood', 'Leather']),
'middle_notes' => fake()->optional()->randomElement(['Rose', 'Jasmine', 'Patchouli', 'Cedarwood', 'Iris']), 'middle_notes' => fake()->optional()->randomElement(['Rose', 'Jasmine', 'Patchouli', 'Cedarwood', 'Iris']),
'top_notes' => fake()->optional()->randomElement(['Citrus', 'Bergamot', 'Pepper', 'Mint', 'Lavender']), 'top_notes' => fake()->optional()->randomElement(['Citrus', 'Bergamot', 'Pepper', 'Mint', 'Lavender']),

View File

@ -36,7 +36,6 @@ public function run(): void
'sku' => $sku, 'sku' => $sku,
'cost_price' => fake()->numberBetween(15, 80) * 1000, 'cost_price' => fake()->numberBetween(15, 80) * 1000,
'sale_price' => $salePrice, 'sale_price' => $salePrice,
'point_per_pcs' => round($salePrice / 100),
'description' => fake()->sentence(12), 'description' => fake()->sentence(12),
]); ]);

View File

@ -91,7 +91,6 @@ function mountBottleCreateComponent(User $user)
expect($bottle->size)->toBe(100); expect($bottle->size)->toBe(100);
expect($bottle->cost_price)->toBe(50000); expect($bottle->cost_price)->toBe(50000);
expect($bottle->sale_price)->toBe(75000); expect($bottle->sale_price)->toBe(75000);
expect($bottle->point_per_pcs)->toBe(750); // 75000 / 100
expect($bottle->description)->toBe($data['description']); expect($bottle->description)->toBe($data['description']);
expect($bottle->outlets)->toHaveCount(2); expect($bottle->outlets)->toHaveCount(2);
}); });
@ -342,5 +341,4 @@ function mountBottleCreateComponent(User $user)
$bottle = Bottle::where('size', 500)->first(); $bottle = Bottle::where('size', 500)->first();
expect($bottle->cost_price)->toBe(5000000); expect($bottle->cost_price)->toBe(5000000);
expect($bottle->sale_price)->toBe(7500000); expect($bottle->sale_price)->toBe(7500000);
expect($bottle->point_per_pcs)->toBe(75000); // 7500000 / 100
}); });

View File

@ -112,7 +112,6 @@ function mountBottleEditComponent(User $user, Bottle $bottle)
expect($bottle->size)->toBe(100); expect($bottle->size)->toBe(100);
expect($bottle->cost_price)->toBe(40000); expect($bottle->cost_price)->toBe(40000);
expect($bottle->sale_price)->toBe(60000); expect($bottle->sale_price)->toBe(60000);
expect($bottle->point_per_pcs)->toBe(600); // 60000 / 100
expect($bottle->description)->toBe($updateData['description']); expect($bottle->description)->toBe($updateData['description']);
expect($bottle->outlets)->toHaveCount(2); expect($bottle->outlets)->toHaveCount(2);
}); });

View File

@ -117,7 +117,6 @@ function mountPerfumeCreateComponent(User $user)
expect($perfume->brand_id)->toBe($data['brand_id']); expect($perfume->brand_id)->toBe($data['brand_id']);
expect($perfume->cost_price)->toBe(150000); expect($perfume->cost_price)->toBe(150000);
expect($perfume->sale_price)->toBe(250000); expect($perfume->sale_price)->toBe(250000);
expect($perfume->point_per_ml)->toBe(250); // 250000 / 1000
expect($perfume->concentration->value)->toBe($data['concentration']); expect($perfume->concentration->value)->toBe($data['concentration']);
expect($perfume->base_notes)->toBe($data['base_notes']); expect($perfume->base_notes)->toBe($data['base_notes']);
expect($perfume->middle_notes)->toBe($data['middle_notes']); expect($perfume->middle_notes)->toBe($data['middle_notes']);
@ -453,5 +452,4 @@ function mountPerfumeCreateComponent(User $user)
$perfume = Perfume::where('sku', 'EP001')->first(); $perfume = Perfume::where('sku', 'EP001')->first();
expect($perfume->cost_price)->toBe(10000000); expect($perfume->cost_price)->toBe(10000000);
expect($perfume->sale_price)->toBe(15000000); expect($perfume->sale_price)->toBe(15000000);
expect($perfume->point_per_ml)->toBe(15000); // 15000000 / 1000
}); });

View File

@ -148,7 +148,6 @@ function mountPerfumeEditComponent(User $user, Perfume $perfume)
expect($perfume->brand_id)->toBe($updateData['brand_id']); expect($perfume->brand_id)->toBe($updateData['brand_id']);
expect($perfume->cost_price)->toBe(150000); expect($perfume->cost_price)->toBe(150000);
expect($perfume->sale_price)->toBe(300000); expect($perfume->sale_price)->toBe(300000);
expect($perfume->point_per_ml)->toBe(300); // 300000 / 1000
expect($perfume->concentration->value)->toBe($updateData['concentration']); expect($perfume->concentration->value)->toBe($updateData['concentration']);
expect($perfume->base_notes)->toBe($updateData['base_notes']); expect($perfume->base_notes)->toBe($updateData['base_notes']);
expect($perfume->middle_notes)->toBe($updateData['middle_notes']); expect($perfume->middle_notes)->toBe($updateData['middle_notes']);

View File

@ -91,7 +91,6 @@ function mountProductCreateComponent(User $user)
expect($product->sku)->toBe($data['sku']); expect($product->sku)->toBe($data['sku']);
expect($product->cost_price)->toBe(10000); expect($product->cost_price)->toBe(10000);
expect($product->sale_price)->toBe(15000); expect($product->sale_price)->toBe(15000);
expect($product->point_per_pcs)->toBe(150); // 15000 / 100
expect($product->description)->toBe($data['description']); expect($product->description)->toBe($data['description']);
expect($product->outlets)->toHaveCount(2); expect($product->outlets)->toHaveCount(2);
}); });
@ -349,5 +348,4 @@ function mountProductCreateComponent(User $user)
$product = Product::where('sku', 'EP001')->first(); $product = Product::where('sku', 'EP001')->first();
expect($product->cost_price)->toBe(10000000); expect($product->cost_price)->toBe(10000000);
expect($product->sale_price)->toBe(15000000); expect($product->sale_price)->toBe(15000000);
expect($product->point_per_pcs)->toBe(150000); // 15000000 / 100
}); });

View File

@ -112,7 +112,6 @@ function mountProductEditComponent(User $user, Product $product)
expect($product->sku)->toBe($updateData['sku']); expect($product->sku)->toBe($updateData['sku']);
expect($product->cost_price)->toBe(12000); expect($product->cost_price)->toBe(12000);
expect($product->sale_price)->toBe(18000); expect($product->sale_price)->toBe(18000);
expect($product->point_per_pcs)->toBe(180); // 18000 / 100
expect($product->description)->toBe($updateData['description']); expect($product->description)->toBe($updateData['description']);
expect($product->outlets)->toHaveCount(2); expect($product->outlets)->toHaveCount(2);
}); });