mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-14 00:04:24 +00:00
Update bill transformers with enrichments
This commit is contained in:
@@ -109,6 +109,17 @@ class ShowController extends Controller
|
|||||||
{
|
{
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
// enrich
|
||||||
|
/** @var User $admin */
|
||||||
|
$admin = auth()->user();
|
||||||
|
$enrichment = new SubscriptionEnrichment();
|
||||||
|
$enrichment->setUser($admin);
|
||||||
|
$enrichment->setConvertToNative($this->convertToNative);
|
||||||
|
$enrichment->setNative($this->nativeCurrency);
|
||||||
|
$enrichment->setStart($this->parameters->get('start'));
|
||||||
|
$enrichment->setEnd($this->parameters->get('end'));
|
||||||
|
$bill = $enrichment->enrichSingle($bill);
|
||||||
|
|
||||||
/** @var BillTransformer $transformer */
|
/** @var BillTransformer $transformer */
|
||||||
$transformer = app(BillTransformer::class);
|
$transformer = app(BillTransformer::class);
|
||||||
$transformer->setParameters($this->parameters);
|
$transformer->setParameters($this->parameters);
|
||||||
|
@@ -29,7 +29,9 @@ use FireflyIII\Api\V1\Requests\Models\Bill\StoreRequest;
|
|||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||||
use FireflyIII\Support\Http\Api\TransactionFilter;
|
use FireflyIII\Support\Http\Api\TransactionFilter;
|
||||||
|
use FireflyIII\Support\JsonApi\Enrichments\SubscriptionEnrichment;
|
||||||
use FireflyIII\Transformers\BillTransformer;
|
use FireflyIII\Transformers\BillTransformer;
|
||||||
|
use FireflyIII\User;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use League\Fractal\Resource\Item;
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
@@ -72,6 +74,17 @@ class StoreController extends Controller
|
|||||||
$bill = $this->repository->store($data);
|
$bill = $this->repository->store($data);
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
// enrich
|
||||||
|
/** @var User $admin */
|
||||||
|
$admin = auth()->user();
|
||||||
|
$enrichment = new SubscriptionEnrichment();
|
||||||
|
$enrichment->setUser($admin);
|
||||||
|
$enrichment->setConvertToNative($this->convertToNative);
|
||||||
|
$enrichment->setNative($this->nativeCurrency);
|
||||||
|
$enrichment->setStart($this->parameters->get('start'));
|
||||||
|
$enrichment->setEnd($this->parameters->get('end'));
|
||||||
|
$bill = $enrichment->enrichSingle($bill);
|
||||||
|
|
||||||
/** @var BillTransformer $transformer */
|
/** @var BillTransformer $transformer */
|
||||||
$transformer = app(BillTransformer::class);
|
$transformer = app(BillTransformer::class);
|
||||||
$transformer->setParameters($this->parameters);
|
$transformer->setParameters($this->parameters);
|
||||||
|
@@ -28,7 +28,9 @@ use FireflyIII\Api\V1\Controllers\Controller;
|
|||||||
use FireflyIII\Api\V1\Requests\Models\Bill\UpdateRequest;
|
use FireflyIII\Api\V1\Requests\Models\Bill\UpdateRequest;
|
||||||
use FireflyIII\Models\Bill;
|
use FireflyIII\Models\Bill;
|
||||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||||
|
use FireflyIII\Support\JsonApi\Enrichments\SubscriptionEnrichment;
|
||||||
use FireflyIII\Transformers\BillTransformer;
|
use FireflyIII\Transformers\BillTransformer;
|
||||||
|
use FireflyIII\User;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use League\Fractal\Resource\Item;
|
use League\Fractal\Resource\Item;
|
||||||
|
|
||||||
@@ -67,6 +69,17 @@ class UpdateController extends Controller
|
|||||||
$bill = $this->repository->update($bill, $data);
|
$bill = $this->repository->update($bill, $data);
|
||||||
$manager = $this->getManager();
|
$manager = $this->getManager();
|
||||||
|
|
||||||
|
// enrich
|
||||||
|
/** @var User $admin */
|
||||||
|
$admin = auth()->user();
|
||||||
|
$enrichment = new SubscriptionEnrichment();
|
||||||
|
$enrichment->setUser($admin);
|
||||||
|
$enrichment->setConvertToNative($this->convertToNative);
|
||||||
|
$enrichment->setNative($this->nativeCurrency);
|
||||||
|
$enrichment->setStart($this->parameters->get('start'));
|
||||||
|
$enrichment->setEnd($this->parameters->get('end'));
|
||||||
|
$bill = $enrichment->enrichSingle($bill);
|
||||||
|
|
||||||
/** @var BillTransformer $transformer */
|
/** @var BillTransformer $transformer */
|
||||||
$transformer = app(BillTransformer::class);
|
$transformer = app(BillTransformer::class);
|
||||||
$transformer->setParameters($this->parameters);
|
$transformer->setParameters($this->parameters);
|
||||||
|
@@ -28,6 +28,7 @@ use FireflyIII\Api\V1\Controllers\Controller;
|
|||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Models\ObjectGroup;
|
use FireflyIII\Models\ObjectGroup;
|
||||||
use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface;
|
use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface;
|
||||||
|
use FireflyIII\Support\JsonApi\Enrichments\SubscriptionEnrichment;
|
||||||
use FireflyIII\Transformers\BillTransformer;
|
use FireflyIII\Transformers\BillTransformer;
|
||||||
use FireflyIII\Transformers\PiggyBankTransformer;
|
use FireflyIII\Transformers\PiggyBankTransformer;
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
@@ -79,6 +80,17 @@ class ListController extends Controller
|
|||||||
$count = $collection->count();
|
$count = $collection->count();
|
||||||
$bills = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
$bills = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||||
|
|
||||||
|
// enrich
|
||||||
|
/** @var User $admin */
|
||||||
|
$admin = auth()->user();
|
||||||
|
$enrichment = new SubscriptionEnrichment();
|
||||||
|
$enrichment->setUser($admin);
|
||||||
|
$enrichment->setConvertToNative($this->convertToNative);
|
||||||
|
$enrichment->setNative($this->nativeCurrency);
|
||||||
|
$enrichment->setStart($this->parameters->get('start'));
|
||||||
|
$enrichment->setEnd($this->parameters->get('end'));
|
||||||
|
$bills = $enrichment->enrich($bills);
|
||||||
|
|
||||||
// make paginator:
|
// make paginator:
|
||||||
$paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page'));
|
$paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page'));
|
||||||
$paginator->setPath(route('api.v1.currencies.bills', [$objectGroup->id]).$this->buildParams());
|
$paginator->setPath(route('api.v1.currencies.bills', [$objectGroup->id]).$this->buildParams());
|
||||||
|
@@ -43,6 +43,7 @@ use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
|
|||||||
use FireflyIII\Support\Http\Api\AccountFilter;
|
use FireflyIII\Support\Http\Api\AccountFilter;
|
||||||
use FireflyIII\Support\Http\Api\TransactionFilter;
|
use FireflyIII\Support\Http\Api\TransactionFilter;
|
||||||
use FireflyIII\Support\JsonApi\Enrichments\AccountEnrichment;
|
use FireflyIII\Support\JsonApi\Enrichments\AccountEnrichment;
|
||||||
|
use FireflyIII\Support\JsonApi\Enrichments\SubscriptionEnrichment;
|
||||||
use FireflyIII\Support\JsonApi\Enrichments\TransactionGroupEnrichment;
|
use FireflyIII\Support\JsonApi\Enrichments\TransactionGroupEnrichment;
|
||||||
use FireflyIII\Transformers\AccountTransformer;
|
use FireflyIII\Transformers\AccountTransformer;
|
||||||
use FireflyIII\Transformers\AvailableBudgetTransformer;
|
use FireflyIII\Transformers\AvailableBudgetTransformer;
|
||||||
@@ -182,6 +183,17 @@ class ListController extends Controller
|
|||||||
$count = $collection->count();
|
$count = $collection->count();
|
||||||
$bills = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
$bills = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
|
||||||
|
|
||||||
|
// enrich
|
||||||
|
/** @var User $admin */
|
||||||
|
$admin = auth()->user();
|
||||||
|
$enrichment = new SubscriptionEnrichment();
|
||||||
|
$enrichment->setUser($admin);
|
||||||
|
$enrichment->setConvertToNative($this->convertToNative);
|
||||||
|
$enrichment->setNative($this->nativeCurrency);
|
||||||
|
$enrichment->setStart($this->parameters->get('start'));
|
||||||
|
$enrichment->setEnd($this->parameters->get('end'));
|
||||||
|
$bills = $enrichment->enrichSingle($bills);
|
||||||
|
|
||||||
// make paginator:
|
// make paginator:
|
||||||
$paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page'));
|
$paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page'));
|
||||||
$paginator->setPath(route('api.v1.currencies.bills', [$currency->code]).$this->buildParams());
|
$paginator->setPath(route('api.v1.currencies.bills', [$currency->code]).$this->buildParams());
|
||||||
|
@@ -29,7 +29,9 @@ use FireflyIII\Http\Controllers\Controller;
|
|||||||
use FireflyIII\Models\Bill;
|
use FireflyIII\Models\Bill;
|
||||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||||
use FireflyIII\Repositories\ObjectGroup\OrganisesObjectGroups;
|
use FireflyIII\Repositories\ObjectGroup\OrganisesObjectGroups;
|
||||||
|
use FireflyIII\Support\JsonApi\Enrichments\SubscriptionEnrichment;
|
||||||
use FireflyIII\Transformers\BillTransformer;
|
use FireflyIII\Transformers\BillTransformer;
|
||||||
|
use FireflyIII\User;
|
||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
use Illuminate\Contracts\View\View;
|
use Illuminate\Contracts\View\View;
|
||||||
use Illuminate\Foundation\Application;
|
use Illuminate\Foundation\Application;
|
||||||
@@ -76,11 +78,26 @@ class IndexController extends Controller
|
|||||||
$collection = $this->repository->getBills();
|
$collection = $this->repository->getBills();
|
||||||
$total = $collection->count();
|
$total = $collection->count();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$parameters = new ParameterBag();
|
$parameters = new ParameterBag();
|
||||||
// sub one day from temp start so the last paid date is one day before it should be.
|
// sub one day from temp start so the last paid date is one day before it should be.
|
||||||
$tempStart = clone $start;
|
$tempStart = clone $start;
|
||||||
// 2023-06-23 do not sub one day from temp start, fix is in BillTransformer::payDates instead
|
// 2023-06-23 do not sub one day from temp start, fix is in BillTransformer::payDates instead
|
||||||
// $tempStart->subDay();
|
// $tempStart->subDay();
|
||||||
|
|
||||||
|
// enrich
|
||||||
|
/** @var User $admin */
|
||||||
|
$admin = auth()->user();
|
||||||
|
$enrichment = new SubscriptionEnrichment();
|
||||||
|
$enrichment->setUser($admin);
|
||||||
|
$enrichment->setConvertToNative($this->convertToNative);
|
||||||
|
$enrichment->setNative($this->defaultCurrency);
|
||||||
|
$enrichment->setStart($tempStart);
|
||||||
|
$enrichment->setEnd($end);
|
||||||
|
$collection = $enrichment->enrich($collection);
|
||||||
|
|
||||||
|
|
||||||
$parameters->set('start', $tempStart);
|
$parameters->set('start', $tempStart);
|
||||||
$parameters->set('end', $end);
|
$parameters->set('end', $end);
|
||||||
$parameters->set('convertToNative', $this->convertToNative);
|
$parameters->set('convertToNative', $this->convertToNative);
|
||||||
|
@@ -30,9 +30,11 @@ use FireflyIII\Http\Controllers\Controller;
|
|||||||
use FireflyIII\Models\Attachment;
|
use FireflyIII\Models\Attachment;
|
||||||
use FireflyIII\Models\Bill;
|
use FireflyIII\Models\Bill;
|
||||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||||
|
use FireflyIII\Support\JsonApi\Enrichments\SubscriptionEnrichment;
|
||||||
use FireflyIII\TransactionRules\Engine\RuleEngineInterface;
|
use FireflyIII\TransactionRules\Engine\RuleEngineInterface;
|
||||||
use FireflyIII\Transformers\AttachmentTransformer;
|
use FireflyIII\Transformers\AttachmentTransformer;
|
||||||
use FireflyIII\Transformers\BillTransformer;
|
use FireflyIII\Transformers\BillTransformer;
|
||||||
|
use FireflyIII\User;
|
||||||
use Illuminate\Contracts\View\Factory;
|
use Illuminate\Contracts\View\Factory;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@@ -142,6 +144,17 @@ class ShowController extends Controller
|
|||||||
$parameters->set('start', $start);
|
$parameters->set('start', $start);
|
||||||
$parameters->set('end', $end);
|
$parameters->set('end', $end);
|
||||||
|
|
||||||
|
// enrich
|
||||||
|
/** @var User $admin */
|
||||||
|
$admin = auth()->user();
|
||||||
|
$enrichment = new SubscriptionEnrichment();
|
||||||
|
$enrichment->setUser($admin);
|
||||||
|
$enrichment->setConvertToNative($this->convertToNative);
|
||||||
|
$enrichment->setNative($this->defaultCurrency);
|
||||||
|
$enrichment->setStart($start);
|
||||||
|
$enrichment->setEnd($end);
|
||||||
|
$bill = $enrichment->enrichSingle($bill);
|
||||||
|
|
||||||
/** @var BillTransformer $transformer */
|
/** @var BillTransformer $transformer */
|
||||||
$transformer = app(BillTransformer::class);
|
$transformer = app(BillTransformer::class);
|
||||||
$transformer->setParameters($parameters);
|
$transformer->setParameters($parameters);
|
||||||
|
@@ -35,7 +35,7 @@ class AttachmentTransformer extends AbstractTransformer
|
|||||||
private readonly AttachmentRepositoryInterface $repository;
|
private readonly AttachmentRepositoryInterface $repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BillTransformer constructor.
|
* AttachmentTransformer constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user