Moved to Angular 16
Moved to FastAPI 0.100.0
Moved to pydantic 2.0
This commit is contained in:
tanshu committed 2023-07-22 09:20:01 +05:30
1 parent 8b2d15b9e1
commit 09b762d154
161 files changed
+693 -753

No files matched your search

+2 -5
View File
@@ -1,7 +1,7 @@
import secrets
from dotenv import load_dotenv
from pydantic import BaseSettings
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
@@ -27,10 +27,7 @@ class Settings(BaseSettings):
WORKER_REDIS_HOST: str = "127.0.0.1"
WORKER_REDIS_PORT: int = 6379
WORKER_QUEUE_NAME: str = "arq:queue"
class Config:
case_sensitive = True
env_file = ".env"
model_config = SettingsConfigDict(case_sensitive=True, env_file=".env")
load_dotenv()
+22 -17
View File
@@ -1,49 +1,54 @@
from datetime import date, datetime
from decimal import Decimal
from pydantic import BaseModel, validator
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
from . import to_camel
class BillSettlementItem(BaseModel):
date: datetime
date_: datetime
bill_id: str
settlement: str
amount: Decimal
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
json_encoders = {
datetime: lambda v: v.strftime("%d-%b-%Y %H:%M"),
}
@validator("date", pre=True)
@field_validator("date_", mode="before")
@classmethod
def parse_date(cls, value):
if isinstance(value, datetime):
return value
return datetime.strptime(value, "%d-%b-%Y %H:%M")
@field_serializer("date_")
def serialize_date(self, value: datetime, _info):
return value.strftime("%d-%b-%Y %H:%M")
class BillSettlement(BaseModel):
start_date: date
finish_date: date
amounts: list[BillSettlementItem]
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
json_encoders = {datetime: lambda v: v.strftime("%d-%b-%Y %H:%M"), date: lambda v: v.strftime("%d-%b-%Y")}
@validator("start_date", pre=True)
@field_validator("start_date", mode="before")
@classmethod
def parse_start_date(cls, value):
if isinstance(value, date):
return value
return datetime.strptime(value, "%d-%b-%Y").date()
@validator("finish_date", pre=True)
@field_serializer("start_date")
def serialize_start_date(self, value: date, _info):
return value.strftime("%d-%b-%Y")
@field_validator("finish_date", mode="before")
@classmethod
def parse_finish_date(cls, value):
if isinstance(value, date):
return value
return datetime.strptime(value, "%d-%b-%Y").date()
@field_serializer("finish_date")
def serialize_finish_date(self, value: date, _info):
return value.strftime("%d-%b-%Y")
+22 -24
View File
@@ -1,7 +1,7 @@
from datetime import date, datetime
from decimal import Decimal
from pydantic import BaseModel, validator
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
from . import to_camel
from .user import UserLink
@@ -10,24 +10,19 @@ from .user import UserLink
class NameAmount(BaseModel):
name: str
amount: Decimal
class Config:
anystr_strip_whitespace = True
model_config = ConfigDict(str_strip_whitespace=True)
class SettleOptionSchema(BaseModel):
def __hash__(self):
return hash(self.id)
return hash(self.id_)
def __eq__(self, other):
return self.id == other.id
return self.id_ == other.id_
id: int
id_: int
name: str
class Config:
fields = {"id": "id"}
anystr_strip_whitespace = True
model_config = ConfigDict(alias_generator=to_camel, str_strip_whitespace=True)
class InfoItem(BaseModel):
@@ -35,12 +30,10 @@ class InfoItem(BaseModel):
bill_id: str
customer: str
amount: Decimal
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
@validator("date", pre=True)
@field_validator("date", mode="before")
@classmethod
def parse_date(cls, value):
if isinstance(value, datetime):
return value
@@ -55,21 +48,26 @@ class CashierReport(BaseModel):
user: UserLink
amounts: list[NameAmount]
info: dict[str, list[InfoItem]]
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class Config:
fields = {"id_": "id"}
anystr_strip_whitespace = True
alias_generator = to_camel
json_encoders = {datetime: lambda v: v.strftime("%d-%b-%Y %H:%M"), date: lambda v: v.strftime("%d-%b-%Y")}
@validator("start_date", pre=True)
@field_validator("start_date", mode="before")
@classmethod
def parse_start_date(cls, value):
if isinstance(value, date):
return value
return datetime.strptime(value, "%d-%b-%Y").date()
@validator("finish_date", pre=True)
@field_serializer("start_date")
def serialize_start_date(self, value: date, _info):
return value.strftime("%d-%b-%Y")
@field_validator("finish_date", mode="before")
@classmethod
def parse_finish_date(cls, value):
if isinstance(value, date):
return value
return datetime.strptime(value, "%d-%b-%Y").date()
@field_serializer("finish_date")
def serialize_finish_date(self, value: date, _info):
return value.strftime("%d-%b-%Y")
+8 -22
View File
@@ -2,7 +2,7 @@ import uuid
from decimal import Decimal
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field
from . import to_camel
@@ -12,45 +12,31 @@ class CustomerDiscount(BaseModel):
name: str
discount: Decimal = Field(ge=0, multiple_of=0.0001, default=0, le=1)
limit: Decimal = Field(ge=0, multiple_of=0.0001, default=0, le=1)
class Config:
alias_generator = to_camel
model_config = ConfigDict(alias_generator=to_camel)
class CustomerIn(BaseModel):
name: str = Field(..., min_length=1)
# phone: str = Field(..., min_length=1)
phone: str
address: str | None
address: str | None = None
print_in_bill: bool
discounts: list[CustomerDiscount]
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class Customer(CustomerIn):
id_: uuid.UUID
class Config:
fields = {"id_": "id"}
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class CustomerLink(BaseModel):
id_: uuid.UUID = Field(...)
name: str | None
class Config:
fields = {"id_": "id"}
name: str | None = None
model_config = ConfigDict(alias_generator=to_camel)
class CustomerBlank(CustomerIn):
name: str
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
+13 -16
View File
@@ -2,7 +2,7 @@ import uuid
from datetime import datetime
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field, field_serializer
from . import to_camel
from .section import SectionLink
@@ -12,29 +12,26 @@ class DeviceIn(BaseModel):
name: str = Field(..., min_length=1)
enabled: bool
section: SectionLink
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class Device(DeviceIn):
id_: uuid.UUID
creation_date: datetime
last_user: str
last_date: datetime | None
last_date: datetime | None = None
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class Config:
fields = {"id_": "id"}
anystr_strip_whitespace = True
alias_generator = to_camel
json_encoders = {datetime: lambda v: v.strftime("%d-%b-%Y %H:%M")}
@field_serializer("creation_date")
def serialize_creation_date(self, value: datetime, _info):
return value.strftime("%d-%b-%Y %H:%M")
@field_serializer("last_date")
def serialize_last_date(self, value: datetime | None, _info):
return None if value is None else value.strftime("%d-%b-%Y %H:%M")
class DeviceLink(BaseModel):
id_: uuid.UUID = Field(...)
name: str | None
class Config:
fields = {"id_": "id"}
alias_generator = to_camel
name: str | None = None
model_config = ConfigDict(alias_generator=to_camel)
+2 -4
View File
@@ -3,7 +3,7 @@ import uuid
from decimal import Decimal
from barker.schemas import to_camel
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field
class DiscountItem(BaseModel):
@@ -12,6 +12,4 @@ class DiscountItem(BaseModel):
discount: Decimal | None = Field(ge=0, multiple_of=0.0001, default=0, le=1)
limit: Decimal
customer: Decimal
class Config:
alias_generator = to_camel
model_config = ConfigDict(alias_generator=to_camel)
+15 -12
View File
@@ -1,7 +1,7 @@
from datetime import date, datetime
from decimal import Decimal
from pydantic import BaseModel, validator
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
from . import to_camel
@@ -9,30 +9,33 @@ from . import to_camel
class DiscountReportItem(BaseModel):
name: str
amount: Decimal
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class DiscountReport(BaseModel):
start_date: date
finish_date: date
amounts: list[DiscountReportItem]
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
json_encoders = {datetime: lambda v: v.strftime("%d-%b-%Y %H:%M"), date: lambda v: v.strftime("%d-%b-%Y")}
@validator("start_date", pre=True)
@field_validator("start_date", mode="before")
@classmethod
def parse_start_date(cls, value):
if isinstance(value, date):
return value
return datetime.strptime(value, "%d-%b-%Y").date()
@validator("finish_date", pre=True)
@field_serializer("start_date")
def serialize_start_date(self, value: date, _info):
return value.strftime("%d-%b-%Y")
@field_validator("finish_date", mode="before")
@classmethod
def parse_finish_date(cls, value):
if isinstance(value, date):
return value
return datetime.strptime(value, "%d-%b-%Y").date()
@field_serializer("finish_date")
def serialize_finish_date(self, value: date, _info):
return value.strftime("%d-%b-%Y")
+27 -35
View File
@@ -2,7 +2,7 @@ import uuid
from datetime import date, datetime
from pydantic import BaseModel, Field, validator
from pydantic import BaseModel, ConfigDict, Field, field_serializer, field_validator
from . import to_camel
@@ -10,37 +10,28 @@ from . import to_camel
class GuestBookIn(BaseModel):
name: str
phone: str
address: str | None
address: str | None = None
pax: int = Field(ge=0)
date_: datetime
@validator("date_", pre=True)
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
@field_validator("date_", mode="before")
@classmethod
def parse_date(cls, value):
if isinstance(value, datetime):
return value
return datetime.strptime(value, "%d-%b-%Y %H:%M")
class Config:
fields = {"id_": "id"}
anystr_strip_whitespace = True
alias_generator = to_camel
json_encoders = {datetime: lambda v: v.strftime("%d-%b-%Y %H:%M")}
@field_serializer("date_")
def serialize_date(self, value: datetime, _info):
return value.strftime("%d-%b-%Y %H:%M")
class GuestBook(GuestBookIn):
id_: uuid.UUID
@validator("date_", pre=True)
def parse_date(cls, value):
if isinstance(value, datetime):
return value
return datetime.strptime(value, "%d-%b-%Y %H:%M")
class Config:
fields = {"id_": "id"}
anystr_strip_whitespace = True
alias_generator = to_camel
json_encoders = {datetime: lambda v: v.strftime("%d-%b-%Y %H:%M")}
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class GuestBookListItem(BaseModel):
@@ -50,36 +41,37 @@ class GuestBookListItem(BaseModel):
phone: str
pax: int
date_: datetime
status: str | None
table_id: uuid.UUID | None
voucher_id: uuid.UUID | None
table_name: str | None
status: str | None = None
table_id: uuid.UUID | None = None
voucher_id: uuid.UUID | None = None
table_name: str | None = None
@validator("date_", pre=True)
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
@field_validator("date_", mode="before")
@classmethod
def parse_date(cls, value):
if isinstance(value, datetime):
return value
return datetime.strptime(value, "%d-%b-%Y %H:%M")
class Config:
fields = {"id_": "id"}
anystr_strip_whitespace = True
alias_generator = to_camel
json_encoders = {datetime: lambda v: v.strftime("%d-%b-%Y %H:%M"), date: lambda v: v.strftime("%d-%b-%Y")}
@field_serializer("date_")
def serialize_date(self, value: datetime, _info):
return value.strftime("%d-%b-%Y %H:%M")
class GuestBookList(BaseModel):
date_: date
list: list[GuestBookListItem]
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
@validator("date_", pre=True)
@field_validator("date_", mode="before")
@classmethod
def parse_date(cls, value):
if isinstance(value, date):
return value
return datetime.strptime(value, "%d-%b-%Y").date()
class Config:
fields = {"id_": "id"}
anystr_strip_whitespace = True
alias_generator = to_camel
json_encoders = {datetime: lambda v: v.strftime("%d-%b-%Y %H:%M"), date: lambda v: v.strftime("%d-%b-%Y")}
@field_serializer("date_")
def serialize_date(self, value: date, _info):
return value.strftime("%d-%b-%Y")
+2 -4
View File
@@ -1,6 +1,6 @@
import uuid
from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict
from . import to_camel
@@ -9,6 +9,4 @@ class HeaderFooter(BaseModel):
id_: uuid.UUID
name: str
text: str
class Config:
alias_generator = to_camel
model_config = ConfigDict(alias_generator=to_camel)
+2 -5
View File
@@ -3,7 +3,7 @@ import uuid
from datetime import datetime
from barker.schemas import to_camel
from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict
class LoginHistory(BaseModel):
@@ -11,7 +11,4 @@ class LoginHistory(BaseModel):
user_id: uuid.UUID
client_id: uuid.UUID
date: datetime
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
+14 -18
View File
@@ -3,7 +3,7 @@ import uuid
from datetime import date, datetime
from decimal import Decimal
from pydantic import BaseModel, Field, validator
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
from . import to_camel
@@ -12,11 +12,7 @@ class AccountBase(BaseModel):
name: str = Field(..., min_length=1)
is_starred: bool
is_active: bool
class Config:
fields = {"id_": "id"}
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class AccountIn(AccountBase):
@@ -35,26 +31,28 @@ class EmployeeIn(AccountBase):
salary: int = Field(ge=0)
points: Decimal = Field(ge=0, lt=1000, multiple_of=0.01)
joining_date: date
leaving_date: date | None
leaving_date: date | None = None
@validator("joining_date", pre=True)
@field_validator("joining_date", mode="before")
@classmethod
def parse_joining_date(cls, value):
return datetime.strptime(value, "%d-%b-%Y").date()
@validator("leaving_date", pre=True)
@field_validator("leaving_date", mode="before")
@classmethod
def parse_leaving_date(cls, value):
if value is None or value == "":
return None
else:
return datetime.strptime(value, "%d-%b-%Y").date()
@validator("leaving_date")
def leaving_date_more_than_joining_date(cls, v, values, **kwargs):
if values["is_active"]:
return None
if v < values["joining_date"]:
@model_validator(mode="after")
def leaving_date_more_than_joining_date(self) -> "EmployeeIn":
if self.is_active:
self.leaving_date = None
elif self.leaving_date < self.joining_date:
raise ValueError("Leaving Date cannot be less than Joining Date")
return v
return self
class Employee(EmployeeIn):
@@ -72,6 +70,4 @@ class DbSetting(BaseModel):
class AccountType(BaseModel):
id_: int
name: str
class Config:
fields = {"id_": "id"}
model_config = ConfigDict(alias_generator=to_camel)
+6 -17
View File
@@ -1,6 +1,6 @@
import uuid
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field
from . import to_camel
from .product_link import ProductLink
@@ -10,33 +10,22 @@ class MenuCategoryIn(BaseModel):
name: str = Field(..., min_length=1)
is_active: bool
is_fixture: bool
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class MenuCategory(MenuCategoryIn):
id_: uuid.UUID
sort_order: int
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class MenuCategoryBlank(MenuCategoryIn):
name: str
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class MenuCategoryLink(BaseModel):
id_: uuid.UUID = Field(...)
name: str | None
name: str | None = None
products: list[ProductLink]
class Config:
fields = {"id_": "id"}
model_config = ConfigDict(alias_generator=to_camel)
@@ -3,7 +3,7 @@ import uuid
from datetime import date, datetime
from decimal import Decimal
from pydantic import BaseModel, validator
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
from . import to_camel
@@ -19,30 +19,33 @@ class MeItem(BaseModel):
sales: Decimal
quantity_percent: Decimal
sales_percent: Decimal
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class MeReport(BaseModel):
start_date: date
finish_date: date
amounts: list[MeItem]
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
json_encoders = {datetime: lambda v: v.strftime("%d-%b-%Y %H:%M"), date: lambda v: v.strftime("%d-%b-%Y")}
@validator("start_date", pre=True)
@field_validator("start_date", mode="before")
@classmethod
def parse_start_date(cls, value):
if isinstance(value, date):
return value
return datetime.strptime(value, "%d-%b-%Y").date()
@validator("finish_date", pre=True)
@field_serializer("start_date")
def serialize_start_date(self, value: date, _info):
return value.strftime("%d-%b-%Y")
@field_validator("finish_date", mode="before")
@classmethod
def parse_finish_date(cls, value):
if isinstance(value, date):
return value
return datetime.strptime(value, "%d-%b-%Y").date()
@field_serializer("finish_date")
def serialize_finish_date(self, value: date, _info):
return value.strftime("%d-%b-%Y")
+5 -17
View File
@@ -1,6 +1,6 @@
import uuid
from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict
from . import to_camel
@@ -10,36 +10,24 @@ class MergeKot(BaseModel):
kot_id: uuid.UUID
table_id: uuid.UUID
new_voucher_id: uuid.UUID
class Config:
alias_generator = to_camel
fields = {"id_": "id"}
model_config = ConfigDict(alias_generator=to_camel)
class MoveKot(BaseModel):
voucher_id: uuid.UUID
kot_id: uuid.UUID
table_id: uuid.UUID
class Config:
alias_generator = to_camel
fields = {"id_": "id"}
model_config = ConfigDict(alias_generator=to_camel)
class MergeTable(BaseModel):
voucher_id: uuid.UUID
table_id: uuid.UUID
new_voucher_id: uuid.UUID
class Config:
alias_generator = to_camel
fields = {"id_": "id"}
model_config = ConfigDict(alias_generator=to_camel)
class MoveTable(BaseModel):
voucher_id: uuid.UUID
table_id: uuid.UUID
class Config:
alias_generator = to_camel
fields = {"id_": "id"}
model_config = ConfigDict(alias_generator=to_camel)
+5 -15
View File
@@ -2,7 +2,7 @@ import uuid
from decimal import Decimal
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field
from . import to_camel
from .modifier_category import ModifierCategoryLink
@@ -14,11 +14,7 @@ class ModifierIn(BaseModel):
price: Decimal = Field(ge=0, multiple_of=0.01, default=0)
is_active: bool
modifier_category: ModifierCategoryLink
class Config:
fields = {"id_": "id"}
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class Modifier(ModifierIn):
@@ -27,10 +23,8 @@ class Modifier(ModifierIn):
class ModifierLink(BaseModel):
id_: uuid.UUID = Field(...)
name: str | None
class Config:
fields = {"id_": "id"}
name: str | None = None
model_config = ConfigDict(alias_generator=to_camel)
class ModifierBlank(BaseModel):
@@ -38,8 +32,4 @@ class ModifierBlank(BaseModel):
show_in_bill: bool
price: Decimal
is_active: bool
class Config:
fields = {"id_": "id"}
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
+6 -18
View File
@@ -1,6 +1,6 @@
import uuid
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field
from . import to_camel
from .menu_category import MenuCategoryLink
@@ -12,33 +12,21 @@ class ModifierCategoryIn(BaseModel):
maximum: int | None = Field(ge=0)
is_active: bool
menu_categories: list[MenuCategoryLink]
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class ModifierCategory(ModifierCategoryIn):
id_: uuid.UUID
sort_order: int
class Config:
fields = {"id_": "id"}
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class ModifierCategoryBlank(ModifierCategoryIn):
name: str
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class ModifierCategoryLink(BaseModel):
id_: uuid.UUID = Field(...)
name: str | None
class Config:
fields = {"id_": "id"}
name: str | None = None
model_config = ConfigDict(alias_generator=to_camel)
+4 -4
View File
@@ -1,12 +1,12 @@
import uuid
from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict
from . import to_camel
class PermissionItem(BaseModel):
id_: uuid.UUID
name: str
enabled: bool
class Config:
fields = {"id_": "id"}
model_config = ConfigDict(alias_generator=to_camel)
+5 -16
View File
@@ -1,6 +1,6 @@
import uuid
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field
from . import to_camel
@@ -9,31 +9,20 @@ class PrinterIn(BaseModel):
name: str = Field(..., min_length=1)
address: str = Field(..., min_length=1)
cut_code: str
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class Printer(PrinterIn):
id_: uuid.UUID
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class PrinterBlank(PrinterIn):
name: str
address: str
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class PrinterLink(BaseModel):
id_: uuid.UUID = Field(...)
class Config:
fields = {"id_": "id"}
model_config = ConfigDict(alias_generator=to_camel)
+18 -18
View File
@@ -3,7 +3,7 @@ import uuid
from datetime import date, datetime
from decimal import Decimal
from pydantic import BaseModel, Field, validator
from pydantic import BaseModel, ConfigDict, Field, field_serializer, field_validator
from . import to_camel
from .menu_category import MenuCategoryLink
@@ -21,24 +21,18 @@ class ProductIn(BaseModel):
quantity: Decimal = Field(ge=0, multiple_of=0.01, default=0)
is_active: bool
sort_order: int
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class Product(ProductIn):
id_: uuid.UUID
version_id: uuid.UUID
valid_from: date | None
valid_till: date | None
valid_from: date | None = None
valid_till: date | None = None
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
json_encoders = {date: lambda v: v.strftime("%d-%b-%Y")}
@validator("valid_from", pre=True)
@field_validator("valid_from", mode="before")
@classmethod
def parse_valid_from(cls, value):
if value is None:
return None
@@ -46,7 +40,12 @@ class Product(ProductIn):
return value
return datetime.strptime(value, "%d-%b-%Y").date()
@validator("valid_till", pre=True)
@field_serializer("valid_from")
def serialize_valid_from(self, value: date | None, _info):
return None if value is None else value.strftime("%d-%b-%Y")
@field_validator("valid_till", mode="before")
@classmethod
def parse_valid_till(cls, value):
if value is None:
return None
@@ -54,6 +53,10 @@ class Product(ProductIn):
return value
return datetime.strptime(value, "%d-%b-%Y").date()
@field_serializer("valid_till")
def serialize_valid_till(self, value: date | None, _info):
return None if value is None else value.strftime("%d-%b-%Y")
class ProductBlank(BaseModel):
name: str
@@ -64,7 +67,4 @@ class ProductBlank(BaseModel):
quantity: Decimal
is_active: bool
sort_order: int
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
+6 -6
View File
@@ -1,12 +1,12 @@
import uuid
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field
from . import to_camel
class ProductLink(BaseModel):
id_: uuid.UUID = Field(...)
name: str | None
enabled: bool | None
class Config:
fields = {"id_": "id"}
name: str | None = None
enabled: bool | None = None
model_config = ConfigDict(alias_generator=to_camel)
+3 -8
View File
@@ -1,6 +1,6 @@
from decimal import Decimal
from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict
from . import to_camel
@@ -8,15 +8,10 @@ from . import to_camel
class ReceivePaymentItem(BaseModel):
id_: int
amount: Decimal
class Config:
fields = {"id_": "id"}
model_config = ConfigDict(alias_generator=to_camel)
class ReceivePayment(BaseModel):
reason: str
amounts: list[ReceivePaymentItem]
class Config:
alias_generator = to_camel
anystr_strip_whitespace = True
model_config = ConfigDict(alias_generator=to_camel, str_strip_whitespace=True)
+6 -14
View File
@@ -1,4 +1,4 @@
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field
from . import to_camel
@@ -8,30 +8,22 @@ class RegimeIn(BaseModel):
header: str
prefix: str = Field(..., min_length=1)
is_fixture: bool
class Config:
alias_generator = to_camel
model_config = ConfigDict(alias_generator=to_camel)
class Regime(RegimeIn):
id_: int
class Config:
alias_generator = to_camel
model_config = ConfigDict(alias_generator=to_camel)
class RegimeBlank(RegimeIn):
name: str
header: str
prefix: str
class Config:
alias_generator = to_camel
model_config = ConfigDict(alias_generator=to_camel)
class RegimeLink(BaseModel):
id_: int = Field(...)
name: str | None
class Config:
fields = {"id_": "id"}
name: str | None = None
model_config = ConfigDict(alias_generator=to_camel)
+8 -18
View File
@@ -1,46 +1,36 @@
import uuid
from barker.schemas.permission import PermissionItem
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field
from . import to_camel
class RoleIn(BaseModel):
name: str = Field(..., min_length=1)
permissions: list[PermissionItem]
class Config:
anystr_strip_whitespace = True
model_config = ConfigDict(str_strip_whitespace=True)
class Role(RoleIn):
id_: uuid.UUID
class Config:
anystr_strip_whitespace = True
fields = {"id_": "id"}
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class RoleBlank(RoleIn):
name: str
class Config:
anystr_strip_whitespace = True
model_config = ConfigDict(str_strip_whitespace=True)
class RoleList(BaseModel):
id_: uuid.UUID
name: str
permissions: list[str]
class Config:
fields = {"id_": "id"}
anystr_strip_whitespace = True
model_config = ConfigDict(alias_generator=to_camel, str_strip_whitespace=True)
class RoleItem(BaseModel):
id_: uuid.UUID
name: str
enabled: bool
class Config:
fields = {"id_": "id"}
model_config = ConfigDict(alias_generator=to_camel)
+7 -21
View File
@@ -2,7 +2,7 @@ import uuid
from decimal import Decimal
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field
from . import to_camel
from .tax import TaxLink
@@ -12,27 +12,18 @@ class SaleCategoryIn(BaseModel):
name: str = Field(..., min_length=1)
discount_limit: Decimal = Field(ge=0, multiple_of=0.0001, default=0, le=1)
tax: TaxLink = Field(...)
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class SaleCategory(SaleCategoryIn):
id_: uuid.UUID
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class SaleCategoryBlank(BaseModel):
name: str
discount_limit: Decimal
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class SaleCategoryForDiscount(BaseModel):
@@ -40,15 +31,10 @@ class SaleCategoryForDiscount(BaseModel):
name: str
discount_limit: Decimal
discount: Decimal
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class SaleCategoryLink(BaseModel):
id_: uuid.UUID = Field(...)
name: str | None
class Config:
fields = {"id_": "id"}
name: str | None = None
model_config = ConfigDict(alias_generator=to_camel)
+15 -12
View File
@@ -1,7 +1,7 @@
from datetime import date, datetime
from decimal import Decimal
from pydantic import BaseModel, validator
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
from . import to_camel
from .user import UserLink
@@ -10,10 +10,7 @@ from .user import UserLink
class SaleReportItem(BaseModel):
name: str
amount: Decimal
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class SaleReport(BaseModel):
@@ -21,20 +18,26 @@ class SaleReport(BaseModel):
finish_date: date
amounts: list[SaleReportItem]
user: UserLink
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
json_encoders = {datetime: lambda v: v.strftime("%d-%b-%Y %H:%M"), date: lambda v: v.strftime("%d-%b-%Y")}
@validator("start_date", pre=True)
@field_validator("start_date", mode="before")
@classmethod
def parse_start_date(cls, value):
if isinstance(value, date):
return value
return datetime.strptime(value, "%d-%b-%Y").date()
@validator("finish_date", pre=True)
@field_serializer("start_date")
def serialize_start_date(self, value: date, _info):
return value.strftime("%d-%b-%Y")
@field_validator("finish_date", mode="before")
@classmethod
def parse_finish_date(cls, value):
if isinstance(value, date):
return value
return datetime.strptime(value, "%d-%b-%Y").date()
@field_serializer("finish_date")
def serialize_finish_date(self, value: date, _info):
return value.strftime("%d-%b-%Y")
+8 -15
View File
@@ -1,33 +1,26 @@
import uuid
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field
from . import to_camel
class SectionIn(BaseModel):
name: str = Field(..., min_length=1)
class Config:
anystr_strip_whitespace = True
model_config = ConfigDict(str_strip_whitespace=True)
class Section(SectionIn):
id_: uuid.UUID
class Config:
anystr_strip_whitespace = True
fields = {"id_": "id"}
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class SectionBlank(BaseModel):
name: str
class Config:
anystr_strip_whitespace = True
model_config = ConfigDict(str_strip_whitespace=True)
class SectionLink(BaseModel):
id_: uuid.UUID = Field(...)
name: str | None
class Config:
fields = {"id_": "id"}
name: str | None = None
model_config = ConfigDict(alias_generator=to_camel)
+4 -6
View File
@@ -1,4 +1,4 @@
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field
from . import to_camel
from .printer import PrinterLink
@@ -6,9 +6,7 @@ from .sale_category import SaleCategoryLink
class SectionPrinter(BaseModel):
sale_category: SaleCategoryLink | None
printer: PrinterLink | None
sale_category: SaleCategoryLink | None = None
printer: PrinterLink | None = None
copies: int = Field(ge=0)
class Config:
alias_generator = to_camel
model_config = ConfigDict(alias_generator=to_camel)
+2 -5
View File
@@ -1,4 +1,4 @@
from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict
from ..models.reporting_level import ReportingLevel
from ..models.voucher_type import VoucherType
@@ -12,7 +12,4 @@ class SettleOption(BaseModel):
reporting_level: ReportingLevel
has_reason: bool
is_fixture: bool
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
+2 -5
View File
@@ -1,6 +1,6 @@
import uuid
from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict
from . import to_camel
@@ -8,7 +8,4 @@ from . import to_camel
class Split(BaseModel):
inventories: list[uuid.UUID]
table_id: uuid.UUID
class Config:
alias_generator = to_camel
fields = {"id_": "id"}
model_config = ConfigDict(alias_generator=to_camel)
+6 -16
View File
@@ -1,6 +1,6 @@
import uuid
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field
from . import to_camel
from .section import SectionLink
@@ -12,17 +12,12 @@ class TableIn(BaseModel):
section: SectionLink
is_active: bool
sort_order: int
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class Table(TableIn):
id_: uuid.UUID
class Config:
alias_generator = to_camel
model_config = ConfigDict(alias_generator=to_camel)
class TableBlank(BaseModel):
@@ -30,15 +25,10 @@ class TableBlank(BaseModel):
seats: int
is_active: bool
sort_order: int
class Config:
alias_generator = to_camel
model_config = ConfigDict(alias_generator=to_camel)
class TableLink(BaseModel):
id_: uuid.UUID = Field(...)
name: str | None
class Config:
fields = {"id_": "id"}
alias_generator = to_camel
name: str | None = None
model_config = ConfigDict(alias_generator=to_camel)
+7 -18
View File
@@ -3,7 +3,7 @@ import uuid
from decimal import Decimal
from barker.schemas.regime import RegimeLink
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field
from . import to_camel
@@ -13,34 +13,23 @@ class TaxIn(BaseModel):
rate: Decimal = Field(ge=0, default=0)
regime: RegimeLink = Field(...)
is_fixture: bool
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class Tax(TaxIn):
id_: uuid.UUID
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class TaxBlank(BaseModel):
name: str
rate: Decimal = Field(ge=0, default=0)
is_fixture: bool
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class TaxLink(BaseModel):
id_: uuid.UUID = Field(...)
name: str | None
rate: Decimal | None
class Config:
fields = {"id_": "id"}
name: str | None = None
rate: Decimal | None = None
model_config = ConfigDict(alias_generator=to_camel)
+15 -12
View File
@@ -1,7 +1,7 @@
from datetime import date, datetime
from decimal import Decimal
from pydantic import BaseModel, validator
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
from . import to_camel
@@ -11,30 +11,33 @@ class TaxReportItem(BaseModel):
tax_rate: Decimal
sale_amount: Decimal
amount: Decimal
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class TaxReport(BaseModel):
start_date: date
finish_date: date
amounts: list[TaxReportItem]
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
json_encoders = {datetime: lambda v: v.strftime("%d-%b-%Y %H:%M"), date: lambda v: v.strftime("%d-%b-%Y")}
@validator("start_date", pre=True)
@field_validator("start_date", mode="before")
@classmethod
def parse_start_date(cls, value):
if isinstance(value, date):
return value
return datetime.strptime(value, "%d-%b-%Y").date()
@validator("finish_date", pre=True)
@field_serializer("start_date")
def serialize_start_date(self, value: date, _info):
return value.strftime("%d-%b-%Y")
@field_validator("finish_date", mode="before")
@classmethod
def parse_finish_date(cls, value):
if isinstance(value, date):
return value
return datetime.strptime(value, "%d-%b-%Y").date()
@field_serializer("finish_date")
def serialize_finish_date(self, value: date, _info):
return value.strftime("%d-%b-%Y")
+10 -10
View File
@@ -3,7 +3,7 @@ import uuid
from datetime import date, datetime
from decimal import Decimal
from pydantic import BaseModel, validator
from pydantic import BaseModel, ConfigDict, field_serializer, field_validator
from . import to_camel
@@ -13,22 +13,22 @@ class UpdateProductPricesItem(BaseModel):
name: str
old_price: Decimal
new_price: Decimal
class Config:
alias_generator = to_camel
model_config = ConfigDict(alias_generator=to_camel)
class UpdateProductPrices(BaseModel):
date_: date
menu_category_id: uuid.UUID | None
menu_category_id: uuid.UUID | None = None
items: list[UpdateProductPricesItem]
model_config = ConfigDict(alias_generator=to_camel)
class Config:
alias_generator = to_camel
json_encoders = {date: lambda v: v.strftime("%d-%b-%Y")}
@validator("date_", pre=True)
@field_validator("date_", mode="before")
@classmethod
def parse_date(cls, value):
if isinstance(value, date):
return value
return datetime.strptime(value, "%d-%b-%Y").date()
@field_serializer("date_")
def serialize_date(self, value: date, _info):
return value.strftime("%d-%b-%Y")
+13 -23
View File
@@ -4,7 +4,7 @@ from datetime import datetime
from barker.schemas import to_camel
from barker.schemas.role import RoleItem
from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict, field_serializer
class UserIn(BaseModel):
@@ -12,34 +12,23 @@ class UserIn(BaseModel):
password: str
locked_out: bool
roles: list[RoleItem]
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class User(UserIn):
id_: uuid.UUID
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class UserMe(UserIn):
id_: str
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class UserLink(BaseModel):
id_: uuid.UUID | None
name: str | None
class Config:
fields = {"id_": "id"}
id_: uuid.UUID | None = None
name: str | None = None
model_config = ConfigDict(alias_generator=to_camel)
class UserList(BaseModel):
@@ -47,9 +36,10 @@ class UserList(BaseModel):
name: str
roles: list[str]
last_device: str
last_date: datetime | None
last_date: datetime | None = None
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
json_encoders = {datetime: lambda v: v.strftime("%d-%b-%Y %H:%M")}
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
@field_serializer("last_date")
def serialize_last_date(self, value: datetime | None, _info):
return None if value is None else value.strftime("%d-%b-%Y %H:%M")
+16 -33
View File
@@ -2,7 +2,7 @@ import uuid
from decimal import Decimal
from pydantic import BaseModel, Field, validator
from pydantic import BaseModel, ConfigDict, Field, model_validator
from . import to_camel
from .customer import CustomerLink
@@ -13,55 +13,38 @@ from .tax import TaxLink
class Inventory(BaseModel):
id_: uuid.UUID | None
id_: uuid.UUID | None = None
product: ProductLink
quantity: Decimal
price: Decimal | None
tax: TaxLink | None
tax_rate: Decimal | None
price: Decimal | None = None
tax: TaxLink | None = None
tax_rate: Decimal | None = None
discount: Decimal = Field(ge=0, multiple_of=0.00001, le=1)
is_happy_hour: bool
modifiers: list[ModifierLink]
amount: Decimal | None
amount: Decimal | None = None
model_config = ConfigDict(alias_generator=to_camel)
class Config:
alias_generator = to_camel
@validator("amount", always=True)
def calculate_amount(cls, v, values):
is_happy_hour = values["is_happy_hour"] if "is_happy_hour" in values else False
price = values["price"] if "price" in values and not is_happy_hour else 0
quantity = values["quantity"] if "quantity" in values else 0
discount = values["discount"] if "discount" in values else 0
tax_rate = values["tax_rate"] if "tax_rate" in values else 0
return round(Decimal(price * quantity * (1 - discount) * (1 + tax_rate)), 2)
@model_validator(mode="after")
def calculate_amount(self) -> "Inventory":
self.amount = round(Decimal(self.price * self.quantity * (1 - self.discount) * (1 + self.tax_rate)), 2)
return self
class Kot(BaseModel):
id_: uuid.UUID | None
id_: uuid.UUID | None = None
inventories: list[Inventory]
class Config:
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class VoucherIn(BaseModel):
pax: int
table: TableLink
customer: CustomerLink | None
customer: CustomerLink | None = None
kots: list[Kot]
class Config:
fields = {"id_": "id"}
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
class Voucher(VoucherIn):
id_: uuid.UUID
class Config:
fields = {"id_": "id"}
anystr_strip_whitespace = True
alias_generator = to_camel
model_config = ConfigDict(str_strip_whitespace=True, alias_generator=to_camel)
+14 -14
View File
@@ -7,30 +7,30 @@ authors = ["tanshu <git@tanshu.com>"]
[tool.poetry.dependencies]
python = "^3.11"
uvicorn = {extras = ["standard"], version = "^0.21.1"}
fastapi = "^0.95.0"
fastapi = {extras = ["all"], version = "^0.100.0"}
python-jose = {extras = ["cryptography"], version = "^3.3.0"}
passlib = {extras = ["bcrypt"], version = "^1.7.4"}
psycopg2-binary = "^2.9.5"
SQLAlchemy = "^2.0.7"
psycopg2-binary = "^2.9.6"
SQLAlchemy = "^2.0.19"
python-multipart = "^0.0.6"
PyJWT = "^2.6.0"
alembic = "^1.10.2"
PyJWT = "^2.8.0"
alembic = "^1.11.1"
itsdangerous = "^2.1.2"
python-dotenv = "^1.0.0"
pydantic = {extras = ["dotenv"], version = "^1.10.7"}
starlette = "^0.26.1"
pydantic = {extras = ["dotenv"], version = "^2.0.3"}
starlette = "^0.27.0"
arq = "^0.25.0"
aiohttp = "^3.8.4"
cryptography = "^40.0.1"
gunicorn = "^20.1.0"
aiohttp = "^3.8.5"
cryptography = "^41.0.2"
gunicorn = "^21.2.0"
[tool.poetry.dev-dependencies]
flake8 = "^6.0.0"
black = "^23.1.0"
black = "^23.7.0"
isort = {extras = ["toml"], version = "^5.12.0"}
pre-commit = "^3.2.0"
mypy = "^1.1.1"
types-python-jose = "^3.3.4.5"
pre-commit = "^3.3.3"
mypy = "^1.4.1"
types-python-jose = "^3.3.4.8"
[tool.poetry.group.dev.dependencies]
tomli = "^2.0.1"
-1
View File
@@ -13,7 +13,6 @@
"plugin:@typescript-eslint/recommended",
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates",
"plugin:@angular-eslint/recommended--extra",
"prettier"
],
"plugins": [
-1
View File
@@ -1,5 +1,4 @@
module.exports = {
trailingComma: "all",
tabWidth: 2,
semi: true,
singleQuote: true,
+38 -38
View File
@@ -13,54 +13,54 @@
},
"private": true,
"dependencies": {
"@angular/animations": "^15.1.0",
"@angular/cdk": "^15.1.5",
"@angular/common": "^15.1.0",
"@angular/compiler": "^15.1.0",
"@angular/core": "^15.1.0",
"@angular/forms": "^15.1.0",
"@angular/material": "^15.1.5",
"@angular/material-moment-adapter": "^15.1.5",
"@angular/platform-browser": "^15.1.0",
"@angular/platform-browser-dynamic": "^15.1.0",
"@angular/router": "^15.1.0",
"mathjs": "^11.5.1",
"@angular/animations": "^16.1.6",
"@angular/cdk": "^16.1.5",
"@angular/common": "^16.1.6",
"@angular/compiler": "^16.1.6",
"@angular/core": "^16.1.6",
"@angular/forms": "^16.1.6",
"@angular/material": "^16.1.5",
"@angular/material-moment-adapter": "^16.1.5",
"@angular/platform-browser": "^16.1.6",
"@angular/platform-browser-dynamic": "^16.1.6",
"@angular/router": "^16.1.6",
"mathjs": "^11.9.0",
"moment": "^2.29.4",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.12.0"
"tslib": "^2.6.0",
"zone.js": "^0.13.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "^15.1.6",
"@angular-eslint/builder": "^15.2.1",
"@angular-eslint/eslint-plugin": "^15.2.1",
"@angular-eslint/eslint-plugin-template": "^15.2.1",
"@angular-eslint/schematics": "^15.2.1",
"@angular-eslint/template-parser": "^15.2.1",
"@angular/cli": "^15.1.6",
"@angular/compiler-cli": "^15.1.0",
"@types/jasmine": "~4.3.0",
"@typescript-eslint/eslint-plugin": "^5.52.0",
"@typescript-eslint/parser": "^5.52.0",
"@angular-devkit/build-angular": "^16.1.5",
"@angular-eslint/builder": "^16.1.0",
"@angular-eslint/eslint-plugin": "^16.1.0",
"@angular-eslint/eslint-plugin-template": "^16.1.0",
"@angular-eslint/schematics": "^16.1.0",
"@angular-eslint/template-parser": "^16.1.0",
"@angular/cli": "^16.1.5",
"@angular/compiler-cli": "^16.1.6",
"@types/jasmine": "~4.3.5",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"autoprefixer": "^10.4.13",
"eslint": "^8.34.0",
"eslint-config-prettier": "^8.7.0",
"eslint": "^8.39.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-unused-imports": "^2.0.0",
"eslint-plugin-unused-imports": "^3.0.0",
"husky": "^8.0.3",
"jasmine-core": "~4.5.0",
"jasmine-core": "5.0.1",
"jasmine-spec-reporter": "^7.0.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.1.1",
"karma-coverage": "~2.2.0",
"karma": "^6.4.2",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "^2.2.1",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.0.0",
"lint-staged": "^13.1.2",
"postcss": "^8.4.21",
"prettier": "^2.8.4",
"karma-jasmine-html-reporter": "~2.1.0",
"lint-staged": "^13.2.3",
"postcss": "^8.4.27",
"prettier": "^3.0.0",
"standard-version": "^9.5.0",
"tailwindcss": "^3.2.7",
"typescript": "~4.9.4"
"tailwindcss": "^3.3.3",
"typescript": "~5.1.3"
},
"husky": {
"hooks": {
+7 -3
View File
@@ -1,13 +1,17 @@
import { Injectable } from '@angular/core';
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { Router, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { ToasterService } from '../core/toaster.service';
import { AuthService } from './auth.service';
@Injectable({ providedIn: 'root' })
export class AuthGuard implements CanActivate {
constructor(private router: Router, private authService: AuthService, private toaster: ToasterService) {}
export class AuthGuard {
constructor(
private router: Router,
private authService: AuthService,
private toaster: ToasterService,
) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
const { user } = this.authService;
+4 -1
View File
@@ -19,7 +19,10 @@ export class AuthService {
public device: Device;
private currentUserSubject: BehaviorSubject<User | null> = new BehaviorSubject<User | null>(null);
constructor(private http: HttpClient, private cs: CookieService) {
constructor(
private http: HttpClient,
private cs: CookieService,
) {
this.checkStorage();
this.currentUser = this.currentUserSubject.asObservable();
const deviceId = this.cs.getCookie('device_id');
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { BeerSaleReport } from './beer-sale-report';
@@ -8,7 +8,7 @@ import { BeerSaleReportService } from './beer-sale-report.service';
@Injectable({
providedIn: 'root',
})
export class BeerSaleReportResolver implements Resolve<BeerSaleReport> {
export class BeerSaleReportResolver {
constructor(private ser: BeerSaleReportService) {}
resolve(route: ActivatedRouteSnapshot): Observable<BeerSaleReport> {
@@ -29,7 +29,11 @@ export class BeerSaleReportComponent implements OnInit {
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns: string[] = ['date'];
constructor(private route: ActivatedRoute, private router: Router, private toCsv: ToCsvService) {
constructor(
private route: ActivatedRoute,
private router: Router,
private toCsv: ToCsvService,
) {
// Create form
this.form = new FormGroup({
startDate: new FormControl(new Date(), { nonNullable: true }),
@@ -14,7 +14,10 @@ const serviceName = 'BeerSaleReportService';
providedIn: 'root',
})
export class BeerSaleReportService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
constructor(
private http: HttpClient,
private log: ErrorLoggerService,
) {}
get(
startDate: string | null,
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { BillSettlementReport } from './bill-settlement-report';
@@ -8,7 +8,7 @@ import { BillSettlementReportService } from './bill-settlement-report.service';
@Injectable({
providedIn: 'root',
})
export class BillSettlementReportResolver implements Resolve<BillSettlementReport> {
export class BillSettlementReportResolver {
constructor(private ser: BillSettlementReportService) {}
resolve(route: ActivatedRouteSnapshot): Observable<BillSettlementReport> {
@@ -53,7 +53,7 @@
<!-- Amount Column -->
<ng-container matColumnDef="amount">
<mat-header-cell *matHeaderCellDef class="right">Amount</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.amount | number : '1.2-2' }}</mat-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.amount | number: '1.2-2' }}</mat-cell>
</ng-container>
<!-- Settlement Column -->
@@ -25,7 +25,11 @@ export class BillSettlementReportComponent implements OnInit {
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['date', 'billId', 'amount', 'settlement'];
constructor(private route: ActivatedRoute, private router: Router, private toCsv: ToCsvService) {
constructor(
private route: ActivatedRoute,
private router: Router,
private toCsv: ToCsvService,
) {
// Create form
this.form = new FormGroup({
startDate: new FormControl(new Date(), { nonNullable: true }),
@@ -14,7 +14,10 @@ const serviceName = 'BillSettlementReportService';
providedIn: 'root',
})
export class BillSettlementReportService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
constructor(
private http: HttpClient,
private log: ErrorLoggerService,
) {}
get(startDate: string | null, finishDate: string | null): Observable<BillSettlementReport> {
const options = { params: new HttpParams() };
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { User } from '../core/user';
@@ -9,7 +9,7 @@ import { CashierReportService } from './cashier-report.service';
@Injectable({
providedIn: 'root',
})
export class ActiveCashiersResolver implements Resolve<User[]> {
export class ActiveCashiersResolver {
constructor(private ser: CashierReportService) {}
resolve(route: ActivatedRouteSnapshot): Observable<User[]> {
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { CashierReport } from './cashier-report';
@@ -8,7 +8,7 @@ import { CashierReportService } from './cashier-report.service';
@Injectable({
providedIn: 'root',
})
export class CashierReportResolver implements Resolve<CashierReport> {
export class CashierReportResolver {
constructor(private ser: CashierReportService) {}
resolve(route: ActivatedRouteSnapshot): Observable<CashierReport> {
@@ -62,7 +62,7 @@
<!-- Amount Column -->
<ng-container matColumnDef="amount">
<mat-header-cell *matHeaderCellDef class="right">Amount</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.amount | currency : 'INR' }}</mat-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.amount | currency: 'INR' }}</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
@@ -15,7 +15,10 @@ const serviceName = 'CashierReportService';
providedIn: 'root',
})
export class CashierReportService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
constructor(
private http: HttpClient,
private log: ErrorLoggerService,
) {}
list(id: string | null, startDate: string | null, finishDate: string | null): Observable<CashierReport> {
const listUrl = id === null ? url : `${url}/${id}`;
@@ -39,7 +39,7 @@
<mat-label>Discount on {{ r.name }}</mat-label>
<input matInput formControlName="discount" />
<span matSuffix>%</span>
<mat-hint>Max {{ r.limit | percent : '1.2-2' }}</mat-hint>
<mat-hint>Max {{ r.limit | percent: '1.2-2' }}</mat-hint>
</mat-form-field>
</div>
</div>
@@ -1,5 +1,4 @@
import { Injectable } from '@angular/core';
import { Resolve } from '@angular/router';
import { Observable } from 'rxjs';
import { Customer } from '../core/customer';
@@ -9,7 +8,7 @@ import { CustomerService } from './customer.service';
@Injectable({
providedIn: 'root',
})
export class CustomerListResolver implements Resolve<Customer[]> {
export class CustomerListResolver {
constructor(private ser: CustomerService) {}
resolve(): Observable<Customer[]> {
@@ -42,7 +42,7 @@
<mat-cell *matCellDef="let row">
<ul>
<li *ngFor="let discount of row.discounts">
{{ discount.name }} - {{ discount.discount | percent : '1.2-2' }}
{{ discount.name }} - {{ discount.discount | percent: '1.2-2' }}
</li>
</ul>
</mat-cell>
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { Customer } from '../core/customer';
@@ -9,7 +9,7 @@ import { CustomerService } from './customer.service';
@Injectable({
providedIn: 'root',
})
export class CustomerResolver implements Resolve<Customer> {
export class CustomerResolver {
constructor(private ser: CustomerService) {}
resolve(route: ActivatedRouteSnapshot): Observable<Customer> {
+4 -1
View File
@@ -16,7 +16,10 @@ const serviceName = 'CustomerService';
providedIn: 'root',
})
export class CustomerService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
constructor(
private http: HttpClient,
private log: ErrorLoggerService,
) {}
get(id: string | null): Observable<Customer> {
const getUrl: string = id === null ? `${url}` : `${url}/${id}`;
@@ -1,5 +1,4 @@
import { Injectable } from '@angular/core';
import { Resolve } from '@angular/router';
import { Observable } from 'rxjs';
import { Device } from '../core/device';
@@ -9,7 +8,7 @@ import { DeviceService } from './device.service';
@Injectable({
providedIn: 'root',
})
export class DeviceListResolver implements Resolve<Device[]> {
export class DeviceListResolver {
constructor(private ser: DeviceService) {}
resolve(): Observable<Device[]> {
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { Device } from '../core/device';
@@ -9,7 +9,7 @@ import { DeviceService } from './device.service';
@Injectable({
providedIn: 'root',
})
export class DeviceResolver implements Resolve<Device> {
export class DeviceResolver {
constructor(private ser: DeviceService) {}
resolve(route: ActivatedRouteSnapshot): Observable<Device> {
+4 -1
View File
@@ -13,7 +13,10 @@ const serviceName = 'DeviceService';
providedIn: 'root',
})
export class DeviceService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
constructor(
private http: HttpClient,
private log: ErrorLoggerService,
) {}
get(id: string | null): Observable<Device> {
const getUrl: string = id === null ? `${url}` : `${url}/${id}`;
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { DiscountReport } from './discount-report';
@@ -8,7 +8,7 @@ import { DiscountReportService } from './discount-report.service';
@Injectable({
providedIn: 'root',
})
export class DiscountReportResolver implements Resolve<DiscountReport> {
export class DiscountReportResolver {
constructor(private ser: DiscountReportService) {}
resolve(route: ActivatedRouteSnapshot): Observable<DiscountReport> {
@@ -51,7 +51,7 @@
<!-- Amount Column -->
<ng-container matColumnDef="amount">
<mat-header-cell *matHeaderCellDef class="right">Amount</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.amount | currency : 'INR' }}</mat-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.amount | currency: 'INR' }}</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns"></mat-row>
@@ -14,7 +14,10 @@ const serviceName = 'DiscountReportService';
providedIn: 'root',
})
export class DiscountReportService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
constructor(
private http: HttpClient,
private log: ErrorLoggerService,
) {}
get(startDate: string | null, finishDate: string | null): Observable<DiscountReport> {
const options = { params: new HttpParams() };
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { GuestBook } from './guest-book';
@@ -8,7 +8,7 @@ import { GuestBookService } from './guest-book.service';
@Injectable({
providedIn: 'root',
})
export class GuestBookDetailResolver implements Resolve<GuestBook> {
export class GuestBookDetailResolver {
constructor(private ser: GuestBookService) {}
resolve(route: ActivatedRouteSnapshot): Observable<GuestBook> {
@@ -1,5 +1,4 @@
import { Injectable } from '@angular/core';
import { Resolve } from '@angular/router';
import { Observable } from 'rxjs';
import { GuestBookList } from './guest-book-list';
@@ -8,7 +7,7 @@ import { GuestBookService } from './guest-book.service';
@Injectable({
providedIn: 'root',
})
export class GuestBookListResolver implements Resolve<GuestBookList> {
export class GuestBookListResolver {
constructor(private ser: GuestBookService) {}
resolve(): Observable<GuestBookList> {
@@ -17,7 +17,10 @@ const serviceName = 'GuestBookService';
@Injectable({ providedIn: 'root' })
export class GuestBookService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
constructor(
private http: HttpClient,
private log: ErrorLoggerService,
) {}
get(id: string | null): Observable<GuestBook> {
const getUrl: string = id === null ? url : `${url}/${id}`;
@@ -1,5 +1,4 @@
import { Injectable } from '@angular/core';
import { Resolve } from '@angular/router';
import { Observable } from 'rxjs';
import { HeaderFooter } from './header-footer';
@@ -8,7 +7,7 @@ import { HeaderFooterService } from './header-footer.service';
@Injectable({
providedIn: 'root',
})
export class HeaderFooterResolver implements Resolve<HeaderFooter[]> {
export class HeaderFooterResolver {
constructor(private ser: HeaderFooterService) {}
resolve(): Observable<HeaderFooter[]> {
@@ -17,7 +17,10 @@ const serviceName = 'HeaderFooterService';
providedIn: 'root',
})
export class HeaderFooterService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
constructor(
private http: HttpClient,
private log: ErrorLoggerService,
) {}
list(): Observable<HeaderFooter[]> {
return this.http.get<HeaderFooter[]>(url).pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<
@@ -1,5 +1,4 @@
import { Injectable } from '@angular/core';
import { Resolve } from '@angular/router';
import { Observable } from 'rxjs';
import { MenuCategory } from '../core/menu-category';
@@ -9,7 +8,7 @@ import { MenuCategoryService } from './menu-category.service';
@Injectable({
providedIn: 'root',
})
export class MenuCategoryListResolver implements Resolve<MenuCategory[]> {
export class MenuCategoryListResolver {
constructor(private ser: MenuCategoryService) {}
resolve(): Observable<MenuCategory[]> {
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { MenuCategory } from '../core/menu-category';
@@ -9,7 +9,7 @@ import { MenuCategoryService } from './menu-category.service';
@Injectable({
providedIn: 'root',
})
export class MenuCategoryResolver implements Resolve<MenuCategory> {
export class MenuCategoryResolver {
constructor(private ser: MenuCategoryService) {}
resolve(route: ActivatedRouteSnapshot): Observable<MenuCategory> {
@@ -16,7 +16,10 @@ const serviceName = 'MenuCategoryService';
providedIn: 'root',
})
export class MenuCategoryService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
constructor(
private http: HttpClient,
private log: ErrorLoggerService,
) {}
get(id: string | null): Observable<MenuCategory> {
const getUrl: string = id === null ? url : `${url}/${id}`;
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { MenuEngineeringReport } from './menu-engineering-report';
@@ -8,7 +8,7 @@ import { MenuEngineeringReportService } from './menu-engineering-report.service'
@Injectable({
providedIn: 'root',
})
export class MenuEngineeringReportResolver implements Resolve<MenuEngineeringReport> {
export class MenuEngineeringReportResolver {
constructor(private ser: MenuEngineeringReportService) {}
resolve(route: ActivatedRouteSnapshot): Observable<MenuEngineeringReport> {
@@ -62,7 +62,7 @@
<ng-container matColumnDef="price">
<mat-header-cell *matHeaderCellDef mat-sort-header class="right">Price</mat-header-cell>
<mat-cell *matCellDef="let row" class="right"
>{{ row.average | number : '1.2-2' }} / {{ row.price | number : '1.2-2' }}</mat-cell
>{{ row.average | number: '1.2-2' }} / {{ row.price | number: '1.2-2' }}</mat-cell
>
</ng-container>
@@ -82,7 +82,7 @@
<ng-container matColumnDef="quantity">
<mat-header-cell *matHeaderCellDef mat-sort-header class="right">Quantity</mat-header-cell>
<mat-cell *matCellDef="let row" class="right"
>{{ row.quantity | number : '1.2-2' }} ({{ row.quantityPercent | percent : '1.2-2' }})</mat-cell
>{{ row.quantity | number: '1.2-2' }} ({{ row.quantityPercent | percent: '1.2-2' }})</mat-cell
>
</ng-container>
@@ -90,7 +90,7 @@
<ng-container matColumnDef="sales">
<mat-header-cell *matHeaderCellDef mat-sort-header class="right">Sales</mat-header-cell>
<mat-cell *matCellDef="let row" class="right"
>{{ row.sales | number : '1.2-2' }} ({{ row.salesPercent | percent : '1.2-2' }})</mat-cell
>{{ row.sales | number: '1.2-2' }} ({{ row.salesPercent | percent: '1.2-2' }})</mat-cell
>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
@@ -14,7 +14,10 @@ const serviceName = 'MenuEngineeringReportService';
providedIn: 'root',
})
export class MenuEngineeringReportService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
constructor(
private http: HttpClient,
private log: ErrorLoggerService,
) {}
get(startDate: string | null, finishDate: string | null): Observable<MenuEngineeringReport> {
const options = { params: new HttpParams() };
@@ -1,5 +1,4 @@
import { Injectable } from '@angular/core';
import { Resolve } from '@angular/router';
import { Observable } from 'rxjs';
import { ModifierCategory } from '../core/modifier-category';
@@ -9,7 +8,7 @@ import { ModifierCategoryService } from './modifier-category.service';
@Injectable({
providedIn: 'root',
})
export class ModifierCategoryListResolver implements Resolve<ModifierCategory[]> {
export class ModifierCategoryListResolver {
constructor(private ser: ModifierCategoryService) {}
resolve(): Observable<ModifierCategory[]> {
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { ModifierCategory } from '../core/modifier-category';
@@ -9,7 +9,7 @@ import { ModifierCategoryService } from './modifier-category.service';
@Injectable({
providedIn: 'root',
})
export class ModifierCategoryResolver implements Resolve<ModifierCategory> {
export class ModifierCategoryResolver {
constructor(private ser: ModifierCategoryService) {}
resolve(route: ActivatedRouteSnapshot): Observable<ModifierCategory> {
@@ -16,7 +16,10 @@ const serviceName = 'ModifierCategoryService';
providedIn: 'root',
})
export class ModifierCategoryService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
constructor(
private http: HttpClient,
private log: ErrorLoggerService,
) {}
get(id: string | null): Observable<ModifierCategory> {
const getUrl: string = id === null ? url : `${url}/${id}`;
@@ -1,5 +1,4 @@
import { Injectable } from '@angular/core';
import { Resolve } from '@angular/router';
import { Observable } from 'rxjs';
import { Modifier } from '../core/modifier';
@@ -9,7 +8,7 @@ import { ModifierService } from './modifier.service';
@Injectable({
providedIn: 'root',
})
export class ModifierListResolver implements Resolve<Modifier[]> {
export class ModifierListResolver {
constructor(private ser: ModifierService) {}
resolve(): Observable<Modifier[]> {
@@ -10,7 +10,10 @@ export class ModifierListDataSource extends DataSource<Modifier> {
public viewData: Modifier[];
private filterValue: string;
constructor(private readonly filter: Observable<string>, private readonly dataObs: Observable<Modifier[]>) {
constructor(
private readonly filter: Observable<string>,
private readonly dataObs: Observable<Modifier[]>,
) {
super();
this.data = [];
this.viewData = [];
@@ -49,7 +49,7 @@
<!-- Price Column -->
<ng-container matColumnDef="price">
<mat-header-cell *matHeaderCellDef>Price</mat-header-cell>
<mat-cell *matCellDef="let row">{{ row.price | currency : 'INR' }}</mat-cell>
<mat-cell *matCellDef="let row">{{ row.price | currency: 'INR' }}</mat-cell>
</ng-container>
<!-- Modifier Category Column -->
@@ -29,7 +29,10 @@ export class ModifierListComponent implements OnInit {
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns: string[] = ['name', 'showInBill', 'price', 'isActive', 'modifierCategory'];
constructor(private route: ActivatedRoute, private router: Router) {
constructor(
private route: ActivatedRoute,
private router: Router,
) {
this.form = new FormGroup({
modifierCategory: new FormControl<string | null>(''),
});
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { Modifier } from '../core/modifier';
@@ -9,7 +9,7 @@ import { ModifierService } from './modifier.service';
@Injectable({
providedIn: 'root',
})
export class ModifierResolver implements Resolve<Modifier> {
export class ModifierResolver {
constructor(private ser: ModifierService) {}
resolve(route: ActivatedRouteSnapshot): Observable<Modifier> {
+4 -1
View File
@@ -15,7 +15,10 @@ const serviceName = 'ModifierService';
@Injectable({ providedIn: 'root' })
export class ModifierService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
constructor(
private http: HttpClient,
private log: ErrorLoggerService,
) {}
get(id: string | null): Observable<Modifier> {
const getUrl: string = id === null ? url : `${url}/${id}`;
+4 -1
View File
@@ -9,7 +9,10 @@ import { AuthService } from '../auth/auth.service';
styleUrls: ['./nav-bar.component.css'],
})
export class NavBarComponent {
constructor(private router: Router, public auth: AuthService) {}
constructor(
private router: Router,
public auth: AuthService,
) {}
logout() {
this.auth.logout();
@@ -1,5 +1,4 @@
import { Injectable } from '@angular/core';
import { Resolve } from '@angular/router';
import { Observable } from 'rxjs';
import { Printer } from '../core/printer';
@@ -9,7 +8,7 @@ import { PrinterService } from './printer.service';
@Injectable({
providedIn: 'root',
})
export class PrinterListResolver implements Resolve<Printer[]> {
export class PrinterListResolver {
constructor(private ser: PrinterService) {}
resolve(): Observable<Printer[]> {
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { Printer } from '../core/printer';
@@ -9,7 +9,7 @@ import { PrinterService } from './printer.service';
@Injectable({
providedIn: 'root',
})
export class PrinterResolver implements Resolve<Printer> {
export class PrinterResolver {
constructor(private ser: PrinterService) {}
resolve(route: ActivatedRouteSnapshot): Observable<Printer> {
+4 -1
View File
@@ -16,7 +16,10 @@ const serviceName = 'PrinterService';
providedIn: 'root',
})
export class PrinterService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
constructor(
private http: HttpClient,
private log: ErrorLoggerService,
) {}
get(id: string | null): Observable<Printer> {
const getUrl: string = id === null ? url : `${url}/${id}`;
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { ProductSaleReport } from './product-sale-report';
@@ -8,7 +8,7 @@ import { ProductSaleReportService } from './product-sale-report.service';
@Injectable({
providedIn: 'root',
})
export class ProductSaleReportResolver implements Resolve<ProductSaleReport> {
export class ProductSaleReportResolver {
constructor(private ser: ProductSaleReportService) {}
resolve(route: ActivatedRouteSnapshot): Observable<ProductSaleReport> {
@@ -51,31 +51,31 @@
<!-- Unbilled Column -->
<ng-container matColumnDef="unbilled">
<mat-header-cell *matHeaderCellDef class="right">Unbilled</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.kot | number : '1.2-2' }}</mat-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.kot | number: '1.2-2' }}</mat-cell>
</ng-container>
<!-- Sale Column -->
<ng-container matColumnDef="sale">
<mat-header-cell *matHeaderCellDef class="right">Sale</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.regularBill | number : '1.2-2' }}</mat-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.regularBill | number: '1.2-2' }}</mat-cell>
</ng-container>
<!-- No Charge Column -->
<ng-container matColumnDef="noCharge">
<mat-header-cell *matHeaderCellDef class="right">No Charge</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.noCharge | number : '1.2-2' }}</mat-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.noCharge | number: '1.2-2' }}</mat-cell>
</ng-container>
<!-- Staff Column -->
<ng-container matColumnDef="staff">
<mat-header-cell *matHeaderCellDef class="right">Staff</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.staff | number : '1.2-2' }}</mat-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.staff | number: '1.2-2' }}</mat-cell>
</ng-container>
<!-- Cancelled Column -->
<ng-container matColumnDef="cancel">
<mat-header-cell *matHeaderCellDef class="right">Cancelled</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.cancel | number : '1.2-2' }}</mat-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.cancel | number: '1.2-2' }}</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
@@ -14,7 +14,10 @@ const serviceName = 'ProductSaleReportService';
providedIn: 'root',
})
export class ProductSaleReportService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
constructor(
private http: HttpClient,
private log: ErrorLoggerService,
) {}
get(startDate: string | null, finishDate: string | null): Observable<ProductSaleReport> {
const options = { params: new HttpParams() };
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { ProductUpdatesReport } from './product-updates-report';
@@ -8,7 +8,7 @@ import { ProductUpdatesReportService } from './product-updates-report.service';
@Injectable({
providedIn: 'root',
})
export class ProductUpdatesReportResolver implements Resolve<ProductUpdatesReport> {
export class ProductUpdatesReportResolver {
constructor(private ser: ProductUpdatesReportService) {}
resolve(route: ActivatedRouteSnapshot): Observable<ProductUpdatesReport> {
@@ -24,7 +24,11 @@ export class ProductUpdatesReportComponent implements OnInit {
/** Columns displayed in the table. Columns IDs can be added, removed, or reordered. */
displayedColumns = ['details'];
constructor(private route: ActivatedRoute, private router: Router, private toCsv: ToCsvService) {
constructor(
private route: ActivatedRoute,
private router: Router,
private toCsv: ToCsvService,
) {
// Create form
this.form = new FormGroup({
startDate: new FormControl(new Date(), { nonNullable: true }),
@@ -14,7 +14,10 @@ const serviceName = 'ProductUpdatesReportService';
providedIn: 'root',
})
export class ProductUpdatesReportService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
constructor(
private http: HttpClient,
private log: ErrorLoggerService,
) {}
get(startDate: string | null, finishDate: string | null): Observable<ProductUpdatesReport> {
const options = { params: new HttpParams() };
@@ -1,5 +1,4 @@
import { Injectable } from '@angular/core';
import { Resolve } from '@angular/router';
import { Observable } from 'rxjs';
import { Product } from '../core/product';
@@ -9,7 +8,7 @@ import { ProductService } from './product.service';
@Injectable({
providedIn: 'root',
})
export class ProductListResolver implements Resolve<Product[]> {
export class ProductListResolver {
constructor(private ser: ProductService) {}
resolve(): Observable<Product[]> {
@@ -56,7 +56,7 @@
<!-- Price Column -->
<ng-container matColumnDef="price">
<mat-header-cell *matHeaderCellDef class="right">Price</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.price | currency : 'INR' }}</mat-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.price | currency: 'INR' }}</mat-cell>
</ng-container>
<!-- Menu Category Column -->
@@ -95,7 +95,7 @@
<!-- Quantity Column -->
<ng-container matColumnDef="quantity">
<mat-header-cell *matHeaderCellDef class="right">Quantity</mat-header-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.quantity | number : '1.2-2' }}</mat-cell>
<mat-cell *matCellDef="let row" class="right">{{ row.quantity | number: '1.2-2' }}</mat-cell>
</ng-container>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { Product } from '../core/product';
@@ -9,7 +9,7 @@ import { ProductService } from './product.service';
@Injectable({
providedIn: 'root',
})
export class ProductResolver implements Resolve<Product> {
export class ProductResolver {
constructor(private ser: ProductService) {}
resolve(route: ActivatedRouteSnapshot): Observable<Product> {
+4 -1
View File
@@ -15,7 +15,10 @@ const serviceName = 'ProductService';
@Injectable({ providedIn: 'root' })
export class ProductService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
constructor(
private http: HttpClient,
private log: ErrorLoggerService,
) {}
get(id: string | null): Observable<Product> {
const getUrl: string = id === null ? `${url}` : `${url}/${id}`;
@@ -1,5 +1,4 @@
import { Injectable } from '@angular/core';
import { Resolve } from '@angular/router';
import { Observable } from 'rxjs';
import { Regime } from '../core/regime';
@@ -9,7 +8,7 @@ import { RegimeService } from './regime.service';
@Injectable({
providedIn: 'root',
})
export class RegimeListResolver implements Resolve<Regime[]> {
export class RegimeListResolver {
constructor(private ser: RegimeService) {}
resolve(): Observable<Regime[]> {
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
import { ActivatedRouteSnapshot } from '@angular/router';
import { Observable } from 'rxjs';
import { Regime } from '../core/regime';
@@ -9,7 +9,7 @@ import { RegimeService } from './regime.service';
@Injectable({
providedIn: 'root',
})
export class RegimeResolver implements Resolve<Regime> {
export class RegimeResolver {
constructor(private ser: RegimeService) {}
resolve(route: ActivatedRouteSnapshot): Observable<Regime> {
+4 -1
View File
@@ -16,7 +16,10 @@ const serviceName = 'RegimeService';
providedIn: 'root',
})
export class RegimeService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
constructor(
private http: HttpClient,
private log: ErrorLoggerService,
) {}
get(id: number | null): Observable<Regime> {
const getUrl: string = id === null ? url : `${url}/${id}`;
Loaded 100 of 161 files, more files were not shown because too many files have changed in this diff. Show more