Basic code for tracking liabilities.

This commit is contained in:
James Cole
2018-08-04 17:30:47 +02:00
parent f0d3ca5d53
commit 8dbc846314
17 changed files with 161 additions and 43 deletions

View File

@@ -528,6 +528,34 @@ class ExpandedForm
return $html;
}
/**
* Function to render a percentage.
*
* @param string $name
* @param mixed $value
* @param array $options
*
* @return string
*
*/
public function percentage(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';
unset($options['placeholder']);
try {
$html = view('form.percentage', compact('classes', 'name', 'label', 'value', 'options'))->render();
} catch (Throwable $e) {
Log::debug(sprintf('Could not render percentage(): %s', $e->getMessage()));
$html = 'Could not render percentage.';
}
return $html;
}
/**
* @param string $type
* @param string $name
@@ -772,6 +800,7 @@ class ExpandedForm
return $html;
}
/** @noinspection MoreThanThreeArgumentsInspection */
/**
* @param string $name
* @param string $view

View File

@@ -69,7 +69,9 @@ class Translation extends Twig_Extension
'journalLinkTranslation',
function (string $direction, string $original) {
$key = sprintf('firefly.%s_%s', $original, $direction);
return $key;
$translation = trans($key);
if ($key === $translation) {
return $original;
}