mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-25 05:03:13 +00:00
Small check in tags.
This commit is contained in:
@@ -40,7 +40,7 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getAssetAccount(TransactionJournal $journal)
|
public function getAssetAccount(TransactionJournal $journal)
|
||||||
{
|
{
|
||||||
@@ -135,7 +135,19 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
|
|
||||||
// only if this is a deposit.
|
// only if this is a deposit.
|
||||||
if ($journal->transaction_type_id == $deposit->id) {
|
if ($journal->transaction_type_id == $deposit->id) {
|
||||||
$journal->tags()->save($tag);
|
|
||||||
|
// if this is a deposit, account must match the current only journal
|
||||||
|
// (if already present):
|
||||||
|
$currentWithdrawal = $tag->transactionjournals()->where('transaction_type_id', $withdrawal->id)->first();
|
||||||
|
if ($currentWithdrawal && $this->getAssetAccount($currentWithdrawal) == $this->getAssetAccount($journal)) {
|
||||||
|
$journal->tags()->save($tag);
|
||||||
|
} else {
|
||||||
|
if (is_null($currentWithdrawal)) {
|
||||||
|
$journal->tags()->save($tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,10 +177,6 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
);
|
);
|
||||||
$journal->save();
|
$journal->save();
|
||||||
|
|
||||||
if (isset($data['tags']) && is_array($data['tags'])) {
|
|
||||||
$this->saveTags($journal, $data['tags']);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// store or get category
|
// store or get category
|
||||||
if (strlen($data['category']) > 0) {
|
if (strlen($data['category']) > 0) {
|
||||||
@@ -203,6 +211,11 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
$journal->completed = 1;
|
$journal->completed = 1;
|
||||||
$journal->save();
|
$journal->save();
|
||||||
|
|
||||||
|
// store tags
|
||||||
|
if (isset($data['tags']) && is_array($data['tags'])) {
|
||||||
|
$this->saveTags($journal, $data['tags']);
|
||||||
|
}
|
||||||
|
|
||||||
return $journal;
|
return $journal;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user