This commit is contained in:
James Cole
2020-10-04 17:11:59 +02:00
parent a5c37f1e4a
commit 0b8415e82b
3 changed files with 13 additions and 5 deletions

View File

@@ -59,6 +59,7 @@ class TransactionGroupFactory
*/ */
public function create(array $data): TransactionGroup public function create(array $data): TransactionGroup
{ {
Log::debug('Now in TransactionGroupFactory::create()');
$this->journalFactory->setUser($this->user); $this->journalFactory->setUser($this->user);
$this->journalFactory->setErrorOnHash($data['error_if_duplicate_hash'] ?? false); $this->journalFactory->setErrorOnHash($data['error_if_duplicate_hash'] ?? false);
try { try {

View File

@@ -134,6 +134,7 @@ class TransactionJournalFactory
*/ */
public function create(array $data): Collection public function create(array $data): Collection
{ {
Log::debug('Now in TransactionJournalFactory::create()');
// convert to special object. // convert to special object.
$dataObject = new NullArrayObject($data); $dataObject = new NullArrayObject($data);

View File

@@ -83,9 +83,9 @@ trait JournalServiceTrait
* @param string $direction * @param string $direction
* @param array $data * @param array $data
* *
* @throws FireflyException
* @return Account * @return Account
* @codeCoverageIgnore * @codeCoverageIgnore
* @throws FireflyException
*/ */
protected function getAccount(string $transactionType, string $direction, array $data): Account protected function getAccount(string $transactionType, string $direction, array $data): Account
{ {
@@ -184,7 +184,7 @@ trait JournalServiceTrait
*/ */
protected function storeNotes(TransactionJournal $journal, ?string $notes): void protected function storeNotes(TransactionJournal $journal, ?string $notes): void
{ {
$notes = (string)$notes; $notes = (string) $notes;
$note = $journal->notes()->first(); $note = $journal->notes()->first();
if ('' !== $notes) { if ('' !== $notes) {
if (null === $note) { if (null === $note) {
@@ -219,14 +219,17 @@ trait JournalServiceTrait
*/ */
protected function storeTags(TransactionJournal $journal, ?array $tags): void protected function storeTags(TransactionJournal $journal, ?array $tags): void
{ {
Log::debug('Now in storeTags()', $tags ?? []);
$this->tagFactory->setUser($journal->user); $this->tagFactory->setUser($journal->user);
$set = []; $set = [];
if (!is_array($tags)) { if (!is_array($tags)) {
Log::debug('Tags is not an array, break.');
return; return;
} }
Log::debug('Start of loop.');
foreach ($tags as $string) { foreach ($tags as $string) {
$string = (string)$string; $string = (string) $string;
Log::debug(sprintf('Now at tag "%s"', $string));
if ('' !== $string) { if ('' !== $string) {
$tag = $this->tagFactory->findOrCreate($string); $tag = $this->tagFactory->findOrCreate($string);
if (null !== $tag) { if (null !== $tag) {
@@ -234,7 +237,10 @@ trait JournalServiceTrait
} }
} }
} }
Log::debug('End of loop.');
Log::debug(sprintf('Total nr. of tags: %d', count($tags)), $tags);
$journal->tags()->sync($set); $journal->tags()->sync($set);
Log::debug('Done!');
} }
/** /**
@@ -336,8 +342,8 @@ trait JournalServiceTrait
* @param array $data * @param array $data
* @param string $preferredType * @param string $preferredType
* *
* @throws FireflyException
* @return Account * @return Account
* @throws FireflyException
*/ */
private function createAccount(?Account $account, array $data, string $preferredType): Account private function createAccount(?Account $account, array $data, string $preferredType): Account
{ {