feat(shayegan): per-product item code and auto customer Account/Put
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (Schema::hasTable('products') && ! Schema::hasColumn('products', 'shayegan_item_number')) {
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->string('shayegan_item_number', 32)->nullable()->after('finance_p_name');
|
||||
});
|
||||
}
|
||||
|
||||
if (Schema::hasTable('shayegan') && ! Schema::hasColumn('shayegan', 'product_id')) {
|
||||
Schema::table('shayegan', function (Blueprint $table) {
|
||||
$table->unsignedBigInteger('product_id')->nullable()->after('order_id')->index();
|
||||
});
|
||||
}
|
||||
|
||||
if (! Schema::hasTable('settings')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->insertSettingIfMissing('shayegan_kol_customer', [
|
||||
'value' => '121',
|
||||
'title_fa' => 'کد کل حساب دریافتنی مشتری (شایگان)',
|
||||
'description' => 'طبق راهنمای حسابداری بورس مس: کل 121 — معین در shayegan_moin_customer (12101). فعلاً فقط مستند؛ Account/Put از MoinNumber استفاده میکند.',
|
||||
'type' => 'text',
|
||||
'menu' => 'accounting_shayegan',
|
||||
]);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (Schema::hasTable('products') && Schema::hasColumn('products', 'shayegan_item_number')) {
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->dropColumn('shayegan_item_number');
|
||||
});
|
||||
}
|
||||
|
||||
if (Schema::hasTable('shayegan') && Schema::hasColumn('shayegan', 'product_id')) {
|
||||
Schema::table('shayegan', function (Blueprint $table) {
|
||||
$table->dropColumn('product_id');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{value:string,title_fa:string,description:string,type:string,menu:string} $meta
|
||||
*/
|
||||
private function insertSettingIfMissing(string $key, array $meta): void
|
||||
{
|
||||
$exists = DB::table('settings')->where('key', $key)->exists();
|
||||
if ($exists) {
|
||||
return;
|
||||
}
|
||||
|
||||
DB::table('settings')->insert([
|
||||
'key' => $key,
|
||||
'value' => $meta['value'],
|
||||
'title_fa' => $meta['title_fa'],
|
||||
'description' => $meta['description'],
|
||||
'type' => $meta['type'],
|
||||
'menu' => $meta['menu'],
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user