mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-25 13:10:35 +00:00
Migrated all code to group collector.
This commit is contained in:
@@ -160,6 +160,12 @@ class ImportTransaction
|
||||
'opposing-bic' => 'opposingBic',
|
||||
'opposing-number' => 'opposingNumber',
|
||||
];
|
||||
|
||||
// overrule some old role values.
|
||||
if ('original-source' === $role) {
|
||||
$role = 'original_source';
|
||||
}
|
||||
|
||||
if (isset($basics[$role])) {
|
||||
$field = $basics[$role];
|
||||
$this->$field = $columnValue->getValue();
|
||||
@@ -229,6 +235,18 @@ class ImportTransaction
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mapped value if it exists in the ColumnValue object.
|
||||
*
|
||||
* @param ColumnValue $columnValue
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getMappedValue(ColumnValue $columnValue): int
|
||||
{
|
||||
return $columnValue->getMappedValue() > 0 ? $columnValue->getMappedValue() : (int)$columnValue->getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the amount of this transaction.
|
||||
*
|
||||
@@ -276,6 +294,40 @@ class ImportTransaction
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This methods decides which input value to use for the amount calculation.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function selectAmountInput(): array
|
||||
{
|
||||
$info = [];
|
||||
$converterClass = '';
|
||||
if (null !== $this->amount) {
|
||||
Log::debug('Amount value is not NULL, assume this is the correct value.');
|
||||
$converterClass = Amount::class;
|
||||
$info['amount'] = $this->amount;
|
||||
}
|
||||
if (null !== $this->amountDebit) {
|
||||
Log::debug('Amount DEBIT value is not NULL, assume this is the correct value (overrules Amount).');
|
||||
$converterClass = AmountDebit::class;
|
||||
$info['amount'] = $this->amountDebit;
|
||||
}
|
||||
if (null !== $this->amountCredit) {
|
||||
Log::debug('Amount CREDIT value is not NULL, assume this is the correct value (overrules Amount and AmountDebit).');
|
||||
$converterClass = AmountCredit::class;
|
||||
$info['amount'] = $this->amountCredit;
|
||||
}
|
||||
if (null !== $this->amountNegated) {
|
||||
Log::debug('Amount NEGATED value is not NULL, assume this is the correct value (overrules Amount and AmountDebit and AmountCredit).');
|
||||
$converterClass = AmountNegated::class;
|
||||
$info['amount'] = $this->amountNegated;
|
||||
}
|
||||
$info['class'] = $converterClass;
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* The method that calculates the foreign amount isn't nearly as complex,\
|
||||
* because Firefly III only supports one foreign amount field. So the foreign amount is there
|
||||
@@ -372,50 +424,4 @@ class ImportTransaction
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mapped value if it exists in the ColumnValue object.
|
||||
*
|
||||
* @param ColumnValue $columnValue
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function getMappedValue(ColumnValue $columnValue): int
|
||||
{
|
||||
return $columnValue->getMappedValue() > 0 ? $columnValue->getMappedValue() : (int)$columnValue->getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* This methods decides which input value to use for the amount calculation.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function selectAmountInput(): array
|
||||
{
|
||||
$info = [];
|
||||
$converterClass = '';
|
||||
if (null !== $this->amount) {
|
||||
Log::debug('Amount value is not NULL, assume this is the correct value.');
|
||||
$converterClass = Amount::class;
|
||||
$info['amount'] = $this->amount;
|
||||
}
|
||||
if (null !== $this->amountDebit) {
|
||||
Log::debug('Amount DEBIT value is not NULL, assume this is the correct value (overrules Amount).');
|
||||
$converterClass = AmountDebit::class;
|
||||
$info['amount'] = $this->amountDebit;
|
||||
}
|
||||
if (null !== $this->amountCredit) {
|
||||
Log::debug('Amount CREDIT value is not NULL, assume this is the correct value (overrules Amount and AmountDebit).');
|
||||
$converterClass = AmountCredit::class;
|
||||
$info['amount'] = $this->amountCredit;
|
||||
}
|
||||
if (null !== $this->amountNegated) {
|
||||
Log::debug('Amount NEGATED value is not NULL, assume this is the correct value (overrules Amount and AmountDebit and AmountCredit).');
|
||||
$converterClass = AmountNegated::class;
|
||||
$info['amount'] = $this->amountNegated;
|
||||
}
|
||||
$info['class'] = $converterClass;
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user