apply demeter law for transaction type calls

- adds contants for transaction type names
- demeter law = never speaks with strangers
This commit is contained in:
Antonio Spinelli
2015-12-09 22:39:50 -02:00
parent 90e696f82c
commit b3d99cd210
23 changed files with 196 additions and 118 deletions

View File

@@ -296,7 +296,7 @@ class Importer
// some debug info:
$journalId = $journal->id;
$type = $journal->transactionType->type;
$type = $journal->getTransactionType();
/** @var Account $asset */
$asset = $this->importData['asset-account-object'];
/** @var Account $opposing */
@@ -314,13 +314,13 @@ class Importer
*/
protected function getTransactionType()
{
$transactionType = TransactionType::where('type', 'Deposit')->first();
$transactionType = TransactionType::where('type', TransactionType::DEPOSIT)->first();
if ($this->importData['amount'] < 0) {
$transactionType = TransactionType::where('type', 'Withdrawal')->first();
$transactionType = TransactionType::where('type', TransactionType::WITHDRAWAL)->first();
}
if (in_array($this->importData['opposing-account-object']->accountType->type, ['Asset account', 'Default account'])) {
$transactionType = TransactionType::where('type', 'Transfer')->first();
$transactionType = TransactionType::where('type', TransactionType::TRANSFER)->first();
}
return $transactionType;