Add formula-based product pricing (P/W/MG) for Parsian-style unit prices.

Port FormulaPriceService from colleague app so admins can compute a single unit price from reference mid, weight, and wage instead of offset coefficients.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-10 16:47:29 +03:30
co-authored by Cursor
parent 71a48c9c08
commit f421fcb83f
9 changed files with 515 additions and 9 deletions
@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
if (! Schema::hasTable('products')) {
return;
}
Schema::table('products', function (Blueprint $table) {
if (! Schema::hasColumn('products', 'price_formula_enabled')) {
if (Schema::hasColumn('products', 'app_price')) {
$table->boolean('price_formula_enabled')->default(false)->after('app_price');
} else {
$table->boolean('price_formula_enabled')->default(false);
}
}
if (! Schema::hasColumn('products', 'price_formula')) {
$table->text('price_formula')->nullable()->after('price_formula_enabled');
}
});
}
public function down(): void
{
if (! Schema::hasTable('products')) {
return;
}
Schema::table('products', function (Blueprint $table) {
$drop = [];
if (Schema::hasColumn('products', 'price_formula_enabled')) {
$drop[] = 'price_formula_enabled';
}
if (Schema::hasColumn('products', 'price_formula')) {
$drop[] = 'price_formula';
}
if ($drop !== []) {
$table->dropColumn($drop);
}
});
}
};