mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-26 05:26:17 +00:00
Auto commit for release 'develop' on 2025-01-19
This commit is contained in:
@@ -82,7 +82,7 @@ class AccountTransformer extends AbstractTransformer
|
||||
[$openingBalance, $nativeOpeningBalance, $openingBalanceDate] = $this->getOpeningBalance($account, $accountType, $convertToNative);
|
||||
[$interest, $interestPeriod] = $this->getInterest($account, $accountType);
|
||||
|
||||
$default = $this->default;
|
||||
$default = $this->default;
|
||||
if (!$this->convertToNative) {
|
||||
// reset default currency to NULL, not interesting.
|
||||
$default = null;
|
||||
|
||||
@@ -62,8 +62,8 @@ class AvailableBudgetTransformer extends AbstractTransformer
|
||||
$this->repository->setUser($availableBudget->user);
|
||||
|
||||
$currency = $availableBudget->transactionCurrency;
|
||||
$default = $this->default;
|
||||
if(!$this->convertToNative) {
|
||||
$default = $this->default;
|
||||
if (!$this->convertToNative) {
|
||||
$default = null;
|
||||
}
|
||||
$data = [
|
||||
@@ -87,7 +87,7 @@ class AvailableBudgetTransformer extends AbstractTransformer
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
'uri' => '/available_budgets/' . $availableBudget->id,
|
||||
'uri' => '/available_budgets/'.$availableBudget->id,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
@@ -64,23 +64,23 @@ class BillTransformer extends AbstractTransformer
|
||||
*/
|
||||
public function transform(Bill $bill): array
|
||||
{
|
||||
$default = $this->parameters->get('defaultCurrency') ?? $this->default;
|
||||
$default = $this->parameters->get('defaultCurrency') ?? $this->default;
|
||||
|
||||
$paidData = $this->paidData($bill);
|
||||
$lastPaidDate = $this->getLastPaidDate($paidData);
|
||||
$start = $this->parameters->get('start') ?? today()->subYears(10);
|
||||
$end = $this->parameters->get('end') ?? today()->addYears(10);
|
||||
$payDates = $this->calculator->getPayDates($start, $end, $bill->date, $bill->repeat_freq, $bill->skip, $lastPaidDate);
|
||||
$currency = $bill->transactionCurrency;
|
||||
$notes = $this->repository->getNoteText($bill);
|
||||
$notes = '' === $notes ? null : $notes;
|
||||
$objectGroupId = null;
|
||||
$objectGroupOrder = null;
|
||||
$objectGroupTitle = null;
|
||||
$paidData = $this->paidData($bill);
|
||||
$lastPaidDate = $this->getLastPaidDate($paidData);
|
||||
$start = $this->parameters->get('start') ?? today()->subYears(10);
|
||||
$end = $this->parameters->get('end') ?? today()->addYears(10);
|
||||
$payDates = $this->calculator->getPayDates($start, $end, $bill->date, $bill->repeat_freq, $bill->skip, $lastPaidDate);
|
||||
$currency = $bill->transactionCurrency;
|
||||
$notes = $this->repository->getNoteText($bill);
|
||||
$notes = '' === $notes ? null : $notes;
|
||||
$objectGroupId = null;
|
||||
$objectGroupOrder = null;
|
||||
$objectGroupTitle = null;
|
||||
$this->repository->setUser($bill->user);
|
||||
|
||||
/** @var null|ObjectGroup $objectGroup */
|
||||
$objectGroup = $bill->objectGroups->first();
|
||||
$objectGroup = $bill->objectGroups->first();
|
||||
if (null !== $objectGroup) {
|
||||
$objectGroupId = $objectGroup->id;
|
||||
$objectGroupOrder = $objectGroup->order;
|
||||
@@ -90,7 +90,7 @@ class BillTransformer extends AbstractTransformer
|
||||
$paidDataFormatted = [];
|
||||
$payDatesFormatted = [];
|
||||
foreach ($paidData as $object) {
|
||||
$date = Carbon::createFromFormat('!Y-m-d', $object['date'], config('app.timezone'));
|
||||
$date = Carbon::createFromFormat('!Y-m-d', $object['date'], config('app.timezone'));
|
||||
if (null === $date) {
|
||||
$date = today(config('app.timezone'));
|
||||
}
|
||||
@@ -99,24 +99,24 @@ class BillTransformer extends AbstractTransformer
|
||||
}
|
||||
|
||||
foreach ($payDates as $string) {
|
||||
$date = Carbon::createFromFormat('!Y-m-d', $string, config('app.timezone'));
|
||||
$date = Carbon::createFromFormat('!Y-m-d', $string, config('app.timezone'));
|
||||
if (null === $date) {
|
||||
$date = today(config('app.timezone'));
|
||||
}
|
||||
$payDatesFormatted[] = $date->toAtomString();
|
||||
}
|
||||
// next expected match
|
||||
$nem = null;
|
||||
$nemDate = null;
|
||||
$nemDiff = trans('firefly.not_expected_period');
|
||||
$firstPayDate = $payDates[0] ?? null;
|
||||
$nem = null;
|
||||
$nemDate = null;
|
||||
$nemDiff = trans('firefly.not_expected_period');
|
||||
$firstPayDate = $payDates[0] ?? null;
|
||||
|
||||
if (null !== $firstPayDate) {
|
||||
$nemDate = Carbon::createFromFormat('!Y-m-d', $firstPayDate, config('app.timezone'));
|
||||
if (null === $nemDate) {
|
||||
$nemDate = today(config('app.timezone'));
|
||||
}
|
||||
$nem = $nemDate->toAtomString();
|
||||
$nem = $nemDate->toAtomString();
|
||||
|
||||
// nullify again when it's outside the current view range.
|
||||
if (
|
||||
@@ -137,7 +137,7 @@ class BillTransformer extends AbstractTransformer
|
||||
|
||||
$current = $payDatesFormatted[0] ?? null;
|
||||
if (null !== $current && !$nemDate->isToday()) {
|
||||
$temp2 = Carbon::createFromFormat('Y-m-d\TH:i:sP', $current);
|
||||
$temp2 = Carbon::createFromFormat('Y-m-d\TH:i:sP', $current);
|
||||
if (null === $temp2) {
|
||||
$temp2 = today(config('app.timezone'));
|
||||
}
|
||||
@@ -158,32 +158,32 @@ class BillTransformer extends AbstractTransformer
|
||||
'native_currency_code' => $default?->code,
|
||||
'native_currency_symbol' => $default?->symbol,
|
||||
'native_currency_decimal_places' => $default?->decimal_places,
|
||||
'name' => $bill->name,
|
||||
'amount_min' => app('steam')->bcround($bill->amount_min, $currency->decimal_places),
|
||||
'amount_max' => app('steam')->bcround($bill->amount_max, $currency->decimal_places),
|
||||
'native_amount_min' => $this->convertToNative ? app('steam')->bcround($bill->native_amount_min, $default->decimal_places) : null,
|
||||
'native_amount_max' => $this->convertToNative ? app('steam')->bcround($bill->native_amount_max, $default->decimal_places) : null,
|
||||
'date' => $bill->date->toAtomString(),
|
||||
'end_date' => $bill->end_date?->toAtomString(),
|
||||
'extension_date' => $bill->extension_date?->toAtomString(),
|
||||
'repeat_freq' => $bill->repeat_freq,
|
||||
'skip' => $bill->skip,
|
||||
'active' => $bill->active,
|
||||
'order' => $bill->order,
|
||||
'notes' => $notes,
|
||||
'object_group_id' => null !== $objectGroupId ? (string) $objectGroupId : null,
|
||||
'object_group_order' => $objectGroupOrder,
|
||||
'object_group_title' => $objectGroupTitle,
|
||||
'name' => $bill->name,
|
||||
'amount_min' => app('steam')->bcround($bill->amount_min, $currency->decimal_places),
|
||||
'amount_max' => app('steam')->bcround($bill->amount_max, $currency->decimal_places),
|
||||
'native_amount_min' => $this->convertToNative ? app('steam')->bcround($bill->native_amount_min, $default->decimal_places) : null,
|
||||
'native_amount_max' => $this->convertToNative ? app('steam')->bcround($bill->native_amount_max, $default->decimal_places) : null,
|
||||
'date' => $bill->date->toAtomString(),
|
||||
'end_date' => $bill->end_date?->toAtomString(),
|
||||
'extension_date' => $bill->extension_date?->toAtomString(),
|
||||
'repeat_freq' => $bill->repeat_freq,
|
||||
'skip' => $bill->skip,
|
||||
'active' => $bill->active,
|
||||
'order' => $bill->order,
|
||||
'notes' => $notes,
|
||||
'object_group_id' => null !== $objectGroupId ? (string) $objectGroupId : null,
|
||||
'object_group_order' => $objectGroupOrder,
|
||||
'object_group_title' => $objectGroupTitle,
|
||||
|
||||
// these fields need work:
|
||||
'next_expected_match' => $nem,
|
||||
'next_expected_match_diff' => $nemDiff,
|
||||
'pay_dates' => $payDatesFormatted,
|
||||
'paid_dates' => $paidDataFormatted,
|
||||
'links' => [
|
||||
'next_expected_match' => $nem,
|
||||
'next_expected_match_diff' => $nemDiff,
|
||||
'pay_dates' => $payDatesFormatted,
|
||||
'paid_dates' => $paidDataFormatted,
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
'uri' => '/bills/' . $bill->id,
|
||||
'uri' => '/bills/'.$bill->id,
|
||||
],
|
||||
],
|
||||
];
|
||||
@@ -205,13 +205,13 @@ class BillTransformer extends AbstractTransformer
|
||||
// 2023-07-18 this particular date is used to search for the last paid date.
|
||||
// 2023-07-18 the cloned $searchDate is used to grab the correct transactions.
|
||||
/** @var Carbon $start */
|
||||
$start = clone $this->parameters->get('start');
|
||||
$searchStart = clone $start;
|
||||
$start = clone $this->parameters->get('start');
|
||||
$searchStart = clone $start;
|
||||
$start->subDay();
|
||||
|
||||
/** @var Carbon $end */
|
||||
$end = clone $this->parameters->get('end');
|
||||
$searchEnd = clone $end;
|
||||
$end = clone $this->parameters->get('end');
|
||||
$searchEnd = clone $end;
|
||||
|
||||
// move the search dates to the start of the day.
|
||||
$searchStart->startOfDay();
|
||||
@@ -221,7 +221,7 @@ class BillTransformer extends AbstractTransformer
|
||||
app('log')->debug(sprintf('Search parameters are: start: %s', $searchStart->format('Y-m-d')));
|
||||
|
||||
// Get from database when bill was paid.
|
||||
$set = $this->repository->getPaidDatesInRange($bill, $searchStart, $searchEnd);
|
||||
$set = $this->repository->getPaidDatesInRange($bill, $searchStart, $searchEnd);
|
||||
app('log')->debug(sprintf('Count %d entries in getPaidDatesInRange()', $set->count()));
|
||||
|
||||
// Grab from array the most recent payment. If none exist, fall back to the start date and pretend *that* was the last paid date.
|
||||
@@ -230,7 +230,7 @@ class BillTransformer extends AbstractTransformer
|
||||
app('log')->debug(sprintf('Result of lastPaidDate is %s', $lastPaidDate->format('Y-m-d')));
|
||||
|
||||
// At this point the "next match" is exactly after the last time the bill was paid.
|
||||
$result = [];
|
||||
$result = [];
|
||||
foreach ($set as $entry) {
|
||||
$result[] = [
|
||||
'transaction_group_id' => (string) $entry->transaction_group_id,
|
||||
|
||||
@@ -66,8 +66,8 @@ class BudgetLimitTransformer extends AbstractTransformer
|
||||
*/
|
||||
public function transform(BudgetLimit $budgetLimit): array
|
||||
{
|
||||
$repository = app(OperationsRepository::class);
|
||||
$limitRepos = app(BudgetLimitRepositoryInterface::class);
|
||||
$repository = app(OperationsRepository::class);
|
||||
$limitRepos = app(BudgetLimitRepositoryInterface::class);
|
||||
$repository->setUser($budgetLimit->budget->user);
|
||||
$limitRepos->setUser($budgetLimit->budget->user);
|
||||
$expenses = $repository->sumExpenses(
|
||||
@@ -93,8 +93,8 @@ class BudgetLimitTransformer extends AbstractTransformer
|
||||
$currencySymbol = $currency->symbol;
|
||||
$currencyDecimalPlaces = $currency->decimal_places;
|
||||
}
|
||||
$amount = app('steam')->bcround($amount, $currencyDecimalPlaces);
|
||||
$default = $this->default;
|
||||
$amount = app('steam')->bcround($amount, $currencyDecimalPlaces);
|
||||
$default = $this->default;
|
||||
if (!$this->convertToNative) {
|
||||
$default = null;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ class BudgetLimitTransformer extends AbstractTransformer
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
'uri' => '/budgets/limits/' . $budgetLimit->id,
|
||||
'uri' => '/budgets/limits/'.$budgetLimit->id,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
@@ -70,23 +70,23 @@ class BudgetTransformer extends AbstractTransformer
|
||||
}
|
||||
|
||||
// info for auto budget.
|
||||
$abType = null;
|
||||
$abAmount = null;
|
||||
$abNative = null;
|
||||
$abPeriod = null;
|
||||
$notes = $this->repository->getNoteText($budget);
|
||||
$abType = null;
|
||||
$abAmount = null;
|
||||
$abNative = null;
|
||||
$abPeriod = null;
|
||||
$notes = $this->repository->getNoteText($budget);
|
||||
|
||||
$types = [
|
||||
$types = [
|
||||
AutoBudgetType::AUTO_BUDGET_RESET->value => 'reset',
|
||||
AutoBudgetType::AUTO_BUDGET_ROLLOVER->value => 'rollover',
|
||||
AutoBudgetType::AUTO_BUDGET_ADJUSTED->value => 'adjusted',
|
||||
];
|
||||
$currency = $autoBudget?->transactionCurrency;
|
||||
$default = $this->default;
|
||||
$currency = $autoBudget?->transactionCurrency;
|
||||
$default = $this->default;
|
||||
if (!$this->convertToNative) {
|
||||
$default = null;
|
||||
}
|
||||
if(null === $autoBudget) {
|
||||
if (null === $autoBudget) {
|
||||
$currency = $default;
|
||||
}
|
||||
if (null !== $autoBudget) {
|
||||
@@ -97,15 +97,15 @@ class BudgetTransformer extends AbstractTransformer
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => (string) $budget->id,
|
||||
'created_at' => $budget->created_at->toAtomString(),
|
||||
'updated_at' => $budget->updated_at->toAtomString(),
|
||||
'active' => $budget->active,
|
||||
'name' => $budget->name,
|
||||
'order' => $budget->order,
|
||||
'notes' => $notes,
|
||||
'auto_budget_type' => $abType,
|
||||
'auto_budget_period' => $abPeriod,
|
||||
'id' => (string) $budget->id,
|
||||
'created_at' => $budget->created_at->toAtomString(),
|
||||
'updated_at' => $budget->updated_at->toAtomString(),
|
||||
'active' => $budget->active,
|
||||
'name' => $budget->name,
|
||||
'order' => $budget->order,
|
||||
'notes' => $notes,
|
||||
'auto_budget_type' => $abType,
|
||||
'auto_budget_period' => $abPeriod,
|
||||
|
||||
'currency_id' => null === $autoBudget ? null : (string) $autoBudget->transactionCurrency->id,
|
||||
'currency_code' => $autoBudget?->transactionCurrency->code,
|
||||
@@ -125,7 +125,7 @@ class BudgetTransformer extends AbstractTransformer
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
'uri' => '/budgets/' . $budget->id,
|
||||
'uri' => '/budgets/'.$budget->id,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
@@ -60,10 +60,10 @@ class CategoryTransformer extends AbstractTransformer
|
||||
$this->opsRepository->setUser($category->user);
|
||||
$this->repository->setUser($category->user);
|
||||
|
||||
$spent = [];
|
||||
$earned = [];
|
||||
$start = $this->parameters->get('start');
|
||||
$end = $this->parameters->get('end');
|
||||
$spent = [];
|
||||
$earned = [];
|
||||
$start = $this->parameters->get('start');
|
||||
$end = $this->parameters->get('end');
|
||||
if (null !== $start && null !== $end) {
|
||||
$earned = $this->beautify($this->opsRepository->sumIncome($start, $end, null, new Collection([$category])));
|
||||
$spent = $this->beautify($this->opsRepository->sumExpenses($start, $end, null, new Collection([$category])));
|
||||
@@ -72,7 +72,7 @@ class CategoryTransformer extends AbstractTransformer
|
||||
if (!$this->convertToNative) {
|
||||
$default = null;
|
||||
}
|
||||
$notes = $this->repository->getNoteText($category);
|
||||
$notes = $this->repository->getNoteText($category);
|
||||
|
||||
return [
|
||||
'id' => $category->id,
|
||||
@@ -89,7 +89,7 @@ class CategoryTransformer extends AbstractTransformer
|
||||
'links' => [
|
||||
[
|
||||
'rel' => 'self',
|
||||
'uri' => '/categories/' . $category->id,
|
||||
'uri' => '/categories/'.$category->id,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
@@ -40,7 +40,7 @@ class CurrencyTransformer extends AbstractTransformer
|
||||
'id' => $currency->id,
|
||||
'created_at' => $currency->created_at->toAtomString(),
|
||||
'updated_at' => $currency->updated_at->toAtomString(),
|
||||
'native' => $currency->userGroupNative,
|
||||
'native' => $currency->userGroupNative,
|
||||
'enabled' => $currency->userGroupEnabled,
|
||||
'name' => $currency->name,
|
||||
'code' => $currency->code,
|
||||
|
||||
@@ -83,13 +83,13 @@ class UserGroupTransformer extends AbstractTransformer
|
||||
|
||||
private function mergeMemberships(): void
|
||||
{
|
||||
$new = [];
|
||||
$new = [];
|
||||
foreach ($this->memberships as $groupId => $members) {
|
||||
$new[$groupId] ??= [];
|
||||
|
||||
foreach ($members as $member) {
|
||||
$mail = $member['user_email'];
|
||||
$new[$groupId][$mail] ??= [
|
||||
$new[$groupId][$mail] ??= [
|
||||
'user_id' => $member['user_id'],
|
||||
'user_email' => $member['user_email'],
|
||||
'you' => $member['you'],
|
||||
@@ -107,6 +107,7 @@ class UserGroupTransformer extends AbstractTransformer
|
||||
public function transform(UserGroup $userGroup): array
|
||||
{
|
||||
$currency = Amount::getDefaultCurrencyByUserGroup($userGroup);
|
||||
|
||||
return [
|
||||
'id' => $userGroup->id,
|
||||
'created_at' => $userGroup->created_at->toAtomString(),
|
||||
|
||||
@@ -46,7 +46,7 @@ class CurrencyTransformer extends AbstractTransformer
|
||||
'id' => $currency->id,
|
||||
'created_at' => $currency->created_at->toAtomString(),
|
||||
'updated_at' => $currency->updated_at->toAtomString(),
|
||||
'native' => $currency->userGroupNative,
|
||||
'native' => $currency->userGroupNative,
|
||||
'enabled' => $currency->userGroupEnabled,
|
||||
'name' => $currency->name,
|
||||
'code' => $currency->code,
|
||||
|
||||
Reference in New Issue
Block a user