87 lines
2.6 KiB
PHP
87 lines
2.6 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
use Migrations\AbstractSeed;
|
|
|
|
/**
|
|
* SeedLookupTables seed.
|
|
*/
|
|
class JournalsTablesSeed extends AbstractSeed
|
|
{
|
|
/**
|
|
* Run Method.
|
|
*
|
|
* Write your database seeder using this method.
|
|
*
|
|
* More information on writing seeds is available here:
|
|
* https://book.cakephp.org/phinx/0/en/seeding.html
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run(): void
|
|
{
|
|
// base types
|
|
$stmt = $this->query('SELECT * FROM de_journal_types'); // returns PDOStatement
|
|
$existing = $stmt->fetchAll(); // returns the result as an array
|
|
if (!$existing) {
|
|
$journalTypes = [
|
|
[
|
|
'de_journal_type_code' => DE_JOURNAL_TYPE_SALES,
|
|
],
|
|
[
|
|
'de_journal_type_code' => DE_JOURNAL_TYPE_PURCHASING,
|
|
],
|
|
[
|
|
'de_journal_type_code' => DE_JOURNAL_TYPE_BANK,
|
|
],
|
|
[
|
|
'de_journal_type_code' => DE_JOURNAL_TYPE_MISC,
|
|
],
|
|
[
|
|
'de_journal_type_code' => DE_JOURNAL_TYPE_CASH,
|
|
],
|
|
];
|
|
|
|
$table = $this->table('de_journal_types');
|
|
$table->insert($journalTypes)->save();
|
|
}
|
|
|
|
|
|
// entity types
|
|
$stmt = $this->query('SELECT * FROM de_journals'); // returns PDOStatement
|
|
$existing = $stmt->fetchAll(); // returns the result as an array
|
|
if (!$existing) {
|
|
$entityTypes = [
|
|
[
|
|
'name' => 'Customer Invoices',
|
|
'de_journal_type_code' => DE_JOURNAL_TYPE_SALES,
|
|
'short_code' => 'SALES',
|
|
],
|
|
[
|
|
'name' => 'Vendor Bills',
|
|
'de_journal_type_code' => DE_JOURNAL_TYPE_PURCHASING,
|
|
'short_code' => 'BILLS',
|
|
],
|
|
[
|
|
'name' => 'Bank',
|
|
'de_journal_type_code' => DE_JOURNAL_TYPE_BANK,
|
|
'short_code' => 'BANK',
|
|
],
|
|
[
|
|
'name' => 'Misc.',
|
|
'de_journal_type_code' => DE_JOURNAL_TYPE_MISC,
|
|
'short_code' => 'MISC',
|
|
],
|
|
[
|
|
'name' => 'Cash',
|
|
'de_journal_type_code' => DE_JOURNAL_TYPE_CASH,
|
|
'short_code' => 'CASH',
|
|
],
|
|
];
|
|
|
|
$table = $this->table('de_journals');
|
|
$table->insert($entityTypes)->save();
|
|
}
|
|
}
|
|
}
|