Import Store, ProductCost from CORE DB

and tweak API importer accordingly
This commit is contained in:
Lance Edgar 2023-10-20 14:37:25 -05:00
parent 67861522eb
commit b6e21f52ee
5 changed files with 199 additions and 9 deletions

View file

@ -0,0 +1,39 @@
# -*- coding: utf-8; -*-
"""fix FK for CoreProductCost
Revision ID: b5a8734b1fe0
Revises: 15bf65f68c52
Create Date: 2023-10-20 11:20:09.231682
"""
# revision identifiers, used by Alembic.
revision = 'b5a8734b1fe0'
down_revision = '15bf65f68c52'
branch_labels = None
depends_on = None
from alembic import op
import sqlalchemy as sa
import rattail.db.types
def upgrade():
# corepos_product_cost
op.alter_column('corepos_product_cost', 'corepos_id', existing_type=sa.INTEGER(), nullable=True)
op.add_column('corepos_product_cost', sa.Column('corepos_vendor_id', sa.Integer(), nullable=False))
op.add_column('corepos_product_cost', sa.Column('corepos_sku', sa.String(length=13), nullable=False))
op.add_column('corepos_product_cost_version', sa.Column('corepos_vendor_id', sa.Integer(), autoincrement=False, nullable=True))
op.add_column('corepos_product_cost_version', sa.Column('corepos_sku', sa.String(length=13), autoincrement=False, nullable=True))
def downgrade():
# corepos_product_cost
op.drop_column('corepos_product_cost_version', 'corepos_sku')
op.drop_column('corepos_product_cost_version', 'corepos_vendor_id')
op.drop_column('corepos_product_cost', 'corepos_sku')
op.drop_column('corepos_product_cost', 'corepos_vendor_id')
op.alter_column('corepos_product_cost', 'corepos_id', existing_type=sa.INTEGER(), nullable=False)

View file

@ -195,11 +195,24 @@ class CoreProductCost(model.Base):
Reference to the CORE-POS extension record for this product cost.
"""))
corepos_id = sa.Column(sa.Integer(), nullable=False, doc="""
``vendorItemID`` value for the corresponding record within CORE-POS.
corepos_vendor_id = sa.Column(sa.Integer(), nullable=False, doc="""
``vendorItems.vendorID`` value for the corresponding record within
CORE-POS.
""")
corepos_sku = sa.Column(sa.String(length=13), nullable=False, doc="""
``vendorItems.sku`` value for the corresponding record within
CORE-POS.
""")
corepos_id = sa.Column(sa.Integer(), nullable=True, doc="""
``vendorItems.vendorItemID`` value for the corresponding record
within CORE-POS.
""")
def __str__(self):
return str(self.cost)
CoreProductCost.make_proxy(model.ProductCost, '_corepos', 'corepos_vendor_id')
CoreProductCost.make_proxy(model.ProductCost, '_corepos', 'corepos_sku')
CoreProductCost.make_proxy(model.ProductCost, '_corepos', 'corepos_id')