Fix a bug where transfers would be stored reversed (ie. source and destination switched).

This commit is contained in:
James Cole
2018-07-14 08:33:13 +02:00
parent 46482bdae1
commit cd076cc069
7 changed files with 28 additions and 22 deletions

View File

@@ -203,13 +203,14 @@ class ImportTransaction
case 'external-id':
$this->externalId = $columnValue->getValue();
break;
case 'sepa-ct-id';
case 'sepa-ct-op';
case 'sepa-db';
case 'sepa-ct-id':
case 'sepa-ct-op':
case 'sepa-db':
case 'sepa-cc':
case 'sepa-country';
case 'sepa-ep';
case 'sepa-ci';
case 'sepa-country':
case 'sepa-batch-id':
case 'sepa-ep':
case 'sepa-ci':
case 'internal-reference':
case 'date-interest':
case 'date-invoice':

View File

@@ -183,8 +183,8 @@ class ImportableConverter
$transactionType = 'transfer';
}
// amount is positive and its not a transfer? Then switch:
if ($transactionType !== 'transfer' && bccomp($amount, '0') === 1) {
// amount is positive? Then switch:
if (1 === bccomp($amount, '0')) {
[$destination, $source] = [$source, $destination];
Log::debug(
@@ -194,17 +194,6 @@ class ImportableConverter
)
);
}
// amount is negative and type is transfer? then switch.
if ($transactionType === 'transfer' && bccomp($amount, '0') === -1) {
// amount is positive? Then switch:
[$destination, $source] = [$source, $destination];
Log::debug(
sprintf(
'%s is negative, so "%s" (#%d) is now source and "%s" (#%d) is now destination.',
$amount, $source->name, $source->id, $destination->name, $destination->id
)
);
}
// get currency preference from source asset account (preferred)
// or destination asset account
@@ -273,9 +262,10 @@ class ImportableConverter
'sepa-ct-op' => $importable->meta['sepa-ct-op'] ?? null,
'sepa-ct-id' => $importable->meta['sepa-ct-id'] ?? null,
'sepa-db' => $importable->meta['sepa-db'] ?? null,
'sepa-country' => $importable->meta['sepa-countru'] ?? null,
'sepa-country' => $importable->meta['sepa-country'] ?? null,
'sepa-ep' => $importable->meta['sepa-ep'] ?? null,
'sepa-ci' => $importable->meta['sepa-ci'] ?? null,
'sepa-batch-id' => $importable->meta['sepa-batch-id'] ?? null,
'interest_date' => $this->convertDateValue($importable->meta['date-interest'] ?? null),
'book_date' => $this->convertDateValue($importable->meta['date-book'] ?? null),
'process_date' => $this->convertDateValue($importable->meta['date-process'] ?? null),