Make sure each source of transactions stores where it's from.

This commit is contained in:
James Cole 2018-09-05 19:45:59 +02:00
parent 2afbef63aa
commit b1cc17d96e
10 changed files with 16 additions and 4 deletions

View File

@ -73,6 +73,7 @@ class TransactionRequest extends Request
'invoice_date' => $this->date('invoice_date'),
'internal_reference' => $this->string('internal_reference'),
'notes' => $this->string('notes'),
'original-source' => sprintf('api-v%s', config('firefly.api_version')),
'transactions' => $this->getTransactionData(),
];

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', 'sepa-batch-id'];
'external_id', 'sepa-batch-id','original-source'];
foreach ($fields as $field) {
$this->storeMeta($journal, $data, $field);

View File

@ -75,6 +75,7 @@ class JournalFormRequest extends Request
'piggy_bank_name' => null,
'bill_id' => null,
'bill_name' => null,
'original-source' => sprintf('gui-v%s', config('firefly.version')),
// transaction data:
'transactions' => [

View File

@ -182,10 +182,10 @@ class ImportTransaction
}
$meta = ['sepa-ct-id', 'sepa-ct-op', 'sepa-db', 'sepa-cc', 'sepa-country', 'sepa-batch-id', 'sepa-ep', 'sepa-ci', 'internal-reference', 'date-interest',
'date-invoice', 'date-book', 'date-payment', 'date-process', 'date-due',];
'date-invoice', 'date-book', 'date-payment', 'date-process', 'date-due','original-source'];
Log::debug(sprintf('Now going to check role "%s".', $role));
if (\in_array($role, $meta, true)) {
Log::debug(sprintf('Role "%s" is in allowed meta roles, so store its value %s.', $role, $columnValue->getValue()));
Log::debug(sprintf('Role "%s" is in allowed meta roles, so store its value "%s".', $role, $columnValue->getValue()));
$this->meta[$role] = $columnValue->getValue();
return;

View File

@ -173,6 +173,7 @@ class StageImportDataHandler
'external_id' => $paymentId,
'notes' => null,
'bunq_payment_id' => $paymentId,
'original-source' => sprintf('bunq-v%s', config('firefly.version')),
'transactions' => [
// single transaction:
[

View File

@ -61,6 +61,7 @@ class StageFinalHandler
'piggy_bank_name' => null,
'bill_id' => null,
'bill_name' => null,
'original-source' => sprintf('fake-import-v%s', config('firefly.version')),
// transaction data:
'transactions' => [

View File

@ -235,7 +235,7 @@ class ImportableConverter
'payment_date' => $this->convertDateValue($importable->meta['date-payment'] ?? null),
'invoice_date' => $this->convertDateValue($importable->meta['date-invoice'] ?? null),
'external_id' => $importable->externalId,
'original-source' => $importable->meta['original-source'] ?? null,
// journal data:
'description' => $importable->description,
'piggy_bank_id' => null,

View File

@ -201,6 +201,12 @@ class MappingConverger
Log::debug('Column skipped because value is empty.');
}
}
// add a special column value for the "source"
$columnValue = new ColumnValue;
$columnValue->setValue(sprintf('csv-import-v%s', config('firefly.version')));
$columnValue->setMappedValue(0);
$columnValue->setRole('original-source');
$return[] = $columnValue;
return $return;
}

View File

@ -189,6 +189,7 @@ class StageImportDataHandler
'piggy_bank_name' => null,
'bill_id' => null,
'bill_name' => null,
'original-source' => sprintf('spectre-v%s', config('firefly.version')),
// transaction data:
'transactions' => [

View File

@ -173,6 +173,7 @@ class ImportDataHandler
'piggy_bank_name' => null,
'bill_id' => null,
'bill_name' => null,
'original-source' => sprintf('ynab-v%s', config('firefly.version')),
// transaction data:
'transactions' => [