update account

This commit is contained in:
Husnu Setiawan 2025-02-13 22:42:17 +07:00
parent ed7182f9fd
commit c445ee43e3
10 changed files with 90 additions and 8 deletions

View File

@ -27,12 +27,12 @@ class ListRequest extends FormRequest
'search' => 'nullable',
'filter' => 'nullable|array',
'filter.*.column' => 'required|in:name',
'filter.*.column' => 'required|in:code,name,sheet,type,category,subcategory',
'filter.*.operator' => 'nullable|in:eq,in',
'filter.*.query' => 'required',
'sort' => 'nullable|array',
'sort.column' => 'nullable|in:name',
'sort.column' => 'nullable|in:code,name,sheet,type,category,subcategory',
'sort.dir' => 'nullable',
];
}

View File

@ -29,6 +29,7 @@ class StoreRequest extends FormRequest
'category' => 'required|string',
'subcategory' => 'nullable|string',
'structure' => 'required|string',
'totaling' => 'nullable|string',
];
}
}

View File

@ -13,7 +13,7 @@ class Account extends Model
use HasFactory;
use LogsActivity;
protected $fillable = ['code', 'name','sheet','type','category','subcategory','structure'];
protected $fillable = ['code', 'name','sheet','type','category','subcategory','structure','totaling'];
public function getActivitylogOptions(): LogOptions
{

View File

@ -3,6 +3,7 @@
namespace App\Repositories\Accounting;
use App\Models\Account;
use DB;
class AccountRepository
{
@ -15,7 +16,7 @@ class AccountRepository
$sortDir = @$params["sort"]["dir"] ?? "desc";
return Account::skip($offset)
->orderBy($sortColumn, $sortDir)
->orderBy(DB::raw("structure::ltree"), "asc")
->when(@$params["filter"], function ($query) use ($params) {
foreach ($params["filter"] as $filter) {

View File

@ -13,10 +13,18 @@ class RoleRepository
$offset = @$params["offset"] ?? 0;
$sortColumn = @$params["sort"]["column"] ?? "id";
$sortDir = @$params["sort"]["dir"] ?? "desc";
$search = @$params["search"] ?? 0;
return Role::skip($offset)
->orderBy($sortColumn, $sortDir)
->when($search, function ($query) use ($search){
$query->where(function($query) use ($search){
$query->where("name","ilike","%$search%");
$query->orWhere("code","ilike","%$search%");
});
})
->when(@$params["filter"], function ($query) use ($params) {
foreach ($params["filter"] as $filter) {
$query->where($filter["column"], $filter["query"]);

View File

@ -23,7 +23,7 @@ class AccountFactory extends Factory
'type' => fake()->randomElement(["header","posting","begin-total","end-total"]),
'category' => fake()->name(),
'subcategory' => fake()->name(),
'structure' => fake()->name(),
'structure' => str_replace(" ",".",strtolower(fake()->name())),
];
}
}

View File

@ -16,10 +16,11 @@ return new class extends Migration
$table->string('code')->unique();
$table->string('name');
$table->string('sheet'); // Balance/Income
$table->string('category'); // Assets, Equity, Liabilities, Income, Expense, Cost of Goods
$table->string('subcategory');
$table->string('type'); // Header, Begin-Total, Posting, End-Total
$table->string('category')->nullable(); // Assets, Equity, Liabilities, Income, Expense, Cost of Goods
$table->string('subcategory')->nullable();
$table->string('type')->nullable(); // Header, Begin-Total, Posting, End-Total
$table->string('structure');
$table->string('totaling')->nullable();
$table->timestamps();
});
}

View File

@ -0,0 +1,27 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateActivityLogTable extends Migration
{
public function up()
{
Schema::connection(config('activitylog.database_connection'))->create(config('activitylog.table_name'), function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('log_name')->nullable();
$table->text('description');
$table->nullableMorphs('subject', 'subject');
$table->nullableMorphs('causer', 'causer');
$table->json('properties')->nullable();
$table->timestamps();
$table->index('log_name');
});
}
public function down()
{
Schema::connection(config('activitylog.database_connection'))->dropIfExists(config('activitylog.table_name'));
}
}

View File

@ -0,0 +1,22 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddEventColumnToActivityLogTable extends Migration
{
public function up()
{
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
$table->string('event')->nullable()->after('subject_type');
});
}
public function down()
{
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
$table->dropColumn('event');
});
}
}

View File

@ -0,0 +1,22 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddBatchUuidColumnToActivityLogTable extends Migration
{
public function up()
{
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
$table->uuid('batch_uuid')->nullable()->after('properties');
});
}
public function down()
{
Schema::connection(config('activitylog.database_connection'))->table(config('activitylog.table_name'), function (Blueprint $table) {
$table->dropColumn('batch_uuid');
});
}
}