mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-28 01:41:14 -06:00
Possible fix for #2437
This commit is contained in:
parent
4f6ba1e706
commit
02df24bbc9
File diff suppressed because it is too large
Load Diff
@ -196,6 +196,7 @@ class BillController extends Controller
|
||||
$end = session('end');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$paginator = $this->billRepository->getPaginator($pageSize);
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$parameters = new ParameterBag();
|
||||
$parameters->set('start', $start);
|
||||
$parameters->set('end', $end);
|
||||
@ -206,9 +207,9 @@ class BillController extends Controller
|
||||
|
||||
/** @var Collection $bills */
|
||||
$bills = $paginator->getCollection()->map(
|
||||
static function (Bill $bill) use ($transformer) {
|
||||
static function (Bill $bill) use ($transformer, $defaultCurrency) {
|
||||
$return = $transformer->transform($bill);
|
||||
$return['currency'] = $bill->transactionCurrency;
|
||||
$return['currency'] = $bill->transactionCurrency ?? $defaultCurrency;
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
@ -150,7 +150,6 @@ class BillControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BillController
|
||||
* @covers \FireflyIII\Http\Controllers\BillController
|
||||
*/
|
||||
public function testIndex(): void
|
||||
@ -158,6 +157,8 @@ class BillControllerTest extends TestCase
|
||||
$this->mockDefaultSession();
|
||||
$this->mockIntroPreference('shown_demo_bills_index');
|
||||
|
||||
Amount::shouldReceive('getDefaultCurrency')->andReturn($this->getEuro());
|
||||
|
||||
// mock stuff
|
||||
$this->mock(AttachmentHelperInterface::class);
|
||||
$bill = $this->getRandomBill();
|
||||
|
@ -267,6 +267,8 @@ class CurrencyControllerTest extends TestCase
|
||||
|
||||
$userRepos->shouldReceive('hasRole')->atLeast()->once()->andReturn(true);
|
||||
$repository->shouldReceive('currencyInuse')->atLeast()->once()->andReturn(true);
|
||||
$repository->shouldReceive('currencyInUseAt')->atLeast()->once()->andReturn('accounts');
|
||||
|
||||
$repository->shouldNotReceive('disable');
|
||||
Preferences::shouldReceive('mark')->atLeast()->once();
|
||||
|
||||
|
@ -88,8 +88,13 @@ class BillTransformerTest extends TestCase
|
||||
|
||||
// repos should also receive call for dates:
|
||||
$list = new Collection(
|
||||
[new Carbon('2018-01-02'), new Carbon('2018-01-09'), new Carbon('2018-01-16'),
|
||||
new Carbon('2018-01-21'), new Carbon('2018-01-30'),
|
||||
[
|
||||
|
||||
(object)['date' => new Carbon('2018-01-02'), 'id' => 1, 'transaction_group_id' => 1,],
|
||||
(object)['date' => new Carbon('2018-01-09'), 'id' => 1, 'transaction_group_id' => 1,],
|
||||
(object)['date' => new Carbon('2018-01-16'), 'id' => 1, 'transaction_group_id' => 1,],
|
||||
(object)['date' => new Carbon('2018-01-21'), 'id' => 1, 'transaction_group_id' => 1,],
|
||||
(object)['date' => new Carbon('2018-01-30'), 'id' => 1, 'transaction_group_id' => 1,],
|
||||
]
|
||||
);
|
||||
$repository->shouldReceive('getPaidDatesInRange')->atLeast()->once()->andReturn($list);
|
||||
@ -112,7 +117,15 @@ class BillTransformerTest extends TestCase
|
||||
|
||||
$this->assertEquals('2018-03-01', $result['next_expected_match']);
|
||||
$this->assertEquals(['2018-01-01'], $result['pay_dates']);
|
||||
$this->assertEquals(['2018-01-02', '2018-01-09', '2018-01-16', '2018-01-21', '2018-01-30',], $result['paid_dates']);
|
||||
$this->assertEquals(
|
||||
[
|
||||
['date' => '2018-01-02', 'transaction_group_id' => 1, 'transaction_journal_id' => 1,],
|
||||
['date' => '2018-01-09', 'transaction_group_id' => 1, 'transaction_journal_id' => 1,],
|
||||
['date' => '2018-01-16', 'transaction_group_id' => 1, 'transaction_journal_id' => 1,],
|
||||
['date' => '2018-01-21', 'transaction_group_id' => 1, 'transaction_journal_id' => 1,],
|
||||
['date' => '2018-01-30', 'transaction_group_id' => 1, 'transaction_journal_id' => 1,],
|
||||
], $result['paid_dates']
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user