Fixes and tests for the journal and journaled transactions #130

This commit is contained in:
Nabeel Shahzad
2018-02-28 21:52:36 -06:00
parent 1794549a20
commit 498e795e4b
9 changed files with 213 additions and 33 deletions

View File

@@ -0,0 +1,9 @@
<?php
use Faker\Generator as Faker;
$factory->define(App\Models\Journal::class, function (Faker $faker) {
return [
'currency' => 'USD',
];
});

View File

@@ -0,0 +1,17 @@
<?php
use Faker\Generator as Faker;
$factory->define(App\Models\JournalTransactions::class, function (Faker $faker) {
return [
'transaction_group' => \Ramsey\Uuid\Uuid::uuid4()->toString(),
'journal_id' => function () {
return factory(App\Models\Journal::class)->create()->id;
},
'credit' => $faker->numberBetween(100, 10000),
'debit' => $faker->numberBetween(100, 10000),
'currency' => 'USD',
'memo' => $faker->sentence(6),
'post_date' => \Carbon\Carbon::now(),
];
});

View File

@@ -17,8 +17,8 @@ class CreateJournalTransactionsTable extends Migration
$table->char('id', 36)->unique();
$table->char('transaction_group', 36)->nullable();
$table->integer('journal_id');
$table->unsignedBigInteger('debit')->nullable();
$table->unsignedBigInteger('credit')->nullable();
$table->unsignedBigInteger('debit')->nullable();
$table->char('currency', 5);
$table->text('memo')->nullable();
$table->char('ref_class', 32)->nullable();

View File

@@ -17,9 +17,9 @@ class CreateJournalsTable extends Migration
$table->increments('id');
$table->unsignedInteger('ledger_id')->nullable();
$table->bigInteger('balance')->default(0);
$table->char('currency', 5);
$table->char('morphed_type', 32);
$table->integer('morphed_id');
$table->string('currency', 5);
$table->string('morphed_type', 32)->nullable();
$table->unsignedInteger('morphed_id')->nullable();
$table->timestamps();
});
}