mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 23:24:36 -04:00
fixes for tests
This commit is contained in:
parent
49ac6a3d50
commit
c085845da1
@ -198,6 +198,7 @@ class CreateSingleAccount extends Command
|
|||||||
$btr = BankTransactionRule::factory()->create([
|
$btr = BankTransactionRule::factory()->create([
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
'company_id' => $company->id,
|
'company_id' => $company->id,
|
||||||
|
'applies_to' => (bool)rand(0,1) ? 'CREDIT' : 'DEBIT',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->info('Creating '.$this->count.' clients');
|
$this->info('Creating '.$this->count.' clients');
|
||||||
|
@ -26,7 +26,7 @@ class BankTransactionRuleFactory extends Factory
|
|||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'name' => $this->faker->name(),
|
'name' => $this->faker->name(),
|
||||||
'applies_to' => (bool)rand(0,1) ? 'CREDIT' : 'DEBIT',
|
// 'applies_to' => (bool)rand(0,1) ? 'CREDIT' : 'DEBIT',
|
||||||
'matches_on_all' => (bool)rand(0,1),
|
'matches_on_all' => (bool)rand(0,1),
|
||||||
'auto_convert' => (bool)rand(0,1),
|
'auto_convert' => (bool)rand(0,1),
|
||||||
];
|
];
|
||||||
|
@ -25,7 +25,6 @@ use Tests\TestCase;
|
|||||||
|
|
||||||
class BankTransactionRuleTest extends TestCase
|
class BankTransactionRuleTest extends TestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
use DatabaseTransactions;
|
use DatabaseTransactions;
|
||||||
use MockAccountData;
|
use MockAccountData;
|
||||||
|
|
||||||
@ -44,8 +43,21 @@ class BankTransactionRuleTest extends TestCase
|
|||||||
|
|
||||||
public function testValidationContainsRule()
|
public function testValidationContainsRule()
|
||||||
{
|
{
|
||||||
//[{"search_key":"description","operator":"contains","value":"hello"}]
|
|
||||||
|
|
||||||
|
$bi = BankIntegration::factory()->create([
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'account_id' => $this->account->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$bt = BankTransaction::factory()->create([
|
||||||
|
'bank_integration_id' => $bi->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'description' => 'HellO ThErE CowBoY',
|
||||||
|
'base_type' => 'DEBIT',
|
||||||
|
'amount' => 100
|
||||||
|
]);
|
||||||
|
|
||||||
$br = BankTransactionRule::factory()->create([
|
$br = BankTransactionRule::factory()->create([
|
||||||
'company_id' => $this->company->id,
|
'company_id' => $this->company->id,
|
||||||
@ -63,24 +75,12 @@ class BankTransactionRuleTest extends TestCase
|
|||||||
'value' => 'hello',
|
'value' => 'hello',
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$bi = BankIntegration::factory()->create([
|
$bt = $bt->refresh();
|
||||||
'company_id' => $this->company->id,
|
|
||||||
'user_id' => $this->user->id,
|
|
||||||
'account_id' => $this->account->id,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$bt = BankTransaction::factory()->create([
|
|
||||||
'bank_integration_id' => $bi->id,
|
|
||||||
'company_id' => $this->company->id,
|
|
||||||
'user_id' => $this->user->id,
|
|
||||||
'description' => 'HellO ThErE CowBoY',
|
|
||||||
'base_type' => 'DEBIT',
|
|
||||||
'amount' => 100
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
|
||||||
|
$debit_rules = $bt->company->debit_rules();
|
||||||
|
|
||||||
$bt->service()->processRules();
|
$bt->service()->processRules();
|
||||||
|
|
||||||
$bt = $bt->fresh();
|
$bt = $bt->fresh();
|
||||||
@ -89,7 +89,7 @@ class BankTransactionRuleTest extends TestCase
|
|||||||
$this->assertNotNull($bt->expense->category_id);
|
$this->assertNotNull($bt->expense->category_id);
|
||||||
$this->assertNotNull($bt->expense->vendor_id);
|
$this->assertNotNull($bt->expense->vendor_id);
|
||||||
|
|
||||||
|
$bt = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -152,6 +152,21 @@ class BankTransactionRuleTest extends TestCase
|
|||||||
public function testMatchingBankTransactionExpenseAmountLessThanEqualTo()
|
public function testMatchingBankTransactionExpenseAmountLessThanEqualTo()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$bi = BankIntegration::factory()->create([
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'account_id' => $this->account->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$bt = BankTransaction::factory()->create([
|
||||||
|
'bank_integration_id' => $bi->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'description' => 'xx',
|
||||||
|
'base_type' => 'DEBIT',
|
||||||
|
'amount' => 100
|
||||||
|
]);
|
||||||
|
|
||||||
$br = BankTransactionRule::factory()->create([
|
$br = BankTransactionRule::factory()->create([
|
||||||
'company_id' => $this->company->id,
|
'company_id' => $this->company->id,
|
||||||
'user_id' => $this->user->id,
|
'user_id' => $this->user->id,
|
||||||
@ -168,28 +183,17 @@ class BankTransactionRuleTest extends TestCase
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$bi = BankIntegration::factory()->create([
|
|
||||||
'company_id' => $this->company->id,
|
|
||||||
'user_id' => $this->user->id,
|
|
||||||
'account_id' => $this->account->id,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$bt = BankTransaction::factory()->create([
|
|
||||||
'bank_integration_id' => $bi->id,
|
|
||||||
'company_id' => $this->company->id,
|
|
||||||
'user_id' => $this->user->id,
|
|
||||||
'description' => '',
|
|
||||||
'base_type' => 'DEBIT',
|
|
||||||
'amount' => 100
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
$bt->company->refresh();
|
||||||
|
|
||||||
$bt->service()->processRules();
|
$bt->refresh()->service()->processRules();
|
||||||
|
|
||||||
$bt = $bt->fresh();
|
$bt = $bt->fresh();
|
||||||
|
|
||||||
$this->assertNotNull($bt->expense_id);
|
$this->assertNotNull($bt->expense_id);
|
||||||
|
|
||||||
|
$bt=null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -272,7 +276,7 @@ class BankTransactionRuleTest extends TestCase
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
$bt->service()->processRules();
|
$bt->refresh()->service()->processRules();
|
||||||
|
|
||||||
$bt = $bt->fresh();
|
$bt = $bt->fresh();
|
||||||
|
|
||||||
@ -402,6 +406,7 @@ class BankTransactionRuleTest extends TestCase
|
|||||||
'amount' => 100
|
'amount' => 100
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$bt = $bt->refresh();
|
||||||
|
|
||||||
$bt->service()->processRules();
|
$bt->service()->processRules();
|
||||||
|
|
||||||
@ -413,6 +418,22 @@ class BankTransactionRuleTest extends TestCase
|
|||||||
public function testMatchingBankTransactionExpenseIsEmptyMiss()
|
public function testMatchingBankTransactionExpenseIsEmptyMiss()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$bi = BankIntegration::factory()->create([
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'account_id' => $this->account->id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$bt = BankTransaction::factory()->create([
|
||||||
|
'bank_integration_id' => $bi->id,
|
||||||
|
'company_id' => $this->company->id,
|
||||||
|
'user_id' => $this->user->id,
|
||||||
|
'description' => 'asdadsa',
|
||||||
|
'base_type' => 'DEBIT',
|
||||||
|
'amount' => 100
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
$br = BankTransactionRule::factory()->create([
|
$br = BankTransactionRule::factory()->create([
|
||||||
'company_id' => $this->company->id,
|
'company_id' => $this->company->id,
|
||||||
'user_id' => $this->user->id,
|
'user_id' => $this->user->id,
|
||||||
@ -430,21 +451,8 @@ class BankTransactionRuleTest extends TestCase
|
|||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$bi = BankIntegration::factory()->create([
|
|
||||||
'company_id' => $this->company->id,
|
|
||||||
'user_id' => $this->user->id,
|
|
||||||
'account_id' => $this->account->id,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$bt = BankTransaction::factory()->create([
|
|
||||||
'bank_integration_id' => $bi->id,
|
|
||||||
'company_id' => $this->company->id,
|
|
||||||
'user_id' => $this->user->id,
|
|
||||||
'description' => 'asdadsa',
|
|
||||||
'base_type' => 'DEBIT',
|
|
||||||
'amount' => 100
|
|
||||||
]);
|
|
||||||
|
|
||||||
|
$bt->load('company');
|
||||||
|
|
||||||
$bt->service()->processRules();
|
$bt->service()->processRules();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user