Update tests and code.

This commit is contained in:
James Cole
2018-12-21 16:38:10 +01:00
parent a5520d45e7
commit 2c7d94e5e9
24 changed files with 378 additions and 150 deletions

View File

@@ -332,14 +332,17 @@ trait AccountServiceTrait
* @param string $note
*
* @return bool
* @throws \Exception
*/
public function updateNote(Account $account, string $note): bool
{
if ('' === $note) {
$dbNote = $account->notes()->first();
if (null !== $dbNote) {
$dbNote->delete();
try {
$dbNote->delete();
} catch (\Exception $e) {
Log::debug($e->getMessage());
}
}
return true;
@@ -365,7 +368,7 @@ trait AccountServiceTrait
public function validIBData(array $data): bool
{
$data['openingBalance'] = (string)($data['openingBalance'] ?? '');
if (isset($data['openingBalance'], $data['openingBalanceDate']) && \strlen($data['openingBalance']) > 0) {
if ('' !== $data['openingBalance'] && isset($data['openingBalance'], $data['openingBalanceDate'])) {
Log::debug('Array has valid opening balance data.');
return true;

View File

@@ -96,8 +96,8 @@ trait RecurringTransactionTrait
/** @var TransactionCurrencyFactory $factory */
$factory = app(TransactionCurrencyFactory::class);
$currency = $factory->find($array['currency_id'], $array['currency_code']);
$foreignCurrency = $factory->find($array['foreign_currency_id'], $array['foreign_currency_code']);
$currency = $factory->find($array['currency_id'] ?? null, $array['currency_code'] ?? null);
$foreignCurrency = $factory->find($array['foreign_currency_id'] ?? null, $array['foreign_currency_code'] ?? null);
if (null === $currency) {
$currency = app('amount')->getDefaultCurrencyByUser($recurrence->user);
}