mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
remove changes from new branch
This commit is contained in:
parent
77b44d0abc
commit
141cd6a112
@ -66,12 +66,15 @@ class JsonRequestHandlerController extends AppController {
|
||||
|
||||
private function putTransaction($transactionBase64) {
|
||||
$transaction = new Transaction($transactionBase64);
|
||||
//echo "after new transaction<br>";
|
||||
if($transaction->hasErrors()) {
|
||||
return $this->returnJson(['state' => 'error', 'msg' => 'error parsing transaction', 'details' => $transaction->getErrors()]);
|
||||
}
|
||||
//echo "after check on errors<br>";
|
||||
if(!$transaction->validate()) {
|
||||
return $this->returnJsonSaveError($transaction, ['state' => 'error', 'msg' => 'error validate transaction', 'details' => $transaction->getErrors()]);
|
||||
}
|
||||
//echo "after validate <br>";
|
||||
|
||||
if ($transaction->save()) {
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ use Cake\Routing\Router;
|
||||
//use Cake\I18n\Number;
|
||||
use Cake\Http\Client;
|
||||
use Cake\Core\Configure;
|
||||
use Cake\I18n\FrozenDate;
|
||||
use Cake\Datasource\ConnectionManager;
|
||||
|
||||
use App\Form\CreationForm;
|
||||
@ -262,6 +263,7 @@ class TransactionCreationsController extends AppController
|
||||
// amount
|
||||
$memo = $requestData['memo'];
|
||||
$amountCent = $this->GradidoNumber->parseInputNumberToCentNumber($requestData['amount']);
|
||||
$targetDate = $requestData['target_date'];
|
||||
$mode = 'next';
|
||||
if(isset($requestData['add'])) {$mode = 'add'; }
|
||||
|
||||
@ -284,10 +286,14 @@ class TransactionCreationsController extends AppController
|
||||
//var_dump($receiverUsers);
|
||||
foreach($receiverUsers as $receiverUser) {
|
||||
$localAmountCent = $amountCent;
|
||||
$localTargetDate = $targetDate;
|
||||
$id = $receiverUser->id;
|
||||
if($requestData['user_amount'][$id] != '') {
|
||||
$localAmountCent = $this->GradidoNumber->parseInputNumberToCentNumber($requestData['user_amount'][$id]);
|
||||
}
|
||||
if($requestData['user_target_date'][$id]) {
|
||||
$localTargetDate = $requestData['user_target_date'][$id];
|
||||
}
|
||||
if(isset($pendings[$id])) {
|
||||
$pendings[$id] += $localAmountCent;
|
||||
} else {
|
||||
@ -295,11 +301,22 @@ class TransactionCreationsController extends AppController
|
||||
}
|
||||
$pubKeyHex = bin2hex(stream_get_contents($receiverUser->public_key));
|
||||
$identHash = TransactionCreation::DRMakeStringHash($receiverUser->email);
|
||||
//var_dump($localTargetDate);
|
||||
//die('a');
|
||||
$localTargetDateFrozen = FrozenDate::now();
|
||||
$localTargetDateFrozen = $localTargetDateFrozen
|
||||
->year($localTargetDate['year'])
|
||||
->month($localTargetDate['month'])
|
||||
->day($localTargetDate['day']);
|
||||
echo "input: "; var_dump($localTargetDate);echo "<br>";
|
||||
echo "output: "; var_dump($localTargetDateFrozen);
|
||||
//die('a');
|
||||
$builderResult = TransactionCreation::build(
|
||||
$localAmountCent,
|
||||
$memo,
|
||||
$pubKeyHex,
|
||||
$identHash
|
||||
$identHash,
|
||||
$localTargetDateFrozen
|
||||
);
|
||||
if($builderResult['state'] == 'success') {
|
||||
array_push($transactions, base64_encode($builderResult['transactionBody']->serializeToString()));
|
||||
|
||||
@ -15,6 +15,7 @@ class CreationForm extends Form
|
||||
//->addField('receiver_pubkey_hex', ['type' => 'string'])
|
||||
->addField('receiver', ['type' => 'select'])
|
||||
->addField('amount', ['type' => 'decimal', 'precision' => 2])
|
||||
->addField('target_date', ['type' => 'date'])
|
||||
->addField('memo', ['type' =>'text', 'default' => '', 'rows' => 3, 'maxlength' => 150]);
|
||||
}
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@ class TransactionCreation extends Entity
|
||||
'amount' => true,
|
||||
'ident_hash' => true,
|
||||
'transaction' => true,
|
||||
'state_user' => true
|
||||
'state_user' => true,
|
||||
'target_date' => true
|
||||
];
|
||||
}
|
||||
|
||||
@ -17,13 +17,23 @@ use Google\Protobuf\Internal\GPBUtil;
|
||||
class TransactionCreation extends \Google\Protobuf\Internal\Message
|
||||
{
|
||||
/**
|
||||
* 40 Byte
|
||||
*
|
||||
* Generated from protobuf field <code>.model.messages.gradido.ReceiverAmount receiverAmount = 1;</code>
|
||||
*/
|
||||
private $receiverAmount = null;
|
||||
/**
|
||||
* 4 Byte
|
||||
*
|
||||
* Generated from protobuf field <code>sint32 ident_hash = 2;</code>
|
||||
*/
|
||||
private $ident_hash = 0;
|
||||
/**
|
||||
* 8 Byte
|
||||
*
|
||||
* Generated from protobuf field <code>.model.messages.gradido.TimestampSeconds target_date = 3;</code>
|
||||
*/
|
||||
private $target_date = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -32,7 +42,11 @@ class TransactionCreation extends \Google\Protobuf\Internal\Message
|
||||
* Optional. Data for populating the Message object.
|
||||
*
|
||||
* @type \Model\Messages\Gradido\ReceiverAmount $receiverAmount
|
||||
* 40 Byte
|
||||
* @type int $ident_hash
|
||||
* 4 Byte
|
||||
* @type \Model\Messages\Gradido\TimestampSeconds $target_date
|
||||
* 8 Byte
|
||||
* }
|
||||
*/
|
||||
public function __construct($data = NULL) {
|
||||
@ -41,6 +55,8 @@ class TransactionCreation extends \Google\Protobuf\Internal\Message
|
||||
}
|
||||
|
||||
/**
|
||||
* 40 Byte
|
||||
*
|
||||
* Generated from protobuf field <code>.model.messages.gradido.ReceiverAmount receiverAmount = 1;</code>
|
||||
* @return \Model\Messages\Gradido\ReceiverAmount
|
||||
*/
|
||||
@ -50,6 +66,8 @@ class TransactionCreation extends \Google\Protobuf\Internal\Message
|
||||
}
|
||||
|
||||
/**
|
||||
* 40 Byte
|
||||
*
|
||||
* Generated from protobuf field <code>.model.messages.gradido.ReceiverAmount receiverAmount = 1;</code>
|
||||
* @param \Model\Messages\Gradido\ReceiverAmount $var
|
||||
* @return $this
|
||||
@ -63,6 +81,8 @@ class TransactionCreation extends \Google\Protobuf\Internal\Message
|
||||
}
|
||||
|
||||
/**
|
||||
* 4 Byte
|
||||
*
|
||||
* Generated from protobuf field <code>sint32 ident_hash = 2;</code>
|
||||
* @return int
|
||||
*/
|
||||
@ -72,6 +92,8 @@ class TransactionCreation extends \Google\Protobuf\Internal\Message
|
||||
}
|
||||
|
||||
/**
|
||||
* 4 Byte
|
||||
*
|
||||
* Generated from protobuf field <code>sint32 ident_hash = 2;</code>
|
||||
* @param int $var
|
||||
* @return $this
|
||||
@ -84,5 +106,31 @@ class TransactionCreation extends \Google\Protobuf\Internal\Message
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 8 Byte
|
||||
*
|
||||
* Generated from protobuf field <code>.model.messages.gradido.TimestampSeconds target_date = 3;</code>
|
||||
* @return \Model\Messages\Gradido\TimestampSeconds
|
||||
*/
|
||||
public function getTargetDate()
|
||||
{
|
||||
return $this->target_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* 8 Byte
|
||||
*
|
||||
* Generated from protobuf field <code>.model.messages.gradido.TimestampSeconds target_date = 3;</code>
|
||||
* @param \Model\Messages\Gradido\TimestampSeconds $var
|
||||
* @return $this
|
||||
*/
|
||||
public function setTargetDate($var)
|
||||
{
|
||||
GPBUtil::checkMessage($var, \Model\Messages\Gradido\TimestampSeconds::class);
|
||||
$this->target_date = $var;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -8,6 +8,8 @@ use Cake\ORM\TableRegistry;
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Mailer\Email;
|
||||
|
||||
|
||||
|
||||
class TransactionCreation extends TransactionBase {
|
||||
|
||||
private $protoTransactionCreation;
|
||||
@ -24,7 +26,7 @@ class TransactionCreation extends TransactionBase {
|
||||
return $this->protoTransactionCreation;
|
||||
}
|
||||
|
||||
static public function build($amount, $memo, $receiver_public_hex, $ident_hash)
|
||||
static public function build($amount, $memo, $receiver_public_hex, $ident_hash, $targetDate = null)
|
||||
{
|
||||
$receiver = new \Model\Messages\Gradido\ReceiverAmount();
|
||||
$receiver->setAmount($amount);
|
||||
@ -42,10 +44,21 @@ class TransactionCreation extends TransactionBase {
|
||||
$transactionBody = new \Model\Messages\Gradido\TransactionBody();
|
||||
$transactionBody->setMemo($memo);
|
||||
$transactionBody->setCreated($creationDate);
|
||||
|
||||
|
||||
$transaction = new \Model\Messages\Gradido\TransactionCreation();
|
||||
$transaction->setReceiverAmount($receiver);
|
||||
$transaction->setIdentHash($ident_hash);
|
||||
echo "target date: ";
|
||||
//var_dump($targetDate);
|
||||
//die('die');
|
||||
if($targetDate) {
|
||||
$targetDateTimestamp = new \Model\Messages\Gradido\TimestampSeconds();
|
||||
$targetDateTimestamp->setSeconds($targetDate->getTimestamp());
|
||||
//var_dump($targetDateTimestamp); die('target');
|
||||
$transaction->setTargetDate($targetDateTimestamp);
|
||||
}
|
||||
|
||||
$transactionBody->setCreation($transaction);
|
||||
return ['state' => 'success', 'transactionBody' => $transactionBody];
|
||||
}
|
||||
@ -100,14 +113,19 @@ class TransactionCreation extends TransactionBase {
|
||||
// ident hash isn't collision ressistent, it is for speed up search
|
||||
$identHashBin = pack('a32', $this->getIdentHash());
|
||||
|
||||
$existingCreations = $this->transactionCreationsTable
|
||||
$q = $existingCreations = $this->transactionCreationsTable
|
||||
->find('all')
|
||||
->select(['amount', 'state_user_id'])
|
||||
->select(['amount', 'state_user_id', 'target_date'])
|
||||
->contain(['StateUsers' => ['fields' => ['StateUsers.public_key']]]);
|
||||
|
||||
//$targetDate = $this->protoTransactionCreation->getTargetDate();
|
||||
//echo "choose existing transactions<br>";
|
||||
//$existingCreations->where([$q->func()->extract('YEAR_MONTH', 'target_date') . ' LIKE ' . $q->func()->extract('YEAR_MONTH', $targetDate)]);
|
||||
// ->where(['EXTRACT(YEAR_MONTH FROM target_date) LIKE EXTRACT(YEAR_MONTH FROM']);
|
||||
// uncomment because ident hash didn't work at the moment
|
||||
//->where(['ident_hash' => $identHashBin]);
|
||||
//$existingCreations->select(['amount_sum' => $existingCreations->func()->sum('amount')]);
|
||||
$existingCreations->select(['amount', 'state_user_id']);
|
||||
/* old validation not more than 3k GDD for 3 Month*/
|
||||
$existingCreations->matching('Transactions', function ($q) {
|
||||
|
||||
return $q->where(
|
||||
@ -115,8 +133,11 @@ class TransactionCreation extends TransactionBase {
|
||||
['EXTRACT(YEAR_MONTH FROM Transactions.received) LIKE EXTRACT(YEAR_MONTH FROM NOW())',
|
||||
'EXTRACT(YEAR_MONTH FROM DATE_ADD(Transactions.received, INTERVAL 2 MONTH)) LIKE EXTRACT(YEAR_MONTH FROM NOW())']
|
||||
])->select('received');
|
||||
});
|
||||
|
||||
|
||||
});//*/
|
||||
//debug($existingCreations);
|
||||
//echo "after choose existing transactions<br>";
|
||||
$newSum = $this->getAmount();
|
||||
//var_dump($existingCreations->toArray());
|
||||
foreach($existingCreations as $creation) {
|
||||
|
||||
@ -48,7 +48,8 @@ $this->assign('title', __('GDT Kontoübersicht'));
|
||||
<table class="table table-hover table-sm">
|
||||
<thead>
|
||||
<tr class="solid-header">
|
||||
<th class="pl-4"><?= __('Datum') ?></th>
|
||||
<th class="pl-4"><?= __('E-Mail') ?></th>
|
||||
<th><?= __('Datum') ?></th>
|
||||
<th><?= __('Kommentar') ?></th>
|
||||
<th><?= __('Euro') ?></th>
|
||||
<th><?= __('Factor')?></th>
|
||||
@ -58,6 +59,7 @@ $this->assign('title', __('GDT Kontoübersicht'));
|
||||
<tbody>
|
||||
<?php foreach($ownEntries as $entry) : ?>
|
||||
<tr>
|
||||
<td><?= $entry['email'] ?></td>
|
||||
<td><?= new FrozenTime($entry['date']) ?></td>
|
||||
<td><?= h($entry['comment']) ?></td>
|
||||
<td>
|
||||
|
||||
@ -15,6 +15,9 @@ foreach($receiverProposal as $i => $receiver) {
|
||||
]);
|
||||
}*/
|
||||
$this->assign('title', __('Schöpfungstransaktion'));
|
||||
|
||||
use Cake\I18n\FrozenTime;
|
||||
|
||||
?>
|
||||
<style type="text/css">
|
||||
input[type='checkbox'] {
|
||||
@ -63,6 +66,11 @@ $this->assign('title', __('Schöpfungstransaktion'));
|
||||
<fieldset>
|
||||
<?= $this->Form->control('memo'); ?>
|
||||
<?= $this->Form->control('amount', ['required' => false]); ?>
|
||||
<?php
|
||||
$firstDayLastMonth = new FrozenTime();
|
||||
$firstDayLastMonth = $firstDayLastMonth->day(1)->subMonth(1);
|
||||
?>
|
||||
<?= $this->Form->control('target_date', ['value' => $firstDayLastMonth]); ?>
|
||||
<?php foreach($possibleReceiver as $possibleReceiver) :
|
||||
$disable = null;
|
||||
if($activeUser['id'] == $possibleReceiver['id'] || $possibleReceiver['amount'] > 20000000) {
|
||||
@ -85,6 +93,9 @@ $this->assign('title', __('Schöpfungstransaktion'));
|
||||
<div class="input number grd-padding-top-bottom-5">
|
||||
<?= $this->Form->text('user_amount[' . $possibleReceiver['id'] . ']', ['placeholder' => __('Für benutzerdefinierten Betrag'), 'class' => 'user_amount', 'type' => 'number', 'step' => '0.01', $disable]); ?> GDD
|
||||
</div>
|
||||
<div class="input date grd-padding-top-bottom-5">
|
||||
<?= $this->Form->date('user_target_date[' . $possibleReceiver['id'] . ']', ['value' => $firstDayLastMonth]) ?>
|
||||
</div>
|
||||
<?php if(isset($possibleReceiver['pending'])) : ?>
|
||||
<span class="grd_smaller color-orange">
|
||||
Bereits als Transaktion angelegt: <?= $this->element('printGradido', ['number' => $possibleReceiver['pending']]);?>
|
||||
@ -139,7 +150,7 @@ $this->assign('title', __('Schöpfungstransaktion'));
|
||||
var input = userAmountInputs[i];
|
||||
//console.log("input: %o", input);
|
||||
if(input.parentNode != undefined) {
|
||||
var checkbox = input.parentNode.previousElementSibling.previousElementSibling.previousElementSibling;
|
||||
//var checkbox = input.parentNode.previousElementSibling.previousElementSibling.previousElementSibling;
|
||||
//console.log("checkbox: %o?", checkbox);
|
||||
input.onfocus = function(e) {
|
||||
var checkbox = e.target.parentNode.previousElementSibling.previousElementSibling.previousElementSibling;
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit 77e878253ac2a044eb59700386c961c812667eae
|
||||
Subproject commit 9004e6978ac3dafcc635b2ffcf8bc6a156451cca
|
||||
Loading…
x
Reference in New Issue
Block a user