mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
remove second decay by creation transaction, update old data set
This commit is contained in:
parent
aa459580b9
commit
f9ee57a858
@ -151,7 +151,7 @@ class AppController extends Controller
|
|||||||
if($last_migration) {
|
if($last_migration) {
|
||||||
$current_db_version = $last_migration->db_version;
|
$current_db_version = $last_migration->db_version;
|
||||||
}
|
}
|
||||||
$php_data_version = 2;
|
$php_data_version = 3;
|
||||||
if($current_db_version < $php_data_version) {
|
if($current_db_version < $php_data_version) {
|
||||||
$this->redirect(['controller' => 'Migrations', 'action' => 'migrate', 'html' => $html, 'db_version' => $current_db_version]);
|
$this->redirect(['controller' => 'Migrations', 'action' => 'migrate', 'html' => $html, 'db_version' => $current_db_version]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,6 +69,14 @@ class MigrationsController extends AppController
|
|||||||
[$stateBalancesTable, 'updateAllBalances']
|
[$stateBalancesTable, 'updateAllBalances']
|
||||||
];
|
];
|
||||||
$new_db_version = 2;
|
$new_db_version = 2;
|
||||||
|
} else if($current_db_version == 2) {
|
||||||
|
$commands = [
|
||||||
|
[$stateUserTransactionsTable, 'truncate'],
|
||||||
|
[$stateBalancesTable, 'truncate'],
|
||||||
|
[$transactionsTable, 'fillStateUserTransactions'],
|
||||||
|
[$stateBalancesTable, 'updateAllBalances']
|
||||||
|
];
|
||||||
|
$new_db_version = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
$migration_result = $this->callFunctions($commands);
|
$migration_result = $this->callFunctions($commands);
|
||||||
|
|||||||
@ -163,7 +163,8 @@ class TransactionCreation extends TransactionBase {
|
|||||||
$transactionCreationEntity->target_date = $this->protoTransactionCreation->getTargetDate()->getSeconds();
|
$transactionCreationEntity->target_date = $this->protoTransactionCreation->getTargetDate()->getSeconds();
|
||||||
$target_date = new FrozenTime($transactionCreationEntity->target_date);
|
$target_date = new FrozenTime($transactionCreationEntity->target_date);
|
||||||
|
|
||||||
$decayed_balance = $stateBalancesTable->calculateDecay($this->getAmount(), $target_date, $received);
|
//$decayed_balance = $stateBalancesTable->calculateDecay($this->getAmount(), $target_date, $received);
|
||||||
|
$balance = $this->getAmount();
|
||||||
|
|
||||||
if(!$this->transactionCreationsTable->save($transactionCreationEntity)) {
|
if(!$this->transactionCreationsTable->save($transactionCreationEntity)) {
|
||||||
$this->addError('TransactionCreation::save', 'error saving transactionCreation with errors: ' . json_encode($transactionCreationEntity->getErrors()));
|
$this->addError('TransactionCreation::save', 'error saving transactionCreation with errors: ' . json_encode($transactionCreationEntity->getErrors()));
|
||||||
@ -171,13 +172,13 @@ class TransactionCreation extends TransactionBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update state balance
|
// update state balance
|
||||||
$final_balance = $this->updateStateBalance($receiverUserId, $decayed_balance, $received);
|
$final_balance = $this->updateStateBalance($receiverUserId, $balance, $received);
|
||||||
if(false === $final_balance) {
|
if(false === $final_balance) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// decay is a virtual field which is calculated from amount and now() - record_date
|
// decay is a virtual field which is calculated from amount and now() - record_date
|
||||||
if(!$this->addStateUserTransaction($receiverUserId, $transaction_id, 1, $decayed_balance, $received)) {
|
if(!$this->addStateUserTransaction($receiverUserId, $transaction_id, 1, $balance, $received)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user