Skip to content

Commit

Permalink
Merge pull request #13 from andrewdwallo/dev
Browse files Browse the repository at this point in the history
Refraction of database tables, models, and filament resources for accuracy and space usage
  • Loading branch information
andrewdwallo authored Nov 4, 2022
2 parents 60dbcd0 + 3fb1667 commit 0f66d5c
Show file tree
Hide file tree
Showing 25 changed files with 881 additions and 1,097 deletions.
14 changes: 4 additions & 10 deletions app/Filament/Pages/ChartOfAccountsWidgets/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,8 @@ protected function getTableActions(): array
return $company->departments->pluck('name', 'id');
}),

Forms\Components\TextInput::make('code')
->required(),
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\TextInput::make('code')->required()->unique()->numeric()->minValue(100)->maxValue(199),
Forms\Components\TextInput::make('name')->required()->maxLength(50)->unique(),
Forms\Components\Select::make('type')
->required()
->options([
Expand Down Expand Up @@ -150,11 +147,8 @@ protected function getTableHeaderActions(): array
return $company->departments->pluck('name', 'id');
}),

Forms\Components\TextInput::make('code')
->required(),
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\TextInput::make('code')->required()->unique()->numeric()->minValue(118)->maxValue(199),
Forms\Components\TextInput::make('name')->required()->maxLength(50)->unique(),
Forms\Components\Select::make('type')
->required()
->options([
Expand Down
15 changes: 4 additions & 11 deletions app/Filament/Pages/ChartOfAccountsWidgets/Equities.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ protected function getTableColumns(): array
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('type'),
Tables\Columns\TextColumn::make('description')->hidden(),
Tables\Columns\TextColumn::make('expense_transactions_sum_amount')->sum('expense_transactions', 'amount')->money('USD', 2)->label('Amount'),
];
}

Expand Down Expand Up @@ -95,11 +94,8 @@ protected function getTableActions(): array
return $company->departments->pluck('name', 'id');
}),

Forms\Components\TextInput::make('code')
->required(),
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\TextInput::make('code')->required()->unique()->numeric()->minValue(300)->maxValue(399),
Forms\Components\TextInput::make('name')->required()->maxLength(50)->unique(),
Forms\Components\Select::make('type')
->required()
->options([
Expand Down Expand Up @@ -140,11 +136,8 @@ protected function getTableHeaderActions(): array
return $company->departments->pluck('name', 'id');
}),

Forms\Components\TextInput::make('code')
->required(),
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\TextInput::make('code')->required()->unique()->numeric()->minValue(300)->maxValue(399),
Forms\Components\TextInput::make('name')->required()->maxLength(50)->unique(),
Forms\Components\Select::make('type')
->required()
->options([
Expand Down
14 changes: 4 additions & 10 deletions app/Filament/Pages/ChartOfAccountsWidgets/Expenses.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,8 @@ protected function getTableActions(): array
return $company->departments->pluck('name', 'id');
}),

Forms\Components\TextInput::make('code')
->required(),
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\TextInput::make('code')->required()->unique()->numeric()->minValue(500)->maxValue(599),
Forms\Components\TextInput::make('name')->required()->maxLength(50)->unique(),
Forms\Components\Select::make('type')
->required()
->options([
Expand Down Expand Up @@ -142,11 +139,8 @@ protected function getTableHeaderActions(): array
return $company->departments->pluck('name', 'id');
}),

Forms\Components\TextInput::make('code')
->required(),
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\TextInput::make('code')->required()->unique()->numeric()->minValue(500)->maxValue(599),
Forms\Components\TextInput::make('name')->required()->maxLength(50)->unique(),
Forms\Components\Select::make('type')
->required()
->options([
Expand Down
15 changes: 4 additions & 11 deletions app/Filament/Pages/ChartOfAccountsWidgets/Liabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ protected function getTableColumns(): array
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('type'),
Tables\Columns\TextColumn::make('description')->hidden(),
Tables\Columns\TextColumn::make('expense_transactions_sum_amount')->sum('expense_transactions', 'amount')->money('USD', 2)->label('Amount'),
];
}

Expand Down Expand Up @@ -96,11 +95,8 @@ protected function getTableActions(): array
return $company->departments->pluck('name', 'id');
}),

Forms\Components\TextInput::make('code')
->required(),
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\TextInput::make('code')->required()->unique()->numeric()->minValue(200)->maxValue(299),
Forms\Components\TextInput::make('name')->required()->maxLength(50)->unique(),
Forms\Components\Select::make('type')
->required()
->options([
Expand Down Expand Up @@ -142,11 +138,8 @@ protected function getTableHeaderActions(): array
return $company->departments->pluck('name', 'id');
}),

Forms\Components\TextInput::make('code')
->required(),
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\TextInput::make('code')->required()->unique()->numeric()->minValue(200)->maxValue(299),
Forms\Components\TextInput::make('name')->required()->maxLength(50)->unique(),
Forms\Components\Select::make('type')
->required()
->options([
Expand Down
14 changes: 4 additions & 10 deletions app/Filament/Pages/ChartOfAccountsWidgets/Revenues.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,8 @@ protected function getTableActions(): array
return $company->departments->pluck('name', 'id');
}),

Forms\Components\TextInput::make('code')
->required(),
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\TextInput::make('code')->required()->unique()->numeric()->minValue(400)->maxValue(499),
Forms\Components\TextInput::make('name')->required()->maxLength(50)->unique(),
Forms\Components\Select::make('type')
->required()
->options([
Expand Down Expand Up @@ -140,11 +137,8 @@ protected function getTableHeaderActions(): array
return $company->departments->pluck('name', 'id');
}),

Forms\Components\TextInput::make('code')
->required(),
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\TextInput::make('code')->required()->unique()->numeric()->minValue(400)->maxValue(499),
Forms\Components\TextInput::make('name')->required()->maxLength(50)->unique(),
Forms\Components\Select::make('type')
->required()
->options([
Expand Down
8 changes: 4 additions & 4 deletions app/Filament/Pages/TransactionWidgets/Expenses.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function getTableColumns(): array
Tables\Columns\TextColumn::make('bank.bank_name', 'bank_name')->label('Bank Name'),
Tables\Columns\TextColumn::make('account.account_name', 'account_name')->label('Bank Account Name'),
Tables\Columns\TextColumn::make('card.card_name', 'card_name')->label('Card Network'),
Tables\Columns\TextColumn::make('date'),
Tables\Columns\TextColumn::make('paid_at')->label('Paid At'),
Tables\Columns\TextColumn::make('number'),
Tables\Columns\TextColumn::make('expense.name', 'name')->label('Account Name'),
Tables\Columns\TextColumn::make('merchant_name')->label('Merchant Name'),
Expand Down Expand Up @@ -121,7 +121,7 @@ protected function getTableActions(): array
return $account->cards->pluck('card_name', 'id');
}),

Forms\Components\DatePicker::make('date')->maxDate(now())->format('m/d/Y')->displayFormat('m/d/Y'),
Forms\Components\DatePicker::make('paid_at')->maxDate(now())->format('m/d/Y')->displayFormat('m/d/Y')->label('Paid At'),
Forms\Components\TextInput::make('number')->nullable()->numeric()->mask(fn (TextInput\Mask $mask) => $mask->money(prefix: 'TRA-0000', thousandsSeparator: '', decimalPlaces:0, isSigned: false))->label('Transaction Number'),
Forms\Components\Select::make('expense_id')->label('Expense Account')
->options(Expense::all()->pluck('name', 'id')->toArray()),
Expand Down Expand Up @@ -201,7 +201,7 @@ protected function getTableActions(): array
return $account->cards->pluck('card_name', 'id');
}),

Forms\Components\DatePicker::make('date')->maxDate(now())->format('m/d/Y')->displayFormat('m/d/Y'),
Forms\Components\DatePicker::make('paid_at')->maxDate(now())->format('m/d/Y')->displayFormat('m/d/Y')->label('Paid At'),
Forms\Components\TextInput::make('number')->nullable()->numeric()->mask(fn (TextInput\Mask $mask) => $mask->money(prefix: 'TRA-0000', thousandsSeparator: '', decimalPlaces:0, isSigned: false))->label('Transaction Number'),
Forms\Components\Select::make('expense_id')->label('Expense Account')
->options(Expense::all()->pluck('name', 'id')->toArray()),
Expand Down Expand Up @@ -287,7 +287,7 @@ protected function getTableHeaderActions(): array
return $account->cards->pluck('card_name', 'id');
}),

Forms\Components\DatePicker::make('date')->maxDate(now())->format('m/d/Y')->displayFormat('m/d/Y'),
Forms\Components\DatePicker::make('paid_at')->maxDate(now())->format('m/d/Y')->displayFormat('m/d/Y')->label('Paid At'),
Forms\Components\TextInput::make('number')->nullable()->numeric()->mask(fn (TextInput\Mask $mask) => $mask->money(prefix: 'TRA-0000', thousandsSeparator: '', decimalPlaces:0, isSigned: false))->label('Transaction Number'),
Forms\Components\Select::make('expense_id')->label('Expense Account')
->options(Expense::all()->pluck('name', 'id')->toArray()),
Expand Down
8 changes: 4 additions & 4 deletions app/Filament/Pages/TransactionWidgets/Incomes.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function getTableColumns(): array
Tables\Columns\TextColumn::make('bank.bank_name', 'bank_name')->label('Bank Name'),
Tables\Columns\TextColumn::make('account.account_name', 'account_name')->label('Bank Account Name'),
Tables\Columns\TextColumn::make('card.card_name', 'card_name')->label('Card Network'),
Tables\Columns\TextColumn::make('date'),
Tables\Columns\TextColumn::make('paid_at')->label('Paid At'),
Tables\Columns\TextColumn::make('number'),
Tables\Columns\TextColumn::make('revenue.name', 'name')->label('Account Name'),
Tables\Columns\TextColumn::make('merchant_name')->label('Merchant Name'),
Expand Down Expand Up @@ -121,7 +121,7 @@ protected function getTableActions(): array
return $account->cards->pluck('card_name', 'id');
}),

Forms\Components\DatePicker::make('date')->maxDate(now())->format('m/d/Y')->displayFormat('m/d/Y'),
Forms\Components\DatePicker::make('paid_at')->maxDate(now())->format('m/d/Y')->displayFormat('m/d/Y')->label('Paid At'),
Forms\Components\TextInput::make('number')->nullable()->numeric()->mask(fn (TextInput\Mask $mask) => $mask->money(prefix: 'TRA-0000', thousandsSeparator: '', decimalPlaces:0, isSigned: false))->label('Transaction Number'),
Forms\Components\Select::make('revenue_id')->label('Revenue/Income Account')
->options(Revenue::all()->pluck('name', 'id')->toArray()),
Expand Down Expand Up @@ -201,7 +201,7 @@ protected function getTableActions(): array
return $account->cards->pluck('card_name', 'id');
}),

Forms\Components\DatePicker::make('date')->maxDate(now())->format('m/d/Y')->displayFormat('m/d/Y'),
Forms\Components\DatePicker::make('paid_at')->maxDate(now())->format('m/d/Y')->displayFormat('m/d/Y')->label('Paid At'),
Forms\Components\TextInput::make('number')->nullable()->numeric()->mask(fn (TextInput\Mask $mask) => $mask->money(prefix: 'TRA-0000', thousandsSeparator: '', decimalPlaces:0, isSigned: false))->label('Transaction Number'),
Forms\Components\Select::make('revenue_id')->label('Revenue/Income Account')
->options(Revenue::all()->pluck('name', 'id')->toArray()),
Expand Down Expand Up @@ -287,7 +287,7 @@ protected function getTableHeaderActions(): array
return $account->cards->pluck('card_name', 'id');
}),

Forms\Components\DatePicker::make('date')->maxDate(now())->format('m/d/Y')->displayFormat('m/d/Y'),
Forms\Components\DatePicker::make('paid_at')->maxDate(now())->format('m/d/Y')->displayFormat('m/d/Y')->label('Paid At'),
Forms\Components\TextInput::make('number')->nullable()->numeric()->mask(fn (TextInput\Mask $mask) => $mask->money(prefix: 'TRA-0000', thousandsSeparator: '', decimalPlaces:0, isSigned: false))->label('Transaction Number'),
Forms\Components\Select::make('revenue_id')->label('Revenue/Income Account')
->options(Revenue::all()->pluck('name', 'id')->toArray()),
Expand Down
2 changes: 2 additions & 0 deletions app/Models/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class Asset extends Model
{
use HasFactory;

protected $table = 'assets';

protected $fillable = [
'company_id',
'department_id',
Expand Down
11 changes: 0 additions & 11 deletions app/Models/Customer.php

This file was deleted.

6 changes: 6 additions & 0 deletions app/Models/Equity.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class Equity extends Model
{
use HasFactory;

protected $table = 'equities';

protected $fillable = [
'company_id',
'department_id',
Expand All @@ -18,6 +20,10 @@ class Equity extends Model
'description',
];

protected $casts = [
'type' => 'array',
];

public function company()
{
return $this->belongsTo(Company::class);
Expand Down
6 changes: 6 additions & 0 deletions app/Models/Expense.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class Expense extends Model
{
use HasFactory;

protected $table = 'expenses';

protected $fillable = [
'company_id',
'department_id',
Expand All @@ -18,6 +20,10 @@ class Expense extends Model
'description',
];

protected $casts = [
'type' => 'array',
];

public function company()
{
return $this->belongsTo(Company::class);
Expand Down
37 changes: 7 additions & 30 deletions app/Models/ExpenseTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,21 @@ class ExpenseTransaction extends Model
{
use HasFactory;

protected $table = 'expense_transactions';

protected $fillable = [
'company_id',
'department_id',
'bank_id',
'account_id',
'card_id',
'asset_id',
'liability_id',
'expense_id',
'revenue_id',
'equity_id',
'date',
'asset_id',
'paid_at',
'number',
'type',
'category',
'merchant_name',
'description',
'amount',
'running_balance',
];

public function company()
Expand All @@ -50,38 +46,19 @@ public function account()
return $this->belongsTo(Account::class);
}

public function category()
{
return $this->belongsTo(Category::class);
}

public function card()
{
return $this->belongsTo(Card::class);
}

public function asset()
{
return $this->belongsTo(Asset::class);
}

public function liability()
{
return $this->belongsTo(Liability::class);
}

public function expense()
{
return $this->belongsTo(Expense::class);
}

public function equity()
{
return $this->belongsTo(Equity::class);
}

public function revenue()
public function asset()
{
return $this->belongsTo(Revenue::class);
return $this->belongsTo(Asset::class);
}

}
Loading

0 comments on commit 0f66d5c

Please sign in to comment.