Expand types.

This commit is contained in:
James Cole
2017-11-18 15:53:27 +01:00
parent 03edf6c0a0
commit 5f127b7bec
4 changed files with 16 additions and 11 deletions

View File

@@ -38,6 +38,8 @@ class AccountType extends Model
const INITIAL_BALANCE = 'Initial balance account'; const INITIAL_BALANCE = 'Initial balance account';
const BENEFICIARY = 'Beneficiary account'; const BENEFICIARY = 'Beneficiary account';
const IMPORT = 'Import account'; const IMPORT = 'Import account';
const RECONCILIATION = 'Reconciliation account';
const LOAN = 'Loan';
/** /**
* The attributes that should be casted to native types. * The attributes that should be casted to native types.

View File

@@ -37,6 +37,7 @@ class TransactionType extends Model
const DEPOSIT = 'Deposit'; const DEPOSIT = 'Deposit';
const TRANSFER = 'Transfer'; const TRANSFER = 'Transfer';
const OPENING_BALANCE = 'Opening balance'; const OPENING_BALANCE = 'Opening balance';
const RECONCILIATION = 'Reconciliation';
/** /**
* The attributes that should be casted to native types. * The attributes that should be casted to native types.
@@ -58,13 +59,13 @@ class TransactionType extends Model
public static function routeBinder(string $type) public static function routeBinder(string $type)
{ {
if (!auth()->check()) { if (!auth()->check()) {
throw new NotFoundHttpException; throw new NotFoundHttpException();
} }
$transactionType = self::where('type', ucfirst($type))->first(); $transactionType = self::where('type', ucfirst($type))->first();
if (null !== $transactionType) { if (null !== $transactionType) {
return $transactionType; return $transactionType;
} }
throw new NotFoundHttpException; throw new NotFoundHttpException();
} }
/** /**

View File

@@ -21,14 +21,15 @@ class AccountTypeSeeder extends Seeder
{ {
public function run() public function run()
{ {
AccountType::create(['type' => 'Default account']); AccountType::create(['type' => AccountType::DEFAULT]);
AccountType::create(['type' => 'Cash account']); AccountType::create(['type' => AccountType::CASH]);
AccountType::create(['type' => 'Asset account']); AccountType::create(['type' => AccountType::ASSET]);
AccountType::create(['type' => 'Expense account']); AccountType::create(['type' => AccountType::EXPENSE]);
AccountType::create(['type' => 'Revenue account']); AccountType::create(['type' => AccountType::REVENUE]);
AccountType::create(['type' => 'Initial balance account']); AccountType::create(['type' => AccountType::INITIAL_BALANCE]);
AccountType::create(['type' => 'Beneficiary account']); AccountType::create(['type' => AccountType::BENEFICIARY]);
AccountType::create(['type' => 'Import account']); AccountType::create(['type' => AccountType::IMPORT]);
AccountType::create(['type' => 'Loan']); AccountType::create(['type' => AccountType::LOAN]);
AccountType::create(['type' => AccountType::RECONCILIATION]);
} }
} }

View File

@@ -25,5 +25,6 @@ class TransactionTypeSeeder extends Seeder
TransactionType::create(['type' => TransactionType::DEPOSIT]); TransactionType::create(['type' => TransactionType::DEPOSIT]);
TransactionType::create(['type' => TransactionType::TRANSFER]); TransactionType::create(['type' => TransactionType::TRANSFER]);
TransactionType::create(['type' => TransactionType::OPENING_BALANCE]); TransactionType::create(['type' => TransactionType::OPENING_BALANCE]);
TransactionType::create(['type' => TransactionType::RECONCILIATION]);
} }
} }