mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
increase creation validation range to 2 month and 2.000 GDD
This commit is contained in:
parent
05240b6654
commit
8189fd7d86
@ -55,8 +55,11 @@ Router::scope('/', function (RouteBuilder $routes) {
|
||||
$csrf->whitelistCallback(function ($request) {
|
||||
// Skip token check for API URLs.
|
||||
//die($request->getParam('controller'));
|
||||
if($request->getParam('controller') === 'JsonRequestHandler') {
|
||||
return true;
|
||||
$whitelist = ['JsonRequestHandler', 'ElopageWebhook'];
|
||||
foreach($whitelist as $entry) {
|
||||
if($request->getParam('controller') === $entry) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -197,7 +197,7 @@ class TransactionCreationsController extends AppController
|
||||
$connection = ConnectionManager::get('default');
|
||||
$transactionActiveMonth = $connection->execute(
|
||||
'SELECT id, received FROM transactions '
|
||||
. 'where received >= date_add(curdate(), interval 1 - day(curdate()) day) '
|
||||
. 'where received >= date_sub(date_add(curdate(), interval 1 - day(curdate()) day), interval 1 month) '
|
||||
. 'AND '
|
||||
. 'received < date_add(date_add(curdate(), interval 1 - day(curdate()) day), interval 1 month) '
|
||||
. 'AND '
|
||||
@ -229,14 +229,16 @@ class TransactionCreationsController extends AppController
|
||||
$sumAmount += $transactionCreation->amount;
|
||||
}
|
||||
}
|
||||
//if($sumAmount < 10000000) {
|
||||
//if($sumAmount < 20000000) {
|
||||
array_push($possibleReceiver, [
|
||||
'name' => $stateUser->first_name . ' ' . $stateUser->last_name,
|
||||
'id' => $stateUser->id,
|
||||
'email' => $stateUser->email,
|
||||
'amount' => $sumAmount
|
||||
]);
|
||||
//}
|
||||
/*} else {
|
||||
$this->Flash->error(__('Creation above 2.000 GDD for 2 last two month'));
|
||||
}*/
|
||||
}
|
||||
usort($possibleReceiver, function($a, $b) {
|
||||
return (strtolower ($a['name']) <=> strtolower ($b['name']));
|
||||
|
||||
@ -163,7 +163,7 @@ class TransactionBody extends TransactionBase {
|
||||
$protoBody->setCreation(TransactionCreation::fromEntity($transaction->transaction_creations[0])->getProto());
|
||||
}
|
||||
else if(count($transaction->transaction_send_coins) == 1) {
|
||||
echo "is transfer";
|
||||
//echo "is transfer";
|
||||
$protoBody->setTransfer(TransactionTransfer::fromEntity($transaction->transaction_send_coins)->getProto());
|
||||
} else {
|
||||
return ['invalid transaction type or count'];
|
||||
|
||||
@ -109,7 +109,12 @@ class TransactionCreation extends TransactionBase {
|
||||
//$existingCreations->select(['amount_sum' => $existingCreations->func()->sum('amount')]);
|
||||
$existingCreations->select(['amount', 'state_user_id']);
|
||||
$existingCreations->matching('Transactions', function ($q) {
|
||||
return $q->where(['EXTRACT(YEAR_MONTH FROM Transactions.received) LIKE EXTRACT(YEAR_MONTH FROM NOW())']);
|
||||
|
||||
return $q->where(
|
||||
['OR' =>
|
||||
['EXTRACT(YEAR_MONTH FROM Transactions.received) LIKE EXTRACT(YEAR_MONTH FROM NOW())',
|
||||
'EXTRACT(YEAR_MONTH FROM DATE_ADD(Transactions.received, INTERVAL 1 MONTH)) LIKE EXTRACT(YEAR_MONTH FROM NOW())']
|
||||
])->select('received');
|
||||
});
|
||||
//debug($existingCreations);
|
||||
$newSum = $this->getAmount();
|
||||
@ -121,8 +126,8 @@ class TransactionCreation extends TransactionBase {
|
||||
$newSum += $creation->amount;
|
||||
}
|
||||
}
|
||||
if($newSum > 10000000) {
|
||||
$this->addError('TransactionCreation::validate', 'Creation more than 1.000 GDD per Month not allowed');
|
||||
if($newSum > 20000000) {
|
||||
$this->addError('TransactionCreation::validate', 'Creation more than 1.000 GDD per Month (2 Month) not allowed');
|
||||
return false;
|
||||
}
|
||||
//die("\n");
|
||||
|
||||
@ -65,7 +65,7 @@ $this->assign('title', __('Schöpfungstransaktion'));
|
||||
<?= $this->Form->control('amount', ['required' => false]); ?>
|
||||
<?php foreach($possibleReceiver as $possibleReceiver) :
|
||||
$disable = null;
|
||||
if($activeUser['id'] == $possibleReceiver['id'] || $possibleReceiver['amount'] > 10000000) {
|
||||
if($activeUser['id'] == $possibleReceiver['id'] || $possibleReceiver['amount'] > 20000000) {
|
||||
$disable = 'disabled';
|
||||
}
|
||||
?>
|
||||
@ -92,7 +92,7 @@ $this->assign('title', __('Schöpfungstransaktion'));
|
||||
<?php endif; ?>
|
||||
<?php if($possibleReceiver['amount'] != 0) : ?>
|
||||
<span class="grd_smaller">
|
||||
In diesem Monat bereits geschöpft: <?= $this->element('printGradido', ['number' => $possibleReceiver['amount']]);?>
|
||||
In diesem und letztem Monat bereits geschöpft: <?= $this->element('printGradido', ['number' => $possibleReceiver['amount']]);?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<?php if($disable != null) : ?>
|
||||
|
||||
@ -53,7 +53,7 @@ Letzte eingereichte Transaktion <?= gTransactionIds[0] - 1 ?>
|
||||
if(gTransactionIds[index] === undefined) {
|
||||
return;
|
||||
}
|
||||
console.log("index: %d", index);
|
||||
//console.log("index: %d", index);
|
||||
var progressState = $('#put-progress .progress-state').eq(index);
|
||||
progressState.html('<i>Wird verarbeitet</i>');
|
||||
|
||||
@ -66,7 +66,12 @@ Letzte eingereichte Transaktion <?= gTransactionIds[0] - 1 ?>
|
||||
headers: {'X-CSRF-Token': csfr_token},
|
||||
dataType: 'json',
|
||||
success: function (data) {
|
||||
if(data.result.state === 'success') {
|
||||
var isNodeAnswer = true;
|
||||
if(typeof data.result === 'undefined') {
|
||||
isNodeAnswer = false;
|
||||
}
|
||||
//console.log("node answer: %o", isNodeAnswer)
|
||||
if(isNodeAnswer && data.result.state === 'success') {
|
||||
progressState.addClass('grd-success').html('Erfolgreich eingereicht');
|
||||
setTimeout(function() { putTransaction(index+1);}, 1000);
|
||||
} else {
|
||||
@ -74,11 +79,20 @@ Letzte eingereichte Transaktion <?= gTransactionIds[0] - 1 ?>
|
||||
if(_index <= index) return;
|
||||
$(dom).html('Abgebrochen');
|
||||
});
|
||||
progressState.addClass('grd-error').html('Fehler beim einreichen');
|
||||
//console.log("Fehler beim einreichen")
|
||||
if(isNodeAnswer) {
|
||||
progressState.addClass('grd-error').html('Fehler beim einreichen');
|
||||
} else {
|
||||
progressState.addClass('grd-error').html('Fehler auf Community Server');
|
||||
}
|
||||
}
|
||||
var timeString = round_to_precision(data.timeUsed * 1000.0, 4) + ' ms';
|
||||
var nodeTime = data.result.timeUsed;
|
||||
progressState.append(' ').append('<span class="time-used">' + timeString + ' (node: ' + nodeTime + ')</span>');
|
||||
if(isNodeAnswer) {
|
||||
var nodeTime = data.result.timeUsed;
|
||||
progressState.append(' ').append('<span class="time-used">' + timeString + ' (node: ' + nodeTime + ')</span>');
|
||||
} else {
|
||||
progressState.append(' ').append('<span class="time-used">' + timeString + '</span>');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user