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
{
Log::debug('Now in TransactionGroupFactory::create()');
$this->journalFactory->setUser($this->user);
$this->journalFactory->setErrorOnHash($data['error_if_duplicate_hash'] ?? false);
try {

View File

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

View File

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