mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Last code optimization before release.
This commit is contained in:
@@ -46,6 +46,9 @@ class Amount
|
||||
* @param bool $csPrecedes
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*/
|
||||
public static function getAmountJsConfig(bool $sepBySpace, int $signPosn, string $sign, bool $csPrecedes): string
|
||||
{
|
||||
@@ -53,7 +56,7 @@ class Amount
|
||||
$space = ' ';
|
||||
|
||||
// require space between symbol and amount?
|
||||
if (!$sepBySpace) {
|
||||
if ($sepBySpace === false) {
|
||||
$space = ''; // no
|
||||
}
|
||||
|
||||
@@ -116,6 +119,7 @@ class Amount
|
||||
* @param bool $coloured
|
||||
*
|
||||
* @return string
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public function formatAnything(TransactionCurrency $format, string $amount, bool $coloured = null): string
|
||||
{
|
||||
@@ -130,12 +134,8 @@ class Amount
|
||||
// some complicated switches to format the amount correctly:
|
||||
$precedes = $amount < 0 ? $info['n_cs_precedes'] : $info['p_cs_precedes'];
|
||||
$separated = $amount < 0 ? $info['n_sep_by_space'] : $info['p_sep_by_space'];
|
||||
$space = $separated ? ' ' : '';
|
||||
$result = $format->symbol . $space . $formatted;
|
||||
|
||||
if (!$precedes) {
|
||||
$result = $formatted . $space . $format->symbol;
|
||||
}
|
||||
$space = $separated === true ? ' ' : '';
|
||||
$result = $precedes === true ? $format->symbol . $space . $formatted : $formatted . $space . $format->symbol;
|
||||
|
||||
if (true === $coloured) {
|
||||
if ($amount > 0) {
|
||||
|
@@ -41,11 +41,11 @@ class AccountList implements BinderInterface
|
||||
*
|
||||
* @return Collection
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public static function routeBinder(string $value, Route $route): Collection
|
||||
{
|
||||
if (auth()->check()) {
|
||||
|
||||
$collection = new Collection;
|
||||
if ('allAssetAccounts' === $value) {
|
||||
/** @var \Illuminate\Support\Collection $collection */
|
||||
@@ -55,18 +55,8 @@ class AccountList implements BinderInterface
|
||||
->get(['accounts.*']);
|
||||
}
|
||||
if ('allAssetAccounts' !== $value) {
|
||||
|
||||
$list = [];
|
||||
$incoming = explode(',', $value);
|
||||
foreach ($incoming as $entry) {
|
||||
$list[] = (int)$entry;
|
||||
}
|
||||
$list = array_unique($list);
|
||||
if (0 === \count($list)) {
|
||||
Log::error('Account list is empty.');
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$incoming = array_map('\intval', explode(',', $value));
|
||||
$list = array_merge(array_unique($incoming), [0]);
|
||||
/** @var \Illuminate\Support\Collection $collection */
|
||||
$collection = auth()->user()->accounts()
|
||||
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||
|
@@ -38,16 +38,12 @@ class BudgetList implements BinderInterface
|
||||
*
|
||||
* @return Collection
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public static function routeBinder(string $value, Route $route): Collection
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$list = [];
|
||||
$incoming = explode(',', $value);
|
||||
foreach ($incoming as $entry) {
|
||||
$list[] = (int)$entry;
|
||||
}
|
||||
$list = array_unique($list);
|
||||
$list = array_unique(array_map('\intval', explode(',', $value)));
|
||||
if (0 === \count($list)) {
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
}
|
||||
|
@@ -38,16 +38,12 @@ class CategoryList implements BinderInterface
|
||||
*
|
||||
* @return Collection
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public static function routeBinder(string $value, Route $route): Collection
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$list = [];
|
||||
$incoming = explode(',', $value);
|
||||
foreach ($incoming as $entry) {
|
||||
$list[] = (int)$entry;
|
||||
}
|
||||
$list = array_unique($list);
|
||||
$list = array_unique(array_map('\intval', explode(',', $value)));
|
||||
if (0 === \count($list)) {
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
}
|
||||
|
@@ -46,28 +46,25 @@ class Date implements BinderInterface
|
||||
/** @var FiscalHelperInterface $fiscalHelper */
|
||||
$fiscalHelper = app(FiscalHelperInterface::class);
|
||||
|
||||
switch ($value) {
|
||||
default:
|
||||
try {
|
||||
$date = new Carbon($value);
|
||||
} catch (Exception $e) {
|
||||
Log::error(sprintf('Could not parse date "%s" for user #%d: %s', $value, auth()->user()->id, $e->getMessage()));
|
||||
throw new NotFoundHttpException;
|
||||
}
|
||||
|
||||
return $date;
|
||||
case 'currentMonthStart':
|
||||
return Carbon::now()->startOfMonth();
|
||||
case 'currentMonthEnd':
|
||||
return Carbon::now()->endOfMonth();
|
||||
case 'currentYearStart':
|
||||
return Carbon::now()->startOfYear();
|
||||
case 'currentYearEnd':
|
||||
return Carbon::now()->endOfYear();
|
||||
case 'currentFiscalYearStart':
|
||||
return $fiscalHelper->startOfFiscalYear(Carbon::now());
|
||||
case 'currentFiscalYearEnd':
|
||||
return $fiscalHelper->endOfFiscalYear(Carbon::now());
|
||||
$magicWords = [
|
||||
'currentMonthStart' => Carbon::now()->startOfMonth(),
|
||||
'currentMonthEnd' => Carbon::now()->endOfMonth(),
|
||||
'currentYearStart' => Carbon::now()->startOfYear(),
|
||||
'currentYearEnd' => Carbon::now()->endOfYear(),
|
||||
'currentFiscalYearStart' => $fiscalHelper->startOfFiscalYear(Carbon::now()),
|
||||
'currentFiscalYearEnd' => $fiscalHelper->endOfFiscalYear(Carbon::now()),
|
||||
];
|
||||
if (isset($magicWords[$value])) {
|
||||
return $magicWords[$value];
|
||||
}
|
||||
|
||||
try {
|
||||
$result = new Carbon($value);
|
||||
} catch (Exception $e) {
|
||||
Log::error(sprintf('Could not parse date "%s" for user #%d: %s', $value, auth()->user()->id, $e->getMessage()));
|
||||
throw new NotFoundHttpException;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
@@ -37,6 +37,8 @@ class ImportProvider implements BinderInterface
|
||||
{
|
||||
/**
|
||||
* @return array
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
*/
|
||||
public static function getProviders(): array
|
||||
{
|
||||
|
@@ -41,12 +41,7 @@ class JournalList implements BinderInterface
|
||||
public static function routeBinder(string $value, Route $route): Collection
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$list = [];
|
||||
$incoming = explode(',', $value);
|
||||
foreach ($incoming as $entry) {
|
||||
$list[] = (int)$entry;
|
||||
}
|
||||
$list = array_unique($list);
|
||||
$list = array_unique(array_map('\intval', explode(',', $value)));
|
||||
if (0 === \count($list)) {
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
}
|
||||
|
@@ -41,16 +41,14 @@ class SimpleJournalList implements BinderInterface
|
||||
*
|
||||
* @return mixed
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||
* @SuppressWarnings(PHPMD.NPathComplexity)
|
||||
*/
|
||||
public static function routeBinder(string $value, Route $route): Collection
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$list = [];
|
||||
$incoming = explode(',', $value);
|
||||
foreach ($incoming as $entry) {
|
||||
$list[] = (int)$entry;
|
||||
}
|
||||
$list = array_unique($list);
|
||||
$list = array_unique(array_map('\intval', explode(',', $value)));
|
||||
if (0 === \count($list)) {
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
}
|
||||
@@ -97,7 +95,6 @@ class SimpleJournalList implements BinderInterface
|
||||
}
|
||||
|
||||
if ($final->count() > 0) {
|
||||
|
||||
if (\count($messages) > 0) {
|
||||
session()->flash('info', $messages);
|
||||
}
|
||||
|
@@ -44,12 +44,7 @@ class TagList implements BinderInterface
|
||||
public static function routeBinder(string $value, Route $route): Collection
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$list = [];
|
||||
$incoming = explode(',', $value);
|
||||
foreach ($incoming as $entry) {
|
||||
$list[] = strtolower(trim($entry));
|
||||
}
|
||||
$list = array_unique($list);
|
||||
$list = array_unique(array_map('\strtolower', explode(',', $value)));
|
||||
if (0 === \count($list)) {
|
||||
Log::error('Tag list is empty.');
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
|
@@ -25,6 +25,7 @@ namespace FireflyIII\Support;
|
||||
use Amount as Amt;
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Models\Account;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\PiggyBank;
|
||||
@@ -46,6 +47,8 @@ use Throwable;
|
||||
/**
|
||||
* Class ExpandedForm.
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.TooManyMethods)
|
||||
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
|
||||
*/
|
||||
class ExpandedForm
|
||||
{
|
||||
@@ -94,6 +97,7 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function amount(string $name, $value = null, array $options = null): string
|
||||
{
|
||||
@@ -132,19 +136,6 @@ class ExpandedForm
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
public function amountSmall(string $name, $value = null, array $options = null): string
|
||||
{
|
||||
return $this->currencyField($name, 'amount-small', $value, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param array $options
|
||||
@@ -232,6 +223,7 @@ class ExpandedForm
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function balance(string $name, $value = null, array $options = null): string
|
||||
{
|
||||
@@ -428,6 +420,7 @@ class ExpandedForm
|
||||
* @param \Illuminate\Support\Collection $set
|
||||
*
|
||||
* @return array
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public function makeSelectList(Collection $set): array
|
||||
{
|
||||
@@ -453,6 +446,7 @@ class ExpandedForm
|
||||
* @param \Illuminate\Support\Collection $set
|
||||
*
|
||||
* @return array
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public function makeSelectListWithEmpty(Collection $set): array
|
||||
{
|
||||
@@ -475,36 +469,6 @@ class ExpandedForm
|
||||
return $selectList;
|
||||
}
|
||||
|
||||
/** @noinspection MoreThanThreeArgumentsInspection */
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param array $list
|
||||
* @param mixed $selected
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function multiRadio(string $name, array $list = null, $selected = null, array $options = null): string
|
||||
{
|
||||
$list = $list ?? [];
|
||||
$label = $this->label($name, $options);
|
||||
$options = $this->expandOptionArray($name, $label, $options);
|
||||
$classes = $this->getHolderClasses($name);
|
||||
$selected = $this->fillFieldValue($name, $selected);
|
||||
|
||||
unset($options['class']);
|
||||
try {
|
||||
$html = view('form.multiRadio', compact('classes', 'name', 'label', 'selected', 'options', 'list'))->render();
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render multiRadio(): %s', $e->getMessage()));
|
||||
$html = 'Could not render multiRadio.';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
@@ -538,40 +502,6 @@ class ExpandedForm
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
*
|
||||
*/
|
||||
public function nonSelectableBalance(string $name, $value = null, array $options = null): string
|
||||
{
|
||||
$label = $this->label($name, $options);
|
||||
$options = $this->expandOptionArray($name, $label, $options);
|
||||
$classes = $this->getHolderClasses($name);
|
||||
$value = $this->fillFieldValue($name, $value);
|
||||
$options['step'] = 'any';
|
||||
$selectedCurrency = $options['currency'] ?? Amt::getDefaultCurrency();
|
||||
unset($options['currency'], $options['placeholder']);
|
||||
|
||||
// make sure value is formatted nicely:
|
||||
if (null !== $value && '' !== $value) {
|
||||
$decimals = $selectedCurrency->decimal_places ?? 2;
|
||||
$value = round($value, $decimals);
|
||||
}
|
||||
try {
|
||||
$html = view('form.non-selectable-amount', compact('selectedCurrency', 'classes', 'name', 'label', 'value', 'options'))->render();
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render nonSelectableBalance(): %s', $e->getMessage()));
|
||||
$html = 'Could not render nonSelectableBalance.';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
@@ -841,6 +771,59 @@ class ExpandedForm
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $view
|
||||
* @param mixed $value
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
* @throws FireflyException
|
||||
*
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
protected function currencyField(string $name, string $view, $value = null, array $options = null): string
|
||||
{
|
||||
$label = $this->label($name, $options);
|
||||
$options = $this->expandOptionArray($name, $label, $options);
|
||||
$classes = $this->getHolderClasses($name);
|
||||
$value = $this->fillFieldValue($name, $value);
|
||||
$options['step'] = 'any';
|
||||
$defaultCurrency = $options['currency'] ?? Amt::getDefaultCurrency();
|
||||
/** @var Collection $currencies */
|
||||
$currencies = app('amount')->getAllCurrencies();
|
||||
unset($options['currency'], $options['placeholder']);
|
||||
|
||||
// perhaps the currency has been sent to us in the field $amount_currency_id_$name (amount_currency_id_amount)
|
||||
$preFilled = session('preFilled');
|
||||
$key = 'amount_currency_id_' . $name;
|
||||
$sentCurrencyId = isset($preFilled[$key]) ? (int)$preFilled[$key] : $defaultCurrency->id;
|
||||
|
||||
Log::debug(sprintf('Sent currency ID is %d', $sentCurrencyId));
|
||||
|
||||
// find this currency in set of currencies:
|
||||
foreach ($currencies as $currency) {
|
||||
if ($currency->id === $sentCurrencyId) {
|
||||
$defaultCurrency = $currency;
|
||||
Log::debug(sprintf('default currency is now %s', $defaultCurrency->code));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// make sure value is formatted nicely:
|
||||
if (null !== $value && '' !== $value) {
|
||||
$value = round($value, $defaultCurrency->decimal_places);
|
||||
}
|
||||
try {
|
||||
$html = view('form.' . $view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render currencyField(): %s', $e->getMessage()));
|
||||
$html = 'Could not render currencyField.';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $label
|
||||
@@ -865,6 +848,7 @@ class ExpandedForm
|
||||
* @param $value
|
||||
*
|
||||
* @return mixed
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
protected function fillFieldValue(string $name, $value)
|
||||
{
|
||||
@@ -906,6 +890,8 @@ class ExpandedForm
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/** @noinspection MoreThanThreeArgumentsInspection */
|
||||
|
||||
/**
|
||||
* @param $name
|
||||
* @param $options
|
||||
@@ -922,56 +908,4 @@ class ExpandedForm
|
||||
|
||||
return (string)trans('form.' . $name);
|
||||
}
|
||||
|
||||
/** @noinspection MoreThanThreeArgumentsInspection */
|
||||
/**
|
||||
* @param string $name
|
||||
* @param string $view
|
||||
* @param mixed $value
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
*/
|
||||
private function currencyField(string $name, string $view, $value = null, array $options = null): string
|
||||
{
|
||||
$label = $this->label($name, $options);
|
||||
$options = $this->expandOptionArray($name, $label, $options);
|
||||
$classes = $this->getHolderClasses($name);
|
||||
$value = $this->fillFieldValue($name, $value);
|
||||
$options['step'] = 'any';
|
||||
$defaultCurrency = $options['currency'] ?? Amt::getDefaultCurrency();
|
||||
$currencies = app('amount')->getAllCurrencies();
|
||||
unset($options['currency'], $options['placeholder']);
|
||||
|
||||
// perhaps the currency has been sent to us in the field $amount_currency_id_$name (amount_currency_id_amount)
|
||||
$preFilled = session('preFilled');
|
||||
$key = 'amount_currency_id_' . $name;
|
||||
$sentCurrencyId = isset($preFilled[$key]) ? (int)$preFilled[$key] : $defaultCurrency->id;
|
||||
|
||||
Log::debug(sprintf('Sent currency ID is %d', $sentCurrencyId));
|
||||
|
||||
// find this currency in set of currencies:
|
||||
foreach ($currencies as $currency) {
|
||||
if ($currency->id === $sentCurrencyId) {
|
||||
$defaultCurrency = $currency;
|
||||
Log::debug(sprintf('default currency is now %s', $defaultCurrency->code));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// make sure value is formatted nicely:
|
||||
if (null !== $value && '' !== $value) {
|
||||
$value = round($value, $defaultCurrency->decimal_places);
|
||||
}
|
||||
try {
|
||||
$html = view('form.' . $view, compact('defaultCurrency', 'currencies', 'classes', 'name', 'label', 'value', 'options'))->render();
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render currencyField(): %s', $e->getMessage()));
|
||||
$html = 'Could not render currencyField.';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
@@ -271,6 +271,7 @@ class ConfigureMappingHandler implements FileConfigurationInterface
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public function getValuesForMapping(Reader $reader, array $config, array $columnConfig): array
|
||||
{
|
||||
|
@@ -58,6 +58,7 @@ class ConfigureRolesHandler implements FileConfigurationInterface
|
||||
* @param array $config
|
||||
*
|
||||
* @return MessageBag
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public function configurationComplete(array $config): MessageBag
|
||||
{
|
||||
|
@@ -110,6 +110,7 @@ class ChooseAccountsHandler implements SpectreJobConfigurationInterface
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public function getNextData(): array
|
||||
{
|
||||
|
@@ -128,6 +128,7 @@ class ImportTransaction
|
||||
* @param ColumnValue $columnValue
|
||||
*
|
||||
* @throws FireflyException
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public function addColumnValue(ColumnValue $columnValue): void
|
||||
{
|
||||
|
@@ -48,6 +48,7 @@ class AssetAccountMapper
|
||||
* @param array $data
|
||||
*
|
||||
* @return Account
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public function map(?int $accountId, array $data): Account
|
||||
{
|
||||
|
@@ -81,6 +81,7 @@ class MappedValuesValidator
|
||||
*
|
||||
* @return array
|
||||
* @throws FireflyException
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public function validate(array $mappings): array
|
||||
{
|
||||
|
@@ -135,44 +135,32 @@ class MappingConverger
|
||||
|
||||
return $role;
|
||||
}
|
||||
switch ($role) {
|
||||
default:
|
||||
throw new FireflyException(sprintf('Cannot indicate new role for mapped role "%s"', $role)); // @codeCoverageIgnore
|
||||
case 'account-id':
|
||||
case 'account-name':
|
||||
case 'account-iban':
|
||||
case 'account-number':
|
||||
$newRole = 'account-id';
|
||||
break;
|
||||
case 'bill-id':
|
||||
case 'bill-name':
|
||||
$newRole = 'bill-id';
|
||||
break;
|
||||
case 'budget-id':
|
||||
case 'budget-name':
|
||||
$newRole = 'budget-id';
|
||||
break;
|
||||
case 'currency-id':
|
||||
case 'currency-name':
|
||||
case 'currency-code':
|
||||
case 'currency-symbol':
|
||||
$newRole = 'currency-id';
|
||||
break;
|
||||
case 'category-id':
|
||||
case 'category-name':
|
||||
$newRole = 'category-id';
|
||||
break;
|
||||
case 'foreign-currency-id':
|
||||
case 'foreign-currency-code':
|
||||
$newRole = 'foreign-currency-id';
|
||||
break;
|
||||
case 'opposing-id':
|
||||
case 'opposing-name':
|
||||
case 'opposing-iban':
|
||||
case 'opposing-number':
|
||||
$newRole = 'opposing-id';
|
||||
break;
|
||||
$roleMapping = [
|
||||
'account-id' => 'account-id',
|
||||
'account-name' => 'account-id',
|
||||
'account-iban' => 'account-id',
|
||||
'account-number' => 'account-id',
|
||||
'bill-id' => 'bill-id',
|
||||
'bill-name' => 'bill-id',
|
||||
'budget-id' => 'budget-id',
|
||||
'budget-name' => 'budget-id',
|
||||
'currency-id' => 'currency-id',
|
||||
'currency-name' => 'currency-id',
|
||||
'currency-code' => 'currency-id',
|
||||
'currency-symbol' => 'currency-id',
|
||||
'category-id' => 'category-id',
|
||||
'category-name' => 'category-id',
|
||||
'foreign-currency-id' => 'foreign-currency-id',
|
||||
'foreign-currency-code' => 'foreign-currency-id',
|
||||
'opposing-id' => 'opposing-id',
|
||||
'opposing-name' => 'opposing-id',
|
||||
'opposing-iban' => 'opposing-id',
|
||||
'opposing-number' => 'opposing-id',
|
||||
];
|
||||
if (!isset($roleMapping[$role])) {
|
||||
throw new FireflyException(sprintf('Cannot indicate new role for mapped role "%s"', $role)); // @codeCoverageIgnore
|
||||
}
|
||||
$newRole = $roleMapping[$role];
|
||||
Log::debug(sprintf('Role was "%s", but because of mapping (mapped to #%d), role becomes "%s"', $role, $mapped, $newRole));
|
||||
|
||||
// also store the $mapped values in a "mappedValues" array.
|
||||
|
@@ -45,6 +45,7 @@ class OpposingAccountMapper
|
||||
* @param array $data
|
||||
*
|
||||
* @return Account
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public function map(?int $accountId, string $amount, array $data): Account
|
||||
{
|
||||
|
@@ -107,6 +107,7 @@ class StageImportDataHandler
|
||||
* @param LocalAccount $originalSource
|
||||
*
|
||||
* @return array
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
private function convertToArray(array $transactions, SpectreAccount $spectreAccount, LocalAccount $originalSource): array
|
||||
{
|
||||
|
@@ -87,6 +87,7 @@ class Navigation
|
||||
*
|
||||
* @return array
|
||||
* @throws \FireflyIII\Exceptions\FireflyException
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
public function blockPeriods(\Carbon\Carbon $start, \Carbon\Carbon $end, string $range): array
|
||||
{
|
||||
|
@@ -188,6 +188,7 @@ class Search implements SearchInterface
|
||||
* @param JournalCollectorInterface $collector
|
||||
*
|
||||
* @return JournalCollectorInterface
|
||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||
*/
|
||||
private function applyModifiers(JournalCollectorInterface $collector): JournalCollectorInterface
|
||||
{
|
||||
|
@@ -46,11 +46,11 @@ class Transaction extends Twig_Extension
|
||||
*/
|
||||
public function amount(TransactionModel $transaction): string
|
||||
{
|
||||
// at this point amount is always negative.
|
||||
$amount = bcmul(app('steam')->positive((string)$transaction->transaction_amount), '-1');
|
||||
$format = '%s';
|
||||
$coloured = true;
|
||||
|
||||
// at this point amount is always negative.
|
||||
if (TransactionType::RECONCILIATION === $transaction->transaction_type_type && 1 === bccomp((string)$transaction->transaction_amount, '0')) {
|
||||
$amount = bcmul($amount, '-1');
|
||||
}
|
||||
|
Reference in New Issue
Block a user