Added all the fields to case detail

This commit is contained in:
Amritanshu Agrawal 2021-01-12 11:54:50 +05:30
parent 789722c0a9
commit 0233e7145b
8 changed files with 214 additions and 1044 deletions

View File

@ -1,131 +0,0 @@
# import uuid
#
# from typing import List
#
# import barker.schemas.printer as schemas
#
# from fastapi import APIRouter, Depends, HTTPException, Security, status
# from sqlalchemy.exc import SQLAlchemyError
# from sqlalchemy.orm import Session
#
# from ..core.security import get_current_active_user as get_user
# from ..db.session import SessionLocal
# from ..models.master import Printer
# from ..schemas.user_token import UserToken
#
#
# router = APIRouter()
#
#
# # Dependency
# def get_db():
# try:
# db = SessionLocal()
# yield db
# finally:
# db.close()
#
#
# @router.post("", response_model=schemas.Printer)
# def save(
# data: schemas.PrinterIn,
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["printers"]),
# ) -> schemas.Printer:
# try:
# item = Printer(name=data.name, address=data.address, cut_code=data.cut_code)
# db.add(item)
# db.commit()
# return printer_info(item)
# except SQLAlchemyError as e:
# db.rollback()
# raise HTTPException(
# status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
# detail=str(e),
# )
# except Exception:
# db.rollback()
# raise
#
#
# @router.put("/{id_}", response_model=schemas.Printer)
# def update(
# id_: uuid.UUID,
# data: schemas.PrinterIn,
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["printers"]),
# ) -> schemas.Printer:
# try:
# item: Printer = db.query(Printer).filter(Printer.id == id_).first()
# item.name = data.name
# item.address = data.address
# item.cut_code = data.cut_code
# db.commit()
# return printer_info(item)
# except SQLAlchemyError as e:
# db.rollback()
# raise HTTPException(
# status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
# detail=str(e),
# )
# except Exception:
# db.rollback()
# raise
#
#
# @router.delete("/{id_}", response_model=schemas.PrinterBlank)
# def delete(
# id_: uuid.UUID,
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["printers"]),
# ) -> schemas.PrinterBlank:
# try:
# item: Printer = db.query(Printer).filter(Printer.id == id_).first()
# db.delete(item)
# db.commit()
# return printer_blank()
# except SQLAlchemyError as e:
# db.rollback()
# raise HTTPException(
# status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
# detail=str(e),
# )
# except Exception:
# db.rollback()
# raise
#
#
# @router.get("", response_model=schemas.PrinterBlank)
# def show_blank(
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["printers"]),
# ) -> schemas.PrinterBlank:
# return printer_blank()
#
#
# @router.get("/list", response_model=List[schemas.Printer])
# def show_list(db: Session = Depends(get_db), user: UserToken = Depends(get_user)):
# return [printer_info(item) for item in db.query(Printer).order_by(Printer.name).all()]
#
#
# @router.get("/{id_}", response_model=schemas.Printer)
# def show_id(
# id_: uuid.UUID,
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["printers"]),
# ) -> schemas.Printer:
# item: Printer = db.query(Printer).filter(Printer.id == id_).first()
# return printer_info(item)
#
#
# def printer_info(item: Printer) -> schemas.Printer:
# return schemas.Printer(
# id=item.id,
# name=item.name,
# address=item.address,
# cutCode=item.cut_code,
# )
#
#
# def printer_blank() -> schemas.PrinterBlank:
# return schemas.PrinterBlank(name="", address="", cutCode="")

View File

@ -1,391 +0,0 @@
# import uuid
#
# from datetime import date, timedelta
# from typing import List
#
# import barker.schemas.product as schemas
#
# from fastapi import APIRouter, Depends, HTTPException, Security, status
# from sqlalchemy import and_, or_
# from sqlalchemy.exc import SQLAlchemyError
# from sqlalchemy.orm import Session, contains_eager, joinedload
#
# from ..core.security import get_current_active_user as get_user
# from ..db.session import SessionLocal
# from ..models.master import MenuCategory, Product, ProductVersion, SaleCategory
# from ..schemas.user_token import UserToken
# from . import effective_date
#
#
# router = APIRouter()
#
#
# # Dependency
# def get_db():
# try:
# db = SessionLocal()
# yield db
# finally:
# db.close()
#
#
# @router.post("/list", response_model=List[schemas.Product])
# def sort_order(
# data: List[schemas.Product],
# date_: date = Depends(effective_date),
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["products"]),
# ):
# try:
# indexes = {}
# for item in data:
# if item.menu_category.id_ in indexes:
# indexes[item.menu_category.id_] += 1
# else:
# indexes[item.menu_category.id_] = 0
# db.query(ProductVersion).filter(
# and_(
# ProductVersion.product_id == item.id_,
# or_(
# ProductVersion.valid_from == None, # noqa: E711
# ProductVersion.valid_from <= date_,
# ),
# or_(
# ProductVersion.valid_till == None, # noqa: E711
# ProductVersion.valid_till >= date_,
# ),
# )
# ).update({ProductVersion.sort_order: indexes[item.menu_category.id_]})
# db.commit()
# return product_list(date_, db)
# except SQLAlchemyError as e:
# db.rollback()
# raise HTTPException(
# status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
# detail=str(e),
# )
# except Exception:
# db.rollback()
# raise
#
#
# @router.post("", response_model=schemas.Product)
# def save(
# data: schemas.ProductIn,
# date_: date = Depends(effective_date),
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["products"]),
# ):
# try:
# item = Product()
# db.add(item)
# db.flush()
# product_version = ProductVersion(
# product_id=item.id,
# name=data.name,
# units=data.units,
# menu_category_id=data.menu_category.id_,
# sale_category_id=data.sale_category.id_,
# price=data.price,
# has_happy_hour=data.has_happy_hour,
# is_not_available=data.is_not_available,
# quantity=data.quantity,
# valid_from=date_,
# valid_till=None,
# )
# db.add(product_version)
# db.commit()
# return product_info(product_version)
# except SQLAlchemyError as e:
# db.rollback()
# raise HTTPException(
# status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
# detail=str(e),
# )
# except Exception:
# db.rollback()
# raise
#
#
# @router.put("/{id_}", response_model=schemas.Product)
# def update(
# id_: uuid.UUID,
# data: schemas.ProductIn,
# date_: date = Depends(effective_date),
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["products"]),
# ) -> schemas.Product:
# try:
# item: ProductVersion = (
# db.query(ProductVersion)
# .join(ProductVersion.menu_category)
# .filter(
# and_(
# ProductVersion.product_id == id_,
# or_(
# ProductVersion.valid_from == None, # noqa: E711
# ProductVersion.valid_from <= date_,
# ),
# or_(
# ProductVersion.valid_till == None, # noqa: E711
# ProductVersion.valid_till >= date_,
# ),
# )
# )
# .first()
# )
# if item.valid_till is not None:
# # Allow adding a product here splitting the valid from and to, but not implemented right now
# raise HTTPException(
# status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
# detail="Product has been invalidated",
# )
# if item.valid_from == date_: # Update the product as valid from the the same
# item.name = data.name
# item.units = data.units
# item.menu_category_id = data.menu_category.id_
# item.sale_category_id = data.sale_category.id_
# item.price = data.price
# item.has_happy_hour = data.has_happy_hour
# item.is_not_available = data.is_not_available
# item.quantity = data.quantity
# db.commit()
# return product_info(item)
# else: # Create a new version of the product from the new details
# item.valid_till = date_ - timedelta(days=1)
# product_version = ProductVersion(
# product_id=item.product_id,
# name=data.name,
# units=data.units,
# menu_category_id=data.menu_category.id_,
# sale_category_id=data.sale_category.id_,
# price=data.price,
# has_happy_hour=data.has_happy_hour,
# is_not_available=data.is_not_available,
# quantity=data.quantity,
# valid_from=date_,
# valid_till=None,
# sort_order=item.sort_order,
# )
# db.add(product_version)
# db.commit()
# return product_info(product_version)
#
# except SQLAlchemyError as e:
# db.rollback()
# raise HTTPException(
# status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
# detail=str(e),
# )
# except Exception:
# db.rollback()
# raise
#
#
# @router.delete("/{id_}")
# def delete(
# id_: uuid.UUID,
# date_: date = Depends(effective_date),
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["products"]),
# ):
# try:
# item: ProductVersion = (
# db.query(ProductVersion)
# .filter(
# and_(
# ProductVersion.product_id == id_,
# or_(
# ProductVersion.valid_from == None, # noqa: E711
# ProductVersion.valid_from <= date_,
# ),
# or_(
# ProductVersion.valid_till == None, # noqa: E711
# ProductVersion.valid_till >= date_,
# ),
# )
# )
# .first()
# )
# if item is None:
# raise HTTPException(
# status_code=status.HTTP_404_NOT_FOUND,
# detail="Product not found",
# )
# elif item.valid_from == date_:
# db.delete(item)
# else:
# item.valid_till = date_ - timedelta(days=1)
# db.commit()
# except Exception:
# db.rollback()
# raise
#
#
# @router.get("", response_model=schemas.ProductBlank)
# def show_blank(
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["products"]),
# ) -> schemas.ProductBlank:
# return schemas.ProductBlank(
# name="",
# units="",
# price=0,
# hasHappyHour=False,
# isNotAvailable=False,
# isActive=True,
# sortOrder=0,
# )
#
#
# @router.get("/list", response_model=List[schemas.Product])
# def show_list(
# date_: date = Depends(effective_date), db: Session = Depends(get_db), user: UserToken = Depends(get_user)
# ) -> List[schemas.Product]:
# return product_list(date_, db)
#
#
# def product_list(date_: date, db: Session) -> List[schemas.Product]:
# return [
# product_info(item)
# for item in db.query(ProductVersion)
# .join(ProductVersion.menu_category)
# .join(ProductVersion.sale_category)
# .filter(
# and_(
# or_(
# ProductVersion.valid_from == None, # noqa: E711
# ProductVersion.valid_from <= date_,
# ),
# or_(
# ProductVersion.valid_till == None, # noqa: E711
# ProductVersion.valid_till >= date_,
# ),
# )
# )
# .order_by(MenuCategory.sort_order)
# .order_by(MenuCategory.name)
# .order_by(ProductVersion.sort_order)
# .order_by(ProductVersion.name)
# .options(
# joinedload(ProductVersion.menu_category, innerjoin=True),
# joinedload(ProductVersion.sale_category, innerjoin=True),
# contains_eager(ProductVersion.menu_category),
# contains_eager(ProductVersion.sale_category),
# )
# .all()
# ]
#
#
# @router.get("/query")
# async def show_term(
# mc: uuid.UUID = None,
# date_: date = Depends(effective_date),
# db: Session = Depends(get_db),
# current_user: UserToken = Depends(get_user),
# ):
# list_ = []
# for item in (
# db.query(ProductVersion)
# .join(ProductVersion.sale_category)
# .join(ProductVersion.sale_category, SaleCategory.tax)
# .filter(
# and_(
# ProductVersion.menu_category_id == mc,
# or_(
# ProductVersion.valid_from == None, # noqa: E711
# ProductVersion.valid_from <= date_,
# ),
# or_(
# ProductVersion.valid_till == None, # noqa: E711
# ProductVersion.valid_till >= date_,
# ),
# )
# )
# .order_by(ProductVersion.sort_order, ProductVersion.name)
# .options(
# joinedload(ProductVersion.sale_category, innerjoin=True),
# joinedload(ProductVersion.sale_category, SaleCategory.tax, innerjoin=True),
# contains_eager(ProductVersion.sale_category),
# contains_eager(ProductVersion.sale_category, SaleCategory.tax),
# )
# .all()
# ):
# list_.append(query_product_info(item, False))
# if item.has_happy_hour:
# list_.append(query_product_info(item, True))
# return list_
#
#
# @router.get("/{id_}", response_model=schemas.Product)
# def show_id(
# id_: uuid.UUID,
# date_: date = Depends(effective_date),
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["products"]),
# ) -> schemas.Product:
# item: ProductVersion = (
# db.query(ProductVersion)
# .join(ProductVersion.sale_category)
# .join(ProductVersion.sale_category, SaleCategory.tax)
# .filter(
# and_(
# ProductVersion.product_id == id_,
# or_(
# ProductVersion.valid_from == None, # noqa: E711
# ProductVersion.valid_from <= date_,
# ),
# or_(
# ProductVersion.valid_till == None, # noqa: E711
# ProductVersion.valid_till >= date_,
# ),
# )
# )
# .order_by(ProductVersion.sort_order, ProductVersion.name)
# .options(
# joinedload(ProductVersion.sale_category, innerjoin=True),
# joinedload(ProductVersion.sale_category, SaleCategory.tax, innerjoin=True),
# contains_eager(ProductVersion.sale_category),
# contains_eager(ProductVersion.sale_category, SaleCategory.tax),
# )
# .first()
# )
# return product_info(item)
#
#
# def query_product_info(item: ProductVersion, happy_hour: bool):
# return {
# "id": item.product_id,
# "name": ("H H " if happy_hour else "") + item.full_name,
# "saleCategory": {
# "id": item.sale_category_id,
# "name": item.sale_category.name,
# },
# "tax": {
# "id": item.sale_category.tax_id,
# "name": item.sale_category.tax.name,
# "rate": item.sale_category.tax.rate,
# },
# "price": item.price,
# "hasHappyHour": happy_hour,
# "isNotAvailable": item.is_not_available,
# "sortOrder": item.sort_order,
# }
#
#
# def product_info(item: ProductVersion) -> schemas.Product:
# return schemas.Product(
# id=item.product_id,
# name=item.name,
# units=item.units,
# menuCategory=schemas.MenuCategoryLink(id=item.menu_category_id, name=item.menu_category.name),
# saleCategory=schemas.SaleCategoryLink(
# id=item.sale_category_id,
# name=item.sale_category.name,
# ),
# price=item.price,
# hasHappyHour=item.has_happy_hour,
# isNotAvailable=item.is_not_available,
# isActive=True,
# sortOrder=item.sort_order,
# )

View File

@ -1,124 +0,0 @@
import uuid
from typing import List
import luthor.schemas.act as schemas
from fastapi import APIRouter, Depends, HTTPException, Security, status
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.orm import Session
from ..core.security import get_current_active_user as get_user
from ..db.session import SessionLocal
from ..models.act import Act
from ..schemas.user_token import UserToken
router = APIRouter()
# Dependency
def get_db():
try:
db = SessionLocal()
yield db
finally:
db.close()
@router.post("", response_model=schemas.Act)
def save(
data: schemas.ActIn,
db: Session = Depends(get_db),
user: UserToken = Security(get_user, scopes=["acts"]),
) -> schemas.Act:
try:
item = Act(name=data.name)
db.add(item)
db.commit()
return act_info(item)
except SQLAlchemyError as e:
db.rollback()
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail=str(e),
)
except Exception:
db.rollback()
raise
@router.put("/{id_}", response_model=schemas.Act)
def update(
id_: uuid.UUID,
data: schemas.ActIn,
db: Session = Depends(get_db),
user: UserToken = Security(get_user, scopes=["acts"]),
) -> schemas.Act:
try:
item: Act = db.query(Act).filter(Act.id == id_).first()
item.name = data.name
db.commit()
return act_info(item)
except SQLAlchemyError as e:
db.rollback()
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail=str(e),
)
except Exception:
db.rollback()
raise
@router.delete("/{id_}", response_model=schemas.ActBlank)
def delete(
id_: uuid.UUID,
db: Session = Depends(get_db),
user: UserToken = Security(get_user, scopes=["acts"]),
) -> schemas.ActBlank:
try:
item: Act = db.query(Act).filter(Act.id == id_).first()
db.delete(item)
db.commit()
return act_blank()
except SQLAlchemyError as e:
db.rollback()
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail=str(e),
)
except Exception:
db.rollback()
raise
@router.get("", response_model=schemas.ActBlank)
def show_blank(
db: Session = Depends(get_db),
user: UserToken = Security(get_user, scopes=["acts"]),
) -> schemas.ActBlank:
return act_blank()
@router.get("/list", response_model=List[schemas.Act])
def show_list(db: Session = Depends(get_db), user: UserToken = Depends(get_user)):
return [act_info(item) for item in db.query(Act).order_by(Act.name).all()]
@router.get("/{id_}", response_model=schemas.Act)
def show_id(
id_: uuid.UUID,
db: Session = Depends(get_db),
user: UserToken = Security(get_user, scopes=["acts"]),
) -> schemas.Act:
item: Act = db.query(Act).filter(Act.id == id_).first()
return act_info(item)
def act_info(item: Act) -> schemas.Act:
return schemas.Act(id=item.id, name=item.name)
def act_blank() -> schemas.ActBlank:
return schemas.ActBlank(name="")

View File

@ -1,212 +0,0 @@
# import uuid
#
# from typing import List, Union
#
# import barker.schemas.table as schemas
#
# from fastapi import APIRouter, Depends, HTTPException, Security, status
# from sqlalchemy.exc import SQLAlchemyError
# from sqlalchemy.orm import Session
#
# from ..core.security import get_current_active_user as get_user
# from ..db.session import SessionLocal
# from ..models.master import FoodTable
# from ..models.voucher import Overview
# from ..schemas.user_token import UserToken
#
#
# router = APIRouter()
#
#
# # Dependency
# def get_db():
# try:
# db = SessionLocal()
# yield db
# finally:
# db.close()
#
#
# @router.post("/list", response_model=List[schemas.Table])
# def sort_order(
# data: List[schemas.Table],
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["sections"]),
# ) -> List[schemas.Table]:
# try:
# for index, item in enumerate(data):
# db.query(FoodTable).filter(FoodTable.id == item.id_).update({FoodTable.sort_order: index})
# db.commit()
# return [
# {
# "id": item.id,
# "name": item.name,
# "seats": item.seats,
# "section": {"id": item.section_id, "name": item.section.name},
# "isActive": item.is_active,
# "sortOrder": item.sort_order,
# }
# for item in db.query(FoodTable).order_by(FoodTable.sort_order).all()
# ]
# except SQLAlchemyError as e:
# db.rollback()
# raise HTTPException(
# status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
# detail=str(e),
# )
# except Exception:
# db.rollback()
# raise
#
#
# @router.post("", response_model=schemas.Table)
# def save(
# data: schemas.TableIn,
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["sections"]),
# ) -> schemas.Table:
# try:
# item = FoodTable(
# name=data.name,
# seats=data.seats,
# section_id=data.section.id_,
# is_active=data.is_active,
# )
# db.add(item)
# db.commit()
# return food_table_info(item)
# except SQLAlchemyError as e:
# db.rollback()
# raise HTTPException(
# status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
# detail=str(e),
# )
# except Exception:
# db.rollback()
# raise
#
#
# @router.put("/{id_}", response_model=schemas.Table)
# def update(
# id_: uuid.UUID,
# data: schemas.TableIn,
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["sections"]),
# ) -> schemas.Table:
# try:
# item: FoodTable = db.query(FoodTable).filter(FoodTable.id == id_).first()
# item.name = data.name
# item.seats = data.seats
# item.section_id = data.section.id_
# item.is_active = data.is_active
# db.commit()
# return food_table_info(item)
# except SQLAlchemyError as e:
# db.rollback()
# raise HTTPException(
# status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
# detail=str(e),
# )
# except Exception:
# db.rollback()
# raise
#
#
# @router.delete("/{id_}", response_model=schemas.TableBlank)
# def delete(
# id_: uuid.UUID,
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["sections"]),
# ) -> schemas.TableBlank:
# try:
# item: FoodTable = db.query(FoodTable).filter(FoodTable.id == id_).first()
# db.delete(item)
# db.commit()
# return food_table_blank()
# except SQLAlchemyError as e:
# db.rollback()
# raise HTTPException(
# status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
# detail=str(e),
# )
# except Exception:
# db.rollback()
# raise
#
#
# @router.get("", response_model=schemas.TableBlank)
# def show_blank(
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["sections"]),
# ) -> schemas.TableBlank:
# return food_table_blank()
#
#
# @router.get("/list", response_model=List[schemas.Table])
# def show_list(db: Session = Depends(get_db), user: UserToken = Depends(get_user)):
# return [food_table_info(item) for item in db.query(FoodTable).order_by(FoodTable.sort_order).all()]
#
#
# @router.get("/running")
# def show_running(db: Session = Depends(get_db), user: UserToken = Depends(get_user)):
# list_ = db.query(FoodTable).filter(FoodTable.is_active == True).order_by(FoodTable.sort_order).all() # noqa: E712
#
# food_tables = []
# for item in list_:
# ft = {
# "id": item.id,
# "name": item.name,
# "seats": item.seats,
# "section": {"id": item.section_id, "name": item.section.name},
# "isActive": item.is_active,
# "sortOrder": item.sort_order,
# }
# if item.status is not None:
# ft["status"] = item.status.status
# ft["voucherId"] = item.status.voucher_id
# ft["pax"] = item.status.voucher.pax
# ft["date"] = item.status.voucher.date.strftime("%d-%b-%Y %H:%M")
# ft["amount"] = item.status.voucher.amount
# if item.status.guest is not None:
# ft["guest"] = item.status.guest.customer.name
# food_tables.append(ft)
# return food_tables
#
#
# @router.get("/from-voucher/{id_}", response_model=Union[schemas.Table, schemas.TableBlank])
# def show_voucher(
# id_: uuid.UUID,
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user),
# ) -> Union[schemas.Table, schemas.TableBlank]:
# overview: Overview = db.query(Overview).filter(Overview.voucher_id == id_).first()
# if overview is not None:
# return food_table_info(overview.food_table)
# return food_table_blank()
#
#
# @router.get("/{id_}", response_model=schemas.Table)
# def show_id(
# id_: uuid.UUID,
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["sections"]),
# ) -> schemas.Table:
# item: FoodTable = db.query(FoodTable).filter(FoodTable.id == id_).first()
# return food_table_info(item)
#
#
# def food_table_info(item: FoodTable) -> schemas.Table:
# return schemas.Table(
# id=item.id,
# name=item.name,
# seats=item.seats,
# section=schemas.SectionLink(id=item.section_id, name=item.section.name),
# isActive=item.is_active,
# status="" if item.status is None else item.status.status,
# sortOrder=item.sort_order,
# voucherId=None if item.status is None else item.status.voucher_id,
# )
#
#
# def food_table_blank() -> schemas.TableBlank:
# return schemas.TableBlank(name="", seats=0, isActive=True, sortOrder=0)

View File

@ -1,178 +0,0 @@
# import re
# import uuid
#
# from decimal import Decimal
# from typing import List
#
# import barker.schemas.tax as schemas
#
# from fastapi import APIRouter, Depends, HTTPException, Security, status
# from sqlalchemy.exc import SQLAlchemyError
# from sqlalchemy.orm import Session
# from sqlalchemy.sql.functions import count
#
# from ..core.security import get_current_active_user as get_user
# from ..db.session import SessionLocal
# from ..models.master import SaleCategory, Tax
# from ..models.voucher import Inventory
# from ..schemas.user_token import UserToken
#
#
# router = APIRouter()
#
#
# # Dependency
# def get_db():
# try:
# db = SessionLocal()
# yield db
# finally:
# db.close()
#
#
# @router.post("", response_model=schemas.Tax)
# def save(
# data: schemas.TaxIn,
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["taxes"]),
# ) -> schemas.Tax:
# try:
# item = Tax(name=data.name, rate=round(data.rate, 5))
# if not name_valid(data.name):
# raise HTTPException(
# status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
# detail="The name is not valid",
# )
# db.add(item)
# db.commit()
# return tax_info(item)
# except SQLAlchemyError as e:
# db.rollback()
# raise HTTPException(
# status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
# detail=str(e),
# )
# except Exception:
# db.rollback()
# raise
#
#
# @router.put("/{id_}", response_model=schemas.Tax)
# def update(
# id_: uuid.UUID,
# data: schemas.TaxIn,
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["taxes"]),
# ) -> schemas.Tax:
# try:
# item: Tax = db.query(Tax).filter(Tax.id == id_).first()
# if item.is_fixture:
# raise HTTPException(
# status_code=status.HTTP_423_LOCKED,
# detail=f"{item.name} is a fixture and cannot be edited or deleted.",
# )
# if not name_valid(data.name):
# raise HTTPException(
# status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
# detail="The name is not valid",
# )
# item.name = data.name
# item.rate = round(data.rate, 5)
# db.commit()
# return tax_info(item)
# except SQLAlchemyError as e:
# db.rollback()
# raise HTTPException(
# status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
# detail=str(e),
# )
# except Exception:
# db.rollback()
# raise
#
#
# @router.delete("/{id_}", response_model=schemas.TaxBlank)
# def delete(
# id_: uuid.UUID,
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["taxes"]),
# ) -> schemas.TaxBlank:
# try:
# item: Tax = db.query(Tax).filter(Tax.id == id_).first()
# if item is None:
# raise HTTPException(
# status_code=status.HTTP_404_NOT_FOUND,
# detail="Tax not found",
# )
# if item.is_fixture:
# raise HTTPException(
# status_code=status.HTTP_423_LOCKED,
# detail=f"{item.name} is a fixture and cannot be edited or deleted.",
# )
# if db.query(count(SaleCategory.tax_id)).filter(SaleCategory.tax_id == item.id).scalar() > 0:
# raise HTTPException(
# status_code=status.HTTP_423_LOCKED,
# detail=f"{item.name} has associated Sale Categories and cannot be deleted",
# )
# if db.query(count(Inventory.tax_id)).filter(Inventory.tax_id == item.id).scalar() > 0:
# raise HTTPException(
# status_code=status.HTTP_423_LOCKED,
# detail=f"{item.name} has associated Inventories and cannot be deleted",
# )
# db.delete(item)
# db.commit()
# return tax_blank()
# except Exception:
# db.rollback()
# raise
#
#
# @router.get("", response_model=schemas.TaxBlank)
# def show_blank(
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["taxes"]),
# ) -> schemas.TaxBlank:
# return tax_blank()
#
#
# @router.get("/list", response_model=List[schemas.Tax])
# def show_list(db: Session = Depends(get_db), user: UserToken = Depends(get_user)) -> List[schemas.Tax]:
# return [tax_info(item) for item in db.query(Tax).order_by(Tax.name).all()]
#
#
# @router.get("/{id_}", response_model=schemas.Tax)
# def show_id(
# id_: uuid.UUID,
# db: Session = Depends(get_db),
# user: UserToken = Security(get_user, scopes=["taxes"]),
# ) -> schemas.Tax:
# item: Tax = db.query(Tax).filter(Tax.id == id_).first()
# return tax_info(item)
#
#
# def tax_info(item: Tax) -> schemas.Tax:
# return schemas.Tax(
# id=item.id,
# name=item.name,
# rate=item.rate,
# isFixture=item.is_fixture,
# )
#
#
# def tax_blank() -> schemas.TaxBlank:
# return schemas.TaxBlank(name="", rate=0, isFixture=False)
#
#
# def name_valid(name: str) -> bool:
# items = name.split(";")
# if len(items) == 1:
# return True
# total = 0
# for i, item in enumerate(it.strip() for it in items):
# match = re.match(r"(^.*)\s+\((.*?)/(.*?)\)[^(]*$", item)
# if not match or len(match.groups()) != 3:
# return False
# total += round(Decimal(match.group(2)) / Decimal(match.group(3)), 5)
# if round(total, 2) != 1:
# return False
# return True

View File

@ -21,6 +21,20 @@
formControlName="officeFileNumber"
/>
</mat-form-field>
<mat-form-field fxFlex>
<mat-label>Receipt Date</mat-label>
<input
matInput
[matDatepicker]="receiptDate"
placeholder="Receipt Date"
formControlName="receiptDate"
autocomplete="off"
#receiptDateElement
(focus)="receiptDateElement.select()"
/>
<mat-datepicker-toggle matSuffix [for]="receiptDate"></mat-datepicker-toggle>
<mat-datepicker #receiptDate></mat-datepicker>
</mat-form-field>
</div>
<div
fxLayout="row"
@ -45,6 +59,20 @@
<mat-label>Court Case Number</mat-label>
<input matInput placeholder="Court Case Number" formControlName="courtCaseNumber" />
</mat-form-field>
<mat-form-field fxFlex>
<mat-label>Filing Date</mat-label>
<input
matInput
[matDatepicker]="filingDate"
placeholder="Filing Date"
formControlName="filingDate"
autocomplete="off"
#filingDateElement
(focus)="filingDateElement.select()"
/>
<mat-datepicker-toggle matSuffix [for]="filingDate"></mat-datepicker-toggle>
<mat-datepicker #filingDate></mat-datepicker>
</mat-form-field>
</div>
<div
fxLayout="row"
@ -84,7 +112,7 @@
>
<mat-form-field fxFlex>
<mat-label>Connected Cases</mat-label>
<input matInput placeholder="Connected Cases" formControlName="connectedCases" />
<input matInput placeholder="Connected Cases" formControlName="caseConnectedWith" />
</mat-form-field>
</div>
<div
@ -136,8 +164,8 @@
</mat-select>
</mat-form-field>
<mat-form-field fxFlex>
<mat-label>Department</mat-label>
<mat-select placeholder="Department" formControlName="office">
<mat-label>Office</mat-label>
<mat-select placeholder="Office" formControlName="office">
<mat-option value=""> -- Not Applicable -- </mat-option>
<mat-option *ngFor="let o of offices | async" [value]="o.id">
{{ o.name }}
@ -154,7 +182,7 @@
>
<mat-form-field fxFlex>
<mat-label>Contact Person</mat-label>
<input matInput placeholder="Contact Person" formControlName="contactPerson" />
<input matInput placeholder="Contact Person" formControlName="contactDetail" />
</mat-form-field>
</div>
<div
@ -209,6 +237,157 @@
</mat-select>
</mat-form-field>
</div>
<div
fxLayout="row"
fxLayoutAlign="space-around start"
fxLayout.lt-md="column"
fxLayoutGap="20px"
fxLayoutGap.lt-md="0px"
>
<mat-form-field fxFlex>
<mat-label>Docket No of Departments/ Legal Cell</mat-label>
<input
matInput
placeholder="Docket No of Departments/ Legal Cell"
formControlName="docketNumber"
/>
</mat-form-field>
</div>
<div
fxLayout="row"
fxLayoutAlign="space-around start"
fxLayout.lt-md="column"
fxLayoutGap="20px"
fxLayoutGap.lt-md="0px"
>
<mat-form-field fxFlex>
<mat-label>Petition/Counter</mat-label>
<input matInput placeholder="Petition/Counter" formControlName="slpCounter" />
</mat-form-field>
</div>
<div
fxLayout="row"
fxLayoutAlign="space-around start"
fxLayout.lt-md="column"
fxLayoutGap="20px"
fxLayoutGap.lt-md="0px"
>
<mat-form-field fxFlex>
<mat-label>Question of Law</mat-label>
<input matInput placeholder="Question of Law" formControlName="questionOfLaw" />
</mat-form-field>
</div>
<div
fxLayout="row"
fxLayoutAlign="space-around start"
fxLayout.lt-md="column"
fxLayoutGap="20px"
fxLayoutGap.lt-md="0px"
>
<mat-form-field fxFlex>
<mat-label>Brief Description</mat-label>
<input matInput placeholder="(Synopsis)" formControlName="briefDescription" />
</mat-form-field>
</div>
<div
fxLayout="row"
fxLayoutAlign="space-around start"
fxLayout.lt-md="column"
fxLayoutGap="20px"
fxLayoutGap.lt-md="0px"
>
<mat-form-field fxFlex>
<mat-label>Advocate on Record</mat-label>
<input matInput placeholder="Advocate on Record" formControlName="aorName" />
</mat-form-field>
<mat-form-field fxFlex>
<mat-label>Opposing Advocate on Record</mat-label>
<input
matInput
placeholder="Opposing Advocate on Record"
formControlName="opposingCouncilAor"
/>
</mat-form-field>
</div>
<div
fxLayout="row"
fxLayoutAlign="space-around start"
fxLayout.lt-md="column"
fxLayoutGap="20px"
fxLayoutGap.lt-md="0px"
>
<mat-form-field fxFlex>
<mat-label>Previous Court Case No</mat-label>
<input
matInput
placeholder="Lower Court Case No"
formControlName="lowerCourtCaseNumber"
/>
</mat-form-field>
<mat-form-field fxFlex>
<mat-label>Date of Impunged Judgement</mat-label>
<input
matInput
[matDatepicker]="dateOfImpugnedJudgement"
placeholder="Date of Impunged Judgement"
formControlName="dateOfImpugnedJudgement"
autocomplete="off"
#dateOfImpugnedJudgementElement
(focus)="dateOfImpugnedJudgementElement.select()"
/>
<mat-datepicker-toggle
matSuffix
[for]="dateOfImpugnedJudgement"
></mat-datepicker-toggle>
<mat-datepicker #dateOfImpugnedJudgement></mat-datepicker>
</mat-form-field>
</div>
<div
fxLayout="row"
fxLayoutAlign="space-around start"
fxLayout.lt-md="column"
fxLayoutGap="20px"
fxLayoutGap.lt-md="0px"
>
<mat-form-field fxFlex>
<mat-label>Date of Limitation/Target</mat-label>
<input
matInput
[matDatepicker]="limitationDate"
placeholder="Date of Limitation/Target"
formControlName="limitationDate"
autocomplete="off"
#limitationDateElement
(focus)="limitationDateElement.select()"
/>
<mat-datepicker-toggle matSuffix [for]="limitationDate"></mat-datepicker-toggle>
<mat-datepicker #limitationDate></mat-datepicker>
</mat-form-field>
</div>
<div
fxLayout="row"
fxLayoutAlign="space-around start"
fxLayout.lt-md="column"
fxLayoutGap="20px"
fxLayoutGap.lt-md="0px"
>
<mat-form-field fxFlex>
<mat-label>Bunch Cases</mat-label>
<input matInput placeholder="Bunch Cases" formControlName="bunchCases" />
</mat-form-field>
</div>
<div
fxLayout="row"
fxLayoutAlign="space-around start"
fxLayout.lt-md="column"
fxLayoutGap="20px"
fxLayoutGap.lt-md="0px"
>
<mat-form-field fxFlex>
<mat-label>Remarks/Status</mat-label>
<input matInput placeholder="Remarks/Status" formControlName="remarks" />
</mat-form-field>
</div>
</form>
</mat-card-content>
<mat-card-actions>

View File

@ -1,3 +1,4 @@
import * as moment from 'moment';
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
import { MatDialog } from '@angular/material/dialog';
@ -111,16 +112,16 @@ export class CaseDetailComponent implements OnInit, AfterViewInit {
year: this.item.year,
title: this.item.title,
docketNumber: this.item.docketNumber,
receiptDate: this.item.receiptDate,
limitationDate: this.item.limitationDate,
filingDate: this.item.filingDate,
receiptDate: moment(this.item.receiptDate, 'DD-MMM-YYYY').toDate(),
limitationDate: moment(this.item.limitationDate, 'DD-MMM-YYYY').toDate(),
filingDate: moment(this.item.filingDate, 'DD-MMM-YYYY').toDate(),
appearOnBehalfOf: this.item.appearOnBehalfOf,
questionOfLaw: this.item.questionOfLaw,
aorName: this.item.aorName,
opposingCouncilAor: this.item.opposingCouncilAor,
opposingCouncilDetail: this.item.opposingCouncilDetail,
lowerCourtCaseNumber: this.item.lowerCourtCaseNumber,
dateOfImpugnedJudgement: this.item.dateOfImpugnedJudgement,
dateOfImpugnedJudgement: moment(this.item.dateOfImpugnedJudgement, 'DD-MMM-YYYY').toDate(),
briefDescription: this.item.briefDescription,
remarks: this.item.remarks,
slpCounter: this.item.slpCounter,

View File

@ -3,8 +3,16 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FlexLayoutModule } from '@angular/flex-layout';
import { ReactiveFormsModule } from '@angular/forms';
import { MomentDateAdapter } from '@angular/material-moment-adapter';
import { MatButtonModule } from '@angular/material/button';
import { MatCardModule } from '@angular/material/card';
import {
DateAdapter,
MAT_DATE_FORMATS,
MAT_DATE_LOCALE,
MatNativeDateModule,
} from '@angular/material/core';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatIconModule } from '@angular/material/icon';
import { MatInputModule } from '@angular/material/input';
import { MatPaginatorModule } from '@angular/material/paginator';
@ -16,6 +24,19 @@ import { CaseDetailComponent } from './case-detail/case-detail.component';
import { CaseListComponent } from './case-list/case-list.component';
import { CasesRoutingModule } from './cases-routing.module';
export const MY_FORMATS = {
parse: {
dateInput: 'DD-MMM-YYYY',
},
display: {
dateInput: 'DD-MMM-YYYY',
monthYearLabel: 'MMM YYYY',
dateA11yLabel: 'DD-MMM-YYYY',
monthYearA11yLabel: 'MMM YYYY',
},
};
@NgModule({
imports: [
CommonModule,
@ -31,7 +52,12 @@ import { CasesRoutingModule } from './cases-routing.module';
CasesRoutingModule,
MatSelectModule,
MatPaginatorModule,
MatDatepickerModule,
],
declarations: [CaseListComponent, CaseDetailComponent],
providers: [
{ provide: DateAdapter, useClass: MomentDateAdapter, deps: [MAT_DATE_LOCALE] },
{ provide: MAT_DATE_FORMATS, useValue: MY_FORMATS },
],
})
export class CasesModule {}