mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Extend rule set for import.
This commit is contained in:
@@ -66,9 +66,17 @@ class AssetAccountIban extends BasicConverter implements ConverterInterface
|
||||
|
||||
|
||||
$account = $repository->store(
|
||||
['name' => 'Account with IBAN ' . $value, 'iban' => $value, 'user' => $this->user->id, 'accountType' => 'asset', 'virtualBalance' => 0,
|
||||
'active' => true]
|
||||
['name' => 'Asset account with IBAN ' . $value, 'iban' => $value, 'user' => $this->user->id, 'accountType' => 'asset', 'virtualBalance' => 0,
|
||||
'active' => true, 'openingBalance' => 0]
|
||||
);
|
||||
|
||||
if (is_null($account->id)) {
|
||||
$this->setCertainty(0);
|
||||
Log::info('Could not store new asset account by IBAN', $account->getErrors()->toArray());
|
||||
|
||||
return new Account;
|
||||
}
|
||||
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $account;
|
||||
|
@@ -68,6 +68,14 @@ class AssetAccountName extends BasicConverter implements ConverterInterface
|
||||
['name' => $value, 'iban' => null, 'openingBalance' => 0, 'user' => $this->user->id, 'accountType' => 'asset', 'virtualBalance' => 0,
|
||||
'active' => true]
|
||||
);
|
||||
|
||||
if (is_null($account->id)) {
|
||||
$this->setCertainty(0);
|
||||
Log::info('Could not store new asset account by name', $account->getErrors()->toArray());
|
||||
|
||||
return new Account;
|
||||
}
|
||||
|
||||
$this->setCertainty(100);
|
||||
|
||||
Log::debug('Created new asset account ', ['name' => $account->name, 'id' => $account->id]);
|
||||
|
@@ -32,7 +32,7 @@ class AssetAccountNumber extends BasicConverter implements ConverterInterface
|
||||
public function convert($value)
|
||||
{
|
||||
$value = trim($value);
|
||||
Log::debug('Going to convert using AssetAccountName', ['value' => $value]);
|
||||
Log::debug('Going to convert using AssetAccountNumber', ['value' => $value]);
|
||||
|
||||
if (strlen($value) === 0) {
|
||||
return new Account;
|
||||
@@ -77,6 +77,14 @@ class AssetAccountNumber extends BasicConverter implements ConverterInterface
|
||||
'accountType' => 'asset',
|
||||
'virtualBalance' => 0, 'accountNumber' => $value, 'active' => true]
|
||||
);
|
||||
|
||||
if (is_null($account->id)) {
|
||||
$this->setCertainty(0);
|
||||
Log::notice('Could not store new asset account by account number', $account->getErrors()->toArray());
|
||||
|
||||
return new Account;
|
||||
}
|
||||
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $account;
|
||||
|
@@ -63,6 +63,7 @@ class BillId extends BasicConverter implements ConverterInterface
|
||||
}
|
||||
|
||||
// should not really happen. If the ID does not match FF, what is FF supposed to do?
|
||||
Log::info(sprintf('Could not find bill with ID %d. Will return NULL', $value));
|
||||
|
||||
$this->setCertainty(0);
|
||||
|
||||
|
@@ -76,6 +76,13 @@ class BillName extends BasicConverter implements ConverterInterface
|
||||
|
||||
]
|
||||
);
|
||||
if (is_null($bill->id)) {
|
||||
$this->setCertainty(0);
|
||||
Log::info('Could not store new bill by name', $bill->getErrors()->toArray());
|
||||
|
||||
return new Bill;
|
||||
}
|
||||
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $bill;
|
||||
|
@@ -63,6 +63,9 @@ class BudgetId extends BasicConverter implements ConverterInterface
|
||||
|
||||
// should not really happen. If the ID does not match FF, what is FF supposed to do?
|
||||
$this->setCertainty(0);
|
||||
|
||||
Log::info(sprintf('Could not find budget with ID %d. Will return NULL', $value));
|
||||
|
||||
return new Budget;
|
||||
|
||||
}
|
||||
|
@@ -62,6 +62,9 @@ class CategoryId extends BasicConverter implements ConverterInterface
|
||||
|
||||
// should not really happen. If the ID does not match FF, what is FF supposed to do?
|
||||
$this->setCertainty(0);
|
||||
|
||||
Log::info(sprintf('Could not find category with ID %d. Will return NULL', $value));
|
||||
|
||||
return new Category;
|
||||
|
||||
}
|
||||
|
@@ -61,6 +61,9 @@ class CurrencyId extends BasicConverter implements ConverterInterface
|
||||
}
|
||||
$this->setCertainty(0);
|
||||
// should not really happen. If the ID does not match FF, what is FF supposed to do?
|
||||
|
||||
Log::info(sprintf('Could not find category with ID %d. Will return NULL', $value));
|
||||
|
||||
return new TransactionCurrency;
|
||||
|
||||
}
|
||||
|
@@ -37,9 +37,10 @@ class Date extends BasicConverter implements ConverterInterface
|
||||
try {
|
||||
$date = Carbon::createFromFormat($this->config['date-format'], $value);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
Log::critical($e->getMessage());
|
||||
Log::critical('Cannot convert this string using the given format.', ['value' => $value, 'format' => $this->config['date-format']]);
|
||||
throw new FireflyException(sprintf('Cannot convert "%s" to a valid date using format "%s".', $value, $this->config['date-format']));
|
||||
Log::notice($e->getMessage());
|
||||
Log::notice('Cannot convert this string using the given format.', ['value' => $value, 'format' => $this->config['date-format']]);
|
||||
$this->setCertainty(0);
|
||||
return new Carbon;
|
||||
}
|
||||
Log::debug('Converted date', ['converted' => $date->toAtomString()]);
|
||||
$this->setCertainty(100);
|
||||
|
@@ -56,7 +56,7 @@ class OpposingAccountIban extends BasicConverter implements ConverterInterface
|
||||
$account = $repository->findByIban($value, []);
|
||||
if (!is_null($account->id)) {
|
||||
Log::debug('Found account by IBAN', ['id' => $account->id]);
|
||||
Log::warning(
|
||||
Log::notice(
|
||||
'The match between IBAN and account is uncertain because the type of transactions may not have been determined.',
|
||||
['id' => $account->id, 'iban' => $value]
|
||||
);
|
||||
|
@@ -47,6 +47,7 @@ class OpposingAccountName extends BasicConverter implements ConverterInterface
|
||||
if (!is_null($account->id)) {
|
||||
Log::debug('Found account by ID', ['id' => $account->id]);
|
||||
$this->setCertainty(100);
|
||||
|
||||
return $account;
|
||||
}
|
||||
}
|
||||
@@ -55,11 +56,12 @@ class OpposingAccountName extends BasicConverter implements ConverterInterface
|
||||
$account = $repository->findByName($value, []);
|
||||
if (!is_null($account->id)) {
|
||||
Log::debug('Found opposing account by name', ['id' => $account->id]);
|
||||
Log::warning(
|
||||
Log::info(
|
||||
'The match between name and account is uncertain because the type of transactions may not have been determined.',
|
||||
['id' => $account->id, 'name' => $value]
|
||||
);
|
||||
$this->setCertainty(50);
|
||||
|
||||
return $account;
|
||||
}
|
||||
|
||||
@@ -68,6 +70,11 @@ class OpposingAccountName extends BasicConverter implements ConverterInterface
|
||||
'openingBalance' => 0,
|
||||
]
|
||||
);
|
||||
if (is_null($account->id)) {
|
||||
$this->setCertainty(0);
|
||||
|
||||
return new Account;
|
||||
}
|
||||
$this->setCertainty(100);
|
||||
|
||||
Log::debug('Created new opposing account ', ['name' => $account->name, 'id' => $account->id]);
|
||||
|
Reference in New Issue
Block a user