mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix small errors in bulk and mass controller
This commit is contained in:
parent
8b52006959
commit
2f17521c06
@ -168,7 +168,7 @@ class BulkController extends Controller
|
|||||||
}
|
}
|
||||||
if ($ignoreTags === false) {
|
if ($ignoreTags === false) {
|
||||||
Log::debug(sprintf('Set tags to %s', $request->string('budget_id')));
|
Log::debug(sprintf('Set tags to %s', $request->string('budget_id')));
|
||||||
$repository->updateTags($journal, explode(',', $request->string('tags')));
|
$repository->updateTags($journal,['tags' => explode(',', $request->string('tags'))]);
|
||||||
}
|
}
|
||||||
// update tags if not told to ignore (and is withdrawal)
|
// update tags if not told to ignore (and is withdrawal)
|
||||||
}
|
}
|
||||||
|
@ -115,6 +115,8 @@ class MassController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* TODO this code is a mess.
|
||||||
|
*
|
||||||
* @param Collection $journals
|
* @param Collection $journals
|
||||||
*
|
*
|
||||||
* @return View
|
* @return View
|
||||||
@ -222,10 +224,11 @@ class MassController extends Controller
|
|||||||
if (!is_null($journal)) {
|
if (!is_null($journal)) {
|
||||||
// get optional fields:
|
// get optional fields:
|
||||||
$what = strtolower($this->repository->getTransactionType($journal));
|
$what = strtolower($this->repository->getTransactionType($journal));
|
||||||
$sourceAccountId = $request->get('source_account_id')[$journal->id] ?? 0;
|
$sourceAccountId = $request->get('source_account_id')[$journal->id] ?? null;
|
||||||
$sourceAccountName = $request->get('source_account_name')[$journal->id] ?? '';
|
$currencyId = $request->get('transaction_currency_id')[$journal->id] ?? 1;
|
||||||
$destAccountId = $request->get('destination_account_id')[$journal->id] ?? 0;
|
$sourceAccountName = $request->get('source_account_name')[$journal->id] ?? null;
|
||||||
$destAccountName = $request->get('destination_account_name')[$journal->id] ?? '';
|
$destAccountId = $request->get('destination_account_id')[$journal->id] ?? null;
|
||||||
|
$destAccountName = $request->get('destination_account_name')[$journal->id] ?? null;
|
||||||
$budgetId = $request->get('budget_id')[$journal->id] ?? 0;
|
$budgetId = $request->get('budget_id')[$journal->id] ?? 0;
|
||||||
$category = $request->get('category')[$journal->id];
|
$category = $request->get('category')[$journal->id];
|
||||||
$tags = $journal->tags->pluck('tag')->toArray();
|
$tags = $journal->tags->pluck('tag')->toArray();
|
||||||
@ -233,29 +236,47 @@ class MassController extends Controller
|
|||||||
$foreignAmount = isset($request->get('foreign_amount')[$journal->id]) ? round($request->get('foreign_amount')[$journal->id], 12) : null;
|
$foreignAmount = isset($request->get('foreign_amount')[$journal->id]) ? round($request->get('foreign_amount')[$journal->id], 12) : null;
|
||||||
$foreignCurrencyId = isset($request->get('foreign_currency_id')[$journal->id]) ?
|
$foreignCurrencyId = isset($request->get('foreign_currency_id')[$journal->id]) ?
|
||||||
intval($request->get('foreign_currency_id')[$journal->id]) : null;
|
intval($request->get('foreign_currency_id')[$journal->id]) : null;
|
||||||
|
$notes = $repository->getNoteText($journal);
|
||||||
// build data array
|
// build data array
|
||||||
$data = [
|
$data = [
|
||||||
'id' => $journal->id,
|
'id' => $journal->id,
|
||||||
'what' => $what,
|
'what' => $what,
|
||||||
'description' => $request->get('description')[$journal->id],
|
'description' => $request->get('description')[$journal->id],
|
||||||
'source_account_id' => intval($sourceAccountId),
|
|
||||||
'source_account_name' => $sourceAccountName,
|
|
||||||
'destination_account_id' => intval($destAccountId),
|
|
||||||
'destination_account_name' => $destAccountName,
|
|
||||||
'amount' => $foreignAmount,
|
|
||||||
'native_amount' => $amount,
|
|
||||||
'source_amount' => $amount,
|
|
||||||
'date' => new Carbon($request->get('date')[$journal->id]),
|
'date' => new Carbon($request->get('date')[$journal->id]),
|
||||||
|
'bill_id' => null,
|
||||||
|
'bill_name' => null,
|
||||||
|
'notes' => $notes,
|
||||||
|
'transactions' => [[
|
||||||
|
|
||||||
|
'category_id' => null,
|
||||||
|
'category_name' => $category,
|
||||||
|
'budget_id' => intval($budgetId),
|
||||||
|
'budget_name' => null,
|
||||||
|
'source_id' => intval($sourceAccountId),
|
||||||
|
'source_name' => $sourceAccountName,
|
||||||
|
'destination_id' => intval($destAccountId),
|
||||||
|
'destination_name' => $destAccountName,
|
||||||
|
'amount' => $amount,
|
||||||
|
'identifier' => 0,
|
||||||
|
'reconciled' => false,
|
||||||
|
'currency_id' => intval($currencyId),
|
||||||
|
'currency_code' => null,
|
||||||
|
'description' => null,
|
||||||
|
'foreign_amount' => null,
|
||||||
|
'foreign_currency_id' => $foreignCurrencyId,
|
||||||
|
'foreign_currency_code' => null,
|
||||||
|
//'native_amount' => $amount,
|
||||||
|
//'source_amount' => $amount,
|
||||||
|
//'foreign_amount' => $foreignAmount,
|
||||||
|
//'destination_amount' => $foreignAmount,
|
||||||
|
//'amount' => $foreignAmount,
|
||||||
|
]],
|
||||||
|
'currency_id' => $foreignCurrencyId,
|
||||||
|
'tags' => $tags,
|
||||||
'interest_date' => $journal->interest_date,
|
'interest_date' => $journal->interest_date,
|
||||||
'book_date' => $journal->book_date,
|
'book_date' => $journal->book_date,
|
||||||
'process_date' => $journal->process_date,
|
'process_date' => $journal->process_date,
|
||||||
'budget_id' => intval($budgetId),
|
|
||||||
'currency_id' => $foreignCurrencyId,
|
|
||||||
'foreign_amount' => $foreignAmount,
|
|
||||||
'destination_amount' => $foreignAmount,
|
|
||||||
'category' => $category,
|
|
||||||
'tags' => $tags,
|
|
||||||
];
|
];
|
||||||
// call repository update function.
|
// call repository update function.
|
||||||
$repository->update($journal, $data);
|
$repository->update($journal, $data);
|
||||||
|
@ -37,6 +37,28 @@ use FireflyIII\Models\TransactionJournal;
|
|||||||
trait JournalServiceTrait
|
trait JournalServiceTrait
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
* @param array $data
|
||||||
|
*/
|
||||||
|
public function connectTags(TransactionJournal $journal, array $data): void
|
||||||
|
{
|
||||||
|
/** @var TagFactory $factory */
|
||||||
|
$factory = app(TagFactory::class);
|
||||||
|
$factory->setUser($journal->user);
|
||||||
|
$set = [];
|
||||||
|
if (!is_array($data['tags'])) {
|
||||||
|
return; // @codeCoverageIgnore
|
||||||
|
}
|
||||||
|
foreach ($data['tags'] as $string) {
|
||||||
|
if (strlen($string) > 0) {
|
||||||
|
$tag = $factory->findOrCreate($string);
|
||||||
|
$set[] = $tag->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$journal->tags()->sync($set);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connect bill if present.
|
* Connect bill if present.
|
||||||
*
|
*
|
||||||
@ -62,28 +84,6 @@ trait JournalServiceTrait
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param TransactionJournal $journal
|
|
||||||
* @param array $data
|
|
||||||
*/
|
|
||||||
protected function connectTags(TransactionJournal $journal, array $data): void
|
|
||||||
{
|
|
||||||
/** @var TagFactory $factory */
|
|
||||||
$factory = app(TagFactory::class);
|
|
||||||
$factory->setUser($journal->user);
|
|
||||||
$set = [];
|
|
||||||
if (!is_array($data['tags'])) {
|
|
||||||
return; // @codeCoverageIgnore
|
|
||||||
}
|
|
||||||
foreach ($data['tags'] as $string) {
|
|
||||||
if (strlen($string) > 0) {
|
|
||||||
$tag = $factory->findOrCreate($string);
|
|
||||||
$set[] = $tag->id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$journal->tags()->sync($set);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
* @param array $data
|
* @param array $data
|
||||||
|
Loading…
Reference in New Issue
Block a user