check if type is set

This commit is contained in:
Dario Rekowski on RockPI 2021-07-13 13:18:24 +00:00
parent 8ddec8e067
commit 89bf681f48

View File

@ -12,6 +12,9 @@ $body['gdtSum'] = $this->element('centToFloat', ['cent' => $body['gdtSum'], 'pre
foreach($body['transactions'] as $i => $transaction) { foreach($body['transactions'] as $i => $transaction) {
$useCeil = false; $useCeil = false;
if(!isset($transaction['type'])) {
$body = ['state' => 'error', 'msg' => 'transaction without type found', 'details' => $transaction];
} else {
if($transaction['type'] == 'decay') { if($transaction['type'] == 'decay') {
$useCeil = true; $useCeil = true;
} }
@ -23,5 +26,6 @@ foreach($body['transactions'] as $i => $transaction) {
$body['transactions'][$i]['decay']['balance'] = $this->element('centToFloat', ['cent' => $transaction['decay']['balance'], 'precision' => 4]); $body['transactions'][$i]['decay']['balance'] = $this->element('centToFloat', ['cent' => $transaction['decay']['balance'], 'precision' => 4]);
} }
} }
}
?><?= json_encode($body) ?> ?><?= json_encode($body) ?>