mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
return also start_date and end_date timestamp for decay calculation
This commit is contained in:
parent
ee67f60652
commit
08f1aefcf5
@ -98,7 +98,12 @@ class StateBalancesTable extends AppTable
|
||||
// if start date for decay is after enddate, we also just return input
|
||||
if($decayStartDate === null || $decayStartDate >= $endDate) {
|
||||
if($withInterval) {
|
||||
return ['balance' => $startBalance, 'interval' => new \DateInterval('PT0S')];
|
||||
return [
|
||||
'balance' => $startBalance,
|
||||
'interval' => new \DateInterval('PT0S'),
|
||||
'start_date' => $startDate->getTimestamp(),
|
||||
'end_date' => $startDate->getTimestamp()
|
||||
];
|
||||
} else {
|
||||
return $startBalance;
|
||||
}
|
||||
@ -118,7 +123,12 @@ class StateBalancesTable extends AppTable
|
||||
}
|
||||
$decay = $state_balance->partDecay($endDate);
|
||||
if($withInterval) {
|
||||
return ['balance' => $decay, 'interval' => $interval];
|
||||
return [
|
||||
'balance' => $decay,
|
||||
'interval' => $interval,
|
||||
'start_date' => $state_balance->record_date->getTimestamp(),
|
||||
'end_date' => $endDate->getTimestamp()
|
||||
];
|
||||
} else {
|
||||
return $decay;
|
||||
}
|
||||
|
||||
@ -196,7 +196,9 @@ class TransactionsTable extends Table
|
||||
{
|
||||
$final_transaction['decay'] = [
|
||||
'balance' => $balance,
|
||||
'decay_duration' => $calculated_decay['interval']->format('%a days, %H hours, %I minutes, %S seconds')
|
||||
'decay_duration' => $calculated_decay['interval']->format('%a days, %H hours, %I minutes, %S seconds'),
|
||||
'decay_start' => $calculated_decay['start_date'],
|
||||
'decay_end' => $calculated_decay['end_date']
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -251,9 +253,10 @@ class TransactionsTable extends Table
|
||||
$final_transactions[] = $final_transaction;
|
||||
|
||||
if($i == $stateUserTransactionsCount-1 && $decay == true) {
|
||||
$now = new FrozenTime();
|
||||
$calculated_decay = $stateBalancesTable->calculateDecay(
|
||||
$su_transaction->balance,
|
||||
$su_transaction->balance_date, new FrozenTime(), true);
|
||||
$su_transaction->balance_date, $now, true);
|
||||
$decay_start_date = $stateBalancesTable->getDecayStartDateCached();
|
||||
$duration = $su_transaction->balance_date->timeAgoInWords();
|
||||
if($decay_start_date > $su_transaction->balance_date) {
|
||||
@ -265,6 +268,8 @@ class TransactionsTable extends Table
|
||||
'type' => 'decay',
|
||||
'balance' => $balance,
|
||||
'decay_duration' => $duration,
|
||||
'decay_start' => $calculated_decay['start_date'],
|
||||
'decay_end' => $calculated_decay['end_date'],
|
||||
'memo' => ''
|
||||
];
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user