Fix: ValueErrors should be HTTPException
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
from datetime import date, datetime, timedelta
|
from datetime import date, datetime, timedelta
|
||||||
|
|
||||||
from barker.core.config import settings
|
from barker.core.config import settings
|
||||||
from fastapi import APIRouter, Depends, Security
|
from fastapi import APIRouter, Depends, HTTPException, Security, status
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
from sqlalchemy.sql.expression import func
|
from sqlalchemy.sql.expression import func
|
||||||
|
|
||||||
@ -35,7 +35,10 @@ def beer_consumption(
|
|||||||
if (
|
if (
|
||||||
date.today() - start_date
|
date.today() - start_date
|
||||||
).days > 5 and "accounts-audit" not in user.permissions:
|
).days > 5 and "accounts-audit" not in user.permissions:
|
||||||
raise ValueError("Accounts Audit")
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_403_FORBIDDEN,
|
||||||
|
detail="Accounts Audit",
|
||||||
|
)
|
||||||
|
|
||||||
day = func.date_trunc(
|
day = func.date_trunc(
|
||||||
"day", Voucher.date - timedelta(minutes=settings.NEW_DAY_OFFSET_MINUTES)
|
"day", Voucher.date - timedelta(minutes=settings.NEW_DAY_OFFSET_MINUTES)
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
from datetime import date, datetime, timedelta
|
from datetime import date, datetime, timedelta
|
||||||
|
|
||||||
from barker.core.config import settings
|
from barker.core.config import settings
|
||||||
from fastapi import APIRouter, Depends, Security
|
from fastapi import APIRouter, Depends, HTTPException, Security, status
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from ...core.security import get_current_active_user as get_user
|
from ...core.security import get_current_active_user as get_user
|
||||||
@ -34,7 +34,10 @@ def bill_details(
|
|||||||
if (
|
if (
|
||||||
date.today() - start_date
|
date.today() - start_date
|
||||||
).days > 5 and "accounts-audit" not in user.permissions:
|
).days > 5 and "accounts-audit" not in user.permissions:
|
||||||
raise ValueError("Accounts Audit")
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_403_FORBIDDEN,
|
||||||
|
detail="Accounts Audit",
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"startDate": start_date.strftime("%d-%b-%Y"),
|
"startDate": start_date.strftime("%d-%b-%Y"),
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import uuid
|
|||||||
|
|
||||||
from datetime import date, datetime, timedelta
|
from datetime import date, datetime, timedelta
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, Security
|
from fastapi import APIRouter, Depends, HTTPException, Security, status
|
||||||
from sqlalchemy import distinct
|
from sqlalchemy import distinct
|
||||||
from sqlalchemy.orm import Session, joinedload
|
from sqlalchemy.orm import Session, joinedload
|
||||||
|
|
||||||
@ -37,7 +37,10 @@ def active_cashiers(
|
|||||||
if (
|
if (
|
||||||
date.today() - start_date
|
date.today() - start_date
|
||||||
).days > 5 and "accounts-audit" not in user.permissions:
|
).days > 5 and "accounts-audit" not in user.permissions:
|
||||||
raise ValueError("Accounts Audit")
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_403_FORBIDDEN,
|
||||||
|
detail="Accounts Audit",
|
||||||
|
)
|
||||||
|
|
||||||
users = (
|
users = (
|
||||||
db.query(User)
|
db.query(User)
|
||||||
@ -72,7 +75,10 @@ def show_id(
|
|||||||
if (
|
if (
|
||||||
date.today() - start_date
|
date.today() - start_date
|
||||||
).days > 5 and "accounts-audit" not in user.permissions:
|
).days > 5 and "accounts-audit" not in user.permissions:
|
||||||
raise ValueError("Accounts Audit")
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_403_FORBIDDEN,
|
||||||
|
detail="Accounts Audit",
|
||||||
|
)
|
||||||
|
|
||||||
vouchers = (
|
vouchers = (
|
||||||
db.query(Voucher)
|
db.query(Voucher)
|
||||||
@ -130,7 +136,10 @@ def show_blank(
|
|||||||
if (
|
if (
|
||||||
date.today() - start_date
|
date.today() - start_date
|
||||||
).days > 5 and "accounts-audit" not in user.permissions:
|
).days > 5 and "accounts-audit" not in user.permissions:
|
||||||
raise ValueError("Accounts Audit")
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_403_FORBIDDEN,
|
||||||
|
detail="Accounts Audit",
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"startDate": start_date.strftime("%d-%b-%Y"),
|
"startDate": start_date.strftime("%d-%b-%Y"),
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
from datetime import date, datetime, timedelta
|
from datetime import date, datetime, timedelta
|
||||||
|
|
||||||
from barker.core.config import settings
|
from barker.core.config import settings
|
||||||
from fastapi import APIRouter, Depends, Security
|
from fastapi import APIRouter, Depends, HTTPException, Security, status
|
||||||
from sqlalchemy import func
|
from sqlalchemy import func
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
@ -45,7 +45,10 @@ def discount_report_view(
|
|||||||
if (
|
if (
|
||||||
date.today() - start_date
|
date.today() - start_date
|
||||||
).days > 5 and "accounts-audit" not in user.permissions:
|
).days > 5 and "accounts-audit" not in user.permissions:
|
||||||
raise ValueError("Accounts Audit")
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_403_FORBIDDEN,
|
||||||
|
detail="Accounts Audit",
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"startDate": start_date.strftime("%d-%b-%Y"),
|
"startDate": start_date.strftime("%d-%b-%Y"),
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
from datetime import date, datetime, timedelta
|
from datetime import date, datetime, timedelta
|
||||||
|
|
||||||
from barker.core.config import settings
|
from barker.core.config import settings
|
||||||
from fastapi import APIRouter, Depends, Security
|
from fastapi import APIRouter, Depends, HTTPException, Security, status
|
||||||
from sqlalchemy import func
|
from sqlalchemy import func
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
@ -44,7 +44,10 @@ def product_sale_report_view(
|
|||||||
if (
|
if (
|
||||||
date.today() - start_date
|
date.today() - start_date
|
||||||
).days > 5 and "accounts-audit" not in user.permissions:
|
).days > 5 and "accounts-audit" not in user.permissions:
|
||||||
raise ValueError("Accounts Audit")
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_403_FORBIDDEN,
|
||||||
|
detail="Accounts Audit",
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"startDate": start_date.strftime("%d-%b-%Y"),
|
"startDate": start_date.strftime("%d-%b-%Y"),
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
from datetime import date, datetime, timedelta
|
from datetime import date, datetime, timedelta
|
||||||
|
|
||||||
from barker.core.config import settings
|
from barker.core.config import settings
|
||||||
from fastapi import APIRouter, Depends, Security
|
from fastapi import APIRouter, Depends, HTTPException, Security, status
|
||||||
from sqlalchemy import func
|
from sqlalchemy import func
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
@ -45,7 +45,10 @@ def get_sale_analysis(
|
|||||||
if (
|
if (
|
||||||
date.today() - start_date
|
date.today() - start_date
|
||||||
).days > 5 and "accounts-audit" not in user.permissions:
|
).days > 5 and "accounts-audit" not in user.permissions:
|
||||||
raise ValueError("Accounts Audit")
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_403_FORBIDDEN,
|
||||||
|
detail="Accounts Audit",
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"startDate": start_date.strftime("%d-%b-%Y"),
|
"startDate": start_date.strftime("%d-%b-%Y"),
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
from datetime import date, datetime, timedelta
|
from datetime import date, datetime, timedelta
|
||||||
|
|
||||||
from barker.core.config import settings
|
from barker.core.config import settings
|
||||||
from fastapi import APIRouter, Depends, Security
|
from fastapi import APIRouter, Depends, HTTPException, Security, status
|
||||||
from sqlalchemy import func
|
from sqlalchemy import func
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
@ -35,7 +35,10 @@ def get_tax_report(
|
|||||||
if (
|
if (
|
||||||
date.today() - start_date
|
date.today() - start_date
|
||||||
).days > 5 and "accounts-audit" not in user.permissions:
|
).days > 5 and "accounts-audit" not in user.permissions:
|
||||||
raise ValueError("Accounts Audit")
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_403_FORBIDDEN,
|
||||||
|
detail="Accounts Audit",
|
||||||
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"startDate": start_date.strftime("%d-%b-%Y"),
|
"startDate": start_date.strftime("%d-%b-%Y"),
|
||||||
|
|||||||
@ -11,10 +11,9 @@ from barker.models import (
|
|||||||
VoucherType,
|
VoucherType,
|
||||||
)
|
)
|
||||||
from barker.schemas.receive_payment import ReceivePaymentItem as SettleSchema
|
from barker.schemas.receive_payment import ReceivePaymentItem as SettleSchema
|
||||||
from fastapi import HTTPException
|
from fastapi import HTTPException, status
|
||||||
from sqlalchemy import func
|
from sqlalchemy import func
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
from starlette import status
|
|
||||||
|
|
||||||
|
|
||||||
def get_tax(tax, voucher_type):
|
def get_tax(tax, voucher_type):
|
||||||
|
|||||||
Reference in New Issue
Block a user