OMG a ridiculous commit to overhaul import handler config etc.
- register all import/export handlers via setup.py and config - use "handler key" lookup for all import/export commands - fix logic bugs w/ CORE -> Trainwreck importer
This commit is contained in:
parent
0e28a6ee2b
commit
3140245857
9 changed files with 122 additions and 97 deletions
|
@ -33,4 +33,4 @@ class ImportCore(commands.ImportSubcommand):
|
|||
"""
|
||||
name = 'import-corepos'
|
||||
description = __doc__.strip()
|
||||
handler_spec = 'rattail_corepos.trainwreck.importing.corepos:FromCoreToTrainwreck'
|
||||
handler_key = 'to_trainwreck.from_corepos_db_office_trans.import'
|
||||
|
|
|
@ -37,7 +37,9 @@ class FromCoreToTrainwreck(importing.FromSQLAlchemyHandler, trainwreck_importing
|
|||
"""
|
||||
Import data from CORE-POS into Trainwreck
|
||||
"""
|
||||
host_key = 'corepos_db_office_trans'
|
||||
host_title = "CORE-POS"
|
||||
generic_host_title = 'CORE Office (DB "trans")'
|
||||
corepos_dbkey = 'default'
|
||||
|
||||
def make_host_session(self):
|
||||
|
@ -150,23 +152,23 @@ class TransactionImporter(FromCore, trainwreck_importing.model.TransactionImport
|
|||
current = {}
|
||||
|
||||
def collect(detail, i):
|
||||
receipt_number = str(detail.transaction_number)
|
||||
|
||||
system_id = self.make_system_id(detail)
|
||||
if current and current['system_id'] != system_id:
|
||||
transactions.append(dict(current))
|
||||
current.clear()
|
||||
|
||||
date_time = detail.date_time
|
||||
if date_time:
|
||||
date_time = localtime(self.config, date_time)
|
||||
date_time = make_utc(date_time)
|
||||
|
||||
if current and current['receipt_number'] != receipt_number:
|
||||
transactions.append(dict(current))
|
||||
current.clear()
|
||||
|
||||
if not current:
|
||||
current.update({
|
||||
'system': self.enum.TRAINWRECK_SYSTEM_COREPOS,
|
||||
'system_id': self.make_system_id(detail),
|
||||
'system_id': system_id,
|
||||
'terminal_id': str(detail.register_number),
|
||||
'receipt_number': receipt_number,
|
||||
'receipt_number': str(detail.transaction_number),
|
||||
'cashier_id': str(detail.employee_number) if detail.employee_number else None,
|
||||
'customer_id': str(detail.card_number) if detail.card_number else None,
|
||||
'start_time': date_time,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue