Added the Sales Categories to migrate updated the others
This commit is contained in:
parent
e1c42d4470
commit
6ace2078bd
@ -6,9 +6,10 @@ call:copyQuery d-Users "SELECT 'INSERT INTO users(id, name, msr_string, password
|
||||
call:copyQuery e-UserRoles "SELECT 'INSERT INTO user_roles(id, user_id, role_id) VALUES (''' + CAST(UserGroupID AS Nvarchar(36)) + ''', ''' + CAST(UserID AS Nvarchar(36)) + ''', ''' + CAST(GroupID AS Nvarchar(36)) + ''');' FROM Test.dbo.Auth_UserGroups;"
|
||||
call:copyQuery f-Customers "SELECT 'INSERT INTO customers(id, name, address, is_important, phone) VALUES (''' + CAST(CustomerID AS Nvarchar(36)) + ''', ''' + REPLACE(Name, '''', '''''') + ''', ''' + COALESCE(Address, 'null') + ''', ' + CASE WHEN Important = 1 THEN 'true' ELSE 'false' END + ', ''' + COALESCE(Phone, 'null') + ''');' FROM Test.dbo.Customers;"
|
||||
call:copyQuery g-FoodTables "SELECT 'INSERT INTO food_tables(id, name, is_active, location, sort_order) VALUES (''' + CAST(FoodTableID AS Nvarchar(36)) + ''', ''' + Name + ''', ' + CASE WHEN IsActive = 1 THEN 'true' ELSE 'false' END + ', ''' + COALESCE(Location, 'null') + ''', ' + CAST(SortOrder AS Nvarchar(36)) + ');' FROM Test.dbo.FoodTables;"
|
||||
call:copyQuery h-Taxes "SELECT 'INSERT INTO taxes(id, name, rate) VALUES ('''+ CAST(TaxID AS Nvarchar(36)) + ''', ' + '''' + REPLACE(Name, '''', '''''') + '''' + ', ' + CAST(Rate AS Nvarchar(36)) + ');' FROM Test.dbo.Taxes;"
|
||||
call:copyQuery i-ProductGroups "SELECT 'INSERT INTO product_groups(id, name, discount_limit, is_modifier_compulsory, is_active, sort_order, group_type) VALUES (''' + CAST(ProductGroupID AS Nvarchar(36)) + ''', ''' + REPLACE(Name, '''', '''''') + ''', ' + CAST(DiscountLimit AS nvarchar(36)) + ', ' + CASE WHEN IsModifierCompulsory = 1 THEN 'true' ELSE 'false' END + ', ' + CASE WHEN IsActive = 1 THEN 'true' ELSE 'false' END + ', ' + CAST(SortOrder AS Nvarchar(36)) + ', ''' + GroupType + ''');' FROM Test.dbo.ProductGroups;"
|
||||
call:copyQuery j-Products "SELECT 'INSERT INTO products(id, name, units, product_group_id, vat_id, service_tax_id, service_charge, is_sc_taxable, price, has_happy_hour, is_active, is_not_available, sort_order, quantity) VALUES (''' + CAST(ProductID AS Nvarchar(36)) + ''', ' + '''' + REPLACE(Name, '''', '''''') + '''' + ', ' + '''' + Units + '''' + ', ' + '''' + CAST(ProductGroupID AS Nvarchar(36)) + '''' + ', ' + '''' + CAST(VatID AS Nvarchar(36)) + '''' + ', ' + '''' + CAST(ServiceTaxID AS Nvarchar(36)) + '''' + ', ' + CAST(ServiceCharge AS Nvarchar(36)) + ', ' + CASE WHEN IsScTaxable = 1 THEN 'true' ELSE 'false' END + ', ' + CAST(Price AS Nvarchar(36)) + ', ' + CASE WHEN HasHappyHour = 1 THEN 'true' ELSE 'false' END + ', ' + CASE WHEN IsActive = 1 THEN 'true' ELSE 'false' END + ', ' + CASE WHEN IsNotAvailable = 1 THEN 'true' ELSE 'false' END + ', ' + CAST(SortOrder AS Nvarchar(36)) + ', ' + CAST(Quantity AS Nvarchar(36)) + ');' FROM Test.dbo.Products;"
|
||||
call:copyQuery h-Taxes "SELECT 'INSERT INTO taxes(id, name, rate, is_fixture) VALUES ('''+ CAST(TaxID AS Nvarchar(36)) + ''', ' + '''' + REPLACE(Name, '''', '''''') + '''' + ', ' + CAST(Rate AS Nvarchar(36)) + ', false);' FROM Test.dbo.Taxes;"
|
||||
call:copyQuery i-ProductGroups "SELECT 'INSERT INTO menu_categories(id, name, discount_limit, is_modifier_compulsory, is_active, is_fixture, sort_order) VALUES (''' + CAST(ProductGroupID AS Nvarchar(36)) + ''', ''' + REPLACE(Name, '''', '''''') + ''', ' + CAST(DiscountLimit AS nvarchar(36)) + ', ' + CASE WHEN IsModifierCompulsory = 1 THEN 'true' ELSE 'false' END + ', ' + CASE WHEN IsActive = 1 THEN 'true' ELSE 'false' END + ', false, ' + CAST(SortOrder AS Nvarchar(36)) + ');' FROM Test.dbo.ProductGroups;"
|
||||
call:copyQuery i-SaleCategories "SELECT 'INSERT INTO sale_categories(id, name, tax_id) VALUES (''' + CAST(newid() AS Nvarchar(36)) + ''', ''' + REPLACE(pgo.GroupType, '''', '''''') + ''', ''' + CAST((select top 1 t.TaxID from Test.dbo.Taxes t inner join Test.dbo.Products p on t.TaxID = p.VatID inner join Test.dbo.ProductGroups pg on p.ProductGroupID = pg.ProductGroupID where pg.GroupType = pgo.GroupType) AS Nvarchar(36)) + ''');' from (select distinct pgx.GroupType from Test.dbo.ProductGroups pgx) as pgo;"
|
||||
call:copyQuery j-Products "SELECT 'INSERT INTO products(id, name, units, menu_category_id, sale_category_id, price, has_happy_hour, is_active, is_not_available, sort_order, quantity) VALUES (''' + CAST(ProductID AS Nvarchar(36)) + ''', ' + '''' + REPLACE(Name, '''', '''''') + '''' + ', ' + '''' + Units + '''' + ', ' + '''' + CAST(ProductGroupID AS Nvarchar(36)) + '''' + ', ' + '(select id from sale_categories where name = ''' + (SELECT GroupType FROM Test.dbo.ProductGroups pgs WHERE pgs.ProductGroupID = Products.ProductGroupID) + ''')' + ', ' + CAST(Price AS Nvarchar(36)) + ', ' + CASE WHEN HasHappyHour = 1 THEN 'true' ELSE 'false' END + ', ' + CASE WHEN IsActive = 1 THEN 'true' ELSE 'false' END + ', ' + CASE WHEN IsNotAvailable = 1 THEN 'true' ELSE 'false' END + ', ' + CAST(SortOrder AS Nvarchar(36)) + ', ' + CAST(Quantity AS Nvarchar(36)) + ');' FROM Test.dbo.Products;"
|
||||
call:copyQuery k-Vouchers "SELECT 'INSERT INTO vouchers(id, date, pax, user_id, creation_date, last_edit_date, bill_id, food_table_id, customer_id, narration, is_void, void_reason, is_printed, voucher_type, kot_id) VALUES (''' + CAST(VoucherID AS Nvarchar(36)) + ''', ' + '''' + CONVERT(Nvarchar(36), Date, 126) + ''', ' + COALESCE(CAST(Pax AS Nvarchar(36)), 'null') + ', ' + '''' + CAST(UserID AS Nvarchar(36)) + ''', ' + '''' + CONVERT(Nvarchar(36), CreationDate, 126) + ''', ' + '''' + CONVERT(Nvarchar(36), LastEditDate, 126) + ''', ' + COALESCE(CAST(BillID AS Nvarchar(36)), 'null') + ', ' + '''' + CAST(TableID AS Nvarchar(36)) + ''', ' + '''' + CAST(CustomerID AS Nvarchar(36)) + ''', ' + COALESCE('''' + REPLACE(Narration, '''', '''''') + '''', 'null') + ', ' + CASE WHEN Void = 1 THEN 'true' ELSE 'false' END + ', ' + COALESCE('''' + REPLACE(VoidReason, '''', '''''') + '''', 'null') + ', ' + CASE WHEN Printed = 1 THEN 'true' ELSE 'false' END + ', ' + CAST(VoucherType AS Nvarchar(36)) + ', ' + CAST(KotID AS Nvarchar(36)) + ');' FROM Test.dbo.Vouchers;"
|
||||
call:copyQuery l-Voucher-Food-Table "SELECT 'INSERT INTO voucher_food_table(id, voucher_id, food_table_id, status) VALUES (''' + CAST(newid() AS Nvarchar(36)) + ''', ' + '''' + CAST(VoucherID AS Nvarchar(36)) + ''', ' + '''' + CAST(FoodTableID AS Nvarchar(36)) + ''', ' + '''' + Status + ''');' FROM Test.dbo.FoodTables WHERE VoucherID IS NOT NULL;"
|
||||
call:copyQuery m-Kots "SELECT 'INSERT INTO kots(id, voucher_id, code, food_table_id, date, user_id) VALUES (''' + CAST(KotID AS Nvarchar(36)) + ''', ' + '''' + CAST(VoucherID AS Nvarchar(36)) + '''' + ', ' + CAST(Code AS Nvarchar(36)) + ', ' + '''' + CAST(TableID AS Nvarchar(36)) + '''' + ', ' + '''' + CONVERT(Nvarchar(36), Date, 126) + ''', ' + '''' + CAST(UserID AS Nvarchar(36)) + '''' + ');' FROM Test.dbo.Kots;"
|
||||
|
@ -4,11 +4,10 @@ import transaction
|
||||
|
||||
from pyramid.view import view_config
|
||||
from sqlalchemy import or_
|
||||
from sqlalchemy.orm import joinedload, Load
|
||||
from sqlalchemy.orm import joinedload
|
||||
|
||||
from barker.models import ModifierCategory, Product
|
||||
from barker.models.validation_exception import ValidationError
|
||||
from barker.views import product
|
||||
|
||||
|
||||
@view_config(
|
||||
@ -192,7 +191,7 @@ def modifier_category_info(item, dbsession):
|
||||
|
||||
menu_categories = (
|
||||
dbsession.query(MenuCategory)
|
||||
.options(joinedload(MenuCategory.products, innerjoin=True))
|
||||
.join(MenuCategory.products)
|
||||
.filter(Product.is_active == True)
|
||||
.order_by(MenuCategory.sort_order, Product.sort_order, Product.name)
|
||||
.all()
|
||||
@ -247,7 +246,7 @@ def modifier_category_info(item, dbsession):
|
||||
|
||||
def add_products(modifier_category, menu_categories, dbsession):
|
||||
for mc in menu_categories:
|
||||
for p in mc['products']:
|
||||
for p in mc["products"]:
|
||||
id_ = uuid.UUID(p["id"])
|
||||
old = [p for p in modifier_category.products if p.id == id_]
|
||||
old = None if len(old) == 0 else old[0]
|
||||
|
Loading…
Reference in New Issue
Block a user