Make sure that accounts and their opening balance values are the same currency.

This commit is contained in:
James Cole
2017-04-14 07:11:30 +02:00
parent 89ee9c058a
commit 953c38563b
10 changed files with 180 additions and 21 deletions

View File

@@ -261,6 +261,36 @@ class ExpandedForm
return $html;
}
/**
* @param string $name
* @param null $value
* @param array $options
*
* @return string
*/
public function nonSelectableBalance(string $name, $value = null, array $options = []): 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 = isset($options['currency']) ? $options['currency'] : Amt::getDefaultCurrency();
unset($options['currency']);
unset($options['placeholder']);
// make sure value is formatted nicely:
if (!is_null($value) && $value !== '') {
$value = round($value, $selectedCurrency->decimal_places);
}
$html = view('form.non-selectable-balance', compact('selectedCurrency', 'classes', 'name', 'label', 'value', 'options'))->render();
return $html;
}
/**
* @param $type
* @param $name