From 8daec28faf64a43a20f762e74ff82ac3315ea917 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 15 Mar 2022 11:34:37 -0500 Subject: [PATCH] Add "raw" card number value to CORE Member Import batch b/c source file may not have it, or may not be numeric --- rattail_corepos/batch/coremember.py | 4 ++- ...4_add_card_number_raw_for_member_import.py | 33 +++++++++++++++++++ rattail_corepos/db/model/batch/coremember.py | 1 + 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 rattail_corepos/db/alembic/versions/d6a0f21a6a94_add_card_number_raw_for_member_import.py 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)