mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix phpstan issues.
This commit is contained in:
parent
1d2e95f5af
commit
6f6b8d9b3e
@ -103,14 +103,14 @@ class EditController extends Controller
|
||||
$direction = $request->get('direction');
|
||||
if ('down' === $direction) {
|
||||
$maxOrder = $this->repository->maxOrder();
|
||||
$order = (int)$ruleGroup->order;
|
||||
$order = $ruleGroup->order;
|
||||
if ($order < $maxOrder) {
|
||||
$newOrder = $order + 1;
|
||||
$this->repository->setOrder($ruleGroup, $newOrder);
|
||||
}
|
||||
}
|
||||
if ('up' === $direction) {
|
||||
$order = (int)$ruleGroup->order;
|
||||
$order = $ruleGroup->order;
|
||||
if ($order > 1) {
|
||||
$newOrder = $order - 1;
|
||||
$this->repository->setOrder($ruleGroup, $newOrder);
|
||||
|
@ -55,7 +55,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property string|null $iban
|
||||
* @property bool $active
|
||||
* @property bool $encrypted
|
||||
* @property int|string $order
|
||||
* @property int $order
|
||||
* @property-read Collection|AccountMeta[] $accountMeta
|
||||
* @property-read int|null $account_meta_count
|
||||
* @property AccountType $accountType
|
||||
@ -324,4 +324,14 @@ class Account extends Model
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property bool $active
|
||||
* @property bool $name_encrypted
|
||||
* @property bool $match_encrypted
|
||||
* @property int|string $order
|
||||
* @property int $order
|
||||
* @property-read Collection|Attachment[] $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read Collection|Note[] $notes
|
||||
@ -269,5 +269,15 @@ class Bill extends Model
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ 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;
|
||||
@ -49,7 +50,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
* @property string $name
|
||||
* @property bool $active
|
||||
* @property bool $encrypted
|
||||
* @property int|string $order
|
||||
* @property int $order
|
||||
* @property-read Collection|Attachment[] $attachments
|
||||
* @property-read int|null $attachments_count
|
||||
* @property-read Collection|AutoBudget[] $autoBudgets
|
||||
@ -180,6 +181,14 @@ class Budget extends Model
|
||||
{
|
||||
return $this->belongsToMany(Transaction::class, 'budget_transaction', 'budget_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
* @property string $targetamount
|
||||
* @property Carbon|null $startdate
|
||||
* @property Carbon|null $targetdate
|
||||
* @property int|string $order
|
||||
* @property int $order
|
||||
* @property bool $active
|
||||
* @property bool $encrypted
|
||||
* @property-read Account $account
|
||||
@ -203,4 +203,15 @@ class PiggyBank extends Model
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
* @property int $rule_id
|
||||
* @property string|null $action_type
|
||||
* @property string|null $action_value
|
||||
* @property int|string $order
|
||||
* @property int $order
|
||||
* @property bool $active
|
||||
* @property bool $stop_processing
|
||||
* @property-read Rule $rule
|
||||
@ -90,4 +90,15 @@ class RuleAction extends Model
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ 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;
|
||||
@ -45,7 +46,7 @@ use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
* @property int $user_id
|
||||
* @property string|null $title
|
||||
* @property string|null $description
|
||||
* @property int|string $order
|
||||
* @property int $order
|
||||
* @property bool $active
|
||||
* @property bool $stop_processing
|
||||
* @property Collection|Rule[] $rules
|
||||
@ -129,4 +130,14 @@ class RuleGroup extends Model
|
||||
{
|
||||
return $this->hasMany(Rule::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
|
||||
* @property int $rule_id
|
||||
* @property string|null $trigger_type
|
||||
* @property string|null $trigger_value
|
||||
* @property int|string $order
|
||||
* @property int $order
|
||||
* @property bool $active
|
||||
* @property bool $stop_processing
|
||||
* @property-read Rule $rule
|
||||
@ -90,4 +90,15 @@ class RuleTrigger extends Model
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -404,4 +404,13 @@ class TransactionJournal extends Model
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @return Attribute
|
||||
*/
|
||||
protected function order(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: static fn($value) => (int)$value,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
$set = $this->user->bills()->orderBy('order', 'ASC')->get();
|
||||
$current = 1;
|
||||
foreach ($set as $bill) {
|
||||
if ((int)$bill->order !== $current) {
|
||||
if ($bill->order !== $current) {
|
||||
$bill->order = $current;
|
||||
$bill->save();
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface
|
||||
$index = 1;
|
||||
/** @var ObjectGroup $objectGroup */
|
||||
foreach ($list as $objectGroup) {
|
||||
if ($index !== (int)$objectGroup->order) {
|
||||
if ($index !== $objectGroup->order) {
|
||||
app('log')->debug(
|
||||
sprintf('objectGroup #%d ("%s"): order should %d be but is %d.', $objectGroup->id, $objectGroup->title, $index, $objectGroup->order)
|
||||
);
|
||||
@ -183,7 +183,7 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface
|
||||
*/
|
||||
public function setOrder(ObjectGroup $objectGroup, int $newOrder): ObjectGroup
|
||||
{
|
||||
$oldOrder = (int)$objectGroup->order;
|
||||
$oldOrder = $objectGroup->order;
|
||||
|
||||
if ($newOrder > $oldOrder) {
|
||||
$this->user->objectGroups()->where('object_groups.order', '<=', $newOrder)->where('object_groups.order', '>', $oldOrder)
|
||||
|
@ -297,7 +297,7 @@ trait ModifiesPiggyBanks
|
||||
$set = $this->user->piggyBanks()->orderBy('piggy_banks.order', 'ASC')->get(['piggy_banks.*']);
|
||||
$current = 1;
|
||||
foreach ($set as $piggyBank) {
|
||||
if ((int)$piggyBank->order !== $current) {
|
||||
if ($piggyBank->order !== $current) {
|
||||
app('log')->debug(sprintf('Piggy bank #%d ("%s") was at place %d but should be on %d', $piggyBank->id, $piggyBank->name, $piggyBank->order, $current));
|
||||
$piggyBank->order = $current;
|
||||
$piggyBank->save();
|
||||
@ -311,7 +311,7 @@ trait ModifiesPiggyBanks
|
||||
*/
|
||||
public function setOrder(PiggyBank $piggyBank, int $newOrder): bool
|
||||
{
|
||||
$oldOrder = (int)$piggyBank->order;
|
||||
$oldOrder = $piggyBank->order;
|
||||
//app('log')->debug(sprintf('Will move piggy bank #%d ("%s") from %d to %d', $piggyBank->id, $piggyBank->name, $oldOrder, $newOrder));
|
||||
if ($newOrder > $oldOrder) {
|
||||
$this->user->piggyBanks()->where('piggy_banks.order', '<=', $newOrder)->where('piggy_banks.order', '>', $oldOrder)
|
||||
@ -373,7 +373,7 @@ trait ModifiesPiggyBanks
|
||||
}
|
||||
|
||||
// update the order of the piggy bank:
|
||||
$oldOrder = (int)$piggyBank->order;
|
||||
$oldOrder = $piggyBank->order;
|
||||
$newOrder = (int)($data['order'] ?? $oldOrder);
|
||||
if ($oldOrder !== $newOrder) {
|
||||
$this->setOrder($piggyBank, $newOrder);
|
||||
|
@ -178,7 +178,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
$index = 1;
|
||||
/** @var RuleAction $action */
|
||||
foreach ($actions as $action) {
|
||||
if ((int)$action->order !== $index) {
|
||||
if ($action->order !== $index) {
|
||||
$action->order = $index;
|
||||
$action->save();
|
||||
app('log')->debug(sprintf('Rule action #%d was on spot %d but must be on spot %d', $action->id, $action->order, $index));
|
||||
@ -200,7 +200,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
$index = 1;
|
||||
/** @var RuleTrigger $trigger */
|
||||
foreach ($triggers as $trigger) {
|
||||
$order = (int)$trigger->order;
|
||||
$order = $trigger->order;
|
||||
if ($order !== $index) {
|
||||
$trigger->order = $index;
|
||||
$trigger->save();
|
||||
@ -483,7 +483,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
*/
|
||||
public function setOrder(RuleGroup $ruleGroup, int $newOrder): void
|
||||
{
|
||||
$oldOrder = (int)$ruleGroup->order;
|
||||
$oldOrder = $ruleGroup->order;
|
||||
|
||||
if ($newOrder > $oldOrder) {
|
||||
$this->user->ruleGroups()->where('rule_groups.order', '<=', $newOrder)->where('rule_groups.order', '>', $oldOrder)
|
||||
|
@ -49,7 +49,7 @@ class BillRepository implements BillRepositoryInterface
|
||||
$set = $this->userGroup->bills()->orderBy('order', 'ASC')->get();
|
||||
$current = 1;
|
||||
foreach ($set as $bill) {
|
||||
if ((int)$bill->order !== $current) {
|
||||
if ($bill->order !== $current) {
|
||||
$bill->order = $current;
|
||||
$bill->save();
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ class AccountUpdateService
|
||||
return $account;
|
||||
}
|
||||
// get account type ID's because a join and an update is hard:
|
||||
$oldOrder = (int)$account->order;
|
||||
$oldOrder = $account->order;
|
||||
$newOrder = $data['order'];
|
||||
app('log')->debug(sprintf('Order is set to be updated from %s to %s', $oldOrder, $newOrder));
|
||||
$list = $this->getTypeIds([AccountType::MORTGAGE, AccountType::LOAN, AccountType::DEBT]);
|
||||
|
@ -87,7 +87,7 @@ class BillUpdateService
|
||||
// update order.
|
||||
if (array_key_exists('order', $data)) {
|
||||
// update the order of the piggy bank:
|
||||
$oldOrder = (int)$bill->order;
|
||||
$oldOrder = $bill->order;
|
||||
$newOrder = (int)($data['order'] ?? $oldOrder);
|
||||
if ($oldOrder !== $newOrder) {
|
||||
$this->updateOrder($bill, $oldOrder, $newOrder);
|
||||
|
@ -92,7 +92,7 @@ class AccountTransformer extends AbstractTransformer
|
||||
}
|
||||
|
||||
// no order for some accounts:
|
||||
$order = (int)$account->order;
|
||||
$order = $account->order;
|
||||
if (!in_array(strtolower($accountType), ['liability', 'liabilities', 'asset'], true)) {
|
||||
$order = null;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ class BillTransformer extends AbstractTransformer
|
||||
unset($temp, $temp2);
|
||||
|
||||
return [
|
||||
'id' => (int)$bill->id,
|
||||
'id' => $bill->id,
|
||||
'created_at' => $bill->created_at->toAtomString(),
|
||||
'updated_at' => $bill->updated_at->toAtomString(),
|
||||
'currency_id' => (string)$bill->transaction_currency_id,
|
||||
@ -121,7 +121,7 @@ class BillTransformer extends AbstractTransformer
|
||||
'repeat_freq' => $bill->repeat_freq,
|
||||
'skip' => (int)$bill->skip,
|
||||
'active' => $bill->active,
|
||||
'order' => (int)$bill->order,
|
||||
'order' => $bill->order,
|
||||
'notes' => $notes,
|
||||
'object_group_id' => null !== $objectGroupId ? (string)$objectGroupId : null,
|
||||
'object_group_order' => $objectGroupOrder,
|
||||
|
@ -60,7 +60,7 @@ class ObjectGroupTransformer extends AbstractTransformer
|
||||
'created_at' => $objectGroup->created_at?->toAtomString(),
|
||||
'updated_at' => $objectGroup->updated_at?->toAtomString(),
|
||||
'title' => $objectGroup->title,
|
||||
'order' => (int)$objectGroup->order,
|
||||
'order' => $objectGroup->order,
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
|
@ -79,8 +79,8 @@ class PiggyBankTransformer extends AbstractTransformer
|
||||
/** @var ObjectGroup|null $objectGroup */
|
||||
$objectGroup = $piggyBank->objectGroups->first();
|
||||
if (null !== $objectGroup) {
|
||||
$objectGroupId = (int)$objectGroup->id;
|
||||
$objectGroupOrder = (int)$objectGroup->order;
|
||||
$objectGroupId = $objectGroup->id;
|
||||
$objectGroupOrder = $objectGroup->order;
|
||||
$objectGroupTitle = $objectGroup->title;
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ class PiggyBankTransformer extends AbstractTransformer
|
||||
'save_per_month' => $savePerMonth,
|
||||
'start_date' => $startDate,
|
||||
'target_date' => $targetDate,
|
||||
'order' => (int)$piggyBank->order,
|
||||
'order' => $piggyBank->order,
|
||||
'active' => true,
|
||||
'notes' => $notes,
|
||||
'object_group_id' => null !== $objectGroupId ? (string)$objectGroupId : null,
|
||||
|
@ -40,7 +40,7 @@ class PreferenceTransformer extends AbstractTransformer
|
||||
public function transform(Preference $preference): array
|
||||
{
|
||||
return [
|
||||
'id' => (int)$preference->id,
|
||||
'id' => $preference->id,
|
||||
'created_at' => $preference->created_at->toAtomString(),
|
||||
'updated_at' => $preference->updated_at->toAtomString(),
|
||||
'name' => $preference->name,
|
||||
|
@ -184,7 +184,7 @@ class RecurrenceTransformer extends AbstractTransformer
|
||||
$sourceIban = null;
|
||||
if (null !== $sourceAccount) {
|
||||
$sourceName = $sourceAccount->name;
|
||||
$sourceId = (int)$sourceAccount->id;
|
||||
$sourceId = $sourceAccount->id;
|
||||
$sourceType = $sourceAccount->accountType->type;
|
||||
$sourceIban = $sourceAccount->iban;
|
||||
}
|
||||
@ -194,7 +194,7 @@ class RecurrenceTransformer extends AbstractTransformer
|
||||
$destinationIban = null;
|
||||
if (null !== $destinationAccount) {
|
||||
$destinationName = $destinationAccount->name;
|
||||
$destinationId = (int)$destinationAccount->id;
|
||||
$destinationId = $destinationAccount->id;
|
||||
$destinationType = $destinationAccount->accountType->type;
|
||||
$destinationIban = $destinationAccount->iban;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class RuleGroupTransformer extends AbstractTransformer
|
||||
public function transform(RuleGroup $ruleGroup): array
|
||||
{
|
||||
return [
|
||||
'id' => (int)$ruleGroup->id,
|
||||
'id' => $ruleGroup->id,
|
||||
'created_at' => $ruleGroup->created_at->toAtomString(),
|
||||
'updated_at' => $ruleGroup->updated_at->toAtomString(),
|
||||
'title' => $ruleGroup->title,
|
||||
|
@ -67,7 +67,7 @@ class RuleTransformer extends AbstractTransformer
|
||||
'rule_group_title' => (string)$rule->ruleGroup->title,
|
||||
'title' => $rule->title,
|
||||
'description' => $rule->description,
|
||||
'order' => (int)$rule->order,
|
||||
'order' => $rule->order,
|
||||
'active' => $rule->active,
|
||||
'strict' => $rule->strict,
|
||||
'stop_processing' => $rule->stop_processing,
|
||||
|
@ -55,7 +55,7 @@ class TagTransformer extends AbstractTransformer
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => (int)$tag->id,
|
||||
'id' => $tag->id,
|
||||
'created_at' => $tag->created_at->toAtomString(),
|
||||
'updated_at' => $tag->updated_at->toAtomString(),
|
||||
'tag' => $tag->tag,
|
||||
|
@ -329,10 +329,10 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
{
|
||||
try {
|
||||
$result = [
|
||||
'id' => (int)$group->id,
|
||||
'id' => $group->id,
|
||||
'created_at' => $group->created_at->toAtomString(),
|
||||
'updated_at' => $group->updated_at->toAtomString(),
|
||||
'user' => (int)$group->user_id,
|
||||
'user' => $group->user_id,
|
||||
'group_title' => $group->title,
|
||||
'transactions' => $this->transformJournals($group->transactionJournals),
|
||||
'links' => [
|
||||
@ -383,7 +383,7 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
$type = $journal->transactionType->type;
|
||||
$currency = $source->transactionCurrency;
|
||||
$amount = app('steam')->bcround($this->getAmount($type, $source->amount), $currency->decimal_places ?? 0);
|
||||
$foreignAmount = $this->getForeignAmount($type, null === $source->foreign_amount ? null : (string)$source->foreign_amount);
|
||||
$foreignAmount = $this->getForeignAmount($type, null === $source->foreign_amount ? null : $source->foreign_amount);
|
||||
$metaFieldData = $this->groupRepos->getMetaFields($journal->id, $this->metaFields);
|
||||
$metaDates = $this->getDates($this->groupRepos->getMetaDateFields($journal->id, $this->metaDateFields));
|
||||
$foreignCurrency = $this->getForeignCurrency($source->foreignCurrency);
|
||||
@ -406,7 +406,7 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
}
|
||||
|
||||
return [
|
||||
'user' => (int)$journal->user_id,
|
||||
'user' => $journal->user_id,
|
||||
'transaction_journal_id' => $journal->id,
|
||||
'type' => strtolower($type),
|
||||
'date' => $journal->date->toAtomString(),
|
||||
|
@ -74,7 +74,7 @@ class AccountTransformer extends AbstractTransformer
|
||||
$this->currencies[$id] = $currency;
|
||||
}
|
||||
foreach ($meta as $entry) {
|
||||
$id = (int)$entry->account_id;
|
||||
$id = $entry->account_id;
|
||||
$this->accountMeta[$id][$entry->name] = $entry->data;
|
||||
}
|
||||
// get account types:
|
||||
@ -84,7 +84,7 @@ class AccountTransformer extends AbstractTransformer
|
||||
->get(['accounts.id', 'account_types.type']);
|
||||
/** @var AccountType $row */
|
||||
foreach ($accountTypes as $row) {
|
||||
$this->accountTypes[(int)$row->id] = (string)config(sprintf('firefly.shortNamesByFullName.%s', $row->type));
|
||||
$this->accountTypes[$row->id] = (string)config(sprintf('firefly.shortNamesByFullName.%s', $row->type));
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ class AccountTransformer extends AbstractTransformer
|
||||
// various meta
|
||||
$accountRole = $this->accountMeta[$id]['account_role'] ?? null;
|
||||
$accountType = $this->accountTypes[$id];
|
||||
$order = (int)$account->order;
|
||||
$order = $account->order;
|
||||
|
||||
// no currency? use default
|
||||
$currency = $this->default;
|
||||
|
@ -62,8 +62,8 @@ class BillTransformer extends AbstractTransformer
|
||||
// start with currencies:
|
||||
/** @var Bill $object */
|
||||
foreach ($objects as $object) {
|
||||
$id = (int)$object->transaction_currency_id;
|
||||
$bills[] = (int)$object->id;
|
||||
$id = $object->transaction_currency_id;
|
||||
$bills[] = $object->id;
|
||||
$currencies[$id] = $currencies[$id] ?? TransactionCurrency::find($id);
|
||||
}
|
||||
$this->currencies = $currencies;
|
||||
@ -72,7 +72,7 @@ class BillTransformer extends AbstractTransformer
|
||||
$notes = Note::whereNoteableType(Bill::class)->whereIn('noteable_id', array_keys($bills))->get();
|
||||
/** @var Note $note */
|
||||
foreach ($notes as $note) {
|
||||
$id = (int)$note->noteable_id;
|
||||
$id = $note->noteable_id;
|
||||
$this->notes[$id] = $note;
|
||||
}
|
||||
// grab object groups:
|
||||
@ -84,7 +84,7 @@ class BillTransformer extends AbstractTransformer
|
||||
foreach ($set as $entry) {
|
||||
$billId = (int)$entry->object_groupable_id;
|
||||
$id = (int)$entry->object_group_id;
|
||||
$order = (int)$entry->order;
|
||||
$order = $entry->order;
|
||||
$this->groups[$billId] = [
|
||||
'object_group_id' => $id,
|
||||
'object_group_title' => $entry->title,
|
||||
@ -143,12 +143,12 @@ class BillTransformer extends AbstractTransformer
|
||||
'transaction_group_id' => (string)$journal->id,
|
||||
'transaction_journal_id' => (string)$journal->transaction_group_id,
|
||||
'date' => $journal->date->toAtomString(),
|
||||
'currency_id' => (int)$currencies[$currencyId]->id,
|
||||
'currency_id' => $currencies[$currencyId]->id,
|
||||
'currency_code' => $currencies[$currencyId]->code,
|
||||
'currency_name' => $currencies[$currencyId]->name,
|
||||
'currency_symbol' => $currencies[$currencyId]->symbol,
|
||||
'currency_decimal_places' => (int)$currencies[$currencyId]->decimal_places,
|
||||
'native_currency_id' => (int)$currencies[$currencyId]->id,
|
||||
'native_currency_id' => $currencies[$currencyId]->id,
|
||||
'native_currency_code' => $currencies[$currencyId]->code,
|
||||
'native_currency_symbol' => $currencies[$currencyId]->symbol,
|
||||
'native_currency_decimal_places' => (int)$currencies[$currencyId]->decimal_places,
|
||||
@ -180,11 +180,11 @@ class BillTransformer extends AbstractTransformer
|
||||
*/
|
||||
public function transform(Bill $bill): array
|
||||
{
|
||||
$paidData = $this->paidDates[(int)$bill->id] ?? [];
|
||||
$nextExpectedMatch = $this->nextExpectedMatch($bill, $this->paidDates[(int)$bill->id] ?? []);
|
||||
$paidData = $this->paidDates[$bill->id] ?? [];
|
||||
$nextExpectedMatch = $this->nextExpectedMatch($bill, $this->paidDates[$bill->id] ?? []);
|
||||
$payDates = $this->payDates($bill);
|
||||
$currency = $this->currencies[$bill->transaction_currency_id];
|
||||
$group = $this->groups[(int)$bill->id] ?? null;
|
||||
$group = $this->groups[$bill->id] ?? null;
|
||||
|
||||
// date for currency conversion
|
||||
/** @var Carbon|null $startParam */
|
||||
@ -195,7 +195,7 @@ class BillTransformer extends AbstractTransformer
|
||||
|
||||
$nextExpectedMatchDiff = $this->getNextExpectedMatchDiff($nextExpectedMatch, $payDates);
|
||||
return [
|
||||
'id' => (int)$bill->id,
|
||||
'id' => $bill->id,
|
||||
'created_at' => $bill->created_at->toAtomString(),
|
||||
'updated_at' => $bill->updated_at->toAtomString(),
|
||||
'name' => $bill->name,
|
||||
@ -219,8 +219,8 @@ class BillTransformer extends AbstractTransformer
|
||||
'repeat_freq' => $bill->repeat_freq,
|
||||
'skip' => (int)$bill->skip,
|
||||
'active' => $bill->active,
|
||||
'order' => (int)$bill->order,
|
||||
'notes' => $this->notes[(int)$bill->id] ?? null,
|
||||
'order' => $bill->order,
|
||||
'notes' => $this->notes[$bill->id] ?? null,
|
||||
'object_group_id' => $group ? $group['object_group_id'] : null,
|
||||
'object_group_order' => $group ? $group['object_group_order'] : null,
|
||||
'object_group_title' => $group ? $group['object_group_title'] : null,
|
||||
|
@ -91,7 +91,7 @@ class PiggyBankTransformer extends AbstractTransformer
|
||||
/** @var AccountMeta $preference */
|
||||
foreach ($currencyPreferences as $preference) {
|
||||
$currencyId = (int)$preference->data;
|
||||
$accountId = (int)$preference->account_id;
|
||||
$accountId = $preference->account_id;
|
||||
$currencies[$currencyId] = $currencies[$currencyId] ?? TransactionJournal::find($currencyId);
|
||||
$this->currencies[$accountId] = $currencies[$currencyId];
|
||||
}
|
||||
@ -105,7 +105,7 @@ class PiggyBankTransformer extends AbstractTransformer
|
||||
foreach ($set as $entry) {
|
||||
$piggyBankId = (int)$entry->object_groupable_id;
|
||||
$id = (int)$entry->object_group_id;
|
||||
$order = (int)$entry->order;
|
||||
$order = $entry->order;
|
||||
$this->groups[$piggyBankId] = [
|
||||
'object_group_id' => $id,
|
||||
'object_group_title' => $entry->title,
|
||||
@ -118,7 +118,7 @@ class PiggyBankTransformer extends AbstractTransformer
|
||||
$repetitions = PiggyBankRepetition::whereIn('piggy_bank_id', $piggyBanks)->get();
|
||||
/** @var PiggyBankRepetition $repetition */
|
||||
foreach ($repetitions as $repetition) {
|
||||
$this->repetitions[(int)$repetition->piggy_bank_id] = [
|
||||
$this->repetitions[$repetition->piggy_bank_id] = [
|
||||
'amount' => $repetition->currentamount,
|
||||
];
|
||||
}
|
||||
@ -128,7 +128,7 @@ class PiggyBankTransformer extends AbstractTransformer
|
||||
$notes = Note::whereNoteableType(PiggyBank::class)->whereIn('noteable_id', array_keys($piggyBanks))->get();
|
||||
/** @var Note $note */
|
||||
foreach ($notes as $note) {
|
||||
$id = (int)$note->noteable_id;
|
||||
$id = $note->noteable_id;
|
||||
$this->notes[$id] = $note;
|
||||
}
|
||||
|
||||
@ -180,15 +180,15 @@ class PiggyBankTransformer extends AbstractTransformer
|
||||
$nativeSavePerMonth = null;
|
||||
$startDate = $piggyBank->startdate?->format('Y-m-d');
|
||||
$targetDate = $piggyBank->targetdate?->format('Y-m-d');
|
||||
$accountId = (int)$piggyBank->account_id;
|
||||
$accountId = $piggyBank->account_id;
|
||||
$accountName = $this->accounts[$accountId]['name'] ?? null;
|
||||
$currency = $this->currencies[$accountId] ?? $this->default;
|
||||
$currentAmount = app('steam')->bcround($this->repetitions[(int)$piggyBank->id]['amount'] ?? '0', $currency->decimal_places);
|
||||
$currentAmount = app('steam')->bcround($this->repetitions[$piggyBank->id]['amount'] ?? '0', $currency->decimal_places);
|
||||
$nativeCurrentAmount = $this->converter->convert($this->default, $currency, today(), $currentAmount);
|
||||
$targetAmount = $piggyBank->targetamount;
|
||||
$nativeTargetAmount = $this->converter->convert($this->default, $currency, today(), $targetAmount);
|
||||
$note = $this->notes[(int)$piggyBank->id] ?? null;
|
||||
$group = $this->groups[(int)$piggyBank->id] ?? null;
|
||||
$note = $this->notes[$piggyBank->id] ?? null;
|
||||
$group = $this->groups[$piggyBank->id] ?? null;
|
||||
|
||||
if (0 !== bccomp($targetAmount, '0')) { // target amount is not 0.00
|
||||
$leftToSave = bcsub($targetAmount, $currentAmount);
|
||||
@ -224,7 +224,7 @@ class PiggyBankTransformer extends AbstractTransformer
|
||||
'native_save_per_month' => $nativeSavePerMonth,
|
||||
'start_date' => $startDate,
|
||||
'target_date' => $targetDate,
|
||||
'order' => (int)$piggyBank->order,
|
||||
'order' => $piggyBank->order,
|
||||
'active' => $piggyBank->active,
|
||||
'notes' => $note,
|
||||
'object_group_id' => $group ? $group['object_group_id'] : null,
|
||||
|
@ -49,7 +49,7 @@ class PreferenceTransformer extends AbstractTransformer
|
||||
public function transform(Preference $preference): array
|
||||
{
|
||||
return [
|
||||
'id' => (int)$preference->id,
|
||||
'id' => $preference->id,
|
||||
'created_at' => $preference->created_at->toAtomString(),
|
||||
'updated_at' => $preference->updated_at->toAtomString(),
|
||||
'name' => $preference->name,
|
||||
|
@ -85,7 +85,7 @@ class TransactionGroupTransformer extends AbstractTransformer
|
||||
$notes = Note::whereNoteableType(TransactionJournal::class)->whereIn('noteable_id', array_keys($journals))->get();
|
||||
/** @var Note $note */
|
||||
foreach ($notes as $note) {
|
||||
$id = (int)$note->noteable_id;
|
||||
$id = $note->noteable_id;
|
||||
$this->notes[$id] = $note;
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ class UserGroupTransformer extends AbstractTransformer
|
||||
$user = auth()->user();
|
||||
/** @var UserGroup $userGroup */
|
||||
foreach ($objects as $userGroup) {
|
||||
$userGroupId = (int)$userGroup->id;
|
||||
$userGroupId = $userGroup->id;
|
||||
$access = $user->hasRoleInGroup($userGroup, UserRoleEnum::VIEW_MEMBERSHIPS, true, true);
|
||||
if ($access) {
|
||||
$groupMemberships = $userGroup->groupMemberships()->get();
|
||||
@ -84,11 +84,11 @@ class UserGroupTransformer extends AbstractTransformer
|
||||
public function transform(UserGroup $userGroup): array
|
||||
{
|
||||
$return = [
|
||||
'id' => (int)$userGroup->id,
|
||||
'id' => $userGroup->id,
|
||||
'created_at' => $userGroup->created_at->toAtomString(),
|
||||
'updated_at' => $userGroup->updated_at->toAtomString(),
|
||||
'title' => $userGroup->title,
|
||||
'members' => $this->memberships[(int)$userGroup->id] ?? [],
|
||||
'members' => $this->memberships[$userGroup->id] ?? [],
|
||||
];
|
||||
// if the user has a specific role in this group, then collect the memberships.
|
||||
|
||||
|
@ -51,7 +51,7 @@ class WebhookTransformer extends AbstractTransformer
|
||||
public function transform(Webhook $webhook): array
|
||||
{
|
||||
return [
|
||||
'id' => (int)$webhook->id,
|
||||
'id' => $webhook->id,
|
||||
'created_at' => $webhook->created_at->toAtomString(),
|
||||
'updated_at' => $webhook->updated_at->toAtomString(),
|
||||
'active' => $webhook->active,
|
||||
|
Loading…
Reference in New Issue
Block a user