added reconciliation factory
This commit is contained in:
parent
9ac0bab7ca
commit
4f44414450
@ -3,9 +3,12 @@
|
|||||||
namespace App\Models\Banking;
|
namespace App\Models\Banking;
|
||||||
|
|
||||||
use App\Abstracts\Model;
|
use App\Abstracts\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
|
||||||
class Reconciliation extends Model
|
class Reconciliation extends Model
|
||||||
{
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
protected $table = 'reconciliations';
|
protected $table = 'reconciliations';
|
||||||
|
|
||||||
protected $dates = ['deleted_at', 'started_at', 'ended_at'];
|
protected $dates = ['deleted_at', 'started_at', 'ended_at'];
|
||||||
@ -38,4 +41,14 @@ class Reconciliation extends Model
|
|||||||
{
|
{
|
||||||
return $this->belongsTo('App\Models\Banking\Account');
|
return $this->belongsTo('App\Models\Banking\Account');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new factory instance for the model.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||||
|
*/
|
||||||
|
protected static function newFactory()
|
||||||
|
{
|
||||||
|
return \Database\Factories\Reconciliation::new();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,6 @@ class Media extends BaseMedia
|
|||||||
{
|
{
|
||||||
use SoftDeletes, Tenants;
|
use SoftDeletes, Tenants;
|
||||||
|
|
||||||
protected $tenantable = true;
|
|
||||||
|
|
||||||
protected $dates = ['deleted_at'];
|
protected $dates = ['deleted_at'];
|
||||||
|
|
||||||
protected $fillable = ['company_id'];
|
protected $fillable = ['company_id'];
|
||||||
|
63
database/factories/Reconciliation.php
Normal file
63
database/factories/Reconciliation.php
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Abstracts\Factory;
|
||||||
|
use App\Models\Banking\Reconciliation as Model;
|
||||||
|
use App\Utilities\Date;
|
||||||
|
|
||||||
|
class Reconciliation extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The name of the factory's corresponding model.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $model = Model::class;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function definition()
|
||||||
|
{
|
||||||
|
$started_at = $this->faker->dateTimeBetween(now()->startOfYear(), now()->endOfYear())->format('Y-m-d H:i:s');
|
||||||
|
$ended_at = Date::parse($started_at)->addDays($this->faker->randomNumber(3))->format('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
return [
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'account_id' => '1',
|
||||||
|
'currency_code' => setting('default.currency'),
|
||||||
|
'opening_balance' => '0',
|
||||||
|
'closing_balance' => '10',
|
||||||
|
'started_at' => $started_at,
|
||||||
|
'ended_at' => $ended_at,
|
||||||
|
'reconcile' => $this->faker->boolean ? 1 : 0,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate that the model is reconciled.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||||
|
*/
|
||||||
|
public function reconciled()
|
||||||
|
{
|
||||||
|
return $this->state([
|
||||||
|
'reconcile' => 1,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate that the model is not reconciled.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Factories\Factory
|
||||||
|
*/
|
||||||
|
public function notreconciled()
|
||||||
|
{
|
||||||
|
return $this->state([
|
||||||
|
'reconcile' => 0,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -3,11 +3,12 @@
|
|||||||
namespace Tests\Feature\Banking;
|
namespace Tests\Feature\Banking;
|
||||||
|
|
||||||
use App\Jobs\Banking\CreateReconciliation;
|
use App\Jobs\Banking\CreateReconciliation;
|
||||||
|
use App\Models\Banking\Reconciliation;
|
||||||
use Tests\Feature\FeatureTestCase;
|
use Tests\Feature\FeatureTestCase;
|
||||||
|
|
||||||
class ReconciliationsTest extends FeatureTestCase
|
class ReconciliationsTest extends FeatureTestCase
|
||||||
{
|
{
|
||||||
public function testItShouldSeeReconciliationtListPage()
|
public function testItShouldSeeReconciliationListPage()
|
||||||
{
|
{
|
||||||
$this->loginAs()
|
$this->loginAs()
|
||||||
->get(route('reconciliations.index'))
|
->get(route('reconciliations.index'))
|
||||||
@ -76,16 +77,6 @@ class ReconciliationsTest extends FeatureTestCase
|
|||||||
|
|
||||||
private function getRequest()
|
private function getRequest()
|
||||||
{
|
{
|
||||||
return [
|
return Reconciliation::factory()->reconciled()->raw();
|
||||||
'company_id' => $this->company->id,
|
|
||||||
'account_id' => '1',
|
|
||||||
'currency_code' => setting('default.currency'),
|
|
||||||
'opening_balance' => '0',
|
|
||||||
'closing_balance' => '10',
|
|
||||||
'started_at' => $this->faker->date(),
|
|
||||||
'ended_at' => $this->faker->date(),
|
|
||||||
'reconcile' => null,
|
|
||||||
'reconciled' => '1',
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user