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

@ -104,7 +104,7 @@ class TransactionJournalFactory
// store date meta fields (if present):
$fields = ['sepa-cc', 'sepa-ct-op', 'sepa-ct-id', 'sepa-db', 'sepa-country', 'sepa-ep', 'sepa-ci', 'interest_date', 'book_date', 'process_date',
'due_date', 'recurrence_id', 'payment_date', 'invoice_date', 'internal_reference', 'bunq_payment_id', 'importHash', 'importHashV2',
'external_id'];
'external_id','sepa-batch-id'];
foreach ($fields as $field) {
$this->storeMeta($journal, $data, $field);

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),

View File

@ -283,6 +283,12 @@ return [
'converter' => 'AssetAccountNumber',
'mapper' => 'AssetAccounts',
],
'account-bic' => [
'mappable' => false,
'pre-process-map' => false,
'field' => 'asset-account-bic',
'converter' => 'AccountBic',
],
'opposing-id' => [
'mappable' => true,
'pre-process-map' => false,
@ -391,6 +397,13 @@ return [
'converter' => 'Description',
'field' => 'sepa_ci',
],
// SEPA Batch ID
'sepa-batch-id' => [
'mappable' => false,
'pre-process-map' => false,
'converter' => 'Description',
'field' => 'sepa_batch',
],
// Internal reference
'internal-reference' => [
'mappable' => false,

View File

@ -219,6 +219,7 @@ return [
'column_account-iban' => 'Asset account (IBAN)',
'column_account-id' => 'Asset account ID (matching FF3)',
'column_account-name' => 'Asset account (name)',
'column_account-bic' => 'Asset account (BIC)',
'column_amount' => 'Amount',
'column_amount_foreign' => 'Amount (in foreign currency)',
'column_amount_debit' => 'Amount (debit column)',

View File

@ -112,6 +112,7 @@ return [
'sepa-cc' => 'SEPA Clearing Code',
'sepa-ep' => 'SEPA External Purpose',
'sepa-ci' => 'SEPA Creditor Identifier',
'sepa-batch-id' => 'SEPA Batch ID',
'external_id' => 'External ID',
'account_at_bunq' => 'Account with bunq',
'file_name' => 'File name',

View File

@ -210,7 +210,7 @@
{% endif %}
{% endfor %}
{# all other meta values #}
{% for metaField in ['external_id','bunq_payment_id','internal_reference','sepa-ct-id','sepa-ct-op','sepa-db','sepa-country','sepa-cc','sepa-ep','sepa-ci'] %}
{% for metaField in ['external_id','bunq_payment_id','internal_reference','sepa-batch-id','sepa-ct-id','sepa-ct-op','sepa-db','sepa-country','sepa-cc','sepa-ep','sepa-ci'] %}
{% if journalHasMeta(journal, metaField) %}
<tr>
<td>{{ trans('list.'~metaField) }}</td>