add payment option

This commit is contained in:
2025-10-02 18:35:02 +02:00
parent 0e0912c81b
commit 971a9e89d1
27 changed files with 1327 additions and 34 deletions
+8 -33
View File
@@ -4,7 +4,6 @@
use App\Models\AccountType;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class AccountTypeSeeder extends Seeder
{
@@ -12,40 +11,16 @@ public function run(): void
{
$now = now();
// If table is empty, insert with explicit IDs so id=1 exists (matches default logic elsewhere)
if (AccountType::count() === 0) {
$rows = [
['id' => 1, 'name' => 'Default', 'description' => 'Default account type', 'created_at' => $now, 'updated_at' => $now],
['id' => 2, 'name' => 'Primary', 'description' => 'Primary account', 'created_at' => $now, 'updated_at' => $now],
['id' => 3, 'name' => 'Secondary', 'description' => 'Secondary account', 'created_at' => $now, 'updated_at' => $now],
['id' => 4, 'name' => 'Savings', 'description' => 'Savings account', 'created_at' => $now, 'updated_at' => $now],
['id' => 5, 'name' => 'Checking', 'description' => 'Checking account', 'created_at' => $now, 'updated_at' => $now],
['id' => 6, 'name' => 'Credit', 'description' => 'Credit account', 'created_at' => $now, 'updated_at' => $now],
['id' => 7, 'name' => 'Loan', 'description' => 'Loan account', 'created_at' => $now, 'updated_at' => $now],
['id' => 8, 'name' => 'Other', 'description' => 'Other account type', 'created_at' => $now, 'updated_at' => $now],
];
DB::table('account_types')->insert($rows);
return;
}
// If table already has data, ensure the basics exist (idempotent, no explicit IDs)
$names = [
'Default' => 'Default account type',
'Primary' => 'Primary account',
'Secondary' => 'Secondary account',
'Savings' => 'Savings account',
'Checking' => 'Checking account',
'Credit' => 'Credit account',
'Loan' => 'Loan account',
'Other' => 'Other account type',
$rows = [
['name' => 'Receivables', 'description' => 'Standard receivable account'],
['name' => 'Payables', 'description' => 'Standard payable account'],
['name' => 'Loan', 'description' => 'Loan and credit account'],
['name' => 'Savings', 'description' => 'Savings account type'],
['name' => 'Current', 'description' => 'Current/operational account'],
];
foreach ($names as $name => $desc) {
AccountType::updateOrCreate(
['name' => $name],
['description' => $desc]
);
foreach ($rows as $row) {
AccountType::updateOrCreate(['name' => $row['name']], ['description' => $row['description']]);
}
}
}
+2
View File
@@ -29,6 +29,8 @@ public function run(): void
);
$this->call([
AccountTypeSeeder::class,
PaymentSettingSeeder::class,
PersonSeeder::class,
SegmentSeeder::class,
ActionSeeder::class,
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace Database\Seeders;
use App\Models\PaymentSetting;
use Illuminate\Database\Seeder;
class PaymentSettingSeeder extends Seeder
{
public function run(): void
{
// Create default record if not exists
PaymentSetting::query()->firstOrCreate([], [
'default_currency' => 'EUR',
'create_activity_on_payment' => false,
'default_decision_id' => null,
'default_action_id' => null,
'activity_note_template' => 'Prejeto plačilo: {amount} {currency}',
]);
}
}