mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Code for 4.8.0
This commit is contained in:
@@ -25,8 +25,12 @@ namespace FireflyIII\Services\Internal\Support;
|
||||
|
||||
use Exception;
|
||||
use FireflyIII\Factory\BillFactory;
|
||||
use FireflyIII\Factory\BudgetFactory;
|
||||
use FireflyIII\Factory\CategoryFactory;
|
||||
use FireflyIII\Factory\TagFactory;
|
||||
use FireflyIII\Factory\TransactionJournalMetaFactory;
|
||||
use FireflyIII\Models\Budget;
|
||||
use FireflyIII\Models\Category;
|
||||
use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Log;
|
||||
@@ -89,6 +93,70 @@ trait JournalServiceTrait
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $budgetId
|
||||
* @param null|string $budgetName
|
||||
*
|
||||
* @return Budget|null
|
||||
*/
|
||||
protected function findBudget(?int $budgetId, ?string $budgetName): ?Budget
|
||||
{
|
||||
/** @var BudgetFactory $factory */
|
||||
$factory = app(BudgetFactory::class);
|
||||
$factory->setUser($this->user);
|
||||
|
||||
return $factory->find($budgetId, $budgetName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $categoryId
|
||||
* @param null|string $categoryName
|
||||
*
|
||||
* @return Category|null
|
||||
*/
|
||||
protected function findCategory(?int $categoryId, ?string $categoryName): ?Category
|
||||
{
|
||||
Log::debug(sprintf('Going to find or create category #%d, with name "%s"', $categoryId, $categoryName));
|
||||
/** @var CategoryFactory $factory */
|
||||
$factory = app(CategoryFactory::class);
|
||||
$factory->setUser($this->user);
|
||||
|
||||
return $factory->findOrCreate($categoryId, $categoryName);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param Budget|null $budget
|
||||
*/
|
||||
protected function setBudget(TransactionJournal $journal, ?Budget $budget): void
|
||||
{
|
||||
if (null === $budget) {
|
||||
$journal->budgets()->sync([]);
|
||||
|
||||
return;
|
||||
}
|
||||
$journal->budgets()->sync([$budget->id]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param Category|null $category
|
||||
*/
|
||||
protected function setCategory(TransactionJournal $journal, ?Category $category): void
|
||||
{
|
||||
if (null === $category) {
|
||||
$journal->categories()->sync([]);
|
||||
|
||||
return;
|
||||
}
|
||||
$journal->categories()->sync([$category->id]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @param array $data
|
||||
|
@@ -93,8 +93,6 @@ trait TransactionServiceTrait
|
||||
$repository = app(AccountRepositoryInterface::class);
|
||||
$repository->setUser($this->user);
|
||||
|
||||
Log::debug(sprintf('Going to find account #%d ("%s")', $accountId, $accountName));
|
||||
|
||||
if (null === $expectedType) {
|
||||
return $repository->findNull($accountId);
|
||||
}
|
||||
@@ -118,37 +116,6 @@ trait TransactionServiceTrait
|
||||
return $repository->getCashAccount();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $budgetId
|
||||
* @param null|string $budgetName
|
||||
*
|
||||
* @return Budget|null
|
||||
*/
|
||||
protected function findBudget(?int $budgetId, ?string $budgetName): ?Budget
|
||||
{
|
||||
/** @var BudgetFactory $factory */
|
||||
$factory = app(BudgetFactory::class);
|
||||
$factory->setUser($this->user);
|
||||
|
||||
return $factory->find($budgetId, $budgetName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $categoryId
|
||||
* @param null|string $categoryName
|
||||
*
|
||||
* @return Category|null
|
||||
*/
|
||||
protected function findCategory(?int $categoryId, ?string $categoryName): ?Category
|
||||
{
|
||||
Log::debug(sprintf('Going to find or create category #%d, with name "%s"', $categoryId, $categoryName));
|
||||
/** @var CategoryFactory $factory */
|
||||
$factory = app(CategoryFactory::class);
|
||||
$factory->setUser($this->user);
|
||||
|
||||
return $factory->findOrCreate($categoryId, $categoryName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int|null $currencyId
|
||||
* @param null|string $currencyCode
|
||||
@@ -162,38 +129,6 @@ trait TransactionServiceTrait
|
||||
return $factory->find($currencyId, $currencyCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Transaction $transaction
|
||||
* @param Budget|null $budget
|
||||
*/
|
||||
protected function setBudget(Transaction $transaction, ?Budget $budget): void
|
||||
{
|
||||
if (null === $budget) {
|
||||
$transaction->budgets()->sync([]);
|
||||
|
||||
return;
|
||||
}
|
||||
$transaction->budgets()->sync([$budget->id]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Transaction $transaction
|
||||
* @param Category|null $category
|
||||
*/
|
||||
protected function setCategory(Transaction $transaction, ?Category $category): void
|
||||
{
|
||||
if (null === $category) {
|
||||
$transaction->categories()->sync([]);
|
||||
|
||||
return;
|
||||
}
|
||||
$transaction->categories()->sync([$category->id]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Transaction $transaction
|
||||
* @param string|null $amount
|
||||
|
Reference in New Issue
Block a user