This commit is contained in:
James Cole
2018-07-06 18:43:46 +02:00
parent 5d4dcd7e4b
commit 52f02cb9eb

View File

@@ -169,19 +169,11 @@ class ImportableConverter
throw new FireflyException('No transaction amount information.'); throw new FireflyException('No transaction amount information.');
} }
$transactionType = 'unknown'; $transactionType = 'unknown';
$accountId = $this->verifyObjectId('account-id', $importable->accountId); $source = $this->assetMapper->map($importable->accountId, $importable->getAccountData());
$billId = $this->verifyObjectId('bill-id', $importable->billId); $destination = $this->opposingMapper->map($importable->opposingId, $amount, $importable->getOpposingAccountData());
$budgetId = $this->verifyObjectId('budget-id', $importable->budgetId); $currency = $this->currencyMapper->map($importable->currencyId, $importable->getCurrencyData());
$currencyId = $this->verifyObjectId('currency-id', $importable->currencyId); $foreignCurrency = $this->currencyMapper->map($importable->foreignCurrencyId, $importable->getForeignCurrencyData());
$categoryId = $this->verifyObjectId('category-id', $importable->categoryId);
$foreignCurrencyId = $this->verifyObjectId('foreign-currency-id', $importable->foreignCurrencyId);
$opposingId = $this->verifyObjectId('opposing-id', $importable->opposingId);
$source = $this->assetMapper->map($accountId, $importable->getAccountData());
$destination = $this->opposingMapper->map($opposingId, $amount, $importable->getOpposingAccountData());
$currency = $this->currencyMapper->map($currencyId, $importable->getCurrencyData());
$foreignCurrency = $this->currencyMapper->map($foreignCurrencyId, $importable->getForeignCurrencyData());
Log::debug(sprintf('"%s" (#%d) is source and "%s" (#%d) is destination.', $source->name, $source->id, $destination->name, $destination->id)); Log::debug(sprintf('"%s" (#%d) is source and "%s" (#%d) is destination.', $source->name, $source->id, $destination->name, $destination->id));
@@ -296,7 +288,7 @@ class ImportableConverter
'description' => $importable->description, 'description' => $importable->description,
'piggy_bank_id' => null, 'piggy_bank_id' => null,
'piggy_bank_name' => null, 'piggy_bank_name' => null,
'bill_id' => $billId, 'bill_id' => $importable->billId,
'bill_name' => $importable->billName, 'bill_name' => $importable->billName,
// transaction data: // transaction data:
@@ -306,15 +298,15 @@ class ImportableConverter
'currency_code' => null, 'currency_code' => null,
'description' => null, 'description' => null,
'amount' => $amount, 'amount' => $amount,
'budget_id' => $budgetId, 'budget_id' => $importable->budgetId,
'budget_name' => null === $budgetId ? $importable->budgetName : null, 'budget_name' => $importable->budgetName,
'category_id' => $categoryId, 'category_id' => $importable->categoryId,
'category_name' => null === $categoryId ? $importable->categoryName : null, 'category_name' => $importable->categoryName,
'source_id' => $source->id, 'source_id' => $source->id,
'source_name' => null, 'source_name' => null,
'destination_id' => $destination->id, 'destination_id' => $destination->id,
'destination_name' => null, 'destination_name' => null,
'foreign_currency_id' => $foreignCurrencyId, 'foreign_currency_id' => $importable->foreignCurrencyId,
'foreign_currency_code' => null === $foreignCurrency ? null : $foreignCurrency->code, 'foreign_currency_code' => null === $foreignCurrency ? null : $foreignCurrency->code,
'foreign_amount' => $foreignAmount, 'foreign_amount' => $foreignAmount,
'reconciled' => false, 'reconciled' => false,
@@ -335,7 +327,6 @@ class ImportableConverter
*/ */
private function verifyObjectId(string $key, int $objectId): ?int private function verifyObjectId(string $key, int $objectId): ?int
{ {
if (isset($this->mappedValues[$key]) && \in_array($objectId, $this->mappedValues[$key], true)) { if (isset($this->mappedValues[$key]) && \in_array($objectId, $this->mappedValues[$key], true)) {
Log::debug(sprintf('verifyObjectId(%s, %d) is valid!', $key, $objectId)); Log::debug(sprintf('verifyObjectId(%s, %d) is valid!', $key, $objectId));