Restructure code to rename a variable.

This commit is contained in:
James Cole
2018-06-30 05:21:21 +02:00
parent 2d7b7c2f3f
commit c9356c1237
50 changed files with 325 additions and 321 deletions

View File

@@ -49,10 +49,12 @@ class AutomationHandler
$user = $repository->findNull($event->userId); $user = $repository->findNull($event->userId);
if (null === $user) { if (null === $user) {
Log::debug('User is NULL'); Log::debug('User is NULL');
return true; return true;
} }
if ($event->journals->count() === 0) { if ($event->journals->count() === 0) {
Log::debug('No journals.'); Log::debug('No journals.');
return true; return true;
} }

View File

@@ -321,6 +321,14 @@ class JournalCollector implements JournalCollectorInterface
return $journals; return $journals;
} }
/**
* @return EloquentBuilder
*/
public function getQuery(): EloquentBuilder
{
return $this->query;
}
/** /**
* @return JournalCollectorInterface * @return JournalCollectorInterface
*/ */
@@ -768,14 +776,6 @@ class JournalCollector implements JournalCollectorInterface
return $this; return $this;
} }
/**
* @return EloquentBuilder
*/
public function getQuery(): EloquentBuilder
{
return $this->query;
}
/** /**
* @param Collection $set * @param Collection $set
* *

View File

@@ -181,11 +181,11 @@ class MassController extends Controller
if (null !== $journal) { if (null !== $journal) {
// get optional fields: // get optional fields:
$what = strtolower($this->repository->getTransactionType($journal)); $what = strtolower($this->repository->getTransactionType($journal));
$sourceAccountId = $request->get('source_account_id')[$journal->id] ?? null; $sourceAccountId = $request->get('source_id')[$journal->id] ?? null;
$currencyId = $request->get('transaction_currency_id')[$journal->id] ?? 1; $currencyId = $request->get('transaction_currency_id')[$journal->id] ?? 1;
$sourceAccountName = $request->get('source_account_name')[$journal->id] ?? null; $sourceAccountName = $request->get('source_name')[$journal->id] ?? null;
$destAccountId = $request->get('destination_account_id')[$journal->id] ?? null; $destAccountId = $request->get('destination_id')[$journal->id] ?? null;
$destAccountName = $request->get('destination_account_name')[$journal->id] ?? null; $destAccountName = $request->get('destination_name')[$journal->id] ?? null;
$budgetId = (int)($request->get('budget_id')[$journal->id] ?? 0.0); $budgetId = (int)($request->get('budget_id')[$journal->id] ?? 0.0);
$category = $request->get('category')[$journal->id]; $category = $request->get('category')[$journal->id];
$tags = $journal->tags->pluck('tag')->toArray(); $tags = $journal->tags->pluck('tag')->toArray();

View File

@@ -99,10 +99,10 @@ class SingleController extends Controller
$preFilled = [ $preFilled = [
'description' => $journal->description, 'description' => $journal->description,
'source_account_id' => $source->id, 'source_id' => $source->id,
'source_account_name' => $source->name, 'source_name' => $source->name,
'destination_account_id' => $destination->id, 'destination_id' => $destination->id,
'destination_account_name' => $destination->name, 'destination_name' => $destination->name,
'amount' => $amount, 'amount' => $amount,
'source_amount' => $amount, 'source_amount' => $amount,
'destination_amount' => $foreignAmount, 'destination_amount' => $foreignAmount,
@@ -152,10 +152,10 @@ class SingleController extends Controller
$source = (int)$request->get('source'); $source = (int)$request->get('source');
if (($what === 'withdrawal' || $what === 'transfer') && $source > 0) { if (($what === 'withdrawal' || $what === 'transfer') && $source > 0) {
$preFilled['source_account_id'] = $source; $preFilled['source_id'] = $source;
} }
if ($what === 'deposit' && $source > 0) { if ($what === 'deposit' && $source > 0) {
$preFilled['destination_account_id'] = $source; $preFilled['destination_id'] = $source;
} }
session()->put('preFilled', $preFilled); session()->put('preFilled', $preFilled);
@@ -266,10 +266,10 @@ class SingleController extends Controller
'category' => $repository->getJournalCategoryName($journal), 'category' => $repository->getJournalCategoryName($journal),
'budget_id' => $repository->getJournalBudgetId($journal), 'budget_id' => $repository->getJournalBudgetId($journal),
'tags' => implode(',', $repository->getTags($journal)), 'tags' => implode(',', $repository->getTags($journal)),
'source_account_id' => $sourceAccounts->first()->id, 'source_id' => $sourceAccounts->first()->id,
'source_account_name' => $sourceAccounts->first()->edit_name, 'source_name' => $sourceAccounts->first()->edit_name,
'destination_account_id' => $destinationAccounts->first()->id, 'destination_id' => $destinationAccounts->first()->id,
'destination_account_name' => $destinationAccounts->first()->edit_name, 'destination_name' => $destinationAccounts->first()->edit_name,
// new custom fields: // new custom fields:
'due_date' => $repository->getJournalDate($journal, 'due_date'), 'due_date' => $repository->getJournalDate($journal, 'due_date'),

View File

@@ -188,9 +188,9 @@ class SplitController extends Controller
'journal_amount' => '0', 'journal_amount' => '0',
'journal_foreign_amount' => '0', 'journal_foreign_amount' => '0',
'sourceAccounts' => $sourceAccounts, 'sourceAccounts' => $sourceAccounts,
'journal_source_account_id' => $request->old('journal_source_account_id', $sourceAccounts->first()->id), 'journal_source_id' => $request->old('journal_source_id', $sourceAccounts->first()->id),
'journal_source_account_name' => $request->old('journal_source_account_name', $sourceAccounts->first()->name), 'journal_source_name' => $request->old('journal_source_name', $sourceAccounts->first()->name),
'journal_destination_account_id' => $request->old('journal_destination_account_id', $destinationAccounts->first()->id), 'journal_destination_id' => $request->old('journal_destination_id', $destinationAccounts->first()->id),
'destinationAccounts' => $destinationAccounts, 'destinationAccounts' => $destinationAccounts,
'what' => strtolower($this->repository->getTransactionType($journal)), 'what' => strtolower($this->repository->getTransactionType($journal)),
'date' => $request->old('date', $this->repository->getJournalDate($journal, null)), 'date' => $request->old('date', $this->repository->getJournalDate($journal, null)),

View File

@@ -81,10 +81,10 @@ class JournalFormRequest extends Request
'budget_name' => null, 'budget_name' => null,
'category_id' => null, 'category_id' => null,
'category_name' => $this->string('category'), 'category_name' => $this->string('category'),
'source_id' => $this->integer('source_account_id'), 'source_id' => $this->integer('source_id'),
'source_name' => $this->string('source_account_name'), 'source_name' => $this->string('source_name'),
'destination_id' => $this->integer('destination_account_id'), 'destination_id' => $this->integer('destination_id'),
'destination_name' => $this->string('destination_account_name'), 'destination_name' => $this->string('destination_name'),
'foreign_currency_id' => null, 'foreign_currency_id' => null,
'foreign_currency_code' => null, 'foreign_currency_code' => null,
'foreign_amount' => null, 'foreign_amount' => null,
@@ -161,11 +161,11 @@ class JournalFormRequest extends Request
'amount' => 'numeric|required|more:0', 'amount' => 'numeric|required|more:0',
'budget_id' => 'mustExist:budgets,id|belongsToUser:budgets,id|nullable', 'budget_id' => 'mustExist:budgets,id|belongsToUser:budgets,id|nullable',
'category' => 'between:1,255|nullable', 'category' => 'between:1,255|nullable',
'source_account_id' => 'numeric|belongsToUser:accounts,id|nullable', 'source_id' => 'numeric|belongsToUser:accounts,id|nullable',
'source_account_name' => 'between:1,255|nullable', 'source_name' => 'between:1,255|nullable',
'destination_account_id' => 'numeric|belongsToUser:accounts,id|nullable', 'destination_id' => 'numeric|belongsToUser:accounts,id|nullable',
'destination_account_name' => 'between:1,255|nullable', 'destination_name' => 'between:1,255|nullable',
'piggy_bank_id' => 'between:1,255|nullable', 'piggy_bank_id' => 'numeric|nullable',
// foreign currency amounts // foreign currency amounts
'native_amount' => 'numeric|more:0|nullable', 'native_amount' => 'numeric|more:0|nullable',
@@ -193,17 +193,17 @@ class JournalFormRequest extends Request
{ {
switch ($what) { switch ($what) {
case strtolower(TransactionType::WITHDRAWAL): case strtolower(TransactionType::WITHDRAWAL):
$rules['source_account_id'] = 'required|exists:accounts,id|belongsToUser:accounts'; $rules['source_id'] = 'required|exists:accounts,id|belongsToUser:accounts';
$rules['destination_account_name'] = 'between:1,255|nullable'; $rules['destination_name'] = 'between:1,255|nullable';
break; break;
case strtolower(TransactionType::DEPOSIT): case strtolower(TransactionType::DEPOSIT):
$rules['source_account_name'] = 'between:1,255|nullable'; $rules['source_name'] = 'between:1,255|nullable';
$rules['destination_account_id'] = 'required|exists:accounts,id|belongsToUser:accounts'; $rules['destination_id'] = 'required|exists:accounts,id|belongsToUser:accounts';
break; break;
case strtolower(TransactionType::TRANSFER): case strtolower(TransactionType::TRANSFER):
// this may not work: // this may not work:
$rules['source_account_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:destination_account_id'; $rules['source_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:destination_id';
$rules['destination_account_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:source_account_id'; $rules['destination_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:source_id';
break; break;
default: default:

View File

@@ -46,8 +46,8 @@ class MassEditJournalRequest extends Request
return [ return [
'description.*' => 'required|min:1,max:255', 'description.*' => 'required|min:1,max:255',
'source_account_id.*' => 'numeric|belongsToUser:accounts,id', 'source_id.*' => 'numeric|belongsToUser:accounts,id',
'destination_account_id.*' => 'numeric|belongsToUser:accounts,id', 'destination_id.*' => 'numeric|belongsToUser:accounts,id',
'revenue_account' => 'max:255', 'revenue_account' => 'max:255',
'expense_account' => 'max:255', 'expense_account' => 'max:255',
]; ];

View File

@@ -104,16 +104,16 @@ class RecurrenceFormRequest extends Request
default: default:
throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->string('transaction_type'))); throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->string('transaction_type')));
case 'withdrawal': case 'withdrawal':
$return['transactions'][0]['source_account_id'] = $this->integer('source_account_id'); $return['transactions'][0]['source_id'] = $this->integer('source_id');
$return['transactions'][0]['destination_account_name'] = $this->string('destination_account_name'); $return['transactions'][0]['destination_name'] = $this->string('destination_name');
break; break;
case 'deposit': case 'deposit':
$return['transactions'][0]['source_account_name'] = $this->string('source_account_name'); $return['transactions'][0]['source_name'] = $this->string('source_name');
$return['transactions'][0]['destination_account_id'] = $this->integer('destination_account_id'); $return['transactions'][0]['destination_id'] = $this->integer('destination_id');
break; break;
case 'transfer': case 'transfer':
$return['transactions'][0]['source_account_id'] = $this->integer('source_account_id'); $return['transactions'][0]['source_id'] = $this->integer('source_id');
$return['transactions'][0]['destination_account_id'] = $this->integer('destination_account_id'); $return['transactions'][0]['destination_id'] = $this->integer('destination_id');
break; break;
} }
@@ -147,10 +147,10 @@ class RecurrenceFormRequest extends Request
'transaction_currency_id' => 'required|exists:transaction_currencies,id', 'transaction_currency_id' => 'required|exists:transaction_currencies,id',
'amount' => 'numeric|required|more:0', 'amount' => 'numeric|required|more:0',
// mandatory account info: // mandatory account info:
'source_account_id' => 'numeric|belongsToUser:accounts,id|nullable', 'source_id' => 'numeric|belongsToUser:accounts,id|nullable',
'source_account_name' => 'between:1,255|nullable', 'source_name' => 'between:1,255|nullable',
'destination_account_id' => 'numeric|belongsToUser:accounts,id|nullable', 'destination_id' => 'numeric|belongsToUser:accounts,id|nullable',
'destination_account_name' => 'between:1,255|nullable', 'destination_name' => 'between:1,255|nullable',
// foreign amount data: // foreign amount data:
'foreign_amount' => 'nullable|more:0', 'foreign_amount' => 'nullable|more:0',
@@ -181,17 +181,17 @@ class RecurrenceFormRequest extends Request
// switchc on type to expand rules for source and destination accounts: // switchc on type to expand rules for source and destination accounts:
switch ($this->string('transaction_type')) { switch ($this->string('transaction_type')) {
case strtolower(TransactionType::WITHDRAWAL): case strtolower(TransactionType::WITHDRAWAL):
$rules['source_account_id'] = 'required|exists:accounts,id|belongsToUser:accounts'; $rules['source_id'] = 'required|exists:accounts,id|belongsToUser:accounts';
$rules['destination_account_name'] = 'between:1,255|nullable'; $rules['destination_name'] = 'between:1,255|nullable';
break; break;
case strtolower(TransactionType::DEPOSIT): case strtolower(TransactionType::DEPOSIT):
$rules['source_account_name'] = 'between:1,255|nullable'; $rules['source_name'] = 'between:1,255|nullable';
$rules['destination_account_id'] = 'required|exists:accounts,id|belongsToUser:accounts'; $rules['destination_id'] = 'required|exists:accounts,id|belongsToUser:accounts';
break; break;
case strtolower(TransactionType::TRANSFER): case strtolower(TransactionType::TRANSFER):
// this may not work: // this may not work:
$rules['source_account_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:destination_account_id'; $rules['source_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:destination_id';
$rules['destination_account_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:source_account_id'; $rules['destination_id'] = 'required|exists:accounts,id|belongsToUser:accounts|different:source_id';
break; break;
default: default:

View File

@@ -64,16 +64,16 @@ class SplitJournalFormRequest extends Request
foreach ($this->get('transactions') as $index => $transaction) { foreach ($this->get('transactions') as $index => $transaction) {
switch ($data['type']) { switch ($data['type']) {
case 'withdrawal': case 'withdrawal':
$sourceId = $this->integer('journal_source_account_id'); $sourceId = $this->integer('journal_source_id');
$destinationName = $transaction['destination_name'] ?? ''; $destinationName = $transaction['destination_name'] ?? '';
break; break;
case 'deposit': case 'deposit':
$sourceName = $transaction['source_name'] ?? ''; $sourceName = $transaction['source_name'] ?? '';
$destinationId = $this->integer('journal_destination_account_id'); $destinationId = $this->integer('journal_destination_id');
break; break;
case 'transfer': case 'transfer':
$sourceId = $this->integer('journal_source_account_id'); $sourceId = $this->integer('journal_source_id');
$destinationId = $this->integer('journal_destination_account_id'); $destinationId = $this->integer('journal_destination_id');
break; break;
} }
$foreignAmount = $transaction['foreign_amount'] ?? null; $foreignAmount = $transaction['foreign_amount'] ?? null;
@@ -112,20 +112,20 @@ class SplitJournalFormRequest extends Request
'what' => 'required|in:withdrawal,deposit,transfer', 'what' => 'required|in:withdrawal,deposit,transfer',
'journal_description' => 'required|between:1,255', 'journal_description' => 'required|between:1,255',
'id' => 'numeric|belongsToUser:transaction_journals,id', 'id' => 'numeric|belongsToUser:transaction_journals,id',
'journal_source_account_id' => 'numeric|belongsToUser:accounts,id', 'journal_source_id' => 'numeric|belongsToUser:accounts,id',
'journal_source_account_name.*' => 'between:1,255', 'journal_source_name.*' => 'between:1,255',
'journal_currency_id' => 'required|exists:transaction_currencies,id', 'journal_currency_id' => 'required|exists:transaction_currencies,id',
'date' => 'required|date', 'date' => 'required|date',
'interest_date' => 'date|nullable', 'interest_date' => 'date|nullable',
'book_date' => 'date|nullable', 'book_date' => 'date|nullable',
'process_date' => 'date|nullable', 'process_date' => 'date|nullable',
'transactions.*.transaction_description' => 'required|between:1,255', 'transactions.*.transaction_description' => 'required|between:1,255',
'transactions.*.destination_account_id' => 'numeric|belongsToUser:accounts,id', 'transactions.*.destination_id' => 'numeric|belongsToUser:accounts,id',
'transactions.*.destination_name' => 'between:1,255|nullable', 'transactions.*.destination_name' => 'between:1,255|nullable',
'transactions.*.amount' => 'required|numeric', 'transactions.*.amount' => 'required|numeric',
'transactions.*.budget_id' => 'belongsToUser:budgets,id', 'transactions.*.budget_id' => 'belongsToUser:budgets,id',
'transactions.*.category_name' => 'between:1,255|nullable', 'transactions.*.category_name' => 'between:1,255|nullable',
'transactions.*.piggy_bank_id' => 'between:1,255|nullable', 'transactions.*.piggy_bank_id' => 'numeric|nullable',
]; ];
} }
@@ -155,8 +155,8 @@ class SplitJournalFormRequest extends Request
/** @var array $array */ /** @var array $array */
foreach ($transactions as $array) { foreach ($transactions as $array) {
if ($array['destination_id'] !== null && $array['source_id'] !== null && $array['destination_id'] === $array['source_id']) { if ($array['destination_id'] !== null && $array['source_id'] !== null && $array['destination_id'] === $array['source_id']) {
$validator->errors()->add('journal_source_account_id', trans('validation.source_equals_destination')); $validator->errors()->add('journal_source_id', trans('validation.source_equals_destination'));
$validator->errors()->add('journal_destination_account_id', trans('validation.source_equals_destination')); $validator->errors()->add('journal_destination_id', trans('validation.source_equals_destination'));
} }
} }

View File

@@ -31,6 +31,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
* Class Budget. * Class Budget.
*
* @property int $id * @property int $id
* @property string $name * @property string $name
* @property bool $active * @property bool $active

View File

@@ -250,6 +250,13 @@ interface BudgetRepositoryInterface
*/ */
public function store(array $data): Budget; public function store(array $data): Budget;
/**
* @param array $data
*
* @return BudgetLimit
*/
public function storeBudgetLimit(array $data): BudgetLimit;
/** /**
* @param Budget $budget * @param Budget $budget
* @param array $data * @param array $data
@@ -274,13 +281,6 @@ interface BudgetRepositoryInterface
*/ */
public function updateBudgetLimit(BudgetLimit $budgetLimit, array $data): BudgetLimit; public function updateBudgetLimit(BudgetLimit $budgetLimit, array $data): BudgetLimit;
/**
* @param array $data
*
* @return BudgetLimit
*/
public function storeBudgetLimit(array $data): BudgetLimit;
/** /**
* @param Budget $budget * @param Budget $budget
* @param Carbon $start * @param Carbon $start

View File

@@ -326,6 +326,7 @@ interface JournalRepositoryInterface
/** /**
* @param array $data * @param array $data
*
* @throws FireflyException * @throws FireflyException
* @return TransactionJournal * @return TransactionJournal
*/ */

View File

@@ -62,13 +62,6 @@ interface LinkTypeRepositoryInterface
*/ */
public function find(int $id): LinkType; public function find(int $id): LinkType;
/**
* @param int $id
*
* @return LinkType|null
*/
public function findNull(int $id): ?LinkType;
/** /**
* Find link type by name. * Find link type by name.
* *
@@ -88,6 +81,13 @@ interface LinkTypeRepositoryInterface
*/ */
public function findLink(TransactionJournal $one, TransactionJournal $two): bool; public function findLink(TransactionJournal $one, TransactionJournal $two): bool;
/**
* @param int $id
*
* @return LinkType|null
*/
public function findNull(int $id): ?LinkType;
/** /**
* See if such a link already exists (and get it). * See if such a link already exists (and get it).
* *

View File

@@ -102,17 +102,12 @@ interface PiggyBankRepositoryInterface
/** /**
* @param int $piggyBankid * @param int $piggyBankid
*
* @deprecated * @deprecated
* @return PiggyBank * @return PiggyBank
*/ */
public function find(int $piggyBankid): PiggyBank; public function find(int $piggyBankid): PiggyBank;
/**
* @param int $piggyBankId
* @return PiggyBank|null
*/
public function findNull(int $piggyBankId): ?PiggyBank;
/** /**
* Find by name or return NULL. * Find by name or return NULL.
* *
@@ -122,6 +117,13 @@ interface PiggyBankRepositoryInterface
*/ */
public function findByName(string $name): ?PiggyBank; public function findByName(string $name): ?PiggyBank;
/**
* @param int $piggyBankId
*
* @return PiggyBank|null
*/
public function findNull(int $piggyBankId): ?PiggyBank;
/** /**
* Get current amount saved in piggy bank. * Get current amount saved in piggy bank.
* *

View File

@@ -25,10 +25,10 @@ namespace FireflyIII\Transformers;
use FireflyIII\Models\Attachment; use FireflyIII\Models\Attachment;
use League\Fractal\Resource\Collection as FractalCollection;
use League\Fractal\Resource\Item; use League\Fractal\Resource\Item;
use League\Fractal\TransformerAbstract; use League\Fractal\TransformerAbstract;
use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\ParameterBag;
use League\Fractal\Resource\Collection as FractalCollection;
/** /**
* Class AttachmentTransformer * Class AttachmentTransformer
@@ -63,20 +63,6 @@ class AttachmentTransformer extends TransformerAbstract
$this->parameters = $parameters; $this->parameters = $parameters;
} }
/**
* Attach the user.
*
* @codeCoverageIgnore
*
* @param Attachment $attachment
*
* @return Item
*/
public function includeUser(Attachment $attachment): Item
{
return $this->item($attachment->user, new UserTransformer($this->parameters), 'users');
}
/** /**
* Attach the notes. * Attach the notes.
* *
@@ -91,6 +77,20 @@ class AttachmentTransformer extends TransformerAbstract
return $this->collection($attachment->notes, new NoteTransformer($this->parameters), 'notes'); return $this->collection($attachment->notes, new NoteTransformer($this->parameters), 'notes');
} }
/**
* Attach the user.
*
* @codeCoverageIgnore
*
* @param Attachment $attachment
*
* @return Item
*/
public function includeUser(Attachment $attachment): Item
{
return $this->item($attachment->user, new UserTransformer($this->parameters), 'users');
}
/** /**
* Transform attachment. * Transform attachment.
* *

View File

@@ -22,6 +22,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace FireflyIII\Transformers; namespace FireflyIII\Transformers;
use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\BudgetLimit;
use League\Fractal\Resource\Item; use League\Fractal\Resource\Item;
use League\Fractal\TransformerAbstract; use League\Fractal\TransformerAbstract;

View File

@@ -162,10 +162,10 @@ class RecurrenceTransformer extends TransformerAbstract
'currency_symbol' => $transaction->transactionCurrency->symbol, 'currency_symbol' => $transaction->transactionCurrency->symbol,
'currency_dp' => $transaction->transactionCurrency->decimal_places, 'currency_dp' => $transaction->transactionCurrency->decimal_places,
'foreign_currency_id' => $transaction->foreign_currency_id, 'foreign_currency_id' => $transaction->foreign_currency_id,
'source_account_id' => $transaction->source_account_id, 'source_id' => $transaction->source_id,
'source_account_name' => $transaction->sourceAccount->name, 'source_name' => $transaction->sourceAccount->name,
'destination_account_id' => $transaction->destination_account_id, 'destination_id' => $transaction->destination_id,
'destination_account_name' => $transaction->destinationAccount->name, 'destination_name' => $transaction->destinationAccount->name,
'amount' => $transaction->amount, 'amount' => $transaction->amount,
'foreign_amount' => $transaction->foreign_amount, 'foreign_amount' => $transaction->foreign_amount,
'description' => $transaction->description, 'description' => $transaction->description,

View File

@@ -25,7 +25,6 @@ namespace FireflyIII\Transformers;
use FireflyIII\Models\RuleAction; use FireflyIII\Models\RuleAction;
use FireflyIII\Models\RuleTrigger;
use League\Fractal\TransformerAbstract; use League\Fractal\TransformerAbstract;
use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\ParameterBag;

View File

@@ -25,10 +25,10 @@ namespace FireflyIII\Transformers;
use FireflyIII\Models\Rule; use FireflyIII\Models\Rule;
use League\Fractal\Resource\Collection as FractalCollection;
use League\Fractal\Resource\Item; use League\Fractal\Resource\Item;
use League\Fractal\TransformerAbstract; use League\Fractal\TransformerAbstract;
use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\ParameterBag;
use League\Fractal\Resource\Collection as FractalCollection;
/** /**
* Class RuleTransformer * Class RuleTransformer
@@ -68,8 +68,22 @@ class RuleTransformer extends TransformerAbstract
* *
* @return FractalCollection * @return FractalCollection
*/ */
public function includeRuleTriggers(Rule $rule): FractalCollection { public function includeRuleActions(Rule $rule): FractalCollection
return $this->collection($rule->ruleTriggers, new RuleTriggerTransformer($this->parameters), 'rule_triggers'); {
return $this->collection($rule->ruleActions, new RuleActionTransformer($this->parameters), 'rule_actions');
}
/**
* Include the rule group.
*
* @param Rule $rule
*
* @codeCoverageIgnore
* @return Item
*/
public function includeRuleGroup(Rule $rule): Item
{
return $this->item($rule->ruleGroup, new RuleGroupTransformer($this->parameters), 'rule_groups');
} }
/** /**
@@ -77,8 +91,9 @@ class RuleTransformer extends TransformerAbstract
* *
* @return FractalCollection * @return FractalCollection
*/ */
public function includeRuleActions(Rule $rule): FractalCollection { public function includeRuleTriggers(Rule $rule): FractalCollection
return $this->collection($rule->ruleActions, new RuleActionTransformer($this->parameters), 'rule_actions'); {
return $this->collection($rule->ruleTriggers, new RuleTriggerTransformer($this->parameters), 'rule_triggers');
} }
/** /**
@@ -94,20 +109,6 @@ class RuleTransformer extends TransformerAbstract
return $this->item($rule->user, new UserTransformer($this->parameters), 'users'); return $this->item($rule->user, new UserTransformer($this->parameters), 'users');
} }
/**
* Include the rule group.
*
* @param Rule $rule
*
* @codeCoverageIgnore
* @return Item
*/
public function includeRuleGroup(Rule $rule): Item
{
return $this->item($rule->ruleGroup, new RuleGroupTransformer($this->parameters), 'rule_groups');
}
/** /**
* Transform the rule. * Transform the rule.
* *

View File

@@ -245,13 +245,13 @@ $factory->define(
'transaction_amount' => (string)$faker->randomFloat(2, -100, 100), 'transaction_amount' => (string)$faker->randomFloat(2, -100, 100),
'destination_amount' => (string)$faker->randomFloat(2, -100, 100), 'destination_amount' => (string)$faker->randomFloat(2, -100, 100),
'opposing_account_id' => $faker->numberBetween(1, 10), 'opposing_account_id' => $faker->numberBetween(1, 10),
'source_account_id' => $faker->numberBetween(1, 10), 'source_id' => $faker->numberBetween(1, 10),
'opposing_account_name' => $faker->words(3, true), 'opposing_account_name' => $faker->words(3, true),
'description' => $faker->words(3, true), 'description' => $faker->words(3, true),
'source_account_name' => $faker->words(3, true), 'source_name' => $faker->words(3, true),
'destination_account_id' => $faker->numberBetween(1, 10), 'destination_id' => $faker->numberBetween(1, 10),
'date' => new Carbon, 'date' => new Carbon,
'destination_account_name' => $faker->words(3, true), 'destination_name' => $faker->words(3, true),
'amount' => (string)$faker->randomFloat(2, -100, 100), 'amount' => (string)$faker->randomFloat(2, -100, 100),
'budget_id' => 0, 'budget_id' => 0,
'category' => $faker->words(3, true), 'category' => $faker->words(3, true),

View File

@@ -24,16 +24,16 @@ $(document).ready(function () {
"use strict"; "use strict";
// destination account names: // destination account names:
if ($('input[name^="destination_account_name["]').length > 0) { if ($('input[name^="destination_name["]').length > 0) {
$.getJSON('json/expense-accounts').done(function (data) { $.getJSON('json/expense-accounts').done(function (data) {
$('input[name^="destination_account_name["]').typeahead({source: data, autoSelect: false}); $('input[name^="destination_name["]').typeahead({source: data, autoSelect: false});
}); });
} }
// source account name // source account name
if ($('input[name^="source_account_name["]').length > 0) { if ($('input[name^="source_name["]').length > 0) {
$.getJSON('json/revenue-accounts').done(function (data) { $.getJSON('json/revenue-accounts').done(function (data) {
$('input[name^="source_account_name["]').typeahead({source: data, autoSelect: false}); $('input[name^="source_name["]').typeahead({source: data, autoSelect: false});
}); });
} }

View File

@@ -65,15 +65,15 @@ function setCommonAutocomplete() {
}); });
if ($('input[name="destination_account_name"]').length > 0) { if ($('input[name="destination_name"]').length > 0) {
$.getJSON('json/expense-accounts').done(function (data) { $.getJSON('json/expense-accounts').done(function (data) {
$('input[name="destination_account_name"]').typeahead({source: data, autoSelect: false}); $('input[name="destination_name"]').typeahead({source: data, autoSelect: false});
}); });
} }
if ($('input[name="source_account_name"]').length > 0) { if ($('input[name="source_name"]').length > 0) {
$.getJSON('json/revenue-accounts').done(function (data) { $.getJSON('json/revenue-accounts').done(function (data) {
$('input[name="source_account_name"]').typeahead({source: data, autoSelect: false}); $('input[name="source_name"]').typeahead({source: data, autoSelect: false});
}); });
} }
@@ -160,8 +160,8 @@ function updateNativeAmount(data) {
* Instructions for transfers * Instructions for transfers
*/ */
function getTransferExchangeInstructions() { function getTransferExchangeInstructions() {
var sourceAccount = $('select[name="source_account_id"]').val(); var sourceAccount = $('select[name="source_id"]').val();
var destAccount = $('select[name="destination_account_id"]').val(); var destAccount = $('select[name="destination_id"]').val();
var sourceCurrency = accountInfo[sourceAccount].preferredCurrency; var sourceCurrency = accountInfo[sourceAccount].preferredCurrency;
var destinationCurrency = accountInfo[destAccount].preferredCurrency; var destinationCurrency = accountInfo[destAccount].preferredCurrency;
@@ -180,8 +180,8 @@ function validateCurrencyForTransfer() {
return; return;
} }
$('#source_amount_holder').show(); $('#source_amount_holder').show();
var sourceAccount = $('select[name="source_account_id"]').val(); var sourceAccount = $('select[name="source_id"]').val();
var destAccount = $('select[name="destination_account_id"]').val(); var destAccount = $('select[name="destination_id"]').val();
var sourceCurrency = accountInfo[sourceAccount].preferredCurrency; var sourceCurrency = accountInfo[sourceAccount].preferredCurrency;
var sourceSymbol = currencyInfo[sourceCurrency].symbol; var sourceSymbol = currencyInfo[sourceCurrency].symbol;
var destinationCurrency = accountInfo[destAccount].preferredCurrency; var destinationCurrency = accountInfo[destAccount].preferredCurrency;
@@ -208,8 +208,8 @@ function validateCurrencyForTransfer() {
* *
*/ */
function convertSourceToDestination() { function convertSourceToDestination() {
var sourceAccount = $('select[name="source_account_id"]').val(); var sourceAccount = $('select[name="source_id"]').val();
var destAccount = $('select[name="destination_account_id"]').val(); var destAccount = $('select[name="destination_id"]').val();
var sourceCurrency = accountInfo[sourceAccount].preferredCurrency; var sourceCurrency = accountInfo[sourceAccount].preferredCurrency;
var destinationCurrency = accountInfo[destAccount].preferredCurrency; var destinationCurrency = accountInfo[destAccount].preferredCurrency;

View File

@@ -38,20 +38,17 @@ $(document).ready(function () {
// when user changes source account or destination, native currency may be different. // when user changes source account or destination, native currency may be different.
$('select[name="source_account_id"]').on('change', function() { $('select[name="source_id"]').on('change', function() {
selectsDifferentSource(); selectsDifferentSource();
// do something for transfers: // do something for transfers:
validateCurrencyForTransfer(); validateCurrencyForTransfer();
}); });
$('select[name="destination_account_id"]').on('change', function() { $('select[name="destination_id"]').on('change', function() {
selectsDifferentDestination(); selectsDifferentDestination();
// do something for transfers: // do something for transfers:
validateCurrencyForTransfer(); validateCurrencyForTransfer();
}); });
//$('select[name="source_account_id"]').on('change', updateNativeCurrency);
//$('select[name="destination_account_id"]').on('change', updateNativeCurrency);
// convert foreign currency to native currency (when input changes, exchange rate) // convert foreign currency to native currency (when input changes, exchange rate)
$('#ffInput_amount').on('change', convertForeignToNative); $('#ffInput_amount').on('change', convertForeignToNative);
@@ -74,7 +71,7 @@ function selectsDifferentSource() {
return; return;
} }
// store original currency ID of the selected account in a separate var: // store original currency ID of the selected account in a separate var:
var sourceId = $('select[name="source_account_id"]').val(); var sourceId = $('select[name="source_id"]').val();
var sourceCurrency = accountInfo[sourceId].preferredCurrency; var sourceCurrency = accountInfo[sourceId].preferredCurrency;
$('input[name="source_account_currency"]').val(sourceCurrency); $('input[name="source_account_currency"]').val(sourceCurrency);
console.log('selectsDifferenctSource(): Set source account currency to ' + sourceCurrency); console.log('selectsDifferenctSource(): Set source account currency to ' + sourceCurrency);
@@ -82,7 +79,7 @@ function selectsDifferentSource() {
// change input thing: // change input thing:
$('.currency-option[data-id="' + sourceCurrency + '"]').click(); $('.currency-option[data-id="' + sourceCurrency + '"]').click();
$('[data-toggle="dropdown"]').parent().removeClass('open'); $('[data-toggle="dropdown"]').parent().removeClass('open');
$('select[name="source_account_id"]').focus(); $('select[name="source_id"]').focus();
} }
/** /**
@@ -96,7 +93,7 @@ function selectsDifferentDestination() {
return; return;
} }
// store original currency ID of the selected account in a separate var: // store original currency ID of the selected account in a separate var:
var destinationId = $('select[name="destination_account_id"]').val(); var destinationId = $('select[name="destination_id"]').val();
var destinationCurrency = accountInfo[destinationId].preferredCurrency; var destinationCurrency = accountInfo[destinationId].preferredCurrency;
$('input[name="destination_account_currency"]').val(destinationCurrency); $('input[name="destination_account_currency"]').val(destinationCurrency);
console.log('selectsDifferentDestination(): Set destinationId account currency to ' + destinationCurrency); console.log('selectsDifferentDestination(): Set destinationId account currency to ' + destinationCurrency);
@@ -104,7 +101,7 @@ function selectsDifferentDestination() {
// change input thing: // change input thing:
$('.currency-option[data-id="' + destinationCurrency + '"]').click(); $('.currency-option[data-id="' + destinationCurrency + '"]').click();
$('[data-toggle="dropdown"]').parent().removeClass('open'); $('[data-toggle="dropdown"]').parent().removeClass('open');
$('select[name="destination_account_id"]').focus(); $('select[name="destination_id"]').focus();
} }
@@ -153,19 +150,19 @@ function updateForm() {
$('input[name="what"]').val(what); $('input[name="what"]').val(what);
var destName = $('#ffInput_destination_account_name'); var destName = $('#ffInput_destination_name');
var srcName = $('#ffInput_source_account_name'); var srcName = $('#ffInput_source_name');
switch (what) { switch (what) {
case 'withdrawal': case 'withdrawal':
// show source_id and dest_name // show source_id and dest_name
document.getElementById('source_account_id_holder').style.display = 'block'; document.getElementById('source_id_holder').style.display = 'block';
document.getElementById('destination_account_name_holder').style.display = 'block'; document.getElementById('destination_name_holder').style.display = 'block';
// hide others: // hide others:
document.getElementById('source_account_name_holder').style.display = 'none'; document.getElementById('source_name_holder').style.display = 'none';
document.getElementById('destination_account_id_holder').style.display = 'none'; document.getElementById('destination_id_holder').style.display = 'none';
document.getElementById('budget_id_holder').style.display = 'block'; document.getElementById('budget_id_holder').style.display = 'block';
// hide piggy bank: // hide piggy bank:
@@ -185,12 +182,12 @@ function updateForm() {
break; break;
case 'deposit': case 'deposit':
// show source_name and dest_id: // show source_name and dest_id:
document.getElementById('source_account_name_holder').style.display = 'block'; document.getElementById('source_name_holder').style.display = 'block';
document.getElementById('destination_account_id_holder').style.display = 'block'; document.getElementById('destination_id_holder').style.display = 'block';
// hide others: // hide others:
document.getElementById('source_account_id_holder').style.display = 'none'; document.getElementById('source_id_holder').style.display = 'none';
document.getElementById('destination_account_name_holder').style.display = 'none'; document.getElementById('destination_name_holder').style.display = 'none';
// hide budget // hide budget
document.getElementById('budget_id_holder').style.display = 'none'; document.getElementById('budget_id_holder').style.display = 'none';
@@ -212,12 +209,12 @@ function updateForm() {
break; break;
case 'transfer': case 'transfer':
// show source_id and dest_id: // show source_id and dest_id:
document.getElementById('source_account_id_holder').style.display = 'block'; document.getElementById('source_id_holder').style.display = 'block';
document.getElementById('destination_account_id_holder').style.display = 'block'; document.getElementById('destination_id_holder').style.display = 'block';
// hide others: // hide others:
document.getElementById('source_account_name_holder').style.display = 'none'; document.getElementById('source_name_holder').style.display = 'none';
document.getElementById('destination_account_name_holder').style.display = 'none'; document.getElementById('destination_name_holder').style.display = 'none';
// hide budget // hide budget
document.getElementById('budget_id_holder').style.display = 'none'; document.getElementById('budget_id_holder').style.display = 'none';
@@ -288,10 +285,10 @@ function clickButton(e) {
*/ */
function getAccountId() { function getAccountId() {
if (what === "withdrawal") { if (what === "withdrawal") {
return $('select[name="source_account_id"]').val(); return $('select[name="source_id"]').val();
} }
if (what === "deposit" || what === "transfer") { if (what === "deposit" || what === "transfer") {
return $('select[name="destination_account_id"]').val(); return $('select[name="destination_id"]').val();
} }
return undefined; return undefined;
} }

View File

@@ -38,12 +38,12 @@ $(document).ready(function () {
$('#ffInput_amount').on('change', convertForeignToNative); $('#ffInput_amount').on('change', convertForeignToNative);
// respond to transfer changes: // respond to transfer changes:
$('#ffInput_source_account_id').on('change', function () { $('#ffInput_source_id').on('change', function () {
validateCurrencyForTransfer(); validateCurrencyForTransfer();
// update the two source account currency ID fields (initial value): // update the two source account currency ID fields (initial value):
initCurrencyIdValues(); initCurrencyIdValues();
}); });
$('#ffInput_destination_account_id').on('change', function () { $('#ffInput_destination_id').on('change', function () {
validateCurrencyForTransfer(); validateCurrencyForTransfer();
// update the two source account currency ID fields (initial value): // update the two source account currency ID fields (initial value):
initCurrencyIdValues(); initCurrencyIdValues();
@@ -77,9 +77,9 @@ function initCurrencyIdValues() {
$('input[name="destination_account_currency"]').val(currencyId); $('input[name="destination_account_currency"]').val(currencyId);
return; return;
} }
var sourceAccount = $('select[name="source_account_id"]').val(); var sourceAccount = $('select[name="source_id"]').val();
console.log('Source account is ' + sourceAccount); console.log('Source account is ' + sourceAccount);
var destAccount = $('select[name="destination_account_id"]').val(); var destAccount = $('select[name="destination_id"]').val();
console.log('Destination account is ' + destAccount); console.log('Destination account is ' + destAccount);
var sourceCurrency = parseInt(accountInfo[sourceAccount].preferredCurrency); var sourceCurrency = parseInt(accountInfo[sourceAccount].preferredCurrency);
@@ -134,10 +134,10 @@ function updateInitialPage() {
function getAccountId() { function getAccountId() {
console.log('in getAccountId()'); console.log('in getAccountId()');
if (journal.transaction_type.type === "Withdrawal") { if (journal.transaction_type.type === "Withdrawal") {
return $('select[name="source_account_id"]').val(); return $('select[name="source_id"]').val();
} }
if (journal.transaction_type.type === "Deposit") { if (journal.transaction_type.type === "Deposit") {
return $('select[name="destination_account_id"]').val(); return $('select[name="destination_id"]').val();
} }
alert('Cannot handle ' + journal.transaction_type.type); alert('Cannot handle ' + journal.transaction_type.type);

View File

@@ -191,12 +191,12 @@ function resetDivSplits() {
var input = $(v); var input = $(v);
input.attr('name', 'transactions[' + i + '][transaction_description]'); input.attr('name', 'transactions[' + i + '][transaction_description]');
}); });
// ends with ][destination_account_name] // ends with ][destination_name]
$.each($('input[name$="][destination_name]"]'), function (i, v) { $.each($('input[name$="][destination_name]"]'), function (i, v) {
var input = $(v); var input = $(v);
input.attr('name', 'transactions[' + i + '][destination_name]'); input.attr('name', 'transactions[' + i + '][destination_name]');
}); });
// ends with ][source_account_name] // ends with ][source_name]
$.each($('input[name$="][source_name]"]'), function (i, v) { $.each($('input[name$="][source_name]"]'), function (i, v) {
var input = $(v); var input = $(v);
input.attr('name', 'transactions[' + i + '][source_name]'); input.attr('name', 'transactions[' + i + '][source_name]');

View File

@@ -70,7 +70,7 @@
<td> <td>
{# SOURCE ACCOUNT ID FOR TRANSFER OR WITHDRAWAL #} {# SOURCE ACCOUNT ID FOR TRANSFER OR WITHDRAWAL #}
{% if transaction.type == 'Transfer' or transaction.type == 'Withdrawal' %} {% if transaction.type == 'Transfer' or transaction.type == 'Withdrawal' %}
<select class="form-control input-sm" name="source_account_id[{{ transaction.journal_id }}]"> <select class="form-control input-sm" name="source_id[{{ transaction.journal_id }}]">
{% for account in accounts %} {% for account in accounts %}
<!-- {{ transaction.type }}: {{ transaction.source_name }} --> <!-- {{ transaction.type }}: {{ transaction.source_name }} -->
<option value="{{ account.id }}"{% if account.id == transaction.source_id %} selected{% endif %} label="{{ account.name }}">{{ account.name }}</option> <option value="{{ account.id }}"{% if account.id == transaction.source_id %} selected{% endif %} label="{{ account.name }}">{{ account.name }}</option>
@@ -79,13 +79,13 @@
{% else %} {% else %}
{# SOURCE ACCOUNT NAME FOR DEPOSIT #} {# SOURCE ACCOUNT NAME FOR DEPOSIT #}
<input class="form-control input-sm" placeholder="{% if transaction.source_type != 'Cash account' %}{{ transaction.source_name }}{% endif %}" autocomplete="off" <input class="form-control input-sm" placeholder="{% if transaction.source_type != 'Cash account' %}{{ transaction.source_name }}{% endif %}" autocomplete="off"
name="source_account_name[{{ transaction.journal_id }}]" type="text" value="{% if transaction.source_type != 'Cash account' %}{{ transaction.source_name }}{% endif %}"> name="source_name[{{ transaction.journal_id }}]" type="text" value="{% if transaction.source_type != 'Cash account' %}{{ transaction.source_name }}{% endif %}">
{% endif %} {% endif %}
</td> </td>
<td> <td>
{% if transaction.type == 'Transfer' or transaction.type == 'Deposit' %} {% if transaction.type == 'Transfer' or transaction.type == 'Deposit' %}
{# DESTINATION ACCOUNT NAME FOR TRANSFER AND DEPOSIT #} {# DESTINATION ACCOUNT NAME FOR TRANSFER AND DEPOSIT #}
<select class="form-control input-sm" name="destination_account_id[{{ transaction.journal_id }}]"> <select class="form-control input-sm" name="destination_id[{{ transaction.journal_id }}]">
{% for account in accounts %} {% for account in accounts %}
<option value="{{ account.id }}"{% if account.id == transaction.destination_id %} selected="selected"{% endif %} <option value="{{ account.id }}"{% if account.id == transaction.destination_id %} selected="selected"{% endif %}
label="{{ account.name }}">{{ account.name }}</option> label="{{ account.name }}">{{ account.name }}</option>
@@ -95,7 +95,7 @@
{# DESTINATION ACCOUNT NAME FOR EXPENSE #} {# DESTINATION ACCOUNT NAME FOR EXPENSE #}
<input class="form-control input-sm" placeholder="{% if transaction.destination_type != 'Cash account' %}{{ transaction.destination_name }}{% endif %}" <input class="form-control input-sm" placeholder="{% if transaction.destination_type != 'Cash account' %}{{ transaction.destination_name }}{% endif %}"
name="destination_account_name[{{ transaction.journal_id }}]" type="text" autocomplete="off" name="destination_name[{{ transaction.journal_id }}]" type="text" autocomplete="off"
value="{% if transaction.destination_type != 'Cash account' %}{{ transaction.destination_name }}{% endif %}"> value="{% if transaction.destination_type != 'Cash account' %}{{ transaction.destination_name }}{% endif %}">
{% endif %} {% endif %}
</td> </td>

View File

@@ -33,16 +33,16 @@
{{ ExpandedForm.text('description') }} {{ ExpandedForm.text('description') }}
{# SELECTABLE SOURCE ACCOUNT ONLY FOR WITHDRAWALS AND TRANSFERS #} {# SELECTABLE SOURCE ACCOUNT ONLY FOR WITHDRAWALS AND TRANSFERS #}
{{ ExpandedForm.activeAssetAccountList('source_account_id', null, {label: trans('form.asset_source_account')}) }} {{ ExpandedForm.activeAssetAccountList('source_id', null, {label: trans('form.asset_source_account')}) }}
{# FREE FORMAT SOURCE ACCOUNT ONLY FOR DEPOSITS #} {# FREE FORMAT SOURCE ACCOUNT ONLY FOR DEPOSITS #}
{{ ExpandedForm.text('source_account_name', null, {label: trans('form.revenue_account')}) }} {{ ExpandedForm.text('source_name', null, {label: trans('form.revenue_account')}) }}
{# FREE FORMAT DESTINATION ACCOUNT ONLY FOR EXPENSES #} {# FREE FORMAT DESTINATION ACCOUNT ONLY FOR EXPENSES #}
{{ ExpandedForm.text('destination_account_name', null, {label: trans('form.expense_account')}) }} {{ ExpandedForm.text('destination_name', null, {label: trans('form.expense_account')}) }}
{# SELECTABLE DESTINATION ACCOUNT ONLY FOR TRANSFERS AND DEPOSITS #} {# SELECTABLE DESTINATION ACCOUNT ONLY FOR TRANSFERS AND DEPOSITS #}
{{ ExpandedForm.activeAssetAccountList('destination_account_id', null, {label: trans('form.asset_destination_account')} ) }} {{ ExpandedForm.activeAssetAccountList('destination_id', null, {label: trans('form.asset_destination_account')} ) }}
{# ALWAYS SHOW AMOUNT #} {# ALWAYS SHOW AMOUNT #}
{{ ExpandedForm.amount('amount') }} {{ ExpandedForm.amount('amount') }}

View File

@@ -39,22 +39,22 @@
{# SELECTABLE SOURCE ACCOUNT ONLY FOR WITHDRAWALS AND TRANSFERS #} {# SELECTABLE SOURCE ACCOUNT ONLY FOR WITHDRAWALS AND TRANSFERS #}
{% if what == 'transfer' or what == 'withdrawal' %} {% if what == 'transfer' or what == 'withdrawal' %}
{{ ExpandedForm.assetAccountList('source_account_id', data.source_account_id, {label: trans('form.asset_source_account')}) }} {{ ExpandedForm.assetAccountList('source_id', data.source_id, {label: trans('form.asset_source_account')}) }}
{% endif %} {% endif %}
{# FREE FORMAT SOURCE ACCOUNT ONLY FOR DEPOSITS #} {# FREE FORMAT SOURCE ACCOUNT ONLY FOR DEPOSITS #}
{% if what == 'deposit' %} {% if what == 'deposit' %}
{{ ExpandedForm.text('source_account_name',data.source_account_name, {label: trans('form.revenue_account')}) }} {{ ExpandedForm.text('source_name',data.source_name, {label: trans('form.revenue_account')}) }}
{% endif %} {% endif %}
{# FREE FORMAT DESTINATION ACCOUNT ONLY FOR EXPENSES #} {# FREE FORMAT DESTINATION ACCOUNT ONLY FOR EXPENSES #}
{% if what == 'withdrawal' %} {% if what == 'withdrawal' %}
{{ ExpandedForm.text('destination_account_name',data.destination_account_name, {label: trans('form.expense_account')}) }} {{ ExpandedForm.text('destination_name',data.destination_name, {label: trans('form.expense_account')}) }}
{% endif %} {% endif %}
{# SELECTABLE DESTINATION ACCOUNT ONLY FOR TRANSFERS AND DEPOSITS #} {# SELECTABLE DESTINATION ACCOUNT ONLY FOR TRANSFERS AND DEPOSITS #}
{% if what == 'transfer' or what == 'deposit' %} {% if what == 'transfer' or what == 'deposit' %}
{{ ExpandedForm.assetAccountList('destination_account_id', data.destination_account_id, {label: trans('form.asset_destination_account')} ) }} {{ ExpandedForm.assetAccountList('destination_id', data.destination_id, {label: trans('form.asset_destination_account')} ) }}
{% endif %} {% endif %}
{# ALWAYS SHOW AMOUNT #} {# ALWAYS SHOW AMOUNT #}

View File

@@ -42,12 +42,12 @@
{# show source if withdrawal or transfer #} {# show source if withdrawal or transfer #}
{% if preFilled.what == 'withdrawal' or preFilled.what == 'transfer' %} {% if preFilled.what == 'withdrawal' or preFilled.what == 'transfer' %}
{{ ExpandedForm.activeAssetAccountList('journal_source_account_id', preFilled.journal_source_account_id) }} {{ ExpandedForm.activeAssetAccountList('journal_source_id', preFilled.journal_source_id) }}
{% endif %} {% endif %}
{# show destination account id, if deposit (is asset): #} {# show destination account id, if deposit (is asset): #}
{% if preFilled.what == 'deposit' or preFilled.what == 'transfer' %} {% if preFilled.what == 'deposit' or preFilled.what == 'transfer' %}
{{ ExpandedForm.activeAssetAccountList('journal_destination_account_id', preFilled.journal_destination_account_id) }} {{ ExpandedForm.activeAssetAccountList('journal_destination_id', preFilled.journal_destination_id) }}
{% endif %} {% endif %}
{# show amount and some helper text when making splits: #} {# show amount and some helper text when making splits: #}

View File

@@ -200,8 +200,8 @@ class MassControllerTest extends TestCase
'amount' => [$deposit->id => 1600], 'amount' => [$deposit->id => 1600],
'amount_currency_id_amount_' . $deposit->id => 1, 'amount_currency_id_amount_' . $deposit->id => 1,
'date' => [$deposit->id => '2014-07-24'], 'date' => [$deposit->id => '2014-07-24'],
'source_account_name' => [$deposit->id => 'Job'], 'source_name' => [$deposit->id => 'Job'],
'destination_account_id' => [$deposit->id => 1], 'destination_id' => [$deposit->id => 1],
'category' => [$deposit->id => 'Salary'], 'category' => [$deposit->id => 'Salary'],
]; ];

View File

@@ -306,7 +306,7 @@ class SingleControllerTest extends TestCase
$response->assertStatus(200); $response->assertStatus(200);
// has bread crumb // has bread crumb
$response->assertSee('<ol class="breadcrumb">'); $response->assertSee('<ol class="breadcrumb">');
$response->assertSee(' name="source_account_name" type="text" value="">'); $response->assertSee(' name="source_name" type="text" value="">');
} }
/** /**
@@ -352,7 +352,7 @@ class SingleControllerTest extends TestCase
$response->assertStatus(200); $response->assertStatus(200);
// has bread crumb // has bread crumb
$response->assertSee('<ol class="breadcrumb">'); $response->assertSee('<ol class="breadcrumb">');
$response->assertSee(' name="destination_account_name" type="text" value="">'); $response->assertSee(' name="destinationt_name" type="text" value="">');
} }
/** /**
@@ -592,8 +592,8 @@ class SingleControllerTest extends TestCase
'what' => 'withdrawal', 'what' => 'withdrawal',
'amount' => '10', 'amount' => '10',
'amount_currency_id_amount' => 1, 'amount_currency_id_amount' => 1,
'source_account_id' => 1, 'source_id' => 1,
'destination_account_name' => 'Some destination', 'destination_name' => 'Some destination',
'date' => '2016-01-01', 'date' => '2016-01-01',
'description' => 'Test descr', 'description' => 'Test descr',
]; ];
@@ -645,8 +645,8 @@ class SingleControllerTest extends TestCase
'what' => 'withdrawal', 'what' => 'withdrawal',
'amount' => '10', 'amount' => '10',
'amount_currency_id_amount' => 1, 'amount_currency_id_amount' => 1,
'source_account_id' => 1, 'source_id' => 1,
'destination_account_name' => 'Some destination', 'destination_name' => 'Some destination',
'date' => '2016-01-01', 'date' => '2016-01-01',
'description' => 'Test descr', 'description' => 'Test descr',
]; ];
@@ -700,8 +700,8 @@ class SingleControllerTest extends TestCase
'what' => 'deposit', 'what' => 'deposit',
'amount' => '10', 'amount' => '10',
'amount_currency_id_amount' => 1, 'amount_currency_id_amount' => 1,
'destination_account_id' => 1, 'destination_id' => 1,
'source_account_name' => 'Some source', 'source_name' => 'Some source',
'date' => '2016-01-01', 'date' => '2016-01-01',
'description' => 'Test descr', 'description' => 'Test descr',
]; ];
@@ -756,8 +756,8 @@ class SingleControllerTest extends TestCase
'what' => 'transfer', 'what' => 'transfer',
'amount' => '10', 'amount' => '10',
'amount_currency_id_amount' => 1, 'amount_currency_id_amount' => 1,
'destination_account_id' => 1, 'destination_id' => 1,
'source_account_id' => 2, 'source_id' => 2,
'date' => '2016-01-01', 'date' => '2016-01-01',
'description' => 'Test descr', 'description' => 'Test descr',
]; ];
@@ -814,8 +814,8 @@ class SingleControllerTest extends TestCase
'amount_currency_id_amount' => 1, 'amount_currency_id_amount' => 1,
'source_account_currency' => 1, 'source_account_currency' => 1,
'destination_account_currency' => 2, 'destination_account_currency' => 2,
'destination_account_id' => 1, 'destination_id' => 1,
'source_account_id' => 2, 'source_id' => 2,
'date' => '2016-01-01', 'date' => '2016-01-01',
'description' => 'Test descr', 'description' => 'Test descr',
]; ];
@@ -872,8 +872,8 @@ class SingleControllerTest extends TestCase
'id' => 123, 'id' => 123,
'what' => 'withdrawal', 'what' => 'withdrawal',
'description' => 'Updated groceries', 'description' => 'Updated groceries',
'source_account_id' => 1, 'source_id' => 1,
'destination_account_name' => 'PLUS', 'destination_name' => 'PLUS',
'amount' => '123', 'amount' => '123',
'amount_currency_id_amount' => 1, 'amount_currency_id_amount' => 1,
'budget_id' => 1, 'budget_id' => 1,

View File

@@ -296,7 +296,7 @@ class SplitControllerTest extends TestCase
'what' => 'deposit', 'what' => 'deposit',
'journal_description' => 'Updated salary', 'journal_description' => 'Updated salary',
'journal_currency_id' => 1, 'journal_currency_id' => 1,
'journal_destination_account_id' => 1, 'journal_destination_id' => 1,
'journal_amount' => 1591, 'journal_amount' => 1591,
'date' => '2014-01-24', 'date' => '2014-01-24',
'tags' => '', 'tags' => '',
@@ -346,7 +346,7 @@ class SplitControllerTest extends TestCase
'what' => 'opening balance', 'what' => 'opening balance',
'journal_description' => 'Updated salary', 'journal_description' => 'Updated salary',
'journal_currency_id' => 1, 'journal_currency_id' => 1,
'journal_destination_account_id' => 1, 'journal_destination_id' => 1,
'journal_amount' => 1591, 'journal_amount' => 1591,
'date' => '2014-01-24', 'date' => '2014-01-24',
'tags' => '', 'tags' => '',
@@ -394,14 +394,14 @@ class SplitControllerTest extends TestCase
'what' => 'transfer', 'what' => 'transfer',
'journal_description' => 'Some updated withdrawal', 'journal_description' => 'Some updated withdrawal',
'journal_currency_id' => 1, 'journal_currency_id' => 1,
'journal_source_account_id' => 1, 'journal_source_id' => 1,
'journal_amount' => 1591, 'journal_amount' => 1591,
'date' => '2014-01-24', 'date' => '2014-01-24',
'tags' => '', 'tags' => '',
'transactions' => [ 'transactions' => [
[ [
'transaction_description' => 'Split #1', 'transaction_description' => 'Split #1',
'source_account_id' => '1', 'source_id' => '1',
'destination_id' => '2', 'destination_id' => '2',
'transaction_currency_id' => 1, 'transaction_currency_id' => 1,
'amount' => 1591, 'amount' => 1591,
@@ -450,7 +450,7 @@ class SplitControllerTest extends TestCase
'what' => 'withdrawal', 'what' => 'withdrawal',
'journal_description' => 'Some updated withdrawal', 'journal_description' => 'Some updated withdrawal',
'journal_currency_id' => 1, 'journal_currency_id' => 1,
'journal_source_account_id' => 1, 'journal_source_id' => 1,
'journal_amount' => 1591, 'journal_amount' => 1591,
'date' => '2014-01-24', 'date' => '2014-01-24',
'tags' => '', 'tags' => '',