journal_id = $object->transaction_journal_id; $entry->description = Steam::decrypt(intval($object->journal_encrypted), $object->journal_description); $entry->amount = $object->amount; $entry->date = $object->date; $entry->transaction_type = $object->transaction_type; $entry->currency_code = $object->transaction_currency_code; $entry->asset_account_id = $object->account_id; $entry->asset_account_name = Steam::decrypt(intval($object->account_name_encrypted), $object->account_name); $entry->opposing_account_id = $object->opposing_account_id; $entry->opposing_account_name = Steam::decrypt(intval($object->opposing_account_encrypted), $object->opposing_account_name); $entry->category_id = $object->category_id ?? ''; $entry->category_name = $object->category_name ?? ''; $entry->budget_id = $object->budget_id ?? ''; $entry->budget_name = $object->budget_name ?? ''; // update description when transaction description is different: if (!is_null($object->description) && $object->description !== $entry->description) { $entry->description = $entry->description . ' (' . $object->description . ')'; } return $entry; } /** * Converts a given transaction (as collected by the collector) into an export entry. * * @param Transaction $transaction * * @return Entry */ public static function fromTransaction(Transaction $transaction): Entry { $entry = new self; $entry->journal_id = $transaction->journal_id; $entry->transaction_id = $transaction->id; $entry->date = $transaction->date->format('Ymd'); $entry->description = $transaction->description; if (strlen(strval($transaction->transaction_description)) > 0) { $entry->description = $transaction->transaction_description . '(' . $transaction->description . ')'; } $entry->currency_code = $transaction->transactionCurrency->code; $entry->amount = round($transaction->transaction_amount, $transaction->transactionCurrency->decimal_places); $entry->foreign_currency_code = is_null($transaction->foreign_currency_id) ? null : $transaction->foreignCurrency->code; $entry->foreign_amount = is_null($transaction->foreign_currency_id) ? null : strval( round( $transaction->transaction_foreign_amount, $transaction->foreignCurrency->decimal_places ) ); $entry->transaction_type = $transaction->transaction_type_type; $entry->asset_account_id = $transaction->account_id; $entry->asset_account_name = app('steam')->tryDecrypt($transaction->account_name); $entry->asset_account_iban = $transaction->account_iban; $entry->asset_account_number = $transaction->account_number; $entry->asset_account_bic = $transaction->account_bic; $entry->asset_currency_code = $transaction->account_currency_code; $entry->opposing_account_id = $transaction->opposing_account_id; $entry->opposing_account_name = app('steam')->tryDecrypt($transaction->opposing_account_name); $entry->opposing_account_iban = $transaction->opposing_account_iban; $entry->opposing_account_number = $transaction->opposing_account_number; $entry->opposing_account_bic = $transaction->opposing_account_bic; $entry->opposing_currency_code = $transaction->opposing_currency_code; /** budget */ $entry->budget_id = $transaction->transaction_budget_id; $entry->budget_name = app('steam')->tryDecrypt($transaction->transaction_budget_name); if (is_null($transaction->transaction_budget_id)) { $entry->budget_id = $transaction->transaction_journal_budget_id; $entry->budget_name = app('steam')->tryDecrypt($transaction->transaction_journal_budget_name); } /** category */ $entry->category_id = $transaction->transaction_category_id; $entry->category_name = app('steam')->tryDecrypt($transaction->transaction_category_name); if (is_null($transaction->transaction_category_id)) { $entry->category_id = $transaction->transaction_journal_category_id; $entry->category_name = app('steam')->tryDecrypt($transaction->transaction_journal_category_name); } /** budget */ $entry->bill_id = $transaction->bill_id; $entry->bill_name = app('steam')->tryDecrypt($transaction->bill_name); $entry->tags = $transaction->tags; $entry->notes = $transaction->notes; return $entry; } }