mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Various code cleanup.
This commit is contained in:
parent
a0564751d6
commit
1d2e95f5af
@ -56,5 +56,5 @@ parameters:
|
||||
|
||||
# The level 8 is the highest level. original was 5
|
||||
# TODO: slowly up the level and fix the issues found.
|
||||
level: 4
|
||||
level: 1
|
||||
|
||||
|
@ -120,8 +120,8 @@ class AccountController extends Controller
|
||||
$return,
|
||||
static function (array $left, array $right) {
|
||||
$order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE];
|
||||
$posA = array_search($left['type'], $order, true);
|
||||
$posB = array_search($right['type'], $order, true);
|
||||
$posA = (int) array_search($left['type'], $order, true);
|
||||
$posB = (int) array_search($right['type'], $order, true);
|
||||
|
||||
return $posA - $posB;
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ class ShowController extends Controller
|
||||
*/
|
||||
public function show(Request $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse
|
||||
{
|
||||
if ((int)$budget->id !== (int)$budgetLimit->budget_id) {
|
||||
if ($budget->id !== $budgetLimit->budget_id) {
|
||||
throw new FireflyException('20028: The budget limit does not belong to the budget.');
|
||||
}
|
||||
// continue!
|
||||
|
@ -78,7 +78,7 @@ class UpdateController extends Controller
|
||||
*/
|
||||
public function update(UpdateRequest $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse
|
||||
{
|
||||
if ((int)$budget->id !== (int)$budgetLimit->budget_id) {
|
||||
if ($budget->id !== $budgetLimit->budget_id) {
|
||||
throw new FireflyException('20028: The budget limit does not belong to the budget.');
|
||||
}
|
||||
$data = $request->getAll();
|
||||
|
@ -125,8 +125,8 @@ class AccountController extends Controller
|
||||
$allItems,
|
||||
static function (array $a, array $b): int {
|
||||
$order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE];
|
||||
$pos_a = array_search($a['type'], $order, true);
|
||||
$pos_b = array_search($b['type'], $order, true);
|
||||
$pos_a = (int) array_search($a['type'], $order, true);
|
||||
$pos_b = (int) array_search($b['type'], $order, true);
|
||||
|
||||
return $pos_a - $pos_b;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ class BalanceController extends Controller
|
||||
/** @var TransactionCurrency $default */
|
||||
$default = app('amount')->getDefaultCurrency();
|
||||
$converter = new ExchangeRateConverter();
|
||||
$currencies = [(int)$default->id => $default,]; // currency cache
|
||||
$currencies = [$default->id => $default,]; // currency cache
|
||||
$data = [];
|
||||
$chartData = [];
|
||||
|
||||
@ -94,7 +94,7 @@ class BalanceController extends Controller
|
||||
$journals = $collector->getExtractedJournals();
|
||||
|
||||
// set array for default currency (even if unused later on)
|
||||
$defaultCurrencyId = (int)$default->id;
|
||||
$defaultCurrencyId = $default->id;
|
||||
$data[$defaultCurrencyId] = [
|
||||
'currency_id' => (string)$defaultCurrencyId,
|
||||
'currency_symbol' => $default->symbol,
|
||||
@ -168,7 +168,7 @@ class BalanceController extends Controller
|
||||
$amountConverted = bcmul($amount, $rate);
|
||||
|
||||
// perhaps transaction already has the foreign amount in the native currency.
|
||||
if ((int)$journal['foreign_currency_id'] === (int)$default->id) {
|
||||
if ((int)$journal['foreign_currency_id'] === $default->id) {
|
||||
$amountConverted = $journal['foreign_amount'] ?? '0';
|
||||
$amountConverted = 'earned' === $key ? app('steam')->positive($amountConverted) : app('steam')->negative($amountConverted);
|
||||
}
|
||||
|
@ -170,9 +170,8 @@ class BudgetController extends Controller
|
||||
*/
|
||||
private function noBudgetLimits(Budget $budget, Carbon $start, Carbon $end): array
|
||||
{
|
||||
$budgetId = (int)$budget->id;
|
||||
$spent = $this->opsRepository->listExpenses($start, $end, null, new Collection([$budget]));
|
||||
return $this->processExpenses($budgetId, $spent, $start, $end);
|
||||
return $this->processExpenses($budget->id, $spent, $start, $end);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -275,11 +274,10 @@ class BudgetController extends Controller
|
||||
*/
|
||||
private function processLimit(Budget $budget, BudgetLimit $limit): array
|
||||
{
|
||||
$budgetId = (int)$budget->id;
|
||||
$end = clone $limit->end_date;
|
||||
$end->endOfDay();
|
||||
$spent = $this->opsRepository->listExpenses($limit->start_date, $end, null, new Collection([$budget]));
|
||||
$limitCurrencyId = (int)$limit->transaction_currency_id;
|
||||
$limitCurrencyId = $limit->transaction_currency_id;
|
||||
$limitCurrency = $limit->transactionCurrency;
|
||||
$converter = new ExchangeRateConverter();
|
||||
$filtered = [];
|
||||
@ -295,9 +293,9 @@ class BudgetController extends Controller
|
||||
$filtered[$currencyId] = $entry;
|
||||
}
|
||||
}
|
||||
$result = $this->processExpenses($budgetId, $filtered, $limit->start_date, $end);
|
||||
$result = $this->processExpenses($budget->id, $filtered, $limit->start_date, $end);
|
||||
if (1 === count($result)) {
|
||||
$compare = bccomp((string)$limit->amount, app('steam')->positive($result[$limitCurrencyId]['spent']));
|
||||
$compare = bccomp($limit->amount, app('steam')->positive($result[$limitCurrencyId]['spent']));
|
||||
if (1 === $compare) {
|
||||
// convert this amount into the native currency:
|
||||
$result[$limitCurrencyId]['left'] = bcadd($limit->amount, $result[$limitCurrencyId]['spent']);
|
||||
|
@ -104,7 +104,7 @@ class CategoryController extends Controller
|
||||
$amount = app('steam')->positive($journal['amount']);
|
||||
$nativeAmount = $converter->convert($default, $currency, $journal['date'], $amount);
|
||||
$key = sprintf('%s-%s', $categoryName, $currency->code);
|
||||
if ((int)$journal['foreign_currency_id'] === (int)$default->id) {
|
||||
if ((int)$journal['foreign_currency_id'] === $default->id) {
|
||||
$nativeAmount = app('steam')->positive($journal['foreign_amount']);
|
||||
}
|
||||
// create arrays
|
||||
|
@ -163,7 +163,7 @@ class BasicController extends Controller
|
||||
$currency = $currencies[$currencyId] ?? TransactionCurrency::find($currencyId);
|
||||
$currencies[$currencyId] = $currency;
|
||||
$nativeAmount = $converter->convert($currency, $default, $transactionJournal['date'], $amount);
|
||||
if ((int)$transactionJournal['foreign_currency_id'] === (int)$default->id) {
|
||||
if ((int)$transactionJournal['foreign_currency_id'] === $default->id) {
|
||||
// use foreign amount instead
|
||||
$nativeAmount = $transactionJournal['foreign_amount'];
|
||||
}
|
||||
@ -201,7 +201,7 @@ class BasicController extends Controller
|
||||
$currency = $currencies[$currencyId] ?? $this->currencyRepos->find($currencyId);
|
||||
$currencies[$currencyId] = $currency;
|
||||
$nativeAmount = $converter->convert($currency, $default, $transactionJournal['date'], $amount);
|
||||
if ((int)$transactionJournal['foreign_currency_id'] === (int)$default->id) {
|
||||
if ((int)$transactionJournal['foreign_currency_id'] === $default->id) {
|
||||
// use foreign amount instead
|
||||
$nativeAmount = $transactionJournal['foreign_amount'];
|
||||
}
|
||||
@ -407,7 +407,7 @@ class BasicController extends Controller
|
||||
$currencies[$currencyId] = $currency;
|
||||
$amount = app('steam')->negative($journal['amount']);
|
||||
$amountNative = $converter->convert($default, $currency, $start, $amount);
|
||||
if ((int)$journal['foreign_currency_id'] === (int)$default->id) {
|
||||
if ((int)$journal['foreign_currency_id'] === $default->id) {
|
||||
$amountNative = $journal['foreign_amount'];
|
||||
}
|
||||
$spent = bcadd($spent, $amount);
|
||||
|
@ -88,7 +88,7 @@ class CorrectAmounts extends Command
|
||||
}
|
||||
/** @var AutoBudget $item */
|
||||
foreach ($set as $item) {
|
||||
$item->amount = app('steam')->positive((string)$item->amount);
|
||||
$item->amount = app('steam')->positive($item->amount);
|
||||
$item->save();
|
||||
}
|
||||
$this->friendlyInfo(sprintf('Corrected %d auto budget amount(s).', $count));
|
||||
@ -108,7 +108,7 @@ class CorrectAmounts extends Command
|
||||
}
|
||||
/** @var AvailableBudget $item */
|
||||
foreach ($set as $item) {
|
||||
$item->amount = app('steam')->positive((string)$item->amount);
|
||||
$item->amount = app('steam')->positive($item->amount);
|
||||
$item->save();
|
||||
}
|
||||
$this->friendlyInfo(sprintf('Corrected %d available budget amount(s).', $count));
|
||||
@ -128,8 +128,8 @@ class CorrectAmounts extends Command
|
||||
}
|
||||
/** @var Bill $item */
|
||||
foreach ($set as $item) {
|
||||
$item->amount_min = app('steam')->positive((string)$item->amount_min);
|
||||
$item->amount_max = app('steam')->positive((string)$item->amount_max);
|
||||
$item->amount_min = app('steam')->positive($item->amount_min);
|
||||
$item->amount_max = app('steam')->positive($item->amount_max);
|
||||
$item->save();
|
||||
}
|
||||
$this->friendlyInfo(sprintf('Corrected %d bill amount(s).', $count));
|
||||
@ -149,7 +149,7 @@ class CorrectAmounts extends Command
|
||||
}
|
||||
/** @var BudgetLimit $item */
|
||||
foreach ($set as $item) {
|
||||
$item->amount = app('steam')->positive((string)$item->amount);
|
||||
$item->amount = app('steam')->positive($item->amount);
|
||||
$item->save();
|
||||
}
|
||||
$this->friendlyInfo(sprintf('Corrected %d budget limit amount(s).', $count));
|
||||
@ -169,7 +169,7 @@ class CorrectAmounts extends Command
|
||||
}
|
||||
/** @var CurrencyExchangeRate $item */
|
||||
foreach ($set as $item) {
|
||||
$item->rate = app('steam')->positive((string)$item->rate);
|
||||
$item->rate = app('steam')->positive($item->rate);
|
||||
$item->save();
|
||||
}
|
||||
$this->friendlyInfo(sprintf('Corrected %d currency exchange rate(s).', $count));
|
||||
@ -189,7 +189,7 @@ class CorrectAmounts extends Command
|
||||
}
|
||||
/** @var PiggyBankRepetition $item */
|
||||
foreach ($set as $item) {
|
||||
$item->currentamount = app('steam')->positive((string)$item->currentamount);
|
||||
$item->currentamount = app('steam')->positive($item->currentamount);
|
||||
$item->save();
|
||||
}
|
||||
$this->friendlyInfo(sprintf('Corrected %d piggy bank repetition amount(s).', $count));
|
||||
@ -209,7 +209,7 @@ class CorrectAmounts extends Command
|
||||
}
|
||||
/** @var PiggyBank $item */
|
||||
foreach ($set as $item) {
|
||||
$item->targetamount = app('steam')->positive((string)$item->targetamount);
|
||||
$item->targetamount = app('steam')->positive($item->targetamount);
|
||||
$item->save();
|
||||
}
|
||||
$this->friendlyInfo(sprintf('Corrected %d piggy bank amount(s).', $count));
|
||||
@ -231,8 +231,8 @@ class CorrectAmounts extends Command
|
||||
}
|
||||
/** @var RecurrenceTransaction $item */
|
||||
foreach ($set as $item) {
|
||||
$item->amount = app('steam')->positive((string)$item->amount);
|
||||
$item->foreign_amount = app('steam')->positive((string)$item->foreign_amount);
|
||||
$item->amount = app('steam')->positive($item->amount);
|
||||
$item->foreign_amount = app('steam')->positive($item->foreign_amount);
|
||||
$item->save();
|
||||
}
|
||||
$this->friendlyInfo(sprintf('Corrected %d recurring transaction amount(s).', $count));
|
||||
@ -259,7 +259,7 @@ class CorrectAmounts extends Command
|
||||
}
|
||||
if (-1 === $check) {
|
||||
$fixed++;
|
||||
$item->trigger_value = app('steam')->positive((string)$item->trigger_value);
|
||||
$item->trigger_value = app('steam')->positive($item->trigger_value);
|
||||
$item->save();
|
||||
}
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ class CorrectOpeningBalanceCurrencies extends Command
|
||||
{
|
||||
$currency = $this->getCurrency($account);
|
||||
$count = 0;
|
||||
if ((int)$journal->transaction_currency_id !== (int)$currency->id) {
|
||||
if ((int)$journal->transaction_currency_id !== $currency->id) {
|
||||
$journal->transaction_currency_id = $currency->id;
|
||||
$journal->save();
|
||||
$count = 1;
|
||||
@ -141,7 +141,7 @@ class CorrectOpeningBalanceCurrencies extends Command
|
||||
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($journal->transactions as $transaction) {
|
||||
if ((int)$transaction->transaction_currency_id !== (int)$currency->id) {
|
||||
if ($transaction->transaction_currency_id !== $currency->id) {
|
||||
$transaction->transaction_currency_id = $currency->id;
|
||||
$transaction->save();
|
||||
$count = 1;
|
||||
|
@ -69,14 +69,14 @@ class DeleteEmptyJournals extends Command
|
||||
if (1 === $count % 2) {
|
||||
// uneven number, delete journal and transactions:
|
||||
try {
|
||||
TransactionJournal::find((int)$row->transaction_journal_id)->delete();
|
||||
TransactionJournal::find($row->transaction_journal_id)->delete();
|
||||
} catch (QueryException $e) {
|
||||
app('log')->info(sprintf('Could not delete journal: %s', $e->getMessage()));
|
||||
app('log')->error($e->getTraceAsString());
|
||||
}
|
||||
|
||||
|
||||
Transaction::where('transaction_journal_id', (int)$row->transaction_journal_id)->delete();
|
||||
Transaction::where('transaction_journal_id', $row->transaction_journal_id)->delete();
|
||||
$this->friendlyWarning(
|
||||
sprintf('Deleted transaction journal #%d because it had an uneven number of transactions.', $row->transaction_journal_id)
|
||||
);
|
||||
|
@ -72,7 +72,7 @@ class DeleteOrphanedTransactions extends Command
|
||||
}
|
||||
$this->friendlyInfo(sprintf('Found %d orphaned journal(s).', $count));
|
||||
foreach ($set as $entry) {
|
||||
$journal = TransactionJournal::withTrashed()->find((int)$entry->id);
|
||||
$journal = TransactionJournal::withTrashed()->find($entry->id);
|
||||
if (null !== $journal) {
|
||||
$journal->delete();
|
||||
$this->friendlyWarning(
|
||||
@ -135,11 +135,11 @@ class DeleteOrphanedTransactions extends Command
|
||||
/** @var Transaction $transaction */
|
||||
foreach ($set as $transaction) {
|
||||
// delete journals
|
||||
$journal = TransactionJournal::find((int)$transaction->transaction_journal_id);
|
||||
$journal = TransactionJournal::find($transaction->transaction_journal_id);
|
||||
if (null !== $journal) {
|
||||
$journal->delete();
|
||||
}
|
||||
Transaction::where('transaction_journal_id', (int)$transaction->transaction_journal_id)->delete();
|
||||
Transaction::where('transaction_journal_id', $transaction->transaction_journal_id)->delete();
|
||||
$this->friendlyWarning(
|
||||
sprintf(
|
||||
'Deleted transaction journal #%d because account #%d was already deleted.',
|
||||
|
@ -73,7 +73,7 @@ class EnableCurrencies extends Command
|
||||
// get all from budget limits
|
||||
$limits = BudgetLimit::groupBy('transaction_currency_id')->get(['transaction_currency_id']);
|
||||
foreach ($limits as $entry) {
|
||||
$found[] = (int)$entry->transaction_currency_id;
|
||||
$found[] = $entry->transaction_currency_id;
|
||||
}
|
||||
|
||||
$found = array_values(array_unique($found));
|
||||
|
@ -114,7 +114,7 @@ class FixAccountTypes extends Command
|
||||
$this->friendlyLine(sprintf('Found %d journals that need to be fixed.', $resultSet->count()));
|
||||
foreach ($resultSet as $entry) {
|
||||
app('log')->debug(sprintf('Now fixing journal #%d', $entry->id));
|
||||
$journal = TransactionJournal::find((int)$entry->id);
|
||||
$journal = TransactionJournal::find($entry->id);
|
||||
if (null !== $journal) {
|
||||
$this->inspectJournal($journal);
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ class FixIbans extends Command
|
||||
$set = [];
|
||||
/** @var Account $account */
|
||||
foreach ($accounts as $account) {
|
||||
$userId = (int)$account->user_id;
|
||||
$userId = $account->user_id;
|
||||
$set[$userId] = $set[$userId] ?? [];
|
||||
$iban = (string)$account->iban;
|
||||
if ('' === $iban) {
|
||||
|
@ -77,7 +77,7 @@ class FixUnevenAmount extends Command
|
||||
);
|
||||
$this->friendlyWarning($message);
|
||||
app('log')->warning($message);
|
||||
$this->fixJournal((int)$entry->transaction_journal_id);
|
||||
$this->fixJournal($entry->transaction_journal_id);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
@ -115,7 +115,7 @@ class FixUnevenAmount extends Command
|
||||
return;
|
||||
}
|
||||
|
||||
$amount = bcmul('-1', (string)$source->amount);
|
||||
$amount = bcmul('-1', $source->amount);
|
||||
|
||||
// fix amount of destination:
|
||||
/** @var Transaction|null $destination */
|
||||
|
@ -501,7 +501,7 @@ class ForceDecimalSize extends Command
|
||||
|
||||
/** @var Transaction $item */
|
||||
foreach ($result as $item) {
|
||||
$value = (string)$item->amount;
|
||||
$value = $item->amount;
|
||||
if ('' === $value) {
|
||||
continue;
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ class BackToJournals extends Command
|
||||
// both have a budget, but they don't match.
|
||||
if (null !== $budget && null !== $journalBudget && $budget->id !== $journalBudget->id) {
|
||||
// sync to journal:
|
||||
$journal->budgets()->sync([(int)$budget->id]);
|
||||
$journal->budgets()->sync([$budget->id]);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -177,7 +177,7 @@ class BackToJournals extends Command
|
||||
// transaction has a budget, but the journal doesn't.
|
||||
if (null !== $budget && null === $journalBudget) {
|
||||
// sync to journal:
|
||||
$journal->budgets()->sync([(int)$budget->id]);
|
||||
$journal->budgets()->sync([$budget->id]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,12 +241,12 @@ class BackToJournals extends Command
|
||||
// both have a category, but they don't match.
|
||||
if (null !== $category && null !== $journalCategory && $category->id !== $journalCategory->id) {
|
||||
// sync to journal:
|
||||
$journal->categories()->sync([(int)$category->id]);
|
||||
$journal->categories()->sync([$category->id]);
|
||||
}
|
||||
|
||||
// transaction has a category, but the journal doesn't.
|
||||
if (null !== $category && null === $journalCategory) {
|
||||
$journal->categories()->sync([(int)$category->id]);
|
||||
$journal->categories()->sync([$category->id]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ class MigrateRecurrenceType extends Command
|
||||
*/
|
||||
private function migrateRecurrence(Recurrence $recurrence): void
|
||||
{
|
||||
$originalType = (int)$recurrence->transaction_type_id;
|
||||
$originalType = $recurrence->transaction_type_id;
|
||||
$newType = $this->getInvalidType();
|
||||
$recurrence->transaction_type_id = $newType->id;
|
||||
$recurrence->save();
|
||||
|
@ -335,7 +335,7 @@ class MigrateToGroups extends Command
|
||||
if (null !== $budget) {
|
||||
app('log')->debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $left->id));
|
||||
|
||||
return (int)$budget->id;
|
||||
return $budget->id;
|
||||
}
|
||||
|
||||
// try to get a budget ID from the right transaction:
|
||||
@ -344,7 +344,7 @@ class MigrateToGroups extends Command
|
||||
if (null !== $budget) {
|
||||
app('log')->debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $right->id));
|
||||
|
||||
return (int)$budget->id;
|
||||
return $budget->id;
|
||||
}
|
||||
app('log')->debug('Neither left or right have a budget, return NULL');
|
||||
|
||||
@ -368,7 +368,7 @@ class MigrateToGroups extends Command
|
||||
if (null !== $category) {
|
||||
app('log')->debug(sprintf('Return category #%d, from transaction #%d', $category->id, $left->id));
|
||||
|
||||
return (int)$category->id;
|
||||
return $category->id;
|
||||
}
|
||||
|
||||
// try to get a category ID from the left transaction:
|
||||
@ -377,7 +377,7 @@ class MigrateToGroups extends Command
|
||||
if (null !== $category) {
|
||||
app('log')->debug(sprintf('Return category #%d, from transaction #%d', $category->id, $category->id));
|
||||
|
||||
return (int)$category->id;
|
||||
return $category->id;
|
||||
}
|
||||
app('log')->debug('Neither left or right have a category, return NULL');
|
||||
|
||||
|
@ -169,8 +169,8 @@ class OtherCurrenciesCorrections extends Command
|
||||
}
|
||||
|
||||
// when mismatch in transaction:
|
||||
if ((int)$transaction->transaction_currency_id !== (int)$currency->id) {
|
||||
$transaction->foreign_currency_id = (int)$transaction->transaction_currency_id;
|
||||
if ($transaction->transaction_currency_id !== $currency->id) {
|
||||
$transaction->foreign_currency_id = $transaction->transaction_currency_id;
|
||||
$transaction->foreign_amount = $transaction->amount;
|
||||
$transaction->transaction_currency_id = $currency->id;
|
||||
$transaction->save();
|
||||
|
@ -161,7 +161,7 @@ class TransactionIdentifier extends Command
|
||||
private function findOpposing(Transaction $transaction, array $exclude): ?Transaction
|
||||
{
|
||||
// find opposing:
|
||||
$amount = bcmul((string)$transaction->amount, '-1');
|
||||
$amount = bcmul($transaction->amount, '-1');
|
||||
|
||||
try {
|
||||
/** @var Transaction $opposing */
|
||||
|
@ -349,7 +349,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
if (null === $this->sourceTransaction->transaction_currency_id && null !== $this->sourceCurrency) {
|
||||
$this->sourceTransaction
|
||||
->transaction_currency_id
|
||||
= (int)$this->sourceCurrency->id;
|
||||
= $this->sourceCurrency->id;
|
||||
$message = sprintf(
|
||||
'Transaction #%d has no currency setting, now set to %s.',
|
||||
$this->sourceTransaction->id,
|
||||
@ -369,7 +369,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
{
|
||||
if (null !== $this->sourceCurrency
|
||||
&& null === $this->sourceTransaction->foreign_amount
|
||||
&& (int)$this->sourceTransaction->transaction_currency_id !== (int)$this->sourceCurrency->id
|
||||
&& (int)$this->sourceTransaction->transaction_currency_id !== $this->sourceCurrency->id
|
||||
) {
|
||||
$message = sprintf(
|
||||
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
|
||||
@ -380,7 +380,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
);
|
||||
$this->friendlyWarning($message);
|
||||
$this->count++;
|
||||
$this->sourceTransaction->transaction_currency_id = (int)$this->sourceCurrency->id;
|
||||
$this->sourceTransaction->transaction_currency_id = $this->sourceCurrency->id;
|
||||
$this->sourceTransaction->save();
|
||||
}
|
||||
}
|
||||
@ -394,7 +394,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
if (null === $this->destinationTransaction->transaction_currency_id && null !== $this->destinationCurrency) {
|
||||
$this->destinationTransaction
|
||||
->transaction_currency_id
|
||||
= (int)$this->destinationCurrency->id;
|
||||
= $this->destinationCurrency->id;
|
||||
$message = sprintf(
|
||||
'Transaction #%d has no currency setting, now set to %s.',
|
||||
$this->destinationTransaction->id,
|
||||
@ -414,7 +414,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
{
|
||||
if (null !== $this->destinationCurrency
|
||||
&& null === $this->destinationTransaction->foreign_amount
|
||||
&& (int)$this->destinationTransaction->transaction_currency_id !== (int)$this->destinationCurrency->id
|
||||
&& (int)$this->destinationTransaction->transaction_currency_id !== $this->destinationCurrency->id
|
||||
) {
|
||||
$message = sprintf(
|
||||
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
|
||||
@ -425,7 +425,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
);
|
||||
$this->friendlyWarning($message);
|
||||
$this->count++;
|
||||
$this->destinationTransaction->transaction_currency_id = (int)$this->destinationCurrency->id;
|
||||
$this->destinationTransaction->transaction_currency_id = $this->destinationCurrency->id;
|
||||
$this->destinationTransaction->save();
|
||||
}
|
||||
}
|
||||
@ -437,7 +437,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
*/
|
||||
private function fixInvalidForeignCurrency(): void
|
||||
{
|
||||
if ((int)$this->destinationCurrency->id === (int)$this->sourceCurrency->id) {
|
||||
if ($this->destinationCurrency->id === $this->sourceCurrency->id) {
|
||||
// update both transactions to match:
|
||||
$this->sourceTransaction->foreign_amount = null;
|
||||
$this->sourceTransaction->foreign_currency_id = null;
|
||||
@ -457,7 +457,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
*/
|
||||
private function fixMismatchedForeignCurrency(): void
|
||||
{
|
||||
if ((int)$this->sourceCurrency->id !== (int)$this->destinationCurrency->id) {
|
||||
if ($this->sourceCurrency->id !== $this->destinationCurrency->id) {
|
||||
$this->sourceTransaction->transaction_currency_id = $this->sourceCurrency->id;
|
||||
$this->sourceTransaction->foreign_currency_id = $this->destinationCurrency->id;
|
||||
$this->destinationTransaction->transaction_currency_id = $this->sourceCurrency->id;
|
||||
@ -479,7 +479,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
private function fixSourceNullForeignAmount(): void
|
||||
{
|
||||
if (null === $this->sourceTransaction->foreign_amount && null !== $this->destinationTransaction->foreign_amount) {
|
||||
$this->sourceTransaction->foreign_amount = bcmul((string)$this->destinationTransaction->foreign_amount, '-1');
|
||||
$this->sourceTransaction->foreign_amount = bcmul($this->destinationTransaction->foreign_amount, '-1');
|
||||
$this->sourceTransaction->save();
|
||||
$this->count++;
|
||||
$this->friendlyInfo(
|
||||
@ -499,7 +499,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
private function fixDestNullForeignAmount(): void
|
||||
{
|
||||
if (null === $this->destinationTransaction->foreign_amount && null !== $this->sourceTransaction->foreign_amount) {
|
||||
$this->destinationTransaction->foreign_amount = bcmul((string)$this->sourceTransaction->foreign_amount, '-1');
|
||||
$this->destinationTransaction->foreign_amount = bcmul($this->sourceTransaction->foreign_amount, '-1');
|
||||
$this->destinationTransaction->save();
|
||||
$this->count++;
|
||||
$this->friendlyInfo(
|
||||
@ -519,7 +519,7 @@ class TransferCurrenciesCorrections extends Command
|
||||
*/
|
||||
private function fixTransactionJournalCurrency(TransactionJournal $journal): void
|
||||
{
|
||||
if ((int)$journal->transaction_currency_id !== (int)$this->sourceCurrency->id) {
|
||||
if ((int)$journal->transaction_currency_id !== $this->sourceCurrency->id) {
|
||||
$oldCurrencyCode = $journal->transactionCurrency->code ?? '(nothing)';
|
||||
$journal->transaction_currency_id = $this->sourceCurrency->id;
|
||||
$message = sprintf(
|
||||
|
@ -149,9 +149,9 @@ class UpgradeLiabilities extends Command
|
||||
return;
|
||||
}
|
||||
// source MUST be the liability.
|
||||
if ((int)$destination->account_id === (int)$account->id) {
|
||||
if ($destination->account_id === $account->id) {
|
||||
// so if not, switch things around:
|
||||
$sourceAccountId = (int)$source->account_id;
|
||||
$sourceAccountId = $source->account_id;
|
||||
$source->account_id = $destination->account_id;
|
||||
$destination->account_id = $sourceAccountId;
|
||||
$source->save();
|
||||
|
@ -238,10 +238,10 @@ class UpgradeLiabilitiesEight extends Command
|
||||
|
||||
// if source is this liability and destination is expense, remove transaction.
|
||||
// if source is revenue and destination is liability, remove transaction.
|
||||
if ((int)$source->account_id === (int)$account->id && $dest->account->accountType->type === AccountType::EXPENSE) {
|
||||
if ($source->account_id === $account->id && $dest->account->accountType->type === AccountType::EXPENSE) {
|
||||
$delete = true;
|
||||
}
|
||||
if ((int)$dest->account_id === (int)$account->id && $source->account->accountType->type === AccountType::REVENUE) {
|
||||
if ($dest->account_id === $account->id && $source->account->accountType->type === AccountType::REVENUE) {
|
||||
$delete = true;
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
|
||||
$route = $request->route();
|
||||
$param = $route->parameter('account');
|
||||
if ($param instanceof Account) {
|
||||
$accountId = (int)$param->id;
|
||||
$accountId = $param->id;
|
||||
}
|
||||
if (!($param instanceof Account)) {
|
||||
$accountId = (int)$param;
|
||||
|
@ -36,6 +36,7 @@ final class IntervalException extends Exception
|
||||
{
|
||||
public array $availableIntervals;
|
||||
public Periodicity $periodicity;
|
||||
/** @var mixed */
|
||||
protected $message = 'The periodicity %s is unknown. Choose one of available periodicity: %s';
|
||||
|
||||
public function __construct(string $message = '', int $code = 0, ?Throwable $previous = null)
|
||||
|
@ -125,7 +125,7 @@ class BudgetLimitHandler
|
||||
|
||||
// no need to calculate if period is equal.
|
||||
if ($currentPeriod->equals($limitPeriod)) {
|
||||
$amount = 0 === (int)$budgetLimit->id ? '0' : $budgetLimit->amount;
|
||||
$amount = 0 === $budgetLimit->id ? '0' : $budgetLimit->amount;
|
||||
}
|
||||
if (0 === bccomp($amount, '0')) {
|
||||
app('log')->debug('Amount is zero, will not create AB.');
|
||||
@ -227,7 +227,7 @@ class BudgetLimitHandler
|
||||
*/
|
||||
private function getDailyAmount(BudgetLimit $budgetLimit): string
|
||||
{
|
||||
if (0 === (int)$budgetLimit->id) {
|
||||
if (0 === $budgetLimit->id) {
|
||||
return '0';
|
||||
}
|
||||
$limitPeriod = Period::make(
|
||||
@ -237,7 +237,7 @@ class BudgetLimitHandler
|
||||
boundaries: Boundaries::EXCLUDE_NONE()
|
||||
);
|
||||
$days = $limitPeriod->length();
|
||||
$amount = bcdiv((string)$budgetLimit->amount, (string)$days, 12);
|
||||
$amount = bcdiv($budgetLimit->amount, (string)$days, 12);
|
||||
app('log')->debug(
|
||||
sprintf('Total amount for budget limit #%d is %s. Nr. of days is %d. Amount per day is %s', $budgetLimit->id, $budgetLimit->amount, $days, $amount)
|
||||
);
|
||||
|
@ -95,7 +95,7 @@ class AttachmentHelper implements AttachmentHelperInterface
|
||||
*/
|
||||
public function getAttachmentLocation(Attachment $attachment): string
|
||||
{
|
||||
return sprintf('%sat-%d.data', \DIRECTORY_SEPARATOR, (int)$attachment->id);
|
||||
return sprintf('%sat-%d.data', \DIRECTORY_SEPARATOR, $attachment->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -563,8 +563,8 @@ class GroupCollector implements GroupCollectorInterface
|
||||
$parsedGroup = $this->parseAugmentedJournal($augumentedJournal);
|
||||
$groupArray = [
|
||||
'id' => (int)$augumentedJournal->transaction_group_id,
|
||||
'user_id' => (int)$augumentedJournal->user_id,
|
||||
'user_group_id' => (int)$augumentedJournal->user_group_id,
|
||||
'user_id' => $augumentedJournal->user_id,
|
||||
'user_group_id' => $augumentedJournal->user_group_id,
|
||||
// Field transaction_group_title was added by the query.
|
||||
'title' => $augumentedJournal->transaction_group_title, // @phpstan-ignore-line
|
||||
'transaction_type' => $parsedGroup['transaction_type_type'],
|
||||
|
@ -85,12 +85,12 @@ class NetWorth implements NetWorthInterface
|
||||
'native' => [
|
||||
'balance' => '0',
|
||||
'native_balance' => '0',
|
||||
'currency_id' => (int)$default->id,
|
||||
'currency_id' => $default->id,
|
||||
'currency_code' => $default->code,
|
||||
'currency_name' => $default->name,
|
||||
'currency_symbol' => $default->symbol,
|
||||
'currency_decimal_places' => (int)$default->decimal_places,
|
||||
'native_id' => (int)$default->id,
|
||||
'native_id' => $default->id,
|
||||
'native_code' => $default->code,
|
||||
'native_name' => $default->name,
|
||||
'native_symbol' => $default->symbol,
|
||||
@ -103,16 +103,16 @@ class NetWorth implements NetWorthInterface
|
||||
foreach ($accounts as $account) {
|
||||
app('log')->debug(sprintf('Now at account #%d ("%s")', $account->id, $account->name));
|
||||
$currency = $this->getRepository()->getAccountCurrency($account);
|
||||
$currencyId = (int)$currency->id;
|
||||
$currencyId = $currency->id;
|
||||
$balance = '0';
|
||||
$nativeBalance = '0';
|
||||
if (array_key_exists((int)$account->id, $balances)) {
|
||||
$balance = $balances[(int)$account->id]['balance'] ?? '0';
|
||||
$nativeBalance = $balances[(int)$account->id]['native_balance'] ?? '0';
|
||||
if (array_key_exists($account->id, $balances)) {
|
||||
$balance = $balances[$account->id]['balance'] ?? '0';
|
||||
$nativeBalance = $balances[$account->id]['native_balance'] ?? '0';
|
||||
}
|
||||
app('log')->debug(sprintf('Balance is %s, native balance is %s', $balance, $nativeBalance));
|
||||
// always subtract virtual balance
|
||||
$virtualBalance = (string)$account->virtual_balance;
|
||||
$virtualBalance = $account->virtual_balance;
|
||||
if ('' !== $virtualBalance) {
|
||||
$balance = bcsub($balance, $virtualBalance);
|
||||
$nativeVirtualBalance = $converter->convert($default, $currency, $account->created_at, $virtualBalance);
|
||||
@ -126,7 +126,7 @@ class NetWorth implements NetWorthInterface
|
||||
'currency_name' => $currency->name,
|
||||
'currency_symbol' => $currency->symbol,
|
||||
'currency_decimal_places' => (int)$currency->decimal_places,
|
||||
'native_id' => (int)$default->id,
|
||||
'native_id' => $default->id,
|
||||
'native_code' => $default->code,
|
||||
'native_name' => $default->name,
|
||||
'native_symbol' => $default->symbol,
|
||||
@ -200,7 +200,7 @@ class NetWorth implements NetWorthInterface
|
||||
$balance = $balances[$account->id] ?? '0';
|
||||
|
||||
// always subtract virtual balance.
|
||||
$virtualBalance = (string)$account->virtual_balance;
|
||||
$virtualBalance = $account->virtual_balance;
|
||||
if ('' !== $virtualBalance) {
|
||||
$balance = bcsub($balance, $virtualBalance);
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ class BillController extends Controller
|
||||
'entries' => [],
|
||||
],
|
||||
];
|
||||
$currencyId = (int)$bill->transaction_currency_id;
|
||||
$currencyId = $bill->transaction_currency_id;
|
||||
foreach ($journals as $journal) {
|
||||
$date = $journal['date']->isoFormat((string)trans('config.month_and_day_js', [], $locale));
|
||||
$chartData[0]['entries'][$date] = $bill->amount_min; // minimum amount of bill
|
||||
|
@ -181,7 +181,7 @@ class BudgetController extends Controller
|
||||
while ($start <= $end) {
|
||||
$current = clone $start;
|
||||
$expenses = $this->opsRepository->sumExpenses($current, $current, null, $budgetCollection, $currency);
|
||||
$spent = $expenses[(int)$currency->id]['sum'] ?? '0';
|
||||
$spent = $expenses[$currency->id]['sum'] ?? '0';
|
||||
$amount = bcadd($amount, $spent);
|
||||
$format = $start->isoFormat((string)trans('config.month_and_day_js', [], $locale));
|
||||
$entries[$format] = $amount;
|
||||
|
@ -193,7 +193,7 @@ class CategoryController extends Controller
|
||||
if (null !== $category) {
|
||||
/** @var OperationsRepositoryInterface $opsRepository */
|
||||
$opsRepository = app(OperationsRepositoryInterface::class);
|
||||
$categoryId = (int)$category->id;
|
||||
$categoryId = $category->id;
|
||||
// this gives us all currencies
|
||||
$collection = new Collection([$category]);
|
||||
$expenses = $opsRepository->listExpenses($start, $end, null, $collection);
|
||||
|
@ -31,6 +31,7 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
|
||||
use FireflyIII\Http\Middleware\Installer;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
|
@ -102,7 +102,7 @@ class BoxController extends Controller
|
||||
// spent in this period, in budgets, for default currency.
|
||||
// also calculate spent per day.
|
||||
$spent = $opsRepository->sumExpenses($start, $end, null, null, $currency);
|
||||
$spentAmount = $spent[(int)$currency->id]['sum'] ?? '0';
|
||||
$spentAmount = $spent[$currency->id]['sum'] ?? '0';
|
||||
app('log')->debug(sprintf('Spent for default currency for all budgets in this period: %s', $spentAmount));
|
||||
|
||||
$days = $today->between($start, $end) ? $today->diffInDays($start) + 1 : $end->diffInDays($start) + 1;
|
||||
|
@ -108,7 +108,7 @@ class MassController extends Controller
|
||||
app('log')->debug(sprintf('Searching for ID #%d', $journalId));
|
||||
/** @var TransactionJournal|null $journal */
|
||||
$journal = $this->repository->find((int)$journalId);
|
||||
if (null !== $journal && (int)$journalId === (int)$journal->id) {
|
||||
if (null !== $journal && (int)$journalId === $journal->id) {
|
||||
$this->repository->destroyJournal($journal);
|
||||
++$count;
|
||||
app('log')->debug(sprintf('Deleted transaction journal #%d', $journalId));
|
||||
|
@ -288,7 +288,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
|
||||
$repository = app(OperationsRepositoryInterface::class);
|
||||
$repository->setUser($autoBudget->budget->user);
|
||||
$spent = $repository->sumExpenses($previousStart, $previousEnd, null, new Collection([$autoBudget->budget]), $autoBudget->transactionCurrency);
|
||||
$currencyId = (int)$autoBudget->transaction_currency_id;
|
||||
$currencyId = $autoBudget->transaction_currency_id;
|
||||
$spentAmount = $spent[$currencyId]['sum'] ?? '0';
|
||||
app('log')->debug(sprintf('Spent in previous budget period (%s-%s) is %s', $previousStart->format('Y-m-d'), $previousEnd->format('Y-m-d'), $spentAmount));
|
||||
|
||||
@ -352,7 +352,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
|
||||
$repository = app(OperationsRepositoryInterface::class);
|
||||
$repository->setUser($autoBudget->budget->user);
|
||||
$spent = $repository->sumExpenses($previousStart, $previousEnd, null, new Collection([$autoBudget->budget]), $autoBudget->transactionCurrency);
|
||||
$currencyId = (int)$autoBudget->transaction_currency_id;
|
||||
$currencyId = $autoBudget->transaction_currency_id;
|
||||
$spentAmount = $spent[$currencyId]['sum'] ?? '0';
|
||||
app('log')->debug(sprintf('Spent in previous budget period (%s-%s) is %s', $previousStart->format('Y-m-d'), $previousEnd->format('Y-m-d'), $spentAmount));
|
||||
|
||||
|
@ -468,7 +468,7 @@ class CreateRecurringTransactions implements ShouldQueue
|
||||
'type' => null === $first->transactionType ? strtolower($recurrence->transactionType->type) : strtolower($first->transactionType->type),
|
||||
'date' => $date,
|
||||
'user' => $recurrence->user_id,
|
||||
'currency_id' => (int)$transaction->transaction_currency_id,
|
||||
'currency_id' => $transaction->transaction_currency_id,
|
||||
'currency_code' => null,
|
||||
'description' => $first->description,
|
||||
'amount' => $transaction->amount,
|
||||
@ -485,7 +485,7 @@ class CreateRecurringTransactions implements ShouldQueue
|
||||
'foreign_amount' => $transaction->foreign_amount,
|
||||
'reconciled' => false,
|
||||
'identifier' => $index,
|
||||
'recurrence_id' => (int)$recurrence->id,
|
||||
'recurrence_id' => $recurrence->id,
|
||||
'order' => $index,
|
||||
'notes' => (string)trans('firefly.created_from_recurrence', ['id' => $recurrence->id, 'title' => $recurrence->title]),
|
||||
'tags' => $this->repository->getTags($transaction),
|
||||
|
@ -25,6 +25,8 @@ namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
@ -42,36 +44,36 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* Class Account
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $user_id
|
||||
* @property int|string $account_type_id
|
||||
* @property string $name
|
||||
* @property string|float|null $virtual_balance
|
||||
* @property string|null $iban
|
||||
* @property bool $active
|
||||
* @property bool $encrypted
|
||||
* @property int|string $order
|
||||
* @property-read Collection|AccountMeta[] $accountMeta
|
||||
* @property-read int|null $account_meta_count
|
||||
* @property AccountType $accountType
|
||||
* @property-read Collection|Attachment[] $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read string $account_number
|
||||
* @property-read string $edit_name
|
||||
* @property-read Collection|Location[] $locations
|
||||
* @property-read int|null $locations_count
|
||||
* @property-read Collection|Note[] $notes
|
||||
* @property-read int|null $notes_count
|
||||
* @property-read Collection|ObjectGroup[] $objectGroups
|
||||
* @property-read int|null $object_groups_count
|
||||
* @property-read Collection|PiggyBank[] $piggyBanks
|
||||
* @property-read int|null $piggy_banks_count
|
||||
* @property-read Collection|Transaction[] $transactions
|
||||
* @property-read int|null $transactions_count
|
||||
* @property-read User $user
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $user_id
|
||||
* @property int $account_type_id
|
||||
* @property string $name
|
||||
* @property string $virtual_balance
|
||||
* @property string|null $iban
|
||||
* @property bool $active
|
||||
* @property bool $encrypted
|
||||
* @property int|string $order
|
||||
* @property-read Collection|AccountMeta[] $accountMeta
|
||||
* @property-read int|null $account_meta_count
|
||||
* @property AccountType $accountType
|
||||
* @property-read Collection|Attachment[] $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read string $account_number
|
||||
* @property-read string $edit_name
|
||||
* @property-read Collection|Location[] $locations
|
||||
* @property-read int|null $locations_count
|
||||
* @property-read Collection|Note[] $notes
|
||||
* @property-read int|null $notes_count
|
||||
* @property-read Collection|ObjectGroup[] $objectGroups
|
||||
* @property-read int|null $object_groups_count
|
||||
* @property-read Collection|PiggyBank[] $piggyBanks
|
||||
* @property-read int|null $piggy_banks_count
|
||||
* @property-read Collection|Transaction[] $transactions
|
||||
* @property-read int|null $transactions_count
|
||||
* @property-read User $user
|
||||
* @method static EloquentBuilder|Account accountTypeIn($types)
|
||||
* @method static EloquentBuilder|Account newModelQuery()
|
||||
* @method static EloquentBuilder|Account newQuery()
|
||||
@ -91,27 +93,28 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static EloquentBuilder|Account whereVirtualBalance($value)
|
||||
* @method static Builder|Account withTrashed()
|
||||
* @method static Builder|Account withoutTrashed()
|
||||
* @property Carbon $lastActivityDate
|
||||
* @property string $startBalance
|
||||
* @property string $endBalance
|
||||
* @property string $difference
|
||||
* @property string $interest
|
||||
* @property string $interestPeriod
|
||||
* @property string $accountTypeString
|
||||
* @property Location $location
|
||||
* @property string $liability_direction
|
||||
* @property string $current_debt
|
||||
* @property int|null $user_group_id
|
||||
* @property Carbon $lastActivityDate
|
||||
* @property string $startBalance
|
||||
* @property string $endBalance
|
||||
* @property string $difference
|
||||
* @property string $interest
|
||||
* @property string $interestPeriod
|
||||
* @property string $accountTypeString
|
||||
* @property Location $location
|
||||
* @property string $liability_direction
|
||||
* @property string $current_debt
|
||||
* @property int $user_group_id
|
||||
* @method static EloquentBuilder|Account whereUserGroupId($value)
|
||||
* @property-read UserGroup|null $userGroup
|
||||
* @property-read UserGroup|null $userGroup
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Account extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use ReturnsIntegerIdTrait;
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
@ -124,7 +127,7 @@ class Account extends Model
|
||||
|
||||
protected $fillable = ['user_id', 'user_group_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban'];
|
||||
|
||||
protected $hidden = ['encrypted'];
|
||||
protected $hidden = ['encrypted'];
|
||||
private bool $joinedAccountTypes = false;
|
||||
|
||||
/**
|
||||
@ -296,7 +299,29 @@ class Account extends Model
|
||||
protected function virtualBalance(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn ($value) => (string)$value,
|
||||
get: static fn($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Get the user ID
|
||||
*
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function accountTypeId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function accountId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,19 +23,20 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Class AccountMeta
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property int|string $account_id
|
||||
* @property int $account_id
|
||||
* @property string $name
|
||||
* @property mixed $data
|
||||
* @property-read Account $account
|
||||
@ -52,6 +53,7 @@ use Carbon\Carbon;
|
||||
*/
|
||||
class AccountMeta extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
@ -88,4 +90,5 @@ class AccountMeta extends Model
|
||||
{
|
||||
$this->attributes['data'] = json_encode($value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,17 +23,18 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* FireflyIII\Models\AccountType
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string $type
|
||||
@ -50,6 +51,8 @@ use Carbon\Carbon;
|
||||
*/
|
||||
class AccountType extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
|
||||
public const ASSET = 'Asset account';
|
||||
public const BENEFICIARY = 'Beneficiary account';
|
||||
public const CASH = 'Cash account';
|
||||
@ -66,7 +69,6 @@ class AccountType extends Model
|
||||
public const REVENUE = 'Revenue account';
|
||||
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
@ -82,4 +84,6 @@ class AccountType extends Model
|
||||
{
|
||||
return $this->hasMany(Account::class);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -23,8 +23,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@ -32,18 +36,17 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Carbon\Carbon;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* FireflyIII\Models\Attachment
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $user_id
|
||||
* @property int|string $attachable_id
|
||||
* @property int $user_id
|
||||
* @property int $attachable_id
|
||||
* @property string $attachable_type
|
||||
* @property bool $file_exists
|
||||
* @property string $md5
|
||||
@ -51,7 +54,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property string|null $title
|
||||
* @property string|null $description
|
||||
* @property string $mime
|
||||
* @property int|string $size
|
||||
* @property int|string $size
|
||||
* @property bool $uploaded
|
||||
* @property string $notes_text
|
||||
* @property-read Model|Eloquent $attachable
|
||||
@ -78,14 +81,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereUserId($value)
|
||||
* @method static Builder|Attachment withTrashed()
|
||||
* @method static Builder|Attachment withoutTrashed()
|
||||
* @property int|null $user_group_id
|
||||
* @property int $user_group_id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereUserGroupId($value)
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Attachment extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
@ -156,4 +160,15 @@ class Attachment extends Model
|
||||
{
|
||||
return $this->morphMany(Note::class, 'noteable');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function attachableId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,12 +24,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Class AuditLogEntry
|
||||
@ -42,13 +44,13 @@ use Carbon\Carbon;
|
||||
* @method static Builder|AuditLogEntry query()
|
||||
* @method static \Illuminate\Database\Query\Builder|AuditLogEntry withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|AuditLogEntry withoutTrashed()
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $auditable_id
|
||||
* @property int $auditable_id
|
||||
* @property string $auditable_type
|
||||
* @property int|string $changer_id
|
||||
* @property int $changer_id
|
||||
* @property string $changer_type
|
||||
* @property string $action
|
||||
* @property array|null $before
|
||||
@ -68,6 +70,7 @@ use Carbon\Carbon;
|
||||
*/
|
||||
class AuditLogEntry extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $casts
|
||||
@ -92,4 +95,26 @@ class AuditLogEntry extends Model
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function auditableId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function changerId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@ -35,14 +36,14 @@ use Carbon\Carbon;
|
||||
/**
|
||||
* FireflyIII\Models\AutoBudget
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $budget_id
|
||||
* @property int|string $transaction_currency_id
|
||||
* @property int|string $auto_budget_type
|
||||
* @property string|float $amount
|
||||
* @property int $budget_id
|
||||
* @property int $transaction_currency_id
|
||||
* @property int|string $auto_budget_type
|
||||
* @property string $amount
|
||||
* @property string $period
|
||||
* @property-read Budget $budget
|
||||
* @property-read TransactionCurrency $transactionCurrency
|
||||
@ -65,6 +66,7 @@ use Carbon\Carbon;
|
||||
*/
|
||||
class AutoBudget extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
public const AUTO_BUDGET_ADJUSTED = 3;
|
||||
@ -97,4 +99,25 @@ class AutoBudget extends Model
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function budgetId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function transactionCurrencyId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@ -36,13 +38,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\AvailableBudget
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $user_id
|
||||
* @property int|string $transaction_currency_id
|
||||
* @property string|float $amount
|
||||
* @property int $user_id
|
||||
* @property int $transaction_currency_id
|
||||
* @property string $amount
|
||||
* @property Carbon $start_date
|
||||
* @property Carbon $end_date
|
||||
* @property-read TransactionCurrency $transactionCurrency
|
||||
@ -62,14 +64,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget whereUserId($value)
|
||||
* @method static Builder|AvailableBudget withTrashed()
|
||||
* @method static Builder|AvailableBudget withoutTrashed()
|
||||
* @property int|null $user_group_id
|
||||
* @property int $user_group_id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget whereUserGroupId($value)
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class AvailableBudget extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
@ -131,4 +134,14 @@ class AvailableBudget extends Model
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function transactionCurrencyId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ declare(strict_types=1);
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
@ -41,26 +43,26 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\Bill
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $user_id
|
||||
* @property int|null $transaction_currency_id
|
||||
* @property int $user_id
|
||||
* @property int $transaction_currency_id
|
||||
* @property string $name
|
||||
* @property string $match
|
||||
* @property string|float $amount_min
|
||||
* @property string|float $amount_max
|
||||
* @property string $amount_min
|
||||
* @property string $amount_max
|
||||
* @property Carbon $date
|
||||
* @property Carbon|null $end_date
|
||||
* @property Carbon|null $extension_date
|
||||
* @property string $repeat_freq
|
||||
* @property int|string $skip
|
||||
* @property int|string $skip
|
||||
* @property bool $automatch
|
||||
* @property bool $active
|
||||
* @property bool $name_encrypted
|
||||
* @property bool $match_encrypted
|
||||
* @property int|string $order
|
||||
* @property int|string $order
|
||||
* @property-read Collection|Attachment[] $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read Collection|Note[] $notes
|
||||
@ -97,14 +99,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Bill whereUserId($value)
|
||||
* @method static Builder|Bill withTrashed()
|
||||
* @method static Builder|Bill withoutTrashed()
|
||||
* @property int|null $user_group_id
|
||||
* @property int $user_group_id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Bill whereUserGroupId($value)
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Bill extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
@ -255,4 +258,16 @@ class Bill extends Model
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function transactionCurrencyId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@ -39,15 +41,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\Budget
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $user_id
|
||||
* @property int $user_id
|
||||
* @property string $name
|
||||
* @property bool $active
|
||||
* @property bool $encrypted
|
||||
* @property int|string $order
|
||||
* @property int|string $order
|
||||
* @property-read Collection|Attachment[] $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read Collection|AutoBudget[] $autoBudgets
|
||||
@ -75,7 +77,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static Builder|Budget withTrashed()
|
||||
* @method static Builder|Budget withoutTrashed()
|
||||
* @property string $email
|
||||
* @property int|null $user_group_id
|
||||
* @property int $user_group_id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Budget whereUserGroupId($value)
|
||||
* @property-read Collection|Note[] $notes
|
||||
* @property-read int|null $notes_count
|
||||
@ -83,8 +85,9 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
*/
|
||||
class Budget extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
@ -177,4 +180,6 @@ class Budget extends Model
|
||||
{
|
||||
return $this->belongsToMany(Transaction::class, 'budget_transaction', 'budget_id');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ use Eloquent;
|
||||
use FireflyIII\Events\Model\BudgetLimit\Created;
|
||||
use FireflyIII\Events\Model\BudgetLimit\Deleted;
|
||||
use FireflyIII\Events\Model\BudgetLimit\Updated;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@ -37,17 +38,17 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
/**
|
||||
* FireflyIII\Models\BudgetLimit
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property int|string $budget_id
|
||||
* @property int|null $transaction_currency_id
|
||||
* @property int $budget_id
|
||||
* @property int $transaction_currency_id
|
||||
* @property Carbon $start_date
|
||||
* @property Carbon|null $end_date
|
||||
* @property string|float $amount
|
||||
* @property string $amount
|
||||
* @property string $spent
|
||||
* @property string|null $period
|
||||
* @property int|string $generated
|
||||
* @property int|string $generated
|
||||
* @property-read Budget $budget
|
||||
* @property-read TransactionCurrency|null $transactionCurrency
|
||||
* @method static Builder|BudgetLimit newModelQuery()
|
||||
@ -67,6 +68,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
*/
|
||||
class BudgetLimit extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
@ -135,4 +137,26 @@ class BudgetLimit extends Model
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function budgetId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function transactionCurrencyId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@ -34,15 +35,15 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\Category
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $user_id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int $user_id
|
||||
* @property string $name
|
||||
* @property Carbon $lastActivity
|
||||
* @property bool $encrypted
|
||||
@ -68,14 +69,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Category whereUserId($value)
|
||||
* @method static Builder|Category withTrashed()
|
||||
* @method static Builder|Category withoutTrashed()
|
||||
* @property int|null $user_group_id
|
||||
* @property int $user_group_id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Category whereUserGroupId($value)
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Category extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
@ -151,4 +153,5 @@ class Category extends Model
|
||||
{
|
||||
return $this->belongsToMany(Transaction::class, 'category_transaction', 'category_id');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,16 +23,16 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\Configuration
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
@ -54,6 +54,7 @@ use Carbon\Carbon;
|
||||
*/
|
||||
class Configuration extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
@ -87,4 +88,6 @@ class Configuration extends Model
|
||||
{
|
||||
$this->attributes['data'] = json_encode($value);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -22,8 +22,9 @@
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
@ -35,16 +36,16 @@ use Carbon\Carbon;
|
||||
/**
|
||||
* Class CurrencyExchangeRate
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
* @property int|string $user_id
|
||||
* @property int|string $from_currency_id
|
||||
* @property int|string $to_currency_id
|
||||
* @property int $user_id
|
||||
* @property int $from_currency_id
|
||||
* @property int $to_currency_id
|
||||
* @property Carbon $date
|
||||
* @property string|float $rate
|
||||
* @property string|null $user_rate
|
||||
* @property string $rate
|
||||
* @property string $user_rate
|
||||
* @property-read TransactionCurrency $fromCurrency
|
||||
* @property-read TransactionCurrency $toCurrency
|
||||
* @property-read User $user
|
||||
@ -61,7 +62,7 @@ use Carbon\Carbon;
|
||||
* @method static Builder|CurrencyExchangeRate whereUpdatedAt($value)
|
||||
* @method static Builder|CurrencyExchangeRate whereUserId($value)
|
||||
* @method static Builder|CurrencyExchangeRate whereUserRate($value)
|
||||
* @property int|null $user_group_id
|
||||
* @property int $user_group_id
|
||||
* @method static Builder|CurrencyExchangeRate whereUserGroupId($value)
|
||||
* @method static Builder|CurrencyExchangeRate onlyTrashed()
|
||||
* @method static Builder|CurrencyExchangeRate withTrashed()
|
||||
@ -70,7 +71,10 @@ use Carbon\Carbon;
|
||||
*/
|
||||
class CurrencyExchangeRate extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
@ -126,4 +130,26 @@ class CurrencyExchangeRate extends Model
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function fromCurrencyId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function toCurrencyId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -24,23 +24,25 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* Class GroupMembership
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
* @property int|string $user_id
|
||||
* @property int|string $user_group_id
|
||||
* @property int|string $user_role_id
|
||||
* @property int $user_id
|
||||
* @property int $user_group_id
|
||||
* @property int $user_role_id
|
||||
* @property-read User $user
|
||||
* @property-read UserGroup $userGroup
|
||||
* @property-read UserRole $userRole
|
||||
@ -58,6 +60,9 @@ use Carbon\Carbon;
|
||||
*/
|
||||
class GroupMembership extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
|
||||
protected $fillable = ['user_id', 'user_group_id', 'user_role_id'];
|
||||
|
||||
/**
|
||||
@ -83,4 +88,16 @@ class GroupMembership extends Model
|
||||
{
|
||||
return $this->belongsTo(UserRole::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function userRoleId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -26,12 +26,13 @@ namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* Class InvitedUser
|
||||
*
|
||||
@ -39,10 +40,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static Builder|InvitedUser newModelQuery()
|
||||
* @method static Builder|InvitedUser newQuery()
|
||||
* @method static Builder|InvitedUser query()
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property int|string $user_id
|
||||
* @property int $user_id
|
||||
* @property string $email
|
||||
* @property string $invite_code
|
||||
* @property Carbon $expires
|
||||
@ -59,6 +60,9 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
*/
|
||||
class InvitedUser extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'expires' => 'datetime',
|
||||
@ -93,4 +97,6 @@ class InvitedUser extends Model
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -23,19 +23,19 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Carbon\Carbon;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\LinkType
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
@ -64,6 +64,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
*/
|
||||
class LinkType extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
@ -106,4 +107,6 @@ class LinkType extends Model
|
||||
{
|
||||
return $this->hasMany(TransactionJournalLink::class);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -24,22 +24,23 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\Location
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $locatable_id
|
||||
* @property int $locatable_id
|
||||
* @property string $locatable_type
|
||||
* @property float|null $latitude
|
||||
* @property float|null $longitude
|
||||
@ -63,6 +64,7 @@ use Carbon\Carbon;
|
||||
*/
|
||||
class Location extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
@ -110,4 +112,16 @@ class Location extends Model
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function locatableId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -23,21 +23,22 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\Note
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $noteable_id
|
||||
* @property int $noteable_id
|
||||
* @property string $noteable_type
|
||||
* @property string|null $title
|
||||
* @property string|null $text
|
||||
@ -60,6 +61,7 @@ use Carbon\Carbon;
|
||||
*/
|
||||
class Note extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
@ -80,4 +82,16 @@ class Note extends Model
|
||||
{
|
||||
return $this->morphTo();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function noteableId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -24,26 +24,28 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphToMany;
|
||||
use Carbon\Carbon;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\ObjectGroup
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int|string $user_id
|
||||
* @property int $id
|
||||
* @property int $user_id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property string $title
|
||||
* @property int|string $order
|
||||
* @property int $order
|
||||
* @property-read Collection|Account[] $accounts
|
||||
* @property-read int|null $accounts_count
|
||||
* @property-read Collection|Bill[] $bills
|
||||
@ -61,12 +63,14 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static Builder|ObjectGroup whereTitle($value)
|
||||
* @method static Builder|ObjectGroup whereUpdatedAt($value)
|
||||
* @method static Builder|ObjectGroup whereUserId($value)
|
||||
* @property int|null $user_group_id
|
||||
* @property int $user_group_id
|
||||
* @method static Builder|ObjectGroup whereUserGroupId($value)
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class ObjectGroup extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
@ -130,4 +134,16 @@ class ObjectGroup extends Model
|
||||
{
|
||||
return $this->morphedByMany(PiggyBank::class, 'object_groupable');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,20 +35,20 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Carbon\Carbon;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\PiggyBank
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $account_id
|
||||
* @property int $account_id
|
||||
* @property string $name
|
||||
* @property string|float $targetamount
|
||||
* @property string $targetamount
|
||||
* @property Carbon|null $startdate
|
||||
* @property Carbon|null $targetdate
|
||||
* @property int|string $order
|
||||
* @property int|string $order
|
||||
* @property bool $active
|
||||
* @property bool $encrypted
|
||||
* @property-read Account $account
|
||||
@ -84,6 +84,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
*/
|
||||
class PiggyBank extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
protected $casts
|
||||
@ -192,4 +193,14 @@ class PiggyBank extends Model
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function accountId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -29,14 +29,14 @@ use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\PiggyBankEvent
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property int|string $piggy_bank_id
|
||||
* @property int $piggy_bank_id
|
||||
* @property int|null $transaction_journal_id
|
||||
* @property Carbon $date
|
||||
* @property string $amount
|
||||
@ -56,6 +56,7 @@ use Carbon\Carbon;
|
||||
*/
|
||||
class PiggyBankEvent extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
@ -104,4 +105,14 @@ class PiggyBankEvent extends Model
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function piggyBankId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -29,18 +29,18 @@ use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\PiggyBankRepetition
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property int|string $piggy_bank_id
|
||||
* @property Carbon|null $startdate
|
||||
* @property Carbon|null $targetdate
|
||||
* @property string|float $currentamount
|
||||
* @property-read PiggyBank $piggyBank
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property int $piggy_bank_id
|
||||
* @property Carbon|null $startdate
|
||||
* @property Carbon|null $targetdate
|
||||
* @property string $currentamount
|
||||
* @property-read PiggyBank $piggyBank
|
||||
* @method static EloquentBuilder|PiggyBankRepetition newModelQuery()
|
||||
* @method static EloquentBuilder|PiggyBankRepetition newQuery()
|
||||
* @method static EloquentBuilder|PiggyBankRepetition onDates(Carbon $start, Carbon $target)
|
||||
@ -57,6 +57,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
*/
|
||||
class PiggyBankRepetition extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
@ -132,4 +133,14 @@ class PiggyBankRepetition extends Model
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function piggyBankId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -23,21 +23,22 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Carbon\Carbon;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\Preference
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property int|string $user_id
|
||||
* @property int $user_id
|
||||
* @property string $name
|
||||
* @property int|string|array|null $data
|
||||
* @property-read User $user
|
||||
@ -54,6 +55,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
*/
|
||||
class Preference extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
|
@ -25,7 +25,9 @@ namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@ -34,22 +36,22 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\Recurrence
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $user_id
|
||||
* @property int|string $transaction_type_id
|
||||
* @property int $user_id
|
||||
* @property int $transaction_type_id
|
||||
* @property string $title
|
||||
* @property string $description
|
||||
* @property Carbon|null $first_date
|
||||
* @property Carbon|null $repeat_until
|
||||
* @property Carbon|null $latest_date
|
||||
* @property int|string $repetitions
|
||||
* @property int|string $repetitions
|
||||
* @property bool $apply_rules
|
||||
* @property bool $active
|
||||
* @property-read Collection|Attachment[] $attachments
|
||||
@ -85,13 +87,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Recurrence whereUserId($value)
|
||||
* @method static Builder|Recurrence withTrashed()
|
||||
* @method static Builder|Recurrence withoutTrashed()
|
||||
* @property int|null $user_group_id
|
||||
* @property int $user_group_id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Recurrence whereUserGroupId($value)
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Recurrence extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
|
||||
|
||||
protected $casts
|
||||
@ -201,4 +205,14 @@ class Recurrence extends Model
|
||||
{
|
||||
return $this->belongsTo(TransactionType::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function transactionTypeId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -23,21 +23,22 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\RecurrenceMeta
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $recurrence_id
|
||||
* @property int $recurrence_id
|
||||
* @property string $name
|
||||
* @property mixed $value
|
||||
* @property-read Recurrence $recurrence
|
||||
@ -58,6 +59,7 @@ use Carbon\Carbon;
|
||||
*/
|
||||
class RecurrenceMeta extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
@ -81,4 +83,14 @@ class RecurrenceMeta extends Model
|
||||
{
|
||||
return $this->belongsTo(Recurrence::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function recurrenceId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -23,25 +23,26 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\RecurrenceRepetition
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $recurrence_id
|
||||
* @property int $recurrence_id
|
||||
* @property string $repetition_type
|
||||
* @property string $repetition_moment
|
||||
* @property int|string $repetition_skip
|
||||
* @property int|string $weekend
|
||||
* @property int|string $repetition_skip
|
||||
* @property int|string $weekend
|
||||
* @property-read Recurrence $recurrence
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceRepetition newModelQuery()
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceRepetition newQuery()
|
||||
@ -62,6 +63,7 @@ use Carbon\Carbon;
|
||||
*/
|
||||
class RecurrenceRepetition extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
public const WEEKEND_DO_NOTHING = 1;
|
||||
@ -92,4 +94,14 @@ class RecurrenceRepetition extends Model
|
||||
{
|
||||
return $this->belongsTo(Recurrence::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function recurrenceId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -32,21 +32,21 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\RecurrenceTransaction
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $recurrence_id
|
||||
* @property int|string $transaction_currency_id
|
||||
* @property int|string|null $foreign_currency_id
|
||||
* @property int|string $source_id
|
||||
* @property int|string $destination_id
|
||||
* @property string|float $amount
|
||||
* @property string|float|null $foreign_amount
|
||||
* @property int $recurrence_id
|
||||
* @property int $transaction_currency_id
|
||||
* @property int|string|null $foreign_currency_id
|
||||
* @property int $source_id
|
||||
* @property int $destination_id
|
||||
* @property string $amount
|
||||
* @property string $foreign_amount
|
||||
* @property string $description
|
||||
* @property-read Account $destinationAccount
|
||||
* @property-read TransactionCurrency|null $foreignCurrency
|
||||
@ -80,6 +80,7 @@ use Carbon\Carbon;
|
||||
*/
|
||||
class RecurrenceTransaction extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
@ -181,5 +182,56 @@ class RecurrenceTransaction extends Model
|
||||
return Attribute::make(
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function recurrenceId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function transactionCurrencyId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function sourceId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function destinationId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function userId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -23,21 +23,22 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\RecurrenceTransactionMeta
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $rt_id
|
||||
* @property int|string $rt_id
|
||||
* @property string $name
|
||||
* @property mixed $value
|
||||
* @property-read RecurrenceTransaction $recurrenceTransaction
|
||||
@ -58,6 +59,7 @@ use Carbon\Carbon;
|
||||
*/
|
||||
class RecurrenceTransactionMeta extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
@ -81,4 +83,14 @@ class RecurrenceTransactionMeta extends Model
|
||||
{
|
||||
return $this->belongsTo(RecurrenceTransaction::class, 'rt_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function rtId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -23,18 +23,19 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* FireflyIII\Models\Role
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string $name
|
||||
@ -55,6 +56,7 @@ use Carbon\Carbon;
|
||||
*/
|
||||
class Role extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
|
@ -23,29 +23,31 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Carbon\Carbon;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\Rule
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $user_id
|
||||
* @property int|string $rule_group_id
|
||||
* @property int $user_id
|
||||
* @property int $rule_group_id
|
||||
* @property string $title
|
||||
* @property string|null $description
|
||||
* @property int|string $order
|
||||
* @property int $order
|
||||
* @property bool $active
|
||||
* @property bool $stop_processing
|
||||
* @property bool $strict
|
||||
@ -74,14 +76,16 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Rule whereUserId($value)
|
||||
* @method static Builder|Rule withTrashed()
|
||||
* @method static Builder|Rule withoutTrashed()
|
||||
* @property int|null $user_group_id
|
||||
* @property int $user_group_id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Rule whereUserGroupId($value)
|
||||
* @property-read UserGroup|null $userGroup
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Rule extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
|
||||
|
||||
protected $casts
|
||||
@ -170,4 +174,24 @@ class Rule extends Model
|
||||
{
|
||||
return $this->belongsTo(UserGroup::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function ruleGroupId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -23,22 +23,23 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\RuleAction
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property int|string $rule_id
|
||||
* @property string|null $action_type
|
||||
* @property string|null $action_value
|
||||
* @property int|string $order
|
||||
* @property int $rule_id
|
||||
* @property string|null $action_type
|
||||
* @property string|null $action_value
|
||||
* @property int|string $order
|
||||
* @property bool $active
|
||||
* @property bool $stop_processing
|
||||
* @property-read Rule $rule
|
||||
@ -58,6 +59,7 @@ use Carbon\Carbon;
|
||||
*/
|
||||
class RuleAction extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
@ -78,4 +80,14 @@ class RuleAction extends Model
|
||||
{
|
||||
return $this->belongsTo(Rule::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function ruleId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@ -31,20 +33,19 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Carbon\Carbon;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\RuleGroup
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $user_id
|
||||
* @property string|null $title
|
||||
* @property int $user_id
|
||||
* @property string|null $title
|
||||
* @property string|null $description
|
||||
* @property int|string $order
|
||||
* @property int|string $order
|
||||
* @property bool $active
|
||||
* @property bool $stop_processing
|
||||
* @property Collection|Rule[] $rules
|
||||
@ -66,13 +67,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup whereUserId($value)
|
||||
* @method static Builder|RuleGroup withTrashed()
|
||||
* @method static Builder|RuleGroup withoutTrashed()
|
||||
* @property int|null $user_group_id
|
||||
* @property int $user_group_id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup whereUserGroupId($value)
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class RuleGroup extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
|
||||
|
||||
protected $casts
|
||||
|
@ -23,22 +23,23 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\RuleTrigger
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property int|string $rule_id
|
||||
* @property string|null $trigger_type
|
||||
* @property string|null $trigger_value
|
||||
* @property int|string $order
|
||||
* @property int $rule_id
|
||||
* @property string|null $trigger_type
|
||||
* @property string|null $trigger_value
|
||||
* @property int|string $order
|
||||
* @property bool $active
|
||||
* @property bool $stop_processing
|
||||
* @property-read Rule $rule
|
||||
@ -58,6 +59,7 @@ use Carbon\Carbon;
|
||||
*/
|
||||
class RuleTrigger extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
@ -78,4 +80,14 @@ class RuleTrigger extends Model
|
||||
{
|
||||
return $this->belongsTo(Rule::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function ruleId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@ -32,17 +34,16 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Carbon\Carbon;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\Tag
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $user_id
|
||||
* @property int $user_id
|
||||
* @property string $tag
|
||||
* @property string $tagMode
|
||||
* @property Carbon|null $date
|
||||
@ -75,13 +76,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Tag whereZoomLevel($value)
|
||||
* @method static Builder|Tag withTrashed()
|
||||
* @method static Builder|Tag withoutTrashed()
|
||||
* @property int|null $user_group_id
|
||||
* @property int $user_group_id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|Tag whereUserGroupId($value)
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Tag extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
|
||||
|
||||
protected $casts
|
||||
|
@ -33,35 +33,35 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\Transaction
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property bool $reconciled
|
||||
* @property int|string $account_id
|
||||
* @property int|string $transaction_journal_id
|
||||
* @property string|null $description
|
||||
* @property int|null $transaction_currency_id
|
||||
* @property string|null $modified
|
||||
* @property string|null $modified_foreign
|
||||
* @property string $date
|
||||
* @property string $max_date
|
||||
* @property string|float $amount
|
||||
* @property string|float|null $foreign_amount
|
||||
* @property int|null $foreign_currency_id
|
||||
* @property int $identifier
|
||||
* @property-read Account $account
|
||||
* @property-read Collection|Budget[] $budgets
|
||||
* @property-read int|null $budgets_count
|
||||
* @property-read Collection|Category[] $categories
|
||||
* @property-read int|null $categories_count
|
||||
* @property-read TransactionCurrency|null $foreignCurrency
|
||||
* @property-read TransactionCurrency|null $transactionCurrency
|
||||
* @property-read TransactionJournal $transactionJournal
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property bool $reconciled
|
||||
* @property int $account_id
|
||||
* @property int $transaction_journal_id
|
||||
* @property string|null $description
|
||||
* @property int|null $transaction_currency_id
|
||||
* @property string|null $modified
|
||||
* @property string|null $modified_foreign
|
||||
* @property string $date
|
||||
* @property string $max_date
|
||||
* @property string $amount
|
||||
* @property string|null $foreign_amount
|
||||
* @property int|null $foreign_currency_id
|
||||
* @property int $identifier
|
||||
* @property-read Account $account
|
||||
* @property-read Collection|Budget[] $budgets
|
||||
* @property-read int|null $budgets_count
|
||||
* @property-read Collection|Category[] $categories
|
||||
* @property-read int|null $categories_count
|
||||
* @property-read TransactionCurrency|null $foreignCurrency
|
||||
* @property-read TransactionCurrency|null $transactionCurrency
|
||||
* @property-read TransactionJournal $transactionJournal
|
||||
* @method static Builder|Transaction after(Carbon $date)
|
||||
* @method static Builder|Transaction before(Carbon $date)
|
||||
* @method static Builder|Transaction newModelQuery()
|
||||
@ -84,12 +84,13 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
* @method static Builder|Transaction whereUpdatedAt($value)
|
||||
* @method static \Illuminate\Database\Query\Builder|Transaction withTrashed()
|
||||
* @method static \Illuminate\Database\Query\Builder|Transaction withoutTrashed()
|
||||
* @property int|string $the_count
|
||||
* @property int|string $the_count
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Transaction extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
@ -275,4 +276,23 @@ class Transaction extends Model
|
||||
get: static fn ($value) => (string)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function accountId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function transactionJournalId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -33,11 +33,11 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\TransactionCurrency
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
@ -77,12 +77,11 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
*/
|
||||
class TransactionCurrency extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
public ?bool $userEnabled;
|
||||
public ?bool $userDefault;
|
||||
|
||||
|
||||
public ?bool $userEnabled;
|
||||
protected $casts
|
||||
= [
|
||||
'created_at' => 'datetime',
|
||||
@ -124,7 +123,7 @@ class TransactionCurrency extends Model
|
||||
{
|
||||
$current = $user->userGroup->currencies()->where('transaction_currencies.id', $this->id)->first();
|
||||
$default = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup);
|
||||
$this->userDefault = (int)$default->id === (int)$this->id;
|
||||
$this->userDefault = $default->id === $this->id;
|
||||
$this->userEnabled = null !== $current;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@ -31,17 +33,16 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Carbon\Carbon;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\TransactionGroup
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $user_id
|
||||
* @property int $user_id
|
||||
* @property string|null $title
|
||||
* @property-read Collection|TransactionJournal[] $transactionJournals
|
||||
* @property-read int|null $transaction_journals_count
|
||||
@ -58,14 +59,16 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionGroup whereUserId($value)
|
||||
* @method static Builder|TransactionGroup withTrashed()
|
||||
* @method static Builder|TransactionGroup withoutTrashed()
|
||||
* @property int|null $user_group_id
|
||||
* @property int $user_group_id
|
||||
* @method static \Illuminate\Database\Eloquent\Builder|TransactionGroup whereUserGroupId($value)
|
||||
* @property-read UserGroup|null $userGroup
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class TransactionGroup extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
|
||||
|
||||
protected $casts
|
||||
|
@ -25,9 +25,11 @@ namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@ -37,20 +39,20 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\TransactionJournal
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $user_id
|
||||
* @property int |string $transaction_type_id
|
||||
* @property int|string|null $transaction_group_id
|
||||
* @property int|string|null $bill_id
|
||||
* @property int|string|null $transaction_currency_id
|
||||
* @property string|null $description
|
||||
* @property int $user_id
|
||||
* @property int $transaction_type_id
|
||||
* @property int|string|null $transaction_group_id
|
||||
* @property int|string|null $bill_id
|
||||
* @property int|string|null $transaction_currency_id
|
||||
* @property string|null $description
|
||||
* @property Carbon $date
|
||||
* @property Carbon|null $interest_date
|
||||
* @property Carbon|null $book_date
|
||||
@ -114,8 +116,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @method static \Illuminate\Database\Query\Builder|TransactionJournal withoutTrashed()
|
||||
* @property-read Collection|Location[] $locations
|
||||
* @property-read int|null $locations_count
|
||||
* @property int|string $the_count
|
||||
* @property int|null $user_group_id
|
||||
* @property int|string $the_count
|
||||
* @property int $user_group_id
|
||||
* @method static EloquentBuilder|TransactionJournal whereUserGroupId($value)
|
||||
* @property-read Collection<int, AuditLogEntry> $auditLogEntries
|
||||
* @property-read int|null $audit_log_entries_count
|
||||
@ -124,7 +126,9 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
class TransactionJournal extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
|
||||
|
||||
protected $casts
|
||||
@ -390,4 +394,14 @@ class TransactionJournal extends Model
|
||||
{
|
||||
return $this->hasMany(Transaction::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function transactionTypeId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -26,19 +26,20 @@ namespace FireflyIII\Models;
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\MorphMany;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\TransactionJournalLink
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|int $link_type_id
|
||||
* @property int $link_type_id
|
||||
* @property int $source_id
|
||||
* @property int $destination_id
|
||||
* @property string|null $comment
|
||||
@ -63,6 +64,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
*/
|
||||
class TransactionJournalLink extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
@ -129,4 +131,32 @@ class TransactionJournalLink extends Model
|
||||
{
|
||||
return $this->belongsTo(TransactionJournal::class, 'source_id');
|
||||
}
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function linkTypeId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function sourceId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function destinationId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -23,20 +23,21 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\TransactionJournalMeta
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property int|string $transaction_journal_id
|
||||
* @property int $transaction_journal_id
|
||||
* @property string $name
|
||||
* @property mixed $data
|
||||
* @property string $hash
|
||||
@ -60,6 +61,7 @@ use Carbon\Carbon;
|
||||
*/
|
||||
class TransactionJournalMeta extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
|
||||
@ -103,4 +105,13 @@ class TransactionJournalMeta extends Model
|
||||
{
|
||||
return $this->belongsTo(TransactionJournal::class);
|
||||
}
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function transactionJournalId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -23,19 +23,19 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Carbon\Carbon;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\TransactionType
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
@ -57,6 +57,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
*/
|
||||
class TransactionType extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
public const DEPOSIT = 'Deposit';
|
||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Enums\UserRoleEnum;
|
||||
use FireflyIII\User;
|
||||
@ -33,13 +34,12 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
|
||||
use Carbon\Carbon;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* Class UserGroup
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
@ -92,6 +92,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
*/
|
||||
class UserGroup extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
|
||||
protected $fillable = ['title'];
|
||||
|
||||
/**
|
||||
|
@ -24,17 +24,17 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* Class UserRole
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
@ -53,6 +53,8 @@ use Carbon\Carbon;
|
||||
*/
|
||||
class UserRole extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
|
||||
protected $fillable = ['title'];
|
||||
|
||||
/**
|
||||
|
@ -23,10 +23,12 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\Enums\WebhookDelivery;
|
||||
use FireflyIII\Enums\WebhookResponse;
|
||||
use FireflyIII\Enums\WebhookTrigger;
|
||||
use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
@ -34,17 +36,16 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Carbon\Carbon;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\Webhook
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
* @property int|string $user_id
|
||||
* @property int $user_id
|
||||
* @property bool $active
|
||||
* @property int $trigger
|
||||
* @property int $response
|
||||
@ -73,13 +74,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property string $secret
|
||||
* @method static Builder|Webhook whereSecret($value)
|
||||
* @method static Builder|Webhook whereTitle($value)
|
||||
* @property int|null $user_group_id
|
||||
* @property int $user_group_id
|
||||
* @method static Builder|Webhook whereUserGroupId($value)
|
||||
* @mixin Eloquent
|
||||
*/
|
||||
class Webhook extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
use ReturnsIntegerUserIdTrait;
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
|
@ -23,24 +23,25 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Eloquent;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Carbon\Carbon;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* Class WebhookAttempt
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
* @property int|string $webhook_message_id
|
||||
* @property int|string $status_code
|
||||
* @property int $webhook_message_id
|
||||
* @property int|string $status_code
|
||||
* @property string|null $logs
|
||||
* @property string|null $response
|
||||
* @property-read WebhookMessage $webhookMessage
|
||||
@ -62,6 +63,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
*/
|
||||
class WebhookAttempt extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
use SoftDeletes;
|
||||
|
||||
/**
|
||||
@ -94,4 +96,14 @@ class WebhookAttempt extends Model
|
||||
{
|
||||
return $this->belongsTo(WebhookMessage::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function webhookMessageId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -33,15 +33,15 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Carbon\Carbon;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
/**
|
||||
* FireflyIII\Models\WebhookMessage
|
||||
*
|
||||
* @property int|string $id
|
||||
* @property int $id
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property string|null $deleted_at
|
||||
* @property int|string $webhook_id
|
||||
* @property int $webhook_id
|
||||
* @property bool $sent
|
||||
* @property bool $errored
|
||||
* @property int $attempts
|
||||
@ -69,6 +69,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
*/
|
||||
class WebhookMessage extends Model
|
||||
{
|
||||
use ReturnsIntegerIdTrait;
|
||||
|
||||
protected $casts
|
||||
= [
|
||||
'sent' => 'boolean',
|
||||
@ -128,4 +130,14 @@ class WebhookMessage extends Model
|
||||
get: static fn ($value) => (bool)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function webhookId(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
return (string)$transaction->amount;
|
||||
return $transaction->amount;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -635,6 +635,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
*/
|
||||
public function oldestJournal(Account $account): ?TransactionJournal
|
||||
{
|
||||
/** @var TransactionJournal|null $first */
|
||||
$first = $account->transactions()
|
||||
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
|
||||
->orderBy('transaction_journals.date', 'ASC')
|
||||
@ -643,7 +644,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
->orderBy('transaction_journals.id', 'ASC')
|
||||
->first(['transaction_journals.id']);
|
||||
if (null !== $first) {
|
||||
return TransactionJournal::find((int)$first->id);
|
||||
return TransactionJournal::find($first->id);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -633,8 +633,8 @@ class BillRepository implements BillRepositoryInterface
|
||||
/** @var Transaction|null $sourceTransaction */
|
||||
$sourceTransaction = $transactionJournal->transactions()->where('amount', '<', 0)->first();
|
||||
if (null !== $sourceTransaction) {
|
||||
$amount = (string)$sourceTransaction->amount;
|
||||
if ((int)$sourceTransaction->foreign_currency_id === (int)$currency->id) {
|
||||
$amount = $sourceTransaction->amount;
|
||||
if ((int)$sourceTransaction->foreign_currency_id === $currency->id) {
|
||||
// use foreign amount instead!
|
||||
$amount = (string)$sourceTransaction->foreign_amount;
|
||||
}
|
||||
|
@ -134,12 +134,13 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
||||
public function getAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end): string
|
||||
{
|
||||
$amount = '0';
|
||||
/** @var AvailableBudget|null $availableBudget */
|
||||
$availableBudget = $this->user->availableBudgets()
|
||||
->where('transaction_currency_id', $currency->id)
|
||||
->where('start_date', $start->format('Y-m-d'))
|
||||
->where('end_date', $end->format('Y-m-d'))->first();
|
||||
if (null !== $availableBudget) {
|
||||
$amount = (string)$availableBudget->amount;
|
||||
$amount = $availableBudget->amount;
|
||||
}
|
||||
|
||||
return $amount;
|
||||
|
@ -114,24 +114,24 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
];
|
||||
// same period
|
||||
if ($limit->start_date->isSameDay($start) && $limit->end_date->isSameDay($end)) {
|
||||
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], (string)$limit->amount);
|
||||
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $limit->amount);
|
||||
app('log')->debug(sprintf('Add full amount [1]: %s', $limit->amount));
|
||||
continue;
|
||||
}
|
||||
// limit is inside of date range
|
||||
if ($start->lte($limit->start_date) && $end->gte($limit->end_date)) {
|
||||
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], (string)$limit->amount);
|
||||
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $limit->amount);
|
||||
app('log')->debug(sprintf('Add full amount [2]: %s', $limit->amount));
|
||||
continue;
|
||||
}
|
||||
$total = $limit->start_date->diffInDays($limit->end_date) + 1; // include the day itself.
|
||||
$days = $this->daysInOverlap($limit, $start, $end);
|
||||
$amount = bcmul(bcdiv((string)$limit->amount, (string)$total), (string)$days);
|
||||
$amount = bcmul(bcdiv($limit->amount, (string)$total), (string)$days);
|
||||
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $amount);
|
||||
app('log')->debug(
|
||||
sprintf(
|
||||
'Amount per day: %s (%s over %d days). Total amount for %d days: %s',
|
||||
bcdiv((string)$limit->amount, (string)$total),
|
||||
bcdiv($limit->amount, (string)$total),
|
||||
$limit->amount,
|
||||
$total,
|
||||
$days,
|
||||
@ -230,24 +230,24 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
];
|
||||
// same period
|
||||
if ($limit->start_date->isSameDay($start) && $limit->end_date->isSameDay($end)) {
|
||||
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], (string)$limit->amount);
|
||||
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $limit->amount);
|
||||
app('log')->debug(sprintf('Add full amount [1]: %s', $limit->amount));
|
||||
continue;
|
||||
}
|
||||
// limit is inside of date range
|
||||
if ($start->lte($limit->start_date) && $end->gte($limit->end_date)) {
|
||||
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], (string)$limit->amount);
|
||||
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $limit->amount);
|
||||
app('log')->debug(sprintf('Add full amount [2]: %s', $limit->amount));
|
||||
continue;
|
||||
}
|
||||
$total = $limit->start_date->diffInDays($limit->end_date) + 1; // include the day itself.
|
||||
$days = $this->daysInOverlap($limit, $start, $end);
|
||||
$amount = bcmul(bcdiv((string)$limit->amount, (string)$total), (string)$days);
|
||||
$amount = bcmul(bcdiv($limit->amount, (string)$total), (string)$days);
|
||||
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $amount);
|
||||
app('log')->debug(
|
||||
sprintf(
|
||||
'Amount per day: %s (%s over %d days). Total amount for %d days: %s',
|
||||
bcdiv((string)$limit->amount, (string)$total),
|
||||
bcdiv($limit->amount, (string)$total),
|
||||
$limit->amount,
|
||||
$total,
|
||||
$days,
|
||||
@ -489,8 +489,8 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
$budgets = $this->getBudgets();
|
||||
/** @var Budget $budget */
|
||||
foreach ($budgets as $budget) {
|
||||
DB::table('budget_transaction')->where('budget_id', (int)$budget->id)->delete();
|
||||
DB::table('budget_transaction_journal')->where('budget_id', (int)$budget->id)->delete();
|
||||
DB::table('budget_transaction')->where('budget_id', $budget->id)->delete();
|
||||
DB::table('budget_transaction_journal')->where('budget_id', $budget->id)->delete();
|
||||
RecurrenceTransactionMeta::where('name', 'budget_id')->where('value', (string)$budget->id)->delete();
|
||||
RuleAction::where('action_type', 'set_budget')->where('action_value', (string)$budget->id)->delete();
|
||||
$budget->delete();
|
||||
|
@ -58,7 +58,7 @@ class OperationsRepository implements OperationsRepositoryInterface
|
||||
foreach ($budget->budgetlimits as $limit) {
|
||||
$diff = $limit->start_date->diffInDays($limit->end_date);
|
||||
$diff = 0 === $diff ? 1 : $diff;
|
||||
$amount = (string)$limit->amount;
|
||||
$amount = $limit->amount;
|
||||
$perDay = bcdiv($amount, (string)$diff);
|
||||
$total = bcadd($total, $perDay);
|
||||
$count++;
|
||||
|
@ -119,7 +119,7 @@ trait ModifiesPiggyBanks
|
||||
{
|
||||
$today = today(config('app.timezone'));
|
||||
$leftOnAccount = $this->leftOnAccount($piggyBank, $today);
|
||||
$savedSoFar = (string)$this->getRepetition($piggyBank)->currentamount;
|
||||
$savedSoFar = $this->getRepetition($piggyBank)->currentamount;
|
||||
$maxAmount = $leftOnAccount;
|
||||
$leftToSave = null;
|
||||
if (0 !== bccomp($piggyBank->targetamount, '0')) {
|
||||
|
@ -146,7 +146,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
return '0';
|
||||
}
|
||||
|
||||
return (string)$rep->currentamount;
|
||||
return $rep->currentamount;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -225,11 +225,11 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
// currency of the account + the piggy bank currency are almost the same.
|
||||
// which amount from the transaction matches?
|
||||
$amount = null;
|
||||
if ((int)$source->transaction_currency_id === (int)$currency->id) {
|
||||
if ((int)$source->transaction_currency_id === $currency->id) {
|
||||
app('log')->debug('Use normal amount');
|
||||
$amount = app('steam')->$operator($source->amount); // @phpstan-ignore-line
|
||||
}
|
||||
if ((int)$source->foreign_currency_id === (int)$currency->id) {
|
||||
if ((int)$source->foreign_currency_id === $currency->id) {
|
||||
app('log')->debug('Use foreign amount');
|
||||
$amount = app('steam')->$operator($source->foreign_amount); // @phpstan-ignore-line
|
||||
}
|
||||
@ -240,10 +240,10 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
}
|
||||
|
||||
app('log')->debug(sprintf('The currency is %s and the amount is %s', $currency->code, $amount));
|
||||
$room = bcsub((string)$piggyBank->targetamount, (string)$repetition->currentamount);
|
||||
$room = bcsub($piggyBank->targetamount, $repetition->currentamount);
|
||||
$compare = bcmul($repetition->currentamount, '-1');
|
||||
|
||||
if (bccomp((string)$piggyBank->targetamount, '0') === 0) {
|
||||
if (bccomp($piggyBank->targetamount, '0') === 0) {
|
||||
// amount is zero? then the "room" is positive amount of we wish to add or remove.
|
||||
$room = app('steam')->positive($amount);
|
||||
app('log')->debug(sprintf('Room is now %s', $room));
|
||||
|
@ -376,8 +376,8 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
*/
|
||||
public function setOrder(Rule $rule, int $newOrder): void
|
||||
{
|
||||
$oldOrder = (int)$rule->order;
|
||||
$groupId = (int)$rule->rule_group_id;
|
||||
$oldOrder = $rule->order;
|
||||
$groupId = $rule->rule_group_id;
|
||||
$maxOrder = $this->maxOrder($rule->ruleGroup);
|
||||
$newOrder = $newOrder > $maxOrder ? $maxOrder + 1 : $newOrder;
|
||||
app('log')->debug(sprintf('New order will be %d', $newOrder));
|
||||
|
@ -151,7 +151,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
$count = 1;
|
||||
/** @var Rule $entry */
|
||||
foreach ($set as $entry) {
|
||||
if ((int)$entry->order !== $count) {
|
||||
if ($entry->order !== $count) {
|
||||
app('log')->debug(sprintf('Rule #%d was on spot %d but must be on spot %d', $entry->id, $entry->order, $count));
|
||||
$entry->order = $count;
|
||||
$entry->save();
|
||||
|
@ -175,7 +175,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
|
||||
$result = [];
|
||||
/** @var Attachment $attachment */
|
||||
foreach ($set as $attachment) {
|
||||
$journalId = (int)$attachment->attachable_id;
|
||||
$journalId = $attachment->attachable_id;
|
||||
$result[$journalId] = $result[$journalId] ?? [];
|
||||
$current = $attachment->toArray();
|
||||
$current['file_exists'] = true;
|
||||
@ -417,7 +417,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
|
||||
if (null !== $currencyPreference) {
|
||||
$currency = TransactionCurrency::where('id', $currencyPreference->data)->first();
|
||||
}
|
||||
$journalId = (int)$row->transaction_journal_id;
|
||||
$journalId = $row->transaction_journal_id;
|
||||
$return[$journalId] = $return[$journalId] ?? [];
|
||||
|
||||
$return[$journalId][] = [
|
||||
|
@ -225,7 +225,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface
|
||||
|
||||
// if it's 1:
|
||||
if (1 === $membershipCount) {
|
||||
$lastUserId = (int)$userGroup->groupMemberships()->distinct()->first(['group_memberships.user_id'])->user_id;
|
||||
$lastUserId = $userGroup->groupMemberships()->distinct()->first(['group_memberships.user_id'])->user_id;
|
||||
// if this is also the user we're editing right now, and we remove all of their roles:
|
||||
if ($lastUserId === (int)$user->id && 0 === count($data['roles'])) {
|
||||
app('log')->debug('User is last in this group, refuse to act');
|
||||
|
@ -81,7 +81,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
/** @var Collection $set */
|
||||
$set = $bill->transactionJournals()->after($start)->before($end)->get(['transaction_journals.*']);
|
||||
$currency = $bill->transactionCurrency;
|
||||
$currencyId = (int)$bill->transaction_currency_id;
|
||||
$currencyId = $bill->transaction_currency_id;
|
||||
|
||||
$return[$currencyId] = $return[$currencyId] ?? [
|
||||
'currency_id' => (string)$currency->id,
|
||||
@ -103,18 +103,18 @@ class BillRepository implements BillRepositoryInterface
|
||||
/** @var Transaction|null $sourceTransaction */
|
||||
$sourceTransaction = $transactionJournal->transactions()->where('amount', '<', 0)->first();
|
||||
if (null !== $sourceTransaction) {
|
||||
$amount = (string)$sourceTransaction->amount;
|
||||
if ((int)$sourceTransaction->foreign_currency_id === (int)$currency->id) {
|
||||
$amount = $sourceTransaction->amount;
|
||||
if ((int)$sourceTransaction->foreign_currency_id === $currency->id) {
|
||||
// use foreign amount instead!
|
||||
$amount = (string)$sourceTransaction->foreign_amount;
|
||||
}
|
||||
// convert to native currency
|
||||
$nativeAmount = $amount;
|
||||
if ($currencyId !== (int)$default->id) {
|
||||
if ($currencyId !== $default->id) {
|
||||
// get rate and convert.
|
||||
$nativeAmount = $converter->convert($currency, $default, $transactionJournal->date, $amount);
|
||||
}
|
||||
if ((int)$sourceTransaction->foreign_currency_id === (int)$default->id) {
|
||||
if ((int)$sourceTransaction->foreign_currency_id === $default->id) {
|
||||
// ignore conversion, use foreign amount
|
||||
$nativeAmount = (string)$sourceTransaction->foreign_amount;
|
||||
}
|
||||
@ -154,7 +154,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
|
||||
if ($total > 0) {
|
||||
$currency = $bill->transactionCurrency;
|
||||
$currencyId = (int)$bill->transaction_currency_id;
|
||||
$currencyId = $bill->transaction_currency_id;
|
||||
$average = bcdiv(bcadd($bill->amount_max, $bill->amount_min), '2');
|
||||
$nativeAverage = $converter->convert($currency, $default, $start, $average);
|
||||
$return[$currencyId] = $return[$currencyId] ?? [
|
||||
|
@ -53,7 +53,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
|
||||
->where('end_date', $end->format('Y-m-d'))->get();
|
||||
/** @var AvailableBudget $availableBudget */
|
||||
foreach ($availableBudgets as $availableBudget) {
|
||||
$currencyId = (int)$availableBudget->transaction_currency_id;
|
||||
$currencyId = $availableBudget->transaction_currency_id;
|
||||
$return[$currencyId] = $return[$currencyId] ?? [
|
||||
'currency_id' => $currencyId,
|
||||
'currency_code' => $availableBudget->transactionCurrency->code,
|
||||
|
@ -113,7 +113,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
// is being used in accounts (as integer)
|
||||
$meta = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
|
||||
->whereNull('accounts.deleted_at')
|
||||
->where('account_meta.name', 'currency_id')->where('account_meta.data', json_encode((int)$currency->id))->count();
|
||||
->where('account_meta.name', 'currency_id')->where('account_meta.data', json_encode($currency->id))->count();
|
||||
if ($meta > 0) {
|
||||
app('log')->info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
|
||||
|
||||
@ -181,10 +181,10 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
$local = $this->get();
|
||||
return $all->map(static function (TransactionCurrency $current) use ($local) {
|
||||
$hasId = $local->contains(static function (TransactionCurrency $entry) use ($current) {
|
||||
return (int)$entry->id === (int)$current->id;
|
||||
return $entry->id === $current->id;
|
||||
});
|
||||
$isDefault = $local->contains(static function (TransactionCurrency $entry) use ($current) {
|
||||
return 1 === (int)$entry->pivot->group_default && (int)$entry->id === (int)$current->id;
|
||||
return 1 === (int)$entry->pivot->group_default && $entry->id === $current->id;
|
||||
});
|
||||
$current->userEnabled = $hasId;
|
||||
$current->userDefault = $isDefault;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user