Make card_number more central for CORE API -> Rattail importers

let's track that as (effectively) `Customer.corepos_card_number` and
use that when possible for importer key
This commit is contained in:
Lance Edgar 2023-06-05 20:45:45 -05:00
parent c1276c998a
commit bfc52a6fb3
6 changed files with 179 additions and 65 deletions

View file

@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
# Copyright © 2010-2020 Lance Edgar
# Copyright © 2010-2023 Lance Edgar
#
# This file is part of Rattail.
#
@ -28,8 +28,8 @@ from corepos.db.office_op import model as corepos, Session as CoreSession
from rattail.importing.handlers import FromFileHandler
from rattail.importing.csv import FromCSVToSQLAlchemyMixin
from rattail_corepos.corepos.importing.db.model import ToCore
from rattail_corepos.corepos.importing.db.corepos import ToCoreHandler
from rattail_corepos.corepos.office.importing.db.model import ToCore
from rattail_corepos.corepos.office.importing.db.corepos import ToCoreHandler
class FromCSVToCore(FromCSVToSQLAlchemyMixin, FromFileHandler, ToCoreHandler):

View file

@ -46,7 +46,9 @@ def get_core_members(config, api, progress=None):
# first we fetch all customer records from CORE DB
with app.short_session(factory=CoreSession) as s:
db_customers = s.query(corepos.CustData).all()
db_customers = s.query(corepos.CustData)\
.order_by(corepos.CustData.card_number)\
.all()
s.expunge_all()
# now we must fetch each customer account individually from API