Big Chunk of updates on way to making the sales portion working
This commit is contained in:
1 parent
87076d9c00
commit
d69ab0063a
83 files changed
+1621
-415
No files matched your search
+1
-1
@@ -14,7 +14,7 @@ call:copyQuery k-Vouchers "SELECT 'INSERT INTO vouchers(id, date, pax, user_id,
|
||||
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;"
|
||||
call:copyQuery n-Inventories "SELECT 'INSERT INTO inventories(id, kot_id, product_id, sort_order, quantity, price, is_happy_hour, service_charge, is_sc_taxable, service_tax_rate, vat_rate, service_tax_id, vat_id, discount) VALUES (''' + CAST(InventoryID AS Nvarchar(36)) + ''', ' + '''' + CAST(KotID AS Nvarchar(36)) + '''' + ', ' + '''' + CAST(ProductID AS Nvarchar(36)) + '''' + ', ' + CAST(SortOrder AS Nvarchar(36)) + ', ' + CAST(Quantity AS Nvarchar(36)) + ', ' + CAST(Price AS Nvarchar(36)) + ', ' + CASE WHEN IsHappyHour = 1 THEN 'true' ELSE 'false' END + ', ' + CAST(ServiceCharge AS Nvarchar(36)) + ', ' + CASE WHEN IsScTaxable = 1 THEN 'true' ELSE 'false' END + ', ' + CAST(ServiceTaxRate AS Nvarchar(36)) + ', ' + CAST(VatRate AS Nvarchar(36)) + ', ' + '''' + CAST(ServiceTaxID AS Nvarchar(36)) + '''' + ', ' + '''' + CAST(VatID AS Nvarchar(36)) + '''' + ', ' + CAST(Discount AS Nvarchar(36)) + ');' FROM Test.dbo.Inventories;"
|
||||
call:copyQuery o-Modifiers "SELECT 'INSERT INTO modifiers(id, name, show_in_bill, price) VALUES (''' + CAST(ModifierID AS Nvarchar(36)) + ''', ' + '''' + REPLACE(Name, '''', '''''') + '''' + ', ' + CASE WHEN ShowInBill = 1 THEN 'true' ELSE 'false' END + ', ' + CAST(Price AS Nvarchar(36)) + ');' FROM Test.dbo.Modifiers;"
|
||||
call:copyQuery o-Modifiers "SELECT 'INSERT INTO modifiers(id, name, show_in_bill, is_active, modifier_category_id, price) VALUES (''' + CAST(ModifierID AS Nvarchar(36)) + ''', ' + '''' + REPLACE(Name, '''', '''''') + '''' + ', ' + CASE WHEN ShowInBill = 1 THEN 'true' ELSE 'false' END + ', true, {ID}, ' + CAST(Price AS Nvarchar(36)) + ');' FROM Test.dbo.Modifiers;"
|
||||
call:copyQuery p-InventoryModifiers "SELECT 'INSERT INTO inventory_modifiers(id, inventory_id, modifier_id, price) VALUES (''' + CAST(InventoryModifierID AS Nvarchar(36)) + ''', ' + '''' + CAST(InventoryID AS Nvarchar(36)) + '''' + ', ' + '''' + CAST(ModifierID AS Nvarchar(36)) + '''' + ', 0);' FROM Test.dbo.InventoryModifiers;"
|
||||
call:copyQuery q-Sections "SELECT 'INSERT INTO sections(id, name) VALUES (''' + CAST(NewID() AS Nvarchar(36)) + ''', ''' + Location + ''');' FROM Test.dbo.PrintLocations GROUP BY Location;"
|
||||
call:copyQuery r-MachineLocations "SELECT 'INSERT INTO machine_locations(id, machine_name, location_id) SELECT ''' + CAST(MachineLocationID AS Nvarchar(36)) + ''', ' + '''' + REPLACE(Machine, '''', '''''') + '''' + ', id from locations where name = ' + '''' + REPLACE(Location, '''', '''''') + '''' + ';' FROM Test.dbo.MachineLocations;"
|
||||
|
||||
@@ -228,13 +228,15 @@ class ModifierCategory(Base):
|
||||
name = Column("name", Unicode(255), nullable=False, unique=True)
|
||||
minimum = Column("minimum", Integer, nullable=False)
|
||||
maximum = Column("maximum", Integer, nullable=True)
|
||||
is_active = Column("is_active", Boolean, nullable=False)
|
||||
sort_order = Column("sort_order", Numeric, nullable=False)
|
||||
|
||||
def __init__(self, name=None, minimum=None, maximum=None, sort_order=0, id=None):
|
||||
def __init__(self, name=None, minimum=None, maximum=None, is_active=True, sort_order=0, id=None):
|
||||
self.id = id
|
||||
self.name = name
|
||||
self.minimum = minimum
|
||||
self.maximum = maximum
|
||||
self.is_active = is_active
|
||||
self.sort_order = sort_order
|
||||
|
||||
|
||||
@@ -245,6 +247,7 @@ class Modifier(Base):
|
||||
name = Column("name", Unicode(255), nullable=False, unique=True)
|
||||
show_in_bill = Column("show_in_bill", Boolean, nullable=False)
|
||||
price = Column("price", Numeric, nullable=False)
|
||||
is_active = Column("is_active", Boolean, nullable=False)
|
||||
modifier_category_id = Column(
|
||||
"modifier_category_id",
|
||||
GUID(),
|
||||
@@ -260,13 +263,15 @@ class Modifier(Base):
|
||||
show_in_bill=None,
|
||||
price=None,
|
||||
modifier_category_id=None,
|
||||
is_active=True,
|
||||
id=None,
|
||||
):
|
||||
self.id = id
|
||||
self.name = name
|
||||
self.show_in_bill = show_in_bill
|
||||
self.modifier_category_id = modifier_category_id
|
||||
self.price = price
|
||||
self.modifier_category_id = modifier_category_id
|
||||
self.is_active = is_active
|
||||
|
||||
|
||||
class DbSetting(Base):
|
||||
|
||||
+393
-144
@@ -1,161 +1,410 @@
|
||||
def includeme(config):
|
||||
config.add_route('home', '/')
|
||||
config.add_route('login', '/login')
|
||||
config.add_route('v1_login', '/v1/login')
|
||||
config.add_route('logout', '/logout')
|
||||
config.add_route('v1_auth', '/v1/auth')
|
||||
config.add_route("home", "/")
|
||||
config.add_route("login", "/login")
|
||||
config.add_route("v1_login", "/v1/login")
|
||||
config.add_route("logout", "/logout")
|
||||
config.add_route("v1_auth", "/v1/auth")
|
||||
|
||||
config.add_route('active_cashiers', '/Cashiers.json')
|
||||
config.add_route('checkout', '/Checkout/{id}.json')
|
||||
# config.add_route('customer_id', '/Customer/{id}.json')
|
||||
|
||||
config.add_route('beer_consumption', '/BeerConsumption.json')
|
||||
config.add_route('bill_details', '/BillDetails.json')
|
||||
|
||||
config.add_route('customer', '/Customer.json')
|
||||
config.add_route('customer_list', '/Customers.json')
|
||||
config.add_route('customer_id', '/Customer/{id}.json')
|
||||
|
||||
config.add_route('discount_report', '/DiscountReport.json')
|
||||
|
||||
config.add_route('location_list', '/Locations.json')
|
||||
|
||||
config.add_route('machine_location', '/MachineLocation.json')
|
||||
config.add_route('machine_location_list', '/MachineLocations.json')
|
||||
config.add_route('machine_location_id', '/MachineLocation/{id}.json')
|
||||
|
||||
config.add_route('merge_kot', '/MergeKot.json')
|
||||
config.add_route('merge_table', '/MergeTable.json')
|
||||
|
||||
config.add_route('move_kot', '/MoveKot.json')
|
||||
config.add_route('move_table', '/MoveTable.json')
|
||||
|
||||
config.add_route('permission_list', '/Permissions.json')
|
||||
|
||||
config.add_route('print_location', '/PrintLocation.json')
|
||||
config.add_route('print_location_list', '/PrintLocations.json')
|
||||
config.add_route('print_location_id', '/PrintLocation/{id}.json')
|
||||
|
||||
config.add_route("products_new", "/products/new")
|
||||
config.add_route("products_id", "/products/{id}")
|
||||
config.add_route("products_list", "/products")
|
||||
config.add_route("v1_products_new", "/v1/products/new")
|
||||
config.add_route("v1_products_id", "/v1/products/{id}")
|
||||
config.add_route("v1_products_list", "/v1/products")
|
||||
|
||||
config.add_route("menu_categories_new", "/menu-categories/new")
|
||||
config.add_route("menu_categories_id", "/menu-categories/{id}")
|
||||
config.add_route("menu_categories_list", "/menu-categories")
|
||||
config.add_route("v1_menu_categories_new", "/v1/menu-categories/new")
|
||||
config.add_route("v1_menu_categories_id", "/v1/menu-categories/{id}")
|
||||
config.add_route("v1_menu_categories_list", "/v1/menu-categories")
|
||||
config.add_route("v1_menu_category_types_list", "/v1/menu-category-types")
|
||||
|
||||
config.add_route("sale_categories_new", "/sale-categories/new")
|
||||
config.add_route("sale_categories_id", "/sale-categories/{id}")
|
||||
config.add_route("sale_categories_list", "/sale-categories")
|
||||
config.add_route("v1_sale_categories_new", "/v1/sale-categories/new")
|
||||
config.add_route("v1_sale_categories_id", "/v1/sale-categories/{id}")
|
||||
config.add_route("v1_sale_categories_list", "/v1/sale-categories")
|
||||
config.add_route("v1_sale_category_types_list", "/v1/sale-category-types")
|
||||
|
||||
config.add_route("modifier_categories_new", "/modifier-categories/new")
|
||||
config.add_route("modifier_categories_id", "/modifier-categories/{id}")
|
||||
config.add_route("modifier_categories_list", "/modifier-categories")
|
||||
config.add_route("v1_modifier_categories_new", "/v1/modifier-categories/new")
|
||||
config.add_route("v1_modifier_categories_id", "/v1/modifier-categories/{id}")
|
||||
config.add_route("v1_modifier_categories_list", "/v1/modifier-categories")
|
||||
|
||||
config.add_route("modifiers_new", "/modifiers/new")
|
||||
config.add_route("modifiers_id", "/modifiers/{id}")
|
||||
config.add_route("modifiers_list", "/modifiers")
|
||||
config.add_route("v1_modifiers_new", "/v1/modifiers/new")
|
||||
config.add_route("v1_modifiers_id", "/v1/modifiers/{id}")
|
||||
config.add_route("v1_modifiers_list", "/v1/modifiers")
|
||||
|
||||
config.add_route("sections_new", "/sections/new")
|
||||
config.add_route("sections_id", "/sections/{id}")
|
||||
config.add_route("sections_list", "/sections")
|
||||
config.add_route("v1_sections_new", "/v1/sections/new")
|
||||
config.add_route("v1_sections_id", "/v1/sections/{id}")
|
||||
config.add_route("v1_sections_list", "/v1/sections")
|
||||
|
||||
config.add_route("section_printers", "/section-printers/{section_id}")
|
||||
config.add_route("v1_section_printers_noid", "/v1/section-printers")
|
||||
config.add_route("v1_section_printers", "/v1/section-printers/{section_id}")
|
||||
|
||||
config.add_route("devices_new", "/devices/new")
|
||||
config.add_route("devices_id", "/devices/{id}")
|
||||
config.add_route("devices_list", "/devices")
|
||||
config.add_route("v1_devices_new", "/v1/devices/new")
|
||||
config.add_route("v1_devices_id", "/v1/devices/{id}")
|
||||
config.add_route("v1_devices_list", "/v1/devices")
|
||||
config.add_route("devices_new", "/devices/new")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="devices_new",
|
||||
request_method="GET",
|
||||
permission="Tables",
|
||||
)
|
||||
config.add_route("devices_id", "/devices/{id}")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="devices_id",
|
||||
request_method="GET",
|
||||
permission="Tables",
|
||||
)
|
||||
config.add_route("devices_list", "/devices")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="devices_list",
|
||||
request_method="GET",
|
||||
permission="Authenticated",
|
||||
)
|
||||
|
||||
config.add_route("v1_guest_book_new", "/v1/guest-book/new")
|
||||
config.add_route("v1_guest_book_id", "/v1/guest-book/{id}")
|
||||
config.add_route("v1_guest_book_list", "/v1/guest-book")
|
||||
config.add_route("guest_book_new", "/guest-book/new")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="guest_book_new",
|
||||
request_method="GET",
|
||||
permission="Guest Book",
|
||||
)
|
||||
config.add_route("guest_book_id", "/guest-book/{id}")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="guest_book_id",
|
||||
request_method="GET",
|
||||
permission="Guest Book",
|
||||
)
|
||||
config.add_route("guest_book_list", "/guest-book/list")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="guest_book_list",
|
||||
request_method="GET",
|
||||
permission="Authenticated",
|
||||
)
|
||||
|
||||
config.add_route("v1_menu_categories_new", "/v1/menu-categories/new")
|
||||
config.add_route("v1_menu_categories_id", "/v1/menu-categories/{id}")
|
||||
config.add_route("v1_menu_categories_list", "/v1/menu-categories")
|
||||
config.add_route("menu_categories_new", "/menu-categories/new")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="menu_categories_new",
|
||||
request_method="GET",
|
||||
permission="Products",
|
||||
)
|
||||
config.add_route("menu_categories_id", "/menu-categories/{id}")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="menu_categories_id",
|
||||
request_method="GET",
|
||||
permission="Products",
|
||||
)
|
||||
config.add_route("menu_categories_list", "/menu-categories")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="menu_categories_list",
|
||||
request_method="GET",
|
||||
permission="Authenticated",
|
||||
)
|
||||
|
||||
config.add_route("v1_modifier_categories_new", "/v1/modifier-categories/new")
|
||||
config.add_route("v1_modifier_categories_id", "/v1/modifier-categories/{id}")
|
||||
config.add_route("v1_modifier_categories_list", "/v1/modifier-categories")
|
||||
config.add_route("modifier_categories_new", "/modifier-categories/new")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="modifier_categories_new",
|
||||
request_method="GET",
|
||||
permission="Products",
|
||||
)
|
||||
config.add_route("modifier_categories_id", "/modifier-categories/{id}")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="modifier_categories_id",
|
||||
request_method="GET",
|
||||
permission="Products",
|
||||
)
|
||||
config.add_route("modifier_categories_list", "/modifier-categories")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="modifier_categories_list",
|
||||
request_method="GET",
|
||||
permission="Authenticated",
|
||||
)
|
||||
|
||||
config.add_route("v1_modifiers_new", "/v1/modifiers/new")
|
||||
config.add_route("v1_modifiers_id", "/v1/modifiers/{id}")
|
||||
config.add_route("v1_modifiers_list", "/v1/modifiers")
|
||||
config.add_route("modifiers_new", "/modifiers/new")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="modifiers_new",
|
||||
request_method="GET",
|
||||
permission="Products",
|
||||
)
|
||||
config.add_route("modifiers_id", "/modifiers/{id}")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="modifiers_id",
|
||||
request_method="GET",
|
||||
permission="Products",
|
||||
)
|
||||
config.add_route("modifiers_list", "/modifiers")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="modifiers_list",
|
||||
request_method="GET",
|
||||
permission="Authenticated",
|
||||
)
|
||||
|
||||
config.add_route("v1_printers_new", "/v1/printers/new")
|
||||
config.add_route("v1_printers_id", "/v1/printers/{id}")
|
||||
config.add_route("v1_printers_list", "/v1/printers")
|
||||
config.add_route("printers_new", "/printers/new")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="printers_new",
|
||||
request_method="GET",
|
||||
permission="Printers",
|
||||
)
|
||||
config.add_route("printers_id", "/printers/{id}")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="printers_id",
|
||||
request_method="GET",
|
||||
permission="Printers",
|
||||
)
|
||||
config.add_route("printers_list", "/printers")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="printers_list",
|
||||
request_method="GET",
|
||||
permission="Authenticated",
|
||||
)
|
||||
|
||||
config.add_route("v1_products_new", "/v1/products/new")
|
||||
config.add_route("v1_products_id", "/v1/products/{id}")
|
||||
config.add_route("v1_products_list", "/v1/products")
|
||||
config.add_route("products_new", "/products/new")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="products_new",
|
||||
request_method="GET",
|
||||
permission="Products",
|
||||
)
|
||||
config.add_route("products_id", "/products/{id}")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="products_id",
|
||||
request_method="GET",
|
||||
permission="Products",
|
||||
)
|
||||
config.add_route("products_list", "/products")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="products_list",
|
||||
request_method="GET",
|
||||
permission="Authenticated",
|
||||
)
|
||||
|
||||
config.add_route("v1_roles_new", "/v1/roles/new")
|
||||
config.add_route("v1_roles_id", "/v1/roles/{id}")
|
||||
config.add_route("v1_roles_list", "/v1/roles")
|
||||
config.add_route("roles_new", "/roles/new")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="roles_new",
|
||||
request_method="GET",
|
||||
permission="Users",
|
||||
)
|
||||
config.add_route("roles_id", "/roles/{id}")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="roles_id",
|
||||
request_method="GET",
|
||||
permission="Users",
|
||||
)
|
||||
config.add_route("roles_list", "/roles")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="roles_list",
|
||||
request_method="GET",
|
||||
permission="Authenticated",
|
||||
)
|
||||
|
||||
config.add_route("v1_sale_categories_new", "/v1/sale-categories/new")
|
||||
config.add_route("v1_sale_categories_id", "/v1/sale-categories/{id}")
|
||||
config.add_route("v1_sale_categories_list", "/v1/sale-categories")
|
||||
config.add_route("sale_categories_new", "/sale-categories/new")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="sale_categories_new",
|
||||
request_method="GET",
|
||||
permission="Products",
|
||||
)
|
||||
config.add_route("sale_categories_id", "/sale-categories/{id}")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="sale_categories_id",
|
||||
request_method="GET",
|
||||
permission="Products",
|
||||
)
|
||||
config.add_route("sale_categories_list", "/sale-categories")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="sale_categories_list",
|
||||
request_method="GET",
|
||||
permission="Authenticated",
|
||||
)
|
||||
|
||||
config.add_route("v1_section_printers", "/v1/section-printers")
|
||||
config.add_route("v1_section_printers_id", "/v1/section-printers/{section_id}")
|
||||
config.add_route("section_printers_id", "/section-printers/{section_id}")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="section_printers_id",
|
||||
request_method="GET",
|
||||
permission="Tables",
|
||||
)
|
||||
config.add_route("section_printers", "/section-printers")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="section_printers",
|
||||
request_method="GET",
|
||||
permission="Tables",
|
||||
)
|
||||
|
||||
config.add_route("v1_sections_new", "/v1/sections/new")
|
||||
config.add_route("v1_sections_id", "/v1/sections/{id}")
|
||||
config.add_route("v1_sections_list", "/v1/sections")
|
||||
config.add_route("sections_new", "/sections/new")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="sections_new",
|
||||
request_method="GET",
|
||||
permission="Tables",
|
||||
)
|
||||
config.add_route("sections_id", "/sections/{id}")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="sections_id",
|
||||
request_method="GET",
|
||||
permission="Tables",
|
||||
)
|
||||
config.add_route("sections_list", "/sections")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="sections_list",
|
||||
request_method="GET",
|
||||
permission="Tables",
|
||||
)
|
||||
|
||||
config.add_route("v1_tables_new", "/v1/tables/new")
|
||||
config.add_route("v1_tables_id", "/v1/tables/{id}")
|
||||
config.add_route("v1_tables_list", "/v1/tables")
|
||||
config.add_route("tables_new", "/tables/new")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="tables_new",
|
||||
request_method="GET",
|
||||
permission="Tables",
|
||||
)
|
||||
config.add_route("tables_id", "/tables/{id}")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="tables_id",
|
||||
request_method="GET",
|
||||
permission="Tables",
|
||||
)
|
||||
config.add_route("tables_list", "/tables")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="tables_list",
|
||||
request_method="GET",
|
||||
permission="Authenticated",
|
||||
)
|
||||
|
||||
config.add_route("v1_taxes_new", "/v1/taxes/new")
|
||||
config.add_route("v1_taxes_id", "/v1/taxes/{id}")
|
||||
config.add_route("v1_taxes_list", "/v1/taxes")
|
||||
config.add_route("taxes_new", "/taxes/new")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="taxes_new",
|
||||
request_method="GET",
|
||||
permission="Taxes",
|
||||
)
|
||||
config.add_route("taxes_id", "/taxes/{id}")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="taxes_id",
|
||||
request_method="GET",
|
||||
permission="Taxes",
|
||||
)
|
||||
config.add_route("taxes_list", "/taxes")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="taxes_list",
|
||||
request_method="GET",
|
||||
permission="Authenticated",
|
||||
)
|
||||
|
||||
config.add_route("v1_users_new", "/v1/users/new")
|
||||
config.add_route("v1_users_id", "/v1/users/{id}")
|
||||
config.add_route("v1_users_list", "/v1/users")
|
||||
config.add_route("users_new", "/users/new")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="users_new",
|
||||
request_method="GET",
|
||||
permission="Users",
|
||||
)
|
||||
config.add_route("users_id", "/users/{id}")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="users_id",
|
||||
request_method="GET",
|
||||
permission="Users",
|
||||
)
|
||||
config.add_route("users_list", "/users")
|
||||
config.add_view(
|
||||
"barker.views.home",
|
||||
route_name="users_list",
|
||||
request_method="GET",
|
||||
permission="Authenticated",
|
||||
)
|
||||
|
||||
# Done till here
|
||||
|
||||
config.add_route("customer", "/Customer.json")
|
||||
config.add_route("customer_list", "/Customers.json")
|
||||
config.add_route("customer_id", "/Customer/{id}.json")
|
||||
|
||||
config.add_route("discount_report", "/DiscountReport.json")
|
||||
|
||||
config.add_route("location_list", "/Locations.json")
|
||||
|
||||
config.add_route("machine_location", "/MachineLocation.json")
|
||||
config.add_route("machine_location_list", "/MachineLocations.json")
|
||||
config.add_route("machine_location_id", "/MachineLocation/{id}.json")
|
||||
|
||||
config.add_route("merge_kot", "/MergeKot.json")
|
||||
config.add_route("merge_table", "/MergeTable.json")
|
||||
|
||||
config.add_route("move_kot", "/MoveKot.json")
|
||||
config.add_route("move_table", "/MoveTable.json")
|
||||
|
||||
config.add_route("permission_list", "/Permissions.json")
|
||||
|
||||
config.add_route("print_location", "/PrintLocation.json")
|
||||
config.add_route("print_location_list", "/PrintLocations.json")
|
||||
config.add_route("print_location_id", "/PrintLocation/{id}.json")
|
||||
|
||||
config.add_route("v1_bills_new", "/v1/bills/new")
|
||||
config.add_route("v1_bills_id", "/v1/bills/{id}")
|
||||
|
||||
config.add_route('quantity_sold', '/QuantitySold.json')
|
||||
config.add_route("quantity_sold", "/QuantitySold.json")
|
||||
|
||||
config.add_route('reprint', '/Reprint.json')
|
||||
config.add_route('reprint_report', '/ReprintReport.json')
|
||||
config.add_route("reprint", "/Reprint.json")
|
||||
config.add_route("reprint_report", "/ReprintReport.json")
|
||||
|
||||
config.add_route('setting', '/Setting.json')
|
||||
config.add_route('setting_list', '/Settings.json')
|
||||
config.add_route('setting_id', '/Setting/{id}.json')
|
||||
config.add_route("setting", "/Setting.json")
|
||||
config.add_route("setting_list", "/Settings.json")
|
||||
config.add_route("setting_id", "/Setting/{id}.json")
|
||||
|
||||
config.add_route('sa_sale', '/SaleAnalysis/Sale.json')
|
||||
config.add_route('sa_settlements', '/SaleAnalysis/Settlements.json')
|
||||
config.add_route('sa_st', '/SaleAnalysis/ServiceTax.json')
|
||||
config.add_route('sa_vat', '/SaleAnalysis/Vat.json')
|
||||
config.add_route("sa_sale", "/SaleAnalysis/Sale.json")
|
||||
config.add_route("sa_settlements", "/SaleAnalysis/Settlements.json")
|
||||
config.add_route("sa_st", "/SaleAnalysis/ServiceTax.json")
|
||||
config.add_route("sa_vat", "/SaleAnalysis/Vat.json")
|
||||
|
||||
config.add_route("taxes_new", "/taxes/new")
|
||||
config.add_route("taxes_id", "/taxes/{id}")
|
||||
config.add_route("taxes_list", "/taxes")
|
||||
config.add_route("v1_taxes_new", "/v1/taxes/new")
|
||||
config.add_route("v1_taxes_id", "/v1/taxes/{id}")
|
||||
config.add_route("v1_taxes_list", "/v1/taxes")
|
||||
config.add_route("voucher", "/Voucher.json")
|
||||
config.add_route("voucher_id", "/Voucher/{id}.json")
|
||||
config.add_route("voucher_reprint", "/ReprintVoucher/{id}.json")
|
||||
config.add_route("voucher_settle", "/Settle/{id}.json")
|
||||
config.add_route("voucher_split", "/Split/{id}.json")
|
||||
config.add_route("voucher_void", "/Void/{id}.json")
|
||||
|
||||
config.add_route('v1_users_new', '/v1/users/new')
|
||||
config.add_route('v1_users_id', '/v1/users/{id}')
|
||||
config.add_route('v1_users_list', '/v1/users')
|
||||
config.add_route('users_new', '/users/new')
|
||||
config.add_route('users_id', '/users/{id}')
|
||||
config.add_route('users_list', '/users')
|
||||
config.add_route("api_lock_info", "/api/LockInfo")
|
||||
config.add_route("api_maintenance", "/api/Maintenance")
|
||||
|
||||
config.add_route('v1_printers_new', '/v1/printers/new')
|
||||
config.add_route('v1_printers_id', '/v1/printers/{id}')
|
||||
config.add_route('v1_printers_list', '/v1/printers')
|
||||
config.add_route('printers_new', '/printers/new')
|
||||
config.add_route('printers_id', '/printers/{id}')
|
||||
config.add_route('printers_list', '/printers')
|
||||
config.add_route("active_cashiers", "/Cashiers.json")
|
||||
config.add_route("checkout", "/Checkout/{id}.json")
|
||||
# config.add_route('customer_id', '/Customer/{id}.json')
|
||||
|
||||
config.add_route('v1_roles_new', '/v1/roles/new')
|
||||
config.add_route('v1_roles_id', '/v1/roles/{id}')
|
||||
config.add_route('v1_roles_list', '/v1/roles')
|
||||
config.add_route('roles_new', '/roles/new')
|
||||
config.add_route('roles_id', '/roles/{id}')
|
||||
config.add_route('roles_list', '/roles')
|
||||
config.add_route("beer_consumption", "/BeerConsumption.json")
|
||||
config.add_route("bill_details", "/BillDetails.json")
|
||||
|
||||
config.add_route('v1_guest_book_new', '/v1/guest-book/new')
|
||||
config.add_route('v1_guest_book_list', '/v1/guest-book/list')
|
||||
config.add_route('v1_guest_book_id', '/v1/guest-book/{id}')
|
||||
config.add_route('guest_book_new', '/guest-book/new')
|
||||
config.add_route('guest_book_list', '/guest-book/list')
|
||||
config.add_route('guest_book_id', '/guest-book/{id}')
|
||||
|
||||
config.add_route("tables_new", "/tables/new")
|
||||
config.add_route("tables_id", "/tables/{id}")
|
||||
config.add_route("tables_list", "/tables")
|
||||
config.add_route("v1_tables_new", "/v1/tables/new")
|
||||
config.add_route("v1_tables_id", "/v1/tables/{id}")
|
||||
config.add_route("v1_tables_list", "/v1/tables")
|
||||
|
||||
config.add_route('voucher', '/Voucher.json')
|
||||
config.add_route('voucher_id', '/Voucher/{id}.json')
|
||||
config.add_route('voucher_reprint', '/ReprintVoucher/{id}.json')
|
||||
config.add_route('voucher_settle', '/Settle/{id}.json')
|
||||
config.add_route('voucher_split', '/Split/{id}.json')
|
||||
config.add_route('voucher_void', '/Void/{id}.json')
|
||||
|
||||
config.add_route('api_lock_info', '/api/LockInfo')
|
||||
config.add_route('api_maintenance', '/api/Maintenance')
|
||||
config.add_static_view("", "barker:static")
|
||||
@@ -19,7 +19,7 @@ from barker.models import (
|
||||
get_session_factory,
|
||||
get_tm_session,
|
||||
SettleOption,
|
||||
Role, Section)
|
||||
Role, Section, ModifierCategory)
|
||||
|
||||
|
||||
def usage(argv):
|
||||
@@ -113,6 +113,13 @@ def main(argv=sys.argv):
|
||||
|
||||
main_section = Section("Main")
|
||||
dbsession.add(main_section)
|
||||
mcs = [ModifierCategory("Bar Instructions", 0, 0, True, 0, uuid.UUID("b572f401-3c2f-48b9-8973-ada5a6e4d3a6")),
|
||||
ModifierCategory("Delivery", 0, 0, True, 0, uuid.UUID("caa72832-5034-405e-8442-68a8cc12ace9")),
|
||||
ModifierCategory("Kitchen Instructions", 0, 0, True, 0, uuid.UUID("d6a0595f-e209-42e4-bb12-b7499f9a9c4d")),
|
||||
ModifierCategory("Mixers", 0, 0, True, 0, uuid.UUID("60ca9122-adc5-463b-ad5f-33a68df8c3ae")),
|
||||
ModifierCategory("Pasta Sauce", 0, 0, True, 0, uuid.UUID("ef5b1a0b-5eb1-45ff-bd82-3209c8b888df"))]
|
||||
for item in mcs:
|
||||
dbsession.add(item)
|
||||
|
||||
for name in range(1, 20):
|
||||
ft = FoodTable(str(name), 0, main_section.id, True)
|
||||
|
||||
@@ -2,9 +2,19 @@ from decimal import Decimal
|
||||
import uuid
|
||||
import re
|
||||
|
||||
import pkg_resources
|
||||
|
||||
from barker.exceptions import ValidationFailure
|
||||
from pyramid.response import Response
|
||||
from pyramid.view import forbidden_view_config, exception_view_config
|
||||
from pyramid.response import Response, FileResponse
|
||||
from pyramid.view import forbidden_view_config, exception_view_config, view_config
|
||||
|
||||
|
||||
@view_config(route_name="home")
|
||||
@view_config(request_method="GET", route_name="login")
|
||||
def home(request):
|
||||
package, resource = "barker:static/index.html".split(":", 1)
|
||||
file = pkg_resources.resource_filename(package, resource)
|
||||
return FileResponse(file, request=request)
|
||||
|
||||
|
||||
@forbidden_view_config(renderer='json')
|
||||
|
||||
+11
-20
@@ -1,5 +1,4 @@
|
||||
import uuid
|
||||
|
||||
import transaction
|
||||
from pyramid.response import Response
|
||||
from pyramid.view import view_config
|
||||
@@ -12,7 +11,7 @@ from barker.models.validation_exception import ValidationError
|
||||
request_method="POST",
|
||||
route_name="v1_devices_new",
|
||||
renderer="json",
|
||||
permission="Products",
|
||||
permission="Tables",
|
||||
trans=True,
|
||||
)
|
||||
def save(request):
|
||||
@@ -34,7 +33,7 @@ def save(request):
|
||||
request_method="PUT",
|
||||
route_name="v1_devices_id",
|
||||
renderer="json",
|
||||
permission="Products",
|
||||
permission="Tables",
|
||||
trans=True,
|
||||
)
|
||||
def update(request):
|
||||
@@ -58,7 +57,7 @@ def update(request):
|
||||
request_method="DELETE",
|
||||
route_name="v1_devices_id",
|
||||
renderer="json",
|
||||
permission="Products",
|
||||
permission="Tables",
|
||||
trans=True,
|
||||
)
|
||||
def delete(request):
|
||||
@@ -81,7 +80,7 @@ def delete(request):
|
||||
request_method="GET",
|
||||
route_name="v1_devices_new",
|
||||
renderer="json",
|
||||
permission="Authenticated",
|
||||
permission="Tables",
|
||||
)
|
||||
def show_blank(request):
|
||||
return device_info(None, request.dbsession)
|
||||
@@ -91,7 +90,7 @@ def show_blank(request):
|
||||
request_method="GET",
|
||||
route_name="v1_devices_id",
|
||||
renderer="json",
|
||||
permission="Authenticated",
|
||||
permission="Tables",
|
||||
)
|
||||
def show_id(request):
|
||||
return device_info(uuid.UUID(request.matchdict["id"]), request.dbsession)
|
||||
@@ -104,27 +103,19 @@ def show_id(request):
|
||||
permission="Authenticated",
|
||||
)
|
||||
def show_list(request):
|
||||
list_ = (
|
||||
request.dbsession.query(Device)
|
||||
.order_by(Device.name)
|
||||
.all()
|
||||
)
|
||||
devices = []
|
||||
for item in list_:
|
||||
devices.append(device_info(item, request.dbsession))
|
||||
return devices
|
||||
return [
|
||||
device_info(item, request.dbsession)
|
||||
for item in request.dbsession.query(Device).order_by(Device.name).all()
|
||||
]
|
||||
|
||||
|
||||
def device_info(item, dbsession):
|
||||
if item is None:
|
||||
return {
|
||||
"name": "",
|
||||
"section": {}
|
||||
}
|
||||
return {"name": "", "section": {}}
|
||||
if type(item) is uuid.UUID:
|
||||
item = dbsession.query(Device).filter(Device.id == item).first()
|
||||
return {
|
||||
"id": item.id,
|
||||
"name": item.name,
|
||||
"section": {"id": item.section_id, "name": item.section.name}
|
||||
"section": {"id": item.section_id, "name": item.section.name},
|
||||
}
|
||||
+75
-48
@@ -7,25 +7,31 @@ from pyramid.view import view_config
|
||||
from barker.models import GuestBook, Customer
|
||||
|
||||
|
||||
@view_config(request_method='PUT', route_name='v1_guest_book_new', renderer='json', permission='Users', trans=True)
|
||||
@view_config(
|
||||
request_method="PUT",
|
||||
route_name="v1_guest_book_new",
|
||||
renderer="json",
|
||||
permission="Guest Book",
|
||||
trans=True,
|
||||
)
|
||||
def save(request):
|
||||
json = request.json_body
|
||||
company = json['company'].strip() if json['company'] is not None else ''
|
||||
name = json['name'].strip()
|
||||
phone = json['phone']
|
||||
address = json['address'].strip()
|
||||
company = json["company"].strip() if json["company"] is not None else ""
|
||||
name = json["name"].strip()
|
||||
phone = json["phone"]
|
||||
address = json["address"].strip()
|
||||
customer = request.dbsession.query(Customer).filter(Customer.phone == phone).first()
|
||||
if customer is None:
|
||||
customer = Customer(company, name, phone, address)
|
||||
request.dbsession.add(customer)
|
||||
else:
|
||||
if company != '':
|
||||
if company != "":
|
||||
customer.company = company
|
||||
if name != '':
|
||||
if name != "":
|
||||
customer.name = name
|
||||
if address != '':
|
||||
if address != "":
|
||||
customer.address = address
|
||||
item = GuestBook(pax=json['pax'])
|
||||
item = GuestBook(pax=json["pax"])
|
||||
item.customer = customer
|
||||
request.dbsession.add(item)
|
||||
transaction.commit()
|
||||
@@ -33,62 +39,83 @@ def save(request):
|
||||
return guest_book_info(item)
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='v1_guest_book_id', renderer='json', permission='Authenticated')
|
||||
@view_config(
|
||||
request_method="GET",
|
||||
route_name="v1_guest_book_id",
|
||||
renderer="json",
|
||||
permission="Guest Book",
|
||||
)
|
||||
def show_id(request):
|
||||
id_ = request.matchdict['id']
|
||||
item = request.dbsession.query(GuestBook).filter(GuestBook.id == uuid.UUID(id_)).one()
|
||||
id_ = request.matchdict["id"]
|
||||
item = (
|
||||
request.dbsession.query(GuestBook).filter(GuestBook.id == uuid.UUID(id_)).one()
|
||||
)
|
||||
return guest_book_info(item)
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='v1_guest_book_new', renderer='json', permission='Authenticated')
|
||||
@view_config(
|
||||
request_method="GET",
|
||||
route_name="v1_guest_book_new",
|
||||
renderer="json",
|
||||
permission="Guest Book",
|
||||
)
|
||||
def show_blank(request):
|
||||
return guest_book_info(None)
|
||||
|
||||
|
||||
@view_config(request_method='GET', route_name='v1_guest_book_list', renderer='json', permission='Authenticated')
|
||||
@view_config(
|
||||
request_method="GET",
|
||||
route_name="v1_guest_book_list",
|
||||
renderer="json",
|
||||
permission="Authenticated",
|
||||
)
|
||||
def show_list(request):
|
||||
date_ = request.GET.get('q', None)
|
||||
if date_ is None or date_ == '':
|
||||
date_ = date.today().strftime('%d-%b-%Y')
|
||||
list_ = request.dbsession.query(
|
||||
GuestBook
|
||||
).filter(
|
||||
GuestBook.date >= datetime.strptime(date_, '%d-%b-%Y') - timedelta(minutes=30) # hack for timezone and 5 am
|
||||
).filter(
|
||||
GuestBook.date < datetime.strptime(date_, '%d-%b-%Y') - timedelta(minutes=30) + timedelta(days=1)
|
||||
).order_by(
|
||||
GuestBook.date
|
||||
).all()
|
||||
date_ = request.GET.get("q", None)
|
||||
if date_ is None or date_ == "":
|
||||
date_ = date.today().strftime("%d-%b-%Y")
|
||||
list_ = (
|
||||
request.dbsession.query(GuestBook)
|
||||
.filter(
|
||||
GuestBook.date
|
||||
>= datetime.strptime(date_, "%d-%b-%Y")
|
||||
- timedelta(minutes=30) # hack for timezone and 5 am
|
||||
)
|
||||
.filter(
|
||||
GuestBook.date
|
||||
< datetime.strptime(date_, "%d-%b-%Y")
|
||||
- timedelta(minutes=30)
|
||||
+ timedelta(days=1)
|
||||
)
|
||||
.order_by(GuestBook.date)
|
||||
.all()
|
||||
)
|
||||
|
||||
guest_book = []
|
||||
for i, item in enumerate(list_):
|
||||
guest_book.insert(0, {
|
||||
'id': item.id,
|
||||
'serial': i + 1,
|
||||
'company': item.customer.company,
|
||||
'name': item.customer.name,
|
||||
'phone': item.customer.phone,
|
||||
'pax': item.pax,
|
||||
'status': '' if item.status is None else item.status.status
|
||||
})
|
||||
guest_book.insert(
|
||||
0,
|
||||
{
|
||||
"id": item.id,
|
||||
"serial": i + 1,
|
||||
"company": item.customer.company,
|
||||
"name": item.customer.name,
|
||||
"phone": item.customer.phone,
|
||||
"pax": item.pax,
|
||||
"status": "" if item.status is None else item.status.status,
|
||||
},
|
||||
)
|
||||
return {"date": date_, "list": guest_book}
|
||||
|
||||
|
||||
def guest_book_info(item):
|
||||
if item is not None:
|
||||
return {
|
||||
'id': item.id,
|
||||
'company': item.customer.company,
|
||||
'name': item.customer.name,
|
||||
'phone': item.customer.phone,
|
||||
'pax': item.pax,
|
||||
'address': item.customer.address
|
||||
"id": item.id,
|
||||
"company": item.customer.company,
|
||||
"name": item.customer.name,
|
||||
"phone": item.customer.phone,
|
||||
"pax": item.pax,
|
||||
"address": item.customer.address,
|
||||
}
|
||||
else:
|
||||
return {
|
||||
'company': '',
|
||||
'name': '',
|
||||
'phone': '',
|
||||
'pax': 0,
|
||||
'address': ''
|
||||
}
|
||||
return {"company": "", "name": "", "phone": "", "pax": 0, "address": ""}
|
||||
@@ -14,7 +14,7 @@ from barker.models.validation_exception import ValidationError
|
||||
request_method="POST",
|
||||
route_name="v1_menu_categories_new",
|
||||
renderer="json",
|
||||
permission="Products",
|
||||
permission="Menu Categories",
|
||||
trans=True,
|
||||
)
|
||||
def save(request):
|
||||
@@ -39,7 +39,7 @@ def save(request):
|
||||
request_method="PUT",
|
||||
route_name="v1_menu_categories_id",
|
||||
renderer="json",
|
||||
permission="Products",
|
||||
permission="Menu Categories",
|
||||
trans=True,
|
||||
)
|
||||
def update(request):
|
||||
@@ -69,7 +69,7 @@ def update(request):
|
||||
request_method="DELETE",
|
||||
route_name="v1_menu_categories_id",
|
||||
renderer="json",
|
||||
permission="Products",
|
||||
permission="Menu Categories",
|
||||
trans=True,
|
||||
)
|
||||
def delete(request):
|
||||
@@ -97,7 +97,7 @@ def delete(request):
|
||||
request_method="GET",
|
||||
route_name="v1_menu_categories_new",
|
||||
renderer="json",
|
||||
permission="Authenticated",
|
||||
permission="Menu Categories",
|
||||
)
|
||||
def show_blank(request):
|
||||
return menu_category_info(None, request.dbsession)
|
||||
@@ -107,7 +107,7 @@ def show_blank(request):
|
||||
request_method="GET",
|
||||
route_name="v1_menu_categories_id",
|
||||
renderer="json",
|
||||
permission="Authenticated",
|
||||
permission="Menu Categories",
|
||||
)
|
||||
def show_id(request):
|
||||
return menu_category_info(uuid.UUID(request.matchdict["id"]), request.dbsession)
|
||||
@@ -157,25 +157,24 @@ def sale_list(request):
|
||||
.order_by(Product.name)
|
||||
.all()
|
||||
)
|
||||
if len(products) > 0:
|
||||
pg = menu_category_info(item)
|
||||
pg["products"] = []
|
||||
for p in products:
|
||||
pg["products"].append(
|
||||
{
|
||||
"id": p.id,
|
||||
"name": p.name,
|
||||
"units": p.units,
|
||||
"tat": {"id": p.vat.id, "name": p.vat.name, "rate": p.vat.rate},
|
||||
"price": p.price,
|
||||
"hasHappyHour": p.has_happy_hour,
|
||||
"isActive": p.is_active,
|
||||
"isNotAvailable": p.is_not_available,
|
||||
"sortOrder": p.sort_order,
|
||||
"quantity": p.quantity,
|
||||
}
|
||||
)
|
||||
menu_categories.append(pg)
|
||||
if len(products) == 0:
|
||||
continue
|
||||
pg = menu_category_info(item, request.dbsession)
|
||||
pg["products"] = [
|
||||
{
|
||||
"id": p.id,
|
||||
"name": p.name,
|
||||
"units": p.units,
|
||||
"tat": {"id": p.vat.id, "name": p.vat.name, "rate": p.vat.rate},
|
||||
"price": p.price,
|
||||
"hasHappyHour": p.has_happy_hour,
|
||||
"isActive": p.is_active,
|
||||
"isNotAvailable": p.is_not_available,
|
||||
"sortOrder": p.sort_order,
|
||||
"quantity": p.quantity,
|
||||
} for p in products
|
||||
]
|
||||
menu_categories.append(pg)
|
||||
return menu_categories
|
||||
|
||||
|
||||
@@ -183,7 +182,7 @@ def sale_list(request):
|
||||
request_method="POST",
|
||||
route_name="v1_menu_categories_list",
|
||||
renderer="json",
|
||||
permission="Products",
|
||||
permission="Menu Categories",
|
||||
trans=True,
|
||||
)
|
||||
def sort_order(request):
|
||||
|
||||
@@ -33,7 +33,9 @@ def save(request):
|
||||
if modifier_category is None:
|
||||
raise ValidationError("please choose a modifier category")
|
||||
modifier_category_id = uuid.UUID(modifier_category["id"])
|
||||
item = Modifier(name, show_in_bill, price, modifier_category_id)
|
||||
is_active = json.get("isActive", True)
|
||||
|
||||
item = Modifier(name, show_in_bill, price, modifier_category_id, is_active)
|
||||
request.dbsession.add(item)
|
||||
transaction.commit()
|
||||
return modifier_info(item.id, request.dbsession)
|
||||
@@ -64,6 +66,7 @@ def update(request):
|
||||
except (ValueError, InvalidOperation):
|
||||
raise ValidationError("Price must be a decimal >= 0")
|
||||
item.modifier_category_id = uuid.UUID(json["modifierCategory"]["id"])
|
||||
item.is_active = json["isActive"]
|
||||
transaction.commit()
|
||||
return modifier_info(item.id, request.dbsession)
|
||||
|
||||
@@ -122,7 +125,7 @@ def show_list(request):
|
||||
|
||||
def modifier_info(item, dbsession):
|
||||
if item is None:
|
||||
return {"name": "", "showInBill": False, "price": 0, "modifierCategory": {}}
|
||||
return {"name": "", "showInBill": False, "price": 0, "isActive": True, "modifierCategory": {}}
|
||||
if type(item) is uuid.UUID:
|
||||
item = dbsession.query(Modifier).filter(Modifier.id == item).first()
|
||||
return {
|
||||
@@ -130,6 +133,7 @@ def modifier_info(item, dbsession):
|
||||
"name": item.name,
|
||||
"showInBill": item.show_in_bill,
|
||||
"price": item.price,
|
||||
"isActive": item.is_active,
|
||||
"modifierCategory": {
|
||||
"id": item.modifier_category.id,
|
||||
"name": item.modifier_category.name,
|
||||
|
||||
@@ -3,7 +3,6 @@ import uuid
|
||||
import transaction
|
||||
|
||||
from pyramid.view import view_config
|
||||
from sqlalchemy import or_
|
||||
|
||||
from barker.models import ModifierCategory, Product
|
||||
from barker.models.validation_exception import ValidationError
|
||||
@@ -39,7 +38,8 @@ def save(request):
|
||||
maximum = None
|
||||
except ValueError:
|
||||
raise ValidationError("Maximum must be an integer and cannot be less than zero")
|
||||
item = ModifierCategory(name, minimum, maximum)
|
||||
is_active = json.get("isActive", True)
|
||||
item = ModifierCategory(name, minimum, maximum, is_active)
|
||||
request.dbsession.add(item)
|
||||
add_products(item, json["menuCategories"], request.dbsession)
|
||||
transaction.commit()
|
||||
@@ -81,6 +81,7 @@ def update(request):
|
||||
item.maximum = None
|
||||
except ValueError:
|
||||
raise ValidationError("Maximum must be an integer and cannot be less than zero")
|
||||
item.is_active = json["isActive"]
|
||||
add_products(item, json["menuCategories"], request.dbsession)
|
||||
transaction.commit()
|
||||
return modifier_category_info(item.id, request.dbsession)
|
||||
@@ -146,6 +147,7 @@ def show_list(request):
|
||||
"name": item.name,
|
||||
"minimum": item.minimum,
|
||||
"maximum": item.maximum,
|
||||
"isActive": item.is_active,
|
||||
"products": [p.name for p in item.products],
|
||||
}
|
||||
)
|
||||
@@ -164,8 +166,22 @@ def show_for_pg(request):
|
||||
product = request.dbsession.query(Product).filter(Product.id == product_id).first()
|
||||
|
||||
return [
|
||||
modifier_category_info(item, request.dbsession)
|
||||
for item in product.modifier_categories
|
||||
{
|
||||
"id": item.id,
|
||||
"name": item.name,
|
||||
"minimum": item.minimum,
|
||||
"maximum": item.maximum,
|
||||
"isActive": item.is_active,
|
||||
"modifiers": [
|
||||
{
|
||||
"id": m.id,
|
||||
"name": m.name,
|
||||
"prince": m.price
|
||||
}
|
||||
for m in item.modifiers if m.is_active == True
|
||||
],
|
||||
}
|
||||
for item in product.modifier_categories if item.is_active == True
|
||||
]
|
||||
|
||||
|
||||
@@ -184,6 +200,7 @@ def modifier_category_info(item, dbsession):
|
||||
"name": "",
|
||||
"minimum": 0,
|
||||
"maximum": 0,
|
||||
"isActive": True,
|
||||
"menuCategories": [
|
||||
{
|
||||
"id": mc.id,
|
||||
@@ -208,6 +225,7 @@ def modifier_category_info(item, dbsession):
|
||||
"name": item.name,
|
||||
"minimum": item.minimum,
|
||||
"maximum": item.maximum,
|
||||
"isActive": item.is_active,
|
||||
"menuCategories": [
|
||||
{
|
||||
"id": mc.id,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import uuid
|
||||
from decimal import Decimal, InvalidOperation
|
||||
from functools import reduce
|
||||
|
||||
import transaction
|
||||
from pyramid.response import Response
|
||||
@@ -175,6 +176,33 @@ def show_list(request):
|
||||
return products
|
||||
|
||||
|
||||
@view_config(
|
||||
request_method="GET",
|
||||
route_name="v1_products_list",
|
||||
renderer="json",
|
||||
request_param=("mc", "a"),
|
||||
permission="Authenticated",
|
||||
)
|
||||
def show_list_sale(request):
|
||||
mc_id = uuid.UUID(request.GET["mc"])
|
||||
list_ = (
|
||||
request.dbsession.query(Product)
|
||||
.filter(Product.is_active == True, Product.menu_category_id == mc_id)
|
||||
.order_by(Product.sort_order, Product.name)
|
||||
.all()
|
||||
)
|
||||
products = []
|
||||
for item in list_:
|
||||
if item.has_happy_hour:
|
||||
i = product_info(item, request.dbsession)
|
||||
i["hasHappyHour"] = False
|
||||
i["name"] = "H + H " + i["name"]
|
||||
i["price"] = 0
|
||||
products.append(i)
|
||||
products.append(product_info(item, request.dbsession))
|
||||
return products
|
||||
|
||||
|
||||
@view_config(
|
||||
request_method="POST",
|
||||
route_name="v1_products_list",
|
||||
|
||||
@@ -94,10 +94,10 @@ def show_id(request):
|
||||
permission="Authenticated",
|
||||
)
|
||||
def show_list(request):
|
||||
return [{
|
||||
"id": item.id,
|
||||
"name": item.name
|
||||
} for item in request.dbsession.query(Section).order_by(Section.name).all()]
|
||||
return [
|
||||
section_info(item, request.dbsession)
|
||||
for item in request.dbsession.query(Section).order_by(Section.name).all()
|
||||
]
|
||||
|
||||
|
||||
def section_info(item, dbsession):
|
||||
@@ -105,7 +105,4 @@ def section_info(item, dbsession):
|
||||
return {"name": ""}
|
||||
if type(item) is uuid.UUID:
|
||||
item = dbsession.query(Section).filter(Section.id == item).first()
|
||||
return {
|
||||
"id": item.id,
|
||||
"name": item.name
|
||||
}
|
||||
return {"id": item.id, "name": item.name}
|
||||
@@ -12,7 +12,7 @@ from barker.models.validation_exception import ValidationError
|
||||
|
||||
@view_config(
|
||||
request_method="POST",
|
||||
route_name="v1_section_printers",
|
||||
route_name="v1_section_printers_id",
|
||||
renderer="json",
|
||||
permission="Products",
|
||||
trans=True,
|
||||
@@ -77,7 +77,7 @@ def save(request):
|
||||
|
||||
@view_config(
|
||||
request_method="DELETE",
|
||||
route_name="v1_section_printers",
|
||||
route_name="v1_section_printers_id",
|
||||
renderer="json",
|
||||
permission="Products",
|
||||
trans=True,
|
||||
@@ -98,7 +98,7 @@ def delete(request):
|
||||
)
|
||||
@view_config(
|
||||
request_method="GET",
|
||||
route_name="v1_section_printers_noid",
|
||||
route_name="v1_section_printers_id",
|
||||
renderer="json",
|
||||
permission="Authenticated",
|
||||
)
|
||||
@@ -111,7 +111,7 @@ def show_id(request):
|
||||
|
||||
@view_config(
|
||||
request_method="GET",
|
||||
route_name="v1_section_printers",
|
||||
route_name="v1_section_printers_id",
|
||||
renderer="json",
|
||||
request_param="m",
|
||||
permission="Authenticated",
|
||||
|
||||
@@ -6,8 +6,8 @@ import {HomeComponent} from "./home/home.component";
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: 'bills',
|
||||
loadChildren: () => import('./bills/bills.module').then(mod => mod.BillsModule)
|
||||
path: 'devices',
|
||||
loadChildren: () => import('./devices/devices.module').then(mod => mod.DevicesModule)
|
||||
},
|
||||
{
|
||||
path: 'guest-book',
|
||||
@@ -38,8 +38,8 @@ const routes: Routes = [
|
||||
loadChildren: () => import('./roles/roles.module').then(mod => mod.RolesModule)
|
||||
},
|
||||
{
|
||||
path: 'running-tables',
|
||||
loadChildren: () => import('./running-tables/running-tables.module').then(mod => mod.RunningTablesModule)
|
||||
path: 'sales',
|
||||
loadChildren: () => import('./sales/sales.module').then(mod => mod.SalesModule)
|
||||
},
|
||||
{
|
||||
path: 'sale-categories',
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { AuthGuard } from "../auth/auth-guard.service";
|
||||
import { BillsComponent } from "./bills.component";
|
||||
import { BillResolver } from "./bill-resolver.service";
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: 'new',
|
||||
component: BillsComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Guest Book'
|
||||
},
|
||||
resolve: {
|
||||
list: BillResolver
|
||||
}
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
component: BillsComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Guest Book'
|
||||
},
|
||||
resolve: {
|
||||
item: BillResolver
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
declarations: [],
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
providers: [
|
||||
BillResolver
|
||||
]
|
||||
})
|
||||
export class BillsRoutingModule { }
|
||||
@@ -1,22 +0,0 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
import { BillsRoutingModule } from './bills-routing.module';
|
||||
import { BillsComponent } from './bills.component';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
|
||||
@NgModule({
|
||||
declarations: [BillsComponent],
|
||||
imports: [
|
||||
CommonModule,
|
||||
FlexLayoutModule,
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
MatTableModule,
|
||||
BillsRoutingModule
|
||||
]
|
||||
})
|
||||
export class BillsModule { }
|
||||
@@ -0,0 +1,7 @@
|
||||
import {Section} from "./section";
|
||||
|
||||
export class Device {
|
||||
id: string;
|
||||
name: string;
|
||||
section: Section;
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
import {MenuCategory} from "./menu-category";
|
||||
import {Modifier} from "./modifier";
|
||||
|
||||
export class ModifierCategory {
|
||||
id: string;
|
||||
name: string;
|
||||
minimum: number;
|
||||
maximum: number;
|
||||
menuCategories: MenuCategory[];
|
||||
isActive: boolean;
|
||||
menuCategories?: MenuCategory[];
|
||||
modifiers?: Modifier[];
|
||||
}
|
||||
@@ -6,4 +6,5 @@ export class Modifier {
|
||||
showInBill: boolean;
|
||||
price: number;
|
||||
modifierCategory: ModifierCategory;
|
||||
isActive: boolean;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
.right-align {
|
||||
text-align: right;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<div fxLayout="row" fxFlex="50%" fxLayoutAlign="space-around center" class="example-card">
|
||||
<mat-card fxFlex>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Device</mat-card-title>
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<form [formGroup]="form" fxLayout="column">
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Name</mat-label>
|
||||
<input matInput #nameElement placeholder="Name" formControlName="name" (keyup.enter)="save()">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<mat-form-field fxFlex>
|
||||
<mat-label>Section</mat-label>
|
||||
<mat-select placeholder="Section" formControlName="section">
|
||||
<mat-option *ngFor="let s of sections" [value]="s.id">
|
||||
{{ s.name }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
</form>
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
<button mat-raised-button color="primary" (click)="save()">Save</button>
|
||||
<button mat-raised-button color="warn" (click)="confirmDelete()" *ngIf="!!item.id">Delete</button>
|
||||
</mat-card-actions>
|
||||
</mat-card>
|
||||
</div>
|
||||
@@ -0,0 +1,25 @@
|
||||
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {DeviceDetailComponent} from './device-detail.component';
|
||||
|
||||
describe('DeviceDetailComponent', () => {
|
||||
let component: DeviceDetailComponent;
|
||||
let fixture: ComponentFixture<DeviceDetailComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [DeviceDetailComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(DeviceDetailComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,108 @@
|
||||
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild} from '@angular/core';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MatDialog} from "@angular/material/dialog";
|
||||
|
||||
import { DeviceService } from '../device.service';
|
||||
import { Device } from '../../core/device';
|
||||
import { ToasterService } from '../../core/toaster.service';
|
||||
import { ConfirmDialogComponent } from "../../shared/confirm-dialog/confirm-dialog.component";
|
||||
import { Section } from "../../core/section";
|
||||
|
||||
@Component({
|
||||
selector: 'app-device-detail',
|
||||
templateUrl: './device-detail.component.html',
|
||||
styleUrls: ['./device-detail.component.css']
|
||||
})
|
||||
export class DeviceDetailComponent implements OnInit, AfterViewInit {
|
||||
@ViewChild('nameElement', { static: true }) nameElement: ElementRef;
|
||||
form: FormGroup;
|
||||
sections: Section[];
|
||||
item: Device;
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private fb: FormBuilder,
|
||||
private toaster: ToasterService,
|
||||
private ser: DeviceService
|
||||
) {
|
||||
this.createForm();
|
||||
}
|
||||
|
||||
createForm() {
|
||||
this.form = this.fb.group({
|
||||
name: '',
|
||||
section: ''
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { item: Device, sections: Section[] }) => {
|
||||
this.showItem(data.item);
|
||||
this.sections = data.sections;
|
||||
});
|
||||
}
|
||||
|
||||
showItem(item: Device) {
|
||||
this.item = item;
|
||||
this.form.setValue({
|
||||
name: this.item.name || '',
|
||||
section: this.item.section.id ? this.item.section.id : ''
|
||||
});
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
setTimeout(() => {
|
||||
this.nameElement.nativeElement.focus();
|
||||
}, 0);
|
||||
}
|
||||
|
||||
save() {
|
||||
this.ser.saveOrUpdate(this.getItem())
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/devices');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
delete() {
|
||||
this.ser.delete(this.item.id)
|
||||
.subscribe(
|
||||
(result) => {
|
||||
this.toaster.show('Success', '');
|
||||
this.router.navigateByUrl('/devices');
|
||||
},
|
||||
(error) => {
|
||||
this.toaster.show('Danger', error.error);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
confirmDelete(): void {
|
||||
const dialogRef = this.dialog.open(ConfirmDialogComponent, {
|
||||
width: '250px',
|
||||
data: {title: 'Delete Device?', content: 'Are you sure? This cannot be undone.'}
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((result: boolean) => {
|
||||
if (result) {
|
||||
this.delete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getItem(): Device {
|
||||
const formModel = this.form.value;
|
||||
this.item.name = formModel.name;
|
||||
this.item.section.id = formModel.section;
|
||||
return this.item;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {DeviceListResolver} from './device-list-resolver.service';
|
||||
|
||||
describe('DeviceListResolverService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [DeviceListResolver]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([DeviceListResolver], (service: DeviceListResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
|
||||
import {Device} from '../core/device';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {DeviceService} from './device.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class DeviceListResolver implements Resolve<Device[]> {
|
||||
|
||||
constructor(private ser: DeviceService, private router: Router) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Device[]> {
|
||||
return this.ser.list();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { DataSource} from '@angular/cdk/collections';
|
||||
import { Observable, of as observableOf} from 'rxjs';
|
||||
import { Device} from '../../core/device';
|
||||
|
||||
export class DeviceListDataSource extends DataSource<Device> {
|
||||
|
||||
constructor(public data: Device[]) {
|
||||
super();
|
||||
}
|
||||
|
||||
connect(): Observable<Device[]> {
|
||||
return observableOf(this.data);
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,28 @@
|
||||
<mat-card>
|
||||
<mat-card-title-group>
|
||||
<mat-card-title>Devices</mat-card-title>
|
||||
<a mat-button [routerLink]="['/devices', 'new']">
|
||||
<mat-icon>add_box</mat-icon>
|
||||
Add
|
||||
</a>
|
||||
</mat-card-title-group>
|
||||
<mat-card-content>
|
||||
<mat-table #table [dataSource]="dataSource" aria-label="Elements">
|
||||
|
||||
<!-- Name Column -->
|
||||
<ng-container matColumnDef="name">
|
||||
<mat-header-cell *matHeaderCellDef>Name</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row"><a [routerLink]="['/devices', row.id]">{{row.name}}</a></mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Section Column -->
|
||||
<ng-container matColumnDef="tax">
|
||||
<mat-header-cell *matHeaderCellDef>Section</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.section.name}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
|
||||
</mat-table>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
@@ -0,0 +1,23 @@
|
||||
import {ComponentFixture, fakeAsync, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {DeviceListComponent} from './device-list.component';
|
||||
|
||||
describe('DeviceListComponent', () => {
|
||||
let component: DeviceListComponent;
|
||||
let fixture: ComponentFixture<DeviceListComponent>;
|
||||
|
||||
beforeEach(fakeAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [DeviceListComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(DeviceListComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
it('should compile', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { DeviceListDataSource } from './device-list-datasource';
|
||||
import { Device } from '../../core/device';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-device-list',
|
||||
templateUrl: './device-list.component.html',
|
||||
styleUrls: ['./device-list.component.css']
|
||||
})
|
||||
export class DeviceListComponent implements OnInit {
|
||||
dataSource: DeviceListDataSource;
|
||||
list: Device[];
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name'];
|
||||
|
||||
constructor(private route: ActivatedRoute) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { list: Device[] }) => {
|
||||
this.list = data.list;
|
||||
});
|
||||
this.dataSource = new DeviceListDataSource(this.list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {DeviceResolver} from './device-resolver.service';
|
||||
|
||||
describe('DeviceResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [DeviceResolver]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([DeviceResolver], (service: DeviceResolver) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
|
||||
import {DeviceService} from './device.service';
|
||||
import {Device} from '../core/device';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class DeviceResolver implements Resolve<Device> {
|
||||
|
||||
constructor(private ser: DeviceService, private router: Router) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Device> {
|
||||
const id = route.paramMap.get('id');
|
||||
return this.ser.get(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import {inject, TestBed} from '@angular/core/testing';
|
||||
|
||||
import {DeviceService} from './device.service';
|
||||
|
||||
describe('DeviceService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [DeviceService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([DeviceService], (service: DeviceService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
@@ -0,0 +1,65 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
|
||||
import {ErrorLoggerService} from '../core/error-logger.service';
|
||||
import {catchError} from 'rxjs/operators';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {Device} from '../core/device';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
};
|
||||
const url = '/v1/devices';
|
||||
const serviceName = 'DeviceService';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class DeviceService {
|
||||
constructor(private http: HttpClient, private log: ErrorLoggerService) {
|
||||
}
|
||||
|
||||
get(id: string): Observable<Device> {
|
||||
const getUrl: string = (id === null) ? `${url}/new` : `${url}/${id}`;
|
||||
return <Observable<Device>>this.http.get<Device>(getUrl)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, `get id=${id}`))
|
||||
);
|
||||
}
|
||||
|
||||
list(): Observable<Device[]> {
|
||||
const options = {params: new HttpParams().set('l', '')};
|
||||
return <Observable<Device[]>>this.http.get<Device[]>(url, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
);
|
||||
}
|
||||
|
||||
save(device: Device): Observable<Device> {
|
||||
return <Observable<Device>>this.http.post<Device>(`${url}/new`, device, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'save'))
|
||||
);
|
||||
}
|
||||
|
||||
update(device: Device): Observable<Device> {
|
||||
return <Observable<Device>>this.http.put<Device>(`${url}/${device.id}`, device, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'update'))
|
||||
);
|
||||
}
|
||||
|
||||
saveOrUpdate(device: Device): Observable<Device> {
|
||||
if (!device.id) {
|
||||
return this.save(device);
|
||||
} else {
|
||||
return this.update(device);
|
||||
}
|
||||
}
|
||||
|
||||
delete(id: string): Observable<Device> {
|
||||
return <Observable<Device>>this.http.delete<Device>(`${url}/${id}`, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'delete'))
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import {DevicesRoutingModule} from './devices-routing.module';
|
||||
|
||||
describe('DevicesRoutingModule', () => {
|
||||
let devicesRoutingModule: DevicesRoutingModule;
|
||||
|
||||
beforeEach(() => {
|
||||
devicesRoutingModule = new DevicesRoutingModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(devicesRoutingModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,64 @@
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {RouterModule, Routes} from '@angular/router';
|
||||
import {DeviceListResolver} from './device-list-resolver.service';
|
||||
import {DeviceResolver} from './device-resolver.service';
|
||||
import {DeviceListComponent} from './device-list/device-list.component';
|
||||
import {DeviceDetailComponent} from './device-detail/device-detail.component';
|
||||
import {AuthGuard} from '../auth/auth-guard.service';
|
||||
import {SectionListResolver} from "../sections/section-list-resolver.service";
|
||||
|
||||
const devicesRoutes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: DeviceListComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Devices'
|
||||
},
|
||||
resolve: {
|
||||
list: DeviceListResolver
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'new',
|
||||
component: DeviceDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Devices'
|
||||
},
|
||||
resolve: {
|
||||
item: DeviceResolver,
|
||||
sections: SectionListResolver
|
||||
}
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
component: DeviceDetailComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Devices'
|
||||
},
|
||||
resolve: {
|
||||
item: DeviceResolver,
|
||||
sections: SectionListResolver
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule.forChild(devicesRoutes)
|
||||
|
||||
],
|
||||
exports: [
|
||||
RouterModule
|
||||
],
|
||||
providers: [
|
||||
DeviceListResolver,
|
||||
DeviceResolver
|
||||
]
|
||||
})
|
||||
export class DevicesRoutingModule {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import {DevicesModule} from './devices.module';
|
||||
|
||||
describe('DevicesModule', () => {
|
||||
let devicesModule: DevicesModule;
|
||||
|
||||
beforeEach(() => {
|
||||
devicesModule = new DevicesModule();
|
||||
});
|
||||
|
||||
it('should create an instance', () => {
|
||||
expect(devicesModule).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
import { DeviceListComponent } from './device-list/device-list.component';
|
||||
import { DeviceDetailComponent } from './device-detail/device-detail.component';
|
||||
import { DevicesRoutingModule } from './devices-routing.module';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatInputModule } from '@angular/material/input';
|
||||
import { MatOptionModule } from '@angular/material/core';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatTableModule } from '@angular/material/table';
|
||||
import { CdkTableModule } from '@angular/cdk/table';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
CdkTableModule,
|
||||
FlexLayoutModule,
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatOptionModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatSelectModule,
|
||||
MatTableModule,
|
||||
ReactiveFormsModule,
|
||||
DevicesRoutingModule
|
||||
],
|
||||
declarations: [
|
||||
DeviceListComponent,
|
||||
DeviceDetailComponent
|
||||
]
|
||||
})
|
||||
export class DevicesModule {
|
||||
}
|
||||
@@ -28,7 +28,7 @@ export class GuestBookService {
|
||||
|
||||
list(date: string): Observable<GuestBookList> {
|
||||
const options = {params: new HttpParams().set('q', (date === null) ? '' : date)};
|
||||
const listUrl: string = `${url}/list`;
|
||||
const listUrl: string = url;
|
||||
return <Observable<GuestBookList>>this.http.get<GuestBookList>(listUrl, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<h1>Welcome to bookie!</h1>
|
||||
<a mat-raised-button routerLink="/login" *ngIf="!(nameObject | async)">
|
||||
<mat-icon>account_box</mat-icon>
|
||||
Login</a>
|
||||
<a mat-raised-button routerLink="/guest-book">
|
||||
Guest Book
|
||||
</a>
|
||||
<a mat-raised-button routerLink="/running-tables">
|
||||
<a mat-raised-button routerLink="/sales">
|
||||
Sales
|
||||
</a>
|
||||
<a mat-raised-button routerLink="/tables">
|
||||
@@ -31,6 +32,9 @@
|
||||
<a mat-raised-button routerLink="/taxes">
|
||||
Taxes
|
||||
</a>
|
||||
<a mat-raised-button routerLink="/devices">
|
||||
Devices
|
||||
</a>
|
||||
<a mat-raised-button routerLink="/section-printers">
|
||||
Section Printers
|
||||
</a>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { inject, TestBed } from '@angular/core/testing';
|
||||
import { MenuCategoryResolver } from './menu-category-resolver.service';
|
||||
|
||||
describe('MenuCategoryResolver', () => {
|
||||
describe('MenuCategoriesResolver', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [MenuCategoryResolver]
|
||||
|
||||
+4
@@ -23,6 +23,10 @@
|
||||
<input matInput placeholder="Maximum" type="number" formControlName="maximum">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<mat-checkbox formControlName="isActive">Is Active?</mat-checkbox>
|
||||
</div>
|
||||
<mat-divider></mat-divider>
|
||||
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl" class="example-tree">
|
||||
<!-- This is the tree node template for leaf nodes -->
|
||||
|
||||
+5
-2
@@ -41,7 +41,8 @@ export class ModifierCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
this.form = this.fb.group({
|
||||
name: '',
|
||||
minimum: '',
|
||||
maximum: ''
|
||||
maximum: '',
|
||||
isActive: ''
|
||||
});
|
||||
}
|
||||
|
||||
@@ -58,7 +59,8 @@ export class ModifierCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
this.form.patchValue({
|
||||
name: this.item.name || '',
|
||||
minimum: '' + this.item.minimum,
|
||||
maximum: '' + this.item.maximum
|
||||
maximum: '' + this.item.maximum,
|
||||
isActive: this.item.isActive
|
||||
});
|
||||
this.products = new Map();
|
||||
this.productsOfMenuCategory = new Map();
|
||||
@@ -128,6 +130,7 @@ export class ModifierCategoryDetailComponent implements OnInit, AfterViewInit {
|
||||
this.item.name = formModel.name;
|
||||
this.item.minimum = +formModel.minimum;
|
||||
this.item.maximum = +formModel.maximum;
|
||||
this.item.isActive = formModel.isActive;
|
||||
return this.item;
|
||||
}
|
||||
|
||||
|
||||
+12
-1
@@ -27,7 +27,18 @@
|
||||
<mat-cell *matCellDef="let row">{{row.maximum}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Permissions Column -->
|
||||
<!-- Is Active Column -->
|
||||
<ng-container matColumnDef="isActive">
|
||||
<mat-header-cell *matHeaderCellDef>Is Active</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">
|
||||
<mat-icon>
|
||||
{{ row.isActive ? "visibility" : "visibility_off" }}
|
||||
</mat-icon>
|
||||
<b> {{ row.isActive ? "Active" : "Not Active" }}</b>
|
||||
</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Products Column -->
|
||||
<ng-container matColumnDef="products">
|
||||
<mat-header-cell *matHeaderCellDef>Products</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ export class ModifierCategoryListComponent implements OnInit {
|
||||
dataSource: ModifierCategoryListDatasource;
|
||||
list: ModifierCategory[];
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns = ['name', 'minimum', 'maximum', 'products'];
|
||||
displayedColumns = ['name', 'minimum', 'maximum', 'products', 'isActive'];
|
||||
|
||||
constructor(private route: ActivatedRoute) {
|
||||
}
|
||||
|
||||
@@ -34,11 +34,11 @@ export class ModifierCategoryService {
|
||||
);
|
||||
}
|
||||
|
||||
listOfNames(): Observable<string[]> {
|
||||
const options = {params: new HttpParams().set('n', '')};
|
||||
return <Observable<string[]>>this.http.get<string[]>(url, options)
|
||||
listIsActiveOfProduct(id: string): Observable<ModifierCategory[]> {
|
||||
const options = {params: new HttpParams().set('p', id).set('a', '')};
|
||||
return <Observable<ModifierCategory[]>>this.http.get<ModifierCategory[]>(url, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
catchError(this.log.handleError(serviceName, 'listIsActiveOfProduct'))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,10 @@
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||
fxLayoutGap.lt-md="0px">
|
||||
<mat-checkbox formControlName="isActive">Is Active?</mat-checkbox>
|
||||
</div>
|
||||
</form>
|
||||
</mat-card-content>
|
||||
<mat-card-actions>
|
||||
|
||||
@@ -35,7 +35,8 @@ export class ModifierDetailComponent implements OnInit, AfterViewInit {
|
||||
name: '',
|
||||
showInBill: '',
|
||||
price: '',
|
||||
modifierCategory: ''
|
||||
modifierCategory: '',
|
||||
isActive: ''
|
||||
});
|
||||
}
|
||||
|
||||
@@ -53,6 +54,7 @@ export class ModifierDetailComponent implements OnInit, AfterViewInit {
|
||||
name: this.item.name || '',
|
||||
showInBill: this.item.showInBill,
|
||||
price: this.item.price || '',
|
||||
isActive: this.item.isActive,
|
||||
modifierCategory: this.item.modifierCategory.id ? this.item.modifierCategory.id : ''
|
||||
});
|
||||
}
|
||||
@@ -107,6 +109,7 @@ export class ModifierDetailComponent implements OnInit, AfterViewInit {
|
||||
this.item.name = formModel.name;
|
||||
this.item.showInBill = formModel.showInBill;
|
||||
this.item.price = +formModel.price;
|
||||
this.item.isActive = formModel.isActive;
|
||||
this.item.modifierCategory.id = formModel.modifierCategory;
|
||||
return this.item;
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@
|
||||
<!-- Name Column -->
|
||||
<ng-container matColumnDef="name">
|
||||
<mat-header-cell *matHeaderCellDef>Name</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row"><a [routerLink]="['/modifiers', row.id]">{{row.name}} ({{row.units}})</a></mat-cell>
|
||||
<mat-cell *matCellDef="let row"><a [routerLink]="['/modifiers', row.id]">{{row.name}}</a></mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Show In Bill Column -->
|
||||
<ng-container matColumnDef="showInBill">
|
||||
<mat-header-cell *matHeaderCellDef>Show</mat-header-cell>
|
||||
<mat-header-cell *matHeaderCellDef>Show In Bill</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">
|
||||
<div layout="row">
|
||||
<div flex>
|
||||
@@ -56,6 +56,16 @@
|
||||
<mat-cell *matCellDef="let row">{{row.modifierCategory.name}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<!-- Is Active Column -->
|
||||
<ng-container matColumnDef="isActive">
|
||||
<mat-header-cell *matHeaderCellDef>Is Active</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">
|
||||
<mat-icon>
|
||||
{{ row.isActive ? "visibility" : "visibility_off" }}
|
||||
</mat-icon>
|
||||
<b> {{ row.isActive ? "Active" : "Not Active" }}</b>
|
||||
</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
|
||||
|
||||
@@ -21,7 +21,7 @@ export class ModifierListComponent implements OnInit {
|
||||
data: BehaviorSubject<Modifier[]>;
|
||||
modifierCategories: ModifierCategory[];
|
||||
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
|
||||
displayedColumns: string[] = ['name', 'showInBill', 'price', 'modifierCategory'];
|
||||
displayedColumns: string[] = ['name', 'showInBill', 'price', 'isActive', 'modifierCategory'];
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
|
||||
@@ -68,7 +68,7 @@ export class ProductDetailComponent implements OnInit, AfterViewInit {
|
||||
hasHappyHour: this.item.hasHappyHour,
|
||||
isNotAvailable: this.item.isNotAvailable,
|
||||
quantity: this.item.quantity || '',
|
||||
isActive: this.item.isActive,
|
||||
isActive: this.item.isActive
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,15 @@ export class ProductService {
|
||||
const options = {params: new HttpParams().set('l', '')};
|
||||
return <Observable<Product[]>>this.http.get<Product[]>(url, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'getList'))
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
);
|
||||
}
|
||||
|
||||
listIsActiveOfCategory(id: string): Observable<Product[]> {
|
||||
const options = {params: new HttpParams().set('mc', id).set('a', '')};
|
||||
return <Observable<Product[]>>this.http.get<Product[]>(url, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'listIsActiveOfCategory'))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { AuthGuard } from "../auth/auth-guard.service";
|
||||
import { RunningTablesComponent } from "./running-tables.component";
|
||||
import { RunningTablesResolver } from "./running-tables-resolver.service";
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
component: RunningTablesComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Guest Book'
|
||||
},
|
||||
resolve: {
|
||||
list: RunningTablesResolver
|
||||
}
|
||||
},
|
||||
{
|
||||
path: ':id',
|
||||
component: RunningTablesComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Guest Book'
|
||||
},
|
||||
resolve: {
|
||||
item: RunningTablesResolver
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
declarations: [],
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
providers: [
|
||||
RunningTablesResolver
|
||||
]
|
||||
})
|
||||
export class RunningTablesRoutingModule { }
|
||||
@@ -1,20 +0,0 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
import { RunningTablesRoutingModule } from './running-tables-routing.module';
|
||||
import { RunningTablesComponent } from './running-tables.component';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
|
||||
@NgModule({
|
||||
declarations: [RunningTablesComponent],
|
||||
imports: [
|
||||
CommonModule,
|
||||
FlexLayoutModule,
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
RunningTablesRoutingModule
|
||||
]
|
||||
})
|
||||
export class RunningTablesModule { }
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
<!-- Tax Column -->
|
||||
<ng-container matColumnDef="tax">
|
||||
- <mat-header-cell *matHeaderCellDef>Tax</mat-header-cell>
|
||||
<mat-header-cell *matHeaderCellDef>Tax</mat-header-cell>
|
||||
<mat-cell *matCellDef="let row">{{row.tax.rate | percent:'1.2-2'}} {{row.tax.name}}</mat-cell>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
|
||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {Table} from "../core/table";
|
||||
import {TableService} from "../tables/table.service";
|
||||
import {Table} from "../../core/table";
|
||||
import {TableService} from "../../tables/table.service";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
File renamed without changes.
+1
-1
@@ -8,8 +8,8 @@
|
||||
<ng-container matColumnDef="info">
|
||||
<mat-cell *matCellDef="let row" [class.kot]="row.isKot">{{row.info}}</mat-cell>
|
||||
</ng-container>
|
||||
|
||||
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
|
||||
</mat-table>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
<router-outlet></router-outlet>
|
||||
File renamed without changes.
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { Table } from "../core/table";
|
||||
import { Table } from "../../core/table";
|
||||
|
||||
@Component({
|
||||
selector: 'app-bills',
|
||||
@@ -0,0 +1,12 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { MenuCategoriesResolver } from './menu-categories-resolver.service';
|
||||
|
||||
describe('MenuCategoriesResolver', () => {
|
||||
beforeEach(() => TestBed.configureTestingModule({}));
|
||||
|
||||
it('should be created', () => {
|
||||
const service: MenuCategoriesResolver = TestBed.get(MenuCategoriesResolver);
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot } from '@angular/router';
|
||||
import { MenuCategory } from '../../core/menu-category';
|
||||
import { Observable } from 'rxjs/internal/Observable';
|
||||
import { MenuCategoryService } from "../../menu-category/menu-category.service";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class MenuCategoriesResolver implements Resolve<MenuCategory[]> {
|
||||
|
||||
constructor(private ser: MenuCategoryService, private router: Router) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<MenuCategory[]> {
|
||||
return this.ser.list();
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -0,0 +1,6 @@
|
||||
<mat-card>
|
||||
<mat-card-content fxLayout="row wrap" fxLayoutGap="grid 20px">
|
||||
<button mat-raised-button class="square-button"
|
||||
*ngFor="let item of list" [routerLink]="['/sales', 'products', item.id]">{{item.name}}</button>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { MenuCategoriesComponent } from './menu-categories.component';
|
||||
|
||||
describe('MenuCategoriesComponent', () => {
|
||||
let component: MenuCategoriesComponent;
|
||||
let fixture: ComponentFixture<MenuCategoriesComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ MenuCategoriesComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(MenuCategoriesComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { MenuCategory } from "../../core/menu-category";
|
||||
|
||||
@Component({
|
||||
selector: 'app-menu-category',
|
||||
templateUrl: './menu-categories.component.html',
|
||||
styleUrls: ['./menu-categories.component.css']
|
||||
})
|
||||
export class MenuCategoriesComponent implements OnInit {
|
||||
list: MenuCategory[];
|
||||
|
||||
constructor(private route: ActivatedRoute) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { list: MenuCategory[] }) => {
|
||||
this.list = data.list;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
.square-button {
|
||||
min-width: 150px;
|
||||
max-width: 150px;
|
||||
min-height: 150px;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<mat-tab-group>
|
||||
<mat-tab *ngFor="let item of list">
|
||||
<ng-template matTabLabel>
|
||||
<span>{{item.name}}</span>
|
||||
<mat-chip-list matBadge="0" matBadgeOverlap="false">
|
||||
<mat-chip *ngIf="!item.maximum">{{item.minimum}} - ∞</mat-chip>
|
||||
<mat-chip *ngIf="!!item.maximum">{{item.minimum}} - {{item.maximum}}</mat-chip>
|
||||
</mat-chip-list>
|
||||
</ng-template>
|
||||
<mat-button-toggle-group multiple>
|
||||
<mat-button-toggle mat-raised-button class="square-button" *ngFor="let m of item.modifiers" (click)="select(m)">{{m.name}}</mat-button-toggle>
|
||||
</mat-button-toggle-group>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-button mat-dialog-close>Done</button>
|
||||
</mat-dialog-actions>
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ModifiersComponent } from './modifiers.component';
|
||||
|
||||
describe('ModifiersComponent', () => {
|
||||
let component: ModifiersComponent;
|
||||
let fixture: ComponentFixture<ModifiersComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ModifiersComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ModifiersComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { ModifierCategory } from "../../core/modifier-category";
|
||||
import { Modifier } from "../../core/modifier";
|
||||
import { MAT_DIALOG_DATA } from "@angular/material";
|
||||
import {Observable} from "rxjs";
|
||||
|
||||
@Component({
|
||||
selector: 'app-modifiers',
|
||||
templateUrl: './modifiers.component.html',
|
||||
styleUrls: ['./modifiers.component.css']
|
||||
})
|
||||
export class ModifiersComponent {
|
||||
list: ModifierCategory[];
|
||||
|
||||
constructor(@Inject(MAT_DIALOG_DATA) public data: Observable<ModifierCategory[]>) {
|
||||
this.data.subscribe((list: ModifierCategory[]) => {
|
||||
this.list = list;
|
||||
console.log(this.list);
|
||||
});
|
||||
console.log(this.list);
|
||||
}
|
||||
|
||||
select(m: Modifier) {
|
||||
console.log(m);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ProductsResolver } from './products-resolver.service';
|
||||
|
||||
describe('ProductsResolver', () => {
|
||||
beforeEach(() => TestBed.configureTestingModule({}));
|
||||
|
||||
it('should be created', () => {
|
||||
const service: ProductsResolver = TestBed.get(ProductsResolver);
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot } from "@angular/router";
|
||||
import { Observable } from "rxjs";
|
||||
import { Product } from "../../core/product";
|
||||
import { ProductService } from "../../product/product.service";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ProductsResolver implements Resolve<Product[]> {
|
||||
|
||||
constructor(private ser: ProductService, private router: Router) {
|
||||
}
|
||||
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Product[]> {
|
||||
const id = route.paramMap.get('id');
|
||||
return this.ser.listIsActiveOfCategory(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
.square-button {
|
||||
min-width: 150px;
|
||||
max-width: 150px;
|
||||
min-height: 150px;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<mat-card>
|
||||
<mat-card-content fxLayout="row wrap" fxLayoutGap="grid 20px">
|
||||
<button mat-raised-button class="square-button"
|
||||
*ngFor="let item of list" (click)="showModifier(item)">{{item.name}}</button>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ProductsComponent } from './products.component';
|
||||
|
||||
describe('ProductsComponent', () => {
|
||||
let component: ProductsComponent;
|
||||
let fixture: ComponentFixture<ProductsComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ ProductsComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ProductsComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { MatDialog } from "@angular/material";
|
||||
import { Product } from "../../core/product";
|
||||
import {ModifiersComponent} from "../modifiers/modifiers.component";
|
||||
import {ModifierCategoryService} from "../../modifier-categories/modifier-category.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-products',
|
||||
templateUrl: './products.component.html',
|
||||
styleUrls: ['./products.component.css']
|
||||
})
|
||||
export class ProductsComponent implements OnInit {
|
||||
list: Product[];
|
||||
|
||||
constructor(private route: ActivatedRoute, private dialog: MatDialog, private modifierCategoryService: ModifierCategoryService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.data
|
||||
.subscribe((data: { list: Product[] }) => {
|
||||
this.list = data.list;
|
||||
});
|
||||
}
|
||||
|
||||
showModifier(product: Product): void {
|
||||
// [routerLink]="['/sales', 'modifiers', item.id]"
|
||||
let dialogRef = this.dialog.open(ModifiersComponent, {
|
||||
position: {
|
||||
top: '10vh'
|
||||
},
|
||||
data: this.modifierCategoryService.listIsActiveOfProduct(product.id)
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe(result => {
|
||||
console.log('The dialog was closed');
|
||||
});
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot} from '@angular/router';
|
||||
import {Observable} from 'rxjs/internal/Observable';
|
||||
import {Table} from "../core/table";
|
||||
import {TableService} from "../tables/table.service";
|
||||
import {Table} from "../../core/table";
|
||||
import {TableService} from "../../tables/table.service";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -0,0 +1,5 @@
|
||||
.square-button {
|
||||
min-width: 150px;
|
||||
max-width: 150px;
|
||||
min-height: 150px;
|
||||
}
|
||||
+2
-1
@@ -3,7 +3,8 @@
|
||||
<mat-card-title>Running Tables</mat-card-title>
|
||||
</mat-card-title-group>
|
||||
<mat-card-content fxLayout="row wrap" fxLayoutGap="grid 20px">
|
||||
<button mat-raised-button class="square-button" [routerLink]="['/sales', 'menu-categories']">Menu Categories</button>
|
||||
<button mat-raised-button class="square-button"
|
||||
*ngFor="let table of list" [routerLink]="['/bills', 'new']" [queryParams]="{table: table.id}">{{table.name}}</button>
|
||||
*ngFor="let table of list" [routerLink]="['/bills', 'new']" [queryParams]="{table: table.id}" queryParamsHandling="merge">{{table.name}}</button>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
File renamed without changes.
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { Table } from "../core/table";
|
||||
import { Table } from "../../core/table";
|
||||
|
||||
@Component({
|
||||
selector: 'app-running-tables',
|
||||
@@ -0,0 +1,88 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { Routes, RouterModule } from '@angular/router';
|
||||
import { AuthGuard } from "../auth/auth-guard.service";
|
||||
import { RunningTablesResolver } from "./running-tables/running-tables-resolver.service";
|
||||
import { RunningTablesComponent } from "./running-tables/running-tables.component";
|
||||
import { MenuCategoriesComponent } from "./menu-categories/menu-categories.component";
|
||||
import { MenuCategoriesResolver } from "./menu-categories/menu-categories-resolver.service";
|
||||
import { ProductsComponent } from "./products/products.component";
|
||||
import { ProductsResolver } from "./products/products-resolver.service";
|
||||
import { BillsComponent } from "./bills/bills.component";
|
||||
import { BillResolver } from "./bills/bill-resolver.service";
|
||||
|
||||
const routes: Routes = [
|
||||
{
|
||||
path: 'tables',
|
||||
component: RunningTablesComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Guest Book'
|
||||
},
|
||||
resolve: {
|
||||
list: RunningTablesResolver
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'tables/:id',
|
||||
component: RunningTablesComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Guest Book'
|
||||
},
|
||||
resolve: {
|
||||
item: RunningTablesResolver
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'bill',
|
||||
component: BillsComponent,
|
||||
canActivate: [AuthGuard],
|
||||
// canDeactivate: [CanDeactivateGuard],
|
||||
data: {
|
||||
permission: 'Guest Book'
|
||||
},
|
||||
resolve: {
|
||||
list: BillResolver
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'menu-categories',
|
||||
component: MenuCategoriesComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Guest Book'
|
||||
},
|
||||
resolve: {
|
||||
list: MenuCategoriesResolver
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'products/:id',
|
||||
component: ProductsComponent,
|
||||
canActivate: [AuthGuard],
|
||||
data: {
|
||||
permission: 'Guest Book'
|
||||
},
|
||||
resolve: {
|
||||
list: ProductsResolver
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{ path: '',
|
||||
redirectTo: 'tables',
|
||||
pathMatch: 'full'
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forChild(routes)],
|
||||
exports: [RouterModule],
|
||||
providers: [
|
||||
RunningTablesResolver,
|
||||
MenuCategoriesResolver,
|
||||
ProductsResolver
|
||||
]
|
||||
})
|
||||
export class SalesRoutingModule { }
|
||||
@@ -0,0 +1,36 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { MatBadgeModule } from '@angular/material/badge';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatChipsModule } from '@angular/material/chips';
|
||||
import { MatDialogModule } from '@angular/material/dialog';
|
||||
import { MatTabsModule } from '@angular/material/tabs';
|
||||
import { FlexLayoutModule } from '@angular/flex-layout';
|
||||
|
||||
import { SalesRoutingModule } from './sales-routing.module';
|
||||
import { RunningTablesComponent } from "./running-tables/running-tables.component";
|
||||
import { MenuCategoriesComponent } from './menu-categories/menu-categories.component';
|
||||
import { ProductsComponent } from './products/products.component';
|
||||
import { ModifiersComponent } from './modifiers/modifiers.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [RunningTablesComponent, MenuCategoriesComponent, ProductsComponent, ModifiersComponent],
|
||||
imports: [
|
||||
CommonModule,
|
||||
FlexLayoutModule,
|
||||
MatBadgeModule,
|
||||
MatButtonModule,
|
||||
MatButtonToggleModule,
|
||||
MatCardModule,
|
||||
MatChipsModule,
|
||||
MatDialogModule,
|
||||
MatTabsModule,
|
||||
SalesRoutingModule
|
||||
],
|
||||
entryComponents: [
|
||||
ModifiersComponent
|
||||
]
|
||||
})
|
||||
export class SalesModule { }
|
||||
Reference in new issue
Block a user