Skip to content

Commit

Permalink
fix: AU-2213: Allow budget explantion to be saved without a value
Browse files Browse the repository at this point in the history
  • Loading branch information
oskarimysteerio authored Mar 8, 2024
1 parent fd572eb commit 21ea0ce
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,22 @@ public static function processBudgetOtherValues(ListInterface $property): array
}

$value = $values['value'];
$isEmptyValue = (is_null($value) || $value === "");

if (is_null($value) || $value === "") {
if ($isEmptyValue && empty(trim($values['label']))) {
continue;
}
elseif ($isEmptyValue && $values['label']) {
$valueToSave = NULL;
}
else {
$valueToSave = (string) GrantsHandler::convertToFloat($value);
}

$itemValues = [
'ID' => $property->getName() . '_' . $index,
'label' => $values['label'] ?? NULL,
'value' => (string) GrantsHandler::convertToFloat($value),
'value' => $valueToSave,
'valueType' => 'double',
];

Expand Down Expand Up @@ -137,14 +144,19 @@ public static function getBudgetOtherValues(array $documentData, array $jsonPath
if (!empty($parent) && isset($parent[$pathLast])) {
$retVal[$groupName] = array_map(function ($e) {
$value = GrantsHandler::convertToFloat($e['value']);
return [
'label' => $e['label'] ?? NULL,
'value' => number_format(

if ($value !== NULL) {
$value = number_format(
$value,
2,
',',
' ',
) ?? NULL,
);
}

return [
'label' => $e['label'] ?? NULL,
'value' => $value,
];
}, $parent[$pathLast]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public function getPropertyDefinitions(): array {
->setPropertyDefinition(
'meno',
GrantsBudgetInfoDefinition::getOtherCostDefinition()
);
)
->setPropertyDefinition('budget_other_income')
->setPropertyDefinition('budget_other_cost');

$info['lisakysymys_1'] = DataDefinition::create('string')
->setSetting('jsonPath', [
Expand Down

0 comments on commit 21ea0ce

Please sign in to comment.