Expand tests.

This commit is contained in:
James Cole
2018-02-19 20:02:27 +01:00
parent e389d0f7fa
commit cae4faad0a
6 changed files with 130 additions and 12 deletions

View File

@@ -32,7 +32,6 @@ use Illuminate\Validation\Validator;
/**
* todo cannot submit using currency not part of source / dest
* Class TransactionRequest
*/
class TransactionRequest extends Request
@@ -146,9 +145,6 @@ class TransactionRequest extends Request
'transactions.*.source_name' => 'between:1,255|nullable',
'transactions.*.destination_id' => ['numeric', 'nullable', new BelongsUser],
'transactions.*.destination_name' => 'between:1,255|nullable',
// todo tags
];
}

View File

@@ -45,12 +45,13 @@ class PiggyBankEventFactory
*/
public function create(TransactionJournal $journal, ?PiggyBank $piggyBank): ?PiggyBankEvent
{
Log::debug(sprintf('Now in PiggyBankEventCreate for a %s', $journal->transactionType->type));
if (is_null($piggyBank)) {
return null;
}
// is a transfer?
if (!TransactionType::TRANSFER === $journal->transactionType->type) {
if (!(TransactionType::TRANSFER === $journal->transactionType->type)) {
Log::info(sprintf('Will not connect %s #%d to a piggy bank.', $journal->transactionType->type, $journal->id));
return null;

View File

@@ -78,9 +78,10 @@ class TransactionJournalFactory
// link bill:
$this->connectBill($journal, $data);
// link piggy bank:
// link piggy bank (if transfer)
$this->connectPiggyBank($journal, $data);
// link tags:
$this->connectTags($journal, $data);

View File

@@ -339,6 +339,10 @@ class SingleController extends Controller
$doSplit = 1 === intval($request->get('split_journal'));
$createAnother = 1 === intval($request->get('create_another'));
$data = $request->getJournalData();
// todo call factory instead of repository
$journal = $repository->store($data);
if (null === $journal->id) {
// error!