Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Merge branch 'develop' of github.com:firefly-iii/firefly-iii into develop
James Colea0166b45e4ed
diff --cc app/Support/JsonApi/Enrichments/SubscriptionEnrichment.phpindex 60a3b66789,a28e5dd24a..19db60bba8--- a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php+++ b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php@@@ -1,9 -1,9 +1,11 @@@<?php+ declare(strict_types=1);+namespace FireflyIII\Support\JsonApi\Enrichments;+use Carbon\Carbon;+use Carbon\CarbonInterface;use FireflyIII\Models\Bill;use FireflyIII\Models\Note;use FireflyIII\Models\ObjectGroup;@@@ -155,12 -138,13 +158,12 @@@ class SubscriptionEnrichment implementprivate function collectObjectGroups(): void{- $set = DB::table('object_groupables')- ->whereIn('object_groupable_id', $this->subscriptionIds)- ->where('object_groupable_type', Bill::class)- ->get(['object_groupable_id', 'object_group_id'])- ;+ $set = DB::table('object_groupables')+ ->whereIn('object_groupable_id', $this->subscriptionIds)+ ->where('object_groupable_type', Bill::class)+ ->get(['object_groupable_id', 'object_group_id']);- $ids = array_unique($set->pluck('object_group_id')->toArray());+ $ids = array_unique($set->pluck('object_group_id')->toArray());foreach ($set as $entry) {$this->mappedObjects[(int)$entry->object_groupable_id] = (int)$entry->object_group_id;diff --cc app/Transformers/BillTransformer.phpindex 1d2d1dfadd,a25e1034a1..02b83d841b--- a/app/Transformers/BillTransformer.php+++ b/app/Transformers/BillTransformer.php@@@ -49,42 -63,105 +49,44 @@@ class BillTransformer extends AbstractT*/public function transform(Bill $bill): array{- $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;- $this->repository->setUser($bill->user);+ $currency = $bill->transactionCurrency;+- $paidDataFormatted = [];- $payDatesFormatted = [];- foreach ($paidData as $object) {- $date = Carbon::createFromFormat('!Y-m-d', $object['date'], config('app.timezone'));- if (!$date instanceof Carbon) {- $date = today(config('app.timezone'));- }- $object['date'] = $date->toAtomString();- $paidDataFormatted[] = $object;- }-- foreach ($payDates as $string) {- $date = Carbon::createFromFormat('!Y-m-d', $string, config('app.timezone'));- if (!$date instanceof Carbon) {- $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;-- if (null !== $firstPayDate) {- $nemDate = Carbon::createFromFormat('!Y-m-d', $firstPayDate, config('app.timezone'));- if (!$nemDate instanceof Carbon) {- $nemDate = today(config('app.timezone'));- }- $nem = $nemDate->toAtomString();-- // nullify again when it's outside the current view range.- if (- (null !== $this->parameters->get('start') && $nemDate->lt($this->parameters->get('start')))- || (null !== $this->parameters->get('end') && $nemDate->gt($this->parameters->get('end')))- ) {- $nem = null;- $nemDate = null;- $firstPayDate = null;- }- }-- // converting back and forth is bad code but OK.- if (null !== $nemDate) {- if ($nemDate->isToday()) {- $nemDiff = trans('firefly.today');- }-- $current = $payDatesFormatted[0] ?? null;- if (null !== $current && !$nemDate->isToday()) {- $temp2 = Carbon::createFromFormat('Y-m-d\TH:i:sP', $current);- if (!$temp2 instanceof Carbon) {- $temp2 = today(config('app.timezone'));- }- $nemDiff = trans('firefly.bill_expected_date', ['date' => $temp2->diffForHumans(today(config('app.timezone')), CarbonInterface::DIFF_RELATIVE_TO_NOW)]);- }- unset($temp2);- }-return [- 'id' => $bill->id,- 'created_at' => $bill->created_at->toAtomString(),- 'updated_at' => $bill->updated_at->toAtomString(),- 'currency_id' => (string)$bill->transaction_currency_id,- 'currency_code' => $currency->code,- 'currency_symbol' => $currency->symbol,- 'currency_decimal_places' => $currency->decimal_places,+ 'id' => $bill->id,+ 'created_at' => $bill->created_at->toAtomString(),+ 'updated_at' => $bill->updated_at->toAtomString(),+ 'currency_id' => (string)$bill->transaction_currency_id,+ 'currency_code' => $currency->code,+ 'currency_symbol' => $currency->symbol,+ 'currency_decimal_places' => $currency->decimal_places,'native_currency_id' => (string)$this->native->id,'native_currency_code' => $this->native->code,'native_currency_symbol' => $this->native->symbol,'native_currency_decimal_places' => $this->native->decimal_places,- 'name' => $bill->name,- 'amount_min' => $bill->amounts['amount_min'],- 'amount_max' => $bill->amounts['amount_max'],- 'amount_avg' => $bill->amounts['average'],- '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' => $bill->meta['notes'],- 'object_group_id' => $bill->meta['object_group_id'],- 'object_group_order' => $bill->meta['object_group_order'],- 'object_group_title' => $bill->meta['object_group_title'],+ 'name' => $bill->name,+ 'amount_min' => $bill->amounts['amount_min'],+ 'amount_max' => $bill->amounts['amount_max'],+ 'amount_avg' => $bill->amounts['average'],+ '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' => $bill->meta['notes'],+ 'object_group_id' => $bill->meta['object_group_id'],+ 'object_group_order' => $bill->meta['object_group_order'],+ 'object_group_title' => $bill->meta['object_group_title'],++++ 'paid_dates' => $bill->meta['paid_dates'],+ 'pay_dates' => $bill->meta['pay_dates'],+ 'next_expected_match' => $bill->meta['nem']?->toAtomString(),+ 'next_expected_match_diff' => $bill->meta['nem_diff'],// these fields need work:// 'next_expected_match' => $nem,