diff --git a/rattail_corepos/batch/coremember.py b/rattail_corepos/batch/coremember.py index 7dacf86..7ee9605 100644 --- a/rattail_corepos/batch/coremember.py +++ b/rattail_corepos/batch/coremember.py @@ -106,7 +106,9 @@ class CoreMemberBatchHandler(BatchHandler): def append(csvrow, i): row = self.make_row() - row.card_number = int(csvrow['external_id']) + row.card_number_raw = csvrow['external_id'] + if csvrow['external_id'].isdigit(): + row.card_number = int(csvrow['external_id']) row.first_name = csvrow['first_name'] row.last_name = csvrow['last_name'] row.street = csvrow['primary_address1'] diff --git a/rattail_corepos/db/alembic/versions/d6a0f21a6a94_add_card_number_raw_for_member_import.py b/rattail_corepos/db/alembic/versions/d6a0f21a6a94_add_card_number_raw_for_member_import.py new file mode 100644 index 0000000..c297345 --- /dev/null +++ b/rattail_corepos/db/alembic/versions/d6a0f21a6a94_add_card_number_raw_for_member_import.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8; -*- +"""add card_number_raw for member import + +Revision ID: d6a0f21a6a94 +Revises: 50961b4b854a +Create Date: 2022-03-15 11:24:41.764317 + +""" + +from __future__ import unicode_literals + +# revision identifiers, used by Alembic. +revision = 'd6a0f21a6a94' +down_revision = '50961b4b854a' +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa +import rattail.db.types + + + +def upgrade(): + + # batch_corepos_member_row + op.add_column('batch_corepos_member_row', sa.Column('card_number_raw', sa.String(length=20), nullable=True)) + + +def downgrade(): + + # batch_corepos_member_row + op.drop_column('batch_corepos_member_row', 'card_number_raw') diff --git a/rattail_corepos/db/model/batch/coremember.py b/rattail_corepos/db/model/batch/coremember.py index 8884a7d..c55a3f6 100644 --- a/rattail_corepos/db/model/batch/coremember.py +++ b/rattail_corepos/db/model/batch/coremember.py @@ -70,6 +70,7 @@ class CoreMemberBatchRow(model.BatchRowMixin, model.Base): STATUS_FIELDS_CHANGED : "update member", } + card_number_raw = sa.Column(sa.String(length=20), nullable=True) card_number = sa.Column(sa.Integer(), nullable=True) first_name = sa.Column(sa.String(length=30), nullable=True)