Commit 1dea1523 authored by Nicolas Frandeboeuf's avatar Nicolas Frandeboeuf Committed by Nicolas Frandeboeuf
Browse files

Use transaction title if raw not provided + skip if no label at all + fix...

Use transaction title if raw not provided + skip if no label at all + fix weboob connector when fields are empty
parent 460bae71
......@@ -296,12 +296,17 @@ merging as per request`);
continue;
}
if (!sourceOp.raw && !sourceOp.title) {
log.error('Operation without raw or title, skipping');
continue;
}
let operation = {
accountId: accountIdNumberMap.get(sourceOp.account),
amount: Number.parseFloat(sourceOp.amount),
raw: sourceOp.raw,
raw: sourceOp.raw || sourceOp.title,
date: new Date(sourceOp.date),
title: sourceOp.title,
title: sourceOp.title || sourceOp.raw,
binary: sourceOp.binary,
debitDate: new Date(sourceOp.debit_date)
};
......@@ -329,7 +334,6 @@ merging as per request`);
operation.debitDate = operation.date;
}
operation.title = operation.title || operation.raw || '';
operation.dateImport = now;
let operationType = transactionTypeIdToName(sourceOp.type);
......
......@@ -544,6 +544,19 @@ class Connector(object):
# Build an operation dict for each operation.
for operation in operations:
title = None
if not empty(operation.label):
title = unicode(operation.label)
raw = None
if not empty(operation.raw):
raw = unicode(operation.raw)
elif title:
raw = title
if raw and not title:
title = raw
# Handle date
if operation.rdate:
# Use date of the payment (real date) if available.
......@@ -554,22 +567,17 @@ class Connector(object):
else:
logging.error(
'No known date property in operation line: %s.',
unicode(operation.raw)
raw or "no label"
)
date = datetime.now()
if operation.label:
title = unicode(operation.label)
else:
title = unicode(operation.raw)
isodate = date.isoformat()
debit_date = operation.date.isoformat()
results.append({
'account': account.id,
'amount': operation.amount,
'raw': unicode(operation.raw),
'raw': raw,
'type': operation.type,
'date': isodate,
'debit_date': debit_date,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment