mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix the transaction factory and associated tests.
This commit is contained in:
parent
e78a59a8a8
commit
8e08ff2d39
@ -96,7 +96,7 @@ class TransactionFactory
|
||||
*/
|
||||
public function createPair(TransactionJournal $journal, array $data): Collection
|
||||
{
|
||||
Log::debug('Start of TransactionFactory::createPair()');
|
||||
Log::debug('Start of TransactionFactory::createPair()', $data);
|
||||
// all this data is the same for both transactions:
|
||||
$currency = $this->findCurrency($data['currency_id'], $data['currency_code']);
|
||||
$description = $journal->description === $data['description'] ? null : $data['description'];
|
||||
@ -105,12 +105,8 @@ class TransactionFactory
|
||||
$sourceType = $this->accountType($journal, 'source');
|
||||
$destinationType = $this->accountType($journal, 'destination');
|
||||
|
||||
if (null === $sourceType || null === $destinationType) {
|
||||
throw new FireflyException('Could not determine source or destination type.');
|
||||
}
|
||||
|
||||
Log::debug(sprintf('Expect source account to be of type %s', $sourceType));
|
||||
Log::debug(sprintf('Expect source destination to be of type %s', $destinationType));
|
||||
Log::debug(sprintf('Expect source account to be of type "%s"', $sourceType));
|
||||
Log::debug(sprintf('Expect source destination to be of type "%s"', $destinationType));
|
||||
|
||||
// find source and destination account:
|
||||
$sourceAccount = $this->findAccount($sourceType, $data['source_id'], $data['source_name']);
|
||||
|
@ -62,6 +62,11 @@ class RuleGroupTransformer extends TransformerAbstract
|
||||
$this->parameters = $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param RuleGroup $ruleGroup
|
||||
*
|
||||
* @return FractalCollection
|
||||
*/
|
||||
public function includeRules(RuleGroup $ruleGroup): FractalCollection
|
||||
{
|
||||
return $this->collection($ruleGroup->rules, new RuleTransformer($this->parameters), 'rules');
|
||||
|
@ -705,7 +705,8 @@ class TransactionFactoryTest extends TestCase
|
||||
{
|
||||
// objects:
|
||||
$asset = $this->user()->accounts()->where('account_type_id', 3)->first();
|
||||
$opposing = $this->user()->accounts()->where('id', '!=', $asset->id)->where('account_type_id', 3)->first();
|
||||
$reconAccount = $this->user()->accounts()->where('account_type_id', 10)->first();
|
||||
//$opposing = $this->user()->accounts()->where('id', '!=', $asset->id)->where('account_type_id', 3)->first();
|
||||
$euro = TransactionCurrency::first();
|
||||
$foreign = TransactionCurrency::where('id', '!=', $euro->id)->first();
|
||||
|
||||
@ -721,7 +722,7 @@ class TransactionFactoryTest extends TestCase
|
||||
'description' => null,
|
||||
'source_id' => $asset->id,
|
||||
'source_name' => null,
|
||||
'destination_id' => $opposing->id,
|
||||
'destination_id' => $reconAccount->id,
|
||||
'destination_name' => null,
|
||||
'amount' => '10',
|
||||
'reconciled' => false,
|
||||
@ -740,7 +741,7 @@ class TransactionFactoryTest extends TestCase
|
||||
$budgetFactory->shouldReceive('setUser');
|
||||
$categoryFactory->shouldReceive('setUser');
|
||||
// first search action is for the asset account, second is for expense account.
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($asset, $opposing);
|
||||
$accountRepos->shouldReceive('findNull')->andReturn($asset, $reconAccount);
|
||||
|
||||
// factories return various stuff:
|
||||
$budgetFactory->shouldReceive('find')->andReturn(null);
|
||||
|
Loading…
Reference in New Issue
Block a user