This commit is contained in:
James Cole 2019-09-14 06:22:02 +02:00
parent ec43c9999a
commit f49ef1622e
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
5 changed files with 68 additions and 1 deletions

View File

@ -1162,4 +1162,40 @@ class GroupCollector implements GroupCollectorInterface
return $this;
}
/**
* Collect transactions created on a specific date.
*
* @param Carbon $date
*
* @return GroupCollectorInterface
*/
public function setCreatedAt(Carbon $date): GroupCollectorInterface
{
$after = $date->format('Y-m-d 00:00:00');
$before = $date->format('Y-m-d 23:59:59');
$this->query->where('transaction_journals.created_at', '>=', $after);
$this->query->where('transaction_journals.created_at', '<=', $before);
Log::debug(sprintf('GroupCollector created_at is now after %s (inclusive)', $after));
return $this;
}
/**
* Collect transactions updated on a specific date.
*
* @param Carbon $date
*
* @return GroupCollectorInterface
*/
public function setUpdatedAt(Carbon $date): GroupCollectorInterface
{
$after = $date->format('Y-m-d 00:00:00');
$before = $date->format('Y-m-d 23:59:59');
$this->query->where('transaction_journals.updated_at', '>=', $after);
$this->query->where('transaction_journals.updated_at', '<=', $before);
Log::debug(sprintf('GroupCollector created_at is now after %s (inclusive)', $after));
return $this;
}
}

View File

@ -139,6 +139,24 @@ interface GroupCollectorInterface
*/
public function setAfter(Carbon $date): GroupCollectorInterface;
/**
* Collect transactions created on a specific date.
*
* @param Carbon $date
*
* @return GroupCollectorInterface
*/
public function setCreatedAt(Carbon $date): GroupCollectorInterface;
/**
* Collect transactions updated on a specific date.
*
* @param Carbon $date
*
* @return GroupCollectorInterface
*/
public function setUpdatedAt(Carbon $date): GroupCollectorInterface;
/**
* Collect transactions before a specific date.
*

View File

@ -288,6 +288,16 @@ class Search implements SearchInterface
$after = new Carbon($modifier['value']);
$collector->setAfter($after);
break;
case 'created_at':
Log::debug(sprintf('Set "%s" using collector with value "%s"', $modifier['type'], $modifier['value']));
$createdAt = new Carbon($modifier['value']);
$collector->setCreatedAt($createdAt);
break;
case 'updated_at':
Log::debug(sprintf('Set "%s" using collector with value "%s"', $modifier['type'], $modifier['value']));
$updatedAt = new Carbon($modifier['value']);
$collector->setUpdatedAt($updatedAt);
break;
}
}
$collector->setAccounts($totalAccounts);

View File

@ -519,7 +519,8 @@ return [
'default_currency' => 'EUR',
'default_language' => 'en_US',
'search_modifiers' => ['amount_is', 'amount', 'amount_max', 'amount_min', 'amount_less', 'amount_more', 'source', 'destination', 'category',
'budget', 'bill', 'type', 'date', 'date_before', 'date_after', 'on', 'before', 'after','from','to','tag'],
'budget', 'bill', 'type', 'date', 'date_before', 'date_after', 'on', 'before', 'after', 'from', 'to', 'tag', 'created_at',
'updated_at'],
// TODO notes has_attachments
'cer_providers' => [

View File

@ -253,6 +253,8 @@ return [
'search_modifier_on' => 'Transaction date is :value',
'search_modifier_before' => 'Transaction date is before :value',
'search_modifier_after' => 'Transaction date is after :value',
'search_modifier_created_at' => 'Transaction was created on :value',
'search_modifier_updated_at' => 'Transaction was last updated on :value',
'modifiers_applies_are' => 'The following modifiers are applied to the search as well:',
'general_search_error' => 'An error occured while searching. Please check the log files for more information.',
'search_box' => 'Search',