mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-19 02:52:44 +00:00
Clean up various code.
This commit is contained in:
14
.ci/php-cs-fixer/composer.lock
generated
14
.ci/php-cs-fixer/composer.lock
generated
@@ -470,16 +470,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/diff",
|
"name": "sebastian/diff",
|
||||||
"version": "5.0.3",
|
"version": "5.1.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/diff.git",
|
"url": "https://github.com/sebastianbergmann/diff.git",
|
||||||
"reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b"
|
"reference": "fbf413a49e54f6b9b17e12d900ac7f6101591b7f"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/912dc2fbe3e3c1e7873313cc801b100b6c68c87b",
|
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/fbf413a49e54f6b9b17e12d900ac7f6101591b7f",
|
||||||
"reference": "912dc2fbe3e3c1e7873313cc801b100b6c68c87b",
|
"reference": "fbf413a49e54f6b9b17e12d900ac7f6101591b7f",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@@ -492,7 +492,7 @@
|
|||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-main": "5.0-dev"
|
"dev-main": "5.1-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@@ -525,7 +525,7 @@
|
|||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/sebastianbergmann/diff/issues",
|
"issues": "https://github.com/sebastianbergmann/diff/issues",
|
||||||
"security": "https://github.com/sebastianbergmann/diff/security/policy",
|
"security": "https://github.com/sebastianbergmann/diff/security/policy",
|
||||||
"source": "https://github.com/sebastianbergmann/diff/tree/5.0.3"
|
"source": "https://github.com/sebastianbergmann/diff/tree/5.1.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@@ -533,7 +533,7 @@
|
|||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-05-01T07:48:21+00:00"
|
"time": "2023-12-22T10:55:06+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/console",
|
"name": "symfony/console",
|
||||||
|
@@ -70,8 +70,8 @@
|
|||||||
</rule>
|
</rule>
|
||||||
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength">
|
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength">
|
||||||
<properties>
|
<properties>
|
||||||
<!-- TODO we want to be at a value of 40. But we start high, and drop the bar slowly. -->
|
<!-- 75 seems like a nice number. Shorter isn't always feasible and there are a few exceptions already -->
|
||||||
<property name="minimum" value="100"/>
|
<property name="minimum" value="75"/>
|
||||||
<property name="ignore-whitespace" value="true"/>
|
<property name="ignore-whitespace" value="true"/>
|
||||||
</properties>
|
</properties>
|
||||||
</rule>
|
</rule>
|
||||||
|
@@ -146,13 +146,7 @@ class BasicController extends Controller
|
|||||||
// collect income of user using the new group collector.
|
// collect income of user using the new group collector.
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector
|
$collector->setRange($start, $end)->setPage($this->parameters->get('page'))->setTypes([TransactionType::DEPOSIT]);
|
||||||
->setRange($start, $end)
|
|
||||||
// set page to retrieve
|
|
||||||
->setPage($this->parameters->get('page'))
|
|
||||||
// set types of transactions to return.
|
|
||||||
->setTypes([TransactionType::DEPOSIT])
|
|
||||||
;
|
|
||||||
|
|
||||||
$set = $collector->getExtractedJournals();
|
$set = $collector->getExtractedJournals();
|
||||||
|
|
||||||
@@ -171,13 +165,7 @@ class BasicController extends Controller
|
|||||||
// collect expenses of user using the new group collector.
|
// collect expenses of user using the new group collector.
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
$collector
|
$collector->setRange($start, $end)->setPage($this->parameters->get('page'))->setTypes([TransactionType::WITHDRAWAL]);
|
||||||
->setRange($start, $end)
|
|
||||||
// set page to retrieve
|
|
||||||
->setPage($this->parameters->get('page'))
|
|
||||||
// set types of transactions to return.
|
|
||||||
->setTypes([TransactionType::WITHDRAWAL])
|
|
||||||
;
|
|
||||||
$set = $collector->getExtractedJournals();
|
$set = $collector->getExtractedJournals();
|
||||||
|
|
||||||
/** @var array $transactionJournal */
|
/** @var array $transactionJournal */
|
||||||
|
@@ -62,74 +62,14 @@ class UpdateRequest extends FormRequest
|
|||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
app('log')->debug(sprintf('Now in %s', __METHOD__));
|
||||||
$this->integerFields = [
|
$this->integerFields = ['order', 'currency_id', 'foreign_currency_id', 'transaction_journal_id', 'source_id', 'destination_id', 'budget_id', 'category_id', 'bill_id', 'recurrence_id'];
|
||||||
'order',
|
$this->dateFields = ['date', 'interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'invoice_date'];
|
||||||
'currency_id',
|
$this->textareaFields = ['notes'];
|
||||||
'foreign_currency_id',
|
// not really floats, for validation.
|
||||||
'transaction_journal_id',
|
$this->floatFields = ['amount', 'foreign_amount'];
|
||||||
'source_id',
|
$this->stringFields = ['type', 'currency_code', 'foreign_currency_code', 'description', 'source_name', 'source_iban', 'source_number', 'source_bic', 'destination_name', 'destination_iban', 'destination_number', 'destination_bic', 'budget_name', 'category_name', 'bill_name', 'internal_reference', 'external_id', 'bunq_payment_id', 'sepa_cc', 'sepa_ct_op', 'sepa_ct_id', 'sepa_db', 'sepa_country', 'sepa_ep', 'sepa_ci', 'sepa_batch_id', 'external_url'];
|
||||||
'destination_id',
|
$this->booleanFields = ['reconciled'];
|
||||||
'budget_id',
|
$this->arrayFields = ['tags'];
|
||||||
'category_id',
|
|
||||||
'bill_id',
|
|
||||||
'recurrence_id',
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->dateFields = [
|
|
||||||
'date',
|
|
||||||
'interest_date',
|
|
||||||
'book_date',
|
|
||||||
'process_date',
|
|
||||||
'due_date',
|
|
||||||
'payment_date',
|
|
||||||
'invoice_date',
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->textareaFields = [
|
|
||||||
'notes',
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->floatFields = [ // not really floats, for validation.
|
|
||||||
'amount',
|
|
||||||
'foreign_amount',
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->stringFields = [
|
|
||||||
'type',
|
|
||||||
'currency_code',
|
|
||||||
'foreign_currency_code',
|
|
||||||
'description',
|
|
||||||
'source_name',
|
|
||||||
'source_iban',
|
|
||||||
'source_number',
|
|
||||||
'source_bic',
|
|
||||||
'destination_name',
|
|
||||||
'destination_iban',
|
|
||||||
'destination_number',
|
|
||||||
'destination_bic',
|
|
||||||
'budget_name',
|
|
||||||
'category_name',
|
|
||||||
'bill_name',
|
|
||||||
'internal_reference',
|
|
||||||
'external_id',
|
|
||||||
'bunq_payment_id',
|
|
||||||
'sepa_cc',
|
|
||||||
'sepa_ct_op',
|
|
||||||
'sepa_ct_id',
|
|
||||||
'sepa_db',
|
|
||||||
'sepa_country',
|
|
||||||
'sepa_ep',
|
|
||||||
'sepa_ci',
|
|
||||||
'sepa_batch_id',
|
|
||||||
'external_url',
|
|
||||||
];
|
|
||||||
$this->booleanFields = [
|
|
||||||
'reconciled',
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->arrayFields = [
|
|
||||||
'tags',
|
|
||||||
];
|
|
||||||
$data = [];
|
$data = [];
|
||||||
if ($this->has('transactions')) {
|
if ($this->has('transactions')) {
|
||||||
$data['transactions'] = $this->getTransactionData();
|
$data['transactions'] = $this->getTransactionData();
|
||||||
|
@@ -240,7 +240,7 @@ class BasicController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \Exception
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
private function getLeftToSpendInfo(Carbon $start, Carbon $end): array
|
private function getLeftToSpendInfo(Carbon $start, Carbon $end): array
|
||||||
{
|
{
|
||||||
|
@@ -47,64 +47,7 @@ class FixPostgresSequences extends Command
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
$this->friendlyLine('Going to verify PostgreSQL table sequences.');
|
$this->friendlyLine('Going to verify PostgreSQL table sequences.');
|
||||||
$tablesToCheck = [
|
$tablesToCheck = ['2fa_tokens', 'account_meta', 'account_types', 'accounts', 'attachments', 'auto_budgets', 'available_budgets', 'bills', 'budget_limits', 'budget_transaction', 'budget_transaction_journal', 'budgets', 'categories', 'category_transaction', 'category_transaction_journal', 'configuration', 'currency_exchange_rates', 'failed_jobs', 'group_journals', 'jobs', 'journal_links', 'journal_meta', 'limit_repetitions', 'link_types', 'locations', 'migrations', 'notes', 'oauth_clients', 'oauth_personal_access_clients', 'object_groups', 'permissions', 'piggy_bank_events', 'piggy_bank_repetitions', 'piggy_banks', 'preferences', 'recurrences', 'recurrences_meta', 'recurrences_repetitions', 'recurrences_transactions', 'roles', 'rt_meta', 'rule_actions', 'rule_groups', 'rule_triggers', 'rules', 'tag_transaction_journal', 'tags', 'transaction_currencies', 'transaction_groups', 'transaction_journals', 'transaction_types', 'transactions', 'users', 'webhook_attempts', 'webhook_messages', 'webhooks'];
|
||||||
'2fa_tokens',
|
|
||||||
'account_meta',
|
|
||||||
'account_types',
|
|
||||||
'accounts',
|
|
||||||
'attachments',
|
|
||||||
'auto_budgets',
|
|
||||||
'available_budgets',
|
|
||||||
'bills',
|
|
||||||
'budget_limits',
|
|
||||||
'budget_transaction',
|
|
||||||
'budget_transaction_journal',
|
|
||||||
'budgets',
|
|
||||||
'categories',
|
|
||||||
'category_transaction',
|
|
||||||
'category_transaction_journal',
|
|
||||||
'configuration',
|
|
||||||
'currency_exchange_rates',
|
|
||||||
'failed_jobs',
|
|
||||||
'group_journals',
|
|
||||||
'jobs',
|
|
||||||
'journal_links',
|
|
||||||
'journal_meta',
|
|
||||||
'limit_repetitions',
|
|
||||||
'link_types',
|
|
||||||
'locations',
|
|
||||||
'migrations',
|
|
||||||
'notes',
|
|
||||||
'oauth_clients',
|
|
||||||
'oauth_personal_access_clients',
|
|
||||||
'object_groups',
|
|
||||||
'permissions',
|
|
||||||
'piggy_bank_events',
|
|
||||||
'piggy_bank_repetitions',
|
|
||||||
'piggy_banks',
|
|
||||||
'preferences',
|
|
||||||
'recurrences',
|
|
||||||
'recurrences_meta',
|
|
||||||
'recurrences_repetitions',
|
|
||||||
'recurrences_transactions',
|
|
||||||
'roles',
|
|
||||||
'rt_meta',
|
|
||||||
'rule_actions',
|
|
||||||
'rule_groups',
|
|
||||||
'rule_triggers',
|
|
||||||
'rules',
|
|
||||||
'tag_transaction_journal',
|
|
||||||
'tags',
|
|
||||||
'transaction_currencies',
|
|
||||||
'transaction_groups',
|
|
||||||
'transaction_journals',
|
|
||||||
'transaction_types',
|
|
||||||
'transactions',
|
|
||||||
'users',
|
|
||||||
'webhook_attempts',
|
|
||||||
'webhook_messages',
|
|
||||||
'webhooks',
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($tablesToCheck as $tableToCheck) {
|
foreach ($tablesToCheck as $tableToCheck) {
|
||||||
$this->friendlyLine(sprintf('Checking the next id sequence for table "%s".', $tableToCheck));
|
$this->friendlyLine(sprintf('Checking the next id sequence for table "%s".', $tableToCheck));
|
||||||
|
@@ -209,6 +209,9 @@ class MigrateToGroups extends Command
|
|||||||
return $set->first();
|
return $set->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
|
*/
|
||||||
private function generateTransaction(TransactionJournal $journal, Transaction $transaction): array
|
private function generateTransaction(TransactionJournal $journal, Transaction $transaction): array
|
||||||
{
|
{
|
||||||
app('log')->debug(sprintf('Now going to add transaction #%d to the array.', $transaction->id));
|
app('log')->debug(sprintf('Now going to add transaction #%d to the array.', $transaction->id));
|
||||||
|
@@ -182,9 +182,14 @@ class TransactionJournalFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* TODO typeOverrule: the account validator may have another opinion on the transaction type. not sure what to do
|
||||||
|
* with this.
|
||||||
|
*
|
||||||
* @throws DuplicateTransactionException
|
* @throws DuplicateTransactionException
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
* */
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
|
*/
|
||||||
private function createJournal(NullArrayObject $row): ?TransactionJournal
|
private function createJournal(NullArrayObject $row): ?TransactionJournal
|
||||||
{
|
{
|
||||||
$row['import_hash_v2'] = $this->hashArray($row);
|
$row['import_hash_v2'] = $this->hashArray($row);
|
||||||
@@ -214,9 +219,6 @@ class TransactionJournalFactory
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// typeOverrule: the account validator may have another opinion on the transaction type.
|
|
||||||
// not sure what to do with this.
|
|
||||||
|
|
||||||
/** create or get source and destination accounts */
|
/** create or get source and destination accounts */
|
||||||
$sourceInfo = [
|
$sourceInfo = [
|
||||||
'id' => $row['source_id'],
|
'id' => $row['source_id'],
|
||||||
@@ -237,9 +239,7 @@ class TransactionJournalFactory
|
|||||||
];
|
];
|
||||||
app('log')->debug('Source info:', $sourceInfo);
|
app('log')->debug('Source info:', $sourceInfo);
|
||||||
app('log')->debug('Destination info:', $destInfo);
|
app('log')->debug('Destination info:', $destInfo);
|
||||||
app('log')->debug('Now calling getAccount for the source.');
|
|
||||||
$sourceAccount = $this->getAccount($type->type, 'source', $sourceInfo);
|
$sourceAccount = $this->getAccount($type->type, 'source', $sourceInfo);
|
||||||
app('log')->debug('Now calling getAccount for the destination.');
|
|
||||||
$destinationAccount = $this->getAccount($type->type, 'destination', $destInfo);
|
$destinationAccount = $this->getAccount($type->type, 'destination', $destInfo);
|
||||||
app('log')->debug('Done with getAccount(2x)');
|
app('log')->debug('Done with getAccount(2x)');
|
||||||
|
|
||||||
@@ -285,15 +285,12 @@ class TransactionJournalFactory
|
|||||||
try {
|
try {
|
||||||
$negative = $transactionFactory->createNegative((string) $row['amount'], (string) $row['foreign_amount']);
|
$negative = $transactionFactory->createNegative((string) $row['amount'], (string) $row['foreign_amount']);
|
||||||
} catch (FireflyException $e) {
|
} catch (FireflyException $e) {
|
||||||
app('log')->error('Exception creating negative transaction.');
|
app('log')->error(sprintf('Exception creating negative transaction: %s', $e->getMessage()));
|
||||||
app('log')->error($e->getMessage());
|
|
||||||
app('log')->error($e->getTraceAsString());
|
|
||||||
$this->forceDeleteOnError(new Collection([$journal]));
|
$this->forceDeleteOnError(new Collection([$journal]));
|
||||||
|
|
||||||
throw new FireflyException($e->getMessage(), 0, $e);
|
throw new FireflyException($e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// and the destination one:
|
|
||||||
/** @var TransactionFactory $transactionFactory */
|
/** @var TransactionFactory $transactionFactory */
|
||||||
$transactionFactory = app(TransactionFactory::class);
|
$transactionFactory = app(TransactionFactory::class);
|
||||||
$transactionFactory->setUser($this->user);
|
$transactionFactory->setUser($this->user);
|
||||||
@@ -307,37 +304,19 @@ class TransactionJournalFactory
|
|||||||
try {
|
try {
|
||||||
$transactionFactory->createPositive((string) $row['amount'], (string) $row['foreign_amount']);
|
$transactionFactory->createPositive((string) $row['amount'], (string) $row['foreign_amount']);
|
||||||
} catch (FireflyException $e) {
|
} catch (FireflyException $e) {
|
||||||
app('log')->error('Exception creating positive transaction.');
|
app('log')->error(sprintf('Exception creating positive transaction: %s', $e->getMessage()));
|
||||||
app('log')->error($e->getMessage());
|
|
||||||
app('log')->error($e->getTraceAsString());
|
|
||||||
app('log')->warning('Delete negative transaction.');
|
|
||||||
$this->forceTrDelete($negative);
|
$this->forceTrDelete($negative);
|
||||||
$this->forceDeleteOnError(new Collection([$journal]));
|
$this->forceDeleteOnError(new Collection([$journal]));
|
||||||
|
|
||||||
throw new FireflyException($e->getMessage(), 0, $e);
|
throw new FireflyException($e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
// verify that journal has two transactions. Otherwise, delete and cancel.
|
|
||||||
$journal->completed = true;
|
$journal->completed = true;
|
||||||
$journal->save();
|
$journal->save();
|
||||||
|
|
||||||
// Link all other data to the journal.
|
|
||||||
|
|
||||||
// Link budget
|
|
||||||
$this->storeBudget($journal, $row);
|
$this->storeBudget($journal, $row);
|
||||||
|
|
||||||
// Link category
|
|
||||||
$this->storeCategory($journal, $row);
|
$this->storeCategory($journal, $row);
|
||||||
|
|
||||||
// Set notes
|
|
||||||
$this->storeNotes($journal, $row['notes']);
|
$this->storeNotes($journal, $row['notes']);
|
||||||
|
|
||||||
// Set piggy bank
|
|
||||||
$this->storePiggyEvent($journal, $row);
|
$this->storePiggyEvent($journal, $row);
|
||||||
|
|
||||||
// Set tags
|
|
||||||
$this->storeTags($journal, $row['tags']);
|
$this->storeTags($journal, $row['tags']);
|
||||||
|
|
||||||
// set all meta fields
|
|
||||||
$this->storeMetaFields($journal, $row);
|
$this->storeMetaFields($journal, $row);
|
||||||
|
|
||||||
return $journal;
|
return $journal;
|
||||||
@@ -348,7 +327,13 @@ class TransactionJournalFactory
|
|||||||
$dataRow = $row->getArrayCopy();
|
$dataRow = $row->getArrayCopy();
|
||||||
|
|
||||||
unset($dataRow['import_hash_v2'], $dataRow['original_source']);
|
unset($dataRow['import_hash_v2'], $dataRow['original_source']);
|
||||||
|
|
||||||
|
try {
|
||||||
$json = json_encode($dataRow, JSON_THROW_ON_ERROR);
|
$json = json_encode($dataRow, JSON_THROW_ON_ERROR);
|
||||||
|
} catch (\JsonException $e) {
|
||||||
|
app('log')->error(sprintf('Could not encode dataRow: %s', $e->getMessage()));
|
||||||
|
$json = microtime();
|
||||||
|
}
|
||||||
$hash = hash('sha256', $json);
|
$hash = hash('sha256', $json);
|
||||||
app('log')->debug(sprintf('The hash is: %s', $hash), $dataRow);
|
app('log')->debug(sprintf('The hash is: %s', $hash), $dataRow);
|
||||||
|
|
||||||
|
@@ -152,22 +152,7 @@ class EditController extends Controller
|
|||||||
|
|
||||||
$request->session()->flash('preFilled', $preFilled);
|
$request->session()->flash('preFilled', $preFilled);
|
||||||
|
|
||||||
return view(
|
return view('accounts.edit', compact('account', 'currency', 'subTitle', 'subTitleIcon', 'locations', 'liabilityDirections', 'objectType', 'roles', 'preFilled', 'liabilityTypes', 'interestPeriods'));
|
||||||
'accounts.edit',
|
|
||||||
compact(
|
|
||||||
'account',
|
|
||||||
'currency',
|
|
||||||
'subTitle',
|
|
||||||
'subTitleIcon',
|
|
||||||
'locations',
|
|
||||||
'liabilityDirections',
|
|
||||||
'objectType',
|
|
||||||
'roles',
|
|
||||||
'preFilled',
|
|
||||||
'liabilityTypes',
|
|
||||||
'interestPeriods'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -44,11 +44,8 @@ class ExpenseReportController extends Controller
|
|||||||
use AugumentData;
|
use AugumentData;
|
||||||
use TransactionCalculation;
|
use TransactionCalculation;
|
||||||
|
|
||||||
/** @var AccountRepositoryInterface The account repository */
|
protected AccountRepositoryInterface $accountRepository;
|
||||||
protected $accountRepository;
|
protected GeneratorInterface $generator;
|
||||||
|
|
||||||
/** @var GeneratorInterface Chart generation methods. */
|
|
||||||
protected $generator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ExpenseReportController constructor.
|
* ExpenseReportController constructor.
|
||||||
@@ -71,7 +68,8 @@ class ExpenseReportController extends Controller
|
|||||||
*
|
*
|
||||||
* TODO this chart is not multi currency aware.
|
* TODO this chart is not multi currency aware.
|
||||||
*
|
*
|
||||||
* */
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
|
*/
|
||||||
public function mainChart(Collection $accounts, Collection $expense, Carbon $start, Carbon $end): JsonResponse
|
public function mainChart(Collection $accounts, Collection $expense, Carbon $start, Carbon $end): JsonResponse
|
||||||
{
|
{
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
@@ -89,9 +87,8 @@ class ExpenseReportController extends Controller
|
|||||||
$chartData = [];
|
$chartData = [];
|
||||||
$currentStart = clone $start;
|
$currentStart = clone $start;
|
||||||
$combined = $this->combineAccounts($expense);
|
$combined = $this->combineAccounts($expense);
|
||||||
// make "all" set:
|
|
||||||
$all = new Collection();
|
$all = new Collection();
|
||||||
foreach ($combined as $name => $combination) {
|
foreach ($combined as $combination) {
|
||||||
$all = $all->merge($combination);
|
$all = $all->merge($combination);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,8 +45,7 @@ class ReportController extends Controller
|
|||||||
use BasicDataSupport;
|
use BasicDataSupport;
|
||||||
use ChartGeneration;
|
use ChartGeneration;
|
||||||
|
|
||||||
/** @var GeneratorInterface Chart generation methods. */
|
protected GeneratorInterface $generator;
|
||||||
protected $generator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ReportController constructor.
|
* ReportController constructor.
|
||||||
@@ -133,7 +132,8 @@ class ReportController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Shows income and expense, debit/credit: operations.
|
* Shows income and expense, debit/credit: operations.
|
||||||
*
|
*
|
||||||
* */
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
|
*/
|
||||||
public function operations(Collection $accounts, Carbon $start, Carbon $end): JsonResponse
|
public function operations(Collection $accounts, Carbon $start, Carbon $end): JsonResponse
|
||||||
{
|
{
|
||||||
// chart properties for cache:
|
// chart properties for cache:
|
||||||
@@ -150,11 +150,8 @@ class ReportController extends Controller
|
|||||||
$titleFormat = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
|
$titleFormat = app('navigation')->preferredCarbonLocalizedFormat($start, $end);
|
||||||
$preferredRange = app('navigation')->preferredRangeFormat($start, $end);
|
$preferredRange = app('navigation')->preferredRangeFormat($start, $end);
|
||||||
$ids = $accounts->pluck('id')->toArray();
|
$ids = $accounts->pluck('id')->toArray();
|
||||||
|
|
||||||
// get journals for entire period:
|
|
||||||
$data = [];
|
$data = [];
|
||||||
$chartData = [
|
$chartData = [];
|
||||||
];
|
|
||||||
|
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
$collector = app(GroupCollectorInterface::class);
|
$collector = app(GroupCollectorInterface::class);
|
||||||
@@ -186,18 +183,7 @@ class ReportController extends Controller
|
|||||||
|
|
||||||
// deposit = incoming
|
// deposit = incoming
|
||||||
// transfer or reconcile or opening balance, and these accounts are the destination.
|
// transfer or reconcile or opening balance, and these accounts are the destination.
|
||||||
if (
|
if (TransactionType::DEPOSIT === $journal['transaction_type_type'] || ((TransactionType::TRANSFER === $journal['transaction_type_type'] || TransactionType::RECONCILIATION === $journal['transaction_type_type'] || TransactionType::OPENING_BALANCE === $journal['transaction_type_type']) && in_array($journal['destination_account_id'], $ids, true))) {
|
||||||
TransactionType::DEPOSIT === $journal['transaction_type_type']
|
|
||||||
|
|
||||||
|| (
|
|
||||||
(
|
|
||||||
TransactionType::TRANSFER === $journal['transaction_type_type']
|
|
||||||
|| TransactionType::RECONCILIATION === $journal['transaction_type_type']
|
|
||||||
|| TransactionType::OPENING_BALANCE === $journal['transaction_type_type']
|
|
||||||
)
|
|
||||||
&& in_array($journal['destination_account_id'], $ids, true)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
$key = 'earned';
|
$key = 'earned';
|
||||||
}
|
}
|
||||||
$data[$currencyId][$period][$key] = bcadd($data[$currencyId][$period][$key], $amount);
|
$data[$currencyId][$period][$key] = bcadd($data[$currencyId][$period][$key], $amount);
|
||||||
|
@@ -48,6 +48,8 @@ class BoxController extends Controller
|
|||||||
* 0) If the user has available amount this period and has overspent: overspent box.
|
* 0) If the user has available amount this period and has overspent: overspent box.
|
||||||
* 1) If the user has available amount this period and has NOT overspent: left to spend box.
|
* 1) If the user has available amount this period and has NOT overspent: left to spend box.
|
||||||
* 2) if the user has no available amount set this period: spent per day
|
* 2) if the user has no available amount set this period: spent per day
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
public function available(): JsonResponse
|
public function available(): JsonResponse
|
||||||
{
|
{
|
||||||
|
@@ -68,8 +68,6 @@ class PreferencesController extends Controller
|
|||||||
{
|
{
|
||||||
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
|
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE]);
|
||||||
$isDocker = env('IS_DOCKER', false);
|
$isDocker = env('IS_DOCKER', false);
|
||||||
|
|
||||||
// group accounts
|
|
||||||
$groupedAccounts = [];
|
$groupedAccounts = [];
|
||||||
|
|
||||||
/** @var Account $account */
|
/** @var Account $account */
|
||||||
@@ -141,27 +139,7 @@ class PreferencesController extends Controller
|
|||||||
$slackUrl = '';
|
$slackUrl = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return view(
|
return view('preferences.index', compact('language', 'groupedAccounts', 'isDocker', 'frontPageAccounts', 'languages', 'darkMode', 'availableDarkModes', 'notifications', 'slackUrl', 'locales', 'locale', 'tjOptionalFields', 'viewRange', 'customFiscalYear', 'listPageSize', 'fiscalYearStart'));
|
||||||
'preferences.index',
|
|
||||||
compact(
|
|
||||||
'language',
|
|
||||||
'groupedAccounts',
|
|
||||||
'isDocker',
|
|
||||||
'frontPageAccounts',
|
|
||||||
'languages',
|
|
||||||
'darkMode',
|
|
||||||
'availableDarkModes',
|
|
||||||
'notifications',
|
|
||||||
'slackUrl',
|
|
||||||
'locales',
|
|
||||||
'locale',
|
|
||||||
'tjOptionalFields',
|
|
||||||
'viewRange',
|
|
||||||
'customFiscalYear',
|
|
||||||
'listPageSize',
|
|
||||||
'fiscalYearStart'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -170,6 +148,8 @@ class PreferencesController extends Controller
|
|||||||
* @return Redirector|RedirectResponse
|
* @return Redirector|RedirectResponse
|
||||||
*
|
*
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
public function postIndex(Request $request)
|
public function postIndex(Request $request)
|
||||||
{
|
{
|
||||||
|
@@ -120,6 +120,8 @@ class CreateController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Factory|\Illuminate\Contracts\View\View
|
* @return Factory|\Illuminate\Contracts\View\View
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
public function createFromJournal(Request $request, TransactionJournal $journal)
|
public function createFromJournal(Request $request, TransactionJournal $journal)
|
||||||
{
|
{
|
||||||
|
@@ -155,6 +155,8 @@ class CategoryController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Factory|View
|
* @return Factory|View
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
public function accounts(Collection $accounts, Collection $categories, Carbon $start, Carbon $end)
|
public function accounts(Collection $accounts, Collection $categories, Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
@@ -355,6 +357,8 @@ class CategoryController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Factory|View
|
* @return Factory|View
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
public function categories(Collection $accounts, Collection $categories, Carbon $start, Carbon $end)
|
public function categories(Collection $accounts, Collection $categories, Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
|
@@ -41,11 +41,8 @@ class DoubleController extends Controller
|
|||||||
{
|
{
|
||||||
use AugumentData;
|
use AugumentData;
|
||||||
|
|
||||||
/** @var AccountRepositoryInterface The account repository */
|
protected AccountRepositoryInterface $accountRepository;
|
||||||
protected $accountRepository;
|
private OperationsRepositoryInterface $opsRepository;
|
||||||
|
|
||||||
/** @var OperationsRepositoryInterface */
|
|
||||||
private $opsRepository;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for ExpenseController
|
* Constructor for ExpenseController
|
||||||
@@ -167,6 +164,8 @@ class DoubleController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Factory|View
|
* @return Factory|View
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
public function operations(Collection $accounts, Collection $double, Carbon $start, Carbon $end)
|
public function operations(Collection $accounts, Collection $double, Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
|
@@ -147,6 +147,8 @@ class TagController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Factory|View
|
* @return Factory|View
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
public function accounts(Collection $accounts, Collection $tags, Carbon $start, Carbon $end)
|
public function accounts(Collection $accounts, Collection $tags, Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
@@ -347,6 +349,8 @@ class TagController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Factory|View
|
* @return Factory|View
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
public function tags(Collection $accounts, Collection $tags, Carbon $start, Carbon $end)
|
public function tags(Collection $accounts, Collection $tags, Carbon $start, Carbon $end)
|
||||||
{
|
{
|
||||||
|
@@ -47,6 +47,8 @@ class RecurrenceFormRequest extends FormRequest
|
|||||||
* Get the data required by the controller.
|
* Get the data required by the controller.
|
||||||
*
|
*
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
public function getAll(): array
|
public function getAll(): array
|
||||||
{
|
{
|
||||||
|
@@ -54,6 +54,8 @@ class BudgetServiceProvider extends ServiceProvider
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Register the application services.
|
* Register the application services.
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
public function register(): void
|
public function register(): void
|
||||||
{
|
{
|
||||||
|
@@ -181,7 +181,6 @@ class CreditRecalculateService
|
|||||||
}
|
}
|
||||||
$startOfDebt = $this->repository->getOpeningBalanceAmount($account) ?? '0';
|
$startOfDebt = $this->repository->getOpeningBalanceAmount($account) ?? '0';
|
||||||
$leftOfDebt = app('steam')->positive($startOfDebt);
|
$leftOfDebt = app('steam')->positive($startOfDebt);
|
||||||
$currency = $this->repository->getAccountCurrency($account);
|
|
||||||
app('log')->debug(sprintf('Start of debt is "%s", so initial left of debt is "%s"', app('steam')->bcround($startOfDebt, 2), app('steam')->bcround($leftOfDebt, 2)));
|
app('log')->debug(sprintf('Start of debt is "%s", so initial left of debt is "%s"', app('steam')->bcround($startOfDebt, 2), app('steam')->bcround($leftOfDebt, 2)));
|
||||||
|
|
||||||
/** @var AccountMetaFactory $factory */
|
/** @var AccountMetaFactory $factory */
|
||||||
@@ -243,6 +242,9 @@ class CreditRecalculateService
|
|||||||
app('log')->debug('Opening balance is valid');
|
app('log')->debug('Opening balance is valid');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
|
*/
|
||||||
private function processTransaction(Account $account, string $direction, Transaction $transaction, string $leftOfDebt): string
|
private function processTransaction(Account $account, string $direction, Transaction $transaction, string $leftOfDebt): string
|
||||||
{
|
{
|
||||||
$journal = $transaction->transactionJournal;
|
$journal = $transaction->transactionJournal;
|
||||||
|
@@ -44,6 +44,11 @@ class StandardWebhookSender implements WebhookSenderInterface
|
|||||||
return $this->version;
|
return $this->version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
|
*/
|
||||||
public function send(): void
|
public function send(): void
|
||||||
{
|
{
|
||||||
// have the signature generator generate a signature. If it fails, the error thrown will
|
// have the signature generator generate a signature. If it fails, the error thrown will
|
||||||
|
@@ -92,9 +92,6 @@ class Amount
|
|||||||
return $user->currencies()->orderBy('code', 'ASC')->get();
|
return $user->currencies()->orderBy('code', 'ASC')->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws FireflyException
|
|
||||||
*/
|
|
||||||
public function getDefaultCurrency(): TransactionCurrency
|
public function getDefaultCurrency(): TransactionCurrency
|
||||||
{
|
{
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
|
@@ -577,39 +577,12 @@ class ExportDataGenerator
|
|||||||
$recurringRepos->setUser($this->user);
|
$recurringRepos->setUser($this->user);
|
||||||
$header = [
|
$header = [
|
||||||
// recurrence:
|
// recurrence:
|
||||||
'user_id',
|
'user_id', 'recurrence_id', 'row_contains', 'created_at', 'updated_at', 'type', 'title', 'description', 'first_date', 'repeat_until', 'latest_date', 'repetitions', 'apply_rules', 'active',
|
||||||
'recurrence_id',
|
|
||||||
'row_contains',
|
|
||||||
'created_at',
|
|
||||||
'updated_at',
|
|
||||||
'type',
|
|
||||||
'title',
|
|
||||||
'description',
|
|
||||||
'first_date',
|
|
||||||
'repeat_until',
|
|
||||||
'latest_date',
|
|
||||||
'repetitions',
|
|
||||||
'apply_rules',
|
|
||||||
'active',
|
|
||||||
|
|
||||||
// repetition info:
|
// repetition info:
|
||||||
'type',
|
'type', 'moment', 'skip', 'weekend',
|
||||||
'moment',
|
|
||||||
'skip',
|
|
||||||
'weekend',
|
|
||||||
// transactions + meta:
|
// transactions + meta:
|
||||||
'currency_code',
|
'currency_code', 'foreign_currency_code', 'source_name', 'source_type', 'destination_name', 'destination_type', 'amount', 'foreign_amount', 'category', 'budget', 'piggy_bank', 'tags',
|
||||||
'foreign_currency_code',
|
|
||||||
'source_name',
|
|
||||||
'source_type',
|
|
||||||
'destination_name',
|
|
||||||
'destination_type',
|
|
||||||
'amount',
|
|
||||||
'foreign_amount',
|
|
||||||
'category',
|
|
||||||
'budget',
|
|
||||||
'piggy_bank',
|
|
||||||
'tags',
|
|
||||||
];
|
];
|
||||||
$records = [];
|
$records = [];
|
||||||
$recurrences = $recurringRepos->getAll();
|
$recurrences = $recurringRepos->getAll();
|
||||||
@@ -618,20 +591,9 @@ class ExportDataGenerator
|
|||||||
foreach ($recurrences as $recurrence) {
|
foreach ($recurrences as $recurrence) {
|
||||||
// add recurrence:
|
// add recurrence:
|
||||||
$records[] = [
|
$records[] = [
|
||||||
$this->user->id,
|
$this->user->id, $recurrence->id,
|
||||||
$recurrence->id,
|
|
||||||
'recurrence',
|
'recurrence',
|
||||||
$recurrence->created_at->toAtomString(),
|
$recurrence->created_at->toAtomString(), $recurrence->updated_at->toAtomString(), $recurrence->transactionType->type, $recurrence->title, $recurrence->description, $recurrence->first_date?->format('Y-m-d'), $recurrence->repeat_until?->format('Y-m-d'), $recurrence->latest_date?->format('Y-m-d'), $recurrence->repetitions, $recurrence->apply_rules, $recurrence->active,
|
||||||
$recurrence->updated_at->toAtomString(),
|
|
||||||
$recurrence->transactionType->type,
|
|
||||||
$recurrence->title,
|
|
||||||
$recurrence->description,
|
|
||||||
$recurrence->first_date?->format('Y-m-d'),
|
|
||||||
$recurrence->repeat_until?->format('Y-m-d'),
|
|
||||||
$recurrence->latest_date?->format('Y-m-d'),
|
|
||||||
$recurrence->repetitions,
|
|
||||||
$recurrence->apply_rules,
|
|
||||||
$recurrence->active,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// add new row for each repetition
|
// add new row for each repetition
|
||||||
@@ -642,23 +604,10 @@ class ExportDataGenerator
|
|||||||
$this->user->id,
|
$this->user->id,
|
||||||
$recurrence->id,
|
$recurrence->id,
|
||||||
'repetition',
|
'repetition',
|
||||||
null,
|
null, null, null, null, null, null, null, null, null, null, null,
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
|
|
||||||
// repetition:
|
// repetition:
|
||||||
$repetition->repetition_type,
|
$repetition->repetition_type, $repetition->repetition_moment, $repetition->repetition_skip, $repetition->weekend,
|
||||||
$repetition->repetition_moment,
|
|
||||||
$repetition->repetition_skip,
|
|
||||||
$repetition->weekend,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -674,37 +623,13 @@ class ExportDataGenerator
|
|||||||
$this->user->id,
|
$this->user->id,
|
||||||
$recurrence->id,
|
$recurrence->id,
|
||||||
'transaction',
|
'transaction',
|
||||||
null,
|
null, null, null, null, null, null, null, null, null, null, null,
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
|
|
||||||
// repetition:
|
// repetition:
|
||||||
null,
|
null, null, null, null,
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
|
|
||||||
// transaction:
|
// transaction:
|
||||||
$transaction->transactionCurrency->code,
|
$transaction->transactionCurrency->code, $transaction->foreignCurrency?->code, $transaction->sourceAccount->name, $transaction->sourceAccount->accountType->type, $transaction->destinationAccount->name, $transaction->destinationAccount->accountType->type, $transaction->amount, $transaction->foreign_amount, $categoryName, $budgetId, $piggyBankId, implode(',', $tags),
|
||||||
$transaction->foreignCurrency?->code,
|
|
||||||
$transaction->sourceAccount->name,
|
|
||||||
$transaction->sourceAccount->accountType->type,
|
|
||||||
$transaction->destinationAccount->name,
|
|
||||||
$transaction->destinationAccount->accountType->type,
|
|
||||||
$transaction->amount,
|
|
||||||
$transaction->foreign_amount,
|
|
||||||
$categoryName,
|
|
||||||
$budgetId,
|
|
||||||
$piggyBankId,
|
|
||||||
implode(',', $tags),
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -739,31 +664,7 @@ class ExportDataGenerator
|
|||||||
*/
|
*/
|
||||||
private function exportRules(): string
|
private function exportRules(): string
|
||||||
{
|
{
|
||||||
$header = [
|
$header = ['user_id', 'rule_id', 'row_contains', 'created_at', 'updated_at', 'group_id', 'title', 'description', 'order', 'active', 'stop_processing', 'strict', 'trigger_type', 'trigger_value', 'trigger_order', 'trigger_active', 'trigger_stop_processing', 'action_type', 'action_value', 'action_order', 'action_active', 'action_stop_processing'];
|
||||||
'user_id',
|
|
||||||
'rule_id',
|
|
||||||
'row_contains',
|
|
||||||
'created_at',
|
|
||||||
'updated_at',
|
|
||||||
'group_id',
|
|
||||||
'group_name',
|
|
||||||
'title',
|
|
||||||
'description',
|
|
||||||
'order',
|
|
||||||
'active',
|
|
||||||
'stop_processing',
|
|
||||||
'strict',
|
|
||||||
'trigger_type',
|
|
||||||
'trigger_value',
|
|
||||||
'trigger_order',
|
|
||||||
'trigger_active',
|
|
||||||
'trigger_stop_processing',
|
|
||||||
'action_type',
|
|
||||||
'action_value',
|
|
||||||
'action_order',
|
|
||||||
'action_active',
|
|
||||||
'action_stop_processing',
|
|
||||||
];
|
|
||||||
$ruleRepos = app(RuleRepositoryInterface::class);
|
$ruleRepos = app(RuleRepositoryInterface::class);
|
||||||
$ruleRepos->setUser($this->user);
|
$ruleRepos->setUser($this->user);
|
||||||
$rules = $ruleRepos->getAll();
|
$rules = $ruleRepos->getAll();
|
||||||
@@ -772,19 +673,9 @@ class ExportDataGenerator
|
|||||||
/** @var Rule $rule */
|
/** @var Rule $rule */
|
||||||
foreach ($rules as $rule) {
|
foreach ($rules as $rule) {
|
||||||
$records[] = [
|
$records[] = [
|
||||||
$this->user->id,
|
$this->user->id, $rule->id,
|
||||||
$rule->id,
|
|
||||||
'rule',
|
'rule',
|
||||||
$rule->created_at->toAtomString(),
|
$rule->created_at->toAtomString(), $rule->updated_at->toAtomString(), $rule->ruleGroup->id, $rule->ruleGroup->title, $rule->title, $rule->description, $rule->order, $rule->active, $rule->stop_processing, $rule->strict,
|
||||||
$rule->updated_at->toAtomString(),
|
|
||||||
$rule->ruleGroup->id,
|
|
||||||
$rule->ruleGroup->title,
|
|
||||||
$rule->title,
|
|
||||||
$rule->description,
|
|
||||||
$rule->order,
|
|
||||||
$rule->active,
|
|
||||||
$rule->stop_processing,
|
|
||||||
$rule->strict,
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var RuleTrigger $trigger */
|
/** @var RuleTrigger $trigger */
|
||||||
@@ -793,21 +684,8 @@ class ExportDataGenerator
|
|||||||
$this->user->id,
|
$this->user->id,
|
||||||
$rule->id,
|
$rule->id,
|
||||||
'trigger',
|
'trigger',
|
||||||
null,
|
null, null, null, null, null, null, null, null, null, null,
|
||||||
null,
|
$trigger->trigger_type, $trigger->trigger_value, $trigger->order, $trigger->active, $trigger->stop_processing,
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
$trigger->trigger_type,
|
|
||||||
$trigger->trigger_value,
|
|
||||||
$trigger->order,
|
|
||||||
$trigger->active,
|
|
||||||
$trigger->stop_processing,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -817,26 +695,8 @@ class ExportDataGenerator
|
|||||||
$this->user->id,
|
$this->user->id,
|
||||||
$rule->id,
|
$rule->id,
|
||||||
'action',
|
'action',
|
||||||
null,
|
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
|
||||||
null,
|
$action->action_type, $action->action_value, $action->order, $action->active, $action->stop_processing,
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
null,
|
|
||||||
$action->action_type,
|
|
||||||
$action->action_value,
|
|
||||||
$action->order,
|
|
||||||
$action->active,
|
|
||||||
$action->stop_processing,
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -927,34 +787,7 @@ class ExportDataGenerator
|
|||||||
private function exportTransactions(): string
|
private function exportTransactions(): string
|
||||||
{
|
{
|
||||||
// TODO better place for keys?
|
// TODO better place for keys?
|
||||||
$header = [
|
$header = ['user_id', 'group_id', 'journal_id', 'created_at', 'updated_at', 'group_title', 'type', 'amount', 'foreign_amount', 'currency_code', 'foreign_currency_code', 'description', 'date', 'source_name', 'source_iban', 'source_type', 'destination_name', 'destination_iban', 'destination_type', 'reconciled', 'category', 'budget', 'bill', 'tags', 'notes'];
|
||||||
'user_id',
|
|
||||||
'group_id',
|
|
||||||
'journal_id',
|
|
||||||
'created_at',
|
|
||||||
'updated_at',
|
|
||||||
'group_title',
|
|
||||||
'type',
|
|
||||||
'amount',
|
|
||||||
'foreign_amount',
|
|
||||||
'currency_code',
|
|
||||||
'foreign_currency_code',
|
|
||||||
'description',
|
|
||||||
'date',
|
|
||||||
'source_name',
|
|
||||||
'source_iban',
|
|
||||||
'source_type',
|
|
||||||
'destination_name',
|
|
||||||
'destination_iban',
|
|
||||||
'destination_type',
|
|
||||||
'reconciled',
|
|
||||||
'category',
|
|
||||||
'budget',
|
|
||||||
'bill',
|
|
||||||
'tags',
|
|
||||||
'notes',
|
|
||||||
// all optional meta fields:
|
|
||||||
];
|
|
||||||
|
|
||||||
$metaFields = config('firefly.journal_meta_fields');
|
$metaFields = config('firefly.journal_meta_fields');
|
||||||
$header = array_merge($header, $metaFields);
|
$header = array_merge($header, $metaFields);
|
||||||
@@ -980,65 +813,21 @@ class ExportDataGenerator
|
|||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
$metaData = $repository->getMetaFields($journal['transaction_journal_id'], $metaFields);
|
$metaData = $repository->getMetaFields($journal['transaction_journal_id'], $metaFields);
|
||||||
$records[] = [
|
$records[] = [
|
||||||
$journal['user_id'],
|
$journal['user_id'], $journal['transaction_group_id'], $journal['transaction_journal_id'], $journal['created_at']->toAtomString(), $journal['updated_at']->toAtomString(), $journal['transaction_group_title'], $journal['transaction_type_type'], $journal['amount'], $journal['foreign_amount'], $journal['currency_code'], $journal['foreign_currency_code'], $journal['description'], $journal['date']->toAtomString(), $journal['source_account_name'], $journal['source_account_iban'], $journal['source_account_type'], $journal['destination_account_name'], $journal['destination_account_iban'], $journal['destination_account_type'], $journal['reconciled'], $journal['category_name'], $journal['budget_name'], $journal['bill_name'],
|
||||||
$journal['transaction_group_id'],
|
|
||||||
$journal['transaction_journal_id'],
|
|
||||||
$journal['created_at']->toAtomString(),
|
|
||||||
$journal['updated_at']->toAtomString(),
|
|
||||||
$journal['transaction_group_title'],
|
|
||||||
$journal['transaction_type_type'],
|
|
||||||
$journal['amount'],
|
|
||||||
$journal['foreign_amount'],
|
|
||||||
$journal['currency_code'],
|
|
||||||
$journal['foreign_currency_code'],
|
|
||||||
$journal['description'],
|
|
||||||
$journal['date']->toAtomString(),
|
|
||||||
$journal['source_account_name'],
|
|
||||||
$journal['source_account_iban'],
|
|
||||||
$journal['source_account_type'],
|
|
||||||
$journal['destination_account_name'],
|
|
||||||
$journal['destination_account_iban'],
|
|
||||||
$journal['destination_account_type'],
|
|
||||||
$journal['reconciled'],
|
|
||||||
$journal['category_name'],
|
|
||||||
$journal['budget_name'],
|
|
||||||
$journal['bill_name'],
|
|
||||||
$this->mergeTags($journal['tags']),
|
$this->mergeTags($journal['tags']),
|
||||||
$this->clearStringKeepNewlines($journal['notes']),
|
$this->clearStringKeepNewlines($journal['notes']),
|
||||||
|
|
||||||
// export also the optional fields (ALL)
|
|
||||||
|
|
||||||
// sepa
|
// sepa
|
||||||
$metaData['sepa_cc'],
|
$metaData['sepa_cc'], $metaData['sepa_ct_op'], $metaData['sepa_ct_id'], $metaData['sepa_db'], $metaData['sepa_country'], $metaData['sepa_ep'], $metaData['sepa_ci'], $metaData['sepa_batch_id'], $metaData['external_url'],
|
||||||
$metaData['sepa_ct_op'],
|
|
||||||
$metaData['sepa_ct_id'],
|
|
||||||
$metaData['sepa_db'],
|
|
||||||
$metaData['sepa_country'],
|
|
||||||
$metaData['sepa_ep'],
|
|
||||||
$metaData['sepa_ci'],
|
|
||||||
$metaData['sepa_batch_id'],
|
|
||||||
$metaData['external_url'],
|
|
||||||
|
|
||||||
// dates
|
// dates
|
||||||
$metaData['interest_date'],
|
$metaData['interest_date'], $metaData['book_date'], $metaData['process_date'], $metaData['due_date'], $metaData['payment_date'], $metaData['invoice_date'],
|
||||||
$metaData['book_date'],
|
|
||||||
$metaData['process_date'],
|
|
||||||
$metaData['due_date'],
|
|
||||||
$metaData['payment_date'],
|
|
||||||
$metaData['invoice_date'],
|
|
||||||
|
|
||||||
// others
|
// others
|
||||||
$metaData['recurrence_id'],
|
$metaData['recurrence_id'], $metaData['internal_reference'], $metaData['bunq_payment_id'], $metaData['import_hash'], $metaData['import_hash_v2'], $metaData['external_id'], $metaData['original_source'],
|
||||||
$metaData['internal_reference'],
|
|
||||||
$metaData['bunq_payment_id'],
|
|
||||||
$metaData['import_hash'],
|
|
||||||
$metaData['import_hash_v2'],
|
|
||||||
$metaData['external_id'],
|
|
||||||
$metaData['original_source'],
|
|
||||||
|
|
||||||
// recurring transactions
|
// recurring transactions
|
||||||
$metaData['recurrence_total'],
|
$metaData['recurrence_total'], $metaData['recurrence_count'],
|
||||||
$metaData['recurrence_count'],
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -156,6 +156,8 @@ trait ModelInformation
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
private function getTriggersForJournal(TransactionJournal $journal): array
|
private function getTriggersForJournal(TransactionJournal $journal): array
|
||||||
{
|
{
|
||||||
|
@@ -215,6 +215,8 @@ class Steam
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
public function balanceInRangeConverted(Account $account, Carbon $start, Carbon $end, TransactionCurrency $native): array
|
public function balanceInRangeConverted(Account $account, Carbon $start, Carbon $end, TransactionCurrency $native): array
|
||||||
{
|
{
|
||||||
@@ -317,22 +319,36 @@ class Steam
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* selection of transactions
|
||||||
|
* 1: all normal transactions. No foreign currency info. In $currency. Need conversion.
|
||||||
|
* 2: all normal transactions. No foreign currency info. In $native. Need NO conversion.
|
||||||
|
* 3: all normal transactions. No foreign currency info. In neither currency. Need conversion.
|
||||||
|
* Then, select everything with foreign currency info:
|
||||||
|
* 4. All transactions with foreign currency info in $native. Normal currency value is ignored. Do not need
|
||||||
|
* conversion.
|
||||||
|
* 5. All transactions with foreign currency info NOT in $native, but currency info in $currency. Need conversion.
|
||||||
|
* 6. All transactions with foreign currency info NOT in $native, and currency info NOT in $currency. Need
|
||||||
|
* conversion.
|
||||||
|
*
|
||||||
* Gets balance at the end of current month by default. Returns the balance converted
|
* Gets balance at the end of current month by default. Returns the balance converted
|
||||||
* to the indicated currency ($native).
|
* to the indicated currency ($native).
|
||||||
*
|
*
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
public function balanceConverted(Account $account, Carbon $date, TransactionCurrency $native): string
|
public function balanceConverted(Account $account, Carbon $date, TransactionCurrency $native): string
|
||||||
{
|
{
|
||||||
// app('log')->debug(sprintf('Now in balanceConverted (%s) for account #%d, converting to %s', $date->format('Y-m-d'), $account->id, $native->code));
|
app('log')->debug(sprintf('Now in balanceConverted (%s) for account #%d, converting to %s', $date->format('Y-m-d'), $account->id, $native->code));
|
||||||
$cache = new CacheProperties();
|
$cache = new CacheProperties();
|
||||||
$cache->addProperty($account->id);
|
$cache->addProperty($account->id);
|
||||||
$cache->addProperty('balance');
|
$cache->addProperty('balance');
|
||||||
$cache->addProperty($date);
|
$cache->addProperty($date);
|
||||||
$cache->addProperty($native->id);
|
$cache->addProperty($native->id);
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
// Log::debug('Cached!');
|
Log::debug('Cached!');
|
||||||
// return $cache->get();
|
|
||||||
|
return $cache->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var AccountRepositoryInterface $repository */
|
/** @var AccountRepositoryInterface $repository */
|
||||||
@@ -344,20 +360,9 @@ class Steam
|
|||||||
return $this->balance($account, $date);
|
return $this->balance($account, $date);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* selection of transactions
|
|
||||||
* 1: all normal transactions. No foreign currency info. In $currency. Need conversion.
|
|
||||||
* 2: all normal transactions. No foreign currency info. In $native. Need NO conversion.
|
|
||||||
* 3: all normal transactions. No foreign currency info. In neither currency. Need conversion.
|
|
||||||
* Then, select everything with foreign currency info:
|
|
||||||
* 4. All transactions with foreign currency info in $native. Normal currency value is ignored. Do not need conversion.
|
|
||||||
* 5. All transactions with foreign currency info NOT in $native, but currency info in $currency. Need conversion.
|
|
||||||
* 6. All transactions with foreign currency info NOT in $native, and currency info NOT in $currency. Need conversion.
|
|
||||||
*/
|
|
||||||
$new = [];
|
$new = [];
|
||||||
$existing = [];
|
$existing = [];
|
||||||
// 1
|
$new[] = $account->transactions() // 1
|
||||||
$new[] = $account->transactions()
|
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
->where('transactions.transaction_currency_id', $currency->id)
|
->where('transactions.transaction_currency_id', $currency->id)
|
||||||
@@ -365,8 +370,7 @@ class Steam
|
|||||||
->get(['transaction_journals.date', 'transactions.amount'])->toArray()
|
->get(['transaction_journals.date', 'transactions.amount'])->toArray()
|
||||||
;
|
;
|
||||||
app('log')->debug(sprintf('%d transaction(s) in set #1', count($new[0])));
|
app('log')->debug(sprintf('%d transaction(s) in set #1', count($new[0])));
|
||||||
// 2
|
$existing[] = $account->transactions() // 2
|
||||||
$existing[] = $account->transactions()
|
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
->where('transactions.transaction_currency_id', $native->id)
|
->where('transactions.transaction_currency_id', $native->id)
|
||||||
@@ -374,8 +378,7 @@ class Steam
|
|||||||
->get(['transactions.amount'])->toArray()
|
->get(['transactions.amount'])->toArray()
|
||||||
;
|
;
|
||||||
app('log')->debug(sprintf('%d transaction(s) in set #2', count($existing[0])));
|
app('log')->debug(sprintf('%d transaction(s) in set #2', count($existing[0])));
|
||||||
// 3
|
$new[] = $account->transactions() // 3
|
||||||
$new[] = $account->transactions()
|
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
->where('transactions.transaction_currency_id', '!=', $currency->id)
|
->where('transactions.transaction_currency_id', '!=', $currency->id)
|
||||||
@@ -384,8 +387,7 @@ class Steam
|
|||||||
->get(['transaction_journals.date', 'transactions.amount'])->toArray()
|
->get(['transaction_journals.date', 'transactions.amount'])->toArray()
|
||||||
;
|
;
|
||||||
app('log')->debug(sprintf('%d transactions in set #3', count($new[1])));
|
app('log')->debug(sprintf('%d transactions in set #3', count($new[1])));
|
||||||
// 4
|
$existing[] = $account->transactions() // 4
|
||||||
$existing[] = $account->transactions()
|
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
->where('transactions.foreign_currency_id', $native->id)
|
->where('transactions.foreign_currency_id', $native->id)
|
||||||
@@ -393,8 +395,7 @@ class Steam
|
|||||||
->get(['transactions.foreign_amount'])->toArray()
|
->get(['transactions.foreign_amount'])->toArray()
|
||||||
;
|
;
|
||||||
app('log')->debug(sprintf('%d transactions in set #4', count($existing[1])));
|
app('log')->debug(sprintf('%d transactions in set #4', count($existing[1])));
|
||||||
// 5
|
$new[] = $account->transactions()// 5
|
||||||
$new[] = $account->transactions()
|
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
->where('transactions.transaction_currency_id', $currency->id)
|
->where('transactions.transaction_currency_id', $currency->id)
|
||||||
@@ -403,8 +404,7 @@ class Steam
|
|||||||
->get(['transaction_journals.date', 'transactions.amount'])->toArray()
|
->get(['transaction_journals.date', 'transactions.amount'])->toArray()
|
||||||
;
|
;
|
||||||
app('log')->debug(sprintf('%d transactions in set #5', count($new[2])));
|
app('log')->debug(sprintf('%d transactions in set #5', count($new[2])));
|
||||||
// 6
|
$new[] = $account->transactions()// 6
|
||||||
$new[] = $account->transactions()
|
|
||||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||||
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
->where('transaction_journals.date', '<=', $date->format('Y-m-d 23:59:59'))
|
||||||
->where('transactions.transaction_currency_id', '!=', $currency->id)
|
->where('transactions.transaction_currency_id', '!=', $currency->id)
|
||||||
|
@@ -49,6 +49,9 @@ class ConvertToTransfer implements ActionInterface
|
|||||||
$this->action = $action;
|
$this->action = $action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
|
*/
|
||||||
public function actOnArray(array $journal): bool
|
public function actOnArray(array $journal): bool
|
||||||
{
|
{
|
||||||
// make object from array (so the data is fresh).
|
// make object from array (so the data is fresh).
|
||||||
|
@@ -51,24 +51,23 @@ class BillTransformer extends AbstractTransformer
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform the bill.
|
* Transform the bill.
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
public function transform(Bill $bill): array
|
public function transform(Bill $bill): array
|
||||||
{
|
{
|
||||||
$paidData = $this->paidData($bill);
|
$paidData = $this->paidData($bill);
|
||||||
$lastPaidDate = $this->getLastPaidDate($paidData);
|
$lastPaidDate = $this->getLastPaidDate($paidData);
|
||||||
|
|
||||||
// both params can be NULL, so just in case they are, add some wide margins:
|
|
||||||
$start = $this->parameters->get('start') ?? today()->subYears(10);
|
$start = $this->parameters->get('start') ?? today()->subYears(10);
|
||||||
$end = $this->parameters->get('end') ?? today()->addYears(10);
|
$end = $this->parameters->get('end') ?? today()->addYears(10);
|
||||||
$payDates = $this->calculator->getPayDates($start, $end, $bill->date, $bill->repeat_freq, $bill->skip, $lastPaidDate);
|
$payDates = $this->calculator->getPayDates($start, $end, $bill->date, $bill->repeat_freq, $bill->skip, $lastPaidDate);
|
||||||
$currency = $bill->transactionCurrency;
|
$currency = $bill->transactionCurrency;
|
||||||
$notes = $this->repository->getNoteText($bill);
|
$notes = $this->repository->getNoteText($bill);
|
||||||
$notes = '' === $notes ? null : $notes;
|
$notes = '' === $notes ? null : $notes;
|
||||||
$this->repository->setUser($bill->user);
|
|
||||||
|
|
||||||
$objectGroupId = null;
|
$objectGroupId = null;
|
||||||
$objectGroupOrder = null;
|
$objectGroupOrder = null;
|
||||||
$objectGroupTitle = null;
|
$objectGroupTitle = null;
|
||||||
|
$this->repository->setUser($bill->user);
|
||||||
|
|
||||||
/** @var null|ObjectGroup $objectGroup */
|
/** @var null|ObjectGroup $objectGroup */
|
||||||
$objectGroup = $bill->objectGroups->first();
|
$objectGroup = $bill->objectGroups->first();
|
||||||
|
@@ -138,6 +138,9 @@ class TransactionGroupTransformer extends AbstractTransformer
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
|
*/
|
||||||
private function transformTransaction(array $transaction): array
|
private function transformTransaction(array $transaction): array
|
||||||
{
|
{
|
||||||
$row = new NullArrayObject($transaction);
|
$row = new NullArrayObject($transaction);
|
||||||
@@ -317,6 +320,8 @@ class TransactionGroupTransformer extends AbstractTransformer
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
private function transformJournal(TransactionJournal $journal): array
|
private function transformJournal(TransactionJournal $journal): array
|
||||||
{
|
{
|
||||||
|
@@ -47,6 +47,11 @@ class BillTransformer extends AbstractTransformer
|
|||||||
private array $notes;
|
private array $notes;
|
||||||
private array $paidDates;
|
private array $paidDates;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \FireflyIII\Exceptions\FireflyException
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
|
*/
|
||||||
public function collectMetaData(Collection $objects): void
|
public function collectMetaData(Collection $objects): void
|
||||||
{
|
{
|
||||||
$currencies = [];
|
$currencies = [];
|
||||||
@@ -55,7 +60,6 @@ class BillTransformer extends AbstractTransformer
|
|||||||
$this->groups = [];
|
$this->groups = [];
|
||||||
$this->paidDates = [];
|
$this->paidDates = [];
|
||||||
|
|
||||||
// start with currencies:
|
|
||||||
/** @var Bill $object */
|
/** @var Bill $object */
|
||||||
foreach ($objects as $object) {
|
foreach ($objects as $object) {
|
||||||
$id = $object->transaction_currency_id;
|
$id = $object->transaction_currency_id;
|
||||||
@@ -63,8 +67,6 @@ class BillTransformer extends AbstractTransformer
|
|||||||
$currencies[$id] ??= TransactionCurrency::find($id);
|
$currencies[$id] ??= TransactionCurrency::find($id);
|
||||||
}
|
}
|
||||||
$this->currencies = $currencies;
|
$this->currencies = $currencies;
|
||||||
|
|
||||||
// continue with notes
|
|
||||||
$notes = Note::whereNoteableType(Bill::class)->whereIn('noteable_id', array_keys($bills))->get();
|
$notes = Note::whereNoteableType(Bill::class)->whereIn('noteable_id', array_keys($bills))->get();
|
||||||
|
|
||||||
/** @var Note $note */
|
/** @var Note $note */
|
||||||
@@ -107,7 +109,6 @@ class BillTransformer extends AbstractTransformer
|
|||||||
->where('transactions.amount', '<', 0)
|
->where('transactions.amount', '<', 0)
|
||||||
->get(['transactions.id', 'transactions.transaction_journal_id', 'transactions.amount', 'transactions.foreign_amount', 'transactions.transaction_currency_id', 'transactions.foreign_currency_id'])
|
->get(['transactions.id', 'transactions.transaction_journal_id', 'transactions.amount', 'transactions.foreign_amount', 'transactions.transaction_currency_id', 'transactions.foreign_currency_id'])
|
||||||
;
|
;
|
||||||
// convert to array for easy finding:
|
|
||||||
$transactions = [];
|
$transactions = [];
|
||||||
|
|
||||||
/** @var Transaction $transaction */
|
/** @var Transaction $transaction */
|
||||||
|
@@ -140,6 +140,8 @@ class TransactionGroupTransformer extends AbstractTransformer
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
private function transformTransaction(array $transaction): array
|
private function transformTransaction(array $transaction): array
|
||||||
{
|
{
|
||||||
|
@@ -115,6 +115,7 @@ class FireflyValidator extends Validator
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
public function validateIban(mixed $attribute, mixed $value): bool
|
public function validateIban(mixed $attribute, mixed $value): bool
|
||||||
{
|
{
|
||||||
|
@@ -386,6 +386,9 @@ class CreateMainTables extends Migration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
|
*/
|
||||||
private function createRuleTables(): void
|
private function createRuleTables(): void
|
||||||
{
|
{
|
||||||
if (!Schema::hasTable('rule_groups')) {
|
if (!Schema::hasTable('rule_groups')) {
|
||||||
|
@@ -107,6 +107,7 @@ class UserGroups extends Migration
|
|||||||
* Run the migrations.
|
* Run the migrations.
|
||||||
*
|
*
|
||||||
* @SuppressWarnings(PHPMD.ShortMethodName)
|
* @SuppressWarnings(PHPMD.ShortMethodName)
|
||||||
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
||||||
*/
|
*/
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user