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,9 +55,12 @@ Router::scope('/', function (RouteBuilder $routes) {
|
|||||||
$csrf->whitelistCallback(function ($request) {
|
$csrf->whitelistCallback(function ($request) {
|
||||||
// Skip token check for API URLs.
|
// Skip token check for API URLs.
|
||||||
//die($request->getParam('controller'));
|
//die($request->getParam('controller'));
|
||||||
if($request->getParam('controller') === 'JsonRequestHandler') {
|
$whitelist = ['JsonRequestHandler', 'ElopageWebhook'];
|
||||||
|
foreach($whitelist as $entry) {
|
||||||
|
if($request->getParam('controller') === $entry) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Register scoped middleware for in scopes.
|
// Register scoped middleware for in scopes.
|
||||||
|
|||||||
@ -197,7 +197,7 @@ class TransactionCreationsController extends AppController
|
|||||||
$connection = ConnectionManager::get('default');
|
$connection = ConnectionManager::get('default');
|
||||||
$transactionActiveMonth = $connection->execute(
|
$transactionActiveMonth = $connection->execute(
|
||||||
'SELECT id, received FROM transactions '
|
'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 '
|
. 'AND '
|
||||||
. 'received < date_add(date_add(curdate(), interval 1 - day(curdate()) day), interval 1 month) '
|
. 'received < date_add(date_add(curdate(), interval 1 - day(curdate()) day), interval 1 month) '
|
||||||
. 'AND '
|
. 'AND '
|
||||||
@ -229,14 +229,16 @@ class TransactionCreationsController extends AppController
|
|||||||
$sumAmount += $transactionCreation->amount;
|
$sumAmount += $transactionCreation->amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//if($sumAmount < 10000000) {
|
//if($sumAmount < 20000000) {
|
||||||
array_push($possibleReceiver, [
|
array_push($possibleReceiver, [
|
||||||
'name' => $stateUser->first_name . ' ' . $stateUser->last_name,
|
'name' => $stateUser->first_name . ' ' . $stateUser->last_name,
|
||||||
'id' => $stateUser->id,
|
'id' => $stateUser->id,
|
||||||
'email' => $stateUser->email,
|
'email' => $stateUser->email,
|
||||||
'amount' => $sumAmount
|
'amount' => $sumAmount
|
||||||
]);
|
]);
|
||||||
//}
|
/*} else {
|
||||||
|
$this->Flash->error(__('Creation above 2.000 GDD for 2 last two month'));
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
usort($possibleReceiver, function($a, $b) {
|
usort($possibleReceiver, function($a, $b) {
|
||||||
return (strtolower ($a['name']) <=> strtolower ($b['name']));
|
return (strtolower ($a['name']) <=> strtolower ($b['name']));
|
||||||
|
|||||||
@ -163,7 +163,7 @@ class TransactionBody extends TransactionBase {
|
|||||||
$protoBody->setCreation(TransactionCreation::fromEntity($transaction->transaction_creations[0])->getProto());
|
$protoBody->setCreation(TransactionCreation::fromEntity($transaction->transaction_creations[0])->getProto());
|
||||||
}
|
}
|
||||||
else if(count($transaction->transaction_send_coins) == 1) {
|
else if(count($transaction->transaction_send_coins) == 1) {
|
||||||
echo "is transfer";
|
//echo "is transfer";
|
||||||
$protoBody->setTransfer(TransactionTransfer::fromEntity($transaction->transaction_send_coins)->getProto());
|
$protoBody->setTransfer(TransactionTransfer::fromEntity($transaction->transaction_send_coins)->getProto());
|
||||||
} else {
|
} else {
|
||||||
return ['invalid transaction type or count'];
|
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_sum' => $existingCreations->func()->sum('amount')]);
|
||||||
$existingCreations->select(['amount', 'state_user_id']);
|
$existingCreations->select(['amount', 'state_user_id']);
|
||||||
$existingCreations->matching('Transactions', function ($q) {
|
$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);
|
//debug($existingCreations);
|
||||||
$newSum = $this->getAmount();
|
$newSum = $this->getAmount();
|
||||||
@ -121,8 +126,8 @@ class TransactionCreation extends TransactionBase {
|
|||||||
$newSum += $creation->amount;
|
$newSum += $creation->amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($newSum > 10000000) {
|
if($newSum > 20000000) {
|
||||||
$this->addError('TransactionCreation::validate', 'Creation more than 1.000 GDD per Month not allowed');
|
$this->addError('TransactionCreation::validate', 'Creation more than 1.000 GDD per Month (2 Month) not allowed');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//die("\n");
|
//die("\n");
|
||||||
|
|||||||
@ -65,7 +65,7 @@ $this->assign('title', __('Schöpfungstransaktion'));
|
|||||||
<?= $this->Form->control('amount', ['required' => false]); ?>
|
<?= $this->Form->control('amount', ['required' => false]); ?>
|
||||||
<?php foreach($possibleReceiver as $possibleReceiver) :
|
<?php foreach($possibleReceiver as $possibleReceiver) :
|
||||||
$disable = null;
|
$disable = null;
|
||||||
if($activeUser['id'] == $possibleReceiver['id'] || $possibleReceiver['amount'] > 10000000) {
|
if($activeUser['id'] == $possibleReceiver['id'] || $possibleReceiver['amount'] > 20000000) {
|
||||||
$disable = 'disabled';
|
$disable = 'disabled';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@ -92,7 +92,7 @@ $this->assign('title', __('Schöpfungstransaktion'));
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if($possibleReceiver['amount'] != 0) : ?>
|
<?php if($possibleReceiver['amount'] != 0) : ?>
|
||||||
<span class="grd_smaller">
|
<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>
|
</span>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if($disable != null) : ?>
|
<?php if($disable != null) : ?>
|
||||||
|
|||||||
@ -53,7 +53,7 @@ Letzte eingereichte Transaktion <?= gTransactionIds[0] - 1 ?>
|
|||||||
if(gTransactionIds[index] === undefined) {
|
if(gTransactionIds[index] === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log("index: %d", index);
|
//console.log("index: %d", index);
|
||||||
var progressState = $('#put-progress .progress-state').eq(index);
|
var progressState = $('#put-progress .progress-state').eq(index);
|
||||||
progressState.html('<i>Wird verarbeitet</i>');
|
progressState.html('<i>Wird verarbeitet</i>');
|
||||||
|
|
||||||
@ -66,7 +66,12 @@ Letzte eingereichte Transaktion <?= gTransactionIds[0] - 1 ?>
|
|||||||
headers: {'X-CSRF-Token': csfr_token},
|
headers: {'X-CSRF-Token': csfr_token},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function (data) {
|
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');
|
progressState.addClass('grd-success').html('Erfolgreich eingereicht');
|
||||||
setTimeout(function() { putTransaction(index+1);}, 1000);
|
setTimeout(function() { putTransaction(index+1);}, 1000);
|
||||||
} else {
|
} else {
|
||||||
@ -74,11 +79,20 @@ Letzte eingereichte Transaktion <?= gTransactionIds[0] - 1 ?>
|
|||||||
if(_index <= index) return;
|
if(_index <= index) return;
|
||||||
$(dom).html('Abgebrochen');
|
$(dom).html('Abgebrochen');
|
||||||
});
|
});
|
||||||
|
//console.log("Fehler beim einreichen")
|
||||||
|
if(isNodeAnswer) {
|
||||||
progressState.addClass('grd-error').html('Fehler beim einreichen');
|
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 timeString = round_to_precision(data.timeUsed * 1000.0, 4) + ' ms';
|
||||||
|
if(isNodeAnswer) {
|
||||||
var nodeTime = data.result.timeUsed;
|
var nodeTime = data.result.timeUsed;
|
||||||
progressState.append(' ').append('<span class="time-used">' + timeString + ' (node: ' + nodeTime + ')</span>');
|
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