mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-18 18:44:16 +00:00
🤖 Auto commit for release 'develop' on 2025-06-02
This commit is contained in:
@@ -34,7 +34,6 @@ use FireflyIII\Support\JsonApi\Enrichments\TransactionGroupEnrichment;
|
|||||||
use FireflyIII\Transformers\TransactionGroupTransformer;
|
use FireflyIII\Transformers\TransactionGroupTransformer;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Support\Facades\Log;
|
|
||||||
use League\Fractal\Resource\Item;
|
use League\Fractal\Resource\Item;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
|
||||||
@@ -73,24 +72,24 @@ class UpdateController extends Controller
|
|||||||
public function update(UpdateRequest $request, TransactionGroup $transactionGroup): JsonResponse
|
public function update(UpdateRequest $request, TransactionGroup $transactionGroup): JsonResponse
|
||||||
{
|
{
|
||||||
app('log')->debug('Now in update routine for transaction group');
|
app('log')->debug('Now in update routine for transaction group');
|
||||||
$data = $request->getAll();
|
$data = $request->getAll();
|
||||||
$oldHash = $this->groupRepository->getCompareHash($transactionGroup);
|
$oldHash = $this->groupRepository->getCompareHash($transactionGroup);
|
||||||
$transactionGroup = $this->groupRepository->update($transactionGroup, $data);
|
$transactionGroup = $this->groupRepository->update($transactionGroup, $data);
|
||||||
$newHash = $this->groupRepository->getCompareHash($transactionGroup);
|
$newHash = $this->groupRepository->getCompareHash($transactionGroup);
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
|
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
$applyRules = $data['apply_rules'] ?? true;
|
$applyRules = $data['apply_rules'] ?? true;
|
||||||
$fireWebhooks = $data['fire_webhooks'] ?? true;
|
$fireWebhooks = $data['fire_webhooks'] ?? true;
|
||||||
$runRecalculations = $oldHash !== $newHash;
|
$runRecalculations = $oldHash !== $newHash;
|
||||||
event(new UpdatedTransactionGroup($transactionGroup, $applyRules, $fireWebhooks, $runRecalculations));
|
event(new UpdatedTransactionGroup($transactionGroup, $applyRules, $fireWebhooks, $runRecalculations));
|
||||||
|
|
||||||
/** @var User $admin */
|
/** @var User $admin */
|
||||||
$admin = auth()->user();
|
$admin = auth()->user();
|
||||||
|
|
||||||
// use new group collector:
|
// use new group collector:
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector
|
$collector
|
||||||
->setUser($admin)
|
->setUser($admin)
|
||||||
// filter on transaction group.
|
// filter on transaction group.
|
||||||
@@ -99,20 +98,20 @@ class UpdateController extends Controller
|
|||||||
->withAPIInformation()
|
->withAPIInformation()
|
||||||
;
|
;
|
||||||
|
|
||||||
$selectedGroup = $collector->getGroups()->first();
|
$selectedGroup = $collector->getGroups()->first();
|
||||||
if (null === $selectedGroup) {
|
if (null === $selectedGroup) {
|
||||||
throw new NotFoundHttpException();
|
throw new NotFoundHttpException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// enrich
|
// enrich
|
||||||
$enrichment = new TransactionGroupEnrichment();
|
$enrichment = new TransactionGroupEnrichment();
|
||||||
$enrichment->setUser($admin);
|
$enrichment->setUser($admin);
|
||||||
$selectedGroup = $enrichment->enrichSingle($selectedGroup);
|
$selectedGroup = $enrichment->enrichSingle($selectedGroup);
|
||||||
|
|
||||||
/** @var TransactionGroupTransformer $transformer */
|
/** @var TransactionGroupTransformer $transformer */
|
||||||
$transformer = app(TransactionGroupTransformer::class);
|
$transformer = app(TransactionGroupTransformer::class);
|
||||||
$transformer->setParameters($this->parameters);
|
$transformer->setParameters($this->parameters);
|
||||||
$resource = new Item($selectedGroup, $transformer, 'transactions');
|
$resource = new Item($selectedGroup, $transformer, 'transactions');
|
||||||
|
|
||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
|
||||||
}
|
}
|
||||||
|
@@ -65,29 +65,29 @@ class UpdateController extends Controller
|
|||||||
public function update(UpdateRequest $request, TransactionGroup $transactionGroup): JsonResponse
|
public function update(UpdateRequest $request, TransactionGroup $transactionGroup): JsonResponse
|
||||||
{
|
{
|
||||||
app('log')->debug('Now in update routine for transaction group [v2]!');
|
app('log')->debug('Now in update routine for transaction group [v2]!');
|
||||||
$data = $request->getAll();
|
$data = $request->getAll();
|
||||||
$transactionGroup = $this->groupRepository->update($transactionGroup, $data);
|
$transactionGroup = $this->groupRepository->update($transactionGroup, $data);
|
||||||
$applyRules = $data['apply_rules'] ?? true;
|
$applyRules = $data['apply_rules'] ?? true;
|
||||||
$fireWebhooks = $data['fire_webhooks'] ?? true;
|
$fireWebhooks = $data['fire_webhooks'] ?? true;
|
||||||
$runRecalculations = true;
|
$runRecalculations = true;
|
||||||
|
|
||||||
event(new UpdatedTransactionGroup($transactionGroup, $applyRules, $fireWebhooks, $runRecalculations));
|
event(new UpdatedTransactionGroup($transactionGroup, $applyRules, $fireWebhooks, $runRecalculations));
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
/** @var User $admin */
|
/** @var User $admin */
|
||||||
$admin = auth()->user();
|
$admin = auth()->user();
|
||||||
|
|
||||||
// use new group collector:
|
// use new group collector:
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector->setUser($admin)->setTransactionGroup($transactionGroup);
|
$collector->setUser($admin)->setTransactionGroup($transactionGroup);
|
||||||
|
|
||||||
$selectedGroup = $collector->getGroups()->first();
|
$selectedGroup = $collector->getGroups()->first();
|
||||||
if (null === $selectedGroup) {
|
if (null === $selectedGroup) {
|
||||||
throw new FireflyException('200032: Cannot find transaction. Possibly, a rule deleted this transaction after its creation.');
|
throw new FireflyException('200032: Cannot find transaction. Possibly, a rule deleted this transaction after its creation.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$transformer = new TransactionGroupTransformer();
|
$transformer = new TransactionGroupTransformer();
|
||||||
$transformer->setParameters($this->parameters);
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
return response()->api($this->jsonApiObject('transactions', $selectedGroup, $transformer))->header('Content-Type', self::CONTENT_TYPE);
|
return response()->api($this->jsonApiObject('transactions', $selectedGroup, $transformer))->header('Content-Type', self::CONTENT_TYPE);
|
||||||
|
@@ -191,15 +191,15 @@ class MassController extends Controller
|
|||||||
*/
|
*/
|
||||||
private function updateJournal(int $journalId, MassEditJournalRequest $request): void
|
private function updateJournal(int $journalId, MassEditJournalRequest $request): void
|
||||||
{
|
{
|
||||||
$journal = $this->repository->find($journalId);
|
$journal = $this->repository->find($journalId);
|
||||||
if (!$journal instanceof TransactionJournal) {
|
if (!$journal instanceof TransactionJournal) {
|
||||||
throw new FireflyException(sprintf('Trying to edit non-existent or deleted journal #%d', $journalId));
|
throw new FireflyException(sprintf('Trying to edit non-existent or deleted journal #%d', $journalId));
|
||||||
}
|
}
|
||||||
$service = app(JournalUpdateService::class);
|
$service = app(JournalUpdateService::class);
|
||||||
// for each field, call the update service.
|
// for each field, call the update service.
|
||||||
$service->setTransactionJournal($journal);
|
$service->setTransactionJournal($journal);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'date' => $this->getDateFromRequest($request, $journal->id, 'date'),
|
'date' => $this->getDateFromRequest($request, $journal->id, 'date'),
|
||||||
'description' => $this->getStringFromRequest($request, $journal->id, 'description'),
|
'description' => $this->getStringFromRequest($request, $journal->id, 'description'),
|
||||||
'source_id' => $this->getIntFromRequest($request, $journal->id, 'source_id'),
|
'source_id' => $this->getIntFromRequest($request, $journal->id, 'source_id'),
|
||||||
|
@@ -85,7 +85,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
|||||||
|
|
||||||
public function expandGroup(TransactionGroup $group): array
|
public function expandGroup(TransactionGroup $group): array
|
||||||
{
|
{
|
||||||
$result = $group->toArray();
|
$result = $group->toArray();
|
||||||
$result['transaction_journals'] = [];
|
$result['transaction_journals'] = [];
|
||||||
|
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
@@ -98,16 +98,16 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
|||||||
|
|
||||||
private function expandJournal(TransactionJournal $journal): array
|
private function expandJournal(TransactionJournal $journal): array
|
||||||
{
|
{
|
||||||
$array = $journal->toArray();
|
$array = $journal->toArray();
|
||||||
$array['transactions'] = [];
|
$array['transactions'] = [];
|
||||||
$array['meta'] = $journal->transactionJournalMeta->toArray();
|
$array['meta'] = $journal->transactionJournalMeta->toArray();
|
||||||
$array['tags'] = $journal->tags->toArray();
|
$array['tags'] = $journal->tags->toArray();
|
||||||
$array['categories'] = $journal->categories->toArray();
|
$array['categories'] = $journal->categories->toArray();
|
||||||
$array['budgets'] = $journal->budgets->toArray();
|
$array['budgets'] = $journal->budgets->toArray();
|
||||||
$array['notes'] = $journal->notes->toArray();
|
$array['notes'] = $journal->notes->toArray();
|
||||||
$array['locations'] = [];
|
$array['locations'] = [];
|
||||||
$array['attachments'] = $journal->attachments->toArray();
|
$array['attachments'] = $journal->attachments->toArray();
|
||||||
$array['links'] = [];
|
$array['links'] = [];
|
||||||
$array['piggy_bank_events'] = $journal->piggyBankEvents->toArray();
|
$array['piggy_bank_events'] = $journal->piggyBankEvents->toArray();
|
||||||
|
|
||||||
/** @var Transaction $transaction */
|
/** @var Transaction $transaction */
|
||||||
@@ -120,9 +120,9 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
|||||||
|
|
||||||
private function expandTransaction(Transaction $transaction): array
|
private function expandTransaction(Transaction $transaction): array
|
||||||
{
|
{
|
||||||
$array = $transaction->toArray();
|
$array = $transaction->toArray();
|
||||||
$array['account'] = $transaction->account->toArray();
|
$array['account'] = $transaction->account->toArray();
|
||||||
$array['budgets'] = [];
|
$array['budgets'] = [];
|
||||||
$array['categories'] = [];
|
$array['categories'] = [];
|
||||||
|
|
||||||
foreach ($transaction->categories as $category) {
|
foreach ($transaction->categories as $category) {
|
||||||
@@ -143,24 +143,25 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
|||||||
{
|
{
|
||||||
$repository = app(AttachmentRepositoryInterface::class);
|
$repository = app(AttachmentRepositoryInterface::class);
|
||||||
$repository->setUser($this->user);
|
$repository->setUser($this->user);
|
||||||
$journals = $group->transactionJournals->pluck('id')->toArray();
|
$journals = $group->transactionJournals->pluck('id')->toArray();
|
||||||
$set = Attachment::whereIn('attachable_id', $journals)
|
$set = Attachment::whereIn('attachable_id', $journals)
|
||||||
->where('attachable_type', TransactionJournal::class)
|
->where('attachable_type', TransactionJournal::class)
|
||||||
->where('uploaded', true)
|
->where('uploaded', true)
|
||||||
->whereNull('deleted_at')->get();
|
->whereNull('deleted_at')->get()
|
||||||
|
;
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
/** @var Attachment $attachment */
|
/** @var Attachment $attachment */
|
||||||
foreach ($set as $attachment) {
|
foreach ($set as $attachment) {
|
||||||
$journalId = $attachment->attachable_id;
|
$journalId = $attachment->attachable_id;
|
||||||
$result[$journalId] ??= [];
|
$result[$journalId] ??= [];
|
||||||
$current = $attachment->toArray();
|
$current = $attachment->toArray();
|
||||||
$current['file_exists'] = true;
|
$current['file_exists'] = true;
|
||||||
$current['notes'] = $repository->getNoteText($attachment);
|
$current['notes'] = $repository->getNoteText($attachment);
|
||||||
// already determined that this attachable is a TransactionJournal.
|
// already determined that this attachable is a TransactionJournal.
|
||||||
$current['journal_title'] = $attachment->attachable->description;
|
$current['journal_title'] = $attachment->attachable->description;
|
||||||
$result[$journalId][] = $current;
|
$result[$journalId][] = $current;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@@ -174,7 +175,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
|||||||
/** @var null|Note $note */
|
/** @var null|Note $note */
|
||||||
$note = Note::where('noteable_id', $journalId)
|
$note = Note::where('noteable_id', $journalId)
|
||||||
->where('noteable_type', TransactionJournal::class)
|
->where('noteable_type', TransactionJournal::class)
|
||||||
->first();
|
->first()
|
||||||
|
;
|
||||||
if (null === $note) {
|
if (null === $note) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -187,9 +189,9 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
|||||||
*/
|
*/
|
||||||
public function getLinks(TransactionGroup $group): array
|
public function getLinks(TransactionGroup $group): array
|
||||||
{
|
{
|
||||||
$return = [];
|
$return = [];
|
||||||
$journals = $group->transactionJournals->pluck('id')->toArray();
|
$journals = $group->transactionJournals->pluck('id')->toArray();
|
||||||
$set = TransactionJournalLink::where(
|
$set = TransactionJournalLink::where(
|
||||||
static function (Builder $q) use ($journals): void {
|
static function (Builder $q) use ($journals): void {
|
||||||
$q->whereIn('source_id', $journals);
|
$q->whereIn('source_id', $journals);
|
||||||
$q->orWhereIn('destination_id', $journals);
|
$q->orWhereIn('destination_id', $journals);
|
||||||
@@ -197,7 +199,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
|||||||
)
|
)
|
||||||
->with(['source', 'destination', 'source.transactions'])
|
->with(['source', 'destination', 'source.transactions'])
|
||||||
->leftJoin('link_types', 'link_types.id', '=', 'journal_links.link_type_id')
|
->leftJoin('link_types', 'link_types.id', '=', 'journal_links.link_type_id')
|
||||||
->get(['journal_links.*', 'link_types.inward', 'link_types.outward', 'link_types.editable']);
|
->get(['journal_links.*', 'link_types.inward', 'link_types.outward', 'link_types.editable'])
|
||||||
|
;
|
||||||
|
|
||||||
/** @var TransactionJournalLink $entry */
|
/** @var TransactionJournalLink $entry */
|
||||||
foreach ($set as $entry) {
|
foreach ($set as $entry) {
|
||||||
@@ -207,28 +210,28 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
|||||||
// phpstan: the editable field is provided by the query.
|
// phpstan: the editable field is provided by the query.
|
||||||
|
|
||||||
if ($journalId === $entry->source_id) {
|
if ($journalId === $entry->source_id) {
|
||||||
$amount = $this->getFormattedAmount($entry->destination);
|
$amount = $this->getFormattedAmount($entry->destination);
|
||||||
$foreignAmount = $this->getFormattedForeignAmount($entry->destination);
|
$foreignAmount = $this->getFormattedForeignAmount($entry->destination);
|
||||||
$return[$journalId][] = [
|
$return[$journalId][] = [
|
||||||
'id' => $entry->id,
|
'id' => $entry->id,
|
||||||
'link' => $entry->outward,
|
'link' => $entry->outward,
|
||||||
'group' => $entry->destination->transaction_group_id,
|
'group' => $entry->destination->transaction_group_id,
|
||||||
'description' => $entry->destination->description,
|
'description' => $entry->destination->description,
|
||||||
'editable' => 1 === (int)$entry->editable,
|
'editable' => 1 === (int)$entry->editable,
|
||||||
'amount' => $amount,
|
'amount' => $amount,
|
||||||
'foreign_amount' => $foreignAmount,
|
'foreign_amount' => $foreignAmount,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
if ($journalId === $entry->destination_id) {
|
if ($journalId === $entry->destination_id) {
|
||||||
$amount = $this->getFormattedAmount($entry->source);
|
$amount = $this->getFormattedAmount($entry->source);
|
||||||
$foreignAmount = $this->getFormattedForeignAmount($entry->source);
|
$foreignAmount = $this->getFormattedForeignAmount($entry->source);
|
||||||
$return[$journalId][] = [
|
$return[$journalId][] = [
|
||||||
'id' => $entry->id,
|
'id' => $entry->id,
|
||||||
'link' => $entry->inward,
|
'link' => $entry->inward,
|
||||||
'group' => $entry->source->transaction_group_id,
|
'group' => $entry->source->transaction_group_id,
|
||||||
'description' => $entry->source->description,
|
'description' => $entry->source->description,
|
||||||
'editable' => 1 === (int)$entry->editable,
|
'editable' => 1 === (int)$entry->editable,
|
||||||
'amount' => $amount,
|
'amount' => $amount,
|
||||||
'foreign_amount' => $foreignAmount,
|
'foreign_amount' => $foreignAmount,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -241,9 +244,9 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
|||||||
{
|
{
|
||||||
/** @var Transaction $transaction */
|
/** @var Transaction $transaction */
|
||||||
$transaction = $journal->transactions->first();
|
$transaction = $journal->transactions->first();
|
||||||
$currency = $transaction->transactionCurrency;
|
$currency = $transaction->transactionCurrency;
|
||||||
$type = $journal->transactionType->type;
|
$type = $journal->transactionType->type;
|
||||||
$amount = app('steam')->positive($transaction->amount);
|
$amount = app('steam')->positive($transaction->amount);
|
||||||
if (TransactionTypeEnum::WITHDRAWAL->value === $type) {
|
if (TransactionTypeEnum::WITHDRAWAL->value === $type) {
|
||||||
return app('amount')->formatAnything($currency, app('steam')->negative($amount));
|
return app('amount')->formatAnything($currency, app('steam')->negative($amount));
|
||||||
}
|
}
|
||||||
@@ -264,9 +267,9 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
|||||||
if (0 === bccomp('0', (string)$transaction->foreign_amount)) {
|
if (0 === bccomp('0', (string)$transaction->foreign_amount)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
$currency = $transaction->foreignCurrency;
|
$currency = $transaction->foreignCurrency;
|
||||||
$type = $journal->transactionType->type;
|
$type = $journal->transactionType->type;
|
||||||
$amount = app('steam')->positive($transaction->foreign_amount);
|
$amount = app('steam')->positive($transaction->foreign_amount);
|
||||||
if (TransactionTypeEnum::WITHDRAWAL->value === $type) {
|
if (TransactionTypeEnum::WITHDRAWAL->value === $type) {
|
||||||
return app('amount')->formatAnything($currency, app('steam')->negative($amount));
|
return app('amount')->formatAnything($currency, app('steam')->negative($amount));
|
||||||
}
|
}
|
||||||
@@ -293,11 +296,12 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
|||||||
*/
|
*/
|
||||||
public function getMetaDateFields(int $journalId, array $fields): NullArrayObject
|
public function getMetaDateFields(int $journalId, array $fields): NullArrayObject
|
||||||
{
|
{
|
||||||
$query = DB::table('journal_meta')
|
$query = DB::table('journal_meta')
|
||||||
->where('transaction_journal_id', $journalId)
|
->where('transaction_journal_id', $journalId)
|
||||||
->whereIn('name', $fields)
|
->whereIn('name', $fields)
|
||||||
->whereNull('deleted_at')
|
->whereNull('deleted_at')
|
||||||
->get(['name', 'data']);
|
->get(['name', 'data'])
|
||||||
|
;
|
||||||
$return = [];
|
$return = [];
|
||||||
|
|
||||||
foreach ($query as $row) {
|
foreach ($query as $row) {
|
||||||
@@ -312,11 +316,12 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
|||||||
*/
|
*/
|
||||||
public function getMetaFields(int $journalId, array $fields): NullArrayObject
|
public function getMetaFields(int $journalId, array $fields): NullArrayObject
|
||||||
{
|
{
|
||||||
$query = DB::table('journal_meta')
|
$query = DB::table('journal_meta')
|
||||||
->where('transaction_journal_id', $journalId)
|
->where('transaction_journal_id', $journalId)
|
||||||
->whereIn('name', $fields)
|
->whereIn('name', $fields)
|
||||||
->whereNull('deleted_at')
|
->whereNull('deleted_at')
|
||||||
->get(['name', 'data']);
|
->get(['name', 'data'])
|
||||||
|
;
|
||||||
$return = [];
|
$return = [];
|
||||||
|
|
||||||
foreach ($query as $row) {
|
foreach ($query as $row) {
|
||||||
@@ -333,12 +338,13 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
|||||||
*/
|
*/
|
||||||
public function getPiggyEvents(TransactionGroup $group): array
|
public function getPiggyEvents(TransactionGroup $group): array
|
||||||
{
|
{
|
||||||
$return = [];
|
$return = [];
|
||||||
$journals = $group->transactionJournals->pluck('id')->toArray();
|
$journals = $group->transactionJournals->pluck('id')->toArray();
|
||||||
$currency = app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
|
$currency = app('amount')->getNativeCurrencyByUserGroup($this->user->userGroup);
|
||||||
$data = PiggyBankEvent::whereIn('transaction_journal_id', $journals)
|
$data = PiggyBankEvent::whereIn('transaction_journal_id', $journals)
|
||||||
->with('piggyBank', 'piggyBank.account')
|
->with('piggyBank', 'piggyBank.account')
|
||||||
->get(['piggy_bank_events.*']);
|
->get(['piggy_bank_events.*'])
|
||||||
|
;
|
||||||
|
|
||||||
/** @var PiggyBankEvent $row */
|
/** @var PiggyBankEvent $row */
|
||||||
foreach ($data as $row) {
|
foreach ($data as $row) {
|
||||||
@@ -346,19 +352,20 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// get currency preference.
|
// get currency preference.
|
||||||
$currencyPreference = AccountMeta::where('account_id', $row->piggyBank->account_id)
|
$currencyPreference = AccountMeta::where('account_id', $row->piggyBank->account_id)
|
||||||
->where('name', 'currency_id')
|
->where('name', 'currency_id')
|
||||||
->first();
|
->first()
|
||||||
|
;
|
||||||
if (null !== $currencyPreference) {
|
if (null !== $currencyPreference) {
|
||||||
$currency = TransactionCurrency::where('id', $currencyPreference->data)->first();
|
$currency = TransactionCurrency::where('id', $currencyPreference->data)->first();
|
||||||
}
|
}
|
||||||
$journalId = $row->transaction_journal_id;
|
$journalId = $row->transaction_journal_id;
|
||||||
$return[$journalId] ??= [];
|
$return[$journalId] ??= [];
|
||||||
|
|
||||||
$return[$journalId][] = [
|
$return[$journalId][] = [
|
||||||
'piggy' => $row->piggyBank->name,
|
'piggy' => $row->piggyBank->name,
|
||||||
'piggy_id' => $row->piggy_bank_id,
|
'piggy_id' => $row->piggy_bank_id,
|
||||||
'amount' => app('amount')->formatAnything($currency, $row->amount),
|
'amount' => app('amount')->formatAnything($currency, $row->amount),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,7 +389,8 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
|||||||
->leftJoin('tags', 'tag_transaction_journal.tag_id', '=', 'tags.id')
|
->leftJoin('tags', 'tag_transaction_journal.tag_id', '=', 'tags.id')
|
||||||
->where('tag_transaction_journal.transaction_journal_id', $journalId)
|
->where('tag_transaction_journal.transaction_journal_id', $journalId)
|
||||||
->orderBy('tags.tag', 'ASC')
|
->orderBy('tags.tag', 'ASC')
|
||||||
->get(['tags.tag']);
|
->get(['tags.tag'])
|
||||||
|
;
|
||||||
|
|
||||||
return $result->pluck('tag')->toArray();
|
return $result->pluck('tag')->toArray();
|
||||||
}
|
}
|
||||||
@@ -427,7 +435,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
|||||||
|
|
||||||
public function getCompareHash(TransactionGroup $group): string
|
public function getCompareHash(TransactionGroup $group): string
|
||||||
{
|
{
|
||||||
$sum = '0';
|
$sum = '0';
|
||||||
$names = '';
|
$names = '';
|
||||||
|
|
||||||
/** @var TransactionJournal $journal */
|
/** @var TransactionJournal $journal */
|
||||||
@@ -435,7 +443,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface,
|
|||||||
/** @var Transaction $transaction */
|
/** @var Transaction $transaction */
|
||||||
foreach ($journal->transactions as $transaction) {
|
foreach ($journal->transactions as $transaction) {
|
||||||
if (-1 === bccomp('0', (string)$transaction->amount)) {
|
if (-1 === bccomp('0', (string)$transaction->amount)) {
|
||||||
$sum = bcadd($sum, $transaction->amount);
|
$sum = bcadd($sum, $transaction->amount);
|
||||||
$names = sprintf('%s%s', $names, $transaction->account->name);
|
$names = sprintf('%s%s', $names, $transaction->account->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -51,9 +51,6 @@ interface TransactionGroupRepositoryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Small method that returns a hash that can be used to compare two transaction groups.
|
* Small method that returns a hash that can be used to compare two transaction groups.
|
||||||
*
|
|
||||||
* @param TransactionGroup $group
|
|
||||||
* @return string
|
|
||||||
*/
|
*/
|
||||||
public function getCompareHash(TransactionGroup $group): string;
|
public function getCompareHash(TransactionGroup $group): string;
|
||||||
|
|
||||||
|
@@ -78,20 +78,20 @@ class JournalUpdateService
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->destinationAccount = null;
|
$this->destinationAccount = null;
|
||||||
$this->destinationTransaction = null;
|
$this->destinationTransaction = null;
|
||||||
$this->sourceAccount = null;
|
$this->sourceAccount = null;
|
||||||
$this->sourceTransaction = null;
|
$this->sourceTransaction = null;
|
||||||
$this->transactionGroup = null;
|
$this->transactionGroup = null;
|
||||||
$this->transactionJournal = null;
|
$this->transactionJournal = null;
|
||||||
$this->billRepository = app(BillRepositoryInterface::class);
|
$this->billRepository = app(BillRepositoryInterface::class);
|
||||||
$this->categoryRepository = app(CategoryRepositoryInterface::class);
|
$this->categoryRepository = app(CategoryRepositoryInterface::class);
|
||||||
$this->budgetRepository = app(BudgetRepositoryInterface::class);
|
$this->budgetRepository = app(BudgetRepositoryInterface::class);
|
||||||
$this->tagFactory = app(TagFactory::class);
|
$this->tagFactory = app(TagFactory::class);
|
||||||
$this->accountRepository = app(AccountRepositoryInterface::class);
|
$this->accountRepository = app(AccountRepositoryInterface::class);
|
||||||
$this->currencyRepository = app(CurrencyRepositoryInterface::class);
|
$this->currencyRepository = app(CurrencyRepositoryInterface::class);
|
||||||
$this->transactionGroupRepository = app(TransactionGroupRepositoryInterface::class);
|
$this->transactionGroupRepository = app(TransactionGroupRepositoryInterface::class);
|
||||||
$this->metaString = [
|
$this->metaString = [
|
||||||
'sepa_cc',
|
'sepa_cc',
|
||||||
'sepa_ct_op',
|
'sepa_ct_op',
|
||||||
'sepa_ct_id',
|
'sepa_ct_id',
|
||||||
@@ -106,7 +106,7 @@ class JournalUpdateService
|
|||||||
'external_id',
|
'external_id',
|
||||||
'external_url',
|
'external_url',
|
||||||
];
|
];
|
||||||
$this->metaDate = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date',
|
$this->metaDate = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date',
|
||||||
'invoice_date', ];
|
'invoice_date', ];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ class JournalUpdateService
|
|||||||
$this->destinationTransaction = null;
|
$this->destinationTransaction = null;
|
||||||
$this->sourceAccount = null;
|
$this->sourceAccount = null;
|
||||||
$this->sourceTransaction = null;
|
$this->sourceTransaction = null;
|
||||||
$this->startCompareHash = $this->transactionGroupRepository->getCompareHash($transactionGroup);
|
$this->startCompareHash = $this->transactionGroupRepository->getCompareHash($transactionGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTransactionJournal(TransactionJournal $transactionJournal): void
|
public function setTransactionJournal(TransactionJournal $transactionJournal): void
|
||||||
@@ -822,7 +822,8 @@ class JournalUpdateService
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isCompareHashChanged(): bool {
|
public function isCompareHashChanged(): bool
|
||||||
|
{
|
||||||
Log::debug(sprintf('Now in %s', __METHOD__));
|
Log::debug(sprintf('Now in %s', __METHOD__));
|
||||||
$compareHash = $this->transactionGroupRepository->getCompareHash($this->transactionGroup);
|
$compareHash = $this->transactionGroupRepository->getCompareHash($this->transactionGroup);
|
||||||
Log::debug(sprintf('Compare hash is "%s".', $compareHash));
|
Log::debug(sprintf('Compare hash is "%s".', $compareHash));
|
||||||
|
@@ -78,7 +78,7 @@ return [
|
|||||||
'running_balance_column' => env('USE_RUNNING_BALANCE', false),
|
'running_balance_column' => env('USE_RUNNING_BALANCE', false),
|
||||||
// see cer.php for exchange rates feature flag.
|
// see cer.php for exchange rates feature flag.
|
||||||
],
|
],
|
||||||
'version' => 'develop/2025-06-01',
|
'version' => 'develop/2025-06-02',
|
||||||
'api_version' => '2.1.0', // field is no longer used.
|
'api_version' => '2.1.0', // field is no longer used.
|
||||||
'db_version' => 25,
|
'db_version' => 25,
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user