Fix: import script to fit the new structure of voucher table (is_printed field removed, voucher_type != KOT is now assumed to be printed)
Fix: Take-away bill type is now removed Fix: Table overview now shows the right amounts Voucher Save and Update should now work Discounts now working (permissions are not checked)
This commit is contained in:
@ -16,7 +16,7 @@ call:copyQuery m-Sections "SELECT 'INSERT INTO sections(id, name) VALUES (''' +
|
|||||||
call:copyQuery n-Printers "SELECT 'INSERT INTO printers(id, name, address, cut_code) VALUES (''' + CAST(NewID() AS Nvarchar(36)) + ''', ''' + Printer + ''', ''' + Printer + ''', ''' + CutCode + ''');' FROM Test.dbo.PrintLocations GROUP BY Printer, CutCode;"
|
call:copyQuery n-Printers "SELECT 'INSERT INTO printers(id, name, address, cut_code) VALUES (''' + CAST(NewID() AS Nvarchar(36)) + ''', ''' + Printer + ''', ''' + Printer + ''', ''' + CutCode + ''');' FROM Test.dbo.PrintLocations GROUP BY Printer, CutCode;"
|
||||||
call:copyQuery o-SectionPrinters "SELECT 'INSERT INTO section_printers(id, menu_category_id, section_id, printer_id, copies) VALUES (''' + CAST(PrintLocationID AS Nvarchar(36)) + ''', ' + COALESCE('''' + CAST(ProductGroupID AS Nvarchar(36)) + '''','null') + ', ' + '(select id from sections where name = ''' + Location + ''')' + ', ' + '(select id from printers where name = ''' + Printer + ''')' + ', ' + CAST(Copies AS nvarchar(36)) + ');' FROM Test.dbo.PrintLocations;"
|
call:copyQuery o-SectionPrinters "SELECT 'INSERT INTO section_printers(id, menu_category_id, section_id, printer_id, copies) VALUES (''' + CAST(PrintLocationID AS Nvarchar(36)) + ''', ' + COALESCE('''' + CAST(ProductGroupID AS Nvarchar(36)) + '''','null') + ', ' + '(select id from sections where name = ''' + Location + ''')' + ', ' + '(select id from printers where name = ''' + Printer + ''')' + ', ' + CAST(Copies AS nvarchar(36)) + ');' FROM Test.dbo.PrintLocations;"
|
||||||
|
|
||||||
call:copyQuery p-Vouchers "SELECT 'INSERT INTO vouchers(id, date, pax, user_id, creation_date, last_edit_date, bill_id, food_table_id, customer_id, narration, is_void, void_reason, is_printed, voucher_type, kot_id) VALUES (''' + CAST(VoucherID AS Nvarchar(36)) + ''', ' + '''' + CONVERT(Nvarchar(36), Date, 126) + ''', ' + COALESCE(CAST(Pax AS Nvarchar(36)), 'null') + ', (SELECT id from users limit 1), ' + '''' + CONVERT(Nvarchar(36), CreationDate, 126) + ''', ' + '''' + CONVERT(Nvarchar(36), LastEditDate, 126) + ''', ' + COALESCE(CAST(BillID AS Nvarchar(36)), 'null') + ', ' + '''' + CAST(TableID AS Nvarchar(36)) + ''', ' + '''' + CAST(CustomerID AS Nvarchar(36)) + ''', ' + COALESCE('''' + REPLACE(Narration, '''', '''''') + '''', 'null') + ', ' + CASE WHEN Void = 1 THEN 'true' ELSE 'false' END + ', ' + COALESCE('''' + REPLACE(VoidReason, '''', '''''') + '''', 'null') + ', ' + CASE WHEN Printed = 1 THEN 'true' ELSE 'false' END + ', ' + CAST(VoucherType AS Nvarchar(36)) + ', ' + CAST(KotID AS Nvarchar(36)) + ');' FROM Test.dbo.Vouchers;"
|
call:copyQuery p-Vouchers "SELECT 'INSERT INTO vouchers(id, date, pax, user_id, creation_date, last_edit_date, bill_id, food_table_id, customer_id, narration, is_void, void_reason, voucher_type, kot_id) VALUES (''' + CAST(VoucherID AS Nvarchar(36)) + ''', ' + '''' + CONVERT(Nvarchar(36), Date, 126) + ''', ' + COALESCE(CAST(Pax AS Nvarchar(36)), 'null') + ', (SELECT id from users limit 1), ' + '''' + CONVERT(Nvarchar(36), CreationDate, 126) + ''', ' + '''' + CONVERT(Nvarchar(36), LastEditDate, 126) + ''', ' + COALESCE(CAST(BillID AS Nvarchar(36)), 'null') + ', ' + '''' + CAST(TableID AS Nvarchar(36)) + ''', ' + '''' + CAST(CustomerID AS Nvarchar(36)) + ''', ' + COALESCE('''' + REPLACE(Narration, '''', '''''') + '''', 'null') + ', ' + CASE WHEN Void = 1 THEN 'true' ELSE 'false' END + ', ' + COALESCE('''' + REPLACE(VoidReason, '''', '''''') + '''', 'null') + ', ' + CASE WHEN Printed = 0 THEN '0' ELSE CAST(VoucherType AS Nvarchar(36)) END + ', ' + CAST(KotID AS Nvarchar(36)) + ');' FROM Test.dbo.Vouchers;"
|
||||||
call:copyQuery q-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) + ''', (SELECT id from users limit 1));' FROM Test.dbo.Kots;"
|
call:copyQuery q-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) + ''', (SELECT id from users limit 1));' FROM Test.dbo.Kots;"
|
||||||
call:copyQuery r-Inventories "SELECT 'INSERT INTO inventories(id, kot_id, product_id, sort_order, quantity, price, is_happy_hour, tax_rate, tax_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(VatRate AS Nvarchar(36)) + ', ' + '''' + CAST(VatID AS Nvarchar(36)) + '''' + ', ' + CAST(Discount AS Nvarchar(36)) + ');' FROM Test.dbo.Inventories;"
|
call:copyQuery r-Inventories "SELECT 'INSERT INTO inventories(id, kot_id, product_id, sort_order, quantity, price, is_happy_hour, tax_rate, tax_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(VatRate AS Nvarchar(36)) + ', ' + '''' + CAST(VatID AS Nvarchar(36)) + '''' + ', ' + CAST(Discount AS Nvarchar(36)) + ');' FROM Test.dbo.Inventories;"
|
||||||
call:copyQuery s-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 s-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;"
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from enum import IntEnum
|
from enum import Enum
|
||||||
import uuid
|
import uuid
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
@ -16,12 +16,12 @@ from sqlalchemy import (
|
|||||||
func,
|
func,
|
||||||
case,
|
case,
|
||||||
)
|
)
|
||||||
from sqlalchemy.orm import relationship, backref
|
from sqlalchemy.orm import relationship, backref, synonym
|
||||||
from barker.models.guidtype import GUID
|
from barker.models.guidtype import GUID
|
||||||
from .meta import Base
|
from .meta import Base
|
||||||
|
|
||||||
|
|
||||||
class VoucherType(IntEnum):
|
class VoucherType(Enum):
|
||||||
KOT = 0
|
KOT = 0
|
||||||
REGULAR_BILL = 1
|
REGULAR_BILL = 1
|
||||||
NO_CHARGE = 2
|
NO_CHARGE = 2
|
||||||
@ -49,9 +49,15 @@ class GuestBook(Base):
|
|||||||
class Overview(Base):
|
class Overview(Base):
|
||||||
__tablename__ = "overview"
|
__tablename__ = "overview"
|
||||||
id = Column("id", GUID(), primary_key=True, default=uuid.uuid4)
|
id = Column("id", GUID(), primary_key=True, default=uuid.uuid4)
|
||||||
voucher_id = Column("voucher_id", GUID(), ForeignKey("vouchers.id"), unique=True)
|
voucher_id = Column(
|
||||||
|
"voucher_id", GUID(), ForeignKey("vouchers.id"), nullable=False, unique=True
|
||||||
|
)
|
||||||
food_table_id = Column(
|
food_table_id = Column(
|
||||||
"food_table_id", GUID(), ForeignKey("food_tables.id"), unique=True
|
"food_table_id",
|
||||||
|
GUID(),
|
||||||
|
ForeignKey("food_tables.id"),
|
||||||
|
nullable=False,
|
||||||
|
unique=True,
|
||||||
)
|
)
|
||||||
guest_book_id = Column(
|
guest_book_id = Column(
|
||||||
"guest_book_id", GUID(), ForeignKey("guest_book.id"), unique=True
|
"guest_book_id", GUID(), ForeignKey("guest_book.id"), unique=True
|
||||||
@ -62,11 +68,12 @@ class Overview(Base):
|
|||||||
food_table = relationship("FoodTable", backref=backref("status", uselist=False))
|
food_table = relationship("FoodTable", backref=backref("status", uselist=False))
|
||||||
guest = relationship("GuestBook", backref=backref("status", uselist=False))
|
guest = relationship("GuestBook", backref=backref("status", uselist=False))
|
||||||
|
|
||||||
def __init__(self, voucher_id, food_table_id, guest_book_id, status):
|
def __init__(self, voucher_id, food_table_id, guest_book_id, status, id_=None):
|
||||||
self.voucher_id = voucher_id
|
self.voucher_id = voucher_id
|
||||||
self.food_table_id = food_table_id
|
self.food_table_id = food_table_id
|
||||||
self.guest_book_id = guest_book_id
|
self.guest_book_id = guest_book_id
|
||||||
self.status = status
|
self.status = status
|
||||||
|
self.id = id_
|
||||||
|
|
||||||
|
|
||||||
class InventoryModifier(Base):
|
class InventoryModifier(Base):
|
||||||
@ -109,8 +116,7 @@ class Voucher(Base):
|
|||||||
narration = Column("narration", Unicode(1000), nullable=False)
|
narration = Column("narration", Unicode(1000), nullable=False)
|
||||||
is_void = Column("is_void", Boolean, nullable=False)
|
is_void = Column("is_void", Boolean, nullable=False)
|
||||||
void_reason = Column("void_reason", Unicode(255))
|
void_reason = Column("void_reason", Unicode(255))
|
||||||
is_printed = Column("is_printed", Boolean, nullable=False)
|
_voucher_type = Column("voucher_type", Integer, nullable=False)
|
||||||
voucher_type = Column("voucher_type", Integer, nullable=False)
|
|
||||||
user_id = Column("user_id", GUID(), ForeignKey("users.id"), nullable=False)
|
user_id = Column("user_id", GUID(), ForeignKey("users.id"), nullable=False)
|
||||||
|
|
||||||
user = relationship("User", backref="vouchers")
|
user = relationship("User", backref="vouchers")
|
||||||
@ -136,61 +142,57 @@ class Voucher(Base):
|
|||||||
cascade_backrefs=False,
|
cascade_backrefs=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
def _get_voucher_type(self):
|
||||||
def __name__(self):
|
return VoucherType(self._voucher_type)
|
||||||
return self.name
|
|
||||||
|
def _set_voucher_type(self, voucher_type):
|
||||||
|
self._voucher_type = voucher_type.value
|
||||||
|
|
||||||
|
voucher_type = property(_get_voucher_type, _set_voucher_type)
|
||||||
|
voucher_type = synonym("_voucher_type", descriptor=voucher_type)
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
date,
|
||||||
pax,
|
pax,
|
||||||
|
bill_id,
|
||||||
|
kot_id,
|
||||||
food_table_id,
|
food_table_id,
|
||||||
customer_id,
|
customer_id,
|
||||||
is_printed,
|
|
||||||
voucher_type,
|
voucher_type,
|
||||||
user_id,
|
user_id,
|
||||||
dbsession,
|
|
||||||
):
|
):
|
||||||
now = datetime.now()
|
self.date = date
|
||||||
self.date = now
|
|
||||||
self.pax = pax
|
self.pax = pax
|
||||||
if is_printed:
|
self.creation_date = date
|
||||||
type = [1, 3] if voucher_type in [1, 3] else [voucher_type]
|
self.last_edit_date = date
|
||||||
self.bill_id = (
|
self.bill_id = bill_id
|
||||||
dbsession.query(func.coalesce(func.max(Voucher.bill_id), 0) + 1)
|
self.kot_id = kot_id
|
||||||
.filter(Voucher.voucher_type.in_(type))
|
|
||||||
.scalar()
|
|
||||||
)
|
|
||||||
self.kot_id = dbsession.query(
|
|
||||||
func.coalesce(func.max(Voucher.kot_id), 0) + 1
|
|
||||||
).scalar()
|
|
||||||
|
|
||||||
self.creation_date = now
|
|
||||||
self.last_edit_date = now
|
|
||||||
self.food_table_id = food_table_id
|
self.food_table_id = food_table_id
|
||||||
self.customer_id = customer_id
|
self.customer_id = customer_id
|
||||||
self.narration = ""
|
self.narration = ""
|
||||||
self.is_void = False
|
self.is_void = False
|
||||||
self.void_reason = None
|
self.void_reason = None
|
||||||
self.is_printed = is_printed
|
|
||||||
self.voucher_type = voucher_type
|
self.voucher_type = voucher_type
|
||||||
self.user_id = user_id
|
self.user_id = user_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def full_bill_id(self):
|
def full_bill_id(self):
|
||||||
if self.bill_id is None:
|
if self.voucher_type == VoucherType.KOT:
|
||||||
return "K-" + str(self.kot_id)
|
return "K-" + str(self.kot_id)
|
||||||
if self.voucher_type == VoucherType.NO_CHARGE.value:
|
if self.voucher_type == VoucherType.NO_CHARGE:
|
||||||
return "NC-" + str(self.bill_id)
|
return "NC-" + str(self.bill_id)
|
||||||
if self.voucher_type == VoucherType.STAFF.value:
|
if self.voucher_type == VoucherType.STAFF:
|
||||||
return "ST-" + str(self.bill_id)
|
return "ST-" + str(self.bill_id)
|
||||||
if self.voucher_type in [
|
if self.voucher_type == VoucherType.REGULAR_BILL:
|
||||||
VoucherType.TAKE_AWAY.value,
|
|
||||||
VoucherType.REGULAR_BILL.value,
|
|
||||||
]:
|
|
||||||
return str(self.bill_id // 10000) + "-" + str(self.bill_id % 10000)
|
return str(self.bill_id // 10000) + "-" + str(self.bill_id % 10000)
|
||||||
else:
|
else:
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|
||||||
|
@property
|
||||||
|
def amount(self):
|
||||||
|
return sum(i.amount for k in self.kots for i in k.inventories)
|
||||||
|
|
||||||
|
|
||||||
class Kot(Base):
|
class Kot(Base):
|
||||||
__tablename__ = "kots"
|
__tablename__ = "kots"
|
||||||
@ -212,15 +214,15 @@ class Kot(Base):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
voucher_id=None,
|
voucher_id=None,
|
||||||
|
code=None,
|
||||||
food_table_id=None,
|
food_table_id=None,
|
||||||
date=None,
|
date=None,
|
||||||
user_id=None,
|
user_id=None,
|
||||||
id=None,
|
id_=None,
|
||||||
dbsession=None,
|
|
||||||
):
|
):
|
||||||
self.id = id
|
self.id = id_
|
||||||
self.voucher_id = voucher_id
|
self.voucher_id = voucher_id
|
||||||
self.code = dbsession.query(func.coalesce(func.max(Kot.code), 0) + 1).scalar()
|
self.code = code
|
||||||
self.food_table_id = food_table_id
|
self.food_table_id = food_table_id
|
||||||
self.date = date
|
self.date = date
|
||||||
self.user_id = user_id
|
self.user_id = user_id
|
||||||
@ -310,7 +312,7 @@ class Inventory(Base):
|
|||||||
|
|
||||||
@hybrid_property
|
@hybrid_property
|
||||||
def effective_price(self):
|
def effective_price(self):
|
||||||
return 0 if self.is_happy_hour == True else self.price
|
return 0 if self.is_happy_hour else self.price
|
||||||
|
|
||||||
@effective_price.expression
|
@effective_price.expression
|
||||||
def effective_price(cls):
|
def effective_price(cls):
|
||||||
@ -320,9 +322,17 @@ class Inventory(Base):
|
|||||||
def net(self):
|
def net(self):
|
||||||
return self.effective_price * self.quantity * (1 - self.discount)
|
return self.effective_price * self.quantity * (1 - self.discount)
|
||||||
|
|
||||||
|
@net.expression
|
||||||
|
def net(cls):
|
||||||
|
return cls.effective_price * cls.quantity * (1 - cls.discount)
|
||||||
|
|
||||||
@hybrid_property
|
@hybrid_property
|
||||||
def tax_amount(self):
|
def tax_amount(self):
|
||||||
return self.net_taxable * self.tax_rate
|
return self.net * self.tax_rate
|
||||||
|
|
||||||
|
@tax_amount.expression
|
||||||
|
def tax_amount(cls):
|
||||||
|
return cls.net * cls.tax_rate
|
||||||
|
|
||||||
@hybrid_property
|
@hybrid_property
|
||||||
def amount(self):
|
def amount(self):
|
||||||
|
|||||||
@ -104,7 +104,7 @@ def show_voucher(request):
|
|||||||
.first()
|
.first()
|
||||||
)
|
)
|
||||||
if voucher is not None:
|
if voucher is not None:
|
||||||
return food_table_info(voucher.food_table)
|
return food_table_info(voucher.food_table, request.dbsession)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ def show_running(request):
|
|||||||
ft["voucherId"] = item.status.voucher_id
|
ft["voucherId"] = item.status.voucher_id
|
||||||
ft["pax"] = item.status.voucher.pax
|
ft["pax"] = item.status.voucher.pax
|
||||||
ft["date"] = item.status.voucher.date.strftime("%d-%b-%Y %H:%M")
|
ft["date"] = item.status.voucher.date.strftime("%d-%b-%Y %H:%M")
|
||||||
ft["amount"] = 12345
|
ft["amount"] = item.status.voucher.amount
|
||||||
if item.status.guest is not None:
|
if item.status.guest is not None:
|
||||||
ft["guest"] = item.status.guest.customer.name
|
ft["guest"] = item.status.guest.customer.name
|
||||||
food_tables.append(ft)
|
food_tables.append(ft)
|
||||||
|
|||||||
@ -172,7 +172,8 @@ def sale_list(request):
|
|||||||
"isNotAvailable": p.is_not_available,
|
"isNotAvailable": p.is_not_available,
|
||||||
"sortOrder": p.sort_order,
|
"sortOrder": p.sort_order,
|
||||||
"quantity": p.quantity,
|
"quantity": p.quantity,
|
||||||
} for p in products
|
}
|
||||||
|
for p in products
|
||||||
]
|
]
|
||||||
menu_categories.append(pg)
|
menu_categories.append(pg)
|
||||||
return menu_categories
|
return menu_categories
|
||||||
|
|||||||
@ -109,10 +109,23 @@ def show_list(request):
|
|||||||
.order_by(SaleCategory.name)
|
.order_by(SaleCategory.name)
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
sale_categories = []
|
return [sale_category_info(item, request.dbsession) for item in list_]
|
||||||
for item in list_:
|
|
||||||
sale_categories.append(sale_category_info(item, request.dbsession))
|
|
||||||
return sale_categories
|
@view_config(
|
||||||
|
request_method="GET",
|
||||||
|
route_name="v1_sale_categories_list",
|
||||||
|
renderer="json",
|
||||||
|
request_param="d",
|
||||||
|
permission="Authenticated",
|
||||||
|
)
|
||||||
|
def show_list_for_discount(request):
|
||||||
|
list_ = (
|
||||||
|
request.dbsession.query(SaleCategory)
|
||||||
|
.order_by(SaleCategory.name)
|
||||||
|
.all()
|
||||||
|
)
|
||||||
|
return [{"id": item.id, "name": item.name, "discount": 0} for item in list_]
|
||||||
|
|
||||||
|
|
||||||
def sale_category_info(item, dbsession):
|
def sale_category_info(item, dbsession):
|
||||||
|
|||||||
@ -1,34 +1,14 @@
|
|||||||
# import re
|
|
||||||
# import uuid
|
|
||||||
# from datetime import datetime
|
|
||||||
# from decimal import Decimal
|
|
||||||
#
|
|
||||||
# import transaction
|
|
||||||
# from pyramid.httpexceptions import HTTPForbidden
|
|
||||||
# from pyramid.view import view_config
|
|
||||||
# from sqlalchemy import func
|
|
||||||
#
|
|
||||||
# from barker.exceptions import ValidationFailure
|
|
||||||
# from barker.models import (
|
|
||||||
# Inventory,
|
|
||||||
# InventoryModifier,
|
|
||||||
# Kot,
|
|
||||||
# Settlement,
|
|
||||||
# SettleOption,
|
|
||||||
# Voucher,
|
|
||||||
# Overview,
|
|
||||||
# VoucherType,
|
|
||||||
# )
|
|
||||||
from barker.models import VoucherType, Settlement, SettleOption
|
from barker.models import VoucherType, Settlement, SettleOption
|
||||||
|
from barker.models.validation_exception import ValidationError
|
||||||
|
|
||||||
|
|
||||||
def get_tax(tax, voucher_type):
|
def get_tax(tax, voucher_type):
|
||||||
if voucher_type == VoucherType.STAFF.value:
|
if voucher_type in [VoucherType.STAFF, VoucherType.NO_CHARGE]:
|
||||||
return 0
|
return 0
|
||||||
elif voucher_type == VoucherType.NO_CHARGE.value:
|
elif voucher_type in [VoucherType.KOT, VoucherType.REGULAR_BILL]:
|
||||||
return 0
|
|
||||||
else: # voucher_type in [REGULAR_BILL, TAKE_AWAY]:
|
|
||||||
return tax
|
return tax
|
||||||
|
else:
|
||||||
|
raise ValidationError("Unexpected Voucher Type")
|
||||||
|
|
||||||
|
|
||||||
def get_settlements(voucher, dbsession):
|
def get_settlements(voucher, dbsession):
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import transaction
|
|||||||
from pyramid.view import view_config
|
from pyramid.view import view_config
|
||||||
|
|
||||||
from barker.models import Voucher, Overview
|
from barker.models import Voucher, Overview
|
||||||
from barker.views.voucher.save import save_voucher
|
from barker.views.voucher.save import save
|
||||||
from barker.views.voucher.show import voucher_info
|
from barker.views.voucher.show import voucher_info
|
||||||
|
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ from barker.views.voucher.show import voucher_info
|
|||||||
def voucher_change(request):
|
def voucher_change(request):
|
||||||
json = request.json_body
|
json = request.json_body
|
||||||
id_ = uuid.UUID(request.matchdict["id"])
|
id_ = uuid.UUID(request.matchdict["id"])
|
||||||
item = save_voucher(json, request.dbsession)
|
item = save(json, request.dbsession)
|
||||||
old = request.dbsession.query(Voucher).filter(Voucher.id == id_).first()
|
old = request.dbsession.query(Voucher).filter(Voucher.id == id_).first()
|
||||||
old.void = True
|
old.void = True
|
||||||
old.void_reason = "Bill Discounted / Changed. New Bill ID is {0}".format(
|
old.void_reason = "Bill Discounted / Changed. New Bill ID is {0}".format(
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
|
import datetime
|
||||||
import uuid
|
import uuid
|
||||||
|
from decimal import Decimal
|
||||||
|
|
||||||
import transaction
|
import transaction
|
||||||
from pyramid.httpexceptions import HTTPForbidden
|
from pyramid.httpexceptions import HTTPForbidden
|
||||||
from pyramid.view import view_config
|
from pyramid.view import view_config
|
||||||
|
from sqlalchemy import func
|
||||||
|
|
||||||
from barker.models import (
|
from barker.models import (
|
||||||
Overview,
|
Overview,
|
||||||
@ -12,7 +15,10 @@ from barker.models import (
|
|||||||
InventoryModifier,
|
InventoryModifier,
|
||||||
VoucherType,
|
VoucherType,
|
||||||
Product,
|
Product,
|
||||||
|
GuestBook,
|
||||||
|
FoodTable,
|
||||||
)
|
)
|
||||||
|
from barker.models.validation_exception import ValidationError
|
||||||
from barker.views.voucher import get_tax, get_settlements
|
from barker.views.voucher import get_tax, get_settlements
|
||||||
from barker.views.voucher.show import voucher_info
|
from barker.views.voucher.show import voucher_info
|
||||||
|
|
||||||
@ -21,63 +27,102 @@ from barker.views.voucher.show import voucher_info
|
|||||||
request_method="POST", route_name="v1_vouchers_new", renderer="json", trans=True
|
request_method="POST", route_name="v1_vouchers_new", renderer="json", trans=True
|
||||||
)
|
)
|
||||||
def save(request):
|
def save(request):
|
||||||
|
json = request.json_body
|
||||||
|
now = datetime.datetime.now()
|
||||||
update_table = request.GET["u"] == "true"
|
update_table = request.GET["u"] == "true"
|
||||||
voucher_type = VoucherType[request.GET["p"]]
|
voucher_type = VoucherType[request.GET["p"]]
|
||||||
guest_book_id = request.GET.get("g", None)
|
guest_book = get_guest_book(request.GET.get("g", None), request.dbsession)
|
||||||
if guest_book_id is not None:
|
|
||||||
guest_book_id = uuid.UUID(guest_book_id)
|
|
||||||
json = request.json_body
|
|
||||||
|
|
||||||
if not json["isPrinted"] and "Print Kot" not in request.effective_principals:
|
table = (
|
||||||
raise HTTPForbidden("You are not allowed to print a kot")
|
request.dbsession.query(FoodTable)
|
||||||
|
.filter(FoodTable.id == uuid.UUID(json["table"]["id"]))
|
||||||
if json["isPrinted"] and "Print Bill" not in request.effective_principals:
|
.first()
|
||||||
raise HTTPForbidden("You are not allowed to print bill")
|
|
||||||
|
|
||||||
item = save_voucher(
|
|
||||||
json, voucher_type, uuid.UUID(request.authenticated_userid), request.dbsession
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
check_permissions(voucher_type, request.effective_principals)
|
||||||
|
|
||||||
|
bill_id = get_bill_id(voucher_type, request.dbsession)
|
||||||
|
kot_id = request.dbsession.query(
|
||||||
|
func.coalesce(func.max(Voucher.kot_id), 0) + 1
|
||||||
|
).scalar()
|
||||||
|
|
||||||
|
item = Voucher(
|
||||||
|
now,
|
||||||
|
guest_book.pax if guest_book is not None else table.seats,
|
||||||
|
bill_id,
|
||||||
|
kot_id,
|
||||||
|
json["table"]["id"],
|
||||||
|
json["customer"]["id"] if "id" in json["customer"] else None,
|
||||||
|
voucher_type,
|
||||||
|
uuid.UUID(request.authenticated_userid)
|
||||||
|
)
|
||||||
|
request.dbsession.add(item)
|
||||||
|
add_kots(json, item, voucher_type, request.dbsession)
|
||||||
|
|
||||||
|
if len(item.kots) == 0 or len(item.kots[0].inventories) == 0:
|
||||||
|
raise ValidationError("Please add some products!")
|
||||||
|
|
||||||
if update_table:
|
if update_table:
|
||||||
status = "printed" if item.is_printed else "running"
|
do_update_table(item, voucher_type, guest_book, request.dbsession)
|
||||||
item.status = Overview(
|
|
||||||
voucher_id=None,
|
|
||||||
food_table_id=item.food_table_id,
|
|
||||||
guest_book_id=guest_book_id,
|
|
||||||
status=status,
|
|
||||||
)
|
|
||||||
request.dbsession.add(item.status)
|
|
||||||
transaction.commit()
|
transaction.commit()
|
||||||
item = request.dbsession.query(Voucher).filter(Voucher.id == item.id).first()
|
item = request.dbsession.query(Voucher).filter(Voucher.id == item.id).first()
|
||||||
return voucher_info(item)
|
return voucher_info(item)
|
||||||
|
|
||||||
|
|
||||||
def save_voucher(json, voucher_type, user_id, dbsession):
|
def check_permissions(voucher_type, permissions):
|
||||||
item = Voucher(
|
if voucher_type == VoucherType.KOT and "Print Kot" not in permissions:
|
||||||
json["pax"],
|
raise HTTPForbidden("You are not allowed to print a kot")
|
||||||
json["table"]["id"],
|
|
||||||
json["customer"]["id"] if "id" in json["customer"] else None,
|
if voucher_type != VoucherType.KOT and "Print Bill" not in permissions:
|
||||||
json["isPrinted"],
|
raise HTTPForbidden("You are not allowed to print bill")
|
||||||
voucher_type,
|
|
||||||
user_id,
|
|
||||||
dbsession,
|
def get_guest_book(guest_book_id, dbsession):
|
||||||
|
if guest_book_id is None:
|
||||||
|
return guest_book_id
|
||||||
|
return (
|
||||||
|
dbsession.query(GuestBook)
|
||||||
|
.filter(GuestBook.id == uuid.UUID(guest_book_id))
|
||||||
|
.first()
|
||||||
)
|
)
|
||||||
dbsession.add(item)
|
|
||||||
|
|
||||||
|
def get_bill_id(voucher_type, dbsession):
|
||||||
|
if voucher_type == VoucherType.KOT:
|
||||||
|
return None
|
||||||
|
return (
|
||||||
|
dbsession.query(func.coalesce(func.max(Voucher.bill_id), 0) + 1)
|
||||||
|
.filter(Voucher.voucher_type == voucher_type.value)
|
||||||
|
.scalar()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def do_update_table(item, voucher_type, guest_book, dbsession):
|
||||||
|
status = "running" if voucher_type == VoucherType.KOT else "printed"
|
||||||
|
item.status = Overview(
|
||||||
|
voucher_id=None,
|
||||||
|
food_table_id=item.food_table_id,
|
||||||
|
guest_book_id=guest_book.id if guest_book is not None else None,
|
||||||
|
status=status,
|
||||||
|
)
|
||||||
|
dbsession.add(item.status)
|
||||||
|
|
||||||
|
|
||||||
|
def add_kots(json, item, voucher_type, dbsession):
|
||||||
for k in json["kots"]:
|
for k in json["kots"]:
|
||||||
kot = Kot(
|
code = dbsession.query(func.coalesce(func.max(Kot.code), 0) + 1).scalar()
|
||||||
item.id, item.food_table_id, item.date, item.user_id, dbsession=dbsession
|
kot = Kot(item.id, code, item.food_table_id, item.date, item.user_id)
|
||||||
)
|
|
||||||
item.kots.append(kot)
|
item.kots.append(kot)
|
||||||
dbsession.add(kot)
|
dbsession.add(kot)
|
||||||
for index, i in enumerate(k["inventories"]):
|
for index, i in enumerate(k["inventories"]):
|
||||||
product_id = uuid.UUID(i["product"]["id"])
|
product = dbsession.query(Product).filter(Product.id == uuid.UUID(i["product"]["id"])).first()
|
||||||
product = dbsession.query(Product).filter(Product.id == product_id).first()
|
|
||||||
tax_rate = get_tax(product.sale_category.tax.rate, voucher_type)
|
tax_rate = get_tax(product.sale_category.tax.rate, voucher_type)
|
||||||
inv = Inventory(
|
inv = Inventory(
|
||||||
kot.id,
|
kot.id,
|
||||||
product_id,
|
product.id,
|
||||||
i["quantity"],
|
round(Decimal(i["quantity"]), 2),
|
||||||
product.price,
|
product.price,
|
||||||
i["discount"],
|
round(Decimal(i["discount"]), 5),
|
||||||
i["isHappyHour"],
|
i["isHappyHour"],
|
||||||
product.sale_category.tax_id,
|
product.sale_category.tax_id,
|
||||||
tax_rate,
|
tax_rate,
|
||||||
@ -90,4 +135,3 @@ def save_voucher(json, voucher_type, user_id, dbsession):
|
|||||||
inv.modifiers.append(mod)
|
inv.modifiers.append(mod)
|
||||||
dbsession.add(mod)
|
dbsession.add(mod)
|
||||||
get_settlements(item, dbsession)
|
get_settlements(item, dbsession)
|
||||||
return item
|
|
||||||
|
|||||||
@ -97,8 +97,7 @@ def voucher_info(item):
|
|||||||
"narration": item.narration,
|
"narration": item.narration,
|
||||||
"void": item.is_void,
|
"void": item.is_void,
|
||||||
"voidReason": item.void_reason,
|
"voidReason": item.void_reason,
|
||||||
"isPrinted": item.is_printed,
|
"voucherType": item.voucher_type.value,
|
||||||
"voucherType": item.voucher_type,
|
|
||||||
"kotId": item.kot_id,
|
"kotId": item.kot_id,
|
||||||
"kots": [
|
"kots": [
|
||||||
{
|
{
|
||||||
@ -156,7 +155,6 @@ def voucher_blank(table, guest):
|
|||||||
"pax": table.seats if guest is None else guest.pax,
|
"pax": table.seats if guest is None else guest.pax,
|
||||||
"table": {"id": table.id, "name": table.name},
|
"table": {"id": table.id, "name": table.name},
|
||||||
"customer": {"id": guest.customer_id, "name": guest.customer.name} if guest is not None else {},
|
"customer": {"id": guest.customer_id, "name": guest.customer.name} if guest is not None else {},
|
||||||
"isPrinted": False,
|
|
||||||
"kots": []
|
"kots": []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import transaction
|
|||||||
from pyramid.view import view_config
|
from pyramid.view import view_config
|
||||||
|
|
||||||
from barker.models import Voucher, Overview
|
from barker.models import Voucher, Overview
|
||||||
from barker.views.voucher.save import save_voucher
|
from barker.views.voucher.save import save
|
||||||
|
|
||||||
|
|
||||||
@view_config(
|
@view_config(
|
||||||
@ -22,8 +22,8 @@ def split_voucher(request):
|
|||||||
item.void_reason = "Bill Split"
|
item.void_reason = "Bill Split"
|
||||||
# TODO: Set the Void Settlement
|
# TODO: Set the Void Settlement
|
||||||
|
|
||||||
new_one = save_voucher(json["One"], request.dbsession)
|
new_one = save(json["One"], request.dbsession)
|
||||||
new_two = save_voucher(json["Two"], request.dbsession)
|
new_two = save(json["Two"], request.dbsession)
|
||||||
|
|
||||||
status = "printed" if item.is_printed else "running"
|
status = "printed" if item.is_printed else "running"
|
||||||
new_one.status = Overview(
|
new_one.status = Overview(
|
||||||
|
|||||||
@ -8,7 +8,16 @@ from pyramid.view import view_config
|
|||||||
from sqlalchemy import func
|
from sqlalchemy import func
|
||||||
|
|
||||||
from barker.exceptions import ValidationFailure
|
from barker.exceptions import ValidationFailure
|
||||||
from barker.models import Voucher, Kot, Inventory, InventoryModifier, Overview
|
from barker.models import (
|
||||||
|
Voucher,
|
||||||
|
Kot,
|
||||||
|
Inventory,
|
||||||
|
InventoryModifier,
|
||||||
|
Overview,
|
||||||
|
VoucherType,
|
||||||
|
GuestBook,
|
||||||
|
Product,
|
||||||
|
)
|
||||||
from barker.views.voucher import get_tax, get_settlements
|
from barker.views.voucher import get_tax, get_settlements
|
||||||
from barker.views.voucher.show import voucher_info
|
from barker.views.voucher.show import voucher_info
|
||||||
|
|
||||||
@ -17,22 +26,89 @@ from barker.views.voucher.show import voucher_info
|
|||||||
request_method="PUT", route_name="v1_vouchers_id", renderer="json", trans=True
|
request_method="PUT", route_name="v1_vouchers_id", renderer="json", trans=True
|
||||||
)
|
)
|
||||||
def update(request):
|
def update(request):
|
||||||
now = datetime.now()
|
|
||||||
update_table = request.GET["u"] == "true"
|
|
||||||
json = request.json_body
|
json = request.json_body
|
||||||
id = uuid.UUID(request.matchdict["id"])
|
now = datetime.datetime.now()
|
||||||
item = request.dbsession.query(Voucher).filter(Voucher.id == id).first()
|
update_table = request.GET["u"] == "true"
|
||||||
|
voucher_type = VoucherType[request.GET["p"]]
|
||||||
|
guest_book = get_guest_book(request.GET.get("g", None), request.dbsession)
|
||||||
|
item = (
|
||||||
|
request.dbsession.query(Voucher)
|
||||||
|
.filter(Voucher.id == uuid.UUID(request.matchdict["id"]))
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
|
||||||
if not json["Printed"] and "Print Kot" not in request.effective_principals:
|
check_permissions(item, voucher_type, request.effective_principals)
|
||||||
|
|
||||||
|
if guest_book is not None:
|
||||||
|
item.pax = guest_book.pax
|
||||||
|
item.food_table_id = json["table"]["id"]
|
||||||
|
if "customer" in json and "id" in json["customer"]:
|
||||||
|
item.customer_id = json["customer"]["id"]
|
||||||
|
if item.voucher_type == VoucherType.KOT and voucher_type != VoucherType.KOT:
|
||||||
|
item.date = now
|
||||||
|
item.bill_id = get_bill_id(voucher_type, request.dbsession)
|
||||||
|
item.voucher_type = voucher_type
|
||||||
|
item.user_id = uuid.UUID(request.authenticated_userid)
|
||||||
|
item.last_edit_date = now
|
||||||
|
for k in item.kots:
|
||||||
|
for i in k.inventories:
|
||||||
|
i.tax_rate = get_tax(i.tax_rate, voucher_type)
|
||||||
|
i.discount = next(
|
||||||
|
round(Decimal(inv["discount"]), 5)
|
||||||
|
for ko in json["kots"]
|
||||||
|
for inv in ko["inventories"]
|
||||||
|
if uuid.UUID(inv["id"]) == i.id
|
||||||
|
)
|
||||||
|
for k in (k for k in json["kots"] if "id" not in k and len(k["inventories"]) > 0):
|
||||||
|
code = request.dbsession.query(
|
||||||
|
func.coalesce(func.max(Kot.code), 0) + 1
|
||||||
|
).scalar()
|
||||||
|
kot = Kot(item.id, code, item.food_table_id, item.date, item.user_id)
|
||||||
|
item.kots.append(kot)
|
||||||
|
request.dbsession.add(kot)
|
||||||
|
for index, i in enumerate(k["inventories"]):
|
||||||
|
product = (
|
||||||
|
request.dbsession.query(Product)
|
||||||
|
.filter(Product.id == uuid.UUID(i["product"]["id"]))
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
tax_rate = get_tax(product.sale_category.tax.rate, voucher_type)
|
||||||
|
inv = Inventory(
|
||||||
|
kot.id,
|
||||||
|
product.id,
|
||||||
|
round(Decimal(i["quantity"]), 2),
|
||||||
|
product.price,
|
||||||
|
round(Decimal(i["discount"]), 5),
|
||||||
|
i["isHappyHour"],
|
||||||
|
product.sale_category.tax_id,
|
||||||
|
tax_rate,
|
||||||
|
index,
|
||||||
|
)
|
||||||
|
kot.inventories.append(inv)
|
||||||
|
request.dbsession.add(inv)
|
||||||
|
for m in i["modifiers"]:
|
||||||
|
mod = InventoryModifier(None, uuid.UUID(m["id"]), 0)
|
||||||
|
inv.modifiers.append(mod)
|
||||||
|
request.dbsession.add(mod)
|
||||||
|
get_settlements(item, request.dbsession)
|
||||||
|
if update_table:
|
||||||
|
do_update_table(item, voucher_type, guest_book, request.dbsession)
|
||||||
|
transaction.commit()
|
||||||
|
item = request.dbsession.query(Voucher).filter(Voucher.id == item.id).first()
|
||||||
|
return voucher_info(item)
|
||||||
|
|
||||||
|
|
||||||
|
def check_permissions(item, voucher_type, permissions):
|
||||||
|
if voucher_type == VoucherType.KOT and "Print Kot" not in permissions:
|
||||||
raise HTTPForbidden("You are not allowed to print a kot")
|
raise HTTPForbidden("You are not allowed to print a kot")
|
||||||
|
|
||||||
if json["Printed"] and "Print Bill" not in request.effective_principals:
|
if voucher_type != VoucherType.KOT and "Print Bill" not in permissions:
|
||||||
raise HTTPForbidden("You are not allowed to print bill")
|
raise HTTPForbidden("You are not allowed to print bill")
|
||||||
|
|
||||||
if item.is_printed and "Edit Printed Bill" not in request.effective_principals:
|
if item.voucher_type != VoucherType.KOT and "Edit Printed Bill" not in permissions:
|
||||||
raise HTTPForbidden("You are not allowed to edit a printed bill")
|
raise HTTPForbidden("You are not allowed to edit a printed bill")
|
||||||
|
|
||||||
if item.is_printed and not json["Printed"]:
|
if item.voucher_type != VoucherType.KOT and voucher_type == VoucherType.KOT:
|
||||||
transaction.abort()
|
transaction.abort()
|
||||||
raise ValidationFailure("This Bill is already printed\nCannot add a Kot to it.")
|
raise ValidationFailure("This Bill is already printed\nCannot add a Kot to it.")
|
||||||
|
|
||||||
@ -42,84 +118,36 @@ def update(request):
|
|||||||
"This Bill is already void.\nReason: {0}".format(item.void_reason)
|
"This Bill is already void.\nReason: {0}".format(item.void_reason)
|
||||||
)
|
)
|
||||||
|
|
||||||
if item.is_printed and not json["Printed"]:
|
|
||||||
transaction.abort()
|
|
||||||
raise ValidationFailure("This Bill is already printed\nCannot add a Kot to it.")
|
|
||||||
|
|
||||||
item.pax = json["Pax"]
|
def get_guest_book(guest_book_id, dbsession):
|
||||||
item.food_table_id = json["Table"]["FoodTableID"]
|
if guest_book_id is None:
|
||||||
item.customer_id = json["Customer"]["CustomerID"]
|
return guest_book_id
|
||||||
item.voucher_type = json["VoucherType"]
|
return (
|
||||||
if not item.is_printed and json["Printed"]:
|
dbsession.query(GuestBook)
|
||||||
item.date = now
|
.filter(GuestBook.id == uuid.UUID(guest_book_id))
|
||||||
type = [1, 3] if item.voucher_type in [1, 3] else [item.voucher_type]
|
.first()
|
||||||
item.bill_id = (
|
)
|
||||||
request.dbsession.query(func.coalesce(func.max(Voucher.bill_id), 0) + 1)
|
|
||||||
.filter(Voucher.voucher_type.in_(type))
|
|
||||||
.scalar()
|
def get_bill_id(voucher_type, dbsession):
|
||||||
|
if voucher_type == VoucherType.KOT:
|
||||||
|
return None
|
||||||
|
return (
|
||||||
|
dbsession.query(func.coalesce(func.max(Voucher.bill_id), 0) + 1)
|
||||||
|
.filter(Voucher.voucher_type == voucher_type.value)
|
||||||
|
.scalar()
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def do_update_table(item, voucher_type, guest_book, dbsession):
|
||||||
|
status = "running" if voucher_type == VoucherType.KOT else "printed"
|
||||||
|
if item.status is None:
|
||||||
|
item.status = Overview(
|
||||||
|
voucher_id=item.id,
|
||||||
|
food_table_id=item.food_table_id,
|
||||||
|
guest_book_id=guest_book.id if guest_book is not None else None,
|
||||||
|
status=status,
|
||||||
)
|
)
|
||||||
|
dbsession.add(item.status)
|
||||||
item.is_printed = item.is_printed or json["Printed"]
|
else:
|
||||||
item.user_id = json["User"]["UserID"]
|
item.status.status = status
|
||||||
item.last_edit_date = now
|
|
||||||
for k in item.kots:
|
|
||||||
for i in k.inventories:
|
|
||||||
i.tax_rate = get_tax(i.tax_rate, item.voucher_type)
|
|
||||||
i.discount = next(
|
|
||||||
Decimal(inv["Discount"])
|
|
||||||
for ko in json["Kots"]
|
|
||||||
for inv in ko["Inventories"]
|
|
||||||
if uuid.UUID(inv["InventoryID"]) == i.id
|
|
||||||
)
|
|
||||||
for k in (
|
|
||||||
k for k in json["Kots"] if k["KotID"] == "00000000-0000-0000-0000-000000000000"
|
|
||||||
):
|
|
||||||
kot = Kot(
|
|
||||||
item.id,
|
|
||||||
item.food_table_id,
|
|
||||||
item.date,
|
|
||||||
item.user_id,
|
|
||||||
dbsession=request.dbsession,
|
|
||||||
)
|
|
||||||
item.kots.append(kot)
|
|
||||||
request.dbsession.add(kot)
|
|
||||||
for index, i in enumerate(k["Inventories"]):
|
|
||||||
tax_rate = get_tax(i["taxRate"], json["VoucherType"])
|
|
||||||
inv = Inventory(
|
|
||||||
kot.id,
|
|
||||||
uuid.UUID(i["product"]["id"]),
|
|
||||||
i["quantity"],
|
|
||||||
i["price"],
|
|
||||||
i["discount"],
|
|
||||||
i["isHappyHour"],
|
|
||||||
i["tax"]["id"],
|
|
||||||
tax_rate,
|
|
||||||
index,
|
|
||||||
)
|
|
||||||
kot.inventories.append(inv)
|
|
||||||
request.dbsession.add(inv)
|
|
||||||
for m in i["Modifiers"]:
|
|
||||||
mod = InventoryModifier(None, uuid.UUID(m["ModifierID"]), 0)
|
|
||||||
inv.modifiers.append(mod)
|
|
||||||
request.dbsession.add(mod)
|
|
||||||
get_settlements(item, request.dbsession)
|
|
||||||
if update_table:
|
|
||||||
vft = (
|
|
||||||
request.dbsession.query(Overview)
|
|
||||||
.filter(Overview.voucher_id == item.id)
|
|
||||||
.first()
|
|
||||||
)
|
|
||||||
status = "printed" if item.is_printed else "running"
|
|
||||||
if vft is None:
|
|
||||||
item.status = Overview(
|
|
||||||
voucher_id=None, food_table_id=item.food_table_id, status=status
|
|
||||||
)
|
|
||||||
request.dbsession.add(item.status)
|
|
||||||
else:
|
|
||||||
vft.status = status
|
|
||||||
vft.food_table_id = item.food_table_id
|
|
||||||
transaction.commit()
|
|
||||||
item = request.dbsession.query(Voucher).filter(Voucher.id == item.id).first()
|
|
||||||
return voucher_info(item)
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -34,6 +34,14 @@ export class SaleCategoryService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
listForDiscount(): Observable<{name: string, discount: number}[]> {
|
||||||
|
const options = {params: new HttpParams().set('d', '')};
|
||||||
|
return <Observable<{name: string, discount: number}[]>>this.http.get<{name: string, discount: number}[]>(url, options)
|
||||||
|
.pipe(
|
||||||
|
catchError(this.log.handleError(serviceName, 'list'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
save(saleCategory: SaleCategory): Observable<SaleCategory> {
|
save(saleCategory: SaleCategory): Observable<SaleCategory> {
|
||||||
return <Observable<SaleCategory>>this.http.post<SaleCategory>(`${url}/new`, saleCategory, httpOptions)
|
return <Observable<SaleCategory>>this.http.post<SaleCategory>(`${url}/new`, saleCategory, httpOptions)
|
||||||
.pipe(
|
.pipe(
|
||||||
|
|||||||
@ -1,12 +1,15 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { MatDialog } from '@angular/material';
|
import { MatDialog } from '@angular/material';
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
|
import { Observable } from 'rxjs/internal/Observable';
|
||||||
import { Product } from '../core/product';
|
import { Product } from '../core/product';
|
||||||
import { ModifiersComponent } from './modifiers/modifiers.component';
|
import { ModifiersComponent } from './modifiers/modifiers.component';
|
||||||
import { ModifierCategoryService } from '../modifier-categories/modifier-category.service';
|
import { ModifierCategoryService } from '../modifier-categories/modifier-category.service';
|
||||||
import { ModifierCategory } from '../core/modifier-category';
|
import { ModifierCategory } from '../core/modifier-category';
|
||||||
import { Bill, Inventory, Kot, PrintType } from './bills/bill';
|
import { Bill, Inventory, Kot, PrintType } from './bills/bill';
|
||||||
import {VoucherService} from './bills/voucher.service';
|
import { VoucherService } from './bills/voucher.service';
|
||||||
|
import { ToasterService } from "../core/toaster.service";
|
||||||
|
import { tap } from "rxjs/operators";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class BillService {
|
export class BillService {
|
||||||
@ -16,6 +19,7 @@ export class BillService {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
|
private toaster: ToasterService,
|
||||||
private ser: VoucherService,
|
private ser: VoucherService,
|
||||||
private modifierCategoryService: ModifierCategoryService
|
private modifierCategoryService: ModifierCategoryService
|
||||||
) {
|
) {
|
||||||
@ -37,7 +41,8 @@ export class BillService {
|
|||||||
productId: i.product.id,
|
productId: i.product.id,
|
||||||
isHappyHour: i.isHappyHour,
|
isHappyHour: i.isHappyHour,
|
||||||
isPrinted: true,
|
isPrinted: true,
|
||||||
info: `${i.product.name} (${i.product.units}) @ ${i.price}`,
|
info: `${i.product.name} (${i.product.units}) @ ${i.price} - ${i.discount * 100}%`,
|
||||||
|
price: i.price,
|
||||||
quantity: i.quantity,
|
quantity: i.quantity,
|
||||||
discount: i.discount,
|
discount: i.discount,
|
||||||
taxRate: i.taxRate,
|
taxRate: i.taxRate,
|
||||||
@ -61,7 +66,7 @@ export class BillService {
|
|||||||
product: product,
|
product: product,
|
||||||
productId: product.id,
|
productId: product.id,
|
||||||
isHappyHour: product.hasHappyHour,
|
isHappyHour: product.hasHappyHour,
|
||||||
info: `${product.name} (${product.units}) @ ${product.price}`,
|
info: `${product.name} (${product.units}) @ ${product.price} - ${0}%`,
|
||||||
price: product.price,
|
price: product.price,
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
discount: 0,
|
discount: 0,
|
||||||
@ -128,8 +133,18 @@ export class BillService {
|
|||||||
this.showModifier(item);
|
this.showModifier(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
printKot(guest_book_id: string): void {
|
discount(discounts:{id: string, name: string, discount: number}[]): void {
|
||||||
const nk = new Kot({
|
this.data.forEach(x=> {
|
||||||
|
if (!x.isKot) {
|
||||||
|
x.discount = discounts.find(d => d.id === x.product.saleCategory.id).discount / 100;
|
||||||
|
x.info = `${x.product.name} (${x.product.units}) @ ${x.price} - ${x.discount * 100}%`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.dataObs.next(this.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
private getKot(): Kot {
|
||||||
|
return new Kot({
|
||||||
inventories: this.data.filter(x => !x.isKot && !x.isPrinted).map(y => new Inventory({
|
inventories: this.data.filter(x => !x.isKot && !x.isPrinted).map(y => new Inventory({
|
||||||
product: y.product,
|
product: y.product,
|
||||||
quantity: y.quantity,
|
quantity: y.quantity,
|
||||||
@ -141,15 +156,32 @@ export class BillService {
|
|||||||
tax: y.tax
|
tax: y.tax
|
||||||
}))
|
}))
|
||||||
});
|
});
|
||||||
let item = JSON.parse(JSON.stringify(this.bill))
|
}
|
||||||
item.kots.push(nk);
|
|
||||||
this.ser.saveOrUpdate(item, PrintType.Kot, guest_book_id, true).subscribe(x =>
|
printKot(guest_book_id: string): Observable<Bill> {
|
||||||
console.log(x)
|
let item = JSON.parse(JSON.stringify(this.bill));
|
||||||
|
let newKot = this.getKot();
|
||||||
|
if (newKot.inventories.length == 0) {
|
||||||
|
this.toaster.show('Error', 'Cannot print a blank KOT\nPlease add some products!');
|
||||||
|
}
|
||||||
|
item.kots.push(newKot);
|
||||||
|
return this.ser.saveOrUpdate(item, PrintType.Kot, guest_book_id, true).pipe(
|
||||||
|
tap(x => console.log(x))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
printBill(): boolean {
|
printBill(guest_book_id: string): Observable<Bill> {
|
||||||
return false;
|
let item = JSON.parse(JSON.stringify(this.bill));
|
||||||
|
item.kots.forEach(k => {
|
||||||
|
k.inventories.forEach(i => {
|
||||||
|
i.discount = this.data.find(x => !x.isKot && x.id === i.id).discount;
|
||||||
|
})
|
||||||
|
});
|
||||||
|
console.log(item);
|
||||||
|
item.kots.push(this.getKot());
|
||||||
|
return this.ser.saveOrUpdate(item, PrintType.Bill, guest_book_id, true).pipe(
|
||||||
|
tap(x => console.log(x))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,7 +46,6 @@ export class Bill {
|
|||||||
settlements: any[];
|
settlements: any[];
|
||||||
void: boolean;
|
void: boolean;
|
||||||
voidReason: string;
|
voidReason: string;
|
||||||
printed: boolean;
|
|
||||||
voucherType: string;
|
voucherType: string;
|
||||||
serial: number;
|
serial: number;
|
||||||
kots: Kot[];
|
kots: Kot[];
|
||||||
@ -59,7 +58,7 @@ export class Bill {
|
|||||||
|
|
||||||
export enum PrintType {
|
export enum PrintType {
|
||||||
Kot = 'KOT',
|
Kot = 'KOT',
|
||||||
Bill = 'BILL',
|
Bill = 'REGULAR_BILL',
|
||||||
NoCharge = 'NO_CHARGE',
|
NoCharge = 'NO_CHARGE',
|
||||||
Staff = 'STAFF'
|
Staff = 'STAFF'
|
||||||
}
|
}
|
||||||
|
|||||||
16
bookie/src/app/sales/discount/discount-datasource.ts
Normal file
16
bookie/src/app/sales/discount/discount-datasource.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { DataSource } from '@angular/cdk/collections';
|
||||||
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
|
|
||||||
|
export class DiscountDataSource extends DataSource<{name: string, discount: number}> {
|
||||||
|
|
||||||
|
constructor(private data: {name: string, discount: number}[]) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(): Observable<{name: string, discount: number}[]> {
|
||||||
|
return observableOf(this.data);
|
||||||
|
}
|
||||||
|
|
||||||
|
disconnect() {
|
||||||
|
}
|
||||||
|
}
|
||||||
4
bookie/src/app/sales/discount/discount.component.css
Normal file
4
bookie/src/app/sales/discount/discount.component.css
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.right {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
30
bookie/src/app/sales/discount/discount.component.html
Normal file
30
bookie/src/app/sales/discount/discount.component.html
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<h2 mat-dialog-title>Discount</h2>
|
||||||
|
<mat-dialog-content>
|
||||||
|
<form [formGroup]="form" fxLayout="column">
|
||||||
|
<mat-table #table [dataSource]="dataSource" formArrayName="discounts">
|
||||||
|
|
||||||
|
<!-- Name Column -->
|
||||||
|
<ng-container matColumnDef="name">
|
||||||
|
<mat-header-cell *matHeaderCellDef>Name</mat-header-cell>
|
||||||
|
<mat-cell *matCellDef="let row">{{row.name}}</mat-cell>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<!-- Discount Column -->
|
||||||
|
<ng-container matColumnDef="discount">
|
||||||
|
<mat-header-cell *matHeaderCellDef class="center" fxFlex>Discount</mat-header-cell>
|
||||||
|
<mat-cell *matCellDef="let row; let i = index" class="center" [formGroupName]="i" fxFlex>
|
||||||
|
<mat-form-field>
|
||||||
|
<input matInput type="number" formControlName="discount" autocomplete="off">
|
||||||
|
</mat-form-field>
|
||||||
|
</mat-cell>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
||||||
|
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
|
||||||
|
</mat-table>
|
||||||
|
</form>
|
||||||
|
</mat-dialog-content>
|
||||||
|
<mat-dialog-actions align="end">
|
||||||
|
<button mat-button [mat-dialog-close]="false">Cancel</button>
|
||||||
|
<button mat-button (click)="accept()" color="primary">Ok</button>
|
||||||
|
</mat-dialog-actions>
|
||||||
25
bookie/src/app/sales/discount/discount.component.spec.ts
Normal file
25
bookie/src/app/sales/discount/discount.component.spec.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { DiscountComponent } from './discount.component';
|
||||||
|
|
||||||
|
describe('DiscountComponent', () => {
|
||||||
|
let component: DiscountComponent;
|
||||||
|
let fixture: ComponentFixture<DiscountComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ DiscountComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(DiscountComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
52
bookie/src/app/sales/discount/discount.component.ts
Normal file
52
bookie/src/app/sales/discount/discount.component.ts
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
import { Component, Inject } from '@angular/core';
|
||||||
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
import { FormArray, FormBuilder, FormGroup, Validators } from "@angular/forms";
|
||||||
|
import { DiscountDataSource } from "./discount-datasource";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-modifiers',
|
||||||
|
templateUrl: './discount.component.html',
|
||||||
|
styleUrls: ['./discount.component.css']
|
||||||
|
})
|
||||||
|
export class DiscountComponent {
|
||||||
|
list: any[];
|
||||||
|
form: FormGroup;
|
||||||
|
dataSource: DiscountDataSource;
|
||||||
|
|
||||||
|
displayedColumns = ['name', 'discount'];
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
public dialogRef: MatDialogRef<DiscountComponent>,
|
||||||
|
private fb: FormBuilder,
|
||||||
|
@Inject(MAT_DIALOG_DATA) public data: Observable<any[]>
|
||||||
|
) {
|
||||||
|
this.createForm();
|
||||||
|
this.data.subscribe((list: any[]) => {
|
||||||
|
this.list = list;
|
||||||
|
this.form.setControl('discounts', this.fb.array(
|
||||||
|
this.list.map(
|
||||||
|
x => this.fb.group({
|
||||||
|
name: [x.name],
|
||||||
|
discount: ["", [Validators.min(0), Validators.max(100)]]
|
||||||
|
})
|
||||||
|
)
|
||||||
|
));
|
||||||
|
this.dataSource = new DiscountDataSource(list);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
createForm() {
|
||||||
|
this.form = this.fb.group({
|
||||||
|
discounts: ''
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
accept(): void {
|
||||||
|
const array = this.form.get('discounts') as FormArray;
|
||||||
|
this.list.forEach((item, index) => {
|
||||||
|
item.discount = Math.max(Math.min(array.controls[index].value.discount, 100), 0);
|
||||||
|
});
|
||||||
|
this.dialogRef.close(this.list);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -3,6 +3,9 @@
|
|||||||
queryParamsHandling="preserve">
|
queryParamsHandling="preserve">
|
||||||
<h3 class="item-name">Add Product</h3>
|
<h3 class="item-name">Add Product</h3>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
<mat-card fxLayout="column" class="square-button" matRipple (click)="discount()">
|
||||||
|
<h3 class="item-name">Discount</h3>
|
||||||
|
</mat-card>
|
||||||
<mat-card fxLayout="column" class="square-button" matRipple (click)="printKot()">
|
<mat-card fxLayout="column" class="square-button" matRipple (click)="printKot()">
|
||||||
<h3 class="item-name">Print KOT</h3>
|
<h3 class="item-name">Print KOT</h3>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
|
|||||||
@ -1,8 +1,12 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { Subject } from 'rxjs';
|
import { ActivatedRoute, Router } from "@angular/router";
|
||||||
import { AuthService } from '../../auth/auth.service';
|
import { MatDialog } from "@angular/material";
|
||||||
|
import { mergeMap, tap } from "rxjs/operators";
|
||||||
|
import { Observable, of as observableOf } from "rxjs";
|
||||||
import { BillService } from '../bill.service';
|
import { BillService } from '../bill.service';
|
||||||
import { ActivatedRoute } from "@angular/router";
|
import { ToasterService } from "../../core/toaster.service";
|
||||||
|
import { DiscountComponent } from "../discount/discount.component";
|
||||||
|
import { SaleCategoryService } from "../../sale-category/sale-category.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-sales-home',
|
selector: 'app-sales-home',
|
||||||
@ -10,19 +14,17 @@ import { ActivatedRoute } from "@angular/router";
|
|||||||
styleUrls: ['./sales-home.component.css']
|
styleUrls: ['./sales-home.component.css']
|
||||||
})
|
})
|
||||||
export class SalesHomeComponent implements OnInit {
|
export class SalesHomeComponent implements OnInit {
|
||||||
public nameObject = new Subject<string>();
|
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute, private auth: AuthService, private bs: BillService) {
|
constructor(
|
||||||
|
private route: ActivatedRoute,
|
||||||
|
private router: Router,
|
||||||
|
private dialog: MatDialog,
|
||||||
|
private toaster: ToasterService,
|
||||||
|
private mcSer: SaleCategoryService,
|
||||||
|
private bs: BillService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.auth.userObservable.subscribe((user) => {
|
|
||||||
if (user.isAuthenticated) {
|
|
||||||
this.nameObject.next(user.name);
|
|
||||||
} else {
|
|
||||||
this.nameObject.next(null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
printKot() {
|
printKot() {
|
||||||
@ -30,10 +32,48 @@ export class SalesHomeComponent implements OnInit {
|
|||||||
if (this.route.snapshot.queryParamMap.has("guest")) {
|
if (this.route.snapshot.queryParamMap.has("guest")) {
|
||||||
guestBookId = this.route.snapshot.queryParamMap.get("guest");
|
guestBookId = this.route.snapshot.queryParamMap.get("guest");
|
||||||
}
|
}
|
||||||
this.bs.printKot(guestBookId);
|
this.bs.printKot(guestBookId).subscribe(x => {
|
||||||
|
this.toaster.show('Success', '');
|
||||||
|
this.router.navigate(['/sales']);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
discount(): void {
|
||||||
|
this.showDiscount().subscribe();
|
||||||
|
}
|
||||||
|
|
||||||
|
showDiscount(): Observable<boolean | { id: string, name: string, discount: number }[]> {
|
||||||
|
const dialogRef = this.dialog.open(DiscountComponent, {
|
||||||
|
// width: '750px',
|
||||||
|
data: this.mcSer.listForDiscount()
|
||||||
|
});
|
||||||
|
return dialogRef.afterClosed().pipe(
|
||||||
|
tap((result: boolean | { id: string, name: string, discount: number }[]) => {
|
||||||
|
if (!!result) {
|
||||||
|
this.bs.discount(result as { id: string, name: string, discount: number }[]);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
printBill() {
|
printBill() {
|
||||||
this.bs.printBill();
|
const canGiveDiscount = true;
|
||||||
|
let guestBookId = null;
|
||||||
|
if (this.route.snapshot.queryParamMap.has("guest")) {
|
||||||
|
guestBookId = this.route.snapshot.queryParamMap.get("guest");
|
||||||
|
}
|
||||||
|
let discObs = null
|
||||||
|
if (!canGiveDiscount) {
|
||||||
|
discObs = this.showDiscount();
|
||||||
|
} else {
|
||||||
|
discObs = observableOf("");
|
||||||
|
}
|
||||||
|
discObs.pipe(
|
||||||
|
mergeMap(x => this.bs.printBill(guestBookId))
|
||||||
|
).subscribe(x => {
|
||||||
|
this.toaster.show('Success', '');
|
||||||
|
this.router.navigate(['/sales']);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { Component, Inject } from '@angular/core';
|
|||||||
import { ModifierCategory } from '../../core/modifier-category';
|
import { ModifierCategory } from '../../core/modifier-category';
|
||||||
import { Modifier } from '../../core/modifier';
|
import { Modifier } from '../../core/modifier';
|
||||||
import { MAT_DIALOG_DATA } from '@angular/material';
|
import { MAT_DIALOG_DATA } from '@angular/material';
|
||||||
import {Observable} from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-modifiers',
|
selector: 'app-modifiers',
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
<div mat-dialog-content>
|
<mat-dialog-content>
|
||||||
<form [formGroup]="form">
|
<form [formGroup]="form">
|
||||||
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
<div fxLayout="row" fxLayoutAlign="space-around start" fxLayout.lt-md="column" fxLayoutGap="20px"
|
||||||
fxLayoutGap.lt-md="0px">
|
fxLayoutGap.lt-md="0px">
|
||||||
@ -9,9 +9,8 @@
|
|||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</mat-dialog-content>
|
||||||
<div mat-dialog-actions>
|
<mat-dialog-actions>
|
||||||
<button mat-button [mat-dialog-close]="false">Cancel</button>
|
<button mat-button [mat-dialog-close]="false">Cancel</button>
|
||||||
<button mat-button (click)="accept()" color="primary">Ok</button>
|
<button mat-button (click)="accept()" color="primary">Ok</button>
|
||||||
</div>
|
</mat-dialog-actions>
|
||||||
|
|
||||||
|
|||||||
@ -25,19 +25,21 @@ import { BillsComponent } from './bills/bills.component';
|
|||||||
import { SalesHomeComponent } from './home/sales-home.component';
|
import { SalesHomeComponent } from './home/sales-home.component';
|
||||||
import { BillService } from './bill.service';
|
import { BillService } from './bill.service';
|
||||||
import { QuantityComponent } from './quantity/quantity.component';
|
import { QuantityComponent } from './quantity/quantity.component';
|
||||||
|
import { DiscountComponent } from "./discount/discount.component";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
providers: [
|
providers: [
|
||||||
BillService
|
BillService
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
RunningTablesComponent,
|
|
||||||
MenuCategoriesComponent,
|
|
||||||
ProductsComponent,
|
|
||||||
ModifiersComponent,
|
|
||||||
BillsComponent,
|
BillsComponent,
|
||||||
SalesHomeComponent,
|
DiscountComponent,
|
||||||
QuantityComponent
|
MenuCategoriesComponent,
|
||||||
|
ModifiersComponent,
|
||||||
|
ProductsComponent,
|
||||||
|
QuantityComponent,
|
||||||
|
RunningTablesComponent,
|
||||||
|
SalesHomeComponent
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
@ -59,6 +61,7 @@ import { QuantityComponent } from './quantity/quantity.component';
|
|||||||
SalesRoutingModule
|
SalesRoutingModule
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
|
DiscountComponent,
|
||||||
ModifiersComponent,
|
ModifiersComponent,
|
||||||
QuantityComponent
|
QuantityComponent
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user