Improve tests, models and views.

This commit is contained in:
James Cole
2019-04-16 16:20:46 +02:00
parent 5ac39dbdef
commit 66c55b7bbe
44 changed files with 13710 additions and 5067 deletions

View File

@@ -291,7 +291,7 @@ class TransactionController extends Controller
$selectedGroup = $collector->getGroups()->first();
if (null === $selectedGroup) {
throw new NotFoundHttpException();
throw new NotFoundHttpException(); // @codeCoverageIgnore
}
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);
@@ -335,7 +335,7 @@ class TransactionController extends Controller
$selectedGroup = $collector->getGroups()->first();
if (null === $selectedGroup) {
throw new NotFoundHttpException();
throw new NotFoundHttpException(); // @codeCoverageIgnore
}
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);

View File

@@ -182,7 +182,7 @@ class TransactionStoreRequest extends Request
// the group must have a description if > 1 journal.
$this->validateGroupDescription($validator);
// TODO validate that the currency fits the source and/or destination account.
// TODO the currency info must match the accounts involved.
}
);
@@ -217,8 +217,8 @@ class TransactionStoreRequest extends Request
'foreign_currency_code' => $this->stringFromValue($object['foreign_currency_code']),
// amount and foreign amount. Cannot be 0.
'amount' => $this->stringFromValue($object['amount']),
'foreign_amount' => $this->stringFromValue($object['foreign_amount']),
'amount' => $this->stringFromValue((string)$object['amount']),
'foreign_amount' => $this->stringFromValue((string)$object['foreign_amount']),
// description.
'description' => $this->stringFromValue($object['description']),

View File

@@ -237,13 +237,12 @@ class TransactionUpdateRequest extends Request
// all transaction types must be equal:
$this->validateTransactionTypesForUpdate($validator);
// if type is set, source + destination info is mandatory.
$this->validateAccountPresence($validator);
// validate source/destination is equal, depending on the transaction journal type.
$this->validateEqualAccountsForUpdate($validator, $transactionGroup);
// TODO if type is set, source + destination info is mandatory.
// TODO validate that the currency fits the source and/or destination account.
// TODO the currency info must match the accounts involved.
// all journals must have a description
//$this->validateDescriptions($validator);
@@ -308,7 +307,7 @@ class TransactionUpdateRequest extends Request
foreach ($this->arrayFields as $fieldName) {
if (array_key_exists($fieldName, $transaction)) {
$current[$fieldName] = $this->arrayFromValue((string)$transaction[$fieldName]);
$current[$fieldName] = $this->arrayFromValue($transaction[$fieldName]);
}
}
$return[] = $current;