mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Various code cleanup as suggested by PHPStorm.
This commit is contained in:
parent
8b7e87ae57
commit
eb6329e556
@ -39,6 +39,7 @@ use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
|||||||
use League\Fractal\Resource\Collection as FractalCollection;
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
use League\Fractal\Resource\Item;
|
use League\Fractal\Resource\Item;
|
||||||
use League\Fractal\Serializer\JsonApiSerializer;
|
use League\Fractal\Serializer\JsonApiSerializer;
|
||||||
|
use function strlen;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AttachmentController.
|
* Class AttachmentController.
|
||||||
@ -111,7 +112,7 @@ class AttachmentController extends Controller
|
|||||||
->header('Expires', '0')
|
->header('Expires', '0')
|
||||||
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
|
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
|
||||||
->header('Pragma', 'public')
|
->header('Pragma', 'public')
|
||||||
->header('Content-Length', \strlen($content));
|
->header('Content-Length', strlen($content));
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,6 @@ use FireflyIII\Transformers\AttachmentTransformer;
|
|||||||
use FireflyIII\Transformers\BillTransformer;
|
use FireflyIII\Transformers\BillTransformer;
|
||||||
use FireflyIII\Transformers\RuleTransformer;
|
use FireflyIII\Transformers\RuleTransformer;
|
||||||
use FireflyIII\Transformers\TransactionGroupTransformer;
|
use FireflyIII\Transformers\TransactionGroupTransformer;
|
||||||
use FireflyIII\Transformers\TransactionTransformer;
|
|
||||||
use FireflyIII\User;
|
use FireflyIII\User;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
@ -303,7 +302,7 @@ class BillController extends Controller
|
|||||||
$paginator->setPath(route('api.v1.bills.transactions', [$bill->id]) . $this->buildParams());
|
$paginator->setPath(route('api.v1.bills.transactions', [$bill->id]) . $this->buildParams());
|
||||||
$transactions = $paginator->getCollection();
|
$transactions = $paginator->getCollection();
|
||||||
|
|
||||||
/** @var TransactionTransformer $transformer */
|
/** @var TransactionGroupTransformer $transformer */
|
||||||
$transformer = app(TransactionGroupTransformer::class);
|
$transformer = app(TransactionGroupTransformer::class);
|
||||||
$transformer->setParameters($this->parameters);
|
$transformer->setParameters($this->parameters);
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Api\V1\Controllers;
|
namespace FireflyIII\Api\V1\Controllers;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use FireflyIII\Api\V1\Requests\BudgetLimitRequest;
|
use FireflyIII\Api\V1\Requests\BudgetLimitRequest;
|
||||||
use FireflyIII\Api\V1\Requests\BudgetRequest;
|
use FireflyIII\Api\V1\Requests\BudgetRequest;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
@ -42,7 +43,7 @@ use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
|||||||
use League\Fractal\Resource\Collection as FractalCollection;
|
use League\Fractal\Resource\Collection as FractalCollection;
|
||||||
use League\Fractal\Resource\Item;
|
use League\Fractal\Resource\Item;
|
||||||
use League\Fractal\Serializer\JsonApiSerializer;
|
use League\Fractal\Serializer\JsonApiSerializer;
|
||||||
use Exception;
|
|
||||||
/**
|
/**
|
||||||
* Class BudgetController.
|
* Class BudgetController.
|
||||||
*
|
*
|
||||||
@ -222,8 +223,8 @@ class BudgetController extends Controller
|
|||||||
*
|
*
|
||||||
* @param BudgetLimitRequest $request
|
* @param BudgetLimitRequest $request
|
||||||
* @param Budget $budget
|
* @param Budget $budget
|
||||||
* @throws Exception
|
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function storeBudgetLimit(BudgetLimitRequest $request, Budget $budget): JsonResponse
|
public function storeBudgetLimit(BudgetLimitRequest $request, Budget $budget): JsonResponse
|
||||||
{
|
{
|
||||||
|
@ -82,7 +82,7 @@ class AccountController extends Controller
|
|||||||
if ('' === $start || '' === $end) {
|
if ('' === $start || '' === $end) {
|
||||||
throw new FireflyException('Start and end are mandatory parameters.');
|
throw new FireflyException('Start and end are mandatory parameters.');
|
||||||
}
|
}
|
||||||
|
/** @var Carbon $start */
|
||||||
$start = Carbon::createFromFormat('Y-m-d', $start);
|
$start = Carbon::createFromFormat('Y-m-d', $start);
|
||||||
$end = Carbon::createFromFormat('Y-m-d', $end);
|
$end = Carbon::createFromFormat('Y-m-d', $end);
|
||||||
$start->subDay();
|
$start->subDay();
|
||||||
@ -156,6 +156,43 @@ class AccountController extends Controller
|
|||||||
return response()->json($chartData);
|
return response()->json($chartData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Small helper function for the revenue and expense account charts.
|
||||||
|
* TODO should include Trait instead of doing this.
|
||||||
|
*
|
||||||
|
* @param Collection $accounts
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function extractNames(Collection $accounts): array
|
||||||
|
{
|
||||||
|
$return = [];
|
||||||
|
/** @var Account $account */
|
||||||
|
foreach ($accounts as $account) {
|
||||||
|
$return[$account->id] = $account->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Small helper function for the revenue and expense account charts.
|
||||||
|
* TODO should include Trait instead of doing this.
|
||||||
|
*
|
||||||
|
* @param array $names
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function expandNames(array $names): array
|
||||||
|
{
|
||||||
|
$result = [];
|
||||||
|
foreach ($names as $entry) {
|
||||||
|
$result[$entry['name']] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
*
|
*
|
||||||
@ -202,7 +239,7 @@ class AccountController extends Controller
|
|||||||
'yAxisID' => 0, // 0, 1, 2
|
'yAxisID' => 0, // 0, 1, 2
|
||||||
'entries' => [],
|
'entries' => [],
|
||||||
];
|
];
|
||||||
|
/** @var Carbon $currentStart */
|
||||||
$currentStart = clone $start;
|
$currentStart = clone $start;
|
||||||
$range = app('steam')->balanceInRange($account, $start, clone $end);
|
$range = app('steam')->balanceInRange($account, $start, clone $end);
|
||||||
$previous = round(array_values($range)[0], 12);
|
$previous = round(array_values($range)[0], 12);
|
||||||
@ -234,7 +271,7 @@ class AccountController extends Controller
|
|||||||
if ('' === $start || '' === $end) {
|
if ('' === $start || '' === $end) {
|
||||||
throw new FireflyException('Start and end are mandatory parameters.');
|
throw new FireflyException('Start and end are mandatory parameters.');
|
||||||
}
|
}
|
||||||
|
/** @var Carbon $start */
|
||||||
$start = Carbon::createFromFormat('Y-m-d', $start);
|
$start = Carbon::createFromFormat('Y-m-d', $start);
|
||||||
$end = Carbon::createFromFormat('Y-m-d', $end);
|
$end = Carbon::createFromFormat('Y-m-d', $end);
|
||||||
$start->subDay();
|
$start->subDay();
|
||||||
@ -308,41 +345,4 @@ class AccountController extends Controller
|
|||||||
return response()->json($chartData);
|
return response()->json($chartData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Small helper function for the revenue and expense account charts.
|
|
||||||
* TODO should include Trait instead of doing this.
|
|
||||||
*
|
|
||||||
* @param array $names
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function expandNames(array $names): array
|
|
||||||
{
|
|
||||||
$result = [];
|
|
||||||
foreach ($names as $entry) {
|
|
||||||
$result[$entry['name']] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Small helper function for the revenue and expense account charts.
|
|
||||||
* TODO should include Trait instead of doing this.
|
|
||||||
*
|
|
||||||
* @param Collection $accounts
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected function extractNames(Collection $accounts): array
|
|
||||||
{
|
|
||||||
$return = [];
|
|
||||||
/** @var Account $account */
|
|
||||||
foreach ($accounts as $account) {
|
|
||||||
$return[$account->id] = $account->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,9 @@ class CategoryController extends Controller
|
|||||||
if ('' === $start || '' === $end) {
|
if ('' === $start || '' === $end) {
|
||||||
throw new FireflyException('Start and end are mandatory parameters.');
|
throw new FireflyException('Start and end are mandatory parameters.');
|
||||||
}
|
}
|
||||||
|
/** @var Carbon $start */
|
||||||
$start = Carbon::createFromFormat('Y-m-d', $start);
|
$start = Carbon::createFromFormat('Y-m-d', $start);
|
||||||
|
/** @var Carbon $end */
|
||||||
$end = Carbon::createFromFormat('Y-m-d', $end);
|
$end = Carbon::createFromFormat('Y-m-d', $end);
|
||||||
$tempData = [];
|
$tempData = [];
|
||||||
$spent = $this->categoryRepository->spentInPeriodPerCurrency(new Collection, new Collection, $start, $end);
|
$spent = $this->categoryRepository->spentInPeriodPerCurrency(new Collection, new Collection, $start, $end);
|
||||||
|
@ -76,24 +76,6 @@ class ConfigurationController extends Controller
|
|||||||
return response()->json(['data' => $configData])->header('Content-Type', 'application/vnd.api+json');
|
return response()->json(['data' => $configData])->header('Content-Type', 'application/vnd.api+json');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the configuration.
|
|
||||||
*
|
|
||||||
* @param ConfigurationRequest $request
|
|
||||||
* @param string $name
|
|
||||||
*
|
|
||||||
* @return JsonResponse
|
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
|
||||||
*/
|
|
||||||
public function update(ConfigurationRequest $request, string $name): JsonResponse
|
|
||||||
{
|
|
||||||
$data = $request->getAll();
|
|
||||||
app('fireflyconfig')->set($name, $data['value']);
|
|
||||||
$configData = $this->getConfigData();
|
|
||||||
|
|
||||||
return response()->json(['data' => $configData])->header('Content-Type', 'application/vnd.api+json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all config values.
|
* Get all config values.
|
||||||
*
|
*
|
||||||
@ -119,4 +101,22 @@ class ConfigurationController extends Controller
|
|||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the configuration.
|
||||||
|
*
|
||||||
|
* @param ConfigurationRequest $request
|
||||||
|
* @param string $name
|
||||||
|
*
|
||||||
|
* @return JsonResponse
|
||||||
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||||
|
*/
|
||||||
|
public function update(ConfigurationRequest $request, string $name): JsonResponse
|
||||||
|
{
|
||||||
|
$data = $request->getAll();
|
||||||
|
app('fireflyconfig')->set($name, $data['value']);
|
||||||
|
$configData = $this->getConfigData();
|
||||||
|
|
||||||
|
return response()->json(['data' => $configData])->header('Content-Type', 'application/vnd.api+json');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,32 +56,6 @@ class Controller extends BaseController
|
|||||||
$this->parameters = $this->getParameters();
|
$this->parameters = $this->getParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to help build URI's.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
|
||||||
*/
|
|
||||||
protected function buildParams(): string
|
|
||||||
{
|
|
||||||
$return = '?';
|
|
||||||
$params = [];
|
|
||||||
foreach ($this->parameters as $key => $value) {
|
|
||||||
if ('page' === $key) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($value instanceof Carbon) {
|
|
||||||
$params[$key] = $value->format('Y-m-d');
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$params[$key] = $value;
|
|
||||||
}
|
|
||||||
$return .= http_build_query($params);
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to grab all parameters from the URI.
|
* Method to grab all parameters from the URI.
|
||||||
*
|
*
|
||||||
@ -125,4 +99,30 @@ class Controller extends BaseController
|
|||||||
return $bag;
|
return $bag;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to help build URI's.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||||
|
*/
|
||||||
|
protected function buildParams(): string
|
||||||
|
{
|
||||||
|
$return = '?';
|
||||||
|
$params = [];
|
||||||
|
foreach ($this->parameters as $key => $value) {
|
||||||
|
if ('page' === $key) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($value instanceof Carbon) {
|
||||||
|
$params[$key] = $value->format('Y-m-d');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$params[$key] = $value;
|
||||||
|
}
|
||||||
|
$return .= http_build_query($params);
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,6 +90,7 @@ class CurrencyExchangeRateController extends Controller
|
|||||||
throw new FireflyException('Unknown destination currency.');
|
throw new FireflyException('Unknown destination currency.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var Carbon $dateObj */
|
||||||
$dateObj = Carbon::createFromFormat('Y-m-d', $request->get('date') ?? date('Y-m-d'));
|
$dateObj = Carbon::createFromFormat('Y-m-d', $request->get('date') ?? date('Y-m-d'));
|
||||||
$this->parameters->set('from', $fromCurrency->code);
|
$this->parameters->set('from', $fromCurrency->code);
|
||||||
$this->parameters->set('to', $toCurrency->code);
|
$this->parameters->set('to', $toCurrency->code);
|
||||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Api\V1\Controllers;
|
namespace FireflyIII\Api\V1\Controllers;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Exception;
|
||||||
use FireflyIII\Api\V1\Requests\RuleRequest;
|
use FireflyIII\Api\V1\Requests\RuleRequest;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Jobs\ExecuteRuleOnExistingTransactions;
|
use FireflyIII\Jobs\ExecuteRuleOnExistingTransactions;
|
||||||
@ -45,7 +46,7 @@ use League\Fractal\Resource\Collection as FractalCollection;
|
|||||||
use League\Fractal\Resource\Item;
|
use League\Fractal\Resource\Item;
|
||||||
use League\Fractal\Serializer\JsonApiSerializer;
|
use League\Fractal\Serializer\JsonApiSerializer;
|
||||||
use Log;
|
use Log;
|
||||||
use Exception;
|
|
||||||
/**
|
/**
|
||||||
* Class RuleController
|
* Class RuleController
|
||||||
*/
|
*/
|
||||||
@ -183,6 +184,7 @@ class RuleController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* TODO deprecated return values in transformer.
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param Rule $rule
|
* @param Rule $rule
|
||||||
*
|
*
|
||||||
@ -193,7 +195,9 @@ class RuleController extends Controller
|
|||||||
{
|
{
|
||||||
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
|
||||||
$page = 0 === (int)$request->query('page') ? 1 : (int)$request->query('page');
|
$page = 0 === (int)$request->query('page') ? 1 : (int)$request->query('page');
|
||||||
|
/** @var Carbon $startDate */
|
||||||
$startDate = null === $request->query('start_date') ? null : Carbon::createFromFormat('Y-m-d', $request->query('start_date'));
|
$startDate = null === $request->query('start_date') ? null : Carbon::createFromFormat('Y-m-d', $request->query('start_date'));
|
||||||
|
/** @var Carbon $endDate */
|
||||||
$endDate = null === $request->query('end_date') ? null : Carbon::createFromFormat('Y-m-d', $request->query('end_date'));
|
$endDate = null === $request->query('end_date') ? null : Carbon::createFromFormat('Y-m-d', $request->query('end_date'));
|
||||||
$searchLimit = 0 === (int)$request->query('search_limit') ? (int)config('firefly.test-triggers.limit') : (int)$request->query('search_limit');
|
$searchLimit = 0 === (int)$request->query('search_limit') ? (int)config('firefly.test-triggers.limit') : (int)$request->query('search_limit');
|
||||||
$triggerLimit = 0 === (int)$request->query('triggered_limit') ? (int)config('firefly.test-triggers.range') : (int)$request->query('triggered_limit');
|
$triggerLimit = 0 === (int)$request->query('triggered_limit') ? (int)config('firefly.test-triggers.range') : (int)$request->query('triggered_limit');
|
||||||
|
@ -24,6 +24,7 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Api\V1\Controllers;
|
namespace FireflyIII\Api\V1\Controllers;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
use Exception;
|
||||||
use FireflyIII\Api\V1\Requests\RuleGroupRequest;
|
use FireflyIII\Api\V1\Requests\RuleGroupRequest;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Jobs\ExecuteRuleOnExistingTransactions;
|
use FireflyIII\Jobs\ExecuteRuleOnExistingTransactions;
|
||||||
@ -47,7 +48,6 @@ use League\Fractal\Resource\Collection as FractalCollection;
|
|||||||
use League\Fractal\Resource\Item;
|
use League\Fractal\Resource\Item;
|
||||||
use League\Fractal\Serializer\JsonApiSerializer;
|
use League\Fractal\Serializer\JsonApiSerializer;
|
||||||
use Log;
|
use Log;
|
||||||
use Exception;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class RuleGroupController
|
* Class RuleGroupController
|
||||||
@ -284,6 +284,51 @@ class RuleGroupController extends Controller
|
|||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getTestParameters(Request $request): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'page_size' => (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data,
|
||||||
|
'page' => 0 === (int)$request->query('page') ? 1 : (int)$request->query('page'),
|
||||||
|
'start_date' => null === $request->query('start_date') ? null : Carbon::createFromFormat('Y-m-d', $request->query('start_date')),
|
||||||
|
'end_date' => null === $request->query('end_date') ? null : Carbon::createFromFormat('Y-m-d', $request->query('end_date')),
|
||||||
|
'search_limit' => 0 === (int)$request->query('search_limit') ? (int)config('firefly.test-triggers.limit') : (int)$request->query('search_limit'),
|
||||||
|
'trigger_limit' => 0 === (int)$request->query('triggered_limit')
|
||||||
|
? (int)config('firefly.test-triggers.range')
|
||||||
|
: (int)$request->query(
|
||||||
|
'triggered_limit'
|
||||||
|
),
|
||||||
|
'account_list' => '' === (string)$request->query('accounts') ? [] : explode(',', $request->query('accounts')),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $accounts
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
private function getAccountParameter(array $accounts): Collection
|
||||||
|
{
|
||||||
|
$return = new Collection;
|
||||||
|
foreach ($accounts as $accountId) {
|
||||||
|
Log::debug(sprintf('Searching for asset account with id "%s"', $accountId));
|
||||||
|
$account = $this->accountRepository->findNull((int)$accountId);
|
||||||
|
if (null !== $account && AccountType::ASSET === $account->accountType->type) {
|
||||||
|
Log::debug(sprintf('Found account #%d ("%s") and its an asset account', $account->id, $account->name));
|
||||||
|
$return->push($account);
|
||||||
|
}
|
||||||
|
if (null === $account) {
|
||||||
|
Log::debug(sprintf('No asset account with id "%s"', $accountId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute the given rule group on a set of existing transactions.
|
* Execute the given rule group on a set of existing transactions.
|
||||||
*
|
*
|
||||||
@ -359,49 +404,4 @@ class RuleGroupController extends Controller
|
|||||||
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', 'application/vnd.api+json');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $accounts
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
|
||||||
private function getAccountParameter(array $accounts): Collection
|
|
||||||
{
|
|
||||||
$return = new Collection;
|
|
||||||
foreach ($accounts as $accountId) {
|
|
||||||
Log::debug(sprintf('Searching for asset account with id "%s"', $accountId));
|
|
||||||
$account = $this->accountRepository->findNull((int)$accountId);
|
|
||||||
if (null !== $account && AccountType::ASSET === $account->accountType->type) {
|
|
||||||
Log::debug(sprintf('Found account #%d ("%s") and its an asset account', $account->id, $account->name));
|
|
||||||
$return->push($account);
|
|
||||||
}
|
|
||||||
if (null === $account) {
|
|
||||||
Log::debug(sprintf('No asset account with id "%s"', $accountId));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function getTestParameters(Request $request): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'page_size' => (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data,
|
|
||||||
'page' => 0 === (int)$request->query('page') ? 1 : (int)$request->query('page'),
|
|
||||||
'start_date' => null === $request->query('start_date') ? null : Carbon::createFromFormat('Y-m-d', $request->query('start_date')),
|
|
||||||
'end_date' => null === $request->query('end_date') ? null : Carbon::createFromFormat('Y-m-d', $request->query('end_date')),
|
|
||||||
'search_limit' => 0 === (int)$request->query('search_limit') ? (int)config('firefly.test-triggers.limit') : (int)$request->query('search_limit'),
|
|
||||||
'trigger_limit' => 0 === (int)$request->query('triggered_limit')
|
|
||||||
? (int)config('firefly.test-triggers.range')
|
|
||||||
: (int)$request->query(
|
|
||||||
'triggered_limit'
|
|
||||||
),
|
|
||||||
'account_list' => '' === (string)$request->query('accounts') ? [] : explode(',', $request->query('accounts')),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,9 @@ class SummaryController extends Controller
|
|||||||
if ('' === $start || '' === $end) {
|
if ('' === $start || '' === $end) {
|
||||||
throw new FireflyException('Start and end are mandatory parameters.');
|
throw new FireflyException('Start and end are mandatory parameters.');
|
||||||
}
|
}
|
||||||
|
/** @var Carbon $start */
|
||||||
$start = Carbon::createFromFormat('Y-m-d', $start);
|
$start = Carbon::createFromFormat('Y-m-d', $start);
|
||||||
|
/** @var Carbon $end */
|
||||||
$end = Carbon::createFromFormat('Y-m-d', $end);
|
$end = Carbon::createFromFormat('Y-m-d', $end);
|
||||||
// balance information:
|
// balance information:
|
||||||
$balanceData = $this->getBalanceInformation($start, $end);
|
$balanceData = $this->getBalanceInformation($start, $end);
|
||||||
@ -114,50 +116,6 @@ class SummaryController extends Controller
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if date is outside session range.
|
|
||||||
*
|
|
||||||
* @param Carbon $date
|
|
||||||
*
|
|
||||||
* @param Carbon $start
|
|
||||||
* @param Carbon $end
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
|
||||||
*/
|
|
||||||
protected function notInDateRange(Carbon $date, Carbon $start, Carbon $end): bool // Validate a preference
|
|
||||||
{
|
|
||||||
$result = false;
|
|
||||||
if ($start->greaterThanOrEqualTo($date) && $end->greaterThanOrEqualTo($date)) {
|
|
||||||
$result = true;
|
|
||||||
}
|
|
||||||
// start and end in the past? use $end
|
|
||||||
if ($start->lessThanOrEqualTo($date) && $end->lessThanOrEqualTo($date)) {
|
|
||||||
$result = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method will scroll through the results of the spentInPeriodMc() array and return the correct info.
|
|
||||||
*
|
|
||||||
* @param array $spentInfo
|
|
||||||
* @param TransactionCurrency $currency
|
|
||||||
*
|
|
||||||
* @return float
|
|
||||||
*/
|
|
||||||
private function findInSpentArray(array $spentInfo, TransactionCurrency $currency): float
|
|
||||||
{
|
|
||||||
foreach ($spentInfo as $array) {
|
|
||||||
if ($array['currency_id'] === $currency->id) {
|
|
||||||
return $array['amount'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
@ -368,6 +326,25 @@ class SummaryController extends Controller
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will scroll through the results of the spentInPeriodMc() array and return the correct info.
|
||||||
|
*
|
||||||
|
* @param array $spentInfo
|
||||||
|
* @param TransactionCurrency $currency
|
||||||
|
*
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
private function findInSpentArray(array $spentInfo, TransactionCurrency $currency): float
|
||||||
|
{
|
||||||
|
foreach ($spentInfo as $array) {
|
||||||
|
if ($array['currency_id'] === $currency->id) {
|
||||||
|
return $array['amount'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Carbon $start
|
* @param Carbon $start
|
||||||
* @param Carbon $end
|
* @param Carbon $end
|
||||||
@ -428,4 +405,29 @@ class SummaryController extends Controller
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if date is outside session range.
|
||||||
|
*
|
||||||
|
* @param Carbon $date
|
||||||
|
*
|
||||||
|
* @param Carbon $start
|
||||||
|
* @param Carbon $end
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||||
|
*/
|
||||||
|
protected function notInDateRange(Carbon $date, Carbon $start, Carbon $end): bool // Validate a preference
|
||||||
|
{
|
||||||
|
$result = false;
|
||||||
|
if ($start->greaterThanOrEqualTo($date) && $end->greaterThanOrEqualTo($date)) {
|
||||||
|
$result = true;
|
||||||
|
}
|
||||||
|
// start and end in the past? use $end
|
||||||
|
if ($start->lessThanOrEqualTo($date) && $end->lessThanOrEqualTo($date)) {
|
||||||
|
$result = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,9 @@ class TagController extends Controller
|
|||||||
if ('' === $start || '' === $end) {
|
if ('' === $start || '' === $end) {
|
||||||
throw new FireflyException('Start and end are mandatory parameters.');
|
throw new FireflyException('Start and end are mandatory parameters.');
|
||||||
}
|
}
|
||||||
|
/** @var Carbon $start */
|
||||||
$start = Carbon::createFromFormat('Y-m-d', $start);
|
$start = Carbon::createFromFormat('Y-m-d', $start);
|
||||||
|
/** @var Carbon $end */
|
||||||
$end = Carbon::createFromFormat('Y-m-d', $end);
|
$end = Carbon::createFromFormat('Y-m-d', $end);
|
||||||
|
|
||||||
// get all tags:
|
// get all tags:
|
||||||
|
@ -70,7 +70,7 @@ class UserController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Remove the specified resource from storage.
|
* Remove the specified resource from storage.
|
||||||
*
|
*
|
||||||
* @param \FireflyIII\User $user
|
* @param User $user
|
||||||
*
|
*
|
||||||
* @return JsonResponse
|
* @return JsonResponse
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
|
@ -24,7 +24,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Api\V1\Requests;
|
namespace FireflyIII\Api\V1\Requests;
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use FireflyIII\Rules\IsBoolean;
|
use FireflyIII\Rules\IsBoolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,7 +24,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Api\V1\Requests;
|
namespace FireflyIII\Api\V1\Requests;
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use FireflyIII\Rules\IsBoolean;
|
use FireflyIII\Rules\IsBoolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +25,6 @@ namespace FireflyIII\Api\V1\Requests;
|
|||||||
|
|
||||||
use FireflyIII\Models\Bill;
|
use FireflyIII\Models\Bill;
|
||||||
use FireflyIII\Models\ImportJob;
|
use FireflyIII\Models\ImportJob;
|
||||||
use FireflyIII\Models\Transaction;
|
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Rules\IsValidAttachmentModel;
|
use FireflyIII\Rules\IsValidAttachmentModel;
|
||||||
|
|
||||||
|
@ -23,8 +23,6 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace FireflyIII\Api\V1\Requests;
|
namespace FireflyIII\Api\V1\Requests;
|
||||||
|
|
||||||
use Exception;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class AvailableBudgetRequest
|
* Class AvailableBudgetRequest
|
||||||
*
|
*
|
||||||
|
@ -90,7 +90,7 @@ class BillRequest extends Request
|
|||||||
'date' => 'required|date',
|
'date' => 'required|date',
|
||||||
'repeat_freq' => 'required|in:weekly,monthly,quarterly,half-year,yearly',
|
'repeat_freq' => 'required|in:weekly,monthly,quarterly,half-year,yearly',
|
||||||
'skip' => 'between:0,31',
|
'skip' => 'between:0,31',
|
||||||
'automatch' => [new IsBoolean],
|
'automatch' => [new IsBoolean], // TODO isn't automatch deprecated?
|
||||||
'active' => [new IsBoolean],
|
'active' => [new IsBoolean],
|
||||||
'notes' => 'between:1,65536',
|
'notes' => 'between:1,65536',
|
||||||
];
|
];
|
||||||
|
@ -86,6 +86,68 @@ class RecurrenceStoreRequest extends Request
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the transaction data as it is found in the submitted data. It's a complex method according to code
|
||||||
|
* standards but it just has a lot of ??-statements because of the fields that may or may not exist.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @SuppressWarnings(PHPMD.NPathComplexity)
|
||||||
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||||
|
*/
|
||||||
|
private function getTransactionData(): array
|
||||||
|
{
|
||||||
|
$return = [];
|
||||||
|
// transaction data:
|
||||||
|
/** @var array $transactions */
|
||||||
|
$transactions = $this->get('transactions');
|
||||||
|
/** @var array $transaction */
|
||||||
|
foreach ($transactions as $transaction) {
|
||||||
|
$return[] = [
|
||||||
|
'amount' => $transaction['amount'],
|
||||||
|
'currency_id' => isset($transaction['currency_id']) ? (int)$transaction['currency_id'] : null,
|
||||||
|
'currency_code' => $transaction['currency_code'] ?? null,
|
||||||
|
'foreign_amount' => $transaction['foreign_amount'] ?? null,
|
||||||
|
'foreign_currency_id' => isset($transaction['foreign_currency_id']) ? (int)$transaction['foreign_currency_id'] : null,
|
||||||
|
'foreign_currency_code' => $transaction['foreign_currency_code'] ?? null,
|
||||||
|
'budget_id' => isset($transaction['budget_id']) ? (int)$transaction['budget_id'] : null,
|
||||||
|
'budget_name' => $transaction['budget_name'] ?? null,
|
||||||
|
'category_id' => isset($transaction['category_id']) ? (int)$transaction['category_id'] : null,
|
||||||
|
'category_name' => $transaction['category_name'] ?? null,
|
||||||
|
'source_id' => isset($transaction['source_id']) ? (int)$transaction['source_id'] : null,
|
||||||
|
'source_name' => isset($transaction['source_name']) ? (string)$transaction['source_name'] : null,
|
||||||
|
'destination_id' => isset($transaction['destination_id']) ? (int)$transaction['destination_id'] : null,
|
||||||
|
'destination_name' => isset($transaction['destination_name']) ? (string)$transaction['destination_name'] : null,
|
||||||
|
'description' => $transaction['description'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the repetition data as it is found in the submitted data.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getRepetitionData(): array
|
||||||
|
{
|
||||||
|
$return = [];
|
||||||
|
// repetition data:
|
||||||
|
/** @var array $repetitions */
|
||||||
|
$repetitions = $this->get('repetitions');
|
||||||
|
/** @var array $repetition */
|
||||||
|
foreach ($repetitions as $repetition) {
|
||||||
|
$return[] = [
|
||||||
|
'type' => $repetition['type'],
|
||||||
|
'moment' => $repetition['moment'],
|
||||||
|
'skip' => (int)$repetition['skip'],
|
||||||
|
'weekend' => (int)$repetition['weekend'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The rules that the incoming request must be matched against.
|
* The rules that the incoming request must be matched against.
|
||||||
*
|
*
|
||||||
@ -148,67 +210,4 @@ class RecurrenceStoreRequest extends Request
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the repetition data as it is found in the submitted data.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function getRepetitionData(): array
|
|
||||||
{
|
|
||||||
$return = [];
|
|
||||||
// repetition data:
|
|
||||||
/** @var array $repetitions */
|
|
||||||
$repetitions = $this->get('repetitions');
|
|
||||||
/** @var array $repetition */
|
|
||||||
foreach ($repetitions as $repetition) {
|
|
||||||
$return[] = [
|
|
||||||
'type' => $repetition['type'],
|
|
||||||
'moment' => $repetition['moment'],
|
|
||||||
'skip' => (int)$repetition['skip'],
|
|
||||||
'weekend' => (int)$repetition['weekend'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the transaction data as it is found in the submitted data. It's a complex method according to code
|
|
||||||
* standards but it just has a lot of ??-statements because of the fields that may or may not exist.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* @SuppressWarnings(PHPMD.NPathComplexity)
|
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
|
||||||
*/
|
|
||||||
private function getTransactionData(): array
|
|
||||||
{
|
|
||||||
$return = [];
|
|
||||||
// transaction data:
|
|
||||||
/** @var array $transactions */
|
|
||||||
$transactions = $this->get('transactions');
|
|
||||||
/** @var array $transaction */
|
|
||||||
foreach ($transactions as $transaction) {
|
|
||||||
$return[] = [
|
|
||||||
'amount' => $transaction['amount'],
|
|
||||||
'currency_id' => isset($transaction['currency_id']) ? (int)$transaction['currency_id'] : null,
|
|
||||||
'currency_code' => $transaction['currency_code'] ?? null,
|
|
||||||
'foreign_amount' => $transaction['foreign_amount'] ?? null,
|
|
||||||
'foreign_currency_id' => isset($transaction['foreign_currency_id']) ? (int)$transaction['foreign_currency_id'] : null,
|
|
||||||
'foreign_currency_code' => $transaction['foreign_currency_code'] ?? null,
|
|
||||||
'budget_id' => isset($transaction['budget_id']) ? (int)$transaction['budget_id'] : null,
|
|
||||||
'budget_name' => $transaction['budget_name'] ?? null,
|
|
||||||
'category_id' => isset($transaction['category_id']) ? (int)$transaction['category_id'] : null,
|
|
||||||
'category_name' => $transaction['category_name'] ?? null,
|
|
||||||
'source_id' => isset($transaction['source_id']) ? (int)$transaction['source_id'] : null,
|
|
||||||
'source_name' => isset($transaction['source_name']) ? (string)$transaction['source_name'] : null,
|
|
||||||
'destination_id' => isset($transaction['destination_id']) ? (int)$transaction['destination_id'] : null,
|
|
||||||
'destination_name' => isset($transaction['destination_name']) ? (string)$transaction['destination_name'] : null,
|
|
||||||
'description' => $transaction['description'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,68 @@ class RecurrenceUpdateRequest extends Request
|
|||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the transaction data as it is found in the submitted data. It's a complex method according to code
|
||||||
|
* standards but it just has a lot of ??-statements because of the fields that may or may not exist.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @SuppressWarnings(PHPMD.NPathComplexity)
|
||||||
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||||
|
*/
|
||||||
|
private function getTransactionData(): array
|
||||||
|
{
|
||||||
|
$return = [];
|
||||||
|
// transaction data:
|
||||||
|
/** @var array $transactions */
|
||||||
|
$transactions = $this->get('transactions');
|
||||||
|
/** @var array $transaction */
|
||||||
|
foreach ($transactions as $transaction) {
|
||||||
|
$return[] = [
|
||||||
|
'amount' => $transaction['amount'],
|
||||||
|
'currency_id' => isset($transaction['currency_id']) ? (int)$transaction['currency_id'] : null,
|
||||||
|
'currency_code' => $transaction['currency_code'] ?? null,
|
||||||
|
'foreign_amount' => $transaction['foreign_amount'] ?? null,
|
||||||
|
'foreign_currency_id' => isset($transaction['foreign_currency_id']) ? (int)$transaction['foreign_currency_id'] : null,
|
||||||
|
'foreign_currency_code' => $transaction['foreign_currency_code'] ?? null,
|
||||||
|
'budget_id' => isset($transaction['budget_id']) ? (int)$transaction['budget_id'] : null,
|
||||||
|
'budget_name' => $transaction['budget_name'] ?? null,
|
||||||
|
'category_id' => isset($transaction['category_id']) ? (int)$transaction['category_id'] : null,
|
||||||
|
'category_name' => $transaction['category_name'] ?? null,
|
||||||
|
'source_id' => isset($transaction['source_id']) ? (int)$transaction['source_id'] : null,
|
||||||
|
'source_name' => isset($transaction['source_name']) ? (string)$transaction['source_name'] : null,
|
||||||
|
'destination_id' => isset($transaction['destination_id']) ? (int)$transaction['destination_id'] : null,
|
||||||
|
'destination_name' => isset($transaction['destination_name']) ? (string)$transaction['destination_name'] : null,
|
||||||
|
'description' => $transaction['description'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the repetition data as it is found in the submitted data.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getRepetitionData(): array
|
||||||
|
{
|
||||||
|
$return = [];
|
||||||
|
// repetition data:
|
||||||
|
/** @var array $repetitions */
|
||||||
|
$repetitions = $this->get('repetitions');
|
||||||
|
/** @var array $repetition */
|
||||||
|
foreach ($repetitions as $repetition) {
|
||||||
|
$return[] = [
|
||||||
|
'type' => $repetition['type'],
|
||||||
|
'moment' => $repetition['moment'],
|
||||||
|
'skip' => (int)$repetition['skip'],
|
||||||
|
'weekend' => (int)$repetition['weekend'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The rules that the incoming request must be matched against.
|
* The rules that the incoming request must be matched against.
|
||||||
*
|
*
|
||||||
@ -148,67 +210,4 @@ class RecurrenceUpdateRequest extends Request
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the repetition data as it is found in the submitted data.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function getRepetitionData(): array
|
|
||||||
{
|
|
||||||
$return = [];
|
|
||||||
// repetition data:
|
|
||||||
/** @var array $repetitions */
|
|
||||||
$repetitions = $this->get('repetitions');
|
|
||||||
/** @var array $repetition */
|
|
||||||
foreach ($repetitions as $repetition) {
|
|
||||||
$return[] = [
|
|
||||||
'type' => $repetition['type'],
|
|
||||||
'moment' => $repetition['moment'],
|
|
||||||
'skip' => (int)$repetition['skip'],
|
|
||||||
'weekend' => (int)$repetition['weekend'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the transaction data as it is found in the submitted data. It's a complex method according to code
|
|
||||||
* standards but it just has a lot of ??-statements because of the fields that may or may not exist.
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
* @SuppressWarnings(PHPMD.NPathComplexity)
|
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
|
||||||
*/
|
|
||||||
private function getTransactionData(): array
|
|
||||||
{
|
|
||||||
$return = [];
|
|
||||||
// transaction data:
|
|
||||||
/** @var array $transactions */
|
|
||||||
$transactions = $this->get('transactions');
|
|
||||||
/** @var array $transaction */
|
|
||||||
foreach ($transactions as $transaction) {
|
|
||||||
$return[] = [
|
|
||||||
'amount' => $transaction['amount'],
|
|
||||||
'currency_id' => isset($transaction['currency_id']) ? (int)$transaction['currency_id'] : null,
|
|
||||||
'currency_code' => $transaction['currency_code'] ?? null,
|
|
||||||
'foreign_amount' => $transaction['foreign_amount'] ?? null,
|
|
||||||
'foreign_currency_id' => isset($transaction['foreign_currency_id']) ? (int)$transaction['foreign_currency_id'] : null,
|
|
||||||
'foreign_currency_code' => $transaction['foreign_currency_code'] ?? null,
|
|
||||||
'budget_id' => isset($transaction['budget_id']) ? (int)$transaction['budget_id'] : null,
|
|
||||||
'budget_name' => $transaction['budget_name'] ?? null,
|
|
||||||
'category_id' => isset($transaction['category_id']) ? (int)$transaction['category_id'] : null,
|
|
||||||
'category_name' => $transaction['category_name'] ?? null,
|
|
||||||
'source_id' => isset($transaction['source_id']) ? (int)$transaction['source_id'] : null,
|
|
||||||
'source_name' => isset($transaction['source_name']) ? (string)$transaction['source_name'] : null,
|
|
||||||
'destination_id' => isset($transaction['destination_id']) ? (int)$transaction['destination_id'] : null,
|
|
||||||
'destination_name' => isset($transaction['destination_name']) ? (string)$transaction['destination_name'] : null,
|
|
||||||
'description' => $transaction['description'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ namespace FireflyIII\Api\V1\Requests;
|
|||||||
|
|
||||||
use FireflyIII\Rules\IsBoolean;
|
use FireflyIII\Rules\IsBoolean;
|
||||||
use Illuminate\Validation\Validator;
|
use Illuminate\Validation\Validator;
|
||||||
|
use function is_array;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,6 +80,48 @@ class RuleRequest extends Request
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getRuleTriggers(): array
|
||||||
|
{
|
||||||
|
$triggers = $this->get('triggers');
|
||||||
|
$return = [];
|
||||||
|
if (is_array($triggers)) {
|
||||||
|
foreach ($triggers as $trigger) {
|
||||||
|
$return[] = [
|
||||||
|
'type' => $trigger['type'],
|
||||||
|
'value' => $trigger['value'],
|
||||||
|
'active' => $this->convertBoolean((string)($trigger['active'] ?? 'false')),
|
||||||
|
'stop_processing' => $this->convertBoolean((string)($trigger['stop_processing'] ?? 'false')),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getRuleActions(): array
|
||||||
|
{
|
||||||
|
$actions = $this->get('actions');
|
||||||
|
$return = [];
|
||||||
|
if (is_array($actions)) {
|
||||||
|
foreach ($actions as $action) {
|
||||||
|
$return[] = [
|
||||||
|
'type' => $action['type'],
|
||||||
|
'value' => $action['value'],
|
||||||
|
'active' => $this->convertBoolean((string)($action['active'] ?? 'false')),
|
||||||
|
'stop_processing' => $this->convertBoolean((string)($action['stop_processing'] ?? 'false')),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The rules that the incoming request must be matched against.
|
* The rules that the incoming request must be matched against.
|
||||||
*
|
*
|
||||||
@ -131,6 +174,21 @@ class RuleRequest extends Request
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an error to the validator when there are no repetitions in the array of data.
|
||||||
|
*
|
||||||
|
* @param Validator $validator
|
||||||
|
*/
|
||||||
|
protected function atLeastOneTrigger(Validator $validator): void
|
||||||
|
{
|
||||||
|
$data = $validator->getData();
|
||||||
|
$triggers = $data['triggers'] ?? [];
|
||||||
|
// need at least one trigger
|
||||||
|
if (0 === count($triggers)) {
|
||||||
|
$validator->errors()->add('title', (string)trans('validation.at_least_one_trigger'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an error to the validator when there are no repetitions in the array of data.
|
* Adds an error to the validator when there are no repetitions in the array of data.
|
||||||
*
|
*
|
||||||
@ -145,61 +203,4 @@ class RuleRequest extends Request
|
|||||||
$validator->errors()->add('title', (string)trans('validation.at_least_one_action'));
|
$validator->errors()->add('title', (string)trans('validation.at_least_one_action'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds an error to the validator when there are no repetitions in the array of data.
|
|
||||||
*
|
|
||||||
* @param Validator $validator
|
|
||||||
*/
|
|
||||||
protected function atLeastOneTrigger(Validator $validator): void
|
|
||||||
{
|
|
||||||
$data = $validator->getData();
|
|
||||||
$triggers = $data['triggers'] ?? [];
|
|
||||||
// need at least one trugger
|
|
||||||
if (0 === count($triggers)) {
|
|
||||||
$validator->errors()->add('title', (string)trans('validation.at_least_one_trigger'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function getRuleActions(): array
|
|
||||||
{
|
|
||||||
$actions = $this->get('actions');
|
|
||||||
$return = [];
|
|
||||||
if (\is_array($actions)) {
|
|
||||||
foreach ($actions as $action) {
|
|
||||||
$return[] = [
|
|
||||||
'type' => $action['type'],
|
|
||||||
'value' => $action['value'],
|
|
||||||
'active' => $this->convertBoolean((string)($action['active'] ?? 'false')),
|
|
||||||
'stop_processing' => $this->convertBoolean((string)($action['stop_processing'] ?? 'false')),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function getRuleTriggers(): array
|
|
||||||
{
|
|
||||||
$triggers = $this->get('triggers');
|
|
||||||
$return = [];
|
|
||||||
if (\is_array($triggers)) {
|
|
||||||
foreach ($triggers as $trigger) {
|
|
||||||
$return[] = [
|
|
||||||
'type' => $trigger['type'],
|
|
||||||
'value' => $trigger['value'],
|
|
||||||
'active' => $this->convertBoolean((string)($trigger['active'] ?? 'false')),
|
|
||||||
'stop_processing' => $this->convertBoolean((string)($trigger['stop_processing'] ?? 'false')),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,101 @@ class TransactionStoreRequest extends Request
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get transaction data.
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||||
|
* @SuppressWarnings(PHPMD.NPathComplexity)
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getTransactionData(): array
|
||||||
|
{
|
||||||
|
$return = [];
|
||||||
|
/**
|
||||||
|
* @var int $index
|
||||||
|
* @var array $transaction
|
||||||
|
*/
|
||||||
|
foreach ($this->get('transactions') as $index => $transaction) {
|
||||||
|
$object = new NullArrayObject($transaction);
|
||||||
|
$return[] = [
|
||||||
|
'type' => $this->stringFromValue($object['type']),
|
||||||
|
'date' => $this->dateFromValue($object['date']),
|
||||||
|
'order' => $this->integerFromValue((string)$object['order']),
|
||||||
|
|
||||||
|
'currency_id' => $this->integerFromValue($object['currency_id']),
|
||||||
|
'currency_code' => $this->stringFromValue($object['currency_code']),
|
||||||
|
|
||||||
|
// foreign currency info:
|
||||||
|
'foreign_currency_id' => $this->integerFromValue((string)$object['foreign_currency_id']),
|
||||||
|
'foreign_currency_code' => $this->stringFromValue($object['foreign_currency_code']),
|
||||||
|
|
||||||
|
// amount and foreign amount. Cannot be 0.
|
||||||
|
'amount' => $this->stringFromValue((string)$object['amount']),
|
||||||
|
'foreign_amount' => $this->stringFromValue((string)$object['foreign_amount']),
|
||||||
|
|
||||||
|
// description.
|
||||||
|
'description' => $this->stringFromValue($object['description']),
|
||||||
|
|
||||||
|
// source of transaction. If everything is null, assume cash account.
|
||||||
|
'source_id' => $this->integerFromValue((string)$object['source_id']),
|
||||||
|
'source_name' => $this->stringFromValue($object['source_name']),
|
||||||
|
|
||||||
|
// destination of transaction. If everything is null, assume cash account.
|
||||||
|
'destination_id' => $this->integerFromValue((string)$object['destination_id']),
|
||||||
|
'destination_name' => $this->stringFromValue($object['destination_name']),
|
||||||
|
|
||||||
|
// budget info
|
||||||
|
'budget_id' => $this->integerFromValue((string)$object['budget_id']),
|
||||||
|
'budget_name' => $this->stringFromValue($object['budget_name']),
|
||||||
|
|
||||||
|
// category info
|
||||||
|
'category_id' => $this->integerFromValue((string)$object['category_id']),
|
||||||
|
'category_name' => $this->stringFromValue($object['category_name']),
|
||||||
|
|
||||||
|
// journal bill reference. Optional. Will only work for withdrawals
|
||||||
|
'bill_id' => $this->integerFromValue((string)$object['bill_id']),
|
||||||
|
'bill_name' => $this->stringFromValue($object['bill_name']),
|
||||||
|
|
||||||
|
// piggy bank reference. Optional. Will only work for transfers
|
||||||
|
'piggy_bank_id' => $this->integerFromValue((string)$object['piggy_bank_id']),
|
||||||
|
'piggy_bank_name' => $this->stringFromValue($object['piggy_bank_name']),
|
||||||
|
|
||||||
|
// some other interesting properties
|
||||||
|
'reconciled' => $this->convertBoolean((string)$object['reconciled']),
|
||||||
|
'notes' => $this->stringFromValue($object['notes']),
|
||||||
|
'tags' => $this->arrayFromValue($object['tags']),
|
||||||
|
|
||||||
|
// all custom fields:
|
||||||
|
'internal_reference' => $this->stringFromValue($object['internal_reference']),
|
||||||
|
'external_id' => $this->stringFromValue($object['external_id']),
|
||||||
|
'original_source' => sprintf('ff3-v%s|api-v%s', config('firefly.version'), config('firefly.api_version')),
|
||||||
|
'recurrence_id' => $this->integerFromValue($object['recurrence_id']),
|
||||||
|
'bunq_payment_id' => $this->stringFromValue($object['bunq_payment_id']),
|
||||||
|
|
||||||
|
'sepa_cc' => $this->stringFromValue($object['sepa_cc']),
|
||||||
|
'sepa_ct_op' => $this->stringFromValue($object['sepa_ct_op']),
|
||||||
|
'sepa_ct_id' => $this->stringFromValue($object['sepa_ct_id']),
|
||||||
|
'sepa_db' => $this->stringFromValue($object['sepa_db']),
|
||||||
|
'sepa_country' => $this->stringFromValue($object['sepa_country']),
|
||||||
|
'sepa_ep' => $this->stringFromValue($object['sepa_ep']),
|
||||||
|
'sepa_ci' => $this->stringFromValue($object['sepa_ci']),
|
||||||
|
'sepa_batch_id' => $this->stringFromValue($object['sepa_batch_id']),
|
||||||
|
|
||||||
|
|
||||||
|
// custom date fields. Must be Carbon objects. Presence is optional.
|
||||||
|
'interest_date' => $this->dateFromValue($object['interest_date']),
|
||||||
|
'book_date' => $this->dateFromValue($object['book_date']),
|
||||||
|
'process_date' => $this->dateFromValue($object['process_date']),
|
||||||
|
'due_date' => $this->dateFromValue($object['due_date']),
|
||||||
|
'payment_date' => $this->dateFromValue($object['payment_date']),
|
||||||
|
'invoice_date' => $this->dateFromValue($object['invoice_date']),
|
||||||
|
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The rules that the incoming request must be matched against.
|
* The rules that the incoming request must be matched against.
|
||||||
*
|
*
|
||||||
@ -187,99 +282,4 @@ class TransactionStoreRequest extends Request
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get transaction data.
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
|
||||||
* @SuppressWarnings(PHPMD.NPathComplexity)
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function getTransactionData(): array
|
|
||||||
{
|
|
||||||
$return = [];
|
|
||||||
/**
|
|
||||||
* @var int $index
|
|
||||||
* @var array $transaction
|
|
||||||
*/
|
|
||||||
foreach ($this->get('transactions') as $index => $transaction) {
|
|
||||||
$object = new NullArrayObject($transaction);
|
|
||||||
$return[] = [
|
|
||||||
'type' => $this->stringFromValue($object['type']),
|
|
||||||
'date' => $this->dateFromValue($object['date']),
|
|
||||||
'order' => $this->integerFromValue((string)$object['order']),
|
|
||||||
|
|
||||||
'currency_id' => $this->integerFromValue($object['currency_id']),
|
|
||||||
'currency_code' => $this->stringFromValue($object['currency_code']),
|
|
||||||
|
|
||||||
// foreign currency info:
|
|
||||||
'foreign_currency_id' => $this->integerFromValue((string)$object['foreign_currency_id']),
|
|
||||||
'foreign_currency_code' => $this->stringFromValue($object['foreign_currency_code']),
|
|
||||||
|
|
||||||
// amount and foreign amount. Cannot be 0.
|
|
||||||
'amount' => $this->stringFromValue((string)$object['amount']),
|
|
||||||
'foreign_amount' => $this->stringFromValue((string)$object['foreign_amount']),
|
|
||||||
|
|
||||||
// description.
|
|
||||||
'description' => $this->stringFromValue($object['description']),
|
|
||||||
|
|
||||||
// source of transaction. If everything is null, assume cash account.
|
|
||||||
'source_id' => $this->integerFromValue((string)$object['source_id']),
|
|
||||||
'source_name' => $this->stringFromValue($object['source_name']),
|
|
||||||
|
|
||||||
// destination of transaction. If everything is null, assume cash account.
|
|
||||||
'destination_id' => $this->integerFromValue((string)$object['destination_id']),
|
|
||||||
'destination_name' => $this->stringFromValue($object['destination_name']),
|
|
||||||
|
|
||||||
// budget info
|
|
||||||
'budget_id' => $this->integerFromValue((string)$object['budget_id']),
|
|
||||||
'budget_name' => $this->stringFromValue($object['budget_name']),
|
|
||||||
|
|
||||||
// category info
|
|
||||||
'category_id' => $this->integerFromValue((string)$object['category_id']),
|
|
||||||
'category_name' => $this->stringFromValue($object['category_name']),
|
|
||||||
|
|
||||||
// journal bill reference. Optional. Will only work for withdrawals
|
|
||||||
'bill_id' => $this->integerFromValue((string)$object['bill_id']),
|
|
||||||
'bill_name' => $this->stringFromValue($object['bill_name']),
|
|
||||||
|
|
||||||
// piggy bank reference. Optional. Will only work for transfers
|
|
||||||
'piggy_bank_id' => $this->integerFromValue((string)$object['piggy_bank_id']),
|
|
||||||
'piggy_bank_name' => $this->stringFromValue($object['piggy_bank_name']),
|
|
||||||
|
|
||||||
// some other interesting properties
|
|
||||||
'reconciled' => $this->convertBoolean((string)$object['reconciled']),
|
|
||||||
'notes' => $this->stringFromValue($object['notes']),
|
|
||||||
'tags' => $this->arrayFromValue($object['tags']),
|
|
||||||
|
|
||||||
// all custom fields:
|
|
||||||
'internal_reference' => $this->stringFromValue($object['internal_reference']),
|
|
||||||
'external_id' => $this->stringFromValue($object['external_id']),
|
|
||||||
'original_source' => sprintf('ff3-v%s|api-v%s', config('firefly.version'), config('firefly.api_version')),
|
|
||||||
'recurrence_id' => $this->integerFromValue($object['recurrence_id']),
|
|
||||||
'bunq_payment_id' => $this->stringFromValue($object['bunq_payment_id']),
|
|
||||||
|
|
||||||
'sepa_cc' => $this->stringFromValue($object['sepa_cc']),
|
|
||||||
'sepa_ct_op' => $this->stringFromValue($object['sepa_ct_op']),
|
|
||||||
'sepa_ct_id' => $this->stringFromValue($object['sepa_ct_id']),
|
|
||||||
'sepa_db' => $this->stringFromValue($object['sepa_db']),
|
|
||||||
'sepa_country' => $this->stringFromValue($object['sepa_country']),
|
|
||||||
'sepa_ep' => $this->stringFromValue($object['sepa_ep']),
|
|
||||||
'sepa_ci' => $this->stringFromValue($object['sepa_ci']),
|
|
||||||
'sepa_batch_id' => $this->stringFromValue($object['sepa_batch_id']),
|
|
||||||
|
|
||||||
|
|
||||||
// custom date fields. Must be Carbon objects. Presence is optional.
|
|
||||||
'interest_date' => $this->dateFromValue($object['interest_date']),
|
|
||||||
'book_date' => $this->dateFromValue($object['book_date']),
|
|
||||||
'process_date' => $this->dateFromValue($object['process_date']),
|
|
||||||
'due_date' => $this->dateFromValue($object['due_date']),
|
|
||||||
'payment_date' => $this->dateFromValue($object['payment_date']),
|
|
||||||
'invoice_date' => $this->dateFromValue($object['invoice_date']),
|
|
||||||
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -136,6 +136,60 @@ class TransactionUpdateRequest extends Request
|
|||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get transaction data.
|
||||||
|
*
|
||||||
|
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
||||||
|
* @SuppressWarnings(PHPMD.NPathComplexity)
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getTransactionData(): array
|
||||||
|
{
|
||||||
|
$return = [];
|
||||||
|
/**
|
||||||
|
* @var int $index
|
||||||
|
* @var array $transaction
|
||||||
|
*/
|
||||||
|
foreach ($this->get('transactions') as $index => $transaction) {
|
||||||
|
// default response is to update nothing in the transaction:
|
||||||
|
$current = [];
|
||||||
|
|
||||||
|
// for each field, add it to the array if a reference is present in the request:
|
||||||
|
foreach ($this->integerFields as $fieldName) {
|
||||||
|
if (array_key_exists($fieldName, $transaction)) {
|
||||||
|
$current[$fieldName] = $this->integerFromValue((string)$transaction[$fieldName]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->stringFields as $fieldName) {
|
||||||
|
if (array_key_exists($fieldName, $transaction)) {
|
||||||
|
$current[$fieldName] = $this->stringFromValue((string)$transaction[$fieldName]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->dateFields as $fieldName) {
|
||||||
|
if (array_key_exists($fieldName, $transaction)) {
|
||||||
|
$current[$fieldName] = $this->dateFromValue((string)$transaction[$fieldName]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->booleanFields as $fieldName) {
|
||||||
|
if (array_key_exists($fieldName, $transaction)) {
|
||||||
|
$current[$fieldName] = $this->convertBoolean((string)$transaction[$fieldName]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->arrayFields as $fieldName) {
|
||||||
|
if (array_key_exists($fieldName, $transaction)) {
|
||||||
|
$current[$fieldName] = $this->arrayFromValue($transaction[$fieldName]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$return[] = $current;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The rules that the incoming request must be matched against.
|
* The rules that the incoming request must be matched against.
|
||||||
*
|
*
|
||||||
@ -261,58 +315,4 @@ class TransactionUpdateRequest extends Request
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get transaction data.
|
|
||||||
*
|
|
||||||
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
|
|
||||||
* @SuppressWarnings(PHPMD.NPathComplexity)
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function getTransactionData(): array
|
|
||||||
{
|
|
||||||
$return = [];
|
|
||||||
/**
|
|
||||||
* @var int $index
|
|
||||||
* @var array $transaction
|
|
||||||
*/
|
|
||||||
foreach ($this->get('transactions') as $index => $transaction) {
|
|
||||||
// default response is to update nothing in the transaction:
|
|
||||||
$current = [];
|
|
||||||
|
|
||||||
// for each field, add it to the array if a reference is present in the request:
|
|
||||||
foreach ($this->integerFields as $fieldName) {
|
|
||||||
if (array_key_exists($fieldName, $transaction)) {
|
|
||||||
$current[$fieldName] = $this->integerFromValue((string)$transaction[$fieldName]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->stringFields as $fieldName) {
|
|
||||||
if (array_key_exists($fieldName, $transaction)) {
|
|
||||||
$current[$fieldName] = $this->stringFromValue((string)$transaction[$fieldName]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->dateFields as $fieldName) {
|
|
||||||
if (array_key_exists($fieldName, $transaction)) {
|
|
||||||
$current[$fieldName] = $this->dateFromValue((string)$transaction[$fieldName]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->booleanFields as $fieldName) {
|
|
||||||
if (array_key_exists($fieldName, $transaction)) {
|
|
||||||
$current[$fieldName] = $this->convertBoolean((string)$transaction[$fieldName]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this->arrayFields as $fieldName) {
|
|
||||||
if (array_key_exists($fieldName, $transaction)) {
|
|
||||||
$current[$fieldName] = $this->arrayFromValue($transaction[$fieldName]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$return[] = $current;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user